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():
|
||||
|
||||
@@ -3,14 +3,14 @@ extends Control
|
||||
signal any_key_pressed
|
||||
|
||||
func _ready():
|
||||
DebugManager.log_debug("PressAnyKeyScreen ready", "PressAnyKey")
|
||||
DebugManager.log_debug("SplashScreen ready", "SplashScreen")
|
||||
update_text()
|
||||
|
||||
func _input(event):
|
||||
if event.is_action_pressed("action_south") or event is InputEventScreenTouch or (event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed):
|
||||
DebugManager.log_debug("Action pressed: " + str(event), "PressAnyKey")
|
||||
DebugManager.log_debug("Action pressed: " + str(event), "SplashScreen")
|
||||
any_key_pressed.emit()
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
func update_text():
|
||||
$PressKeyContainer/PressKeyLabel.text = tr("press_ok_continue")
|
||||
$SplashContainer/ContinueLabel.text = tr("press_ok_continue")
|
||||
@@ -1,6 +1,6 @@
|
||||
[gd_scene load_steps=16 format=3 uid="uid://gbe1jarrwqsi"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cq7or0bcm2xfj" path="res://scenes/main/PressAnyKeyScreen.gd" id="1_0a4p2"]
|
||||
[ext_resource type="Script" uid="uid://cq7or0bcm2xfj" path="res://scenes/main/SplashScreen.gd" id="1_0a4p2"]
|
||||
[ext_resource type="Texture2D" uid="uid://bcr4bokw87m5n" path="res://assets/sprites/characters/skeleton/Skeleton Idle.png" id="2_rjjcb"]
|
||||
[ext_resource type="PackedScene" uid="uid://df2b4wn8j6cxl" path="res://scenes/ui/DebugToggle.tscn" id="3_debug"]
|
||||
|
||||
@@ -89,7 +89,7 @@ animations = [{
|
||||
"speed": 5.0
|
||||
}]
|
||||
|
||||
[node name="PressAnyKeyScreen" type="Control" groups=["localizable"]]
|
||||
[node name="SplashScreen" type="Control" groups=["localizable"]]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
@@ -98,7 +98,7 @@ grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_0a4p2")
|
||||
|
||||
[node name="PressKeyContainer" type="VBoxContainer" parent="."]
|
||||
[node name="SplashContainer" type="VBoxContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
@@ -113,24 +113,21 @@ grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
||||
[node name="AspectRatioContainer" type="AspectRatioContainer" parent="PressKeyContainer"]
|
||||
[node name="SpriteContainer" type="Control" parent="SplashContainer"]
|
||||
custom_minimum_size = Vector2(30, 32)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 0
|
||||
alignment_horizontal = 0
|
||||
alignment_vertical = 0
|
||||
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="PressKeyContainer/AspectRatioContainer"]
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="SplashContainer/SpriteContainer"]
|
||||
sprite_frames = SubResource("SpriteFrames_wtrhp")
|
||||
autoplay = "default"
|
||||
offset = Vector2(0, -30)
|
||||
|
||||
[node name="TitleLabel" type="Label" parent="PressKeyContainer"]
|
||||
[node name="TitleLabel" type="Label" parent="SplashContainer"]
|
||||
layout_mode = 2
|
||||
text = "Skelly"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="PressKeyLabel" type="Label" parent="PressKeyContainer"]
|
||||
[node name="ContinueLabel" type="Label" parent="SplashContainer"]
|
||||
layout_mode = 2
|
||||
text = "`press_ok_continue`"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://ci2gk11211n0d"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://rvuchiy0guv3" path="res://scenes/main/Main.gd" id="1_0wfyh"]
|
||||
[ext_resource type="PackedScene" uid="uid://gbe1jarrwqsi" path="res://scenes/main/PressAnyKeyScreen.tscn" id="1_o5qli"]
|
||||
[ext_resource type="PackedScene" uid="uid://gbe1jarrwqsi" path="res://scenes/main/SplashScreen.tscn" id="1_o5qli"]
|
||||
[ext_resource type="Texture2D" uid="uid://c8y6tlvcgh2gn" path="res://assets/textures/backgrounds/beanstalk-dark.webp" id="2_sugp2"]
|
||||
[ext_resource type="PackedScene" uid="uid://df2b4wn8j6cxl" path="res://scenes/ui/DebugToggle.tscn" id="4_v7g8d"]
|
||||
|
||||
@@ -22,9 +22,10 @@ anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
texture = ExtResource("2_sugp2")
|
||||
expand_mode = 1
|
||||
stretch_mode = 1
|
||||
|
||||
[node name="PressAnyKeyScreen" parent="." instance=ExtResource("1_o5qli")]
|
||||
[node name="SplashScreen" parent="." instance=ExtResource("1_o5qli")]
|
||||
layout_mode = 1
|
||||
|
||||
[node name="DebugToggle" parent="." instance=ExtResource("4_v7g8d")]
|
||||
|
||||
Reference in New Issue
Block a user