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