Fix mod options not loading

The initialization for the options view happened before a few necessary
systems where setup by the game.
This commit is contained in:
Lucas Schwiderski 2023-07-22 14:36:50 +02:00
parent 108696135d
commit e4a2ecdd4b
Signed by: lucas
GPG key ID: AA12679AAA6DF4D8
3 changed files with 32 additions and 21 deletions

View file

@ -97,6 +97,13 @@ end
function dmf_mod_object:on_game_state_changed(status, state)
print("DMF:ON_GAME_STATE_CHANGED(), status: " .. tostring(status) .. ", state: " .. tostring(state))
-- Certain intialization procedures need to be delayed until the game's core systems are
-- fully initialized and running
if status == "enter" and state == "StateTitle" then
dmf.initialize_options()
end
dmf.mods_game_state_changed_event(status, state)
dmf.save_unsaved_settings_to_file()
dmf.apply_delayed_hooks()

View file

@ -170,11 +170,13 @@ function dmf.initialize_mod_data(mod, mod_data)
-- Mod's options initialization
if mod_data.options or (not mod_data.is_mutator and not mod_data.options_widgets) then
local success, error_message = pcall(dmf.initialize_mod_options, mod, mod_data.options)
if not success then
mod:error(ERRORS.REGULAR.mod_options_initializing_failed, error_message)
return
end
dmf.safe_call(
dmf,
ERRORS.REGULAR.mod_options_initializing_failed,
dmf.initialize_mod_options,
mod,
mod_data.options
)
end
-- Textures initialization @TODO: move to a separate function

View file

@ -257,11 +257,12 @@ end
-- ##### Script #######################################################################################################
-- ####################################################################################################################
dmf.initialize_mod_data(dmf, dmf_mod_data)
dmf.initialize_options = function()
dmf.initialize_mod_data(dmf, dmf_mod_data)
-- first DMF initialization
-- it will be run only 1 time, when the player launch the game with DMF for the first time
if not dmf:get("dmf_initialized") then
-- first DMF initialization
-- it will be run only 1 time, when the player launch the game with DMF for the first time
if not dmf:get("dmf_initialized") then
dmf.load_logging_settings()
dmf.load_developer_mode_settings()
@ -277,4 +278,5 @@ if not dmf:get("dmf_initialized") then
dmf:notify(dmf:localize("dmf_first_run_notification"))
dmf:set("dmf_initialized", true)
end
end