Add some UI

This commit is contained in:
2026-06-11 20:42:08 -05:00
parent 456ea1e07e
commit f46f08c083
29 changed files with 678 additions and 88 deletions
+12 -6
View File
@@ -1,19 +1,25 @@
class_name PauseMain extends VBoxContainer
signal resumeRequested
signal settingsRequested
signal quitRequested
@export var btnResume:Button
@export var btnSettings:Button
@export var btnQuit:Button
func _ready() -> void:
visible = false
$HBoxContainer/ItemList.item_selected.connect(onItemSelected)
btnResume.pressed.connect(resumeRequested.emit)
btnSettings.pressed.connect(settingsRequested.emit)
btnQuit.pressed.connect(quitRequested.emit)
func open() -> void:
visible = true
$HBoxContainer/ItemList.clear()
$HBoxContainer/ItemList.grab_focus()
btnResume.grab_focus()
func close() -> void:
visible = false
func isOpen() -> bool:
return visible
func onItemSelected(index:int) -> void:
print("Selected item index: ", index)
+18 -36
View File
@@ -2,51 +2,33 @@
[ext_resource type="Script" uid="uid://c7kvg0jw6w340" path="res://ui/pause/PauseMain.gd" id="1_b5xfl"]
[node name="PauseMain" type="VBoxContainer"]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
[node name="PauseMain" type="VBoxContainer" node_paths=PackedStringArray("btnResume", "btnSettings", "btnQuit")]
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_b5xfl")
metadata/_custom_type_script = "uid://c7kvg0jw6w340"
btnResume = NodePath("Resume")
btnSettings = NodePath("Settings")
btnQuit = NodePath("Quit")
[node name="HBoxContainer" type="HBoxContainer" parent="."]
[node name="Title" type="Label" parent="."]
layout_mode = 2
size_flags_vertical = 3
text = "Paused"
horizontal_alignment = 1
[node name="PanelContainer" type="PanelContainer" parent="HBoxContainer"]
[node name="Resume" type="Button" parent="."]
layout_mode = 2
size_flags_horizontal = 3
text = "Resume"
[node name="ItemList" type="ItemList" parent="HBoxContainer"]
[node name="Settings" type="Button" parent="."]
layout_mode = 2
auto_width = true
item_count = 6
item_0/text = "Equpiment"
item_1/text = "Abilities"
item_2/text = "Items"
item_3/text = "Quests"
item_4/text = "Settings"
item_5/text = "Save"
text = "Settings"
[node name="HBoxContainer2" type="HBoxContainer" parent="."]
[node name="Quit" type="Button" parent="."]
layout_mode = 2
[node name="PanelContainer" type="PanelContainer" parent="HBoxContainer2"]
layout_mode = 2
size_flags_horizontal = 3
[node name="HBoxContainer" type="GridContainer" parent="HBoxContainer2/PanelContainer"]
layout_mode = 2
size_flags_horizontal = 8
theme_override_constants/h_separation = 8
columns = 2
[node name="Money" type="Label" parent="HBoxContainer2/PanelContainer/HBoxContainer"]
layout_mode = 2
text = "%MONEY%"
[node name="Playtime" type="Label" parent="HBoxContainer2/PanelContainer/HBoxContainer"]
layout_mode = 2
text = "%PLAYTIME%"
text = "Quit Game"
+13 -4
View File
@@ -1,29 +1,38 @@
class_name PauseMenu extends Control
@export var MAIN:PauseMain
@export var SETTINGS:PauseSettings
@export var settingsPanel:PauseSettings
func _ready() -> void:
close()
MAIN.resumeRequested.connect(close)
MAIN.settingsRequested.connect(_openSettings)
MAIN.quitRequested.connect(func(): get_tree().quit())
func isOpen() -> bool:
return visible
func open() -> void:
visible = true
get_tree().paused = true
MAIN.open()
func close() -> void:
get_tree().paused = false
visible = false
MAIN.close()
SETTINGS.close()
settingsPanel.close()
func _openSettings() -> void:
MAIN.close()
settingsPanel.open()
func _unhandled_input(event:InputEvent) -> void:
if !visible:
return
if event.is_action_pressed("ui_cancel"):
if SETTINGS.isOpen():
SETTINGS.close()
if settingsPanel.isOpen():
settingsPanel.close()
MAIN.open()
else:
close()
+2 -2
View File
@@ -4,7 +4,7 @@
[ext_resource type="Script" uid="uid://cgvf34t5qgwbm" path="res://ui/pause/PauseMenu.gd" id="1_82qxy"]
[ext_resource type="PackedScene" uid="uid://qgk5trrh6dfd" path="res://ui/pause/PauseSettings.tscn" id="2_3djnw"]
[node name="PauseMenu" type="Control" node_paths=PackedStringArray("MAIN", "SETTINGS")]
[node name="PauseMenu" type="Control" node_paths=PackedStringArray("MAIN", "settingsPanel")]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
@@ -13,7 +13,7 @@ grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_82qxy")
MAIN = NodePath("PauseMain")
SETTINGS = NodePath("PauseSettings")
settingsPanel = NodePath("PauseSettings")
[node name="PauseSettings" parent="." instance=ExtResource("2_3djnw")]
visible = false