class_name Style ## The design system (ui-plan.md §2–3): the print templates' tokens, the two fonts, the chamfered ## boxes and the one Theme, plus the screen space the 2D panels take. The HUD, the table's own 2D ## readouts and the menu all read their colors and fonts from here, so nothing restyles by eye. # --------------------------------------------------------------------------------------------- # Tokens, from decks/files-deck-1/*.css const BG := Color("#05080a") ## Primary, secondary and label text. const SCREEN := Color("#e6fbff") const SECONDARY := Color("#a9d9e0") const MUTED := Color("#6f8a90") ## System chrome: frames, buttons, the grid, the terminal. const ACCENT := Color("#22d3ee") const ACCENT_DK := Color("#0e6b78") ## Panel fills: translucent black over the table, and a lifted shade for buttons. const PANEL := Color("#05080ae6") const PANEL_HI := Color("#0a1a20f0") const DISABLED := Color("#33464b") ## Warnings, damage and attacks. const WARN := Color("#ffb02e") const BAD := Color("#ff5c5c") const ATTACK := Color("#ff4f6d") ## Okabe–Ito sky blue (South) and orange (North): they stay apart for color-blind players. A stripe ## (South) or dot (North) fill is the second cue, since chrome cyan sits beside South's blue. const OWNER: Array[Color] = [Color("#56b4e9"), Color("#e69f00")] const TYPE_ACCENT := { "server": Color("#39d353"), "hardware": Color("#ffd24a"), "execution": Color("#ffb02e"), "program": Color("#8b949e"), "system": Color("#22d3ee"), } ## Anomaly classes: Virus, Bug, Glitch, Patch. const CLASS_ACCENT := {"V": Color("#3fb950"), "B": Color("#ff5c5c"), "G": Color("#d264ff"), "P": Color("#4aa3ff")} const CLASS_NAMES := {"V": "Virus", "B": "Bug", "G": "Glitch", "P": "Patch"} ## How table objects glow: legal sources, responses, the selection, targets, attacks, the combat. const MARK := { "source": ACCENT, "respond": WARN, "selected": Color.WHITE, "target": ACCENT, "attack": ATTACK, "fight": ATTACK, } const MARK_STRENGTH := {"source": 1.0, "respond": 1.2, "selected": 2.0, "target": 1.5, "attack": 1.8, "fight": 1.2} # --------------------------------------------------------------------------------------------- # Panel geometry (§0.4): the one source for what the HUD draws, where the camera fits the mat, # where the hand lays out and which screen points the click test may use. Pixels at the # 1600 × 900 base size; scale by the viewport. const BASE := Vector2(1600, 900) const PANEL_RIGHT := 360.0 ## The status bar, and under it the row of player strips over the table. const BAR_H := 44.0 const STRIPS_H := 40.0 const PANEL_TOP := BAR_H + STRIPS_H const PANEL_BOTTOM := 176.0 ## Gap between a panel and the screen edge. const MARGIN := 8.0 ## The chamfer, ~3 % of a card's shorter edge (22 px at 750 px). const CHAMFER_RATIO := 22.0 / 750.0 # --------------------------------------------------------------------------------------------- # Fonts const DISPLAY_PATH := "res://assets/fonts/Orbitron.ttf" const BODY_PATH := "res://assets/fonts/JetBrainsMono.ttf" static var _fonts := {} static var _theme: Theme ## Orbitron, for the logo, the menu and headings only: it is too wide for dense readouts. static func display_font(weight := 700) -> Font: return _font(DISPLAY_PATH, weight) ## JetBrains Mono, for every HUD string: the nearest shippable match to the cards' Consolas. static func body_font(weight := 400) -> Font: return _font(BODY_PATH, weight) static func _font(path: String, weight: int) -> Font: var key := "%s@%d" % [path, weight] if not _fonts.has(key): var base: FontFile = load(path) var f := FontVariation.new() f.base_font = base f.variation_opentype = {"wght": weight} _fonts[key] = f return _fonts[key] # --------------------------------------------------------------------------------------------- # Boxes and the theme ## A chamfered box: `accent` border, `fill` inside, `width` px border, `glow` px of outer glow. static func chamfer_box(accent: Color, fill := PANEL, width := 1.5, glow := 0.0, cut := 8.0) -> ChamferBox: var b := ChamferBox.new(fill, accent, width, cut) b.glow = glow return b ## An emphasis chip: filled accent, dark text (set the label's color to BG), a glow. static func chip_box(accent: Color, cut := 5.0) -> ChamferBox: var b := ChamferBox.new(accent, accent.lightened(0.25), 1.0, cut) b.glow = 6.0 b.glow_alpha = 0.3 b.content_margin_left = 7 b.content_margin_right = 7 b.content_margin_top = 2 b.content_margin_bottom = 2 return b static func type_accent(kind: String) -> Color: return TYPE_ACCENT.get(kind, ACCENT) ## The V/B/G/P class color of an Anomaly type, or the accent. static func class_accent(type: String) -> Color: return CLASS_ACCENT.get(type, ACCENT) ## The accent for a card def: its class for Anomalies, its kind otherwise. static func card_accent(d: Dictionary) -> Color: if d.get("kind", "") == "anomaly": return class_accent(d.get("type", "")) return type_accent(d.get("kind", "")) ## A Firewall's color at `level` out of `levels` (the rules' firewallCost size): amber to red. static func firewall_color(level: int, levels: int) -> Color: var k := 0.0 if levels <= 1 else clampf(float(level - 1) / (levels - 1), 0.0, 1.0) return WARN.lerp(BAD, k) ## "#22d3ee" for BBCode color tags, which ignore the theme. static func hex(c: Color) -> String: return "#" + c.to_html(c.a < 1.0) ## The one Theme for every 2D screen. static func theme() -> Theme: if _theme != null: return _theme var t := Theme.new() t.default_font = body_font() t.default_font_size = 14 t.set_color("font_color", "Label", SCREEN) t.set_color("default_color", "RichTextLabel", SCREEN) t.set_font("normal_font", "RichTextLabel", body_font()) t.set_font("bold_font", "RichTextLabel", body_font(700)) t.set_font("mono_font", "RichTextLabel", body_font()) t.set_font("italics_font", "RichTextLabel", body_font(300)) t.set_stylebox("panel", "PanelContainer", chamfer_box(ACCENT_DK)) t.set_stylebox("panel", "Panel", chamfer_box(ACCENT_DK)) # Buttons: dim frame at rest, the accent on hover, filled when pressed. var normal := chamfer_box(ACCENT_DK, PANEL_HI, 1.0, 0.0, 6.0) normal.content_margin_left = 10 normal.content_margin_right = 10 t.set_stylebox("normal", "Button", normal) t.set_stylebox("hover", "Button", normal.tinted(Color("#0c2730f0"), ACCENT)) t.set_stylebox("pressed", "Button", normal.tinted(Color(ACCENT, 0.35), ACCENT)) t.set_stylebox("disabled", "Button", normal.tinted(Color("#05080ac0"), Color("#16262b"))) t.set_stylebox("focus", "Button", StyleBoxEmpty.new()) t.set_color("font_color", "Button", SCREEN) t.set_color("font_hover_color", "Button", Color.WHITE) t.set_color("font_pressed_color", "Button", Color.WHITE) t.set_color("font_disabled_color", "Button", DISABLED) # A filled accent button for the main action. t.add_type("PrimaryButton") t.set_type_variation("PrimaryButton", "Button") var prim := chamfer_box(ACCENT, Color(ACCENT, 0.16), 1.5, 6.0, 8.0) prim.ticks = true t.set_stylebox("normal", "PrimaryButton", prim) var prim_hover := prim.tinted(Color(ACCENT, 0.3), ACCENT.lightened(0.3)) prim_hover.glow = 9.0 t.set_stylebox("hover", "PrimaryButton", prim_hover) t.set_stylebox("pressed", "PrimaryButton", prim.tinted(Color(ACCENT, 0.55), Color.WHITE)) t.set_stylebox("disabled", "PrimaryButton", normal.tinted(Color("#05080ac0"), Color("#16262b"))) t.set_color("font_color", "PrimaryButton", ACCENT.lightened(0.35)) t.set_font("font", "PrimaryButton", body_font(700)) # Big menu buttons in the display face (BigButton: MenuButton is a built-in class). t.add_type("BigButton") t.set_type_variation("BigButton", "Button") var menu := chamfer_box(ACCENT_DK, Color("#05080ad0"), 1.5, 0.0, 12.0) menu.content_margin_left = 24 menu.content_margin_right = 24 menu.content_margin_top = 12 menu.content_margin_bottom = 12 t.set_stylebox("normal", "BigButton", menu) var menu_hover := menu.tinted(Color(ACCENT, 0.16), ACCENT) menu_hover.glow = 12.0 menu_hover.ticks = true t.set_stylebox("hover", "BigButton", menu_hover) t.set_stylebox("pressed", "BigButton", menu.tinted(Color(ACCENT, 0.4), Color.WHITE)) t.set_stylebox("disabled", "BigButton", menu.tinted(Color("#05080a90"), Color("#132227"))) t.set_font("font", "BigButton", display_font(600)) t.set_font_size("font_size", "BigButton", 20) # Text styles. t.add_type("Title") t.set_type_variation("Title", "Label") t.set_color("font_color", "Title", ACCENT) t.set_font("font", "Title", body_font(700)) t.add_type("Heading") t.set_type_variation("Heading", "Label") t.set_color("font_color", "Heading", ACCENT) t.set_font("font", "Heading", display_font(700)) t.set_font_size("font_size", "Heading", 18) t.add_type("Muted") t.set_type_variation("Muted", "Label") t.set_color("font_color", "Muted", MUTED) t.add_type("Micro") t.set_type_variation("Micro", "Label") t.set_color("font_color", "Micro", MUTED) t.set_font_size("font_size", "Micro", 11) # Inputs. var field := chamfer_box(ACCENT_DK, Color("#03090bf0"), 1.0, 0.0, 5.0) t.set_stylebox("normal", "LineEdit", field) t.set_stylebox("focus", "LineEdit", field.tinted(Color("#03090bf0"), ACCENT)) t.set_color("font_color", "LineEdit", SCREEN) t.set_color("caret_color", "LineEdit", ACCENT) t.set_color("selection_color", "LineEdit", Color(ACCENT, 0.35)) t.set_stylebox("normal", "OptionButton", normal) t.set_stylebox("hover", "OptionButton", normal.tinted(Color("#0c2730f0"), ACCENT)) t.set_stylebox("pressed", "OptionButton", normal.tinted(Color(ACCENT, 0.35), ACCENT)) t.set_stylebox("focus", "OptionButton", StyleBoxEmpty.new()) var popup := chamfer_box(ACCENT, Color("#05080af8"), 1.0, 0.0, 6.0) t.set_stylebox("panel", "PopupMenu", popup) t.set_stylebox("hover", "PopupMenu", chamfer_box(ACCENT, Color(ACCENT, 0.2), 0.0, 0.0, 4.0)) t.set_color("font_color", "PopupMenu", SCREEN) t.set_color("font_hover_color", "PopupMenu", Color.WHITE) t.set_font("font", "PopupMenu", body_font()) for state in ["normal", "hover", "pressed", "hover_pressed", "disabled"]: t.set_stylebox(state, "CheckBox", StyleBoxEmpty.new()) t.set_stylebox("focus", "CheckBox", StyleBoxEmpty.new()) t.set_color("font_color", "CheckBox", SCREEN) t.set_color("font_hover_color", "CheckBox", Color.WHITE) t.set_color("font_pressed_color", "CheckBox", SCREEN) t.set_color("font_hover_pressed_color", "CheckBox", Color.WHITE) var track := chamfer_box(ACCENT_DK, Color("#03090b"), 1.0, 0.0, 3.0) track.content_margin_top = 3 track.content_margin_bottom = 3 t.set_stylebox("slider", "HSlider", track) var fill := chamfer_box(ACCENT, Color(ACCENT, 0.5), 0.0, 0.0, 3.0) fill.content_margin_top = 3 fill.content_margin_bottom = 3 t.set_stylebox("grabber_area", "HSlider", fill) t.set_stylebox("grabber_area_highlight", "HSlider", fill.tinted(Color(ACCENT, 0.75), ACCENT)) # Thin scrollbars in the chrome color. var grab := chamfer_box(ACCENT_DK, Color(ACCENT_DK, 0.8), 0.0, 0.0, 2.0) grab.set_content_margin_all(3) for bar in ["VScrollBar", "HScrollBar"]: var empty := StyleBoxEmpty.new() empty.set_content_margin_all(3) t.set_stylebox("scroll", bar, empty) t.set_stylebox("grabber", bar, grab) t.set_stylebox("grabber_highlight", bar, grab.tinted(Color(ACCENT, 0.8), ACCENT)) t.set_stylebox("grabber_pressed", bar, grab.tinted(ACCENT, ACCENT)) var tip := chamfer_box(ACCENT, Color("#05080af8"), 1.0, 0.0, 5.0) t.set_stylebox("panel", "TooltipPanel", tip) t.set_color("font_color", "TooltipLabel", SCREEN) _theme = t return t # --------------------------------------------------------------------------------------------- # Screen geometry ## The base-size scale for a viewport of size `vp`. static func scale_of(vp: Vector2) -> Vector2: return vp / BASE ## The screen rect the panels leave free for the table, in viewport pixels. static func table_region(vp: Vector2, bottom := PANEL_BOTTOM) -> Rect2: var s := scale_of(vp) return Rect2(0, PANEL_TOP * s.y, vp.x - PANEL_RIGHT * s.x, vp.y - (PANEL_TOP + bottom) * s.y)