diff --git a/Cryptlib/content_sets.lua b/Cryptlib/content_sets.lua index bc5e555..8ab7828 100644 --- a/Cryptlib/content_sets.lua +++ b/Cryptlib/content_sets.lua @@ -116,6 +116,9 @@ function Card:click() card_in_collection(self) and G.ACTIVE_MOD_UI and (Spectrallib.mod_gameset_whitelist[G.ACTIVE_MOD_UI.id] or G.ACTIVE_MOD_UI.id == "Spectrallib") ) then + if Spectrallib.has_ongoing_run() then + return + end if not self.config.center or self.config.center and self.config.center.set == "Default" then --make a fake center local old_force_gameset = self.config.center and self.config.center.force_gameset @@ -147,6 +150,9 @@ end ---@param center table ---@return nil function Spectrallib.gameset_config_UI(center) + if Spectrallib.has_ongoing_run() then + return + end center = center or G.viewedContentSet local content_set_selected = center.set == "Content Set" @@ -268,6 +274,9 @@ end ---@param gameset "modest"|"mainline"|"madness" ---@return nil function Card:cry_set_gameset(center, gameset) + if Spectrallib.has_ongoing_run() then + return + end local current_save = G.PROFILES[G.SETTINGS.profile] local gameset_already_set = current_save.cry_gameset == gameset @@ -293,6 +302,9 @@ end ---@return nil function G.FUNCS.reset_gameset_config() + if Spectrallib.has_ongoing_run() then + return + end G.PROFILES[G.SETTINGS.profile].cry_gameset_overrides = nil Spectrallib.update_obj_registry() G:save_progress() @@ -658,6 +670,9 @@ G.P_CENTER_POOLS["Content Set"] = {} -- these are mostly copy/paste from vanilla code G.FUNCS.your_collection_content_sets = function(e) + if Spectrallib.has_ongoing_run() then + return + end G.cry_prev_collec = "your_collection_content_sets" G.SETTINGS.paused = true G.FUNCS.overlay_menu({ @@ -1206,6 +1221,47 @@ SMODS.Atlas.inject = function(self) end end +-- Hook to display ongoing game warning on mod additions tab +local bat = buildAdditionsTab +function buildAdditionsTab(mod) + local tab = bat(mod) + if + tab + and mod + and (Spectrallib.mod_gameset_whitelist[mod.id] or mod.id == "Spectrallib") + and Spectrallib.has_ongoing_run() + then + local old_tab_def = tab.tab_definition_function + tab.tab_definition_function = function(...) + local res = old_tab_def(...) + local warning_node = { + n = G.UIT.R, + config = { align = "cm" }, + nodes = { + { + n = G.UIT.O, + config = { + object = DynaText({ + string = localize("cry_gameset_ongoing_warning"), + colours = { G.C.RED }, + shadow = true, + scale = 0.32, + }), + }, + }, + }, + } + local new_nodes = { warning_node } + for _, node in ipairs(res.nodes) do + new_nodes[#new_nodes + 1] = node + end + res.nodes = new_nodes + return res + end + end + return tab +end + -- add second back button to create_UIBox_generic_options local cuigo = create_UIBox_generic_options function create_UIBox_generic_options(args) diff --git a/Spectrallib/other_utils.lua b/Spectrallib/other_utils.lua index 1b380e7..030efcd 100644 --- a/Spectrallib/other_utils.lua +++ b/Spectrallib/other_utils.lua @@ -11,6 +11,16 @@ function Spectrallib.can_mods_load(...) end end +---@return boolean +function Spectrallib.has_ongoing_run() + return (G.STAGE == G.STAGES.RUN) + or not not ( + G.SETTINGS + and G.SETTINGS.profile + and love.filesystem.getInfo(G.SETTINGS.profile .. "/" .. "save.jkr") + ) +end + -- Check if an optional feature is enabled by *any* enabled mod. ---@param key string ---@return true|nil diff --git a/localization/en-us.lua b/localization/en-us.lua index 82ccc38..4262134 100644 --- a/localization/en-us.lua +++ b/localization/en-us.lua @@ -341,6 +341,7 @@ return { b_content_sets = "Thematic Sets", cry_view_set_contents = "View Items in Set", cry_set_enable_features = "Use this section to enable or disable entire Thematic Sets.", + cry_gameset_ongoing_warning = "(Gameset config options cannot be toggled while you have an ongoing game)", cry_family = "Family Friendly Mode", slib_exp_colours = "Exponential Chips and Mult colours",