PressAnyKeyScreen → SplashScreen
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://dmwkyeq2l7u04"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://b16jnk7w22mb" path="res://scenes/game/game.gd" id="1_uwrxv"]
|
||||
[ext_resource type="Script" uid="uid://bs4veuda3h358" path="res://scenes/game/game.gd" id="1_uwrxv"]
|
||||
[ext_resource type="PackedScene" path="res://scenes/ui/DebugToggle.tscn" id="3_debug"]
|
||||
[ext_resource type="Texture2D" uid="uid://c8y6tlvcgh2gn" path="res://assets/textures/backgrounds/beanstalk-dark.webp" id="5_background"]
|
||||
|
||||
@@ -21,6 +21,7 @@ anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
texture = ExtResource("5_background")
|
||||
expand_mode = 1
|
||||
stretch_mode = 1
|
||||
|
||||
[node name="UI" type="Control" parent="."]
|
||||
@@ -53,7 +54,9 @@ grow_vertical = 2
|
||||
|
||||
[node name="BackButtonContainer" type="Control" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 0
|
||||
anchors_preset = 1
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
offset_left = 10.0
|
||||
offset_top = 10.0
|
||||
offset_right = 55.0
|
||||
|
||||
@@ -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")]
|
||||
|
||||
17
scenes/ui/DebugButton.gd
Normal file
17
scenes/ui/DebugButton.gd
Normal file
@@ -0,0 +1,17 @@
|
||||
extends Control
|
||||
|
||||
@onready var button: Button = $Button
|
||||
|
||||
func _ready():
|
||||
button.pressed.connect(_on_button_pressed)
|
||||
DebugManager.debug_ui_toggled.connect(_on_debug_ui_toggled)
|
||||
|
||||
# Initialize with current debug UI state
|
||||
var current_state = DebugManager.is_debug_ui_visible()
|
||||
button.text = "Debug UI: " + ("ON" if current_state else "OFF")
|
||||
|
||||
func _on_button_pressed():
|
||||
DebugManager.toggle_debug_ui()
|
||||
|
||||
func _on_debug_ui_toggled(visible: bool):
|
||||
button.text = "Debug UI: " + ("ON" if visible else "OFF")
|
||||
1
scenes/ui/DebugButton.gd.uid
Normal file
1
scenes/ui/DebugButton.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bwc2yembdjbci
|
||||
@@ -1,7 +1,72 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://m8lf3eh3al5j"]
|
||||
[gd_scene load_steps=13 format=3 uid="uid://m8lf3eh3al5j"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://b2x0kw8f70s8q" path="res://scenes/ui/MainMenu.gd" id="1_b00nv"]
|
||||
[ext_resource type="PackedScene" uid="uid://df2b4wn8j6cxl" path="res://scenes/ui/DebugToggle.tscn" id="2_debug"]
|
||||
[ext_resource type="Texture2D" uid="uid://btfjyc4jfhiii" path="res://assets/sprites/characters/skeleton/Skeleton Hit.png" id="2_iwbf0"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_2ysvc"]
|
||||
atlas = ExtResource("2_iwbf0")
|
||||
region = Rect2(0, 0, 30, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_xpiny"]
|
||||
atlas = ExtResource("2_iwbf0")
|
||||
region = Rect2(30, 0, 30, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_bhu4a"]
|
||||
atlas = ExtResource("2_iwbf0")
|
||||
region = Rect2(60, 0, 30, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_e2per"]
|
||||
atlas = ExtResource("2_iwbf0")
|
||||
region = Rect2(90, 0, 30, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_7mi0g"]
|
||||
atlas = ExtResource("2_iwbf0")
|
||||
region = Rect2(120, 0, 30, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_nqjyj"]
|
||||
atlas = ExtResource("2_iwbf0")
|
||||
region = Rect2(150, 0, 30, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_7vr37"]
|
||||
atlas = ExtResource("2_iwbf0")
|
||||
region = Rect2(180, 0, 30, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_kncl5"]
|
||||
atlas = ExtResource("2_iwbf0")
|
||||
region = Rect2(210, 0, 30, 32)
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_clp4r"]
|
||||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_2ysvc")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_xpiny")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_bhu4a")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_e2per")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_7mi0g")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_nqjyj")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_7vr37")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_kncl5")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"default",
|
||||
"speed": 5.0
|
||||
}]
|
||||
|
||||
[node name="MainMenu" type="Control"]
|
||||
layout_mode = 3
|
||||
@@ -13,6 +78,7 @@ grow_vertical = 2
|
||||
script = ExtResource("1_b00nv")
|
||||
|
||||
[node name="MenuContainer" type="VBoxContainer" parent="."]
|
||||
custom_minimum_size = Vector2(200, 100)
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
@@ -25,6 +91,17 @@ offset_right = 20.0
|
||||
offset_bottom = 20.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
||||
[node name="SpriteContainer" type="Control" parent="MenuContainer"]
|
||||
custom_minimum_size = Vector2(30, 32)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="MenuContainer/SpriteContainer"]
|
||||
sprite_frames = SubResource("SpriteFrames_clp4r")
|
||||
autoplay = "default"
|
||||
frame_progress = 0.574348
|
||||
|
||||
[node name="NewGameButton" type="Button" parent="MenuContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
Reference in New Issue
Block a user