spaceship/tests/_craft_menu_preview.gd
2026-08-15 04:45:15 +02:00

40 lines
1.7 KiB
GDScript

extends Node2D
# Preview, not a test. Opens the CraftMenu so its layout can be checked on a
# real viewport - label collisions and things falling off the bottom of
# shorter screens are what no headless test can see.
#
# bash tests/screenshot.sh res://tests/_craft_menu_preview.tscn /tmp/m.png 20 720x1280
# ... and again at 720x960 to check a shorter screen format.
func _ready() -> void:
GameState.buildings.clear()
GameState.extractors.clear()
GameState.transporters.clear()
GameState.rocks = 180
GameState.gas = 36
GameState.fleet_cargo = 24
GameState.fleet_gas_cargo = 12
GameState.unlocked = ["shipyards", "logistics", "freight"]
GameState.vessel_levels["unlock_gas_bomber"] = 1
var main: Node = load("res://Main.tscn").instantiate()
add_child(main)
main.get_node("BackgroundLayer").visible = false
main.get_node("Fleet").visible = false
main.get_node("AsteroidField").visible = false
main.get_node("PlanetField").visible = false
main.get_node("BuildingField").visible = false
main.get_node("EnemySpawner").set_process(false)
main.get_node("BuildingField").place(GameState.BUILDING_SHIP_CRAFTER, Vector2(400.0, 0.0))
var crafter_id: int = int(GameState.buildings[-1].id)
GameState.deposit_to_building(crafter_id, 42)
GameState.deposit_resource_to_building(crafter_id, GameState.RESOURCE_GAS, 18)
var bc: Node = main.get_node("BuildController")
bc.craft_building_id = crafter_id
# The shared header (#24) is the thing worth eyeballing here, so give it
# a building to report on - otherwise its HERE column hides itself.
for bar in bc.resource_bars:
bar.building_id = crafter_id
main.get_node("UI/CraftMenu").visible = true
bc._refresh_craft_status()