Skip to reading
Replace the Built-in Screens

Menu controller - part 2 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
Code example
func open(surface: String, from_surface: String = "pauseMenu") -> void:
    return_surface = from_surface
    Runtime.call("show_system_interface", surface)
Code example
func back() -> void:
    Runtime.call("show_system_interface", return_surface)
Code example
func slot_command(gui_id: String, element_id: String, command: String) -> void:
    var slot: int = int(GetGUIElementProperty(
        gui_id, element_id, "selected_slot", -1))
    if slot < 1:
        await SetVariable({"name":"save_status", "value":"Choose a slot first."})
        return
    await SaveGameWidgetCommand({"guiId":gui_id, "elementId":element_id,
        "command":command, "slot":slot})

open remembers the parent system surface. back opens that parent. slot_command uses the selected slot on the actual widget and returns without saving/loading if no position has been chosen.

The message uses the save_status string variable. Put $$save_status in a Label on both Save and Load screens so the guard produces useful feedback.

The explicit command names are save-slot and load-slot. A selected-slot fallback is deliberately avoided here.

Page 71 of 88Permalink
Go to page