spaceship/ui/PaletteEntryButton.gd
Loïc Wisniewski 6e13b6397c Take planets by killing what defends them
#211 conquest is the fight now: a planet registers the garrison its setup
authors, each defender's own death counts against it, and the last one takes
the world. The capture points - stand in a ring, wait out a timer, once per
ring - are gone, along with the editor palette that placed them.
#212 conquest opens a dialog on the surface naming the research points
recovered; the award travels with the signal, after it is banked.
#209 the prologue's charted sectors go with the breach, so the map the
survivors keep is of where they now are - and "chart 30 sectors" is no
longer complete before they have flown anywhere.
#218 enemy variety is gated on the FLEET, not on wave strength: a starting
fleet meets chasers only at any wave number, and each vessel past three
opens one more kind.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019AJMdB7iuHuLFZM1aBu3GD
2026-09-05 13:31:25 +02:00

49 lines
1.7 KiB
GDScript

class_name PaletteEntryButton
extends Control
# One selectable tile in the setup editor's palette: one enemy definition's
# own hull and colour. Drawn directly from the definition rather than a fixed
# icon set, so a new EnemyDefinitions entry shows up automatically with no
# editor code change. #211 removed the capture-point tile that used to sit
# alongside them.
signal pressed
const ENEMY_DEFINITIONS = preload("res://enemies/EnemyDefinitions.gd")
@export var enemy_definition: Resource
@export var selected: bool = false: set = set_selected
func set_selected(value: bool) -> void:
selected = value
queue_redraw()
func _ready() -> void:
queue_redraw()
func _gui_input(event: InputEvent) -> void:
if event is InputEventScreenTouch and not event.pressed \
and Rect2(Vector2.ZERO, size).has_point(event.position):
pressed.emit()
elif event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and not event.pressed:
pressed.emit()
func _draw() -> void:
var center: Vector2 = size / 2.0
var margin: float = 4.0
var frame: PackedVector2Array = PackedVector2Array([
Vector2(margin, margin), Vector2(size.x - margin, margin),
Vector2(size.x - margin, size.y - margin), Vector2(margin, size.y - margin),
])
var frame_color: Color = Color(1.0, 0.95, 0.9) if selected else Color(0.4, 0.45, 0.5)
NeonDraw.draw_glowing_polygon(self, frame, frame_color, 0.85 if selected else 0.5)
if enemy_definition != null:
# Same routine as the marker and the enemy, so the button previews
# what will actually be placed.
var scale_factor: float = (size.x * 0.5) / 28.0 * 0.6
ENEMY_DEFINITIONS.draw_definition(self, enemy_definition,
enemy_definition.glow_color, scale_factor, center)