TableTower/ui/card_frame.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

60 lines
1.9 KiB
GDScript

class_name CardFrame
extends Control
## The ornamental border around a card, drawn from the active FrameSet: four
## corners (one picture, mirrored) joined by a repeated edge tile. GradientMap
## recolours the art: its middle greys become the trim colour (the card's own
## colour, else the theme's TRIM) and its black becomes BG_DEEP. A frame set's
## fixed-colour corner pieces are drawn on top by a child, uncoloured.
##
## It's the card's first child and draws around the card's whole rectangle,
## a little outside it (the set's outset), whatever box the container gives it.
var _fixed: Control
func _init() -> void:
mouse_filter = MOUSE_FILTER_IGNORE
texture_filter = TEXTURE_FILTER_LINEAR_WITH_MIPMAPS
var fs := FrameSet.active
if fs and fs.corner_fixed:
_fixed = Control.new()
_fixed.mouse_filter = MOUSE_FILTER_IGNORE
_fixed.use_parent_material = false
_fixed.texture_filter = TEXTURE_FILTER_LINEAR_WITH_MIPMAPS
_fixed.draw.connect(_draw_fixed)
add_child(_fixed)
set_trim(Color(0, 0, 0, 0))
## Recolours the frame; a transparent colour means the theme's TRIM.
func set_trim(c: Color) -> void:
material = material_for(Style.TRIM if c.a == 0.0 else c)
queue_redraw()
if _fixed:
_fixed.queue_redraw()
## The active frame's material for a trim colour (beaded when none is active).
static func material_for(trim: Color) -> ShaderMaterial:
return (FrameSet.active if FrameSet.active else FrameSet.beaded()).material_for(trim)
func _frame_rect() -> Rect2:
var host := get_parent() as Control
return Rect2(-position, host.size).grow(FrameSet.active.outset)
func _draw() -> void:
var fs := FrameSet.active
if fs == null or get_parent() == null:
return
var r := _frame_rect()
fs.draw_corners(self, r, fs.corner)
fs.draw_edges(self, r)
func _draw_fixed() -> void:
var fs := FrameSet.active
if fs == null or fs.corner_fixed == null or get_parent() == null:
return
fs.draw_corners(_fixed, _frame_rect(), fs.corner_fixed)