Options controller - part 4 of 4
func apply() -> void:
var options: Dictionary = Runtime.call("get_runtime_options")
for key: String in NUMBERS:
var spec: Array = NUMBERS[key]
var slider: Range = control(str(spec[0])) as Range
if is_instance_valid(slider):
options[key] = clampf(slider.value, float(spec[1]), float(spec[2]))
for key: String in CHECKS:
var check: BaseButton = control(str(CHECKS[key])) as BaseButton
if is_instance_valid(check) and not check.disabled:
options[key] = check.button_pressed
options["language"] = selected_language("opt_language", "en")
var voice: String = selected_language("opt_voice_language", "auto")
options["voiceLanguage"] = "" if voice == "auto" else voice
Runtime.call("apply_runtime_options", options, true)
fill(Runtime.call("get_runtime_options"))
await SetVariable({"name":"options_notice", "value":"Options saved."})func defaults() -> void:
fill(Runtime.get("project_default_options"))
await SetVariable({"name":"options_notice",
"value":"Defaults selected. Choose Apply to save them."})func back() -> void:
Runtime.call("show_system_interface", return_surface)apply preserves unrelated options and persists the changes. defaults stages the project defaults in the controls. back changes system surfaces without applying the staged values.
Use the small wrappers on the following page to call these functions from ordinary GUI events.
