Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions Cryptlib/content_sets.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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

Expand All @@ -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()
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions Spectrallib/other_utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions localization/en-us.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down