Options controller - part 1 of 4
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.
extends "res://scripts/runtime/script_base.gd"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 = falsefunc on_global_ready(_context: Dictionary = {}) -> void:
set_process(true)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 Controlfunc _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_nowThe 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.
