Skip to content

Commit

Permalink
Merge pull request #20 from piface314/feature/upscale
Browse files Browse the repository at this point in the history
v2.1.0
  • Loading branch information
piface314 authored Jan 15, 2023
2 parents b0bec88 + ba0ce5e commit 8374c19
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 14 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [2.1.0] - Cronomalia Cromática // 2023-01-15
### Added
- `ygofab make` now supports "metamacros", which are references to other fields of the card, e.g. `${@name}` becomes the card name.
- New command `ygofab unmake` turns an existing `.cdb` into a `.toml` file.
- Hologram sticker now can be either `none`, `gold` or `silver`. Still defaults to `gold`.

### Changed
- `ygofab export` and `ygofab sync` now include any `.lua` files inside `script` folder.
- Text formatting improved, also with non breaking spaces added after bullet points.
- Text formatting improved in card pics, also with non breaking spaces added after bullet points.
- Improved proxy resolution from 694x1012 to 813x1185.
- Reduced proxy assets size from ~14MB to ~12MB.
- Shortened log status bar.

### Fixed
- `ygofab compose` now correctly ignores leading and trailing whitespace.
Expand Down Expand Up @@ -103,7 +106,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Export pack to `.zip`, ready for sharing.
- Generation of `.cdb` out of textual card description.

[Unreleased]: https://github.com/piface314/ygo-fabrica/compare/v1.0.0...HEAD
[Unreleased]: https://github.com/piface314/ygo-fabrica/compare/v2.1.0...HEAD
[2.1.0]: https://github.com/piface314/ygo-fabrica/compare/v2.0.2...v2.1.0
[2.0.2]: https://github.com/piface314/ygo-fabrica/compare/v2.0.1...v2.0.2
[2.0.1]: https://github.com/piface314/ygo-fabrica/compare/v2.0.0...v2.0.1
[2.0.0]: https://github.com/piface314/ygo-fabrica/compare/v1.0.2...v2.0.0
Expand Down
9 changes: 7 additions & 2 deletions lib/logs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ function Logs.ok_s(...)
return table.concat(s)
end

local BAR_WIDTH = 32
local BAR_WIDTH = 25
local function prep_bar_label(label)
label = label or ''
local lim = 75 - BAR_WIDTH
return #label > lim and "..." .. label:sub(-lim+3, -1) or label
end
local CHAR, SPACE = '#', ' '
local FMT_WD = #(cl.FG_GREEN .. cl.BOLD .. cl.RESET)
--- Creates a progress bar with `n` steps. This bar can be printed and updated.
Expand All @@ -83,7 +88,7 @@ function Logs.bar(n)
local qt_fill = math.ceil(rate * BAR_WIDTH)
local fill, miss = CHAR:rep(qt_fill), SPACE:rep(BAR_WIDTH - qt_fill)
local s = bar_string:format(rate * 100, cl.FG_GREEN .. cl.BOLD, fill, miss,
cl.RESET, progress, n, label or '')
cl.RESET, progress, n, prep_bar_label(label))
prelabel = prelabel and prelabel .. '\n' or ''
io.write('\r', SPACE:rep(prev_s), '\r', prelabel, s)
io.flush()
Expand Down
3 changes: 3 additions & 0 deletions lib/string.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function string.trim(s)
return s:match("^%s*(.-)%s*$")
end
5 changes: 3 additions & 2 deletions locale/en.lua
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ return {
done = 'Done!'
},
unmake = {
status = 'Making %q .toml file...',
status = 'Unmaking %q into %q...',
done = 'Done!',
no_cdbfp = "missing card dataase file path",
no_tomlfp = "missing toml file path",
Expand All @@ -192,7 +192,8 @@ return {
cmd3 = {id = 'export', desc = [[Exports your project to a .zip file.]]},
cmd4 = {id = 'make', desc = [[Converts card description in .toml into a .cdb.]]},
cmd5 = {id = 'new', desc = [[Creates a new project, given a name.]]},
cmd6 = {id = 'sync', desc = [[Copies your project files to the game.]]}
cmd6 = {id = 'sync', desc = [[Copies your project files to the game.]]},
cmd7 = {id = 'unmake', desc = [[Converts a .cdb into .toml card descriptions.]]}
},
more = 'For more information, go to https://github.com/piface314/ygo-fabrica/wiki'
},
Expand Down
5 changes: 3 additions & 2 deletions locale/pt.lua
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ return {
done = 'Pronto!'
},
unmake = {
status = "Criando arquivo .toml para %q...",
status = "Desfazendo %q para %q...",
done = "Pronto!",
no_cdbfp = "caminho do arquivo .cdb não especificado",
no_tomlfp = "caminho do arquivo .toml não especificado",
Expand All @@ -194,7 +194,8 @@ return {
cmd3 = {id = 'export', desc = [[Exporta um projeto para um arquivo .zip.]]},
cmd4 = {id = 'make', desc = [[Converte cartas descritas em .toml para um .cdb.]]},
cmd5 = {id = 'new', desc = [[Cria um novo projeto, dado um nome.]]},
cmd6 = {id = 'sync', desc = [[Copia os arquivos do projeto para o jogo.]]}
cmd6 = {id = 'sync', desc = [[Copia os arquivos do projeto para o jogo.]]},
cmd7 = {id = 'unmake', desc = [[Converte um .cdb em descrições de carta em .toml.]]}
},
more = 'Para mais informações, vá em https://github.com/piface314/ygo-fabrica/wiki'
},
Expand Down
3 changes: 2 additions & 1 deletion scripts/composer/data-fetcher.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ local sqlite = require 'lsqlite3complete'
local Logs = require 'lib.logs'
local i18n = require 'i18n'
local fun = require 'lib.fun'
require 'lib.string'

---Reads data from a card database (.cdb file)
local DataFetcher = {}
Expand All @@ -17,7 +18,7 @@ local ESC_CHAR = '[' .. table.concat(fun.iter(ESC_REPL):totable()) .. ']'
---@param text string
---@return string
local function escape(text)
return text:gsub(ESC_CHAR, ESC_REPL):match("^%s*(.-)%s*$")
return text:gsub(ESC_CHAR, ESC_REPL):trim()
end

local VALID_EXT = {jpg = true, png = true, jpeg = true}
Expand Down
9 changes: 5 additions & 4 deletions scripts/composer/parser.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local Codes = require 'lib.codes'
require 'lib.string'

--- Groups helper functions to parse card data
local Parser = {}
Expand Down Expand Up @@ -74,7 +75,7 @@ function Parser.get_level(card) return bit.band(card.level, 0x0000FFFF) end
--- @return number
function Parser.get_link_arrows(card) return bit.band(card.def, Codes.const.link.ALL) end

local PEND_DESC_PAT = '^%s*%[.-%]%s*(.-)%s*[-_][-_][-_]+%s*%[.-%]%s*(.-)%s*$'
local PEND_DESC_PAT = '^.-%[.-%]%s*(.-)%s*[-_][-_][-_]+%s*%[.-%]%s*(.-)%s*$'
--- Returns card effect, taking into account that `desc` field in the
--- database can contain Pendulum Effect/Monster Effect/Flavor Text.
--- @param card CardData
Expand All @@ -84,10 +85,10 @@ function Parser.get_effects(card)
local desc = card.desc
if Parser.bcheck(card.type, types.PENDULUM) then
local pe, me = desc:match(PEND_DESC_PAT)
if not pe then return desc end
return me, pe
if not pe then return desc:trim() end
return me:trim(), pe:trim()
else
return desc
return desc:trim()
end
end

Expand Down
1 change: 1 addition & 0 deletions scripts/config/values.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ local fun = require 'lib.fun'
local Schema = require 'scripts.config.schema'
local Logs = require 'lib.logs'
local i18n = require 'i18n'
require 'lib.table'

local Config = {
groups = {from_flag = {}},
Expand Down
3 changes: 3 additions & 0 deletions scripts/make/encoder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ end
local holo = {none = 0, gold = 1, silver = 2}
function encode.holo(card)
if card.holo ~= nil then
if type(card.holo) == "boolean" then
card.holo = card.holo and "gold" or "none"
end
local key = card.holo:match '^%s*(.-)%s*$':lower()
return holo[key] or 0
end
Expand Down
2 changes: 1 addition & 1 deletion scripts/unmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ local i18n = require 'i18n'
return function(flags, cdbfp, tomlfp)
Logs.assert(cdbfp, i18n 'unmake.no_cdbfp')
Logs.assert(tomlfp, i18n 'unmake.no_tomlfp')
Logs.info(i18n('unmake.status', {tomlfp}))
Logs.info(i18n('unmake.status', {cdbfp, tomlfp}))
local data = DataFetcher.get(cdbfp)
local cards = Decoder.decode(data)
Writer.write(tomlfp, cards)
Expand Down

0 comments on commit 8374c19

Please sign in to comment.