TableTower/ui/die_icon.gd
RobinFiredrake ebe81d9f1e Theme system: runtime colour tokens, theme sets and a Theme dialog
Style's colours become static vars named by role (BG, PANEL, CARD, THREAD,
ACCENT, TRIM, GLOW…) instead of materials (felt, copper, brass), so a theme
can replace them. Stray hard-coded colours moved into tokens.

ThemeStore applies built-in sets (Tarot, the new default: jewel-purple
cloth with a shine; Felt, the old look) and the user's own sets from
user://themes/. Fills for the background and panels can be gradients; the
background pattern (dots, stars, none) and logo are per set. View ▾ →
Theme… edits a set; changes to a built-in save as a new set. Using a theme
reloads the UI and keeps the open spread.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 18:10:16 -06:00

46 lines
1.1 KiB
GDScript

class_name DieIcon
extends Control
## A three-pip die face. Tumbles while `spinning` is on.
var color: Color = Style.ACCENT
var spinning: bool = false:
set(value):
spinning = value
if not value:
_angle = 0.0
set_process(value)
queue_redraw()
var _angle: float = 0.0
var _frame: StyleBoxFlat
func _init() -> void:
custom_minimum_size = Vector2(20, 20)
size = custom_minimum_size
mouse_filter = MOUSE_FILTER_IGNORE
_frame = StyleBoxFlat.new()
_frame.draw_center = false
_frame.set_border_width_all(2)
_frame.set_corner_radius_all(3)
_frame.anti_aliasing = true
set_process(false)
func _ready() -> void:
# Godot turns processing on for nodes with _process when they become ready.
set_process(spinning)
func _process(delta: float) -> void:
_angle = fmod(_angle + delta * TAU * 2.0, TAU)
queue_redraw()
func _draw() -> void:
draw_set_transform(size / 2.0, _angle)
_frame.border_color = color
draw_style_box(_frame, Rect2(-7.5, -7.5, 15, 15))
for p in [Vector2(-3, -3), Vector2(0, 0), Vector2(3, 3)]:
draw_circle(p, 1.45, color)
draw_set_transform(Vector2.ZERO)