Randoloot/tests/previews/freighter_windows_review.gd
2026-10-18 18:47:18 +02:00

73 lines
3.5 KiB
GDScript

extends Node
var screen: Control
var snapshots := 0
var gallery: Image
func settle() -> void:
for frame in 5: await get_tree().process_frame
await RenderingServer.frame_post_draw
func review(id: String, phase: String) -> void:
screen._select_section(id)
await settle()
var rect: Rect2 = screen._drawer.get_global_rect()
assert(rect.position.x >= 0 and rect.position.y >= 0)
assert(rect.end.x <= get_viewport().get_visible_rect().size.x and rect.end.y <= get_viewport().get_visible_rect().size.y)
var frame: StyleBoxFlat = screen._drawer.get_theme_stylebox("panel")
assert(frame.bg_color.a > 0.5 and frame.bg_color.a < 1)
for panel in screen._content.find_children("*","PanelContainer",true,false):
var style = panel.get_theme_stylebox("panel")
if style is StyleBoxFlat: assert(style.bg_color.a < 1)
if id == "hangar":
for name in ["RepairLander","UnlockCargo","UnlockWeapon","UnlockExtension","CollectRecovered"]:
var button: Button = screen._content.find_child(name,true,false)
assert(button != null and button.is_visible_in_tree())
assert(button.get_global_rect().end.y < rect.end.y)
assert(button.autowrap_mode == TextServer.AUTOWRAP_OFF)
assert(screen._content.find_child("RepairCost",true,false).text == str(GameState.captain.expedition.repair_cost()))
for button in screen._content.find_children("*","Button",true,false):
assert(button.text not in ["Serwis i odbiór","Rozbudowa statku"])
var shot := get_viewport().get_texture().get_image()
assert(shot.save_png("res://artifacts/frigate_review_%s_%s.png" % [id,phase]) == OK)
shot.convert(Image.FORMAT_RGBA8)
shot.resize(480,270,Image.INTERPOLATE_LANCZOS)
gallery.blit_rect(shot,Rect2i(0,0,480,270),Vector2i(snapshots%3*480,snapshots/3*270))
snapshots += 1
func _ready() -> void:
GameState.start_new_run()
var captain := GameState.captain
captain.parts = 100
for key in ["iron","titanium","aluminium","uranium","sulfur"]: captain.minerals[key] = 1000
captain.expedition.lander_hp = 62
var game := preload("res://scenes/game/game.tscn").instantiate()
add_child(game)
await settle()
game.get_node("PlanetExpeditions").open_freighter()
screen = game.get_node("PlanetExpeditions").screen
gallery = Image.create(1440,1890,false,Image.FORMAT_RGBA8)
for room in screen.deck.ROOMS: await review(str(room.id),"initial")
for id in ["expansion_1","expansion_2","expansion_3","cabin_1","cabin_2","cabin_3","cabin_4","cabin_5"]:
screen._select_section(id)
screen._construct_room(id)
await review(id,"built")
await review("storage","built")
await review("hangar","single")
var repair: Button = screen._content.find_child("RepairLander",true,false)
assert(not repair.disabled)
repair.pressed.emit()
assert(captain.expedition.lander_hp == 100 and captain.parts == 62)
var inventory: ShipInventory = game.player.get_node("ShipInventory")
for name in ["UnlockCargo","UnlockWeapon","UnlockExtension"]:
var button: Button = screen._content.find_child(name,true,false)
assert(not button.disabled)
button.pressed.emit()
assert(captain.minerals.iron == 970)
assert(inventory.unlocked_cargo_rows == 2 and inventory.unlocked_weapon_slots == 2 and inventory.unlocked_extension_slots == 2)
assert(gallery.save_png("res://artifacts/frigate_all_windows_review.png") == OK)
screen.closed.emit()
game.queue_free()
await get_tree().process_frame
print("FRIGATE WINDOWS PASS: 21 screenshots, all 11 sections plus built rooms, bounds, translucent windows/cards, hangar without tabs, visible controls, repair and three upgrades")
get_tree().quit()