From 75b7603f04835a089a6fb0a754b008cc9fa4e0e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Wisniewski?= Date: Mon, 17 Aug 2026 23:20:51 +0200 Subject: [PATCH] Seat the HUD button columns below the resource readout, and move the planet name The build button overlapped the resource list. ResourceReadout builds one row per resource type AT RUNTIME (58px each), so how far down it reaches is not knowable when the scene is authored: PlanetSurface/Main declared offset_bottom 154, four resources actually reach 270, and BuildButton sat at a hardcoded 160. A 110px collision that grew with every resource type added. Because the readout spans the full width - the fleet hold column is at x 356 - it hit both button columns, TransferButton and EnterAtmosphereButton as well as the left one. Rather than nudge the offsets, the layout now derives from the readout: ResourceReadout.rows_height()/content_bottom() report the real extent and _ready() stops the node understating its own size, and BuildController._seat_hud_columns() seats both columns below that at load. Adding a fifth resource type pushes the buttons down on its own, so the overlap cannot come back. Two details worth keeping: the height is derived from the live resource list rather than cached in _ready(), because BuildController readies before UI's children in scene-tree order and a cached value would answer zero. And it translates the block rather than re-flowing it, since BuildingActionButton and HangarButton deliberately share a row as mutually exclusive options. The planet name moved from the centre - where it sat across resource rows 3 and 4 - to the top-right corner, right-aligned. Right alignment is what keeps it clear: short names sit against the right edge, well clear of the fleet hold column, and long ones wrap downward into empty space rather than growing left into it. That scene edit rode along in the #68 commit, both being changes to PlanetSurface.tscn. Also adds three .uid files orphaned by earlier commits this session; the repo tracks them for every other script. Co-Authored-By: Claude Opus 5 --- BuildController.gd | 49 +++++++++++++++++++ ResourceReadout.gd | 20 ++++++++ tests/_setup_editor_load_panel_preview.gd.uid | 1 + tests/test_enemy_detection_range.gd.uid | 1 + tests/test_research_lab_extractor_gate.gd.uid | 1 + 5 files changed, 72 insertions(+) create mode 100644 tests/_setup_editor_load_panel_preview.gd.uid create mode 100644 tests/test_enemy_detection_range.gd.uid create mode 100644 tests/test_research_lab_extractor_gate.gd.uid diff --git a/BuildController.gd b/BuildController.gd index 6a45e1e..c9bc7d0 100644 --- a/BuildController.gd +++ b/BuildController.gd @@ -195,7 +195,56 @@ var pending_time: float = 0.0 var context_actions_expanded: bool = false +# Gap between the last resource row and the first row of HUD buttons. +const HUD_COLUMN_MARGIN: float = 18.0 + + +# Seats the top-anchored HUD button columns below the resource readout instead +# of at the fixed y the scene authored. +# +# ResourceReadout builds one row per resource type AT RUNTIME, so how far down +# it reaches is not knowable when the scene is laid out - the scene's guess +# was 154, and four resources actually reach 270, straight over the build +# button sitting at a hardcoded 160. Every resource type added since made it +# worse. Deriving the column top from the readout's real bottom makes the +# overlap impossible rather than merely fixed for today's resource count. +# +# This TRANSLATES the block rather than re-flowing it, so the rows keep their +# spacing relative to one another - BuildingActionButton and HangarButton +# deliberately share a row, being mutually exclusive, and a flow layout would +# pull them apart. +func _seat_hud_columns() -> void: + var readout: ResourceReadout = get_node_or_null("../UI/ResourceReadout") + if readout == null: + return + # Both columns, not just the left one: the readout spans the full width + # (the fleet hold column sits at x 356), so the second column of buttons + # collides with it exactly as the first does. + var buttons: Array = [ + build_button, transfer_button, + action_button, landing_button, + building_action_button, hangar_button, + ] + var highest: float = INF + for button in buttons: + if button != null: + highest = minf(highest, button.position.y) + if is_inf(highest): + return + + var shift: float = readout.content_bottom() + HUD_COLUMN_MARGIN - highest + # Only ever pushed down, never pulled up: with few enough resources the + # authored layout already clears the readout, and there is no reason to + # drag the HUD away from where the scene deliberately put it. + if shift <= 0.0: + return + for button in buttons: + if button != null: + button.position.y += shift + + func _ready() -> void: + _seat_hud_columns() build_button.pressed.connect(_on_build_pressed) build_close_button.pressed.connect(_close_build_menu) _configure_build_menu_entries() diff --git a/ResourceReadout.gd b/ResourceReadout.gd index c88433f..a2f6d97 100644 --- a/ResourceReadout.gd +++ b/ResourceReadout.gd @@ -61,6 +61,26 @@ func _ready() -> void: y += ROW_HEIGHT + # Stop understating our own extent. The rows are drawn by child nodes, + # which happily paint outside this Control's rect, so the scene-authored + # height stayed at its original guess no matter how many rows appeared. + size.y = rows_height() + + +# How tall the rows are, derived from the live resource list rather than from +# whatever _ready() happened to have built. That matters: _ready() runs in +# scene-tree order, so a sibling laying itself out relative to this readout +# (BuildController._seat_hud_columns) can legitimately ask BEFORE this node +# has built anything, and a cached height would answer zero. +func rows_height() -> float: + return float(GameState.resource_types().size()) * ROW_HEIGHT + + +# Bottom edge of the rows in this Control's parent space - the line anything +# stacked below the readout has to clear. +func content_bottom() -> float: + return position.y + rows_height() + func _add_glyph(resource_type: String, at: Vector2) -> void: var glyph: ResourceGlyph = ResourceGlyph.new() diff --git a/tests/_setup_editor_load_panel_preview.gd.uid b/tests/_setup_editor_load_panel_preview.gd.uid new file mode 100644 index 0000000..f81e4d7 --- /dev/null +++ b/tests/_setup_editor_load_panel_preview.gd.uid @@ -0,0 +1 @@ +uid://ckltesr471lqy diff --git a/tests/test_enemy_detection_range.gd.uid b/tests/test_enemy_detection_range.gd.uid new file mode 100644 index 0000000..2500c16 --- /dev/null +++ b/tests/test_enemy_detection_range.gd.uid @@ -0,0 +1 @@ +uid://dekjmrvv0baqy diff --git a/tests/test_research_lab_extractor_gate.gd.uid b/tests/test_research_lab_extractor_gate.gd.uid new file mode 100644 index 0000000..6b5f117 --- /dev/null +++ b/tests/test_research_lab_extractor_gate.gd.uid @@ -0,0 +1 @@ +uid://1ynm1v0c1qfk