refactor structure
This commit is contained in:
43
scenes/main/Main.gd
Normal file
43
scenes/main/Main.gd
Normal file
@@ -0,0 +1,43 @@
|
||||
extends Control
|
||||
|
||||
@onready var press_any_key_screen = $PressAnyKeyScreen
|
||||
var current_menu = null
|
||||
|
||||
const MAIN_MENU_SCENE = preload("res://scenes/ui/MainMenu.tscn")
|
||||
const SETTINGS_MENU_SCENE = preload("res://scenes/ui/SettingsMenu.tscn")
|
||||
|
||||
func _ready():
|
||||
print("Main scene ready")
|
||||
press_any_key_screen.any_key_pressed.connect(_on_any_key_pressed)
|
||||
|
||||
func _on_any_key_pressed():
|
||||
print("Transitioning to main menu")
|
||||
press_any_key_screen.queue_free()
|
||||
show_main_menu()
|
||||
|
||||
func show_main_menu():
|
||||
clear_current_menu()
|
||||
var main_menu = MAIN_MENU_SCENE.instantiate()
|
||||
main_menu.open_settings.connect(_on_open_settings)
|
||||
add_child(main_menu)
|
||||
current_menu = main_menu
|
||||
|
||||
func show_settings_menu():
|
||||
clear_current_menu()
|
||||
var settings_menu = SETTINGS_MENU_SCENE.instantiate()
|
||||
settings_menu.back_to_main_menu.connect(_on_back_to_main_menu)
|
||||
add_child(settings_menu)
|
||||
current_menu = settings_menu
|
||||
|
||||
func clear_current_menu():
|
||||
if current_menu:
|
||||
current_menu.queue_free()
|
||||
current_menu = null
|
||||
|
||||
func _on_open_settings():
|
||||
print("Opening settings menu")
|
||||
show_settings_menu()
|
||||
|
||||
func _on_back_to_main_menu():
|
||||
print("Back to main menu")
|
||||
show_main_menu()
|
||||
16
scenes/main/PressAnyKeyScreen.gd
Normal file
16
scenes/main/PressAnyKeyScreen.gd
Normal file
@@ -0,0 +1,16 @@
|
||||
extends Control
|
||||
|
||||
signal any_key_pressed
|
||||
|
||||
func _ready():
|
||||
print("PressAnyKeyScreen ready")
|
||||
update_text()
|
||||
|
||||
func _input(event):
|
||||
if event.is_action_pressed("any_key") or event is InputEventScreenTouch:
|
||||
print("Any key pressed: ", event)
|
||||
any_key_pressed.emit()
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
func update_text():
|
||||
$PressKeyContainer/PressKeyLabel.text = tr("press_ok_continue")
|
||||
134
scenes/main/PressAnyKeyScreen.tscn
Normal file
134
scenes/main/PressAnyKeyScreen.tscn
Normal file
@@ -0,0 +1,134 @@
|
||||
[gd_scene load_steps=15 format=3 uid="uid://gbe1jarrwqsi"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://buak21ajgvevl" path="res://scenes/main/PressAnyKeyScreen.gd" id="1_0a4p2"]
|
||||
[ext_resource type="Texture2D" uid="uid://bcr4bokw87m5n" path="res://assets/sprites/characters/skeleton/Skeleton Idle.png" id="2_rjjcb"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_l6pue"]
|
||||
atlas = ExtResource("2_rjjcb")
|
||||
region = Rect2(0, 0, 24, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_3h5mc"]
|
||||
atlas = ExtResource("2_rjjcb")
|
||||
region = Rect2(24, 0, 24, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_gqpp5"]
|
||||
atlas = ExtResource("2_rjjcb")
|
||||
region = Rect2(48, 0, 24, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_ff5uo"]
|
||||
atlas = ExtResource("2_rjjcb")
|
||||
region = Rect2(72, 0, 24, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_e7oxa"]
|
||||
atlas = ExtResource("2_rjjcb")
|
||||
region = Rect2(96, 0, 24, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_urgkb"]
|
||||
atlas = ExtResource("2_rjjcb")
|
||||
region = Rect2(120, 0, 24, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_xfg50"]
|
||||
atlas = ExtResource("2_rjjcb")
|
||||
region = Rect2(144, 0, 24, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_sy0v8"]
|
||||
atlas = ExtResource("2_rjjcb")
|
||||
region = Rect2(168, 0, 24, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_kfv8w"]
|
||||
atlas = ExtResource("2_rjjcb")
|
||||
region = Rect2(192, 0, 24, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_lvvje"]
|
||||
atlas = ExtResource("2_rjjcb")
|
||||
region = Rect2(216, 0, 24, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_vvh7w"]
|
||||
atlas = ExtResource("2_rjjcb")
|
||||
region = Rect2(240, 0, 24, 32)
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_wtrhp"]
|
||||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_l6pue")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_3h5mc")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_gqpp5")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_ff5uo")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_e7oxa")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_urgkb")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_xfg50")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_sy0v8")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_kfv8w")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_lvvje")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_vvh7w")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"default",
|
||||
"speed": 5.0
|
||||
}]
|
||||
|
||||
[node name="PressAnyKeyScreen" type="Control" groups=["localizable"]]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_0a4p2")
|
||||
|
||||
[node name="PressKeyContainer" type="VBoxContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -80.5
|
||||
offset_top = -25.0
|
||||
offset_right = 80.5
|
||||
offset_bottom = 25.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
||||
[node name="AspectRatioContainer" type="AspectRatioContainer" parent="PressKeyContainer"]
|
||||
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"]
|
||||
sprite_frames = SubResource("SpriteFrames_wtrhp")
|
||||
autoplay = "default"
|
||||
offset = Vector2(0, -30)
|
||||
|
||||
[node name="TitleLabel" type="Label" parent="PressKeyContainer"]
|
||||
layout_mode = 2
|
||||
text = "Skelly"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="PressKeyLabel" type="Label" parent="PressKeyContainer"]
|
||||
layout_mode = 2
|
||||
text = "`press_ok_continue`"
|
||||
27
scenes/main/main.tscn
Normal file
27
scenes/main/main.tscn
Normal file
@@ -0,0 +1,27 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://ci2gk11211n0d"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cwlop1ettlqhg" 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="Texture2D" uid="uid://c8y6tlvcgh2gn" path="res://assets/textures/backgrounds/beanstalk-dark.webp" id="2_sugp2"]
|
||||
|
||||
[node name="main" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_0wfyh")
|
||||
|
||||
[node name="Background" type="TextureRect" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
texture = ExtResource("2_sugp2")
|
||||
stretch_mode = 1
|
||||
|
||||
[node name="PressAnyKeyScreen" parent="." instance=ExtResource("1_o5qli")]
|
||||
layout_mode = 1
|
||||
Reference in New Issue
Block a user