spaceship/tests/test_build_menu_hides_locked.gd

222 lines
8.9 KiB
GDScript3
Raw Normal View History

extends SceneTree
# Headless gameplay test: run with
# godot --headless -s res://tests/test_build_menu_hides_locked.gd
# Forgejo #21: a structure the player has not researched should not be in the
# build menu at all, rather than sitting there greyed out.
#
# The menu is a fixed grid in Main.tscn, so simply hiding entries would leave
# holes where they used to be - it is repacked from whatever is researched.
#
# Verifies:
# 1. with nothing researched only the mothership is offered (it is
# deliberately never gated - it is where research happens)
# 2. researching a structure adds it, and it is placed, not left at
# whatever offsets it happened to have in the scene file
# 3. no gaps: what is shown occupies consecutive grid slots
# 4. an entry alone on its row is centred, not hanging in the left column
# 5. researched-but-not-usable is still shown greyed (an extractor with no
# planet under the fleet is "not now", not "not yet")
#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.
2026-08-28 15:05:20 +02:00
# 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
#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.
2026-08-29 12:51:09 +02:00
# 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
var controller: Node
var stage: int = 0
var elapsed: float = 0.0
func _initialize() -> void:
game_state = root.get_node("GameState")
game_state.buildings.clear()
game_state.extractors.clear()
game_state.transporters.clear()
game_state.reset_progression()
game_state.rocks = 500
#84: move 215 root files into a folder hierarchy Everything lived in one flat directory, so a diff gave no clue what area it touched and finding the file you wanted meant knowing its exact name. Twelve folders now, grouped by what a thing IS rather than what type it is - a vessel's definition, its component scenes and its upgrade resources sit together, because that is the set you read when you change one of them. buildings core controllers enemies logistics planets resources shaders surface ui vessels vfx world 332 files moved and every res:// reference rewritten - 306 files touched, including the autoload and main-scene paths in project.godot. Nothing renamed: this is purely where files sit, so the diff is a pile of pure moves and no behaviour is buried in it. ui_theme.tres, icon.svg and web_shell.html stay at the root, where Godot and the export preset expect them. Verified three ways, because a suite alone would not have caught all of it: the full 117 pass, the web export builds clean, and the game renders. The export is why that matters. The FIRST export after the move failed with "Attempt to open script 'res://GameState.gd'" - the old path - while project.godot on disk plainly said res://core/GameState.gd. That is this project's documented Android FUSE mtime trap: Godot served a cached copy of a file whose content had changed. A `touch` fixed it. Nothing in the test suite would have found that, because the suite runs from a copy on a native filesystem - the one place the bug cannot happen. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-21 19:44:14 +02:00
scene = load("res://world/Main.tscn").instantiate()
root.add_child(scene)
controller = scene.get_node("BuildController")
func _shown() -> Array:
var out: Array = []
for entry in controller.build_menu.entries:
if entry.button.visible:
out.append([entry.definition.definition_id, entry.button,
entry.label, entry.cost, entry.definition])
return out
#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.
2026-08-28 15:05:20 +02:00
func _rect(node: Control) -> Rect2:
return Rect2(Vector2(node.offset_left, node.offset_top),
Vector2(node.offset_right - node.offset_left,
node.offset_bottom - node.offset_top))
func _slots() -> Array:
# (row, x) of every visible button, in menu order.
var out: Array = []
for entry in _shown():
var b: Control = entry[1]
out.append([b.offset_top, b.offset_left + (b.offset_right - b.offset_left) / 2.0])
return out
func _process(delta: float) -> bool:
elapsed += delta
match stage:
0:
if elapsed < 0.2:
return false
scene.get_node("AsteroidField").set_process(false)
scene.get_node("EnemySpawner").set_process(false)
# --- 1. nothing researched ----------------------------------
controller._refresh_build_status()
var shown: Array = _shown()
if shown.size() != 1 or shown[0][0] != GameState.BUILDING_MOTHERSHIP:
var names: Array = []
for e in shown:
names.append(e[0])
print("TEST_BUILD_MENU_HIDES_LOCKED: FAIL (unresearched structures on offer: %s)" % [names])
quit(1)
return true
# --- 4. and it is centred, being alone on its row -----------
var only: Array = _slots()[0]
if absf(only[1]) > 0.01:
print("TEST_BUILD_MENU_HIDES_LOCKED: FAIL (the only entry sits at x=%.1f instead of centred)" % only[1])
quit(1)
return true
print("nothing researched -> only the mothership, centred")
# --- 2. research three more ---------------------------------
game_state.unlocked = ["shipyards", "logistics", "coordination"]
controller._refresh_build_status()
stage = 1
return false
1:
var shown2: Array = _shown()
if shown2.size() != 4:
print("TEST_BUILD_MENU_HIDES_LOCKED: FAIL (researched 3, expected 4 entries, got %d)" % shown2.size())
quit(1)
return true
for e in shown2:
if e[0] == GameState.BUILDING_TRANSPORT_HUB:
print("TEST_BUILD_MENU_HIDES_LOCKED: FAIL (the unresearched transport hub is still listed)")
quit(1)
return true
# --- 3. consecutive slots, no holes -------------------------
var slots: Array = _slots()
#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.
2026-08-28 15:05:20 +02:00
var columns: int = controller.menu_columns(slots.size())
var rows: int = controller.menu_rows(slots.size())
if columns != 2:
print("TEST_BUILD_MENU_HIDES_LOCKED: FAIL (4 entries laid out in %d columns)" % columns)
quit(1)
return true
for i in range(slots.size()):
#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.
2026-08-28 15:05:20 +02:00
var want_row: float = controller.menu_row_top(i / columns, rows, columns)
if absf(slots[i][0] - want_row) > 0.01:
#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.
2026-08-28 15:05:20 +02:00
print("slot %d at y=%.1f, expected row %d at y=%.1f" % [i, slots[i][0], i / columns, want_row])
print("TEST_BUILD_MENU_HIDES_LOCKED: FAIL (a gap was left where a hidden entry used to be)")
quit(1)
return true
#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.
2026-08-29 12:51:09 +02:00
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)
return true
print("4 entries packed into consecutive slots, no gaps")
#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.
2026-08-28 15:05:20 +02:00
# --- 6. #136: nothing overlaps, with EVERY structure on offer -
# The bug the ticket reported: the row list ran out and the last
# entry was placed on top of one already there.
for node in GameState.SKILL_TREE:
game_state.unlocked.append(String(node.id))
controller._refresh_build_status()
var all_shown: Array = _shown()
if all_shown.size() < 9:
print("TEST_BUILD_MENU_HIDES_LOCKED: FAIL (only %d structures unlocked - not the crowded case)" % all_shown.size())
quit(1)
return true
for i in range(all_shown.size()):
for j in range(i + 1, all_shown.size()):
for part in [1, 2, 3]:
var a: Control = all_shown[i][part]
var b: Control = all_shown[j][part]
if _rect(a).intersects(_rect(b)):
print("TEST_BUILD_MENU_HIDES_LOCKED: FAIL (%s and %s overlap at %s / %s)" \
% [all_shown[i][0], all_shown[j][0], _rect(a), _rect(b)])
quit(1)
return true
print("%d structures on offer, in %d columns, nothing overlapping" \
% [all_shown.size(), controller.menu_columns(all_shown.size())])
#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.
2026-08-29 12:51:09 +02:00
# --- 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:
if e[0] == GameState.BUILDING_EXTRACTOR:
extractor_shown = true
if e[1].enabled:
print("TEST_BUILD_MENU_HIDES_LOCKED: FAIL (extractor offered as usable with no planet under the fleet)")
quit(1)
return true
if not extractor_shown:
print("TEST_BUILD_MENU_HIDES_LOCKED: FAIL (researched extractor hidden - 'not now' is not 'not yet')")
quit(1)
return true
print("researched extractor shown but greyed, with no planet in reach")
print("TEST_BUILD_MENU_HIDES_LOCKED: PASS")
quit(0)
return true
return false