@@ -22,36 +22,20 @@ extends Node
22
22
23
23
signal logged (entry )
24
24
25
- # Config
26
- # =============================================================================
27
-
28
- # Most of these settings should never need to change, aside from the DEBUG_*
29
- # options (which should be `false` when distributing compiled PCKs)
30
-
31
- const MODLOADER_VERSION = "5.0.1"
32
-
33
- # If true, a complete array of filepaths is stored for each mod. This is
34
- # disabled by default because the operation can be very expensive, but may
35
- # be useful for debugging
36
- const DEBUG_ENABLE_STORING_FILEPATHS := false
37
-
38
- # This is where mod ZIPs are unpacked to
39
- const UNPACKED_DIR := "res://mods-unpacked/"
40
-
41
-
42
- # Set to true to require using "--enable-mods" to enable them
43
- const REQUIRE_CMD_LINE := false
44
-
45
25
# Prefix for this file when using mod_log or dev_log
46
26
const LOG_NAME := "ModLoader"
47
27
28
+ # --- DEPRECATED ---
29
+ # UNPACKED_DIR was moved to ModLoaderStore.
30
+ # However, many Brotato mods use this const directly, which is why the deprecation warning was added.
31
+ var UNPACKED_DIR := "res://mods-unpacked/" setget ,deprecated_direct_access_UNPACKED_DIR
48
32
49
33
# Main
50
34
# =============================================================================
51
35
52
36
func _init () -> void :
53
37
# if mods are not enabled - don't load mods
54
- if REQUIRE_CMD_LINE and not _ModLoaderCLI .is_running_with_command_line_arg ("--enable-mods" ):
38
+ if ModLoaderStore . REQUIRE_CMD_LINE and not _ModLoaderCLI .is_running_with_command_line_arg ("--enable-mods" ):
55
39
return
56
40
57
41
# Rotate the log files once on startup. Can't be checked in utils, since it's static
@@ -170,7 +154,7 @@ func _load_mods() -> void:
170
154
171
155
ModLoaderLog .success ("DONE: Completely finished loading mods" , LOG_NAME )
172
156
173
- _ModLoaderScriptExtension .handle_script_extensions (UNPACKED_DIR )
157
+ _ModLoaderScriptExtension .handle_script_extensions ()
174
158
175
159
ModLoaderLog .success ("DONE: Installed all script extensions" , LOG_NAME )
176
160
@@ -271,8 +255,8 @@ func _load_zips_in_folder(folder_path: String) -> int:
271
255
if OS .has_feature ("editor" ) and not ModLoaderStore .has_shown_editor_zips_warning :
272
256
ModLoaderLog .warning (str (
273
257
"Loading any resource packs (.zip/.pck) with `load_resource_pack` will WIPE the entire virtual res:// directory. " ,
274
- "If you have any unpacked mods in " , UNPACKED_DIR , ", they will not be loaded. " ,
275
- "Please unpack your mod ZIPs instead, and add them to " , UNPACKED_DIR ), LOG_NAME )
258
+ "If you have any unpacked mods in " , ModLoaderStore . UNPACKED_DIR , ", they will not be loaded. " ,
259
+ "Please unpack your mod ZIPs instead, and add them to " , ModLoaderStore . UNPACKED_DIR ), LOG_NAME )
276
260
ModLoaderStore .has_shown_editor_zips_warning = true
277
261
278
262
ModLoaderLog .debug ("Found mod ZIP: %s " % mod_folder_global_path , LOG_NAME )
@@ -339,7 +323,7 @@ func _load_steam_workshop_zips() -> int:
339
323
# which adds their data to mod_data.
340
324
func _setup_mods () -> int :
341
325
# Path to the unpacked mods folder
342
- var unpacked_mods_path := UNPACKED_DIR
326
+ var unpacked_mods_path := ModLoaderStore . UNPACKED_DIR
343
327
344
328
var dir := Directory .new ()
345
329
if not dir .open (unpacked_mods_path ) == OK :
@@ -429,7 +413,7 @@ func _init_mod_data(mod_folder_path: String) -> void:
429
413
var dir_name := _ModLoaderPath .get_file_name_from_path (mod_folder_path , false , true )
430
414
431
415
# Path to the mod in UNPACKED_DIR (eg "res://mods-unpacked/My-Mod")
432
- var local_mod_path := UNPACKED_DIR .plus_file (dir_name )
416
+ var local_mod_path := ModLoaderStore . UNPACKED_DIR .plus_file (dir_name )
433
417
434
418
var mod := ModData .new (local_mod_path )
435
419
mod .dir_name = dir_name
@@ -443,7 +427,7 @@ func _init_mod_data(mod_folder_path: String) -> void:
443
427
# not needed anymore. It can be useful when debugging, but it's also an expensive
444
428
# operation if a mod has a large number of files (eg. Brotato's Invasion mod,
445
429
# which has ~1,000 files). That's why it's disabled by default
446
- if DEBUG_ENABLE_STORING_FILEPATHS :
430
+ if ModLoaderStore . DEBUG_ENABLE_STORING_FILEPATHS :
447
431
mod .file_paths = _ModLoaderPath .get_flat_view_dict (local_mod_path )
448
432
449
433
@@ -502,3 +486,8 @@ func save_scene(modified_scene: Node, scene_path: String) -> void:
502
486
func get_mod_config (mod_dir_name : String = "" , key : String = "" ) -> Dictionary :
503
487
ModLoaderDeprecated .deprecated_changed ("ModLoader.get_mod_config" , "ModLoaderConfig.get_mod_config" , "6.0.0" )
504
488
return ModLoaderConfig .get_mod_config (mod_dir_name , key )
489
+
490
+
491
+ func deprecated_direct_access_UNPACKED_DIR () -> String :
492
+ ModLoaderDeprecated .deprecated_message ("The const \" UNPACKED_DIR\" was removed, use \" ModLoaderMod.get_unpacked_dir()\" instead" , "6.0.0" )
493
+ return _ModLoaderPath .get_unpacked_mods_dir_path ()
0 commit comments