Skip to content

Commit 33f85b7

Browse files
authored
style: ✏️ rename funcs to match naming convention (#232)
* style: ✏️ renamed cli funcs to match #227 * style: ✏️ renamed dependency funcs to match #227 * style: ✏️ renamed file funcs * style: ✏️ renamed `_ModLoaderGodot` funcs * style: ✏️ renamed `ModLoaderUtils` funcs * style: ✏️ renamed `ModData` funcs
1 parent b9ad9a5 commit 33f85b7

File tree

9 files changed

+32
-32
lines changed

9 files changed

+32
-32
lines changed

addons/mod_loader/classes/mod_data.gd

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func _init(_dir_path: String) -> void:
5050

5151
# Load meta data from a mod's manifest.json file
5252
func load_manifest() -> void:
53-
if not has_required_files():
53+
if not _has_required_files():
5454
return
5555

5656
ModLoaderLog.info("Loading mod_manifest (manifest.json) for -> %s" % dir_name, LOG_NAME)
@@ -66,15 +66,15 @@ func load_manifest() -> void:
6666

6767
var mod_manifest := ModManifest.new(manifest_dict)
6868

69-
is_loadable = has_manifest(mod_manifest)
69+
is_loadable = _has_manifest(mod_manifest)
7070
if not is_loadable: return
71-
is_loadable = is_mod_dir_name_same_as_id(mod_manifest)
71+
is_loadable = _is_mod_dir_name_same_as_id(mod_manifest)
7272
if not is_loadable: return
7373
manifest = mod_manifest
7474

7575

7676
# Validates if [member dir_name] matches [method ModManifest.get_mod_id]
77-
func is_mod_dir_name_same_as_id(mod_manifest: ModManifest) -> bool:
77+
func _is_mod_dir_name_same_as_id(mod_manifest: ModManifest) -> bool:
7878
var manifest_id := mod_manifest.get_mod_id()
7979
if not dir_name == manifest_id:
8080
ModLoaderLog.fatal('Mod directory name "%s" does not match the data in manifest.json. Expected "%s" (Format: {namespace}-{name})' % [ dir_name, manifest_id ], LOG_NAME)
@@ -83,7 +83,7 @@ func is_mod_dir_name_same_as_id(mod_manifest: ModManifest) -> bool:
8383

8484

8585
# Confirms that all files from [member required_mod_files] exist
86-
func has_required_files() -> bool:
86+
func _has_required_files() -> bool:
8787
for required_file in required_mod_files:
8888
var file_path := get_required_mod_file_path(required_mod_files[required_file])
8989

@@ -94,7 +94,7 @@ func has_required_files() -> bool:
9494

9595

9696
# Validates if manifest is set
97-
func has_manifest(mod_manifest: ModManifest) -> bool:
97+
func _has_manifest(mod_manifest: ModManifest) -> bool:
9898
if mod_manifest == null:
9999
ModLoaderLog.fatal("Mod manifest could not be created correctly due to errors.", LOG_NAME)
100100
return false

addons/mod_loader/internal/cli.gd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ static func is_running_with_command_line_arg(argument: String) -> bool:
1919

2020
# Get the command line argument value if present when launching the game
2121
static func get_cmd_line_arg_value(argument: String) -> String:
22-
var args := get_fixed_cmdline_args()
22+
var args := _get_fixed_cmdline_args()
2323

2424
for arg_index in args.size():
2525
var arg := args[arg_index] as String
@@ -40,7 +40,7 @@ static func get_cmd_line_arg_value(argument: String) -> String:
4040
return ""
4141

4242

43-
static func get_fixed_cmdline_args() -> PoolStringArray:
43+
static func _get_fixed_cmdline_args() -> PoolStringArray:
4444
return fix_godot_cmdline_args_string_space_splitting(OS.get_cmdline_args())
4545

4646

addons/mod_loader/internal/dependency.gd

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const LOG_NAME := "ModLoader:Dependency"
2121
# loading if they are missing.
2222
#
2323
# Returns: A boolean indicating whether a circular dependency was detected.
24-
static func _check_dependencies(mod: ModData, is_required := true, dependency_chain := []) -> bool:
24+
static func check_dependencies(mod: ModData, is_required := true, dependency_chain := []) -> bool:
2525
var dependency_type := "required" if is_required else "optional"
2626
# Get the dependency array based on the is_required flag
2727
var dependencies := mod.manifest.dependencies if is_required else mod.manifest.optional_dependencies
@@ -58,7 +58,7 @@ static func _check_dependencies(mod: ModData, is_required := true, dependency_ch
5858

5959
# Check if the dependency has any dependencies of its own
6060
if dependency.manifest.dependencies.size() > 0:
61-
if _check_dependencies(dependency, is_required, dependency_chain):
61+
if check_dependencies(dependency, is_required, dependency_chain):
6262
return true
6363

6464
# Return false if all dependencies have been resolved
@@ -68,7 +68,7 @@ static func _check_dependencies(mod: ModData, is_required := true, dependency_ch
6868
# Run load before check on a mod, checking any load_before entries it lists in its
6969
# mod_manifest (ie. its manifest.json file). Add the mod to the dependency of the
7070
# mods inside the load_before array.
71-
static func _check_load_before(mod: ModData) -> void:
71+
static func check_load_before(mod: ModData) -> void:
7272
# Skip if no entries in load_before
7373
if mod.manifest.load_before.size() == 0:
7474
return
@@ -97,7 +97,7 @@ static func _check_load_before(mod: ModData) -> void:
9797

9898

9999
# Get the load order of mods, using a custom sorter
100-
static func _get_load_order(mod_data_array: Array) -> Array:
100+
static func get_load_order(mod_data_array: Array) -> Array:
101101
# Add loadable mods to the mod load order array
102102
for mod in mod_data_array:
103103
mod = mod as ModData
@@ -121,7 +121,7 @@ static func _handle_missing_dependency(mod_id: String, dependency_id: String) ->
121121
ModLoaderStore.mod_missing_dependencies[mod_id].append(dependency_id)
122122

123123

124-
# Inner class so the sort function can be called by _get_load_order()
124+
# Inner class so the sort function can be called by get_load_order()
125125
class CompareImportance:
126126
# Custom sorter that orders mods by important
127127
static func _compare_importance(a: ModData, b: ModData) -> bool:

addons/mod_loader/internal/file.gd

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ static func get_json_as_dict(path: String) -> Dictionary:
2525
ModLoaderLog.error("Error opening file. Code: %s" % error, LOG_NAME)
2626

2727
var content := file.get_as_text()
28-
return get_json_string_as_dict(content)
28+
return _get_json_string_as_dict(content)
2929

3030

3131
# Parses JSON from a given [String] and returns a [Dictionary].
3232
# Returns an empty [Dictionary] on error (check with size() < 1)
33-
static func get_json_string_as_dict(string: String) -> Dictionary:
33+
static func _get_json_string_as_dict(string: String) -> Dictionary:
3434
if string == "":
3535
return {}
3636
var parsed := JSON.parse(string)
@@ -47,7 +47,7 @@ static func get_json_string_as_dict(string: String) -> Dictionary:
4747
# =============================================================================
4848

4949
# Saves a dictionary to a file, as a JSON string
50-
static func save_string_to_file(save_string: String, filepath: String) -> bool:
50+
static func _save_string_to_file(save_string: String, filepath: String) -> bool:
5151
# Create directory if it doesn't exist yet
5252
var file_directory := filepath.get_base_dir()
5353
var dir := Directory.new()
@@ -81,7 +81,7 @@ static func save_string_to_file(save_string: String, filepath: String) -> bool:
8181
# Saves a dictionary to a file, as a JSON string
8282
static func save_dictionary_to_json_file(data: Dictionary, filepath: String) -> bool:
8383
var json_string = JSON.print(data, "\t")
84-
return save_string_to_file(json_string, filepath)
84+
return _save_string_to_file(json_string, filepath)
8585

8686

8787
# Checks

addons/mod_loader/internal/godot.gd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const LOG_NAME := "ModLoader:Godot"
1212
# Returns a bool if the position does not match.
1313
# Optionally triggers a fatal error
1414
static func check_autoload_position(autoload_name: String, position_index: int, trigger_error: bool = false) -> bool:
15-
var autoload_array := _get_autoload_array()
15+
var autoload_array := get_autoload_array()
1616
var autoload_index := autoload_array.find(autoload_name)
1717
var position_matches := autoload_index == position_index
1818

@@ -29,7 +29,7 @@ static func check_autoload_position(autoload_name: String, position_index: int,
2929

3030

3131
# Get an array of all autoloads -> ["autoload/AutoloadName", ...]
32-
static func _get_autoload_array() -> Array:
32+
static func get_autoload_array() -> Array:
3333
var autoloads := []
3434

3535
# Get all autoload settings

addons/mod_loader/internal/mod_loader_utils.gd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const LOG_NAME := "ModLoader:ModLoaderUtils"
88
# This is a dummy func. It is exclusively used to show notes in the code that
99
# stay visible after decompiling a PCK, as is primarily intended to assist new
1010
# modders in understanding and troubleshooting issues
11-
static func code_note(_msg:String):
11+
static func _code_note(_msg:String):
1212
pass
1313

1414

@@ -56,7 +56,7 @@ static func register_global_classes_from_array(new_global_classes: Array) -> voi
5656
var registered_class_icons: Dictionary = ProjectSettings.get_setting("_global_script_class_icons")
5757

5858
for new_class in new_global_classes:
59-
if not is_valid_global_class_dict(new_class):
59+
if not _is_valid_global_class_dict(new_class):
6060
continue
6161
for old_class in registered_classes:
6262
if old_class.class == new_class.class:
@@ -75,7 +75,7 @@ static func register_global_classes_from_array(new_global_classes: Array) -> voi
7575

7676
# Checks if all required fields are in the given [Dictionary]
7777
# Format: { "base": "ParentClass", "class": "ClassName", "language": "GDScript", "path": "res://path/class_name.gd" }
78-
static func is_valid_global_class_dict(global_class_dict: Dictionary) -> bool:
78+
static func _is_valid_global_class_dict(global_class_dict: Dictionary) -> bool:
7979
var required_fields := ["base", "class", "language", "path"]
8080
if not global_class_dict.has_all(required_fields):
8181
ModLoaderLog.fatal("Global class to be registered is missing one of %s" % required_fields, LOG_NAME)

addons/mod_loader/mod_loader.gd

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func _init() -> void:
6161
_check_autoload_positions()
6262

6363
# Log the autoloads order. Helpful when providing support to players
64-
ModLoaderLog.debug_json_print("Autoload order", _ModLoaderGodot._get_autoload_array(), LOG_NAME)
64+
ModLoaderLog.debug_json_print("Autoload order", _ModLoaderGodot.get_autoload_array(), LOG_NAME)
6565

6666
# Log game install dir
6767
ModLoaderLog.info("game_install_directory: %s" % _ModLoaderPath.get_local_folder_dir(), LOG_NAME)
@@ -129,7 +129,7 @@ func _load_mods() -> void:
129129
var mod: ModData = ModLoaderStore.mod_data[dir_name]
130130
if not mod.is_loadable:
131131
continue
132-
_ModLoaderDependency._check_load_before(mod)
132+
_ModLoaderDependency.check_load_before(mod)
133133

134134

135135
# Run optional dependency checks after loading mod_manifest.
@@ -139,7 +139,7 @@ func _load_mods() -> void:
139139
var mod: ModData = ModLoaderStore.mod_data[dir_name]
140140
if not mod.is_loadable:
141141
continue
142-
var _is_circular := _ModLoaderDependency._check_dependencies(mod, false)
142+
var _is_circular := _ModLoaderDependency.check_dependencies(mod, false)
143143

144144

145145
# Run dependency checks after loading mod_manifest. If a mod depends on another
@@ -148,10 +148,10 @@ func _load_mods() -> void:
148148
var mod: ModData = ModLoaderStore.mod_data[dir_name]
149149
if not mod.is_loadable:
150150
continue
151-
var _is_circular := _ModLoaderDependency._check_dependencies(mod)
151+
var _is_circular := _ModLoaderDependency.check_dependencies(mod)
152152

153153
# Sort mod_load_order by the importance score of the mod
154-
ModLoaderStore.mod_load_order = _ModLoaderDependency._get_load_order(ModLoaderStore.mod_data.values())
154+
ModLoaderStore.mod_load_order = _ModLoaderDependency.get_load_order(ModLoaderStore.mod_data.values())
155155

156156
# Log mod order
157157
var mod_i := 1

addons/mod_loader/mod_loader_store.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const LOG_NAME = "ModLoader:Store"
1414
# Vars
1515
# =============================================================================
1616

17-
# Order for mods to be loaded in, set by `_get_load_order`
17+
# Order for mods to be loaded in, set by `get_load_order`
1818
var mod_load_order := []
1919

2020
# Stores data for every found/loaded mod

addons/mod_loader/setup/setup_utils.gd

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ static func register_global_classes_from_array(new_global_classes: Array) -> voi
7878
var registered_class_icons: Dictionary = ProjectSettings.get_setting("_global_script_class_icons")
7979

8080
for new_class in new_global_classes:
81-
if not is_valid_global_class_dict(new_class):
81+
if not _is_valid_global_class_dict(new_class):
8282
continue
8383
for old_class in registered_classes:
8484
if old_class.class == new_class.class:
@@ -97,7 +97,7 @@ static func register_global_classes_from_array(new_global_classes: Array) -> voi
9797

9898
# Checks if all required fields are in the given [Dictionary]
9999
# Format: { "base": "ParentClass", "class": "ClassName", "language": "GDScript", "path": "res://path/class_name.gd" }
100-
static func is_valid_global_class_dict(global_class_dict: Dictionary) -> bool:
100+
static func _is_valid_global_class_dict(global_class_dict: Dictionary) -> bool:
101101
var ModLoaderSetupLog: Object = load("res://addons/mod_loader/setup/setup_log.gd")
102102
var required_fields := ["base", "class", "language", "path"]
103103
if not global_class_dict.has_all(required_fields):
@@ -124,7 +124,7 @@ static func is_running_with_command_line_arg(argument: String) -> bool:
124124

125125
# Get the command line argument value if present when launching the game
126126
static func get_cmd_line_arg_value(argument: String) -> String:
127-
var args := get_fixed_cmdline_args()
127+
var args := _get_fixed_cmdline_args()
128128

129129
for arg_index in args.size():
130130
var arg := args[arg_index] as String
@@ -145,7 +145,7 @@ static func get_cmd_line_arg_value(argument: String) -> String:
145145
return ""
146146

147147

148-
static func get_fixed_cmdline_args() -> PoolStringArray:
148+
static func _get_fixed_cmdline_args() -> PoolStringArray:
149149
return fix_godot_cmdline_args_string_space_splitting(OS.get_cmdline_args())
150150

151151

0 commit comments

Comments
 (0)