#136, #137, #134: one build grid that cannot stack, one way to show a price

#136 - the gas burner drawn on top of the transport hub. The build menu's
rows were a written-down list of tops read with `tops[mini(row, size - 1)]`,
and with every structure researched the menu wanted a fourth row where the
list had three, so the last entry was placed on the third row's centre slot.
A list that silently stacks whatever will not fit in it is not a layout.
Rows are computed now, from a first top and a pitch that tightens to fit and
is floored at the row's own height - so two rows cannot occupy the same
space however far the catalog grows - and the column count widens rather
than adding a row the band cannot hold. Ten structures now sit in four
columns of three rows. The test unlocks the whole tree and checks every pair
of entries for overlap, which is the shape of the bug rather than a
coordinate that happens to be right today.

#137 - the game had three answers to "what does this cost". The build menu
drew a NeonNumber under each option, the craft menu drew glyph strips, and
the ship lab spelled prices out inside the caption. PriceTag is that answer
once: the resource's glyph, then what you HOLD over what it COSTS. It
replaces all three, plus the info popup and the skill panel, and
VesselPriceStrip - which was the same idea for one menu - goes with them.
The build menu also gains the resource bar the other two already had, in the
same place and at the same size, and the craft menu's - the only one not
running the full width of its panel - now matches. The bar drops its LOCAL
column where there is no building to report on, for the same reason #95
dropped it where it only repeated BANKED.

#134 - the skill panel's explanation and its price were both centred in the
same band, so a long description landed on the number. The text is the left
of the band now and the tag is the right. The shortfall it used to spell out
in a sentence - one per case, ore or research points - is the red on the tag
instead, and research points ride along as an entry of their own, so the tag
says WHICH thing is missing without a line of prose per possibility.

One trap worth recording: PriceTag and ResourceBar read the GameState
autoload, and an `extends SceneTree` test script that so much as names such
a class - or preloads the file - fails to compile, because GameState is not
an identifier in that context. GDScript then caches the failure, so the
scene the test instantiates gets a Control with no script where its resource
bar should be. The tests compare script PATHS, as strings.
This commit is contained in:
Loïc Wisniewski 2026-08-28 15:05:20 +02:00
commit ea25318201
12 changed files with 661 additions and 199 deletions

View file

@ -26,7 +26,7 @@ var _header_labels: Array[Label] = []
var _rows: Dictionary = {}
# The value columns, in the order they are drawn. LOCAL is dropped from this
# list at a building that IS the bank - see _local_is_banked().
# list where it would only repeat another column - see _local_is_redundant().
const VALUE_KEYS: Array = ["bank", "fleet", "local"]
var _local_shown: bool = true
@ -79,15 +79,22 @@ func _make_value_label(colour: Color) -> Label:
return label
# Whether a LOCAL column would say anything a reader could act on. Two ways
# it would not:
#
# #95: at a building that IS the bank - the mothership carries both the "bank"
# and the "research" capability, so the research menu is always opened from one
# - building_inventory() redirects to bank_inventory itself, and LOCAL is not
# merely equal to BANKED but the very same store read twice. Printing the
# number again teaches nothing and costs a third of the table, so the column
# goes away there and the remaining two share the width.
func _local_is_banked() -> bool:
# number again teaches nothing and costs a third of the table.
#
# #137: and at no building at all, which is how the build menu opens it - it
# is reached from the fleet's own button rather than from a structure. There
# is no "here" to report on, and a column of em-dashes is worth less than the
# width it takes from the two columns that do say something.
func _local_is_redundant() -> bool:
if building_id == 0:
return false
return true
return GameState.building_inventory(building_id) == GameState.bank_inventory
@ -142,7 +149,7 @@ func _layout() -> void:
func _process(_delta: float) -> void:
# building_id is assigned by whichever panel opens, so the column count can
# change between frames; re-lay out only when it actually flips.
var local_shown: bool = not _local_is_banked()
var local_shown: bool = not _local_is_redundant()
if local_shown != _local_shown:
_local_shown = local_shown
_layout()