#145, #144, #143: a quest that could not be finished, and two boxes that overhung

#145 - the extractor quest could never be completed. Extractors are placed
onto a planet from space and live in GameState.extractors, with their own
position, stock and id; they are not in `buildings`. So the goal asked
has_building_of_type("extractor"), which is false however many the player
builds. Not the death the reporter guessed at - the quest was simply asking
a question that had no yes.

structure_exists() is the question anything wanting "does the player have
one of these" should ask, and the quest model asks it now. The regression
test builds every structure quest's target THE WAY THE GAME BUILDS IT and
watches the goal flip, rather than knowing which array each one lands in -
the knowing is what got this wrong in the first place.

#144 - the build menu's status line is anchored to the top of the panel and
its grid to the panel's centre, so the gap between the two is half the panel
height. It was a written-down constant, correct only at 1280 tall; at 1080
the grid started four pixels ABOVE the status line and drew through it.

Nothing about that geometry is written against a screen size any more. The
band is measured from the header that is actually there, the pitch closes up
to fit it (never below a row's own height, which is what makes overlap
impossible rather than unlikely), and the column count rises until the rows
fit - so a short window gets a wide grid instead of one running off the
bottom. Ten structures now lay out as 5 columns at 900px tall, 4 at 1080, 3
at 1280 and 2 at 1600, clearing the header at every one, which is what the
test walks.

#143 - a hangar caption is "Gas Bomber\n2 available": two lines before
autowrap and three after it in a narrow column, at a size fixed in the
scene. Labels do not clip by default, so the third line was drawn over the
icon of the row below. The size is fitted to the box the layout works out,
and the box clips - the first keeps it legible, the second keeps it correct
however the vessel names grow.

Its box also overhung by exactly HANGAR_LABEL_GAP: the layout subtracted one
gap where it needed two, above the caption and below it. Two pixels, but two
pixels inside the next row's icon.
This commit is contained in:
Loïc Wisniewski 2026-08-29 12:51:09 +02:00
commit 2206b55873
5 changed files with 267 additions and 55 deletions

View file

@ -20,6 +20,10 @@ extends SceneTree
# 6. #136 - with every structure researched, no two entries overlap. The
# grid used to be a fixed list of row positions read with a clamp, so
# the first row that would not fit was drawn on top of another one
# 7. #144 - and that holds at any window shape. The header is anchored to
# the top of the panel and the grid to its centre, so the gap between
# them is half the panel height - it was a constant measured at 1280,
# and at 1080 the grid started above the status line and drew through it
var game_state: Node
var scene: Node
@ -122,8 +126,8 @@ func _process(delta: float) -> bool:
print("TEST_BUILD_MENU_HIDES_LOCKED: FAIL (a gap was left where a hidden entry used to be)")
quit(1)
return true
var col_x: float = float(controller.MENU_COL_X[columns])
var want_x: float = -col_x if i % 2 == 0 else col_x
var spacing: float = controller.menu_column_spacing(columns)
var want_x: float = -spacing * 0.5 if i % 2 == 0 else spacing * 0.5
if absf(slots[i][1] - want_x) > 0.01:
print("TEST_BUILD_MENU_HIDES_LOCKED: FAIL (entry %d at x=%.1f, expected %.1f)" % [i, slots[i][1], want_x])
quit(1)
@ -154,6 +158,49 @@ func _process(delta: float) -> bool:
print("%d structures on offer, in %d columns, nothing overlapping" \
% [all_shown.size(), controller.menu_columns(all_shown.size())])
# --- 7. #144: and at any window shape ------------------------
# The grid is anchored to the panel's CENTRE and the status line
# above it to the panel's TOP, so the gap between them is half
# the panel height. It used to be a written-down constant, right
# only at 1280 - at 1080 the grid started above the status line
# and drew through it, which is what the ticket reported.
var menu: Control = scene.get_node("UI/BuildMenu")
var status: Control = scene.get_node("UI/BuildMenu/StatusLabel")
var restore: float = menu.offset_bottom
for panel_height in [900.0, 1080.0, 1280.0, 1600.0]:
menu.anchor_bottom = 0.0
menu.offset_top = 0.0
menu.offset_bottom = panel_height
controller._refresh_build_status()
var half: float = menu.size.y * 0.5
# The status line's own bottom, in the grid's centre-anchored
# frame - which is the comparison that was never made.
var header_bottom: float = status.offset_bottom - half
var placed: Array = _shown()
for a in range(placed.size()):
for part in [1, 2, 3]:
var box: Rect2 = _rect(placed[a][part])
if box.position.y < header_bottom:
print("TEST_BUILD_MENU_HIDES_LOCKED: FAIL (at %.0fpx tall, %s is drawn at y=%.0f, above the status line at %.0f)" \
% [panel_height, placed[a][0], box.position.y, header_bottom])
quit(1)
return true
for b in range(a + 1, placed.size()):
for part2 in [1, 2, 3]:
if _rect(placed[a][part2]).intersects(_rect(placed[b][part2])):
print("TEST_BUILD_MENU_HIDES_LOCKED: FAIL (at %.0fpx tall, %s and %s overlap)" \
% [panel_height, placed[a][0], placed[b][0]])
quit(1)
return true
print(" %.0fpx tall: %d columns, top row at %.0f, clear of the status line at %.0f" \
% [panel_height, controller.menu_columns(placed.size()),
_rect(placed[0][1]).position.y, header_bottom])
menu.anchor_bottom = 1.0
menu.offset_top = 0.0
menu.offset_bottom = restore
controller._refresh_build_status()
print("the grid clears the header at every window shape")
# --- 5. researched but not usable is shown, greyed ----------
var extractor_shown: bool = false
for e in shown2:

View file

@ -10,6 +10,8 @@ extends SceneTree
# A. #111 - the craft menu names no resources: prices are glyphs, and
# every vessel gets a caption that does not overlap its neighbour
# B. #111 - and a price strip really carries the vessel's cost
# D. #143 - a hangar caption fits the box it was given and cannot draw
# outside it, so it never lands on the icon of the row below
# C. #120 - the hangar's captions have room for two lines, and there is a
# rule between what is parked and what is flying
# D. #112 - every skill node has a mark, and a node that unlocks a
@ -124,6 +126,38 @@ func _process(delta: float) -> bool:
print("hangar: %.0fpx captions, divider at %.0f between %.0f and %.0f" \
% [caption_height, controller.hangar_divider_y, available_bottom, fleet_top])
# --- D. #143 - and the caption stays in its box --------------
# The caption is two lines before autowrap and three after it in
# a narrow column, at a size fixed in the scene - so the third
# line was drawn over the icon of the row below. It is fitted to
# the box now, and the box clips, so nothing can reach the next
# row however the vessel names grow.
controller._refresh_hangar()
for pair in [[controller.hangar_available_labels, controller.hangar_available_slots],
[controller.hangar_fleet_labels, controller.hangar_fleet_slots]]:
for i in range(pair[0].size()):
var caption: Label = pair[0][i]
if not caption.clip_text:
return _fail("hangar caption %d can draw outside its box" % i)
var font: Font = caption.get_theme_font("font")
var size_px: int = caption.get_theme_font_size("font_size")
var needed: float = font.get_multiline_string_size(caption.text,
HORIZONTAL_ALIGNMENT_CENTER, caption.size.x, size_px).y
if needed > caption.size.y + 0.5:
return _fail("caption \"%s\" needs %.0fpx at size %d and has %.0f" \
% [caption.text.replace("\n", " / "), needed, size_px, caption.size.y])
# And the box itself must not reach the row below it.
for slot in pair[1]:
var below: Rect2 = Rect2(slot.position, slot.size)
if below.position.y > caption.position.y \
and Rect2(caption.position, caption.size).intersects(below):
return _fail("caption \"%s\" runs into the icon below it" \
% caption.text.replace("\n", " / "))
var probe: Label = controller.hangar_available_labels[0]
print("captions fitted to %dpx and clipped; \"%s\" fits its %.0fpx box" \
% [probe.get_theme_font_size("font_size"),
probe.text.replace("\n", " / "), probe.size.y])
# --- D. every skill node has a mark -----------------------
var tree_view: Control = scene.get_node("UI/SkillMenu/Tree")
var marked: int = 0

View file

@ -29,6 +29,8 @@ extends SceneTree
# P. #142 - enough rocks are asked for before the first structure is
# Q. #141 - the first structure that needs a doctrine has that doctrine as
# a quest of its own, so research is taught rather than assumed
# R. #145 - every structure quest is actually finishable: building the
# thing it asks for, the way the game builds it, completes it
# I. lines survive having nobody to say them: a quest finished with no
# banner alive is read out by the next one that is
# J. a planet surface carries the chain too - a quest finished down there
@ -126,6 +128,36 @@ func _catalogue_cases() -> bool:
return _fail("the quest after the mothership is %s, not exploration" % after.id)
print("the mothership answers with distance, and exploration follows it")
# --- R. #145: every structure quest can actually be finished ---------
# The extractor quest could not be. Extractors are placed onto a planet
# from space and live in their own array, not in `buildings`, so the
# question the goal asked ("is there a building of this type") was one
# that could never be answered yes however many were built.
#
# Checked by BUILDING each one the way the game builds it and watching
# the goal flip, rather than by knowing which array it lands in - the
# knowing is what got this wrong in the first place.
for i in range(QUESTS.count()):
var build_quest: Dictionary = QUESTS.at(i)
if String(build_quest.goal.kind) != QUESTS.GOAL_BUILDING:
continue
var type: String = String(build_quest.goal.building)
game_state.buildings.clear()
game_state.extractors.clear()
if game_state.quest_goal_met(build_quest):
return _fail("quest %s counts as done with nothing built at all" % build_quest.id)
if type == GameState.BUILDING_EXTRACTOR:
game_state.add_extractor("Quest Test", Vector2.ZERO, GameState.RESOURCE_ORE,
"quest:costs")
else:
game_state.add_building(type, Vector2.ZERO)
if not game_state.quest_goal_met(build_quest):
return _fail("building a %s does not finish quest %s - it cannot be completed at all" \
% [type, build_quest.id])
game_state.buildings.clear()
game_state.extractors.clear()
print("every structure quest is finished by building the thing it asks for")
# --- P. #142: enough rocks before anything is asked to be built ------
# The first structure the chain asks for used to arrive straight after a
# five-ore errand, costing four times that, with nothing in between