From b834b1ec3c45d08f26ee4cb27439efae92ef0eef Mon Sep 17 00:00:00 2001 From: Nano Miratus Date: Wed, 16 Apr 2025 04:29:45 +0200 Subject: [PATCH 1/3] make perkeo on title screen optional and configurable --- main.lua | 108 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 90 insertions(+), 18 deletions(-) diff --git a/main.lua b/main.lua index 1a766a3..3e4a1f0 100644 --- a/main.lua +++ b/main.lua @@ -6,29 +6,101 @@ function Card:resize(mod, force_save) self:set_sprites(self.config.center, self.base.id and self.config.card) end -local mainmenuref2 = Game.main_menu -Game.main_menu = function(change_context) - - local ret = mainmenuref2(change_context) - - --Replace j_unik_unik with 'j_perkeo' or any other card - local newcard = SMODS.create_card({key='j_perkeo', edition='e_negative',area = G.title_top}) - G.title_top.T.w = G.title_top.T.w * 1.7675 - G.title_top.T.x = G.title_top.T.x - 0.8 - G.title_top:emplace(newcard) - newcard:start_materialize() - newcard:resize(1.1 * 1.2) - newcard.no_ui = true - return ret +-- Get the mod's config +local config = SMODS.current_mod.config or {} +-- Set default config value if not present +if config.title == nil then + config.title = true +end +-- Store initial config state for comparison +local perkolator_enabled = copy_table(config) + +-- Add restart function to determine if restart is needed +function G.FUNCS.perkolator_restart() + local config_changed = false + for k, v in pairs(perkolator_enabled) do + if v ~= config[k] then + config_changed = true + break + end + end + + if config_changed then + SMODS.full_restart = 1 + else + SMODS.full_restart = 0 + end +end + +-- Add a configuration menu for the Perkolating mod +SMODS.current_mod.config_tab = function() + local perkolator_nodes = {{ + n = G.UIT.R, + config = { + align = "cm" + }, + nodes = {{ + n = G.UIT.O, + config = { + object = DynaText({ + string = "Options:", + colours = {G.C.WHITE}, + shadow = true, + scale = 0.4 + }) + } + }} + }, create_toggle({ + label = "Perkeo Card on Title Screen (Requires Restart)", + ref_table = config, + ref_value = "title", + callback = G.FUNCS.perkolator_restart + })} + + return { + n = G.UIT.ROOT, + config = { + emboss = 0.05, + minh = 6, + r = 0.1, + minw = 10, + align = "cm", + padding = 0.2, + colour = G.C.BLACK + }, + nodes = perkolator_nodes + } +end + +-- Modify the main menu only if the title screen change is enabled +if config["title"] then + local mainmenuref2 = Game.main_menu + Game.main_menu = function(change_context) + local ret = mainmenuref2(change_context) + + -- Replace j_unik_unik with 'j_perkeo' or any other card + local newcard = SMODS.create_card({ + key = 'j_perkeo', + edition = 'e_negative', + area = G.title_top + }) + G.title_top.T.w = G.title_top.T.w * 1.7675 + G.title_top.T.x = G.title_top.T.x - 0.8 + G.title_top:emplace(newcard) + newcard:start_materialize() + newcard:resize(1.1 * 1.2) + newcard.no_ui = true + return ret + end end SMODS.current_mod.optional_features = function() return { - retrigger_joker = true + retrigger_joker = true } - end - - --loads mod componets +end + +-- loads mod componets assert(SMODS.load_file('jokers.lua'))() assert(SMODS.load_file('rarity.lua'))() From 4ac8c83fcfed178266b82124cb23b515f4d47a4b Mon Sep 17 00:00:00 2001 From: Nano Miratus Date: Wed, 16 Apr 2025 05:48:33 +0200 Subject: [PATCH 2/3] rename config variable --- main.lua | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/main.lua b/main.lua index 3e4a1f0..19b0d78 100644 --- a/main.lua +++ b/main.lua @@ -7,19 +7,25 @@ function Card:resize(mod, force_save) end -- Get the mod's config -local config = SMODS.current_mod.config or {} --- Set default config value if not present -if config.title == nil then - config.title = true +local perkolator_config = SMODS.current_mod.config +-- Create config if it doesn't exist +if not perkolator_config then + perkolator_config = { + title = true + } + SMODS.current_mod.config = perkolator_config + -- Set default value if config exists but title setting doesn't +elseif perkolator_config.title == nil then + perkolator_config.title = true end -- Store initial config state for comparison -local perkolator_enabled = copy_table(config) +local perkolator_enabled = copy_table(perkolator_config) -- Add restart function to determine if restart is needed function G.FUNCS.perkolator_restart() local config_changed = false for k, v in pairs(perkolator_enabled) do - if v ~= config[k] then + if v ~= perkolator_config[k] then config_changed = true break end @@ -52,7 +58,7 @@ SMODS.current_mod.config_tab = function() }} }, create_toggle({ label = "Perkeo Card on Title Screen (Requires Restart)", - ref_table = config, + ref_table = perkolator_config, ref_value = "title", callback = G.FUNCS.perkolator_restart })} From 8390193bb2ecc6ebc2854ffaca30ee431e2028ad Mon Sep 17 00:00:00 2001 From: Nano Miratus Date: Sun, 20 Apr 2025 19:43:21 +0200 Subject: [PATCH 3/3] fix missed rename --- main.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.lua b/main.lua index 19b0d78..534b2f3 100644 --- a/main.lua +++ b/main.lua @@ -79,7 +79,7 @@ SMODS.current_mod.config_tab = function() end -- Modify the main menu only if the title screen change is enabled -if config["title"] then +if perkolator_config["title"] then local mainmenuref2 = Game.main_menu Game.main_menu = function(change_context) local ret = mainmenuref2(change_context)