@@ -150,16 +150,56 @@ func _update_ml_options_from_options_resource() -> void:
150150 var ml_options_path := "res://addons/mod_loader/options/options.tres"
151151
152152 # Get user options for ModLoader
153- if _ModLoaderFile .file_exists (ml_options_path ):
154- var options_resource := load (ml_options_path )
155- if not options_resource .current_options == null :
156- var current_options : Resource = options_resource .current_options
157- # Update from the options in the resource
158- for key in ml_options :
159- ml_options [key ] = current_options [key ]
160- else :
153+ if not _ModLoaderFile .file_exists (ml_options_path ):
161154 ModLoaderLog .fatal (str ("A critical file is missing: " , ml_options_path ), LOG_NAME )
162155
156+ var options_resource : ModLoaderCurrentOptions = load (ml_options_path )
157+ if options_resource .current_options == null :
158+ ModLoaderLog .warning (str (
159+ "No current options are set. Falling back to defaults. " ,
160+ "Edit your options at %s . " % ml_options_path
161+ ), LOG_NAME )
162+ else :
163+ var current_options = options_resource .current_options
164+ if not current_options is ModLoaderOptionsProfile :
165+ ModLoaderLog .error (str (
166+ "Current options is not a valid Resource of type ModLoaderOptionsProfile. " ,
167+ "Please edit your options at %s . " % ml_options_path
168+ ), LOG_NAME )
169+ # Update from the options in the resource
170+ for key in ml_options :
171+ ml_options [key ] = current_options [key ]
172+
173+ # Get options overrides by feature tags
174+ # An override is saved as Dictionary[String: ModLoaderOptionsProfile]
175+ for feature_tag in options_resource .feature_override_options .keys ():
176+ if not feature_tag is String :
177+ ModLoaderLog .error (str (
178+ "Options override keys are required to be of type String. Failing key: \" %s .\" " % feature_tag ,
179+ "Please edit your options at %s . " % ml_options_path ,
180+ "Consult the documentation for all available feature tags: " ,
181+ "https://docs.godotengine.org/en/3.5/tutorials/export/feature_tags.html"
182+ ), LOG_NAME )
183+ continue
184+
185+ if not OS .has_feature (feature_tag ):
186+ ModLoaderLog .info ("Options override feature tag \" %s \" . does not apply, skipping." % feature_tag , LOG_NAME )
187+ continue
188+
189+ ModLoaderLog .info ("Applying options override with feature tag \" %s \" ." % feature_tag , LOG_NAME )
190+ var override_options = options_resource .feature_override_options [feature_tag ]
191+ if not override_options is ModLoaderOptionsProfile :
192+ ModLoaderLog .error (str (
193+ "Options override is not a valid Resource of type ModLoaderOptionsProfile. " ,
194+ "Options override key with invalid resource: \" %s \" . " % feature_tag ,
195+ "Please edit your options at %s . " % ml_options_path
196+ ), LOG_NAME )
197+ continue
198+
199+ # Update from the options in the resource
200+ for key in ml_options :
201+ ml_options [key ] = override_options [key ]
202+
163203
164204# Update ModLoader's options, via CLI args
165205func _update_ml_options_from_cli_args () -> void :
0 commit comments