Initial
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
extends Node
|
||||
|
||||
@onready var auth_screen = $AuthScreen
|
||||
@onready var hub_screen = $HubScreen
|
||||
@onready var dungeon_scene = $DungeonScene
|
||||
@onready var death_screen = $DeathScreen
|
||||
|
||||
func _ready():
|
||||
print("[Main] _ready called")
|
||||
_show_screen("AUTH")
|
||||
call_deferred("_setup_signals")
|
||||
|
||||
func _setup_signals():
|
||||
print("[Main] _setup_signals called")
|
||||
if GameState:
|
||||
print("[Main] GameState found, connecting state_changed signal...")
|
||||
GameState.state_changed.connect(_on_state_changed)
|
||||
print("[Main] Signal connected successfully")
|
||||
else:
|
||||
print("[Main] ERROR: GameState autoload not found!")
|
||||
|
||||
func _on_state_changed(new_state: String):
|
||||
print("[Main] _on_state_changed received: ", new_state)
|
||||
_show_screen(new_state)
|
||||
|
||||
func _show_screen(state: String):
|
||||
print("[Main] _show_screen called with: ", state)
|
||||
|
||||
if auth_screen:
|
||||
_set_screen_visible(auth_screen, state == "AUTH")
|
||||
print("[Main] AuthScreen visible: ", state == "AUTH")
|
||||
if hub_screen:
|
||||
_set_screen_visible(hub_screen, state == "HUB")
|
||||
print("[Main] HubScreen visible: ", state == "HUB")
|
||||
if dungeon_scene:
|
||||
_set_screen_visible(dungeon_scene, state == "PLAYING")
|
||||
print("[Main] DungeonScene visible: ", state == "PLAYING")
|
||||
if death_screen:
|
||||
_set_screen_visible(death_screen, state == "DEAD")
|
||||
print("[Main] DeathScreen visible: ", state == "DEAD")
|
||||
|
||||
func _set_screen_visible(node: Node, is_visible: bool):
|
||||
if node == null:
|
||||
return
|
||||
|
||||
if node is CanvasLayer:
|
||||
node.visible = is_visible
|
||||
elif node is CanvasItem:
|
||||
node.visible = is_visible
|
||||
else:
|
||||
node.set_process(is_visible)
|
||||
node.set_physics_process(is_visible)
|
||||
for child in node.get_children():
|
||||
_set_screen_visible(child, is_visible)
|
||||
Reference in New Issue
Block a user