PressAnyKeyScreen → SplashScreen
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
extends Control
|
||||
|
||||
@onready var press_any_key_screen = $PressAnyKeyScreen
|
||||
@onready var splash_screen = $SplashScreen
|
||||
var current_menu = null
|
||||
|
||||
const MAIN_MENU_SCENE = preload("res://scenes/ui/MainMenu.tscn")
|
||||
@@ -8,11 +8,53 @@ const SETTINGS_MENU_SCENE = preload("res://scenes/ui/SettingsMenu.tscn")
|
||||
|
||||
func _ready():
|
||||
DebugManager.log_debug("Main scene ready", "Main")
|
||||
press_any_key_screen.any_key_pressed.connect(_on_any_key_pressed)
|
||||
# Use alternative connection method with input handling
|
||||
_setup_splash_screen_connection()
|
||||
|
||||
func _setup_splash_screen_connection():
|
||||
# Wait for all nodes to be ready
|
||||
await get_tree().process_frame
|
||||
await get_tree().process_frame
|
||||
|
||||
# Try to find SplashScreen node
|
||||
splash_screen = get_node_or_null("SplashScreen")
|
||||
if not splash_screen:
|
||||
DebugManager.log_warn("SplashScreen node not found, trying alternative methods", "Main")
|
||||
# Try to find by class or group
|
||||
var splash_nodes = get_tree().get_nodes_in_group("localizable")
|
||||
for node in splash_nodes:
|
||||
if node.scene_file_path.ends_with("SplashScreen.tscn"):
|
||||
splash_screen = node
|
||||
break
|
||||
|
||||
if splash_screen:
|
||||
DebugManager.log_debug("SplashScreen node found: %s" % splash_screen.name, "Main")
|
||||
# Try connecting to the signal if it exists
|
||||
if splash_screen.has_signal("any_key_pressed"):
|
||||
splash_screen.any_key_pressed.connect(_on_any_key_pressed)
|
||||
DebugManager.log_debug("Connected to any_key_pressed signal", "Main")
|
||||
else:
|
||||
# Fallback: use input handling directly on the main scene
|
||||
DebugManager.log_warn("Using fallback input handling", "Main")
|
||||
_use_fallback_input_handling()
|
||||
else:
|
||||
DebugManager.log_error("Could not find SplashScreen node", "Main")
|
||||
_use_fallback_input_handling()
|
||||
|
||||
func _use_fallback_input_handling():
|
||||
# Fallback: handle input directly in the main scene
|
||||
set_process_unhandled_input(true)
|
||||
|
||||
func _unhandled_input(event):
|
||||
if splash_screen and splash_screen.is_inside_tree():
|
||||
# Forward input to splash screen or handle directly
|
||||
if event.is_action_pressed("action_south"):
|
||||
_on_any_key_pressed()
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
func _on_any_key_pressed():
|
||||
DebugManager.log_debug("Transitioning to main menu", "Main")
|
||||
press_any_key_screen.queue_free()
|
||||
splash_screen.queue_free()
|
||||
show_main_menu()
|
||||
|
||||
func show_main_menu():
|
||||
|
||||
Reference in New Issue
Block a user