Skip to reading
Replace the Built-in Screens

Options controller - part 1 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

Record ID: options_tools. Global Script: on. All four parts belong in this one record. Create the options_notice string variable used for short status messages.

Code example
extends "res://scripts/runtime/script_base.gd"
Code example
const GUI_ID: String = "options_custom"
const NUMBERS: Dictionary = {
    "masterVolume":["opt_master", 0.0, 1.0],
    "musicVolume":["opt_music", 0.0, 1.0],
    "sfxVolume":["opt_sfx", 0.0, 1.0],
    "voiceVolume":["opt_voice", 0.0, 1.0],
    "textSpeed":["opt_text", 0.1, 5.0],
    "fontScale":["opt_font", 0.5, 2.5]
}
const CHECKS: Dictionary = {
    "subtitles":"opt_subtitles", "highContrast":"opt_contrast",
    "reducedMotion":"opt_motion", "fullscreen":"opt_fullscreen",
    "gameAutosave":"opt_autosave"
}
var return_surface: String = "pauseMenu"
var was_open: bool = false
Code example
func on_global_ready(_context: Dictionary = {}) -> void:
    set_process(true)
Code example
func control(element_id: String) -> Control:
    var manager: Node = Runtime.get("authored_gui_manager")
    if not is_instance_valid(manager):
        return null
    var nodes: Dictionary = manager.get("element_nodes")
    return nodes.get(element_id) as Control
Code example
func _process(_delta: float) -> void:
    var manager: Node = Runtime.get("authored_gui_manager")
    if not is_instance_valid(manager):
        return
    var open_now: bool = bool(manager.call("is_gui_visible", GUI_ID))
    if open_now and not was_open:
        fill(Runtime.call("get_runtime_options"))
    was_open = open_now

The dictionaries map runtime option keys to your element IDs. The small visibility check fills the controls if another route opens the Options GUI.

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

Page 72 of 88Permalink
Go to page