Skip to content

Commit 0e78f89

Browse files
committed
unified parameters
1 parent aa8c606 commit 0e78f89

File tree

8 files changed

+215
-164
lines changed

8 files changed

+215
-164
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ addons/mod_loader/mod_loader_setup.gd export-ignore
1616

1717
# Used during docs generation, but not relevant for addon users
1818
project.godot export-ignore
19+
main.tscn export-ignore
1920
icon.png export-ignore

addons/mod_loader/api/config.gd

+44-40
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ const DEFAULT_CONFIG_NAME := "default"
1212
## Creates a new configuration for a mod.[br]
1313
## [br]
1414
## [b]Parameters:[/b][br]
15-
## - [code]mod_id[/code] ([String]): The ID of the mod.[br]
16-
## - [code]config_name[/code] ([String]): The name of the configuration.[br]
17-
## - [code]config_data[/code] ([Dictionary]): The configuration data to be stored.[br]
15+
## - [param mod_id] ([String]): The ID of the mod.[br]
16+
## - [param config_name] ([String]): The name of the configuration.[br]
17+
## - [param config_data] ([Dictionary]): The configuration data to be stored.[br]
1818
## [br]
1919
## [b]Returns:[/b][br]
20-
## - [ModConfig]: The created ModConfig object if successful, or null otherwise.
20+
## - [ModConfig]: The created [ModConfig] object if successful, or null otherwise.
2121
static func create_config(mod_id: String, config_name: String, config_data: Dictionary) -> ModConfig:
2222
var default_config: ModConfig = get_default_config(mod_id)
2323
if not default_config:
@@ -72,7 +72,7 @@ static func create_config(mod_id: String, config_name: String, config_data: Dict
7272
## Updates an existing [ModConfig] object with new data and saves the config file.[br]
7373
## [br]
7474
## [b]Parameters:[/b][br]
75-
## - [code]config[/code] ([ModConfig]): The [ModConfig] object to be updated.[br]
75+
## - [param config] ([ModConfig]): The [ModConfig] object to be updated.[br]
7676
## [br]
7777
## [b]Returns:[/b][br]
7878
## - [ModConfig]: The updated [ModConfig] object if successful, or null otherwise.
@@ -104,10 +104,10 @@ static func update_config(config: ModConfig) -> ModConfig:
104104
## Deletes a [ModConfig] object and performs cleanup operations.[br]
105105
## [br]
106106
## [b]Parameters:[/b][br]
107-
## - [code]config[/code] ([ModConfig]): The [ModConfig] object to be deleted.[br]
107+
## - [param config] ([ModConfig]): The [ModConfig] object to be deleted.[br]
108108
## [br]
109109
## [b]Returns:[/b][br]
110-
## - [code]bool[/code]: True if the deletion was successful, False otherwise.
110+
## - [bool]: True if the deletion was successful, False otherwise.
111111
static func delete_config(config: ModConfig) -> bool:
112112
# Check if the config is the "default" config, which cannot be deleted
113113
if config.name == DEFAULT_CONFIG_NAME:
@@ -131,15 +131,15 @@ static func delete_config(config: ModConfig) -> bool:
131131
## Sets the current configuration of a mod to the specified configuration.[br]
132132
## [br]
133133
## [b]Parameters:[/b][br]
134-
## - [code]config[/code] ([ModConfig]): The [ModConfig] object to be set as current config.
134+
## - [param config] ([ModConfig]): The [ModConfig] object to be set as current config.
135135
static func set_current_config(config: ModConfig) -> void:
136136
ModLoaderStore.mod_data[config.mod_id].current_config = config
137137

138138

139139
## Returns the schema for the specified mod id.[br]
140140
## [br]
141141
## [b]Parameters:[/b][br]
142-
## - [code]mod_id[/code] (String): the ID of the mod.[br]
142+
## - [param mod_id] ([String]): The ID of the mod.[br]
143143
## [br]
144144
## [b]Returns:[/b][br]
145145
## - A dictionary representing the schema for the mod's configuration file.
@@ -158,8 +158,8 @@ static func get_config_schema(mod_id: String) -> Dictionary:
158158
## Retrieves the schema for a specific property key.[br]
159159
## [br]
160160
## [b]Parameters:[/b][br]
161-
## - [code]config[/code] ([ModConfig]): The [ModConfig] object from which to retrieve the schema.[br]
162-
## - [code]prop[/code] ([String]): The property key for which to retrieve the schema.[br]
161+
## - [param config] ([ModConfig]): The [ModConfig] object from which to retrieve the schema.[br]
162+
## - [param prop] ([String]): The property key for which to retrieve the schema.[br]
163163
## [br]
164164
## [b]Returns:[/b][br]
165165
## - [Dictionary]: The schema dictionary for the specified property.
@@ -182,16 +182,16 @@ static func get_schema_for_prop(config: ModConfig, prop: String) -> Dictionary:
182182
return schema_for_prop
183183

184184

185-
## Recursively traverses the schema dictionary based on the provided [code]prop_key_array[/code]
186-
## and returns the corresponding schema for the target property.[br]
187-
##[br]
188-
## [b]Parameters:[/b][br]
189-
## - [code]schema_prop[/code]: The current schema dictionary to traverse.[br]
190-
## - [code]prop_key_array[/code]: An array containing the property keys representing the path to the target property.[br]
191-
##[br]
192-
## [b]Returns:[/b][br]
193-
## The schema dictionary corresponding to the target property specified by the [code]prop_key_array[/code].[br]
194-
## If the target property is not found, an empty dictionary is returned.
185+
# Recursively traverses the schema dictionary based on the provided [code]prop_key_array[/code]
186+
# and returns the corresponding schema for the target property.[br]
187+
# [br]
188+
# [b]Parameters:[/b][br]
189+
# - [param schema_prop]: The current schema dictionary to traverse.[br]
190+
# - [param prop_key_array]: An array containing the property keys representing the path to the target property.[br]
191+
# [br]
192+
# [b]Returns:[/b][br]
193+
# - [Dictionary]: The schema dictionary corresponding to the target property specified by the [code]prop_key_array[/code].
194+
# If the target property is not found, an empty dictionary is returned.
195195
static func _traverse_schema(schema_prop: Dictionary, prop_key_array: Array) -> Dictionary:
196196
# Return the current schema_prop if the prop_key_array is empty (reached the destination property)
197197
if prop_key_array.is_empty():
@@ -219,7 +219,7 @@ static func _traverse_schema(schema_prop: Dictionary, prop_key_array: Array) ->
219219
## Retrieves an Array of mods that have configuration files.[br]
220220
## [br]
221221
## [b]Returns:[/b][br]
222-
## - An Array containing the mod data of mods that have configuration files.
222+
## - [Array]: An Array containing the mod data of mods that have configuration files.
223223
static func get_mods_with_config() -> Array:
224224
# Create an empty array to store mods with configuration files
225225
var mods_with_config := []
@@ -241,10 +241,10 @@ static func get_mods_with_config() -> Array:
241241
## Retrieves the configurations dictionary for a given mod ID.[br]
242242
## [br]
243243
## [b]Parameters:[/b][br]
244-
## - [code]mod_id[/code]: The ID of the mod.[br]
244+
## - [param mod_id]: The ID of the mod.[br]
245245
## [br]
246246
## [b]Returns:[/b][br]
247-
## - A dictionary containing the configurations for the specified mod.
247+
## - [Dictionary]: A dictionary containing the configurations for the specified mod.
248248
## If the mod ID is invalid or no configurations are found, an empty dictionary is returned.
249249
static func get_configs(mod_id: String) -> Dictionary:
250250
# Check if the mod ID is invalid
@@ -265,11 +265,11 @@ static func get_configs(mod_id: String) -> Dictionary:
265265
## Retrieves the configuration for a specific mod and configuration name.[br]
266266
## [br]
267267
## [b]Parameters:[/b][br]
268-
## - [code]mod_id[/code] ([String]): The ID of the mod.[br]
269-
## - [code]config_name[/code] ([String]): The name of the configuration.[br]
268+
## - [param mod_id] ([String]): The ID of the mod.[br]
269+
## - [param config_name] ([String]): The name of the configuration.[br]
270270
## [br]
271271
## [b]Returns:[/b][br]
272-
## - The configuration as a [ModConfig] object or null if not found.
272+
## - [ModConfig]: The configuration as a [ModConfig] object or null if not found.
273273
static func get_config(mod_id: String, config_name: String) -> ModConfig:
274274
var configs := get_configs(mod_id)
275275

@@ -283,10 +283,10 @@ static func get_config(mod_id: String, config_name: String) -> ModConfig:
283283
## Checks whether a mod has a current configuration set.[br]
284284
## [br]
285285
## [b]Parameters:[/b][br]
286-
## - [code]mod_id[/code] ([String]): The ID of the mod.[br]
286+
## - [param mod_id] ([String]): The ID of the mod.[br]
287287
## [br]
288288
## [b]Returns:[/b][br]
289-
## - [code]bool[/code]: True if the mod has a current configuration, False otherwise.
289+
## - [bool]: True if the mod has a current configuration, false otherwise.
290290
static func has_current_config(mod_id: String) -> bool:
291291
var mod_data := ModLoaderMod.get_mod_data(mod_id)
292292
return not mod_data.current_config == null
@@ -295,11 +295,11 @@ static func has_current_config(mod_id: String) -> bool:
295295
## Checks whether a mod has a configuration with the specified name.[br]
296296
## [br]
297297
## [b]Parameters:[/b][br]
298-
## - [code]mod_id[/code] ([String]): The ID of the mod.[br]
299-
## - [code]config_name[/code] ([String]): The name of the configuration.[br]
298+
## - [param mod_id] ([String]): The ID of the mod.[br]
299+
## - [param config_name] ([String]): The name of the configuration.[br]
300300
## [br]
301301
## [b]Returns:[/b][br]
302-
## - [code]bool[/code]: True if the mod has a configuration with the specified name, False otherwise.
302+
## - [bool]: True if the mod has a configuration with the specified name, False otherwise.
303303
static func has_config(mod_id: String, config_name: String) -> bool:
304304
var mod_data := ModLoaderMod.get_mod_data(mod_id)
305305
return mod_data.configs.has(config_name)
@@ -308,10 +308,10 @@ static func has_config(mod_id: String, config_name: String) -> bool:
308308
## Retrieves the default configuration for a specified mod ID.[br]
309309
## [br]
310310
## [b]Parameters:[/b][br]
311-
## - [code]mod_id[/code]: The ID of the mod.[br]
311+
## - [param mod_id] ([String]): The ID of the mod.[br]
312312
## [br]
313313
## [b]Returns:[/b][br]
314-
## - The [ModConfig] object representing the default configuration for the specified mod.
314+
## - [ModConfig]: The [ModConfig] object representing the default configuration for the specified mod.
315315
## If the mod ID is invalid or no configuration is found, returns null.
316316
static func get_default_config(mod_id: String) -> ModConfig:
317317
return get_config(mod_id, DEFAULT_CONFIG_NAME)
@@ -320,10 +320,10 @@ static func get_default_config(mod_id: String) -> ModConfig:
320320
## Retrieves the currently active configuration for a specific mod.[br]
321321
## [br]
322322
## [b]Parameters:[/b][br]
323-
## - [code]mod_id[/code] ([String]): The ID of the mod.[br]
323+
## - [param mod_id] ([String]): The ID of the mod.[br]
324324
## [br]
325325
## [b]Returns:[/b][br]
326-
## - The configuration as a [ModConfig] object or [code]null[/code] if not found.
326+
## - [ModConfig]: The configuration as a [ModConfig] object or [code]null[/code] if not found.
327327
static func get_current_config(mod_id: String) -> ModConfig:
328328
var current_config_name := get_current_config_name(mod_id)
329329
var current_config: ModConfig
@@ -341,10 +341,10 @@ static func get_current_config(mod_id: String) -> ModConfig:
341341
## Retrieves the name of the current configuration for a specific mod.[br]
342342
## [br]
343343
## [b]Parameters:[/b][br]
344-
## - [code]mod_id[/code] ([String]): The ID of the mod.[br]
344+
## - [param mod_id] ([String]): The ID of the mod.[br]
345345
## [br]
346346
## [b]Returns:[/b][br]
347-
## - The currently active configuration name for the given mod id or an empty string if not found.
347+
## - [String] The currently active configuration name for the given mod id or an empty string if not found.
348348
static func get_current_config_name(mod_id: String) -> String:
349349
# Check if user profile has been loaded
350350
if not ModLoaderStore.current_user_profile or not ModLoaderStore.user_profiles.has(ModLoaderStore.current_user_profile.name):
@@ -369,7 +369,7 @@ static func get_current_config_name(mod_id: String) -> String:
369369
## Refreshes the data of the provided configuration by reloading it from the config file.[br]
370370
## [br]
371371
## [b]Parameters:[/b][br]
372-
## - [code]config[/code] ([ModConfig]): The [ModConfig] object whose data needs to be refreshed.[br]
372+
## - [param config] ([ModConfig]): The [ModConfig] object whose data needs to be refreshed.[br]
373373
## [br]
374374
## [b]Returns:[/b][br]
375375
## - [ModConfig]: The [ModConfig] object with refreshed data if successful, or the original object otherwise.
@@ -383,8 +383,12 @@ static func refresh_config_data(config: ModConfig) -> ModConfig:
383383

384384

385385
## Iterates over all mods to refresh the data of their current configurations, if available.[br]
386-
## Compares the previous configuration data with the refreshed data and emits the `current_config_changed` signal if changes are detected.[br]
387386
## [br]
387+
## [b]Returns:[/b][br]
388+
## - No return value[br]
389+
## [br]
390+
## Compares the previous configuration data with the refreshed data and emits the [signal ModLoader.current_config_changed]
391+
## signal if changes are detected.[br]
388392
## This function ensures that any changes made to the configuration files outside the application
389393
## are reflected within the application's runtime, allowing for dynamic updates without the need for a restart.
390394
static func refresh_current_configs() -> void:

addons/mod_loader/api/deprecated.gd

+24-23
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ const LOG_NAME := "ModLoader:Deprecated"
1010
## Marks a method that has changed its name or class.[br]
1111
## [br]
1212
## [b]Parameters:[/b][br]
13-
## - [code]old_method[/code] ([String]): The name of the deprecated method.[br]
14-
## - [code]new_method[/code] ([String]): The name of the new method to use.[br]
15-
## - [code]since_version[/code] ([String]): The version number from which the method has been deprecated.[br]
16-
## - [code]show_removal_note[/code] ([bool]): (optional) If true, includes a note about future removal of the old method. Default is true.[br]
13+
## - [param old_method] ([String]): The name of the deprecated method.[br]
14+
## - [param new_method] ([String]): The name of the new method to use.[br]
15+
## - [param since_version] ([String]): The version number from which the method has been deprecated.[br]
16+
## - [param show_removal_note] ([bool]): (optional) If true, includes a note about future removal of the old method. Default is true.[br]
1717
## [br]
1818
## [b]Returns:[/b][br]
19-
## - [code]void[/code]
19+
## - No return value[br]
2020
static func deprecated_changed(old_method: String, new_method: String, since_version: String, show_removal_note: bool = true) -> void:
2121
_deprecated_log(str(
2222
"DEPRECATED: ",
@@ -27,18 +27,19 @@ static func deprecated_changed(old_method: String, new_method: String, since_ver
2727

2828

2929
## Marks a method that has been entirely removed, with no replacement.[br]
30-
## ===[br]
31-
## [b]Note:[/b][br]
32-
## This should rarely be needed but is included for completeness.[br]
33-
## ===[br]
3430
## [br]
3531
## [b]Parameters:[/b][br]
36-
## - [code]old_method[/code] ([String]): The name of the removed method.[br]
37-
## - [code]since_version[/code] ([String]): The version number from which the method has been deprecated.[br]
38-
## - [code]show_removal_note[/code] ([bool]): (optional) If true, includes a note about future removal of the old method. Default is true.[br]
32+
## - [param old_method] ([String]): The name of the removed method.[br]
33+
## - [param since_version] ([String]): The version number from which the method has been deprecated.[br]
34+
## - [param show_removal_note] ([bool]): (optional) If true, includes a note about future removal of the old method. Default is true.[br]
3935
## [br]
4036
## [b]Returns:[/b][br]
41-
## - [code]void[/code]
37+
## - No return value[br]
38+
## [br]
39+
## ===[br]
40+
## [b]Note:[/b][br]
41+
## This should rarely be needed but is included for completeness.[br]
42+
## ===[br]
4243
static func deprecated_removed(old_method: String, since_version: String, show_removal_note: bool = true) -> void:
4344
_deprecated_log(str(
4445
"DEPRECATED: ",
@@ -51,23 +52,23 @@ static func deprecated_removed(old_method: String, since_version: String, show_r
5152
## Marks a method with a freeform deprecation message.[br]
5253
## [br]
5354
## [b]Parameters:[/b][br]
54-
## - [code]msg[/code] ([String]): The deprecation message.[br]
55-
## - [code]since_version[/code] ([String]): (optional) The version number from which the deprecation applies.[br]
55+
## - [param msg] ([String]): The deprecation message.[br]
56+
## - [param since_version] ([String]): (optional) The version number from which the deprecation applies.[br]
5657
## [br]
5758
## [b]Returns:[/b][br]
58-
## - [code]void[/code]
59+
## - No return value[br]
5960
static func deprecated_message(msg: String, since_version: String = "") -> void:
6061
var since_text := " (since version %s)" % since_version if since_version else ""
6162
_deprecated_log(str("DEPRECATED: ", msg, since_text))
6263

6364

64-
## Internal function for logging deprecation messages with support to trigger warnings instead of fatal errors.[br]
65-
## [br]
66-
## [b]Parameters:[/b][br]
67-
## - [code]msg[/code] ([String]): The deprecation message.[br]
68-
## [br]
69-
## [b]Returns:[/b][br]
70-
## - [code]void[/code]
65+
# Internal function for logging deprecation messages with support to trigger warnings instead of fatal errors.[br]
66+
# [br]
67+
# [b]Parameters:[/b][br]
68+
# - [param msg] ([String]): The deprecation message.[br]
69+
# [br]
70+
# [b]Returns:[/b][br]
71+
# - No return value[br]
7172
static func _deprecated_log(msg: String) -> void:
7273
if ModLoaderStore and ModLoaderStore.ml_options.ignore_deprecated_errors or OS.has_feature("standalone"):
7374
ModLoaderLog.warning(msg, LOG_NAME, true)

addons/mod_loader/api/hook_chain.gd

+13-9
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@ func _init(reference_object: Object, callbacks: Array) -> void:
2424

2525

2626
## Will execute the next mod hook callable or vanilla method and return the result.[br]
27-
## Make sure to call this method [i][color=orange]once[/color][/i] somewhere in the [param mod_callable] you pass to [method ModLoaderMod.add_hook]. [br]
28-
##
27+
## [br]
2928
## [br][b]Parameters:[/b][br]
3029
## - [param args] ([Array]): An array of all arguments passed into the vanilla function. [br]
31-
##
32-
## [br][b]Returns:[/b] [Variant][br][br]
30+
## [br]
31+
## [br][b]Returns:[/b][br]
32+
## - [Variant]: Return value of the next function in the chain.[br]
33+
## [br]
34+
## Make sure to call this method [i][color=orange]once[/color][/i] somewhere in the [param mod_callable] you pass to [method ModLoaderMod.add_hook]. [br]
3335
func execute_next(args := []) -> Variant:
3436
var callback := _get_next_callback()
3537
if not callback:
@@ -43,13 +45,15 @@ func execute_next(args := []) -> Variant:
4345

4446

4547
## Same as [method execute_next], but asynchronous - it can be used if a method uses [code]await[/code]. [br]
46-
## This hook needs to be used if the vanilla method uses [code]await[/code] somewhere. [br]
47-
## Make sure to call this method [i][color=orange]once[/color][/i] somewhere in the [param mod_callable] you pass to [method ModLoaderMod.add_hook]. [br]
48-
##
48+
## [br]
4949
## [br][b]Parameters:[/b][br]
5050
## - [param args] ([Array]): An array of all arguments passed into the vanilla function. [br]
51-
##
52-
## [br][b]Returns:[/b] [Variant][br][br]
51+
## [br]
52+
## [br][b]Returns:[/b][br]
53+
## - [Variant]: Return value of the next function in the chain.[br]
54+
## [br]
55+
## This hook needs to be used if the vanilla method uses [code]await[/code] somewhere. [br]
56+
## Make sure to call this method [i][color=orange]once[/color][/i] somewhere in the [param mod_callable] you pass to [method ModLoaderMod.add_hook]. [br]
5357
func execute_next_async(args := []) -> Variant:
5458
var callback := _get_next_callback()
5559
if not callback:

0 commit comments

Comments
 (0)