Skip to content

Commit c11cc6a

Browse files
authored
refactor: ♻️ use ModLoaderOptionsProfile instead of Dictionary (#532)
1 parent 8170899 commit c11cc6a

File tree

1 file changed

+4
-72
lines changed

1 file changed

+4
-72
lines changed

addons/mod_loader/mod_loader_store.gd

Lines changed: 4 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -101,64 +101,12 @@ var user_profiles := {}
101101
# ModLoader cache is stored in user://mod_loader_cache.json
102102
var cache := {}
103103

104-
# These variables handle various options, which can be changed either via
104+
# Various options, which can be changed either via
105105
# Godot's GUI (with the options.tres resource file), or via CLI args.
106106
# Usage: `ModLoaderStore.ml_options.KEY`
107107
# See: res://addons/mod_loader/options/options.tres
108108
# See: res://addons/mod_loader/resources/options_profile.gd
109-
var ml_options := {
110-
enable_mods = true,
111-
log_level = ModLoaderLog.VERBOSITY_LEVEL.DEBUG,
112-
113-
# Mods that can't be disabled or enabled in a user profile (contains mod IDs as strings)
114-
locked_mods = [],
115-
116-
# Array of disabled mods (contains mod IDs as strings)
117-
disabled_mods = [],
118-
119-
# If this flag is set to true, the ModLoaderStore and ModLoader Autoloads don't have to be the first Autoloads.
120-
# The ModLoaderStore Autoload still needs to be placed before the ModLoader Autoload.
121-
allow_modloader_autoloads_anywhere = false,
122-
123-
# Application's Steam ID, used if workshop is enabled
124-
steam_id = 0,
125-
# Application's version following semver
126-
semantic_version = "0.0.0",
127-
128-
# Overrides for the path mods/configs/workshop folders are loaded from.
129-
# Only applied if custom settings are provided, either via the options.tres
130-
# resource, or via CLI args. Note that CLI args can be tested in the editor
131-
# via: Project Settings > Display> Editor > Main Run Args
132-
override_path_to_mods = "", # Default if unspecified: "res://mods" -- get with _ModLoaderPath.get_path_to_mods()
133-
override_path_to_configs = "", # Default if unspecified: "res://configs" -- get with _ModLoaderPath.get_path_to_configs()
134-
135-
# Can be used in the editor to load mods from your Steam workshop directory
136-
override_path_to_workshop = "",
137-
138-
# Override for the path where the modding hook resource pack is located.
139-
# Requires an absolute path.
140-
override_path_to_hook_pack = "", # Default if unspecified: "OS.get_executable_path().get_base_dir()" -- get with _ModLoaderPath.get_path_to_hook_pack()
141-
override_hook_pack_name = "", # Default if unspecified: "mod-hooks.zip"
142-
143-
# If true, using deprecated funcs will trigger a warning, instead of a fatal
144-
# error. This can be helpful when developing mods that depend on a mod that
145-
# hasn't been updated to fix the deprecated issues yet
146-
ignore_deprecated_errors = false,
147-
148-
# Array of mods that should be ignored when logging messages (contains mod IDs as strings)
149-
ignored_mod_names_in_log = [],
150-
151-
# Mod Sources
152-
# Indicates whether to load mods from the Steam Workshop directory, or the overridden workshop path.
153-
load_from_steam_workshop = false,
154-
# Indicates whether to load mods from the "mods" folder located at the game's install directory, or the overridden mods path.
155-
load_from_local = true,
156-
157-
# Can be used to overwrite the default scene that is displayed if a game restart is required.
158-
restart_notification_scene_path = "res://addons/mod_loader/restart_notification.tscn",
159-
# Can be used to disable the mod loader's restart logic.
160-
disable_restart = false,
161-
}
109+
var ml_options: ModLoaderOptionsProfile
162110

163111

164112
# Methods
@@ -171,20 +119,6 @@ func _init():
171119
_ModLoaderCache.init_cache(self)
172120

173121

174-
func set_option(option_name: String, new_value: Variant) -> void:
175-
ml_options[option_name] = new_value
176-
177-
match option_name:
178-
"log_level":
179-
ModLoaderLog.verbosity = new_value
180-
"ignored_mod_names_in_log":
181-
ModLoaderLog.ignored_mods = new_value
182-
183-
184-
func get_option(option_name: String) -> Variant:
185-
return ml_options[option_name]
186-
187-
188122
# Update ModLoader's options, via the custom options resource
189123
func _update_ml_options_from_options_resource() -> void:
190124
# Path to the options resource
@@ -209,8 +143,7 @@ func _update_ml_options_from_options_resource() -> void:
209143
"Please edit your options at %s. " % ml_options_path
210144
), LOG_NAME)
211145
# Update from the options in the resource
212-
for key in ml_options:
213-
set_option(key, current_options[key])
146+
ml_options = current_options
214147

215148
# Get options overrides by feature tags
216149
# An override is saved as Dictionary[String: ModLoaderOptionsProfile]
@@ -239,8 +172,7 @@ func _update_ml_options_from_options_resource() -> void:
239172
continue
240173

241174
# Update from the options in the resource
242-
for key in ml_options:
243-
set_option(key, override_options[key])
175+
ml_options = override_options
244176

245177

246178
func _exit_tree() -> void:

0 commit comments

Comments
 (0)