Skip to reading
Replace the Built-in Screens

Options controller - part 2 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 open(from_surface: String = "pauseMenu") -> void:
    return_surface = from_surface
    Runtime.call("show_system_interface", "optionsMenu")
    fill(Runtime.call("get_runtime_options"))
    was_open = true
    await SetVariable({"name":"options_notice",
        "value":"Change settings, then choose Apply."})
Code example
func fill(options: Dictionary) -> void:
    for key: String in NUMBERS:
        var slider: Range = control(str(NUMBERS[key][0])) as Range
        if is_instance_valid(slider):
            slider.set_value_no_signal(float(options.get(key, 1.0)))
    for key: String in CHECKS:
        var check: BaseButton = control(str(CHECKS[key])) as BaseButton
        if is_instance_valid(check):
            check.set_pressed_no_signal(bool(options.get(key, false)))
    select_language("opt_language", str(options.get("language", "en")))
    var voice: String = str(options.get("voiceLanguage", ""))
    select_language("opt_voice_language", "auto" if voice.is_empty() else voice)
    var autosave: BaseButton = control("opt_autosave") as BaseButton
    if is_instance_valid(autosave):
        autosave.disabled = not bool(Runtime.call("can_player_toggle_game_autosave"))

open records the parent menu. fill uses the applied runtime values, sets controls without emitting an artificial user change, and respects the project’s autosave-toggle permission.

Continue with the next part in the same options_tools record. Do not add another extends line.

Page 73 of 88Permalink
Go to page