Skip to reading
Replace the Built-in Screens

Options controller - part 4 of 4

Edition 0.86.4.1 HF1

0.86.4.1 Hotfix 1 edition. Earlier lessons and screenshots retain their original version context; revised references and supplements describe the newer behavior.

Download PDFView PDF page
Code example
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."})
Code example
func defaults() -> void:
    fill(Runtime.get("project_default_options"))
    await SetVariable({"name":"options_notice",
        "value":"Defaults selected. Choose Apply to save them."})
Code example
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.

Page 75 of 88Permalink
Go to page