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
+2
View File
@@ -2,6 +2,8 @@ class_name RootUI extends Control
@export var debugMenu:DebugMenu
@export var textBox:VNTextbox
@export var gameMenu:GameMenu
@export var pauseMenu:PauseMenu
func _enter_tree() -> void:
UI.rootUi = self
+10 -2
View File
@@ -1,11 +1,12 @@
[gd_scene load_steps=5 format=3 uid="uid://baos0arpiskbp"]
[gd_scene load_steps=6 format=3 uid="uid://baos0arpiskbp"]
[ext_resource type="PackedScene" uid="uid://bkx3l0kckf4a8" path="res://ui/component/VNTextbox.tscn" id="1_1mtk3"]
[ext_resource type="Script" uid="uid://dq3qyyayugt5l" path="res://ui/RootUI.gd" id="1_son71"]
[ext_resource type="PackedScene" uid="uid://c0i5e2dj11d8c" path="res://ui/pause/PauseMenu.tscn" id="2_atyu8"]
[ext_resource type="PackedScene" uid="uid://b38dr0wkix76t" path="res://ui/debugmenu/DebugMenu.tscn" id="4_u132g"]
[ext_resource type="PackedScene" uid="uid://bv5r2x9m4k7n1" path="res://ui/gamemenu/GameMenu.tscn" id="5_gmenu"]
[node name="RootUI" type="Control" node_paths=PackedStringArray("debugMenu", "textBox")]
[node name="RootUI" type="Control" node_paths=PackedStringArray("debugMenu", "textBox", "gameMenu", "pauseMenu")]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
@@ -16,6 +17,8 @@ mouse_filter = 2
script = ExtResource("1_son71")
debugMenu = NodePath("DebugMenu")
textBox = NodePath("VNTextbox")
gameMenu = NodePath("GameMenu")
pauseMenu = NodePath("PauseMenu")
metadata/_custom_type_script = "uid://dq3qyyayugt5l"
[node name="DebugMenu" parent="." instance=ExtResource("4_u132g")]
@@ -25,6 +28,11 @@ layout_mode = 1
[node name="PauseMenu" parent="." instance=ExtResource("2_atyu8")]
visible = false
layout_mode = 1
process_mode = 3
[node name="GameMenu" parent="." instance=ExtResource("5_gmenu")]
visible = false
layout_mode = 1
[node name="VNTextbox" parent="." instance=ExtResource("1_1mtk3")]
visible = false
+13 -1
View File
@@ -16,4 +16,16 @@ var TEXTBOX:
get():
if rootUi && rootUi.textBox:
return rootUi.textBox
return null
return null
var GAME_MENU:
get():
if rootUi && rootUi.gameMenu:
return rootUi.gameMenu
return null
var PAUSE_MENU:
get():
if rootUi && rootUi.pauseMenu:
return rootUi.pauseMenu
return null
+52
View File
@@ -0,0 +1,52 @@
class_name GameMenu extends Control
enum Tab { PARTY, ITEMS }
@export var SIDEBAR:ItemList
@export var PARTY_TAB:GameMenuPartyTab
@export var ITEMS_TAB:GameMenuItemsTab
var _currentTab:Tab = Tab.PARTY
func _ready() -> void:
visible = false
SIDEBAR.item_selected.connect(_onTabSelected)
func open() -> void:
visible = true
_selectTab(_currentTab)
SIDEBAR.select(_currentTab)
SIDEBAR.grab_focus()
func close() -> void:
visible = false
func isOpen() -> bool:
return visible
func _onTabSelected(index:int) -> void:
_selectTab(index as Tab)
func _selectTab(tab:Tab) -> void:
_currentTab = tab
PARTY_TAB.visible = (tab == Tab.PARTY)
ITEMS_TAB.visible = (tab == Tab.ITEMS)
match tab:
Tab.PARTY:
PARTY_TAB.refresh()
Tab.ITEMS:
ITEMS_TAB.refresh()
func _unhandled_input(event:InputEvent) -> void:
if event.is_action_pressed("menu"):
if visible:
close()
elif !UI.dialogueActive && UI.TEXTBOX.isClosed:
open()
get_viewport().set_input_as_handled()
return
if !visible:
return
if event.is_action_pressed("ui_cancel"):
close()
get_viewport().set_input_as_handled()
+1
View File
@@ -0,0 +1 @@
uid://dvqu7spul754e
+76
View File
@@ -0,0 +1,76 @@
[gd_scene load_steps=5 format=3 uid="uid://bv5r2x9m4k7n1"]
[ext_resource type="Script" uid="uid://dn8p3y6a1s5t2" path="res://ui/gamemenu/GameMenu.gd" id="1_gmgd"]
[ext_resource type="PackedScene" uid="uid://br9c7x4t1n6q2" path="res://ui/gamemenu/GameMenuPartyTab.tscn" id="2_ptab"]
[ext_resource type="PackedScene" uid="uid://bq4m7v2k9d3c1" path="res://ui/gamemenu/GameMenuItemsTab.tscn" id="3_itab"]
[node name="GameMenu" type="Control" node_paths=PackedStringArray("SIDEBAR", "PARTY_TAB", "ITEMS_TAB")]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 0
script = ExtResource("1_gmgd")
SIDEBAR = NodePath("MarginContainer/HBoxContainer/SidebarPanel/VBoxContainer/Sidebar")
PARTY_TAB = NodePath("MarginContainer/HBoxContainer/ContentPanel/GameMenuPartyTab")
ITEMS_TAB = NodePath("MarginContainer/HBoxContainer/ContentPanel/GameMenuItemsTab")
[node name="ColorRect" type="ColorRect" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
color = Color(0, 0, 0, 0.75)
[node name="MarginContainer" type="MarginContainer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 16
theme_override_constants/margin_right = 16
theme_override_constants/margin_top = 12
theme_override_constants/margin_bottom = 12
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer"]
layout_mode = 2
theme_override_constants/separation = 8
[node name="SidebarPanel" type="PanelContainer" parent="MarginContainer/HBoxContainer"]
layout_mode = 2
custom_minimum_size = Vector2(120, 0)
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/HBoxContainer/SidebarPanel"]
layout_mode = 2
theme_override_constants/separation = 4
[node name="MenuTitle" type="Label" parent="MarginContainer/HBoxContainer/SidebarPanel/VBoxContainer"]
layout_mode = 2
horizontal_alignment = 1
text = "MENU"
[node name="Sidebar" type="ItemList" parent="MarginContainer/HBoxContainer/SidebarPanel/VBoxContainer"]
layout_mode = 2
size_flags_vertical = 3
auto_width = true
item_count = 2
item_0/text = "Party"
item_1/text = "Items"
[node name="ContentPanel" type="PanelContainer" parent="MarginContainer/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
[node name="GameMenuPartyTab" parent="MarginContainer/HBoxContainer/ContentPanel" instance=ExtResource("2_ptab")]
layout_mode = 2
[node name="GameMenuItemsTab" parent="MarginContainer/HBoxContainer/ContentPanel" instance=ExtResource("3_itab")]
layout_mode = 2
visible = false
+32
View File
@@ -0,0 +1,32 @@
class_name GameMenuItemsTab extends Control
func refresh() -> void:
var container = $ScrollContainer/ItemContainer
for child in container.get_children():
child.queue_free()
var items = PARTY.BACKPACK.items
if items.is_empty():
var empty = Label.new()
empty.text = "No items."
container.add_child(empty)
return
for stack in items:
container.add_child(_makeItemRow(stack))
func _makeItemRow(stack:ItemStack) -> Control:
var panel = PanelContainer.new()
var hbox = HBoxContainer.new()
panel.add_child(hbox)
var nameLabel = Label.new()
nameLabel.text = Item.getItemHandle(stack.item).capitalize()
nameLabel.size_flags_horizontal = Control.SIZE_EXPAND_FILL
hbox.add_child(nameLabel)
var qtyLabel = Label.new()
qtyLabel.text = "x%d" % stack.quantity
hbox.add_child(qtyLabel)
return panel
+1
View File
@@ -0,0 +1 @@
uid://bmhnyuhkwti7i
+25
View File
@@ -0,0 +1,25 @@
[gd_scene load_steps=2 format=3 uid="uid://bq4m7v2k9d3c1"]
[ext_resource type="Script" uid="uid://cx6h2j9r4b8w5" path="res://ui/gamemenu/GameMenuItemsTab.gd" id="1_itabgd"]
[node name="GameMenuItemsTab" 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_itabgd")
[node name="ScrollContainer" type="ScrollContainer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="ItemContainer" type="VBoxContainer" parent="ScrollContainer"]
layout_mode = 2
size_flags_horizontal = 3
theme_override_constants/separation = 4
+68
View File
@@ -0,0 +1,68 @@
class_name GameMenuPartyTab extends Control
func refresh() -> void:
var list = $ScrollContainer/MemberList
for child in list.get_children():
child.queue_free()
for member in PARTY.getFullParty():
list.add_child(_makeMemberCard(member))
func _makeMemberCard(member:PartyMember) -> Control:
var panel = PanelContainer.new()
var margin = MarginContainer.new()
panel.add_child(margin)
margin.add_theme_constant_override("margin_left", 8)
margin.add_theme_constant_override("margin_right", 8)
margin.add_theme_constant_override("margin_top", 6)
margin.add_theme_constant_override("margin_bottom", 6)
var vbox = VBoxContainer.new()
margin.add_child(vbox)
# Name + status row
var headerRow = HBoxContainer.new()
vbox.add_child(headerRow)
var nameLabel = Label.new()
nameLabel.text = member.name
nameLabel.size_flags_horizontal = Control.SIZE_EXPAND_FILL
headerRow.add_child(nameLabel)
var statusLabel = Label.new()
statusLabel.text = "DEAD" if member.status == BattleFighter.Status.DEAD else "OK"
headerRow.add_child(statusLabel)
# HP row
var hpRow = HBoxContainer.new()
hpRow.add_theme_constant_override("separation", 6)
vbox.add_child(hpRow)
var hpKey = Label.new()
hpKey.text = "HP"
hpKey.custom_minimum_size = Vector2(30, 0)
hpRow.add_child(hpKey)
var hpVal = Label.new()
hpVal.text = "%d / %d" % [member.health, member.maxHealth]
hpRow.add_child(hpVal)
# MP row
var mpRow = HBoxContainer.new()
mpRow.add_theme_constant_override("separation", 6)
vbox.add_child(mpRow)
var mpKey = Label.new()
mpKey.text = "MP"
mpKey.custom_minimum_size = Vector2(30, 0)
mpRow.add_child(mpKey)
var mpVal = Label.new()
mpVal.text = "%d / %d" % [member.mp, member.maxMp]
mpRow.add_child(mpVal)
# Stats row
var statsRow = HBoxContainer.new()
statsRow.add_theme_constant_override("separation", 14)
vbox.add_child(statsRow)
for pair in [["ATK", member.attack], ["DEF", member.defense], ["SPD", member.speed], ["MAG", member.magic], ["LCK", member.luck]]:
var label = Label.new()
label.text = "%s %d" % [pair[0], pair[1]]
statsRow.add_child(label)
return panel
+1
View File
@@ -0,0 +1 @@
uid://bfklpf0grikg5
+25
View File
@@ -0,0 +1,25 @@
[gd_scene load_steps=2 format=3 uid="uid://br9c7x4t1n6q2"]
[ext_resource type="Script" uid="uid://dw3n5k8m2p1a7" path="res://ui/gamemenu/GameMenuPartyTab.gd" id="1_ptabgd"]
[node name="GameMenuPartyTab" 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_ptabgd")
[node name="ScrollContainer" type="ScrollContainer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="MemberList" type="VBoxContainer" parent="ScrollContainer"]
layout_mode = 2
size_flags_horizontal = 3
theme_override_constants/separation = 6
+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
+13
View File
@@ -2,9 +2,15 @@ class_name SettingsMenu extends Control
@export var tabs:TabBar
@export var tabControls:Array[Control]
@export var checkInvertX:CheckBox
@export var checkInvertY:CheckBox
func _ready() -> void:
tabs.tab_changed.connect(onTabChanged)
checkInvertX.button_pressed = SETTINGS.invertCameraX
checkInvertY.button_pressed = SETTINGS.invertCameraY
checkInvertX.toggled.connect(func(v:bool): SETTINGS.invertCameraX = v)
checkInvertY.toggled.connect(func(v:bool): SETTINGS.invertCameraY = v)
onTabChanged(tabs.current_tab)
func _notification(what:int) -> void:
@@ -16,3 +22,10 @@ func onTabChanged(tabIndex:int) -> void:
control.visible = false
if tabIndex >= 0 and tabIndex < tabControls.size():
tabControls[tabIndex].visible = true
_focusFirstIn(tabControls[tabIndex])
func _focusFirstIn(container:Control) -> void:
for child in container.get_children():
if child is Control and child.focus_mode != Control.FOCUS_NONE:
child.grab_focus()
return
+24 -3
View File
@@ -2,7 +2,7 @@
[ext_resource type="Script" uid="uid://efmr0xkbw1py" path="res://ui/settings/SettingsMenu.gd" id="1_4lnig"]
[node name="SettingsMenu" type="Control" node_paths=PackedStringArray("tabs", "tabControls")]
[node name="SettingsMenu" type="Control" node_paths=PackedStringArray("tabs", "tabControls", "checkInvertX", "checkInvertY")]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
@@ -11,7 +11,9 @@ grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_4lnig")
tabs = NodePath("VBoxContainer/TabBar")
tabControls = [NodePath("VBoxContainer/ScrollContainer/LabelGameplay"), NodePath("VBoxContainer/ScrollContainer/LabelSound"), NodePath("VBoxContainer/ScrollContainer/LabelGraphics")]
tabControls = [NodePath("VBoxContainer/ScrollContainer/LabelGameplay"), NodePath("VBoxContainer/ScrollContainer/LabelSound"), NodePath("VBoxContainer/ScrollContainer/LabelGraphics"), NodePath("VBoxContainer/ScrollContainer/PanelControls")]
checkInvertX = NodePath("VBoxContainer/ScrollContainer/PanelControls/CheckInvertX")
checkInvertY = NodePath("VBoxContainer/ScrollContainer/PanelControls/CheckInvertY")
[node name="VBoxContainer" type="VBoxContainer" parent="."]
layout_mode = 1
@@ -24,10 +26,11 @@ grow_vertical = 2
[node name="TabBar" type="TabBar" parent="VBoxContainer"]
layout_mode = 2
current_tab = 0
tab_count = 3
tab_count = 4
tab_0/title = "Gameplay"
tab_1/title = "Sound"
tab_2/title = "Graphics"
tab_3/title = "Controls"
[node name="ScrollContainer" type="ScrollContainer" parent="VBoxContainer"]
layout_mode = 2
@@ -47,3 +50,21 @@ text = "Sound"
visible = false
layout_mode = 2
text = "Gameplay"
[node name="PanelControls" type="VBoxContainer" parent="VBoxContainer/ScrollContainer"]
visible = false
layout_mode = 2
[node name="LabelController" type="Label" parent="VBoxContainer/ScrollContainer/PanelControls"]
layout_mode = 2
text = "Controller"
[node name="CheckInvertX" type="CheckBox" parent="VBoxContainer/ScrollContainer/PanelControls"]
layout_mode = 2
focus_mode = 2
text = "Invert Camera X"
[node name="CheckInvertY" type="CheckBox" parent="VBoxContainer/ScrollContainer/PanelControls"]
layout_mode = 2
focus_mode = 2
text = "Invert Camera Y"