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 <noreply@anthropic.com>
This commit is contained in:
Loïc Wisniewski 2026-08-17 23:20:51 +02:00
commit 75b7603f04
5 changed files with 72 additions and 0 deletions

View file

@ -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()

View file

@ -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()

View file

@ -0,0 +1 @@
uid://ckltesr471lqy

View file

@ -0,0 +1 @@
uid://dekjmrvv0baqy

View file

@ -0,0 +1 @@
uid://1ynm1v0c1qfk