Skip to content

Commit 768b847

Browse files
authored
Add counts to debug (#65)
1 parent e67c7f7 commit 768b847

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

addons/mod_loader/mod_loader.gd

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,19 @@ func _init():
101101

102102
# Loop over "res://mods" and add any mod zips to the unpacked virtual
103103
# directory (UNPACKED_DIR)
104-
_load_mod_zips()
105-
ModLoaderUtils.log_success("DONE: Loaded all mod files into the virtual filesystem", LOG_NAME)
104+
var unzipped_mods = _load_mod_zips()
105+
if (unzipped_mods > 0):
106+
ModLoaderUtils.log_success("DONE: Loaded %s mod files into the virtual filesystem" % unzipped_mods, LOG_NAME)
107+
else:
108+
ModLoaderUtils.log_info("No zipped mods found", LOG_NAME)
106109

107110
# Loop over UNPACKED_DIR. This triggers _init_mod_data for each mod
108111
# directory, which adds their data to mod_data.
109-
_setup_mods()
112+
var setup_mods = _setup_mods()
113+
if (setup_mods > 0):
114+
ModLoaderUtils.log_success("DONE: Setup %s mods" % setup_mods, LOG_NAME)
115+
else:
116+
ModLoaderUtils.log_info("No mods were setup", LOG_NAME)
110117

111118
# Set up mod configs. If a mod's JSON file is found, its data gets added
112119
# to mod_data.{dir_name}.config
@@ -152,20 +159,21 @@ func _init():
152159

153160
# Loop over "res://mods" and add any mod zips to the unpacked virtual directory
154161
# (UNPACKED_DIR)
155-
func _load_mod_zips():
162+
func _load_mod_zips()->int:
156163
# Path to the games mod folder
157164
var game_mod_folder_path = ModLoaderUtils.get_local_folder_dir("mods")
158165

159166
var dir = Directory.new()
160167
if dir.open(game_mod_folder_path) != OK:
161168
ModLoaderUtils.log_error("Can't open mod folder %s." % game_mod_folder_path, LOG_NAME)
162-
return
169+
return -1
163170
if dir.list_dir_begin() != OK:
164171
ModLoaderUtils.log_error("Can't read mod folder %s." % game_mod_folder_path, LOG_NAME)
165-
return
172+
return -1
166173

167174
var has_shown_editor_warning = false
168175

176+
var zipped_mods_count = 0
169177
# Get all zip folders inside the game mod folder
170178
while true:
171179
# Get the next file in the directory
@@ -213,24 +221,27 @@ func _load_mod_zips():
213221

214222
# Mod successfully loaded!
215223
ModLoaderUtils.log_success(str(mod_zip_file_name, " loaded."), LOG_NAME)
224+
zipped_mods_count += 1
216225

217226
dir.list_dir_end()
227+
return zipped_mods_count
218228

219229

220230
# Loop over UNPACKED_DIR and triggers `_init_mod_data` for each mod directory,
221231
# which adds their data to mod_data.
222-
func _setup_mods():
232+
func _setup_mods()->int:
223233
# Path to the unpacked mods folder
224234
var unpacked_mods_path = UNPACKED_DIR
225235

226236
var dir = Directory.new()
227237
if dir.open(unpacked_mods_path) != OK:
228238
ModLoaderUtils.log_error("Can't open unpacked mods folder %s." % unpacked_mods_path, LOG_NAME)
229-
return
239+
return -1
230240
if dir.list_dir_begin() != OK:
231241
ModLoaderUtils.log_error("Can't read unpacked mods folder %s." % unpacked_mods_path, LOG_NAME)
232-
return
242+
return -1
233243

244+
var unpacked_mods_count = 0
234245
# Get all unpacked mod dirs
235246
while true:
236247
# Get the next file in the directory
@@ -250,8 +261,10 @@ func _setup_mods():
250261

251262
# Init the mod data
252263
_init_mod_data(mod_dir_name)
264+
unpacked_mods_count += 1
253265

254266
dir.list_dir_end()
267+
return unpacked_mods_count
255268

256269

257270
# Load mod config JSONs from res://configs

0 commit comments

Comments
 (0)