Enhance Party Menu

This commit is contained in:
Luke Hubmayer-Werner 2023-12-09 22:30:43 +10:30
parent 09c2a16087
commit 83f8c76fe5
3 changed files with 377 additions and 149 deletions

View File

@ -1,74 +0,0 @@
[gd_scene format=2]
[node name="ItemsMenu" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
[node name="HBoxContainer" type="HBoxContainer" parent="."]
anchor_right = 1.0
margin_bottom = 22.0
custom_constants/separation = 0
[node name="title" type="PanelContainer" parent="HBoxContainer"]
margin_right = 45.0
margin_bottom = 22.0
[node name="ITEMS" type="Label" parent="HBoxContainer/title"]
margin_left = 4.0
margin_top = 4.0
margin_right = 41.0
margin_bottom = 18.0
text = "Items"
[node name="actions" type="PanelContainer" parent="HBoxContainer"]
margin_left = 45.0
margin_right = 384.0
margin_bottom = 22.0
size_flags_horizontal = 3
[node name="HBoxContainer" type="HBoxContainer" parent="HBoxContainer/actions"]
margin_left = 4.0
margin_top = 4.0
margin_right = 335.0
margin_bottom = 18.0
[node name="Label" type="Label" parent="HBoxContainer/actions/HBoxContainer"]
margin_right = 105.0
margin_bottom = 14.0
size_flags_horizontal = 3
text = "Use"
align = 1
[node name="Label2" type="Label" parent="HBoxContainer/actions/HBoxContainer"]
margin_left = 113.0
margin_right = 218.0
margin_bottom = 14.0
size_flags_horizontal = 3
text = "Sort"
align = 1
[node name="Label3" type="Label" parent="HBoxContainer/actions/HBoxContainer"]
margin_left = 226.0
margin_right = 331.0
margin_bottom = 14.0
size_flags_horizontal = 3
text = "Rare"
align = 1
[node name="itemdesc" type="PanelContainer" parent="."]
anchor_right = 1.0
margin_top = 22.0
margin_bottom = 66.0
[node name="Label" type="Label" parent="itemdesc"]
margin_left = 4.0
margin_top = 4.0
margin_right = 380.0
margin_bottom = 40.0
size_flags_vertical = 1
text = "Item description"
[node name="items" type="PanelContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
margin_top = 66.0

View File

@ -1,8 +1,26 @@
extends Panel
onready var sidebar_classic := $'%sidebar_classic'
onready var sbc_menu_item_containers := [$'%menu_items_1', $'%menu_items_2']
onready var characters_container := $'%characters_container'
onready var items_menu := $'%items_menu'
onready var items_container := $'%items_container'
enum Submenu {PARTY, ITEMS}
const str2submenu := {
'party': Submenu.PARTY,
'items': Submenu.ITEMS,
}
var submenu2sbc_label := {}
onready var submenu2widget := {
Submenu.PARTY: characters_container,
Submenu.ITEMS: items_menu,
}
func update_labels(data: Dictionary):
var characters = data.characters
var character_panels = $characters.get_children()
var character_panels = characters_container.get_children()
for i in len(characters):
var p = character_panels[i]
p.visible = not characters[i].is_absent
@ -11,11 +29,73 @@ func update_labels(data: Dictionary):
$'%lbl_time'.text = Common.game_time_frames_to_hhmm(data.game_time_frames)
$'%lbl_gilcount'.text = '%d' % data.current_gil
for child in items_container.get_children():
child.queue_free()
for i in 256:
var item_id = data.inventory_item_ids[i]
var item_qty = data.inventory_item_qtys[i]
var item_name = StringLoader.tables.items[item_id]
var lbl_item_name := Label.new()
var lbl_item_qty := Label.new()
lbl_item_qty.align = HALIGN_RIGHT
if item_qty > 0:
lbl_item_name.text = item_name
lbl_item_qty.text = 'x%d'%item_qty
items_container.add_child(lbl_item_name)
items_container.add_child(lbl_item_qty)
func _init_sidebar_classic() -> void:
for menu_item_container in sbc_menu_item_containers:
for label in menu_item_container.get_children():
var submenu = str2submenu.get(label.name, -1)
if submenu > -1:
self.submenu2sbc_label[submenu] = label
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
_init_sidebar_classic()
var _err = change_submenu(Submenu.PARTY)
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta: float) -> void:
# pass
const active_label_colour := Color.yellow
const inactive_label_colour := Color.white
func change_submenu(submenu_id) -> int:
# print(submenu)
if not (submenu_id in submenu2widget):
return ERR_DOES_NOT_EXIST
# Make everything inactive/invisible
for submenu in submenu2widget.values():
submenu.visible = false
for label in submenu2sbc_label.values():
label.modulate = inactive_label_colour
# Make the selected submenu active/visible
submenu2widget[submenu_id].visible = true
submenu2sbc_label[submenu_id].modulate = active_label_colour
return OK
func change_submenu_by_name(name: String) -> int:
var submenu = str2submenu.get(name, -1)
if submenu < 0:
return ERR_DOES_NOT_EXIST
return change_submenu(submenu)
func _on_sidebar_classic_click(pos: Vector2) -> int:
for menu_item_container in sbc_menu_item_containers:
var rect: Rect2 = menu_item_container.get_global_rect()
if rect.has_point(pos):
var local_y := pos.y - rect.position.y
var menu_items: Array = menu_item_container.get_children()
# A y-check is sufficient if we assume all labels are the same height
var label_height: float = menu_items[0].rect_size.y
var selected_label: int = int(local_y/label_height)
if selected_label < len(menu_items):
return change_submenu_by_name(menu_items[selected_label].name)
return ERR_CANT_RESOLVE
func _input(event: InputEvent) -> void:
if (event is InputEventMouseButton or event is InputEventScreenTouch) and event.pressed:
var pos: Vector2 = event.position
if sidebar_classic.get_global_rect().has_point(pos):
var _err = _on_sidebar_classic_click(pos)

View File

@ -7,143 +7,144 @@
[node name="PartyMenu" type="Panel"]
margin_right = 336.0
margin_bottom = 240.0
rect_min_size = Vector2( 320, 240 )
rect_min_size = Vector2( 384, 240 )
theme = ExtResource( 1 )
script = ExtResource( 2 )
[node name="characters" type="VBoxContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 8.0
margin_top = 8.0
margin_right = -8.0
margin_bottom = -8.0
[node name="PartyMenuCharacter" parent="characters" instance=ExtResource( 3 )]
[node name="PartyMenuCharacter2" parent="characters" instance=ExtResource( 3 )]
margin_top = 58.0
margin_bottom = 108.0
[node name="PartyMenuCharacter3" parent="characters" instance=ExtResource( 3 )]
margin_top = 116.0
margin_bottom = 166.0
[node name="PartyMenuCharacter4" parent="characters" instance=ExtResource( 3 )]
margin_top = 174.0
margin_bottom = 224.0
[node name="rightside" type="VBoxContainer" parent="."]
anchor_left = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = -64.0
[node name="sidebar_classic" type="VBoxContainer" parent="."]
unique_name_in_owner = true
rect_min_size = Vector2( 64, 240 )
size_flags_horizontal = 8
size_flags_vertical = 8
custom_constants/separation = 0
alignment = 2
[node name="panel_menu" type="PanelContainer" parent="rightside"]
margin_left = 8.0
[node name="panel_menu" type="PanelContainer" parent="sidebar_classic"]
margin_right = 64.0
margin_bottom = 36.0
rect_min_size = Vector2( 56, 0 )
margin_bottom = 50.0
rect_min_size = Vector2( 64, 0 )
size_flags_horizontal = 8
[node name="VBoxContainer" type="VBoxContainer" parent="rightside/panel_menu"]
[node name="MarginContainer" type="MarginContainer" parent="sidebar_classic/panel_menu"]
margin_left = 4.0
margin_top = 4.0
margin_right = 52.0
margin_bottom = 32.0
margin_right = 60.0
margin_bottom = 46.0
custom_constants/margin_left = 12
[node name="menu_items_1" type="VBoxContainer" parent="sidebar_classic/panel_menu/MarginContainer"]
unique_name_in_owner = true
margin_left = 12.0
margin_right = 56.0
margin_bottom = 42.0
custom_constants/separation = 0
[node name="lbl_job" type="Label" parent="rightside/panel_menu/VBoxContainer"]
margin_right = 48.0
[node name="party" type="Label" parent="sidebar_classic/panel_menu/MarginContainer/menu_items_1"]
margin_right = 44.0
margin_bottom = 14.0
text = "Party"
[node name="job" type="Label" parent="sidebar_classic/panel_menu/MarginContainer/menu_items_1"]
modulate = Color( 0.501961, 0.501961, 0.501961, 1 )
margin_top = 14.0
margin_right = 44.0
margin_bottom = 28.0
text = "Job"
[node name="lbl_ability" type="Label" parent="rightside/panel_menu/VBoxContainer"]
margin_top = 14.0
margin_right = 48.0
margin_bottom = 28.0
[node name="ability" type="Label" parent="sidebar_classic/panel_menu/MarginContainer/menu_items_1"]
modulate = Color( 0.501961, 0.501961, 0.501961, 1 )
margin_top = 28.0
margin_right = 44.0
margin_bottom = 42.0
text = "Ability"
[node name="panel_menu2" type="PanelContainer" parent="rightside"]
margin_left = 8.0
margin_top = 36.0
[node name="panel_menu2" type="PanelContainer" parent="sidebar_classic"]
margin_top = 50.0
margin_right = 64.0
margin_bottom = 128.0
rect_min_size = Vector2( 56, 0 )
margin_bottom = 142.0
rect_min_size = Vector2( 64, 0 )
size_flags_horizontal = 8
[node name="VBoxContainer" type="VBoxContainer" parent="rightside/panel_menu2"]
[node name="MarginContainer" type="MarginContainer" parent="sidebar_classic/panel_menu2"]
margin_left = 4.0
margin_top = 4.0
margin_right = 52.0
margin_right = 60.0
margin_bottom = 88.0
custom_constants/margin_left = 12
[node name="menu_items_2" type="VBoxContainer" parent="sidebar_classic/panel_menu2/MarginContainer"]
unique_name_in_owner = true
margin_left = 12.0
margin_right = 56.0
margin_bottom = 84.0
custom_constants/separation = 0
[node name="lbl_items" type="Label" parent="rightside/panel_menu2/VBoxContainer"]
margin_right = 48.0
[node name="items" type="Label" parent="sidebar_classic/panel_menu2/MarginContainer/menu_items_2"]
margin_right = 44.0
margin_bottom = 14.0
text = "Items"
[node name="lbl_magic" type="Label" parent="rightside/panel_menu2/VBoxContainer"]
[node name="magic" type="Label" parent="sidebar_classic/panel_menu2/MarginContainer/menu_items_2"]
modulate = Color( 0.501961, 0.501961, 0.501961, 1 )
margin_top = 14.0
margin_right = 48.0
margin_right = 44.0
margin_bottom = 28.0
text = "Magic"
[node name="lbl_equip" type="Label" parent="rightside/panel_menu2/VBoxContainer"]
[node name="equip" type="Label" parent="sidebar_classic/panel_menu2/MarginContainer/menu_items_2"]
modulate = Color( 0.501961, 0.501961, 0.501961, 1 )
margin_top = 28.0
margin_right = 48.0
margin_right = 44.0
margin_bottom = 42.0
text = "Equip"
[node name="lbl_status" type="Label" parent="rightside/panel_menu2/VBoxContainer"]
[node name="status" type="Label" parent="sidebar_classic/panel_menu2/MarginContainer/menu_items_2"]
modulate = Color( 0.501961, 0.501961, 0.501961, 1 )
margin_top = 42.0
margin_right = 48.0
margin_right = 44.0
margin_bottom = 56.0
text = "Status"
[node name="lbl_config" type="Label" parent="rightside/panel_menu2/VBoxContainer"]
[node name="config" type="Label" parent="sidebar_classic/panel_menu2/MarginContainer/menu_items_2"]
modulate = Color( 0.501961, 0.501961, 0.501961, 1 )
margin_top = 56.0
margin_right = 48.0
margin_right = 44.0
margin_bottom = 70.0
text = "Config"
[node name="lbl_save" type="Label" parent="rightside/panel_menu2/VBoxContainer"]
[node name="save" type="Label" parent="sidebar_classic/panel_menu2/MarginContainer/menu_items_2"]
modulate = Color( 0.501961, 0.501961, 0.501961, 1 )
margin_top = 70.0
margin_right = 48.0
margin_right = 44.0
margin_bottom = 84.0
text = "Save"
[node name="spacer" type="Control" parent="rightside"]
margin_top = 128.0
[node name="spacer" type="Control" parent="sidebar_classic"]
margin_top = 142.0
margin_right = 64.0
margin_bottom = 168.0
size_flags_vertical = 3
[node name="panel_time" type="PanelContainer" parent="rightside"]
[node name="panel_time" type="PanelContainer" parent="sidebar_classic"]
margin_top = 168.0
margin_right = 64.0
margin_bottom = 204.0
rect_min_size = Vector2( 64, 0 )
size_flags_horizontal = 8
[node name="VBoxContainer" type="VBoxContainer" parent="rightside/panel_time"]
[node name="VBoxContainer" type="VBoxContainer" parent="sidebar_classic/panel_time"]
margin_left = 4.0
margin_top = 4.0
margin_right = 60.0
margin_bottom = 32.0
custom_constants/separation = 0
[node name="TIME" type="Label" parent="rightside/panel_time/VBoxContainer"]
[node name="TIME" type="Label" parent="sidebar_classic/panel_time/VBoxContainer"]
margin_right = 56.0
margin_bottom = 14.0
text = "Time"
[node name="lbl_time" type="Label" parent="rightside/panel_time/VBoxContainer"]
[node name="lbl_time" type="Label" parent="sidebar_classic/panel_time/VBoxContainer"]
unique_name_in_owner = true
margin_top = 14.0
margin_right = 56.0
@ -151,29 +152,250 @@ margin_bottom = 28.0
text = "000:00:00"
align = 2
[node name="panel_gil" type="PanelContainer" parent="rightside"]
[node name="panel_gil" type="PanelContainer" parent="sidebar_classic"]
margin_top = 204.0
margin_right = 64.0
margin_bottom = 240.0
rect_min_size = Vector2( 64, 0 )
[node name="VBoxContainer" type="VBoxContainer" parent="rightside/panel_gil"]
[node name="VBoxContainer" type="VBoxContainer" parent="sidebar_classic/panel_gil"]
margin_left = 4.0
margin_top = 4.0
margin_right = 60.0
margin_bottom = 32.0
custom_constants/separation = 0
[node name="lbl_gilcount" type="Label" parent="rightside/panel_gil/VBoxContainer"]
[node name="lbl_gilcount" type="Label" parent="sidebar_classic/panel_gil/VBoxContainer"]
unique_name_in_owner = true
margin_right = 56.0
margin_bottom = 14.0
text = "0000000"
align = 2
[node name="GIL" type="Label" parent="rightside/panel_gil/VBoxContainer"]
[node name="GIL" type="Label" parent="sidebar_classic/panel_gil/VBoxContainer"]
margin_top = 14.0
margin_right = 56.0
margin_bottom = 28.0
text = "Gil"
align = 2
[node name="sidebar_modern" type="VBoxContainer" parent="."]
margin_left = -64.0
margin_bottom = 240.0
rect_min_size = Vector2( 64, 240 )
size_flags_horizontal = 8
size_flags_vertical = 8
custom_constants/separation = 0
alignment = 2
[node name="btn_party" type="Button" parent="sidebar_modern"]
margin_right = 64.0
margin_bottom = 22.0
text = "Party"
[node name="btn_job" type="Button" parent="sidebar_modern"]
margin_top = 22.0
margin_right = 64.0
margin_bottom = 44.0
text = "Job"
[node name="btn_items" type="Button" parent="sidebar_modern"]
margin_top = 44.0
margin_right = 64.0
margin_bottom = 66.0
text = "Items"
[node name="btn_equip" type="Button" parent="sidebar_modern"]
margin_top = 66.0
margin_right = 64.0
margin_bottom = 88.0
text = "Equip"
[node name="btn_status" type="Button" parent="sidebar_modern"]
margin_top = 88.0
margin_right = 64.0
margin_bottom = 110.0
text = "Status"
[node name="btn_config" type="Button" parent="sidebar_modern"]
margin_top = 110.0
margin_right = 64.0
margin_bottom = 132.0
text = "Config"
[node name="spacer" type="Control" parent="sidebar_modern"]
margin_top = 132.0
margin_right = 64.0
margin_bottom = 146.0
size_flags_vertical = 3
[node name="btn_save" type="Button" parent="sidebar_modern"]
margin_top = 146.0
margin_right = 64.0
margin_bottom = 168.0
text = "Save"
[node name="panel_time" type="PanelContainer" parent="sidebar_modern"]
margin_top = 168.0
margin_right = 64.0
margin_bottom = 204.0
rect_min_size = Vector2( 64, 0 )
size_flags_horizontal = 8
[node name="VBoxContainer" type="VBoxContainer" parent="sidebar_modern/panel_time"]
margin_left = 4.0
margin_top = 4.0
margin_right = 60.0
margin_bottom = 32.0
custom_constants/separation = 0
[node name="TIME" type="Label" parent="sidebar_modern/panel_time/VBoxContainer"]
margin_right = 56.0
margin_bottom = 14.0
text = "Time"
[node name="lbl_time" type="Label" parent="sidebar_modern/panel_time/VBoxContainer"]
margin_top = 14.0
margin_right = 56.0
margin_bottom = 28.0
text = "000:00:00"
align = 2
[node name="panel_gil" type="PanelContainer" parent="sidebar_modern"]
margin_top = 204.0
margin_right = 64.0
margin_bottom = 240.0
rect_min_size = Vector2( 64, 0 )
[node name="VBoxContainer" type="VBoxContainer" parent="sidebar_modern/panel_gil"]
margin_left = 4.0
margin_top = 4.0
margin_right = 60.0
margin_bottom = 32.0
custom_constants/separation = 0
[node name="lbl_gilcount" type="Label" parent="sidebar_modern/panel_gil/VBoxContainer"]
margin_right = 56.0
margin_bottom = 14.0
text = "0000000"
align = 2
[node name="GIL" type="Label" parent="sidebar_modern/panel_gil/VBoxContainer"]
margin_top = 14.0
margin_right = 56.0
margin_bottom = 28.0
text = "Gil"
align = 2
[node name="submenus" type="Control" parent="."]
margin_left = 64.0
margin_right = 384.0
margin_bottom = 240.0
rect_min_size = Vector2( 320, 240 )
[node name="items_menu" type="Control" parent="submenus"]
unique_name_in_owner = true
visible = false
anchor_right = 1.0
anchor_bottom = 1.0
[node name="HBoxContainer" type="HBoxContainer" parent="submenus/items_menu"]
anchor_right = 1.0
margin_bottom = 22.0
custom_constants/separation = 0
[node name="title" type="PanelContainer" parent="submenus/items_menu/HBoxContainer"]
margin_right = 41.0
margin_bottom = 22.0
[node name="ITEMS" type="Label" parent="submenus/items_menu/HBoxContainer/title"]
margin_left = 4.0
margin_top = 4.0
margin_right = 37.0
margin_bottom = 18.0
text = "Items"
[node name="actions" type="PanelContainer" parent="submenus/items_menu/HBoxContainer"]
margin_left = 41.0
margin_right = 320.0
margin_bottom = 22.0
size_flags_horizontal = 3
[node name="HBoxContainer" type="HBoxContainer" parent="submenus/items_menu/HBoxContainer/actions"]
margin_left = 4.0
margin_top = 4.0
margin_right = 275.0
margin_bottom = 18.0
[node name="Label" type="Label" parent="submenus/items_menu/HBoxContainer/actions/HBoxContainer"]
margin_right = 85.0
margin_bottom = 14.0
size_flags_horizontal = 3
text = "Use"
align = 1
[node name="Label2" type="Label" parent="submenus/items_menu/HBoxContainer/actions/HBoxContainer"]
margin_left = 93.0
margin_right = 178.0
margin_bottom = 14.0
size_flags_horizontal = 3
text = "Sort"
align = 1
[node name="Label3" type="Label" parent="submenus/items_menu/HBoxContainer/actions/HBoxContainer"]
margin_left = 186.0
margin_right = 271.0
margin_bottom = 14.0
size_flags_horizontal = 3
text = "Rare"
align = 1
[node name="itemdesc" type="PanelContainer" parent="submenus/items_menu"]
anchor_right = 1.0
margin_top = 22.0
margin_bottom = 66.0
[node name="Label" type="Label" parent="submenus/items_menu/itemdesc"]
margin_left = 4.0
margin_top = 4.0
margin_right = 316.0
margin_bottom = 40.0
size_flags_vertical = 1
text = "Item description"
[node name="items" type="PanelContainer" parent="submenus/items_menu"]
anchor_right = 1.0
anchor_bottom = 1.0
margin_top = 66.0
[node name="ScrollContainer" type="ScrollContainer" parent="submenus/items_menu/items"]
margin_left = 4.0
margin_top = 4.0
margin_right = 316.0
margin_bottom = 170.0
[node name="items_container" type="GridContainer" parent="submenus/items_menu/items/ScrollContainer"]
unique_name_in_owner = true
custom_constants/vseparation = 0
columns = 4
[node name="characters_container" type="VBoxContainer" parent="submenus"]
unique_name_in_owner = true
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 8.0
margin_top = 8.0
[node name="PartyMenuCharacter1" parent="submenus/characters_container" instance=ExtResource( 3 )]
[node name="PartyMenuCharacter2" parent="submenus/characters_container" instance=ExtResource( 3 )]
margin_top = 58.0
margin_bottom = 108.0
[node name="PartyMenuCharacter3" parent="submenus/characters_container" instance=ExtResource( 3 )]
margin_top = 116.0
margin_bottom = 166.0
[node name="PartyMenuCharacter4" parent="submenus/characters_container" instance=ExtResource( 3 )]
margin_top = 174.0
margin_bottom = 224.0