NEO-75: add collapsible economy HUD section
Reparent inventory, skills, and craft panel under EconomyHudSection with an Economy HUD toggle; update main.gd node paths and GdUnit tests.pull/109/head
parent
fbae3148d2
commit
025d6e529d
|
|
@ -18,6 +18,7 @@
|
||||||
[ext_resource type="Script" path="res://scripts/recipe_definitions_client.gd" id="17_recipe_defs"]
|
[ext_resource type="Script" path="res://scripts/recipe_definitions_client.gd" id="17_recipe_defs"]
|
||||||
[ext_resource type="Script" path="res://scripts/craft_client.gd" id="18_craft"]
|
[ext_resource type="Script" path="res://scripts/craft_client.gd" id="18_craft"]
|
||||||
[ext_resource type="Script" path="res://scripts/craft_recipe_panel.gd" id="19_craft_panel"]
|
[ext_resource type="Script" path="res://scripts/craft_recipe_panel.gd" id="19_craft_panel"]
|
||||||
|
[ext_resource type="Script" path="res://scripts/prototype_economy_hud_section.gd" id="20_economy_hud"]
|
||||||
|
|
||||||
[sub_resource type="NavigationMesh" id="NavigationMesh_district"]
|
[sub_resource type="NavigationMesh" id="NavigationMesh_district"]
|
||||||
geometry_collision_mask = 1
|
geometry_collision_mask = 1
|
||||||
|
|
@ -1211,13 +1212,29 @@ theme_override_font_sizes/font_size = 14
|
||||||
autowrap_mode = 3
|
autowrap_mode = 3
|
||||||
text = "Cooldowns: —"
|
text = "Cooldowns: —"
|
||||||
|
|
||||||
[node name="InventoryLabel" type="Label" parent="UICanvas" unique_id=9000007]
|
[node name="EconomyHudSection" type="VBoxContainer" parent="UICanvas" unique_id=9000014]
|
||||||
offset_left = 8.0
|
offset_left = 8.0
|
||||||
offset_top = 524.0
|
offset_top = 524.0
|
||||||
offset_right = 520.0
|
offset_right = 520.0
|
||||||
offset_bottom = 672.0
|
offset_bottom = 1056.0
|
||||||
grow_horizontal = 0
|
grow_horizontal = 0
|
||||||
grow_vertical = 0
|
grow_vertical = 0
|
||||||
|
script = ExtResource("20_economy_hud")
|
||||||
|
|
||||||
|
[node name="HeaderRow" type="HBoxContainer" parent="UICanvas/EconomyHudSection" unique_id=9000015]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="ToggleButton" type="CheckButton" parent="UICanvas/EconomyHudSection/HeaderRow" unique_id=9000016]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Economy HUD"
|
||||||
|
|
||||||
|
[node name="Body" type="VBoxContainer" parent="UICanvas/EconomyHudSection" unique_id=9000017]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="InventoryLabel" type="Label" parent="UICanvas/EconomyHudSection/Body" unique_id=9000007]
|
||||||
|
custom_minimum_size = Vector2(512, 148)
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
theme_override_colors/font_color = Color(0.9, 0.86, 0.98, 1)
|
theme_override_colors/font_color = Color(0.9, 0.86, 0.98, 1)
|
||||||
theme_override_colors/font_outline_color = Color(0.08, 0.08, 0.1, 1)
|
theme_override_colors/font_outline_color = Color(0.08, 0.08, 0.1, 1)
|
||||||
theme_override_constants/outline_size = 6
|
theme_override_constants/outline_size = 6
|
||||||
|
|
@ -1226,13 +1243,10 @@ autowrap_mode = 3
|
||||||
text = "Inventory: (refresh: I)
|
text = "Inventory: (refresh: I)
|
||||||
Loading…"
|
Loading…"
|
||||||
|
|
||||||
[node name="SkillProgressionLabel" type="Label" parent="UICanvas" unique_id=9000009]
|
[node name="SkillProgressionLabel" type="Label" parent="UICanvas/EconomyHudSection/Body" unique_id=9000009]
|
||||||
offset_left = 8.0
|
custom_minimum_size = Vector2(512, 84)
|
||||||
offset_top = 684.0
|
layout_mode = 2
|
||||||
offset_right = 520.0
|
size_flags_horizontal = 3
|
||||||
offset_bottom = 768.0
|
|
||||||
grow_horizontal = 0
|
|
||||||
grow_vertical = 0
|
|
||||||
theme_override_colors/font_color = Color(0.82, 0.9, 1, 1)
|
theme_override_colors/font_color = Color(0.82, 0.9, 1, 1)
|
||||||
theme_override_colors/font_outline_color = Color(0.08, 0.08, 0.1, 1)
|
theme_override_colors/font_outline_color = Color(0.08, 0.08, 0.1, 1)
|
||||||
theme_override_constants/outline_size = 6
|
theme_override_constants/outline_size = 6
|
||||||
|
|
@ -1241,19 +1255,17 @@ autowrap_mode = 3
|
||||||
text = "Skills:
|
text = "Skills:
|
||||||
Loading…"
|
Loading…"
|
||||||
|
|
||||||
[node name="CraftRecipePanel" type="Control" parent="UICanvas" unique_id=9000011]
|
[node name="CraftRecipePanel" type="Control" parent="UICanvas/EconomyHudSection/Body" unique_id=9000011]
|
||||||
anchors_preset = 0
|
custom_minimum_size = Vector2(512, 280)
|
||||||
offset_left = 8.0
|
layout_mode = 2
|
||||||
offset_top = 776.0
|
size_flags_horizontal = 3
|
||||||
offset_right = 520.0
|
|
||||||
offset_bottom = 1056.0
|
|
||||||
script = ExtResource("19_craft_panel")
|
script = ExtResource("19_craft_panel")
|
||||||
|
|
||||||
[node name="ScrollContainer" type="ScrollContainer" parent="UICanvas/CraftRecipePanel" unique_id=9000012]
|
[node name="ScrollContainer" type="ScrollContainer" parent="UICanvas/EconomyHudSection/Body/CraftRecipePanel" unique_id=9000012]
|
||||||
layout_mode = 0
|
layout_mode = 0
|
||||||
offset_right = 512.0
|
offset_right = 512.0
|
||||||
offset_bottom = 280.0
|
offset_bottom = 280.0
|
||||||
|
|
||||||
[node name="VBoxContainer" type="VBoxContainer" parent="UICanvas/CraftRecipePanel/ScrollContainer" unique_id=9000013]
|
[node name="VBoxContainer" type="VBoxContainer" parent="UICanvas/EconomyHudSection/Body/CraftRecipePanel/ScrollContainer" unique_id=9000013]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
|
|
|
||||||
|
|
@ -102,11 +102,11 @@ var _recipe_defs_error: String = ""
|
||||||
@onready var _target_lock_label: Label = $UICanvas/TargetLockLabel
|
@onready var _target_lock_label: Label = $UICanvas/TargetLockLabel
|
||||||
@onready var _cast_feedback_label: Label = $UICanvas/CastFeedbackLabel
|
@onready var _cast_feedback_label: Label = $UICanvas/CastFeedbackLabel
|
||||||
@onready var _cooldown_slots_label: Label = $UICanvas/CooldownSlotsLabel
|
@onready var _cooldown_slots_label: Label = $UICanvas/CooldownSlotsLabel
|
||||||
@onready var _inventory_label: Label = $UICanvas/InventoryLabel
|
@onready var _inventory_label: Label = $UICanvas/EconomyHudSection/Body/InventoryLabel
|
||||||
@onready var _gather_feedback_label: Label = $UICanvas/GatherFeedbackLabel
|
@onready var _gather_feedback_label: Label = $UICanvas/GatherFeedbackLabel
|
||||||
@onready var _craft_feedback_label: Label = $UICanvas/CraftFeedbackLabel
|
@onready var _craft_feedback_label: Label = $UICanvas/CraftFeedbackLabel
|
||||||
@onready var _skill_progression_label: Label = $UICanvas/SkillProgressionLabel
|
@onready var _skill_progression_label: Label = $UICanvas/EconomyHudSection/Body/SkillProgressionLabel
|
||||||
@onready var _craft_recipe_panel: Node = $UICanvas/CraftRecipePanel
|
@onready var _craft_recipe_panel: Node = $UICanvas/EconomyHudSection/Body/CraftRecipePanel
|
||||||
@onready var _inventory_client: Node = $InventoryClient
|
@onready var _inventory_client: Node = $InventoryClient
|
||||||
@onready var _item_defs_client: Node = $ItemDefinitionsClient
|
@onready var _item_defs_client: Node = $ItemDefinitionsClient
|
||||||
@onready var _skill_progression_client: Node = $SkillProgressionClient
|
@onready var _skill_progression_client: Node = $SkillProgressionClient
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
extends VBoxContainer
|
||||||
|
|
||||||
|
## NEO-75: collapsible economy HUD block (inventory, skills, craft panel).
|
||||||
|
|
||||||
|
@onready var _toggle: CheckButton = $HeaderRow/ToggleButton
|
||||||
|
@onready var _body: VBoxContainer = $Body
|
||||||
|
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
_toggle.button_pressed = true
|
||||||
|
_body.visible = true
|
||||||
|
_toggle.toggled.connect(_on_toggle_toggled)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_toggle_toggled(pressed: bool) -> void:
|
||||||
|
_body.visible = pressed
|
||||||
|
|
||||||
|
|
||||||
|
func set_expanded(expanded: bool) -> void:
|
||||||
|
_toggle.button_pressed = expanded
|
||||||
|
_body.visible = expanded
|
||||||
|
|
||||||
|
|
||||||
|
func is_body_visible() -> bool:
|
||||||
|
return _body.visible
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
uid://bneo75economyhud1
|
||||||
|
|
@ -0,0 +1,60 @@
|
||||||
|
extends GdUnitTestSuite
|
||||||
|
|
||||||
|
## NEO-75: economy HUD collapse toggle shows/hides body container.
|
||||||
|
|
||||||
|
const EconomyHudSection := preload("res://scripts/prototype_economy_hud_section.gd")
|
||||||
|
|
||||||
|
|
||||||
|
func _build_section() -> Node:
|
||||||
|
var section: VBoxContainer = EconomyHudSection.new()
|
||||||
|
var header := HBoxContainer.new()
|
||||||
|
header.name = "HeaderRow"
|
||||||
|
var toggle := CheckButton.new()
|
||||||
|
toggle.name = "ToggleButton"
|
||||||
|
toggle.text = "Economy HUD"
|
||||||
|
header.add_child(toggle)
|
||||||
|
var body := VBoxContainer.new()
|
||||||
|
body.name = "Body"
|
||||||
|
var inventory := Label.new()
|
||||||
|
inventory.name = "InventoryLabel"
|
||||||
|
body.add_child(inventory)
|
||||||
|
section.add_child(header)
|
||||||
|
section.add_child(body)
|
||||||
|
return section
|
||||||
|
|
||||||
|
|
||||||
|
func test_body_visible_when_expanded_by_default() -> void:
|
||||||
|
# Arrange
|
||||||
|
var section := _build_section()
|
||||||
|
add_child(section)
|
||||||
|
await await_idle_frame()
|
||||||
|
# Act
|
||||||
|
var visible: bool = section.call("is_body_visible")
|
||||||
|
# Assert
|
||||||
|
assert_bool(visible).is_true()
|
||||||
|
|
||||||
|
|
||||||
|
func test_toggle_collapses_body() -> void:
|
||||||
|
# Arrange
|
||||||
|
var section := _build_section()
|
||||||
|
add_child(section)
|
||||||
|
await await_idle_frame()
|
||||||
|
# Act
|
||||||
|
section.get_node("HeaderRow/ToggleButton").button_pressed = false
|
||||||
|
await await_idle_frame()
|
||||||
|
# Assert
|
||||||
|
assert_bool(section.call("is_body_visible")).is_false()
|
||||||
|
|
||||||
|
|
||||||
|
func test_toggle_expands_body_again() -> void:
|
||||||
|
# Arrange
|
||||||
|
var section := _build_section()
|
||||||
|
add_child(section)
|
||||||
|
await await_idle_frame()
|
||||||
|
section.call("set_expanded", false)
|
||||||
|
await await_idle_frame()
|
||||||
|
# Act
|
||||||
|
section.call("set_expanded", true)
|
||||||
|
await await_idle_frame()
|
||||||
|
# Assert
|
||||||
|
assert_bool(section.call("is_body_visible")).is_true()
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
uid://bneo75economyhudtest1
|
||||||
Loading…
Reference in New Issue