diff --git a/client/scenes/main.tscn b/client/scenes/main.tscn index 7b80b26..eaa0fc6 100644 --- a/client/scenes/main.tscn +++ b/client/scenes/main.tscn @@ -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/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/prototype_economy_hud_section.gd" id="20_economy_hud"] [sub_resource type="NavigationMesh" id="NavigationMesh_district"] geometry_collision_mask = 1 @@ -1211,13 +1212,29 @@ theme_override_font_sizes/font_size = 14 autowrap_mode = 3 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_top = 524.0 offset_right = 520.0 -offset_bottom = 672.0 +offset_bottom = 1056.0 grow_horizontal = 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_outline_color = Color(0.08, 0.08, 0.1, 1) theme_override_constants/outline_size = 6 @@ -1226,13 +1243,10 @@ autowrap_mode = 3 text = "Inventory: (refresh: I) Loading…" -[node name="SkillProgressionLabel" type="Label" parent="UICanvas" unique_id=9000009] -offset_left = 8.0 -offset_top = 684.0 -offset_right = 520.0 -offset_bottom = 768.0 -grow_horizontal = 0 -grow_vertical = 0 +[node name="SkillProgressionLabel" type="Label" parent="UICanvas/EconomyHudSection/Body" unique_id=9000009] +custom_minimum_size = Vector2(512, 84) +layout_mode = 2 +size_flags_horizontal = 3 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_constants/outline_size = 6 @@ -1241,19 +1255,17 @@ autowrap_mode = 3 text = "Skills: Loading…" -[node name="CraftRecipePanel" type="Control" parent="UICanvas" unique_id=9000011] -anchors_preset = 0 -offset_left = 8.0 -offset_top = 776.0 -offset_right = 520.0 -offset_bottom = 1056.0 +[node name="CraftRecipePanel" type="Control" parent="UICanvas/EconomyHudSection/Body" unique_id=9000011] +custom_minimum_size = Vector2(512, 280) +layout_mode = 2 +size_flags_horizontal = 3 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 offset_right = 512.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 size_flags_horizontal = 3 diff --git a/client/scripts/main.gd b/client/scripts/main.gd index 28e04c2..5b593a0 100644 --- a/client/scripts/main.gd +++ b/client/scripts/main.gd @@ -102,11 +102,11 @@ var _recipe_defs_error: String = "" @onready var _target_lock_label: Label = $UICanvas/TargetLockLabel @onready var _cast_feedback_label: Label = $UICanvas/CastFeedbackLabel @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 _craft_feedback_label: Label = $UICanvas/CraftFeedbackLabel -@onready var _skill_progression_label: Label = $UICanvas/SkillProgressionLabel -@onready var _craft_recipe_panel: Node = $UICanvas/CraftRecipePanel +@onready var _skill_progression_label: Label = $UICanvas/EconomyHudSection/Body/SkillProgressionLabel +@onready var _craft_recipe_panel: Node = $UICanvas/EconomyHudSection/Body/CraftRecipePanel @onready var _inventory_client: Node = $InventoryClient @onready var _item_defs_client: Node = $ItemDefinitionsClient @onready var _skill_progression_client: Node = $SkillProgressionClient diff --git a/client/scripts/prototype_economy_hud_section.gd b/client/scripts/prototype_economy_hud_section.gd new file mode 100644 index 0000000..ec35e92 --- /dev/null +++ b/client/scripts/prototype_economy_hud_section.gd @@ -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 diff --git a/client/scripts/prototype_economy_hud_section.gd.uid b/client/scripts/prototype_economy_hud_section.gd.uid new file mode 100644 index 0000000..2f5c3ae --- /dev/null +++ b/client/scripts/prototype_economy_hud_section.gd.uid @@ -0,0 +1 @@ +uid://bneo75economyhud1 diff --git a/client/test/prototype_economy_hud_section_test.gd b/client/test/prototype_economy_hud_section_test.gd new file mode 100644 index 0000000..0e8a63b --- /dev/null +++ b/client/test/prototype_economy_hud_section_test.gd @@ -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() diff --git a/client/test/prototype_economy_hud_section_test.gd.uid b/client/test/prototype_economy_hud_section_test.gd.uid new file mode 100644 index 0000000..1fd0dd9 --- /dev/null +++ b/client/test/prototype_economy_hud_section_test.gd.uid @@ -0,0 +1 @@ +uid://bneo75economyhudtest1