From c8b689f283c8f4454e07f523446bd91be2574e62 Mon Sep 17 00:00:00 2001 From: Henrique Santana Date: Sun, 27 Nov 2022 15:57:52 -0300 Subject: [PATCH 1/6] Fixed `make` holo option --- CHANGELOG.md | 2 +- scripts/make/encoder.lua | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 031145e..3b35100 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -103,7 +103,7 @@ 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.0.2...HEAD [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 diff --git a/scripts/make/encoder.lua b/scripts/make/encoder.lua index 656bf05..558fcd3 100644 --- a/scripts/make/encoder.lua +++ b/scripts/make/encoder.lua @@ -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 From 8dccf3fe6230ab50d26253f2c2c71394540b2621 Mon Sep 17 00:00:00 2001 From: Henrique Santana Date: Sun, 27 Nov 2022 19:36:09 -0300 Subject: [PATCH 2/6] Changed `unmake` status message --- locale/en.lua | 2 +- locale/pt.lua | 2 +- scripts/unmake.lua | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/en.lua b/locale/en.lua index 9de69ef..27337cc 100644 --- a/locale/en.lua +++ b/locale/en.lua @@ -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", diff --git a/locale/pt.lua b/locale/pt.lua index 88f4feb..cb24833 100644 --- a/locale/pt.lua +++ b/locale/pt.lua @@ -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", diff --git a/scripts/unmake.lua b/scripts/unmake.lua index 1baaccf..40613e9 100644 --- a/scripts/unmake.lua +++ b/scripts/unmake.lua @@ -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) From 87220be3283fb4d6cb8fb6a783019a01e3275dc2 Mon Sep 17 00:00:00 2001 From: Henrique Santana Date: Sun, 27 Nov 2022 19:36:29 -0300 Subject: [PATCH 3/6] Shortened log bar --- lib/logs.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/logs.lua b/lib/logs.lua index 7a10e44..b54d8c9 100644 --- a/lib/logs.lua +++ b/lib/logs.lua @@ -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. @@ -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() From 052325a929264ef2552b6b97e8a0a81ae612583f Mon Sep 17 00:00:00 2001 From: Henrique Santana Date: Sun, 27 Nov 2022 19:37:24 -0300 Subject: [PATCH 4/6] Fixed pendulum effect text parsing --- lib/string.lua | 3 +++ scripts/composer/data-fetcher.lua | 3 ++- scripts/composer/parser.lua | 9 +++++---- 3 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 lib/string.lua diff --git a/lib/string.lua b/lib/string.lua new file mode 100644 index 0000000..da8069d --- /dev/null +++ b/lib/string.lua @@ -0,0 +1,3 @@ +function string.trim(s) + return s:match("^%s*(.-)%s*$") +end \ No newline at end of file diff --git a/scripts/composer/data-fetcher.lua b/scripts/composer/data-fetcher.lua index 8cbeaa7..591c264 100644 --- a/scripts/composer/data-fetcher.lua +++ b/scripts/composer/data-fetcher.lua @@ -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 = {} @@ -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} diff --git a/scripts/composer/parser.lua b/scripts/composer/parser.lua index e49022a..049fee6 100644 --- a/scripts/composer/parser.lua +++ b/scripts/composer/parser.lua @@ -1,4 +1,5 @@ local Codes = require 'lib.codes' +require 'lib.string' --- Groups helper functions to parse card data local Parser = {} @@ -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 @@ -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 From bc09bca8068dc3153678ad5ece9b8c53436934a4 Mon Sep 17 00:00:00 2001 From: Henrique Santana Date: Sun, 27 Nov 2022 19:38:57 -0300 Subject: [PATCH 5/6] Updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b35100..f96483e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Text formatting improved, 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. From ba0ce5e7526f43035d7867860b703aec262bacc7 Mon Sep 17 00:00:00 2001 From: Henrique Santana Date: Sun, 15 Jan 2023 13:08:33 -0300 Subject: [PATCH 6/6] Updated CHANGELOG and strings --- CHANGELOG.md | 7 +++++-- locale/en.lua | 3 ++- locale/pt.lua | 3 ++- scripts/config/values.lua | 1 + 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f96483e..0688329 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ 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. @@ -12,7 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### 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. @@ -104,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/v2.0.2...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 diff --git a/locale/en.lua b/locale/en.lua index 27337cc..47d46ff 100644 --- a/locale/en.lua +++ b/locale/en.lua @@ -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' }, diff --git a/locale/pt.lua b/locale/pt.lua index cb24833..111730b 100644 --- a/locale/pt.lua +++ b/locale/pt.lua @@ -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' }, diff --git a/scripts/config/values.lua b/scripts/config/values.lua index 0ca2f00..1b84e9d 100644 --- a/scripts/config/values.lua +++ b/scripts/config/values.lua @@ -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 = {}},