@@ -39,47 +39,34 @@ var is_setup_create_override_cfg : bool = modloaderutils.is_running_with_command
39
39
40
40
41
41
func _init () -> void :
42
- try_setup_modloader ()
43
- var _changescene_error : int = change_scene (ProjectSettings .get_setting ("application/run/main_scene" ))
42
+ modloaderutils .log_debug ("ModLoader setup initialized" , LOG_NAME )
44
43
45
-
46
- # Set up the ModLoader, if it hasn't been set up yet
47
- func try_setup_modloader () -> void :
48
44
# Avoid doubling the setup work
49
- if is_loader_setup_applied ():
50
- modloaderutils .log_info ("ModLoader is available, mods can be loaded!" , LOG_NAME )
51
- OS .set_window_title ("%s (Modded)" % ProjectSettings .get_setting ("application/config/name" ))
45
+ # Checks if the ModLoader Node is in the root of the scene tree
46
+ # and if the IS_LOADER_SETUP_APPLIED project setting is there
47
+ if modloaderutils .get_autoload_index ("ModLoader" ) == 0 :
48
+ modded_start ()
52
49
return
53
50
54
- setup_file_data ()
55
51
setup_modloader ()
56
52
57
- # If the loader is set up, but the override is not applied yet,
58
- # prompt the user to quit and restart the game.
59
- if is_loader_set_up () and not is_loader_setup_applied ():
60
- modloaderutils .log_info ("ModLoader is set up, but the game needs to be restarted" , LOG_NAME )
61
- ProjectSettings .set_setting (settings .IS_LOADER_SETUP_APPLIED , true )
62
53
63
- if is_setup_create_override_cfg :
64
- handle_override_cfg ()
65
- else :
66
- handle_project_binary ()
54
+ # ModLoader already setup - switch to the main scene
55
+ func modded_start () -> void :
56
+ modloaderutils .log_info ("ModLoader is available, mods can be loaded!" , LOG_NAME )
57
+
58
+ OS .set_window_title ("%s (Modded)" % ProjectSettings .get_setting ("application/config/name" ))
67
59
68
- match true :
69
- # If the --only-setup cli argument is passed, quit with exit code 0
70
- is_only_setup :
71
- quit (0 )
72
- # If no cli argument is passed, show message with OS.alert() and user has to restart the game
73
- _ :
74
- OS .alert ("The Godot ModLoader has been set up. Restart the game to apply the changes. Confirm to quit." )
75
- quit (0 )
60
+ var _error_change_scene_main := change_scene (ProjectSettings .get_setting ("application/run/main_scene" ))
76
61
77
62
78
63
# Set up the ModLoader as an autoload and register the other global classes.
79
- # Saved as override.cfg besides the game executable to extend the existing project settings
80
64
func setup_modloader () -> void :
81
65
modloaderutils .log_info ("Setting up ModLoader" , LOG_NAME )
82
66
67
+ # Setup path and file_name dict with all required paths and file names.
68
+ setup_file_data ()
69
+
83
70
# Register all new helper classes as global
84
71
modloaderutils .register_global_classes_from_array (new_global_classes )
85
72
@@ -98,8 +85,22 @@ func setup_modloader() -> void:
98
85
<<<<<< < HEAD
99
86
====== =
100
87
88
+ <<<<<< < HEAD
101
89
modloaderutils .log_info ("ModLoader setup complete" , LOG_NAME )
102
90
>>>>>> > 32150e0 (✔ added -- setup - create - override - cfg cli arg )
91
+ ====== =
92
+ # ModLoader is set up. A game restart is required to apply the ProjectSettings.
93
+ modloaderutils .log_info ("ModLoader is set up, a game restart is required." , LOG_NAME )
94
+
95
+ match true :
96
+ # If the --only-setup cli argument is passed, quit with exit code 0
97
+ is_only_setup :
98
+ quit (0 )
99
+ # If no cli argument is passed, show message with OS.alert() and user has to restart the game
100
+ _ :
101
+ OS .alert ("The Godot ModLoader has been set up. Restart the game to apply the changes. Confirm to quit." )
102
+ quit (0 )
103
+ >>>>>> > 903 cbeb (✔ run setup based on position in autoloads (# 105))
103
104
104
105
105
106
# Reorders the autoloads in the project settings, to get the ModLoader on top.
@@ -125,11 +126,13 @@ func reorder_autoloads() -> void:
125
126
126
127
# Saves the ProjectSettings to a override.cfg file in the base game directory.
127
128
func handle_override_cfg () -> void :
129
+ modloaderutils .log_debug ("using the override.cfg file" , LOG_NAME )
128
130
var _save_custom_error : int = ProjectSettings .save_custom (modloaderutils .get_override_path ())
129
131
130
132
131
133
# Creates the project.binary file, adds it to the pck and removes the no longer needed project.binary file.
132
134
func handle_project_binary () -> void :
135
+ modloaderutils .log_debug ("injecting the project.binary file" , LOG_NAME )
133
136
create_project_binary ()
134
137
inject_project_binary ()
135
138
clean_up_project_binary_file ()
@@ -182,23 +185,3 @@ func setup_file_data() -> void:
182
185
183
186
modloaderutils .log_debug_json_print ("path: " , path , LOG_NAME )
184
187
modloaderutils .log_debug_json_print ("file_name: " , file_name , LOG_NAME )
185
-
186
-
187
- func is_loader_set_up () -> bool :
188
- return is_project_setting_true (settings .IS_LOADER_SET_UP )
189
-
190
-
191
- func is_loader_setup_applied () -> bool :
192
- if not root .get_node_or_null ("/root/ModLoader" ) == null :
193
- if not is_project_setting_true (settings .IS_LOADER_SETUP_APPLIED ):
194
- modloaderutils .log_info ("ModLoader is already set up. No self setup required." , LOG_NAME )
195
- return true
196
- return false
197
-
198
-
199
- static func is_project_setting_true (project_setting : String ) -> bool :
200
- return ProjectSettings .has_setting (project_setting ) and \
201
- ProjectSettings .get_setting (project_setting )
202
-
203
-
204
-
0 commit comments