Skip to reading
Replace the Built-in Screens

Menu controller - part 1 of 2

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: menu_tools. Global Script: on. Paste Part 2 after Part 1 in the same record. No event subscriptions are needed for this controller.

Code example
extends "res://scripts/runtime/script_base.gd"
Code example
var return_surface: String = "pauseMenu"
var was_main: bool = false
Code example
func on_global_ready(_context: Dictionary = {}) -> void:
    set_process(true)
Code example
func _process(_delta: float) -> void:
    var manager: Node = Runtime.get("authored_gui_manager")
    if not is_instance_valid(manager):
        return
    var main_open: bool = bool(manager.call("is_gui_visible", "main_custom"))
    if main_open and not was_main:
        var nodes: Dictionary = manager.get("element_nodes")
        var button: BaseButton = nodes.get("main_custom_button_1") as BaseButton
        if is_instance_valid(button):
            button.disabled = int(Runtime.call("latest_save_slot")) < 0
    was_main = main_open

The controller checks Continue when main_custom becomes visible. It scans saved positions once at that opening, rather than repeatedly checking the disk every frame.

main_custom_button_1 is the Continue Button in this layout. If you give it a clearer ID in your project, change that one lookup too.

Page 70 of 88Permalink
Go to page