Skip to content

Commit 3661912

Browse files
authored
Merge branch '4.x' into refactor_self_setup_GDRE
2 parents b8c6cc2 + a165641 commit 3661912

17 files changed

+356
-206
lines changed

.gitattributes

+6-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,9 @@ test/ export-ignore
1212

1313
# Files not required by AssetLib downloads (provided via download for manual installers)
1414
addons/mod_loader/vendor/ export-ignore
15-
addons/mod_loader/mod_loader_setup.gd export-ignore
15+
addons/mod_loader/mod_loader_setup.gd export-ignore
16+
17+
# Used during docs generation, but not relevant for addon users
18+
project.godot export-ignore
19+
main.tscn export-ignore
20+
icon.png export-ignore

.gitignore

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
2-
.godot
1+
.godot/
32
# IDEs
43
.idea
54
.vscode

CONTRIBUTING.md

+23-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Contributing Guidelines
22

3-
Thank you for considering contributing to our project! We welcome contributions from everyone. Before getting started, please take a moment to read our guidelines.
3+
Thank you for considering contributing to our project! We welcome contributions from everyone.
4+
Before getting started, please take a moment to read our guidelines.
45

56
## How to contribute
67

@@ -12,11 +13,14 @@ Thank you for considering contributing to our project! We welcome contributions
1213

1314
## Reporting bugs
1415

15-
If you find a bug, please let us know by opening an issue. Be as detailed as possible when describing the issue, including any steps to reproduce the bug. If applicable, please provide your `modloader.log` file from the `user://` (Godot app_userdata) folder. This file contains valuable information that can help us identify the cause of the issue.
16+
If you find a bug, please let us know by opening an issue. Be as detailed as possible when describing the issue,
17+
including any steps to reproduce the bug. If applicable, please provide your `modloader.log` file from the `user://`
18+
(Godot app_userdata) folder. This file contains valuable information that can help us identify the cause of the issue.
1619

1720
## Suggesting features
1821

19-
If you have an idea for a new feature or improvement, please open an issue to discuss it. We welcome all suggestions and will consider them carefully.
22+
If you have an idea for a new feature or improvement, please open an issue to discuss it.
23+
We welcome all suggestions and will consider them carefully.
2024

2125
## Coding style
2226

@@ -27,17 +31,22 @@ In addition, please follow these guidelines:
2731
### Naming Convention
2832
- Prefix local (private) to file vars / functions with `_`
2933
- Prefix classes that should only be used by the ModLoader with `_`
30-
- If a method is in a non-prefixed class and ModLoader Internal, but used outside of the private scope, prefix with `_`, use it outside the scope, but add a comment why it was used there
34+
- If a method is in a non-prefixed class and ModLoader Internal, but used outside the private scope, prefix with `_`,
35+
use it outside the scope, but add a comment why it was used there
3136

3237
Reasoning:
3338
1. Underscore methods/vars should only be used within the same file
34-
2. Most classes should not be used by mods, only by the ModLoader. if they are prefixed with an underscore, no mod should access them and we are free to change the internal structure without breaking mods and needing deprecations
35-
3. In some cases we need to use private methods outside of their file (`_rotate_log_file` for example) and the class is a public one (`ModLoaderLog` here). Since the method should not be accessible to mods, we are using a "private" method outside of its scope here - and that needs an explanation
39+
2. Most classes should not be used by mods, only by the ModLoader. if they are prefixed with an underscore,
40+
no mod should access them and we are free to change the internal structure without breaking mods and needing deprecations
41+
3. In some cases we need to use private methods outside their file (`_rotate_log_file` for example) and the class is a
42+
public one (`ModLoaderLog` here). Since the method should not be accessible to mods, we are using a "private" method outside
43+
its scope here - and that needs an explanation
3644

3745
### String Standards
3846
- Double quotes over single quotes: `"string"`, not `'string'`
3947
- Quote escaping over single quotes : `"\"hello\" world"`, not `'"hello" world'`
40-
- Format strings over string concatenation and `str()`: `"hello %s!" % place`, not `"hello " + place + "!"`, not `str("hello", place)`. Except for very simple cases/single concatenation: `"hello " + place`, not `"hello %s" % place`
48+
- Format strings over string concatenation and `str()`: `"hello %s!" % place`, not `"hello " + place + "!"`,
49+
not `str("hello", place)`. Except for very simple cases/single concatenation: `"hello " + place`, not `"hello %s" % place`
4150
- split long strings into shorter ones with string concatenation `"" + "" + ...`, not `str("", "", ...)`
4251
```gdscript
4352
ModLoaderLog.info(
@@ -49,8 +58,13 @@ ModLoaderLog.info(
4958

5059
## Documentation
5160

52-
The documentation for this project is located in the repository's wiki. Please make sure to update the relevant documentation pages when making changes to the code. If you're not sure what needs to be updated, please ask in your pull request or issue.
53-
*Note that you will mostly edit the [Upcoming Features](https://github.com/GodotModding/godot-mod-loader/wiki/Upcoming-Features) page, where all changes to the dev branch are documented until they become part of the next major update.*
61+
The documentation for this project is kept in the [gmlwiki repository](https://github.com/GodotModding/gmlwiki).
62+
Please make sure to update the relevant documentation pages when making changes to the code. If you're not sure what
63+
needs to be updated, please ask in your pull request or issue.
64+
*Note that you will mostly edit the [Upcoming Features](https://github.com/GodotModding/godot-mod-loader/wiki/Upcoming-Features)
65+
page, where all changes to the dev branch are documented until they become part of the next major update.*
66+
67+
5468

5569
## Communicating over Discord
5670
We use Discord for communication and collaboration. You can join our Discord server at [discord.godotmodding.com](https://discord.godotmodding.com). Please use appropriate channels for your discussions and keep conversations respectful and on-topic.

README.md

+2-11
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# GDScript Mod Loader
44

5-
<img alt="Godot Modding Logo" src="https://github.com/KANAjetzt/godot-mod-loader/assets/41547570/44df4f33-883e-4c1d-baac-06f87b0656f4" width="256" />
5+
<img alt="Godot Modding Logo" src="icon.png" width="256" />
66

77
</div>
88

@@ -37,16 +37,7 @@ Importantly, it provides methods to change existing scripts, scenes, and resourc
3737

3838
## Getting Started
3939

40-
You can find detailed documentation, for game and mod developers, on the [Wiki](https://wiki.godotmodding.com/) page.
41-
42-
1. Add ModLoader to your [Godot Project](https://wiki.godotmodding.com/guides/integration/godot_project_setup/)
43-
*Details on how to set up the Mod Loader in your Godot Project, relevant for game and mod developers.*
44-
2. Create your [Mod Structure](https://wiki.godotmodding.com/guides/modding/mod_structure/)
45-
*The mods loaded by the Mod Loader must follow a specific directory structure.*
46-
3. Create your [Mod Files](https://wiki.godotmodding.com/guides/modding/mod_files/)
47-
*Learn about the required files to create your first mod.*
48-
4. Use the [API Methods](https://wiki.godotmodding.com/api/mod_loader_api/)
49-
*A list of all available API Methods.*
40+
You can find quickstart guides and more on the [Wiki](https://wiki.godotmodding.com/).
5041

5142
## Godot Version
5243
The current version of the Mod Loader is developed for Godot 3.

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:

0 commit comments

Comments
 (0)