spaceship/tests/_icon_preview.gd

35 lines
1.2 KiB
GDScript3
Raw Permalink Normal View History

extends Control
# Preview scene - NOT run by run_tests.sh (underscore prefix). Draws every
# IconButton glyph at the size the build menu uses, so the art can be
# checked without rendering the whole game scene.
#
# bash tests/screenshot.sh res://tests/_icon_preview.tscn /tmp/out.png 20
const BUTTON_SIZE: float = 190.0
const COLUMNS: int = 3
const SWATCHES: Array = [
{"icon": 8, "color": Color(0.45, 0.9, 0.55)}, # mothership
{"icon": 9, "color": Color(1.0, 0.72, 0.25)}, # ship crafter
{"icon": 10, "color": Color(0.55, 0.6, 1.0)}, # command centre
{"icon": 11, "color": Color(0.35, 0.9, 0.75)}, # extractor
{"icon": 11, "color": Color(0.35, 0.9, 0.75), "enabled": false},
{"icon": 5, "color": Color(0.25, 0.85, 1.0)}, # generic build, for contrast
]
func _ready() -> void:
RenderingServer.set_default_clear_color(Color(0.02, 0.03, 0.06))
for i in range(SWATCHES.size()):
var swatch: Dictionary = SWATCHES[i]
var b: IconButton = IconButton.new()
b.icon = swatch.icon
b.glow_color = swatch.color
b.enabled = swatch.get("enabled", true)
b.size = Vector2(BUTTON_SIZE, BUTTON_SIZE)
b.position = Vector2(
120.0 + float(i % COLUMNS) * (BUTTON_SIZE + 60.0),
100.0 + float(i / COLUMNS) * (BUTTON_SIZE + 60.0)
)
add_child(b)