Files
Dawn-Godot/ui/UISingleton.gd
T
2026-06-14 10:19:31 -05:00

85 lines
2.0 KiB
GDScript

extends Node
const _FocusStackScript = preload("res://ui/UIFocusStack.gd")
var rootUi:RootUI = null
var interactIndicator:InteractIndicator = null
var FOCUS_STACK:RefCounted = null
# True whenever any dialogue resource is being processed by DialogueManager.
# Driven by DialogueManager.dialogue_started / dialogue_ended signals.
var dialogueActive:bool = false
# True only during a CONVERSATION-mode sequence. Blocks player movement.
var activeConversation:bool = false
func _ready() -> void:
FOCUS_STACK = _FocusStackScript.new()
DialogueManager.dialogue_started.connect(_onDialogueStarted)
DialogueManager.dialogue_ended.connect(_onDialogueEnded)
SCENE.sceneChanged.connect(_onSceneChanged)
func _onDialogueStarted(_resource:DialogueResource) -> void:
dialogueActive = true
func _onDialogueEnded(_resource:DialogueResource) -> void:
dialogueActive = false
func _onSceneChanged(_newScene:SceneSingleton.SceneType) -> void:
_cleanupDialogue()
func _cleanupDialogue() -> void:
if chatBoxContainer:
for child in chatBoxContainer.get_children():
if child is DialogueTextbox or child is DialogueChoiceBox:
child.queue_free()
activeConversation = false
dialogueActive = false
if INTERACT_INDICATOR:
INTERACT_INDICATOR.clear()
var INTERACT_INDICATOR:InteractIndicator:
get(): return interactIndicator
var chatBoxContainer:Control:
get():
if rootUi:
return rootUi.chatBoxContainer
return null
var DEBUG_MENU:DebugMenu:
get():
if rootUi:
return rootUi.debugMenu
return null
var GAME_MENU:GameMenu:
get():
if rootUi:
return rootUi.gameMenu
return null
var PAUSE_MENU:PauseMenu:
get():
if rootUi:
return rootUi.pauseMenu
return null
var QUIT_DIALOG:QuitConfirmDialog:
get():
if rootUi:
return rootUi.quitConfirmDialog
return null
var MAIN_MENU_DIALOG:ConfirmDialog:
get():
if rootUi:
return rootUi.mainMenuConfirmDialog
return null
var BACKDROP:ModalBackdrop:
get():
if rootUi:
return rootUi.modalBackdrop
return null