Skip to content

Commit 8910f23

Browse files
committed
refactor: ♻️ moved load_from_unpacked check
to `_ModLoaderPath.get_mod_paths_from_all_sources()`
1 parent 2e62e53 commit 8910f23

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

addons/mod_loader/internal/path.gd

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,11 @@ static func get_mod_paths_from_all_sources() -> Array[String]:
194194
var mod_paths: Array[String] = []
195195

196196
var mod_dirs := get_dir_paths_in_dir(get_unpacked_mods_dir_path())
197-
mod_paths.append_array(mod_dirs)
197+
198+
if ModLoaderStore.has_feature.editor or ModLoaderStore.ml_options.load_from_unpacked:
199+
mod_paths.append_array(mod_dirs)
200+
else:
201+
ModLoaderLog.info("Loading mods from \"res://mods-unpacked\" is disabled.", LOG_NAME)
198202

199203
if ModLoaderStore.ml_options.load_from_local:
200204
var mods_dir := get_path_to_mods()

addons/mod_loader/mod_loader.gd

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ signal new_hooks_created
3030

3131
const LOG_NAME := "ModLoader"
3232

33-
var is_in_editor := OS.has_feature("editor")
34-
3533

3634
func _init() -> void:
3735
# if mods are not enabled - don't load mods
@@ -41,7 +39,7 @@ func _init() -> void:
4139
# Only load the hook pack if not in the editor
4240
# We can't use it in the editor - see https://github.com/godotengine/godot/issues/19815
4341
# Mod devs can use the Dev Tool to generate hooks in the editor.
44-
if not is_in_editor and _ModLoaderFile.file_exists(_ModLoaderPath.get_path_to_hook_pack()):
42+
if not ModLoaderStore.has_feature.editor and _ModLoaderFile.file_exists(_ModLoaderPath.get_path_to_hook_pack()):
4543
_load_mod_hooks_pack()
4644

4745
# Rotate the log files once on startup.
@@ -80,10 +78,6 @@ func _init() -> void:
8078
for mod_path in mod_paths:
8179
var is_zip := _ModLoaderPath.is_zip(mod_path)
8280

83-
if not is_zip and not is_in_editor and not ModLoaderStore.ml_options.load_from_unpacked:
84-
ModLoaderLog.debug("The mod from path \"%s\" is not loaded because loading from mods-unpacked has been disabled in the options." % mod_path, LOG_NAME)
85-
continue
86-
8781
# Load manifest file
8882
var manifest_data: Dictionary = _ModLoaderFile.load_manifest_file(mod_path)
8983

@@ -123,7 +117,7 @@ func _init() -> void:
123117
# "don't use ZIPs with unpacked mods!"
124118
# https://github.com/godotengine/godot/issues/19815
125119
# https://github.com/godotengine/godot/issues/16798
126-
if is_in_editor:
120+
if ModLoaderStore.has_feature.editor:
127121
ModLoaderLog.hint(
128122
"Loading any resource packs (.zip/.pck) with `load_resource_pack` will WIPE the entire virtual res:// directory. " +
129123
"If you have any unpacked mods in %s, they will not be loaded.Please unpack your mod ZIPs instead, and add them to %s" %

addons/mod_loader/mod_loader_store.gd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ var cache := {}
111111
# See: res://addons/mod_loader/resources/options_profile.gd
112112
var ml_options: ModLoaderOptionsProfile
113113

114+
var has_feature := {
115+
"editor" = OS.has_feature("editor")
116+
}
114117

115118
# Methods
116119
# =============================================================================

0 commit comments

Comments
 (0)