Randoloot/tests/previews/construction_layout_test.gd
2026-10-19 22:58:37 +02:00

32 lines
1.6 KiB
GDScript

extends Node
func _ready() -> void:
GameState.start_new_run()
var game := preload("res://scenes/game/game.tscn").instantiate()
add_child(game)
game.set_physics_process(false)
game.player.set_physics_process(false)
for enemy in get_tree().get_nodes_in_group("enemies"): enemy.set_physics_process(false)
var manager := game.get_node("PlanetExpeditions")
assert(manager.freighter.find_children("*","Label",true,false).is_empty())
manager.open_freighter()
var screen: Control = manager.screen
assert(screen.deck.is_built("expansion_3"))
for section in ["expansion_1","expansion_2","cabin_1","cabin_2","cabin_3","cabin_4","cabin_5"]:
screen._select_section(section)
for frame in 8: await get_tree().process_frame
for mineral in preload("res://scripts/items/crafting_recipes.gd").MINERALS:
var row: HBoxContainer = screen._content.find_child("Cost" + str(mineral).capitalize(), true, false)
assert(row != null and row.size.y <= 24)
var value: Label = row.get_node("Amount")
assert(value.text == "0 / 100" and value.autowrap_mode == TextServer.AUTOWRAP_OFF)
assert(row.get_global_rect().end.y < screen._drawer.get_global_rect().end.y - 50)
screen._select_section("expansion_1")
for frame in 8: await get_tree().process_frame
await RenderingServer.frame_post_draw
get_viewport().get_texture().get_image().save_png("res://artifacts/construction_layout_fixed.png")
manager.screen.closed.emit()
game.free()
await get_tree().process_frame
print("CONSTRUCTION_LAYOUT_OK: no freighter label, seven unbuilt rooms and default storage, five single-line costs, full cost table visible")
get_tree().quit()