TableTower/ui/group_mark.gd
RobinFiredrake 61a548902f Theme tiers 1-2: theme folders, mascot recolour, background scene and tile, frame sets, picture threads, sounds; nine new built-in themes
- ThemeAssets loads a theme's files; FrameSet + GradientMap (3-stop) generalise the card frame;
  ThreadStrip draws threads from a picture; BoardBackdrop draws scene and tile; MascotArt
  recolours Morgan by role (logo SVG now uses the Keep File importer); SoundBoard plays
  roll / card turn / thread / click / ambient with View > Sound levels.
- Vaporwave, Synthwave, Cozy Autumn, Rustic, Woodsy, Sky Blue, Frutiger Aero, Gothic, Terminal:
  generated art (tools/theme_art), sounds (tools/theme_sounds), settings (tools/theme_defs).
- Ten OFL fonts; --theme=<id> flag; docs/THEMES.md format spec; test_theme_assets.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 15:05:40 -06:00

58 lines
2 KiB
GDScript

class_name GroupMark
extends Control
## The top-right corner of a card in a group, in the group's colour (its own,
## else Style.GROUP), so members are easy to tell from cards that only lie
## inside the group's frame. On a framed card it recolours that corner
## piece; on a plain card it draws a bracket over the corner.
##
## Like CardFrame it draws around the host card's whole rectangle, whatever box
## the container gives it.
## Plain cards: how far the bracket runs along each edge, and its width.
const ARM := 26.0
const WIDTH := 4.0
const RADIUS := 10.0
var _color := Color(0, 0, 0, 0)
func _init() -> void:
mouse_filter = MOUSE_FILTER_IGNORE
texture_filter = TEXTURE_FILTER_LINEAR_WITH_MIPMAPS
visible = false
## The colour of a group's mark and border.
static func color_of(g: TableGroup) -> Color:
return Color.from_string(g.color, Style.GROUP) if g.color != "" else Style.GROUP
## Shows the mark for the card's group, or hides it (null).
func show_for(g: TableGroup) -> void:
var c := color_of(g) if g else Color(0, 0, 0, 0)
if c == _color and visible == (g != null):
return
_color = c
visible = g != null
material = FrameSet.active.material_for(c) if g and FrameSet.active else null
queue_redraw()
func _draw() -> void:
var host := get_parent() as Control
if host == null:
return
var fs := FrameSet.active
if fs:
var r := Rect2(-position, host.size).grow(fs.outset)
draw_set_transform(Vector2(r.end.x, r.position.y), 0.0, Vector2(-1, 1))
draw_texture_rect(fs.corner, Rect2(Vector2.ZERO, fs.corner_drawn()), false)
draw_set_transform(Vector2.ZERO)
return
# Plain: an L along the top and right edges, round where the card is.
var r := Rect2(-position, host.size)
var c := Vector2(r.end.x - RADIUS, r.position.y + RADIUS)
var inset := WIDTH / 2.0
draw_arc(c, RADIUS - inset, -PI / 2.0, 0.0, 12, _color, WIDTH, true)
draw_line(Vector2(r.end.x - ARM, r.position.y + inset), Vector2(c.x, r.position.y + inset), _color, WIDTH, true)
draw_line(Vector2(r.end.x - inset, c.y), Vector2(r.end.x - inset, r.position.y + ARM), _color, WIDTH, true)