From ebe81d9f1ee7bb74f319343d21749518afa3545a Mon Sep 17 00:00:00 2001 From: RobinFiredrake Date: Tue, 10 Nov 2026 18:10:16 -0600 Subject: [PATCH] Theme system: runtime colour tokens, theme sets and a Theme dialog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- tests/test_plain_display.gd | 2 +- tests/test_theme.gd | 80 +++++++++++++++++ ui/board_view.gd | 54 ++++++++---- ui/builtin_themes.gd | 45 ++++++++++ ui/builtin_themes.gd.uid | 1 + ui/card_layer.gd | 16 ++-- ui/chevron_button.gd | 6 +- ui/choice_dialog.gd | 18 ++-- ui/collection_switcher.gd | 2 +- ui/details_popup.gd | 2 +- ui/die_icon.gd | 2 +- ui/earlier_rolls.gd | 10 +-- ui/fill_editor.gd | 96 +++++++++++++++++++++ ui/fill_editor.gd.uid | 1 + ui/group_card.gd | 30 +++---- ui/help_dialog.gd | 2 +- ui/inspector.gd | 10 +-- ui/inspector_card.gd | 4 +- ui/inspector_kit.gd | 16 ++-- ui/io_menu.gd | 2 +- ui/main.gd | 8 +- ui/main_editing.gd | 4 +- ui/main_history.gd | 4 +- ui/main_top_bar.gd | 23 +++-- ui/minimap.gd | 10 +-- ui/modal_card.gd | 14 +-- ui/panel_splitter.gd | 4 +- ui/pipe_layer.gd | 50 +++++------ ui/pipe_popover.gd | 6 +- ui/port_layer.gd | 22 ++--- ui/result_tray.gd | 17 ++-- ui/rich_text.gd | 24 ++---- ui/search_panel.gd | 8 +- ui/style.gd | 151 ++++++++++++++++++++++++-------- ui/table_card.gd | 8 +- ui/table_card_editing.gd | 6 +- ui/table_card_header.gd | 24 +++--- ui/table_card_rows.gd | 18 ++-- ui/table_card_text.gd | 2 +- ui/table_card_value.gd | 4 +- ui/table_preview.gd | 12 +-- ui/template_forms.gd | 10 +-- ui/template_picker.gd | 4 +- ui/test_board_dialog.gd | 4 +- ui/theme_dialog.gd | 150 ++++++++++++++++++++++++++++++++ ui/theme_dialog.gd.uid | 1 + ui/theme_store.gd | 167 ++++++++++++++++++++++++++++++++++++ ui/theme_store.gd.uid | 1 + ui/tray_chips.gd | 24 +++--- ui/value_picker.gd | 6 +- ui/variables_panel.gd | 28 +++--- ui/view_menu.gd | 8 +- ui/why_popover.gd | 2 +- 53 files changed, 926 insertions(+), 297 deletions(-) create mode 100644 tests/test_theme.gd create mode 100644 ui/builtin_themes.gd create mode 100644 ui/builtin_themes.gd.uid create mode 100644 ui/fill_editor.gd create mode 100644 ui/fill_editor.gd.uid create mode 100644 ui/theme_dialog.gd create mode 100644 ui/theme_dialog.gd.uid create mode 100644 ui/theme_store.gd create mode 100644 ui/theme_store.gd.uid diff --git a/tests/test_plain_display.gd b/tests/test_plain_display.gd index fd769da..6bd72d5 100644 --- a/tests/test_plain_display.gd +++ b/tests/test_plain_display.gd @@ -391,7 +391,7 @@ func _test_build_rows() -> void: _eq(main.get("picked").back(), ["beyond", "e2"], "clicking a result row calls select_result") _eq(beyond.selected_entry(), "e2", "the row is selected") var sb := row.get_theme_stylebox("panel") as StyleBoxFlat - _check(sb != null and sb.border_width_left == 3 and sb.border_color == Style.COPPER, "the selected row has a copper bar") + _check(sb != null and sb.border_width_left == 3 and sb.border_color == Style.TRIM, "the selected row has a copper bar") var gate := main.card_for("gate") (gate.rows["ok"] as Control).emit_signal("gui_input", ev) _eq(beyond.selected_entry(), "", "selecting on another card clears this one") diff --git a/tests/test_theme.gd b/tests/test_theme.gd new file mode 100644 index 0000000..0adeeba --- /dev/null +++ b/tests/test_theme.gd @@ -0,0 +1,80 @@ +extends SceneTree +## Theme sets: applying built-ins sets Style tokens and fills, saving and +## deleting a user set, and the Theme dialog building its editors. +## Run: godot --headless --path . -s res://tests/test_theme.gd -- --sample + +var _failures := 0 +var main: Main + + +func _init() -> void: + if not OS.get_cmdline_user_args().has("--sample"): + print("Run with -- --sample so the test can't touch saved data.") + quit(2) + return + ThemeStore.DIR = OS.get_temp_dir().path_join("tt_theme_test_%d/" % OS.get_process_id()) + main = load("res://ui/main.tscn").instantiate() + root.add_child(main) + await _frames(5) + _test_apply() + _test_save_delete() + await _test_dialog() + print("%s: %d failure(s)" % ["PASS" if _failures == 0 else "FAIL", _failures]) + quit(1 if _failures else 0) + + +func _test_apply() -> void: + _check(ThemeStore.current.get("id") == "tarot", "Tarot is the default set") + _check(Style.BG == Color("#2c0744"), "Tarot sets the background colour") + _check(Style.fill_texture(Style.BG_FILL) != null, "Tarot's background is a gradient") + _check(BoardView.pattern_texture("stars") != null and BoardView.pattern_texture("none") == null, "patterns build") + ThemeStore.apply(BuiltinThemes.FELT) + _check(Style.BG == Color("#1f4a39"), "Felt falls back to the original colours") + _check(Style.PATTERN == "dots", "Felt uses dots") + _check(Style.panel_box() is StyleBoxFlat, "a solid panel fill is a flat box") + ThemeStore.apply(BuiltinThemes.TAROT) + _check(Style.panel_box() is StyleBoxTexture, "a gradient panel fill is a texture box") + var cols := ThemeStore.resolved_colors(BuiltinThemes.FELT) + _check(cols.size() == ThemeStore.TOKENS.size(), "resolved colours cover every token") + + +func _test_save_delete() -> void: + var t := BuiltinThemes.TAROT.duplicate(true) + t["name"] = "Night Sky" + var id := ThemeStore.save(t) + _check(id != "tarot", "saving a built-in makes a new id: " + id) + _check(ThemeStore.find(id).get("name") == "Night Sky", "the saved set is found") + _check(ThemeStore.all().size() == BuiltinThemes.all().size() + 1, "the saved set is listed") + ThemeStore.delete("tarot") + _check(ThemeStore.find("tarot").get("builtin", false), "built-ins can't be deleted") + ThemeStore.delete(id) + _check(ThemeStore.all().size() == BuiltinThemes.all().size(), "the user set is deleted") + + +func _test_dialog() -> void: + var d := ThemeDialog.new(main) + main.add_child(d) + await _frames() + _check(d._content.find_children("*", "FillEditor", true, false).size() == 2, "background and panel fill editors") + var basic := d._content.find_children("*", "ColorPickerButton", true, false).size() + d._more = true + d._rebuild() + await _frames() + var all := d._content.find_children("*", "ColorPickerButton", true, false).size() + _check(all > basic, "More colours shows more swatches (%d > %d)" % [all, basic]) + var fe := d._content.find_children("*", "FillEditor", true, false)[0] as FillEditor + fe._set_kind(1) + _check((fe.fill["colors"] as Array).size() >= 2 and d._dirty, "a gradient gets two colours and marks the set changed") + d.close() + await _frames() + + +func _frames(n: int = 2) -> void: + for i in n: + await process_frame + + +func _check(ok: bool, what: String) -> void: + if not ok: + _failures += 1 + print("FAIL ", what) diff --git a/ui/board_view.gd b/ui/board_view.gd index ec7313b..0defaf1 100644 --- a/ui/board_view.gd +++ b/ui/board_view.gd @@ -39,6 +39,7 @@ var _banding := false var _band_from := Vector2.ZERO var _band_to := Vector2.ZERO var _press_at := Vector2(-1, -1) +## The theme background gradient (null when flat) and tiled pattern (null for none). var _glow: GradientTexture2D var _dots: ImageTexture @@ -76,20 +77,8 @@ func setup(p_main: Main) -> void: minimap.setup(self) add_child(minimap) - var img := Image.create(6, 6, false, Image.FORMAT_RGBA8) - img.fill(Color(0, 0, 0, 0)) - img.set_pixel(1, 1, Color(1, 1, 1, 0.06)) - _dots = ImageTexture.create_from_image(img) - var g := Gradient.new() - g.set_color(0, Color(1, 1, 1, 0.06)) - g.set_color(1, Color(1, 1, 1, 0)) - _glow = GradientTexture2D.new() - _glow.gradient = g - _glow.fill = GradientTexture2D.FILL_RADIAL - _glow.fill_from = Vector2(0.35, 0.3) - _glow.fill_to = Vector2(0.8, 0.3) - _glow.width = 256 - _glow.height = 256 + _glow = Style.fill_texture(Style.BG_FILL) + _dots = pattern_texture(Style.PATTERN) resized.connect(queue_redraw) @@ -178,9 +167,36 @@ func _content_of(n: Control) -> CanvasItem: func _draw() -> void: var r := Rect2(Vector2.ZERO, size) - draw_rect(r, Style.FELT) - draw_texture_rect(_glow, r, false) - draw_texture_rect(_dots, r, true) + draw_rect(r, Style.BG) + if _glow: + draw_texture_rect(_glow, r, false) + if _dots: + draw_texture_rect(_dots, r, true) + + +## A small tile for the background pattern: "dots" (a faint grid) or "stars" +## (sparse four-point twinkles). Null for "none". +static func pattern_texture(kind: String) -> ImageTexture: + match kind: + "dots": + var img := Image.create(6, 6, false, Image.FORMAT_RGBA8) + img.fill(Color(0, 0, 0, 0)) + img.set_pixel(1, 1, Color(1, 1, 1, 0.06)) + return ImageTexture.create_from_image(img) + "stars": + var img := Image.create(96, 96, false, Image.FORMAT_RGBA8) + img.fill(Color(0, 0, 0, 0)) + var rng := RandomNumberGenerator.new() + rng.seed = 7 + for i in 9: + var p := Vector2i(rng.randi_range(2, 93), rng.randi_range(2, 93)) + var a := rng.randf_range(0.05, 0.13) + img.set_pixelv(p, Color(1, 1, 1, a * 1.6)) + if i % 3 == 0: + for d: Vector2i in [Vector2i(1, 0), Vector2i(-1, 0), Vector2i(0, 1), Vector2i(0, -1)]: + img.set_pixelv(p + d, Color(1, 1, 1, a * 0.7)) + return ImageTexture.create_from_image(img) + return null func world_mouse() -> Vector2: @@ -357,8 +373,8 @@ func _draw_band() -> void: if not _banding: return var r := Rect2(_band_from.min(_band_to), (_band_from - _band_to).abs()) - overlay.draw_rect(r, Color(Style.BRASS, 0.12)) - overlay.draw_rect(r, Style.BRASS, false, 1.5) + overlay.draw_rect(r, Color(Style.ACCENT, 0.12)) + overlay.draw_rect(r, Style.ACCENT, false, 1.5) func _notification(what: int) -> void: diff --git a/ui/builtin_themes.gd b/ui/builtin_themes.gd new file mode 100644 index 0000000..c19840a --- /dev/null +++ b/ui/builtin_themes.gd @@ -0,0 +1,45 @@ +class_name BuiltinThemes +extends RefCounted +## The theme sets that ship with the app. Kept in code rather than JSON so they +## need no export filter. A set lists only what differs from Style's fallback +## values (the Felt look); ThemeStore fills in the rest. +## +## Set keys: id, name, colors {TOKEN: "#hex"}, background and panel fills +## ({kind: "solid"|"linear"|"radial", colors: [...], angle}), pattern +## ("none"|"dots"|"stars"), logo, font_body, font_display. + +const TAROT := { + "id": "tarot", "name": "Tarot", "builtin": true, + "pattern": "stars", "logo": "fortune_teller", + "font_body": "atkinson", "font_display": "rokkitt", + # A jewel-tone spread cloth with a soft shine up and to the left. + "background": {"kind": "radial", "colors": ["#4b1470", "#2c0744", "#1f0431"], "center": [0.32, 0.28]}, + "panel": {"kind": "linear", "colors": ["#260539", "#16021f"], "angle": 90}, + "colors": { + "BG": "#2c0744", "BG_DEEP": "#1c0329", "BG_HOVER": "#45106a", "PANEL": "#1c0329", + "ON_BG": "#f3e7f8", "ON_BG_MUTED": "#bba5cb", + "CARD": "#f4ead8", "CARD_SOFT": "#faf3e6", "CARD_HOVER": "#eadcc3", "CARD_SHADE": "#ddcdb0", + "INK": "#1c0329", "MUTED": "#6e5a7c", "FAINT": "#a08fae", "RULE": "#e2d2b8", + "DASH": "#c6b395", "HOVER_ROW": "#efe2cb", "STRIPE": "#5c0e7510", + "TRIM": "#823d08", "TRIM_DARK": "#4a2004", + "THREAD": "#c07a2c", "THREAD_DARK": "#5a2a06", + "ACCENT": "#f2b84b", "ACCENT_DARK": "#6b4a0c", "LIT": "#fbe3a6", "FLICK": "#f2b84b59", + "PULSE": "#fff3d6", "GLOW": "#2fe39a", + "OK_INK": "#04736e", "REF_INK": "#03635f", "REF_BG": "#d3eeea", "REF_INK_ON_BG": "#7fe8c9", + "VALUE_INK": "#7a3f06", "VALUE_INK_ON_BG": "#f2b84b", "VALUE_BG": "#fbf0d8", "VALUE_BORDER": "#e0b56a", + }, +} + +## The original green felt and copper look, kept as a second set. +const FELT := { + "id": "felt", "name": "Felt", "builtin": true, + "pattern": "dots", "logo": "none", + "font_body": "atkinson", "font_display": "rokkitt", + "background": {"kind": "radial", "colors": ["#2a5c47", "#1f4a39"], "center": [0.35, 0.3]}, + "panel": {"kind": "solid", "colors": ["#12301f"]}, + "colors": {}, +} + + +static func all() -> Array[Dictionary]: + return [TAROT, FELT] diff --git a/ui/builtin_themes.gd.uid b/ui/builtin_themes.gd.uid new file mode 100644 index 0000000..507e0b0 --- /dev/null +++ b/ui/builtin_themes.gd.uid @@ -0,0 +1 @@ +uid://ci5tt4w4gywbw diff --git a/ui/card_layer.gd b/ui/card_layer.gd index 428ff7b..7b57909 100644 --- a/ui/card_layer.gd +++ b/ui/card_layer.gd @@ -35,7 +35,7 @@ func _init() -> void: _shadow = Style.box(Color(0, 0, 0, 0.22), 10) _ring = Style.box(Color(0, 0, 0, 0), 14) _ring.draw_center = false - Style.bordered(_ring, 4, Style.BRASS) + Style.bordered(_ring, 4, Style.ACCENT) overlay = Control.new() overlay.mouse_filter = MOUSE_FILTER_IGNORE overlay.size = size @@ -102,7 +102,7 @@ func _draw_flash() -> void: # Two quick pulses, then a fade. var pulse := 0.65 + 0.35 * cos((1.0 - t) * TAU * 2.0) var a := minf(1.0, t * 2.5) * pulse - _ring.border_color = Color(Style.BRASS, a) + _ring.border_color = Color(Style.ACCENT, a) var glow := _glow_box(a) for v: Variant in [_flash_node] + _flash_extra: if not is_instance_valid(v): @@ -113,14 +113,14 @@ func _draw_flash() -> void: overlay.draw_style_box(glow, r.grow(6.0)) overlay.draw_style_box(_ring, r) if _flash_row.size != Vector2.ZERO: - overlay.draw_rect(_flash_row, Color(Style.BRASS, 0.28 * a)) - overlay.draw_rect(_flash_row, Color(Style.BRASS_DARK, a), false, 2.5) + overlay.draw_rect(_flash_row, Color(Style.ACCENT, 0.28 * a)) + overlay.draw_rect(_flash_row, Color(Style.ACCENT_DARK, a), false, 2.5) func _glow_box(a: float) -> StyleBoxFlat: var g := Style.box(Color(0, 0, 0, 0), 20) g.draw_center = false - Style.bordered(g, 8, Color(Style.BRASS, 0.25 * a)) + Style.bordered(g, 8, Color(Style.ACCENT, 0.25 * a)) return g @@ -140,7 +140,7 @@ func _draw_far() -> void: var w := card.size.x overlay.draw_rect(Rect2(p + Vector2(14, 16), Vector2(w * 0.6, 16)), ink) if lit.has(card.table.id): - overlay.draw_rect(Rect2(p + Vector2(0, 46), Vector2(w, minf(40.0, card.size.y - 52.0))), Style.BRASS) + overlay.draw_rect(Rect2(p + Vector2(0, 46), Vector2(w, minf(40.0, card.size.y - 52.0))), Style.ACCENT) var z := main.board.zoom var font := Style.display(true) for g in main.data.groups: @@ -158,5 +158,5 @@ func _draw_far() -> void: var at := Vector2(r.position.x + (r.size.x - tw) / 2.0, r.position.y + fs * 0.85) if g.collapsed: at.y = r.position.y + r.size.y / 2.0 + fs * 0.3 - overlay.draw_string_outline(font, at, text, HORIZONTAL_ALIGNMENT_LEFT, -1, fs, maxi(2, int(4.0 / z)), Style.FELT_DEEP) - overlay.draw_string(font, at, text, HORIZONTAL_ALIGNMENT_LEFT, -1, fs, Style.ON_FELT if not g.collapsed else Style.BRASS) + overlay.draw_string_outline(font, at, text, HORIZONTAL_ALIGNMENT_LEFT, -1, fs, maxi(2, int(4.0 / z)), Style.BG_DEEP) + overlay.draw_string(font, at, text, HORIZONTAL_ALIGNMENT_LEFT, -1, fs, Style.ON_BG if not g.collapsed else Style.ACCENT) diff --git a/ui/chevron_button.gd b/ui/chevron_button.gd index 7ebd2ae..71e5d60 100644 --- a/ui/chevron_button.gd +++ b/ui/chevron_button.gd @@ -15,7 +15,7 @@ func _init() -> void: flat = false focus_mode = FOCUS_ALL var normal := Style.box(Color(0, 0, 0, 0), 6) - var hover := Style.box(Color("#e6dfcd"), 6) + var hover := Style.box(Style.CARD_HOVER, 6) Style.skin_button(self, normal, hover, hover, Style.MUTED) mouse_entered.connect(queue_redraw) mouse_exited.connect(queue_redraw) @@ -29,7 +29,7 @@ func _draw() -> void: else: pts = PackedVector2Array([c + Vector2(-2, -4), c + Vector2(2, 0), c + Vector2(-2, 4)]) if on_felt: - draw_polyline(pts, Style.ON_FELT if is_hovered() else Style.ON_FELT_MUTED, 2.0, true) + draw_polyline(pts, Style.ON_BG if is_hovered() else Style.ON_BG_MUTED, 2.0, true) else: draw_polyline(pts, Style.INK if is_hovered() else Style.MUTED, 2.0, true) @@ -39,5 +39,5 @@ func use_felt_colors() -> void: on_felt = true var normal := Style.box(Color(0, 0, 0, 0), 6) var hover := Style.box(Color(1, 1, 1, 0.08), 6) - Style.skin_button(self, normal, hover, hover, Style.ON_FELT_MUTED) + Style.skin_button(self, normal, hover, hover, Style.ON_BG_MUTED) queue_redraw() diff --git a/ui/choice_dialog.gd b/ui/choice_dialog.gd index 36ebfef..584d51c 100644 --- a/ui/choice_dialog.gd +++ b/ui/choice_dialog.gd @@ -131,7 +131,7 @@ func _option_row(k: int, o: Dictionary) -> Control: b.size_flags_horizontal = SIZE_EXPAND_FILL var m := [14, 8, 14, 9] var n := Style.bordered(Style.box(Color.WHITE, 9, m), 1, Style.RULE) - var h := Style.bordered(Style.box(Style.LIT, 9, m), 1, Style.BRASS_DARK) + var h := Style.bordered(Style.box(Style.LIT, 9, m), 1, Style.ACCENT_DARK) Style.skin_button(b, n, h, h, Style.INK) b.add_theme_stylebox_override("focus", Style.focus_ring(9)) var row := HBoxContainer.new() @@ -142,7 +142,7 @@ func _option_row(k: int, o: Dictionary) -> Control: row.offset_right = -14 row.offset_top = 8 row.offset_bottom = -9 - var key := Style.make_label(str(k + 1) if k < 9 else "", Style.display(), 20, Style.COPPER) + var key := Style.make_label(str(k + 1) if k < 9 else "", Style.display(), 20, Style.TRIM) key.custom_minimum_size = Vector2(16, 0) key.size_flags_vertical = SIZE_SHRINK_CENTER key.mouse_filter = MOUSE_FILTER_IGNORE @@ -171,8 +171,8 @@ func _option_row(k: int, o: Dictionary) -> Control: var badge := PanelContainer.new() badge.mouse_filter = MOUSE_FILTER_IGNORE badge.size_flags_vertical = SIZE_SHRINK_CENTER - badge.add_theme_stylebox_override("panel", Style.bordered(Style.box(Color(Style.BRASS, 0.18), 6, [9, 1, 9, 2]), 1, Color(Style.BRASS_DARK, 0.4))) - var vl := Style.make_label(vt, Style.display(), 18, Style.COPPER_DARK) + badge.add_theme_stylebox_override("panel", Style.bordered(Style.box(Color(Style.ACCENT, 0.18), 6, [9, 1, 9, 2]), 1, Color(Style.ACCENT_DARK, 0.4))) + var vl := Style.make_label(vt, Style.display(), 18, Style.TRIM_DARK) vl.mouse_filter = MOUSE_FILTER_IGNORE vl.set_meta("option_value", true) badge.add_child(vl) @@ -418,7 +418,7 @@ func _build_chrome() -> void: preview_panel.clip_contents = true var sb := Style.box(Style.CARD, 10, [14, 11, 14, 12]) sb.border_width_top = 3 - sb.border_color = Style.COPPER + sb.border_color = Style.TRIM sb.shadow_color = Color(0, 0, 0, 0.4) sb.shadow_size = 16 sb.shadow_offset = Vector2(0, 6) @@ -478,7 +478,7 @@ func _bar_panel() -> PanelContainer: var p := PanelContainer.new() var sb := Style.bordered(Style.box(Style.CARD, 12, [14, 7, 8, 7]), 1, Style.DASH) sb.border_width_top = 3 - sb.border_color = Style.COPPER + sb.border_color = Style.TRIM sb.shadow_color = Color(0, 0, 0, 0.4) sb.shadow_size = 14 sb.shadow_offset = Vector2(0, 5) @@ -602,7 +602,7 @@ func preview_for_option(k: int) -> Control: what = "%s%s" % [Formatter.strip_tags(str(o.get("label", o.get("option", "")))), (" · level %s" % o["value_text"]) if str(o.get("value_text", "")) != "" else ""] if src != "": what += "\n" + src - var ol := Style.make_label(what, Style.body_bold(), 13, RichText.VAR_INK) + var ol := Style.make_label(what, Style.body_bold(), 13, Style.VALUE_INK) ol.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART ol.mouse_filter = Control.MOUSE_FILTER_IGNORE box.add_child(ol) @@ -618,7 +618,7 @@ func preview_for_option(k: int) -> Control: box.add_child(_rule()) box.add_child(section("When this comes up" if plain else "Effects")) for st: Variant in fx: - var l := Style.make_label(str(st), Style.body_bold(), 13, RichText.VAR_INK) + var l := Style.make_label(str(st), Style.body_bold(), 13, Style.VALUE_INK) l.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART l.mouse_filter = Control.MOUSE_FILTER_IGNORE box.add_child(l) @@ -629,7 +629,7 @@ func preview_for_option(k: int) -> Control: box.add_child(_rule()) var how := Describe.pipe(e, tid, board) if plain else PipeLayer._pipe_tag(e, tid) if how != "": - var hl := Style.make_label(("Then: " if plain else "pipe: ") + how, Style.body_bold(), 12, Style.COPPER_DARK) + var hl := Style.make_label(("Then: " if plain else "pipe: ") + how, Style.body_bold(), 12, Style.TRIM_DARK) hl.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART hl.mouse_filter = Control.MOUSE_FILTER_IGNORE hl.set_meta("pipe_line", true) diff --git a/ui/collection_switcher.gd b/ui/collection_switcher.gd index ff41313..326eeb8 100644 --- a/ui/collection_switcher.gd +++ b/ui/collection_switcher.gd @@ -18,7 +18,7 @@ var _ids: Array[String] = [] func setup(p_main: Main) -> void: main = p_main Style.menu_button(text, false, self) - add_theme_color_override("font_disabled_color", Style.ON_FELT) + add_theme_color_override("font_disabled_color", Style.ON_BG) add_theme_font_override("font", Style.body_bold()) tooltip_text = "Collections" ModalCard.style_popup(get_popup()) diff --git a/ui/details_popup.gd b/ui/details_popup.gd index 1540660..cd58226 100644 --- a/ui/details_popup.gd +++ b/ui/details_popup.gd @@ -31,7 +31,7 @@ func setup(p_main: Main) -> void: top_level = true var sb := Style.box(Style.CARD, 9, [13, 10, 13, 11]) sb.border_width_top = 3 - sb.border_color = Style.COPPER + sb.border_color = Style.TRIM sb.shadow_color = Color(0, 0, 0, 0.35) sb.shadow_size = 14 sb.shadow_offset = Vector2(0, 6) diff --git a/ui/die_icon.gd b/ui/die_icon.gd index 779168a..28db855 100644 --- a/ui/die_icon.gd +++ b/ui/die_icon.gd @@ -2,7 +2,7 @@ class_name DieIcon extends Control ## A three-pip die face. Tumbles while `spinning` is on. -var color: Color = Style.BRASS +var color: Color = Style.ACCENT var spinning: bool = false: set(value): spinning = value diff --git a/ui/earlier_rolls.gd b/ui/earlier_rolls.gd index 0777caa..1659494 100644 --- a/ui/earlier_rolls.gd +++ b/ui/earlier_rolls.gd @@ -21,7 +21,7 @@ func setup(p_main: Main) -> void: _rows.add_theme_constant_override("separation", 6) _rows.size_flags_horizontal = SIZE_EXPAND_FILL scroll.add_child(_rows) - _empty = Style.make_label("Older rolls show here.", Style.body(), 15, Style.ON_FELT_MUTED) + _empty = Style.make_label("Older rolls show here.", Style.body(), 15, Style.ON_BG_MUTED) add_child(_empty) @@ -35,11 +35,11 @@ func render() -> void: for rec in main.history: var row := HBoxContainer.new() row.add_theme_constant_override("separation", 8) - var time := Style.make_label(clock(rec["time"]), Style.body(), 14, Style.ON_FELT_MUTED) + var time := Style.make_label(clock(rec["time"]), Style.body(), 14, Style.ON_BG_MUTED) time.custom_minimum_size = Vector2(44, 0) time.size_flags_vertical = SIZE_SHRINK_BEGIN row.add_child(time) - var line := RichText.label(earlier_line(rec), 14, Style.ON_FELT, false) + var line := RichText.label(earlier_line(rec), 14, Style.ON_BG, false) line.size_flags_horizontal = SIZE_EXPAND_FILL RichText.hook_hover(line, main) row.add_child(line) @@ -62,9 +62,9 @@ static func earlier_line(rec: Dictionary) -> String: continue texts.insert(0, RichText.decorate(TrayText.one_line(str(s["text"])), true)) shown += 1 - var lead := "[color=#%s]%s:[/color] " % [Style.ON_FELT_MUTED.to_html(false), RichText.plain(Formatter.strip_tags(str(rec.get("root_name", ""))))] + var lead := "[color=#%s]%s:[/color] " % [Style.ON_BG_MUTED.to_html(false), RichText.plain(Formatter.strip_tags(str(rec.get("root_name", ""))))] if skipped > 0: - lead += "[color=#%s]… %d earlier →[/color] " % [Style.ON_FELT_MUTED.to_html(false), skipped] + lead += "[color=#%s]… %d earlier →[/color] " % [Style.ON_BG_MUTED.to_html(false), skipped] return lead + " → ".join(texts) diff --git a/ui/fill_editor.gd b/ui/fill_editor.gd new file mode 100644 index 0000000..7ce4682 --- /dev/null +++ b/ui/fill_editor.gd @@ -0,0 +1,96 @@ +class_name FillEditor +extends VBoxContainer +## Edits a large-area fill (Style.fill_texture spec): Flat, Straight gradient or +## Round gradient, two to four colour stops and, for straight ones, an angle. + +signal changed + +const KINDS := ["solid", "linear", "radial"] +const MAX_STOPS := 4 + +var fill: Dictionary + + +func _init(p_fill: Dictionary, flat: Color) -> void: + fill = p_fill.duplicate(true) + if (fill.get("colors", []) as Array).is_empty(): + fill["colors"] = ["#" + flat.to_html(true)] + if not fill.has("kind"): + fill["kind"] = "solid" + add_theme_constant_override("separation", 8) + _rebuild() + + +func _rebuild() -> void: + for c in get_children(): + c.queue_free() + var kind := KINDS.find(str(fill["kind"])) + add_child(ModalCard.segmented(["Flat", "Straight gradient", "Round gradient"], maxi(kind, 0), _set_kind)) + var row := HBoxContainer.new() + row.add_theme_constant_override("separation", 6) + add_child(row) + var cols: Array = fill["colors"] + var shown := 1 if fill["kind"] == "solid" else cols.size() + for i in shown: + var pick := swatch(Color.from_string(str(cols[i]), Color.BLACK), _set_color.bind(i)) + pick.tooltip_text = "Colour" if shown == 1 else "Colour %d of %d" % [i + 1, shown] + row.add_child(pick) + if fill["kind"] == "solid": + return + if cols.size() < MAX_STOPS: + row.add_child(_small("+", "Add a colour", func() -> void: + cols.append(cols[-1]) + _changed(true))) + if cols.size() > 2: + row.add_child(_small("−", "Remove the last colour", func() -> void: + cols.pop_back() + _changed(true))) + if fill["kind"] == "linear": + var spin := SpinBox.new() + spin.min_value = 0 + spin.max_value = 359 + spin.step = 15 + spin.suffix = "°" + spin.value = float(fill.get("angle", 90)) + spin.tooltip_text = "Direction: 90° runs top to bottom, 0° left to right" + spin.value_changed.connect(func(v: float) -> void: + fill["angle"] = int(v) + changed.emit()) + row.add_child(spin) + + +## A colour button used across the theme editor. +static func swatch(c: Color, on_change: Callable) -> ColorPickerButton: + var pick := ColorPickerButton.new() + pick.color = c + pick.custom_minimum_size = Vector2(44, 30) + pick.edit_alpha = true + pick.color_changed.connect(func(nc: Color) -> void: on_change.call(nc)) + return pick + + +func _set_kind(i: int) -> void: + fill["kind"] = KINDS[i] + var cols: Array = fill["colors"] + if i > 0 and cols.size() < 2: + var base := Color.from_string(str(cols[0]), Color.BLACK) + cols.append("#" + base.darkened(0.35).to_html(true)) + _changed(true) + + +func _set_color(c: Color, i: int) -> void: + (fill["colors"] as Array)[i] = "#" + c.to_html(true) + changed.emit() + + +func _changed(rebuild: bool) -> void: + if rebuild: + _rebuild.call_deferred() + changed.emit() + + +func _small(text: String, tip: String, on_press: Callable) -> Button: + var b := ModalCard.make_button(text) + b.tooltip_text = tip + b.pressed.connect(on_press) + return b diff --git a/ui/fill_editor.gd.uid b/ui/fill_editor.gd.uid new file mode 100644 index 0000000..26dfa85 --- /dev/null +++ b/ui/fill_editor.gd.uid @@ -0,0 +1 @@ +uid://bx6cong187kee diff --git a/ui/group_card.gd b/ui/group_card.gd index 5f14876..ebca2bb 100644 --- a/ui/group_card.gd +++ b/ui/group_card.gd @@ -51,20 +51,20 @@ func setup(p_main: Main, p_group: TableGroup) -> void: theme = Style.card_theme() _frame_box = Style.box(Color(0, 0, 0, 0.16), 16) Style.bordered(_frame_box, 1, Color(1, 1, 1, 0.08)) - _frame_drop = Style.box(Color(Style.BRASS, 0.08), 16) - Style.bordered(_frame_drop, 2, Style.BRASS) + _frame_drop = Style.box(Color(Style.ACCENT, 0.08), 16) + Style.bordered(_frame_drop, 2, Style.ACCENT) _band_box = Style.box(Color(0, 0, 0, 0.16), 0) _band_box.corner_radius_top_left = 16 _band_box.corner_radius_top_right = 16 - _stack_box = Style.bordered(Style.box(Color("#d9d3c2"), 10), 1, Color(0, 0, 0, 0.12)) + _stack_box = Style.bordered(Style.box(Style.CARD_SHADE, 10), 1, Color(0, 0, 0, 0.12)) _card_box = Style.box(Style.CARD, 10) _card_box.shadow_color = Color(0, 0, 0, 0.32) _card_box.shadow_size = 16 _card_box.shadow_offset = Vector2(0, 8) _card_rolling = _card_box.duplicate() as StyleBoxFlat - Style.bordered(_card_rolling, 3, Style.BRASS) + Style.bordered(_card_rolling, 3, Style.ACCENT) _card_rolling.set_expand_margin_all(3) - _card_rolling.shadow_color = Color(Style.BRASS, 0.45) + _card_rolling.shadow_color = Color(Style.ACCENT, 0.45) _card_rolling.shadow_size = 26 _card_rolling.shadow_offset = Vector2.ZERO minimum_size_changed.connect(func() -> void: _shrink.call_deferred()) @@ -157,14 +157,14 @@ func _build_frame() -> void: if build: h.add_child(_name_edit(true)) else: - var title := Style.make_label(Formatter.strip_tags(group.name), Style.display(true), 20, Style.ON_FELT) + var title := Style.make_label(Formatter.strip_tags(group.name), Style.display(true), 20, Style.ON_BG) title.size_flags_vertical = SIZE_SHRINK_CENTER title.size_flags_horizontal = SIZE_EXPAND_FILL title.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS title.custom_minimum_size = Vector2(30, 0) title.mouse_filter = MOUSE_FILTER_IGNORE h.add_child(title) - var count := Style.make_label(count_text(), Style.body(true), 13, Style.ON_FELT_MUTED) + var count := Style.make_label(count_text(), Style.body(true), 13, Style.ON_BG_MUTED) count.size_flags_vertical = SIZE_SHRINK_CENTER count.mouse_filter = MOUSE_FILTER_IGNORE if group.details.strip_edges() != "": @@ -290,14 +290,14 @@ func _stack_badge() -> Control: c.mouse_filter = MOUSE_FILTER_IGNORE c.tooltip_text = count_text() c.draw.connect(func() -> void: - var back := Style.bordered(Style.box(Color("#ddd6c4"), 3), 1, Style.COPPER_DARK) - var front := Style.bordered(Style.box(Style.FELT, 3), 1, Style.FELT_DEEP) + var back := Style.bordered(Style.box(Style.CARD_SHADE, 3), 1, Style.TRIM_DARK) + var front := Style.bordered(Style.box(Style.BG, 3), 1, Style.BG_DEEP) c.draw_style_box(back, Rect2(8, 2, 18, 22)) c.draw_style_box(front, Rect2(3, 6, 18, 22)) var s := str(group.members.size()) var f := Style.display(true) var w := f.get_string_size(s, HORIZONTAL_ALIGNMENT_LEFT, -1, 14).x - c.draw_string(f, Vector2(12.0 - w / 2.0, 22), s, HORIZONTAL_ALIGNMENT_LEFT, -1, 14, Style.BRASS) + c.draw_string(f, Vector2(12.0 - w / 2.0, 22), s, HORIZONTAL_ALIGNMENT_LEFT, -1, 14, Style.ACCENT) ) return c @@ -312,7 +312,7 @@ func _lit_row(key: String) -> Control: row.add_theme_stylebox_override("panel", Style.box(Style.LIT, 0, [14, 5, 22, 6])) var v := TableCard.vbox(1) row.add_child(v) - var cap := Style.make_label(Formatter.strip_tags(t.name if t else tid).to_upper(), Style.caps(), 10, Style.COPPER_DARK) + var cap := Style.make_label(Formatter.strip_tags(t.name if t else tid).to_upper(), Style.caps(), 10, Style.TRIM_DARK) cap.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS cap.custom_minimum_size = Vector2(20, 0) cap.mouse_filter = MOUSE_FILTER_IGNORE @@ -350,11 +350,11 @@ func _name_edit(on_felt: bool) -> LineEdit: le.add_theme_font_override("font", Style.display(true)) le.add_theme_font_size_override("font_size", 18) if on_felt: - le.add_theme_color_override("font_color", Style.ON_FELT) - le.add_theme_color_override("caret_color", Style.ON_FELT) - le.add_theme_color_override("font_placeholder_color", Style.ON_FELT_MUTED) + le.add_theme_color_override("font_color", Style.ON_BG) + le.add_theme_color_override("caret_color", Style.ON_BG) + le.add_theme_color_override("font_placeholder_color", Style.ON_BG_MUTED) le.add_theme_stylebox_override("normal", Style.bordered(Style.box(Color(0, 0, 0, 0.12), 6, [7, 3, 7, 3]), 1, Color(1, 1, 1, 0.14))) - le.add_theme_stylebox_override("focus", Style.bordered(Style.box(Color(0, 0, 0, 0.25), 6, [7, 3, 7, 3]), 1, Style.BRASS)) + le.add_theme_stylebox_override("focus", Style.bordered(Style.box(Color(0, 0, 0, 0.25), 6, [7, 3, 7, 3]), 1, Style.ACCENT)) else: le.add_theme_stylebox_override("normal", Style.bordered(Style.box(Color.WHITE, 6, [7, 3, 7, 3]), 1, Style.RULE)) le.tooltip_text = "Rename this group" diff --git a/ui/help_dialog.gd b/ui/help_dialog.gd index cdab161..e0ad24f 100644 --- a/ui/help_dialog.gd +++ b/ui/help_dialog.gd @@ -137,7 +137,7 @@ func _topic_button(title: String, group: ButtonGroup) -> Button: b.alignment = HORIZONTAL_ALIGNMENT_LEFT b.add_theme_font_size_override("font_size", 15) var m := [10, 5, 10, 5] - var on := Style.box(Color(Style.BRASS, 0.3), 6, m) + var on := Style.box(Color(Style.ACCENT, 0.3), 6, m) Style.skin_button(b, Style.box(Color(0, 0, 0, 0), 6, m), Style.box(Style.HOVER_ROW, 6, m), on, Style.INK) b.add_theme_stylebox_override("hover_pressed", on) b.pressed.connect(func() -> void: show_topic(title)) diff --git a/ui/inspector.gd b/ui/inspector.gd index 12e67f0..8a01afd 100644 --- a/ui/inspector.gd +++ b/ui/inspector.gd @@ -84,7 +84,7 @@ func setup(p_main: Main) -> void: open.tooltip_text = "Show the inspector" open.size_flags_vertical = Control.SIZE_SHRINK_BEGIN Style.skin_button(open, Style.box(Color(0, 0, 0, 0), 5, [4, 2, 4, 2]), Style.box(Style.HOVER_ROW, 5, [4, 2, 4, 2]), - Style.box(Style.HOVER_ROW, 5, [4, 2, 4, 2]), Style.COPPER_DARK) + Style.box(Style.HOVER_ROW, 5, [4, 2, 4, 2]), Style.TRIM_DARK) open.add_theme_font_size_override("font_size", 18) open.pressed.connect(func() -> void: set_collapsed(false)) _strip.add_child(open) @@ -544,7 +544,7 @@ func _pipe_box(t: RollTable, e: TableEntry, to: String) -> Control: var parts := {"inputs": {}} var taken := main.lit_pipes.has(Roller.pipe_key(t.id, e.id, to)) var panel := PanelContainer.new() - var sb := Style.bordered(Style.box(InspectorKit.TAKEN_BG if taken else InspectorKit.BOX_BG, 8, [10, 9, 10, 10]), 1, Style.BRASS if taken else Style.RULE) + var sb := Style.bordered(Style.box(Style.VALUE_BG if taken else Style.CARD_SOFT, 8, [10, 9, 10, 10]), 1, Style.ACCENT if taken else Style.RULE) panel.add_theme_stylebox_override("panel", sb) var v := InspectorKit.vbox(8) panel.add_child(v) @@ -552,13 +552,13 @@ func _pipe_box(t: RollTable, e: TableEntry, to: String) -> Control: parts["taken"] = taken var head := InspectorKit.hbox(8) - head.add_child(InspectorKit.word("→", Style.COPPER, true)) + head.add_child(InspectorKit.word("→", Style.TRIM, true)) var tn := Style.make_label(_title_of(target.name, to) if target else to + " (missing)", Style.display(), 19, Style.INK) tn.size_flags_horizontal = Control.SIZE_EXPAND_FILL tn.clip_text = true head.add_child(tn) if taken: - head.add_child(_chip("taken last roll", Style.BRASS_DARK, Style.LIT)) + head.add_child(_chip("taken last roll", Style.ACCENT_DARK, Style.LIT)) elif main.is_entry_lit(t.id, e.id): head.add_child(Style.make_label("not taken", Style.body_bold(), 12, Style.MUTED)) v.add_child(head) @@ -671,7 +671,7 @@ func _refresh_otherwise(to: String) -> void: static func _chip(text: String, fg: Color, bg: Color) -> Control: var p := PanelContainer.new() - p.add_theme_stylebox_override("panel", Style.bordered(Style.box(bg, 9, [7, 1, 7, 2]), 1, Style.BRASS)) + p.add_theme_stylebox_override("panel", Style.bordered(Style.box(bg, 9, [7, 1, 7, 2]), 1, Style.ACCENT)) p.add_child(Style.make_label(text, Style.body_bold(), 12, fg)) p.size_flags_vertical = Control.SIZE_SHRINK_CENTER return p diff --git a/ui/inspector_card.gd b/ui/inspector_card.gd index c586de5..4ed6f2a 100644 --- a/ui/inspector_card.gd +++ b/ui/inspector_card.gd @@ -131,7 +131,7 @@ static func _check(insp: Inspector, box: VBoxContainer, t: RollTable, plain: boo var sentence := InspectorKit.note("", Style.INK, 15) sentence.add_theme_font_override("font", Style.body_bold()) var sp := PanelContainer.new() - sp.add_theme_stylebox_override("panel", Style.bordered(Style.box(InspectorKit.TAKEN_BG, 8, [10, 7, 10, 8]), 1, Style.BRASS)) + sp.add_theme_stylebox_override("panel", Style.bordered(Style.box(Style.VALUE_BG, 8, [10, 7, 10, 8]), 1, Style.ACCENT)) sp.add_child(sentence) box.add_child(sp) insp.fields["sentence"] = sentence @@ -424,7 +424,7 @@ static func case_block(insp: Inspector, t: RollTable, e: TableEntry, framed: boo insp.remove_meta("open_case") if framed: var p := PanelContainer.new() - p.add_theme_stylebox_override("panel", Style.bordered(Style.box(InspectorKit.BOX_BG, 8, [10, 8, 10, 9]), 1, Style.RULE)) + p.add_theme_stylebox_override("panel", Style.bordered(Style.box(Style.CARD_SOFT, 8, [10, 8, 10, 9]), 1, Style.RULE)) p.add_child(v) return p return v diff --git a/ui/inspector_kit.gd b/ui/inspector_kit.gd index 61f25bb..e80c1ce 100644 --- a/ui/inspector_kit.gd +++ b/ui/inspector_kit.gd @@ -5,10 +5,6 @@ extends RefCounted ## and the rules for turning what a person types into rule tokens. const FIELD_BG := Color.WHITE -const VAR_BG := Color("#fdf6dc") -const VAR_BORDER := Color("#e3c97a") -const BOX_BG := Color("#f7f5ee") -const TAKEN_BG := Color("#fbf3d6") ## Meta key naming a control inside the inspector, so focus can come back to ## the same field after a rebuild. const KEY := "insp_key" @@ -24,7 +20,7 @@ static func line(text: String, placeholder: String = "", min_w: float = 0.0) -> le.text = text le.placeholder_text = placeholder le.add_theme_stylebox_override("normal", _field_box(Style.RULE)) - le.add_theme_stylebox_override("focus", _field_box(Style.COPPER)) + le.add_theme_stylebox_override("focus", _field_box(Style.TRIM)) le.add_theme_stylebox_override("read_only", _field_box(Style.RULE)) Style.field_colors(le) le.add_theme_font_override("font", Style.body()) @@ -55,7 +51,7 @@ static func text_box(text: String, placeholder: String = "", min_h: float = 70.0 te.wrap_mode = TextEdit.LINE_WRAPPING_BOUNDARY te.scroll_fit_content_height = true te.add_theme_stylebox_override("normal", Style.bordered(Style.box(FIELD_BG, 6, [8, 6, 8, 6]), 1, Style.RULE)) - te.add_theme_stylebox_override("focus", Style.bordered(Style.box(FIELD_BG, 6, [8, 6, 8, 6]), 1, Style.COPPER)) + te.add_theme_stylebox_override("focus", Style.bordered(Style.box(FIELD_BG, 6, [8, 6, 8, 6]), 1, Style.TRIM)) Style.field_colors(te) te.add_theme_color_override("background_color", Color(0, 0, 0, 0)) te.add_theme_font_override("font", Style.body()) @@ -76,10 +72,10 @@ static func code(c: Control) -> Control: static func mark(c: Control, ok: bool) -> void: if c is LineEdit: c.add_theme_stylebox_override("normal", _field_box(Style.RULE if ok else Style.DANGER)) - c.add_theme_stylebox_override("focus", _field_box(Style.COPPER if ok else Style.DANGER)) + c.add_theme_stylebox_override("focus", _field_box(Style.TRIM if ok else Style.DANGER)) elif c is TextEdit: var b := Style.bordered(Style.box(FIELD_BG, 6, [8, 6, 8, 6]), 1, Style.RULE if ok else Style.DANGER) - var f := Style.bordered(Style.box(FIELD_BG, 6, [8, 6, 8, 6]), 1, Style.COPPER if ok else Style.DANGER) + var f := Style.bordered(Style.box(FIELD_BG, 6, [8, 6, 8, 6]), 1, Style.TRIM if ok else Style.DANGER) c.add_theme_stylebox_override("normal", b) c.add_theme_stylebox_override("focus", f) @@ -155,8 +151,8 @@ static func link(text: String, tip: String = "") -> Button: b.tooltip_text = tip b.flat = true var n := Style.box(Color(0, 0, 0, 0), 4, [2, 1, 2, 1]) - var h := Style.box(Color(Style.COPPER, 0.12), 4, [2, 1, 2, 1]) - Style.skin_button(b, n, h, h, Style.COPPER_DARK) + var h := Style.box(Color(Style.TRIM, 0.12), 4, [2, 1, 2, 1]) + Style.skin_button(b, n, h, h, Style.TRIM_DARK) b.add_theme_font_override("font", Style.body_bold()) b.add_theme_font_size_override("font_size", 14) b.add_theme_color_override("font_disabled_color", Style.MUTED) diff --git a/ui/io_menu.gd b/ui/io_menu.gd index 129cba7..c2eb5de 100644 --- a/ui/io_menu.gd +++ b/ui/io_menu.gd @@ -142,7 +142,7 @@ static func import_as_collection(library: LibraryStore, text: String, file_name: static func report_dialog(title: String, result: Dictionary) -> ModalCard: var d := ModalCard.new(title, 540.0) var any := false - for spec in [["errors", "Problems", Style.WARN_INK], ["warnings", "Warnings", Style.COPPER_DARK], + for spec in [["errors", "Problems", Style.WARN_INK], ["warnings", "Warnings", Style.TRIM_DARK], ["guesses", "Guesses made", Style.INK]]: var items: Array = result.get(spec[0], []) if items.is_empty(): diff --git a/ui/main.gd b/ui/main.gd index 520bd5e..14141f2 100644 --- a/ui/main.gd +++ b/ui/main.gd @@ -90,12 +90,18 @@ func _init() -> void: func _ready() -> void: rng.randomize() - theme = Style.app_theme() var args := OS.get_cmdline_user_args() if args.has("--sample") or MainCli._arg_value(args, "--screenshot") != "": _saving_enabled = false if _saving_enabled: _open_library() + if ThemeStore.carry_board != null: + if not _saving_enabled: + data = ThemeStore.carry_board + ThemeStore.carry_board = null + if ThemeStore.current.is_empty(): + ThemeStore.apply(ThemeStore.find(str(state.get_setting(ThemeStore.SETTING, ThemeStore.DEFAULT_ID)) if state else ThemeStore.DEFAULT_ID)) + theme = Style.app_theme() if data == null: data = SampleBoard.create() data.id = "fantasy-loot" diff --git a/ui/main_editing.gd b/ui/main_editing.gd index 6135291..770acc1 100644 --- a/ui/main_editing.gd +++ b/ui/main_editing.gd @@ -321,7 +321,7 @@ func select_in_rect(r: Rect2) -> void: func _build_selection_bar() -> void: _sel_bar = PanelContainer.new() - var sb := Style.box(Style.FELT_DEEP, 10, [14, 7, 8, 7]) + var sb := Style.box(Style.BG_DEEP, 10, [14, 7, 8, 7]) Style.bordered(sb, 1, Color(1, 1, 1, 0.12)) sb.shadow_color = Color(0, 0, 0, 0.4) sb.shadow_size = 14 @@ -330,7 +330,7 @@ func _build_selection_bar() -> void: var h := HBoxContainer.new() h.add_theme_constant_override("separation", 8) _sel_bar.add_child(h) - _sel_label = Style.make_label("", Style.body_bold(), 15, Style.ON_FELT) + _sel_label = Style.make_label("", Style.body_bold(), 15, Style.ON_BG) _sel_label.size_flags_vertical = Control.SIZE_SHRINK_CENTER h.add_child(_sel_label) var grp := Style.bar_button("Group", true) diff --git a/ui/main_history.gd b/ui/main_history.gd index 4f0eb46..872acf1 100644 --- a/ui/main_history.gd +++ b/ui/main_history.gd @@ -298,14 +298,14 @@ func _make_history_buttons(tools: HBoxContainer) -> void: if sb: sb.content_margin_left = 26 (b as Button).focus_mode = Control.FOCUS_NONE - (b as Button).add_theme_color_override("font_disabled_color", Color(Style.ON_FELT, 0.35)) + (b as Button).add_theme_color_override("font_disabled_color", Color(Style.ON_BG, 0.35)) tools.add_child(b) ## A curved arrow, pointing left (undo) or right (redo). func _draw_turn_arrow(c: Control, right: bool) -> void: var b := c.get_parent() as Button - var col := Style.ON_FELT if b == null or not b.disabled else Color(Style.ON_FELT, 0.35) + var col := Style.ON_BG if b == null or not b.disabled else Color(Style.ON_BG, 0.35) var s := -1.0 if right else 1.0 var o := Vector2(8, 9) c.draw_arc(o, 5.0, -PI * 0.95 if not right else -PI * 0.05, PI * 0.5 if not right else -PI * 1.5, 16, col, 1.8, true) diff --git a/ui/main_top_bar.gd b/ui/main_top_bar.gd index 8674958..6cc29c9 100644 --- a/ui/main_top_bar.gd +++ b/ui/main_top_bar.gd @@ -32,10 +32,7 @@ func _init(p_main: Main) -> void: func _build_top_bar() -> Control: var bar := PanelContainer.new() - var sb := Style.box(Style.FELT_DEEP, 0, [16, 10, 16, 10]) - sb.border_width_bottom = 1 - sb.border_color = Color(1, 1, 1, 0.07) - bar.add_theme_stylebox_override("panel", sb) + bar.add_theme_stylebox_override("panel", Style.panel_box([16, 10, 16, 10])) var h := HBoxContainer.new() h.add_theme_constant_override("separation", 10) bar.add_child(h) @@ -45,9 +42,9 @@ func _build_top_bar() -> Control: var mark := Control.new() mark.custom_minimum_size = Vector2(20, 24) mark.size_flags_vertical = Control.SIZE_SHRINK_CENTER - mark.draw.connect(func() -> void: Icons.draw_tower(mark, Vector2(0, 0), 20.0 / 22.0, Style.ON_FELT, Style.BRASS)) + mark.draw.connect(func() -> void: Icons.draw_tower(mark, Vector2(0, 0), 20.0 / 22.0, Style.ON_BG, Style.ACCENT)) brand.add_child(mark) - var title := Style.make_label("TableTower", Style.display(), 23, Style.ON_FELT) + var title := Style.make_label("TableTower", Style.display(), 23, Style.ON_BG) title.size_flags_vertical = Control.SIZE_SHRINK_CENTER brand.add_child(title) h.add_child(brand) @@ -73,7 +70,7 @@ func _build_top_bar() -> Control: _switcher.setup(m) h.add_child(_switcher) - _hint = Style.make_label(Main.HINTS[m.mode], Style.body(), 15, Style.ON_FELT_MUTED) + _hint = Style.make_label(Main.HINTS[m.mode], Style.body(), 15, Style.ON_BG_MUTED) _hint.size_flags_horizontal = Control.SIZE_EXPAND_FILL _hint.size_flags_vertical = Control.SIZE_SHRINK_CENTER _hint.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS @@ -127,7 +124,7 @@ func _seg_button(text: String, group: ButtonGroup) -> Button: var normal := Style.box(Color(0, 0, 0, 0), 7, [16, 6, 16, 6]) var hover := Style.box(Color(1, 1, 1, 0.06), 7, [16, 6, 16, 6]) var pressed := Style.box(Style.CARD, 7, [16, 6, 16, 6]) - Style.skin_button(b, normal, hover, pressed, Style.ON_FELT_MUTED, Style.ON_FELT, Style.INK) + Style.skin_button(b, normal, hover, pressed, Style.ON_BG_MUTED, Style.ON_BG, Style.INK) return b @@ -136,8 +133,8 @@ func _make_search_button() -> Button: b.custom_minimum_size = Vector2(38, 0) b.tooltip_text = "Find a card by its name, results, prompt, variables or group (Ctrl+F)" _bar_icon(b, func(c: Control) -> void: - c.draw_arc(Vector2(6.5, 6.5), 5.0, 0.0, TAU, 24, Style.ON_FELT, 1.8, true) - c.draw_line(Vector2(10.3, 10.3), Vector2(14.5, 14.5), Style.ON_FELT, 2.4, true)) + c.draw_arc(Vector2(6.5, 6.5), 5.0, 0.0, TAU, 24, Style.ON_BG, 1.8, true) + c.draw_line(Vector2(10.3, 10.3), Vector2(14.5, 14.5), Style.ON_BG, 2.4, true)) b.pressed.connect(m.nav.toggle_search) return b @@ -179,9 +176,9 @@ func _build_toast() -> void: _toast_undo.text = "Undo" _toast_undo.add_theme_font_override("font", Style.body_bold()) _toast_undo.add_theme_font_size_override("font_size", 15) - var un := Style.box(Style.FELT, 7, [12, 5, 12, 5]) - var uh := Style.box(Style.FELT_HOVER, 7, [12, 5, 12, 5]) - Style.skin_button(_toast_undo, un, uh, uh, Style.BRASS) + var un := Style.box(Style.BG, 7, [12, 5, 12, 5]) + var uh := Style.box(Style.BG_HOVER, 7, [12, 5, 12, 5]) + Style.skin_button(_toast_undo, un, uh, uh, Style.ACCENT) _toast_undo.pressed.connect(_undo) _toast_undo.focus_mode = Control.FOCUS_NONE h.add_child(_toast_undo) diff --git a/ui/minimap.gd b/ui/minimap.gd index 807f1f1..bce201d 100644 --- a/ui/minimap.gd +++ b/ui/minimap.gd @@ -28,7 +28,7 @@ func setup(p_board: BoardView) -> void: mouse_filter = MOUSE_FILTER_STOP mouse_default_cursor_shape = CURSOR_POINTING_HAND tooltip_text = "Overview: click or drag to move around (M)" - _bg = Style.bordered(Style.box(Color(Style.FELT_DEEP, 0.92), 10), 1, Color(1, 1, 1, 0.16)) + _bg = Style.bordered(Style.box(Color(Style.BG_DEEP, 0.92), 10), 1, Color(1, 1, 1, 0.16)) _bg.shadow_color = Color(0, 0, 0, 0.35) _bg.shadow_size = 12 _bg.shadow_offset = Vector2(0, 4) @@ -117,7 +117,7 @@ func _draw() -> void: var c := main.card_for(t.id) var r := Rect2(c.position, c.size) if c else Rect2(t.position, Vector2(TableCard.WIDTH, 120)) var lit := lit_tables.has(t.id) - _block(r, Style.BRASS if lit else Color(Style.CARD, 0.85), Color(0, 0, 0, 0), inner) + _block(r, Style.ACCENT if lit else Color(Style.CARD, 0.85), Color(0, 0, 0, 0), inner) for g in main.data.groups: if g.collapsed: var n := main.group_node(g.id) @@ -127,11 +127,11 @@ func _draw() -> void: if lit_tables.has(tid): lit = true break - _block(r, Style.BRASS if lit else Color("#cfc6ae"), Style.COPPER_DARK, inner) + _block(r, Style.ACCENT if lit else Style.CARD_SHADE, Style.TRIM_DARK, inner) var v := view_rect_on_map().intersection(inner) if v.size.x > 0.0 and v.size.y > 0.0: - draw_rect(v, Color(Style.ON_FELT, 0.08)) - draw_rect(v, Style.ON_FELT, false, 1.5) + draw_rect(v, Color(Style.ON_BG, 0.08)) + draw_rect(v, Style.ON_BG, false, 1.5) ## One block on the map, at least 2 px so tiny cards still show. diff --git a/ui/modal_card.gd b/ui/modal_card.gd index a4a3045..8408167 100644 --- a/ui/modal_card.gd +++ b/ui/modal_card.gd @@ -109,8 +109,8 @@ static func make_button(text: String, kind: String = "plain") -> Button: var m := [16, 7, 16, 7] match kind: "primary": - Style.skin_button(b, Style.box(Style.FELT, 8, m), Style.box(Style.FELT_HOVER, 8, m), - Style.box(Style.FELT_HOVER, 8, m), Style.BRASS) + Style.skin_button(b, Style.box(Style.BG, 8, m), Style.box(Style.BG_HOVER, 8, m), + Style.box(Style.BG_HOVER, 8, m), Style.ACCENT) "danger": Style.skin_button(b, Style.box(Style.DANGER_INK, 8, m), Style.box(Style.DANGER_INK.lightened(0.12), 8, m), Style.box(Style.DANGER_INK.lightened(0.12), 8, m), Color.WHITE) @@ -162,8 +162,8 @@ static func segmented(options: Array, selected: int, on_change: Callable) -> Pan b.add_theme_font_size_override("font_size", 15) var normal := Style.box(Color(0, 0, 0, 0), 7, [14, 5, 14, 5]) var hover := Style.box(Color(0, 0, 0, 0.06), 7, [14, 5, 14, 5]) - var pressed := Style.box(Style.FELT, 7, [14, 5, 14, 5]) - Style.skin_button(b, normal, hover, pressed, Style.MUTED, Style.INK, Style.BRASS) + var pressed := Style.box(Style.BG, 7, [14, 5, 14, 5]) + Style.skin_button(b, normal, hover, pressed, Style.MUTED, Style.INK, Style.ACCENT) b.set_pressed_no_signal(i == selected) b.pressed.connect(on_change.bind(i)) row.add_child(b) @@ -172,7 +172,7 @@ static func segmented(options: Array, selected: int, on_change: Callable) -> Pan static func style_line_edit(le: LineEdit) -> void: le.add_theme_stylebox_override("normal", Style.bordered(Style.box(Color.WHITE, 7, [10, 6, 10, 6]), 1, Style.DASH)) - le.add_theme_stylebox_override("focus", Style.bordered(Style.box(Color.WHITE, 7, [10, 6, 10, 6]), 1, Style.COPPER)) + le.add_theme_stylebox_override("focus", Style.bordered(Style.box(Color.WHITE, 7, [10, 6, 10, 6]), 1, Style.TRIM)) Style.field_colors(le) le.add_theme_constant_override("minimum_character_width", 4) le.size_flags_horizontal = SIZE_EXPAND_FILL @@ -180,7 +180,7 @@ static func style_line_edit(le: LineEdit) -> void: static func style_text_edit(te: TextEdit) -> void: te.add_theme_stylebox_override("normal", Style.bordered(Style.box(Color.WHITE, 7, [10, 7, 10, 7]), 1, Style.DASH)) - te.add_theme_stylebox_override("focus", Style.bordered(Style.box(Color.WHITE, 7, [10, 7, 10, 7]), 1, Style.COPPER)) + te.add_theme_stylebox_override("focus", Style.bordered(Style.box(Color.WHITE, 7, [10, 7, 10, 7]), 1, Style.TRIM)) Style.field_colors(te) te.add_theme_color_override("background_color", Color(0, 0, 0, 0)) @@ -204,7 +204,7 @@ static func style_popup(pm: PopupMenu) -> void: ## A top-bar styled MenuButton (same look as Style.bar_button). static func bar_menu_button(text: String) -> MenuButton: var mb := Style.menu_button(text) - mb.add_theme_color_override("font_disabled_color", Style.ON_FELT_MUTED) + mb.add_theme_color_override("font_disabled_color", Style.ON_BG_MUTED) style_popup(mb.get_popup()) return mb diff --git a/ui/panel_splitter.gd b/ui/panel_splitter.gd index 7238371..8d82f5d 100644 --- a/ui/panel_splitter.gd +++ b/ui/panel_splitter.gd @@ -105,9 +105,9 @@ func _axis(p: Vector2) -> float: func _draw() -> void: - draw_rect(Rect2(Vector2.ZERO, size), Style.FELT_DEEP) + draw_rect(Rect2(Vector2.ZERO, size), Style.PANEL) var lit := _hover or _dragging - var c := Style.BRASS if lit else Color(1, 1, 1, 0.18) + var c := Style.ACCENT if lit else Color(1, 1, 1, 0.18) var mid := size / 2.0 var r := Rect2(mid - Vector2(GRIP / 2.0, 1.5), Vector2(GRIP, 3)) if vertical \ else Rect2(mid - Vector2(1.5, GRIP / 2.0), Vector2(3, GRIP)) diff --git a/ui/pipe_layer.gd b/ui/pipe_layer.gd index 1e55663..c6a00ac 100644 --- a/ui/pipe_layer.gd +++ b/ui/pipe_layer.gd @@ -51,9 +51,9 @@ func _init() -> void: # Controls only draw inside their own rect, so cover the whole world. size = Vector2(BoardView.WORLD_SIZE, BoardView.WORLD_SIZE) _label_box = Style.box(Style.CARD, 7, [6, 1, 6, 2]) - Style.bordered(_label_box, 1, Style.COPPER_DARK) + Style.bordered(_label_box, 1, Style.THREAD_DARK) _lit_label_box = Style.box(Style.LIT, 7, [6, 1, 6, 2]) - Style.bordered(_lit_label_box, 1, Style.BRASS_DARK) + Style.bordered(_lit_label_box, 1, Style.ACCENT_DARK) ## Redraws only when something it draws changed: the board's geometry @@ -108,10 +108,10 @@ func _coarse(rid: RID, pts: PackedVector2Array, color: Color, width: float) -> v func _batch_pipe(pts: PackedVector2Array, hovered: bool) -> void: var rid := _batch_item() if _far: - _coarse(rid, pts, Style.COPPER, 10.0) + _coarse(rid, pts, Style.THREAD, 10.0) return - _line(rid, pts, Style.COPPER_DARK, 11.0) - _line(rid, pts, Style.COPPER.lightened(0.35) if hovered else Style.COPPER, 6.0) + _line(rid, pts, Style.THREAD_DARK, 11.0) + _line(rid, pts, Style.THREAD.lightened(0.35) if hovered else Style.THREAD, 6.0) RenderingServer.canvas_item_add_set_transform(rid, Transform2D(0.0, Vector2(0, -1.5))) _line(rid, pts, Color(1.0, 0.886, 0.745, 0.4), 1.5) RenderingServer.canvas_item_add_set_transform(rid, Transform2D.IDENTITY) @@ -121,23 +121,23 @@ func _batch_pipe(pts: PackedVector2Array, hovered: bool) -> void: func _batch_bundle(pts: PackedVector2Array) -> void: var rid := _batch_item() if _far: - _coarse(rid, pts, Color(Style.COPPER, 0.6), 6.0) + _coarse(rid, pts, Color(Style.THREAD, 0.6), 6.0) return - _line(rid, pts, Color(Style.COPPER_DARK, 0.55), 6.0) - _line(rid, pts, Color(Style.COPPER, 0.6), 3.0) + _line(rid, pts, Color(Style.THREAD_DARK, 0.55), 6.0) + _line(rid, pts, Color(Style.THREAD, 0.6), 3.0) ## An unlit reference pipe (as _draw_ref draws it). func _batch_ref(pts: PackedVector2Array) -> void: var rid := _batch_item() if _far: - _coarse(rid, pts, Color(Style.COPPER, 0.7), 4.0) + _coarse(rid, pts, Color(Style.THREAD, 0.7), 4.0) return var dashes := _dashes(pts, 12.0, 7.0) for d in dashes: - _line(rid, d, Style.COPPER_DARK, 6.0) + _line(rid, d, Style.THREAD_DARK, 6.0) for d in dashes: - _line(rid, d, Style.COPPER, 3.0) + _line(rid, d, Style.THREAD, 3.0) func _notification(what: int) -> void: @@ -247,8 +247,8 @@ func _draw() -> void: if pulse_key != "" and _paths.has(pulse_key): var p := point_along(_paths[pulse_key], pulse_t) var r := 0.75 if Roller.is_ref_key(pulse_key) else 1.0 - draw_circle(p, 13.0 * r, Color(Style.BRASS, 0.3)) - draw_circle(p, 9.0 * r, Color(Style.BRASS, 0.5)) + draw_circle(p, 13.0 * r, Color(Style.ACCENT, 0.3)) + draw_circle(p, 9.0 * r, Color(Style.ACCENT, 0.5)) draw_circle(p, 7.0 * r, Style.PULSE) @@ -299,7 +299,7 @@ func _draw_tag(pts: PackedVector2Array, text: String, lit: bool = false, placed: break placed.append(r) draw_style_box(_lit_label_box if lit else _label_box, r) - draw_string(font, Vector2(r.position.x + 6.0, r.position.y + 14.0), text, HORIZONTAL_ALIGNMENT_LEFT, -1, fs, Style.INK if lit else Style.COPPER_DARK) + draw_string(font, Vector2(r.position.x + 6.0, r.position.y + 14.0), text, HORIZONTAL_ALIGNMENT_LEFT, -1, fs, Style.INK if lit else Style.THREAD_DARK) ## The mark of a conditional pipe: a small diamond near its source end @@ -311,21 +311,21 @@ func _draw_diamond(pts: PackedVector2Array, lit: bool, otherwise: bool) -> void: var c := point_along(pts, 0.2) var r := 7.5 var poly := PackedVector2Array([c + Vector2(0, -r), c + Vector2(r, 0), c + Vector2(0, r), c + Vector2(-r, 0)]) - var edge := Style.BRASS_DARK if lit else Style.COPPER_DARK + var edge := Style.ACCENT_DARK if lit else Style.THREAD_DARK draw_colored_polygon(poly, edge) var inner_r := r - 2.5 var inner := PackedVector2Array([c + Vector2(0, -inner_r), c + Vector2(inner_r, 0), c + Vector2(0, inner_r), c + Vector2(-inner_r, 0)]) - var fill := Style.CARD if otherwise else (Style.BRASS if lit else Style.COPPER.lightened(0.25)) + var fill := Style.CARD if otherwise else (Style.ACCENT if lit else Style.THREAD.lightened(0.25)) draw_colored_polygon(inner, fill) func _draw_pipe(pts: PackedVector2Array, lit: bool, hovered: bool) -> void: if lit: - draw_polyline(pts, Color(Style.BRASS, 0.18), 20.0, true) - draw_polyline(pts, Style.BRASS_DARK if lit else Style.COPPER_DARK, 11.0, true) - var inner := Style.BRASS if lit else Style.COPPER + draw_polyline(pts, Color(Style.ACCENT, 0.18), 20.0, true) + draw_polyline(pts, Style.ACCENT_DARK if lit else Style.THREAD_DARK, 11.0, true) + var inner := Style.ACCENT if lit else Style.THREAD if hovered: - inner = Style.COPPER.lightened(0.35) + inner = Style.THREAD.lightened(0.35) draw_polyline(pts, inner, 6.0, true) draw_set_transform(Vector2(0, -1.5)) draw_polyline(pts, Color(1.0, 0.886, 0.745, 0.4), 1.5, true) @@ -335,19 +335,19 @@ func _draw_pipe(pts: PackedVector2Array, lit: bool, hovered: bool) -> void: ## An unlit pipe to or from a collapsed group: thinner and quieter, so the ## lit path of the last roll stands out on a big board. func _draw_bundle(pts: PackedVector2Array) -> void: - draw_polyline(pts, Color(Style.COPPER_DARK, 0.55), 6.0, true) - draw_polyline(pts, Color(Style.COPPER, 0.6), 3.0, true) + draw_polyline(pts, Color(Style.THREAD_DARK, 0.55), 6.0, true) + draw_polyline(pts, Color(Style.THREAD, 0.6), 3.0, true) ## A reference pipe: thinner, in dashes. func _draw_ref(pts: PackedVector2Array, lit: bool) -> void: if lit: - draw_polyline(pts, Color(Style.BRASS, 0.14), 12.0, true) + draw_polyline(pts, Color(Style.ACCENT, 0.14), 12.0, true) var dashes := _dashes(pts, 12.0, 7.0) for d in dashes: - draw_polyline(d, Style.BRASS_DARK if lit else Style.COPPER_DARK, 6.0, true) + draw_polyline(d, Style.ACCENT_DARK if lit else Style.THREAD_DARK, 6.0, true) for d in dashes: - draw_polyline(d, Style.BRASS if lit else Style.COPPER, 3.0, true) + draw_polyline(d, Style.ACCENT if lit else Style.THREAD, 3.0, true) ## Splits a polyline into dashes `on` long with gaps `off` long. diff --git a/ui/pipe_popover.gd b/ui/pipe_popover.gd index e70dda3..be15650 100644 --- a/ui/pipe_popover.gd +++ b/ui/pipe_popover.gd @@ -29,7 +29,7 @@ func setup(p_main: Main) -> void: theme = Style.card_theme() var sb := Style.box(Style.CARD, 9, [14, 11, 14, 12]) sb.border_width_top = 3 - sb.border_color = Style.COPPER + sb.border_color = Style.THREAD add_theme_stylebox_override("panel", sb) popup_hide.connect(func() -> void: _commit_save() @@ -46,7 +46,7 @@ func setup(p_main: Main) -> void: v.add_child(_title) var field_ok := Style.bordered(Style.box(Color.WHITE, 5, [7, 3, 7, 3]), 1, Style.RULE) - var field_focus := Style.bordered(Style.box(Color.WHITE, 5, [7, 3, 7, 3]), 1, Style.COPPER) + var field_focus := Style.bordered(Style.box(Color.WHITE, 5, [7, 3, 7, 3]), 1, Style.THREAD) _save_ok = field_ok _save_bad = Style.bordered(Style.box(Color.WHITE, 5, [7, 3, 7, 3]), 1, Style.DANGER) _field_focus = field_focus @@ -199,7 +199,7 @@ func open(pipe_key: String, at: Vector2) -> void: return key = pipe_key var target := main.data.get_table(_to) - _title.text = "%s [color=#%s]→[/color] [b]%s[/b]" % [RichText.preview(_entry.text, main.data), Style.COPPER.to_html(false), RichText.plain(Formatter.strip_tags(target.name)) if target else _to] + _title.text = "%s [color=#%s]→[/color] [b]%s[/b]" % [RichText.preview(_entry.text, main.data), Style.THREAD.to_html(false), RichText.plain(Formatter.strip_tags(target.name)) if target else _to] _count.text = _entry.count_text(_to) _count.add_theme_stylebox_override("normal", _save_ok) _count_msg.hide() diff --git a/ui/port_layer.gd b/ui/port_layer.gd index 2559c7e..65d087d 100644 --- a/ui/port_layer.gd +++ b/ui/port_layer.gd @@ -74,7 +74,7 @@ func _draw() -> void: continue # Variable cards are never rolled, so nothing pipes into them. if t.kind != RollTable.KIND_VARIABLE: - _port(card.inlet_point(), Style.COPPER, Style.COPPER_DARK, 1.0) + _port(card.inlet_point(), Style.THREAD, Style.THREAD_DARK, 1.0) for e in t.entries: if not card.rows.has(e.id): continue @@ -85,14 +85,14 @@ func _draw() -> void: if not build and not on: continue var pos: Vector2 = a["pos"] - var fill := Style.COPPER if on else Style.CARD - var ring := Style.COPPER_DARK + var fill := Style.THREAD if on else Style.CARD + var ring := Style.THREAD_DARK var s := 1.0 if on and main.is_entry_lit(t.id, e.id): - fill = Style.BRASS - ring = Style.BRASS_DARK + fill = Style.ACCENT + ring = Style.ACCENT_DARK if build and pos.distance_to(mouse) <= GRAB_RADIUS and not _linking: - fill = Style.BRASS + fill = Style.ACCENT s = 1.2 _port(pos, fill, ring, s) if build: @@ -101,19 +101,19 @@ func _draw() -> void: var m := card.anchor_for("") var on_hidden := card.hidden_has_pipes() if not m.is_empty() and (on_hidden or build): - _port(m["pos"], Style.COPPER if on_hidden else Style.CARD, Style.COPPER_DARK, 1.0) + _port(m["pos"], Style.THREAD if on_hidden else Style.CARD, Style.THREAD_DARK, 1.0) # Collapsed groups: an inlet, and an outlet wherever member pipes leave. for g in main.data.groups: if g.collapsed: var gn := main.group_node(g.id) if gn and gn.is_inside_tree(): - _port(gn.inlet_point(), Style.COPPER, Style.COPPER_DARK, 1.0) + _port(gn.inlet_point(), Style.THREAD, Style.THREAD_DARK, 1.0) var gp: Dictionary = main.board.pipes.group_ports for p: Vector2i in gp: if gp[p]: - _port(Vector2(p), Style.BRASS, Style.BRASS_DARK, 1.0) + _port(Vector2(p), Style.ACCENT, Style.ACCENT_DARK, 1.0) else: - _port(Vector2(p), Style.COPPER, Style.COPPER_DARK, 1.0) + _port(Vector2(p), Style.THREAD, Style.THREAD_DARK, 1.0) if _linking: _draw_ghost(PipeLayer.curve(_ghost_from, _ghost_to)) @@ -131,7 +131,7 @@ func _draw_ghost(pts: PackedVector2Array) -> void: var seg := a.distance_to(b) var d := carry while d < seg: - draw_circle(a.lerp(b, d / seg), 2.5, Style.BRASS) + draw_circle(a.lerp(b, d / seg), 2.5, Style.ACCENT) d += 11.0 carry = d - seg diff --git a/ui/result_tray.gd b/ui/result_tray.gd index 96a5463..719ec2d 100644 --- a/ui/result_tray.gd +++ b/ui/result_tray.gd @@ -68,10 +68,7 @@ var height := HEIGHT func setup(p_main: Main) -> void: main = p_main - var sb := Style.box(Style.FELT_DEEP, 0, [16, 14, 16, 16]) - sb.border_width_top = 1 - sb.border_color = Color(1, 1, 1, 0.08) - add_theme_stylebox_override("panel", sb) + add_theme_stylebox_override("panel", Style.panel_box([16, 14, 16, 16])) var h := HBoxContainer.new() h.add_theme_constant_override("separation", 28) @@ -85,7 +82,7 @@ func setup(p_main: Main) -> void: var head := HBoxContainer.new() head.add_theme_constant_override("separation", 12) now.add_child(head) - _title = Style.make_label("RESULT", Style.caps(), 12, Style.ON_FELT_MUTED) + _title = Style.make_label("RESULT", Style.caps(), 12, Style.ON_BG_MUTED) _title.size_flags_vertical = SIZE_SHRINK_CENTER head.add_child(_title) _again = Style.bar_button("Roll again") @@ -108,7 +105,7 @@ func setup(p_main: Main) -> void: # A chain that reached a sheet card leads with the rendered sheet. _headline = PanelContainer.new() var hsb := Style.box(Style.CARD, 10, [16, 10, 16, 12]) - Style.bordered(hsb, 2, Style.BRASS) + Style.bordered(hsb, 2, Style.ACCENT) _headline.add_theme_stylebox_override("panel", hsb) _headline.size_flags_horizontal = SIZE_SHRINK_BEGIN var hv := VBoxContainer.new() @@ -146,7 +143,7 @@ func setup(p_main: Main) -> void: _flow.minimum_size_changed.connect(_fit_scroll.call_deferred) _scroll.add_child(_flow) body_row.add_child(_scroll) - _empty = Style.make_label("Click a die on any table to roll.", Style.body(), 16, Style.ON_FELT_MUTED) + _empty = Style.make_label("Click a die on any table to roll.", Style.body(), 16, Style.ON_BG_MUTED) now.add_child(_empty) var right := VBoxContainer.new() @@ -191,8 +188,8 @@ func _tab(text: String) -> Button: var n := Style.box(Color(0, 0, 0, 0), 0, [0, 0, 0, 3]) var on := Style.box(Color(0, 0, 0, 0), 0, [0, 0, 0, 1]) on.border_width_bottom = 2 - on.border_color = Style.BRASS - Style.skin_button(b, n, n, on, Style.ON_FELT_MUTED, Style.ON_FELT, Style.ON_FELT) + on.border_color = Style.ACCENT + Style.skin_button(b, n, n, on, Style.ON_BG_MUTED, Style.ON_BG, Style.ON_BG) b.add_theme_stylebox_override("focus", Style.box(Color(0, 0, 0, 0))) return b @@ -214,7 +211,7 @@ func _make_copy_menu() -> MenuButton: m.flat = false var normal := Style.bordered(Style.box(Color(1, 1, 1, 0.04), 8, [12, 6, 12, 6]), 1, Color(1, 1, 1, 0.16)) var hover := Style.bordered(Style.box(Color(1, 1, 1, 0.1), 8, [12, 6, 12, 6]), 1, Color(1, 1, 1, 0.16)) - Style.skin_button(m, normal, hover, hover, Style.ON_FELT) + Style.skin_button(m, normal, hover, hover, Style.ON_BG) m.add_theme_font_size_override("font_size", 15) var pm := m.get_popup() pm.add_item("Copy as text", COPY_TEXT) diff --git a/ui/rich_text.gd b/ui/rich_text.gd index 3eb5393..9746f71 100644 --- a/ui/rich_text.gd +++ b/ui/rich_text.gd @@ -14,14 +14,6 @@ static var _var_re: RegEx static var _count_re: RegEx static var _list_re: RegEx -## Colours for marker text, on cards (light) and on the felt (dark). -const REF_INK := Color("#1d6656") -const REF_BG := Color("#d6e9e2") -const VAR_INK := Color("#7d5a0c") -const REF_INK_FELT := Color("#9fdcc9") -const VAR_INK_FELT := Color("#f3c450") -const BAD_INK_FELT := Color("#ffb1a3") - ## A RichTextLabel that sizes itself to its text like a Label. ## `zoomable` picks the card (MSDF) fonts that stay sharp on the zoomed board. @@ -74,7 +66,7 @@ static func hook_hover(l: RichTextLabel, main: Main) -> void: ## Small muted ⓘ appended to text that has hover details. static func info_mark(on_felt: bool = false) -> String: - var c := Style.ON_FELT_MUTED if on_felt else Color("#9a9483") + var c := Style.ON_BG_MUTED if on_felt else Style.FAINT return " [font_size=12][color=#%s]%s[/color][/font_size]" % [c.to_html(false), INFO_MARK] @@ -119,7 +111,7 @@ static func preview(text: String, board: TowerBoard) -> String: if close >= 0 and (nl < 0 or close < nl): var src := text.substr(i + 2, close - i - 2).strip_edges() var err := Expr.check(src) - var ink := Style.DANGER_INK if err != "" else VAR_INK + var ink := Style.DANGER_INK if err != "" else Style.VALUE_INK out += "[url=%s][color=#%s]{= %s}[/color][/url]" % ["error:expr" if err != "" else "expr:" + plain(src).replace("]", ""), ink.to_html(false), plain(src)] i = close + 1 @@ -127,14 +119,14 @@ static func preview(text: String, board: TowerBoard) -> String: # {@prefix_*}: a list of every variable with the prefix. var lm := _lre().search(text, i) if lm != null and lm.get_start() == i: - out += "[url=var:@%s*][color=#%s]{@%s*}[/color][/url]" % [lm.get_string(1), VAR_INK.to_html(false), lm.get_string(1)] + out += "[url=var:@%s*][color=#%s]{@%s*}[/color][/url]" % [lm.get_string(1), Style.VALUE_INK.to_html(false), lm.get_string(1)] i = lm.get_end() continue var m := _vre().search(text, i) if m != null and m.get_start() == i: var vname := m.get_string(1) var shown := "{%s}" % vname - out += "[url=var:%s][color=#%s]%s[/color][/url]" % [vname, VAR_INK.to_html(false), shown] + out += "[url=var:%s][color=#%s]%s[/color][/url]" % [vname, Style.VALUE_INK.to_html(false), shown] var from := m.get_string(2).strip_edges() if from != "": var id := Roller.resolve(board, from) @@ -169,7 +161,7 @@ static func _ref_chip(body: String, board: TowerBoard) -> String: var label_text := count + plain(Formatter.strip_tags(t.name)) if save != "": label_text += " → " + plain(save) - return "[url=table:%s][bgcolor=#%s][color=#%s] %s [/color][/bgcolor][/url]" % [id, REF_BG.to_html(false), REF_INK.to_html(false), label_text] + return "[url=table:%s][bgcolor=#%s][color=#%s] %s [/color][/bgcolor][/url]" % [id, Style.REF_BG.to_html(false), Style.REF_INK.to_html(false), label_text] ## Colours the internal markers of rolled text: table rolls in teal, variables in @@ -198,11 +190,11 @@ static func decorate(bbcode: String, on_felt: bool = false) -> String: static func _marker_color(meta: String, on_felt: bool) -> String: if meta.begins_with("table:"): - return (REF_INK_FELT if on_felt else REF_INK).to_html(false) + return (Style.REF_INK_ON_BG if on_felt else Style.REF_INK).to_html(false) if meta.begins_with("var:"): - return (VAR_INK_FELT if on_felt else VAR_INK).to_html(false) + return (Style.VALUE_INK_ON_BG if on_felt else Style.VALUE_INK).to_html(false) if meta.begins_with("missing:") or meta.begins_with("unset:") or meta.begins_with("deep:") or meta.begins_with("error:"): - return (BAD_INK_FELT if on_felt else Style.DANGER_INK).to_html(false) + return (Style.BAD_INK_ON_BG if on_felt else Style.DANGER_INK).to_html(false) return "" diff --git a/ui/search_panel.gd b/ui/search_panel.gd index 75e317d..9a56995 100644 --- a/ui/search_panel.gd +++ b/ui/search_panel.gd @@ -43,7 +43,7 @@ func setup(p_main: Main) -> void: custom_minimum_size = Vector2(WIDTH, 0) _row_normal = Style.box(Color(0, 0, 0, 0), 7, [10, 6, 10, 7]) _row_hover = Style.box(Style.HOVER_ROW, 7, [10, 6, 10, 7]) - _row_selected = Style.bordered(Style.box(Style.LIT, 7, [10, 6, 10, 7]), 1, Color(Style.BRASS_DARK, 0.35)) + _row_selected = Style.bordered(Style.box(Style.LIT, 7, [10, 6, 10, 7]), 1, Color(Style.ACCENT_DARK, 0.35)) var col := VBoxContainer.new() col.add_theme_constant_override("separation", 8) @@ -53,7 +53,7 @@ func setup(p_main: Main) -> void: field.add_theme_font_override("font", Style.body()) field.add_theme_font_size_override("font_size", 16) field.add_theme_stylebox_override("normal", Style.bordered(Style.box(Color.WHITE, 7, [10, 6, 10, 6]), 1, Style.RULE)) - field.add_theme_stylebox_override("focus", Style.bordered(Style.box(Color.WHITE, 7, [10, 6, 10, 6]), 2, Style.COPPER)) + field.add_theme_stylebox_override("focus", Style.bordered(Style.box(Color.WHITE, 7, [10, 6, 10, 6]), 2, Style.TRIM)) field.clear_button_enabled = true field.text_changed.connect(func(_t: String) -> void: refresh()) field.gui_input.connect(_on_field_input) @@ -155,7 +155,7 @@ func _make_row(r: Dictionary, i: int) -> PanelContainer: Style.body_bold(), 16) title.size_flags_horizontal = SIZE_EXPAND_FILL top.add_child(title) - var kind := Style.make_label(str(r["kind"]).to_upper(), Style.caps(), 10, Style.COPPER_DARK) + var kind := Style.make_label(str(r["kind"]).to_upper(), Style.caps(), 10, Style.TRIM_DARK) kind.size_flags_vertical = SIZE_SHRINK_CENTER kind.mouse_filter = MOUSE_FILTER_IGNORE top.add_child(kind) @@ -222,7 +222,7 @@ static func _esc(s: String) -> String: static func highlight(text: String, from: int, length: int) -> String: if from < 0 or length <= 0 or from >= text.length(): return _esc(text) - return "%s[bgcolor=#%s][b]%s[/b][/bgcolor]%s" % [_esc(text.substr(0, from)), Style.BRASS.to_html(false), + return "%s[bgcolor=#%s][b]%s[/b][/bgcolor]%s" % [_esc(text.substr(0, from)), Style.ACCENT.to_html(false), _esc(text.substr(from, length)), _esc(text.substr(from + length))] diff --git a/ui/style.gd b/ui/style.gd index 6dd8cd2..c37cdb6 100644 --- a/ui/style.gd +++ b/ui/style.gd @@ -1,34 +1,67 @@ class_name Style extends RefCounted -## Palette, fonts and stylebox helpers for the felt-board look. +## Palette tokens, fonts and stylebox helpers. A theme (ThemeStore) sets the tokens. -const FELT := Color("#1f4a39") -const FELT_DEEP := Color("#12301f") -const FELT_HOVER := Color("#276048") -const CARD := Color("#efece2") -const INK := Color("#1c2520") -const MUTED := Color("#69726b") -const RULE := Color("#d8d3c3") -const COPPER := Color("#b8703a") -const COPPER_DARK := Color("#4f2b12") -const BRASS := Color("#f3c450") -const BRASS_DARK := Color("#6e5410") -const LIT := Color("#f8e4a2") -const FLICK := Color(0.953, 0.769, 0.314, 0.35) -const HOVER_ROW := Color("#e9e4d6") +# Colour tokens. They're static vars, not consts, so a theme can replace them at +# runtime (ThemeStore.apply). The values here are the built-in fallback ("Felt"); +# the token list with editor labels lives in ThemeStore.TOKENS. +static var BG := Color("#1f4a39") +static var BG_DEEP := Color("#12301f") +static var BG_HOVER := Color("#276048") +## The top bar, tray and other docked panels. +static var PANEL := Color("#12301f") +static var ON_BG := Color("#e9efe9") +static var ON_BG_MUTED := Color("#a8bdb1") +static var CARD := Color("#efece2") +static var CARD_SOFT := Color("#f7f5ee") +static var CARD_HOVER := Color("#e6dfcd") +static var CARD_SHADE := Color("#d9d3c2") +static var INK := Color("#1c2520") +static var MUTED := Color("#69726b") +static var FAINT := Color("#9a9483") +static var RULE := Color("#d8d3c3") +static var DASH := Color("#bdb6a2") +static var HOVER_ROW := Color("#e9e4d6") ## Every second result row on a card ("parchment" zebra stripe). -const STRIPE := Color(0.11, 0.145, 0.125, 0.055) -const ON_FELT := Color("#e9efe9") -const ON_FELT_MUTED := Color("#a8bdb1") -const DANGER := Color("#e0574a") -const DANGER_INK := Color("#a33a2c") -const WARN_BG := Color("#f4dacb") -const WARN_INK := Color("#8a2f1d") +static var STRIPE := Color(0.11, 0.145, 0.125, 0.055) +## Secondary accent for headings, focus borders and ports. +static var TRIM := Color("#b8703a") +static var TRIM_DARK := Color("#4f2b12") +## Threads between cards (code: pipes). +static var THREAD := Color("#b8703a") +static var THREAD_DARK := Color("#4f2b12") +## Lit and selected things. +static var ACCENT := Color("#f3c450") +static var ACCENT_DARK := Color("#6e5410") +static var LIT := Color("#f8e4a2") +static var FLICK := Color(0.953, 0.769, 0.314, 0.35) +static var PULSE := Color("#fff6d2") +## Magic sparkle colour for glows and particles. +static var GLOW := Color("#f3c450") +static var DANGER := Color("#e0574a") +static var DANGER_INK := Color("#a33a2c") +static var BAD_INK_ON_BG := Color("#ffb1a3") +static var WARN_BG := Color("#f4dacb") +static var WARN_INK := Color("#8a2f1d") ## A check card's Success and Failure outlets. -const OK_INK := Color("#2f6b3f") -const NO_INK := Color("#8a2f1d") -const DASH := Color("#bdb6a2") -const PULSE := Color("#fff6d2") +static var OK_INK := Color("#2f6b3f") +static var NO_INK := Color("#8a2f1d") +## [[Table]] reference chips and {value} markers, on cards and on the board. +static var REF_INK := Color("#1d6656") +static var REF_BG := Color("#d6e9e2") +static var REF_INK_ON_BG := Color("#9fdcc9") +static var VALUE_INK := Color("#7d5a0c") +static var VALUE_INK_ON_BG := Color("#f3c450") +static var VALUE_BG := Color("#fdf6dc") +static var VALUE_BORDER := Color("#e3c97a") +## Large-area fills: {kind: "solid"|"linear"|"radial", colors: [...], angle, center}. +## Empty means flat BG / PANEL. See fill_texture(). +static var BG_FILL: Dictionary = {} +static var PANEL_FILL: Dictionary = {} +## The board's background pattern: "none", "dots" or "stars". +static var PATTERN := "dots" +## The logo shown in the top bar ("none" for none). +static var LOGO := "none" const FONT_DIR := "res://assets/fonts/" @@ -111,7 +144,7 @@ static func bordered(s: StyleBoxFlat, width: int, color: Color) -> StyleBoxFlat: static func focus_ring(radius: int = 8) -> StyleBoxFlat: var s := box(Color(0, 0, 0, 0), radius) s.draw_center = false - bordered(s, 2, BRASS) + bordered(s, 2, ACCENT) s.set_expand_margin_all(2) return s @@ -151,10 +184,10 @@ static func bar_button(text: String, primary: bool = false) -> Button: b.text = text var normal := bordered(box(Color(1, 1, 1, 0.04), 8, [12, 6, 12, 6]), 1, Color(1, 1, 1, 0.16)) var hover := bordered(box(Color(1, 1, 1, 0.1), 8, [12, 6, 12, 6]), 1, Color(1, 1, 1, 0.16)) - var fg := ON_FELT + var fg := ON_BG if primary: - normal = bordered(box(BRASS, 8, [12, 6, 12, 6]), 1, BRASS) - hover = bordered(box(BRASS.lightened(0.15), 8, [12, 6, 12, 6]), 1, BRASS.lightened(0.15)) + normal = bordered(box(ACCENT, 8, [12, 6, 12, 6]), 1, ACCENT) + hover = bordered(box(ACCENT.lightened(0.15), 8, [12, 6, 12, 6]), 1, ACCENT.lightened(0.15)) fg = INK b.add_theme_font_override("font", body_bold()) skin_button(b, normal, hover, hover, fg) @@ -192,12 +225,12 @@ static func overflow_button(tooltip: String, on_felt: bool = false) -> MenuButto mb.size_flags_vertical = Control.SIZE_SHRINK_CENTER mb.add_theme_font_override("font", body_bold(true)) mb.add_theme_font_size_override("font_size", 16) - var hover := box(Color(1, 1, 1, 0.1) if on_felt else Color("#e6dfcd"), 6) + var hover := box(Color(1, 1, 1, 0.1) if on_felt else Style.CARD_HOVER, 6) for n in ["normal", "disabled", "focus"]: mb.add_theme_stylebox_override(n, box(Color(0, 0, 0, 0), 6)) for n in ["hover", "pressed", "hover_pressed"]: mb.add_theme_stylebox_override(n, hover) - font_colors(mb, ON_FELT if on_felt else MUTED) + font_colors(mb, ON_BG if on_felt else MUTED) mb.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND ModalCard.style_popup(mb.get_popup()) return mb @@ -217,7 +250,7 @@ static func font_colors(c: Control, color: Color) -> void: static func field_colors(c: Control) -> void: c.add_theme_color_override("font_color", INK) c.add_theme_color_override("caret_color", INK) - c.add_theme_color_override("selection_color", Color(BRASS, 0.55)) + c.add_theme_color_override("selection_color", Color(ACCENT, 0.55)) c.add_theme_color_override("font_placeholder_color", MUTED) @@ -238,7 +271,7 @@ static func rules_switch(into: HBoxContainer, is_plain: bool, on_change: Callabl var n := box(Color(0, 0, 0, 0), 7, [11, 4, 11, 5]) var h := box(Color(1, 1, 1, 0.08), 7, [11, 4, 11, 5]) var on := box(CARD, 7, [11, 4, 11, 5]) - skin_button(b, n, h, on, ON_FELT_MUTED, ON_FELT, INK) + skin_button(b, n, h, on, ON_BG_MUTED, ON_BG, INK) b.add_theme_font_override("font", body_bold()) b.add_theme_font_size_override("font_size", 13) var want := k == 0 @@ -248,13 +281,57 @@ static func rules_switch(into: HBoxContainer, is_plain: bool, on_change: Callabl return out +# ---------- Fills ---------- + +## A texture for a gradient fill spec, or null when the spec is flat (fewer +## than two colours, or kind "solid"). +static func fill_texture(fill: Dictionary) -> GradientTexture2D: + var cols: Array = fill.get("colors", []) + if cols.size() < 2 or str(fill.get("kind", "solid")) == "solid": + return null + var g := Gradient.new() + g.offsets = PackedFloat32Array() + g.colors = PackedColorArray() + for i in cols.size(): + g.add_point(float(i) / float(cols.size() - 1), Color.from_string(str(cols[i]), Color.BLACK)) + var t := GradientTexture2D.new() + t.gradient = g + t.width = 256 + t.height = 256 + if str(fill["kind"]) == "radial": + var c: Array = fill.get("center", [0.5, 0.5]) + t.fill = GradientTexture2D.FILL_RADIAL + t.fill_from = Vector2(float(c[0]), float(c[1])) + t.fill_to = t.fill_from + Vector2(0.75, 0.0) + else: + var a := deg_to_rad(float(fill.get("angle", 90))) + var dir := Vector2(cos(a), sin(a)) * 0.5 + t.fill_from = Vector2(0.5, 0.5) - dir + t.fill_to = Vector2(0.5, 0.5) + dir + return t + + +## The background for docked panels: the theme's panel gradient, or flat PANEL. +static func panel_box(margins: Array = [0, 0, 0, 0]) -> StyleBox: + var tex := fill_texture(PANEL_FILL) + if tex == null: + return box(PANEL, 0, margins) + var sb := StyleBoxTexture.new() + sb.texture = tex + sb.content_margin_left = margins[0] + sb.content_margin_top = margins[1] + sb.content_margin_right = margins[2] + sb.content_margin_bottom = margins[3] + return sb + + # ---------- Themes ---------- static func app_theme() -> Theme: var th := Theme.new() th.default_font = body() th.default_font_size = 16 - th.set_color("font_color", "Label", ON_FELT) + th.set_color("font_color", "Label", ON_BG) th.set_stylebox("panel", "TooltipPanel", box(CARD, 6, [8, 5, 8, 5])) th.set_color("font_color", "TooltipLabel", INK) return th @@ -266,13 +343,13 @@ static func card_theme() -> Theme: th.default_font_size = 16 th.set_color("font_color", "Label", INK) var normal := bordered(box(Color(1, 1, 1, 0), 5, [6, 3, 6, 3]), 1, Color(1, 1, 1, 0)) - var focus := bordered(box(Color.WHITE, 5, [6, 3, 6, 3]), 1, COPPER) + var focus := bordered(box(Color.WHITE, 5, [6, 3, 6, 3]), 1, TRIM) th.set_stylebox("normal", "LineEdit", normal) th.set_stylebox("focus", "LineEdit", focus) th.set_stylebox("read_only", "LineEdit", normal) th.set_color("font_color", "LineEdit", INK) th.set_color("caret_color", "LineEdit", INK) - th.set_color("selection_color", "LineEdit", Color(BRASS, 0.55)) + th.set_color("selection_color", "LineEdit", Color(ACCENT, 0.55)) th.set_color("font_placeholder_color", "LineEdit", MUTED) # Card fields are sized by their containers, not by a minimum character count. th.set_constant("minimum_character_width", "LineEdit", 0) diff --git a/ui/table_card.gd b/ui/table_card.gd index 01031db..ad53b4a 100644 --- a/ui/table_card.gd +++ b/ui/table_card.gd @@ -82,9 +82,9 @@ func setup(p_main: Main, p_table: RollTable) -> void: _style_normal.shadow_size = 16 _style_normal.shadow_offset = Vector2(0, 8) _style_rolling = _style_normal.duplicate() as StyleBoxFlat - Style.bordered(_style_rolling, 3, Style.BRASS) + Style.bordered(_style_rolling, 3, Style.ACCENT) _style_rolling.set_expand_margin_all(3) - _style_rolling.shadow_color = Color(Style.BRASS, 0.45) + _style_rolling.shadow_color = Color(Style.ACCENT, 0.45) _style_rolling.shadow_size = 26 _style_rolling.shadow_offset = Vector2.ZERO _style_drop = _style_rolling.duplicate() as StyleBoxFlat @@ -92,9 +92,9 @@ func setup(p_main: Main, p_table: RollTable) -> void: _style_drop.shadow_size = 16 _style_drop.shadow_offset = Vector2(0, 8) _style_selected = _style_normal.duplicate() as StyleBoxFlat - Style.bordered(_style_selected, 3, Style.COPPER) + Style.bordered(_style_selected, 3, Style.TRIM) _style_selected.set_expand_margin_all(4) - _style_selected.shadow_color = Color(Style.COPPER, 0.5) + _style_selected.shadow_color = Color(Style.TRIM, 0.5) _style_selected.shadow_size = 14 _style_selected.shadow_offset = Vector2.ZERO _style_dragging = _style_normal.duplicate() as StyleBoxFlat diff --git a/ui/table_card_editing.gd b/ui/table_card_editing.gd index 52d940f..e87c70d 100644 --- a/ui/table_card_editing.gd +++ b/ui/table_card_editing.gd @@ -81,7 +81,7 @@ func make_case_row(e: TableEntry, index: int, numw: float) -> Control: v.add_child(top) var w := e.when.strip_edges() var bad := w != "" and Expr.check(TemplateKit.probe(w)) != "" - var cond := Style.make_label(RulesView.case_label(e, main.data, plain), Style.body_bold(true), 14, Style.DANGER_INK if bad else Style.COPPER_DARK) + var cond := Style.make_label(RulesView.case_label(e, main.data, plain), Style.body_bold(true), 14, Style.DANGER_INK if bad else Style.TRIM_DARK) cond.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART cond.size_flags_horizontal = Control.SIZE_EXPAND_FILL cond.size_flags_vertical = Control.SIZE_SHRINK_CENTER @@ -110,7 +110,7 @@ static func mini_button(glyph: String, tip: String, enabled: bool, on_press: Cal b.custom_minimum_size = Vector2(22, 22) b.size_flags_vertical = Control.SIZE_SHRINK_CENTER b.add_theme_font_size_override("font_size", 16 if glyph == "×" else 13) - Style.skin_button(b, Style.box(Color(0, 0, 0, 0), 5), Style.box(Color("#e6dfcd"), 5), Style.box(Color("#e6dfcd"), 5), Style.MUTED, Style.DANGER_INK if glyph == "×" else Style.INK) + Style.skin_button(b, Style.box(Color(0, 0, 0, 0), 5), Style.box(Style.CARD_HOVER, 5), Style.box(Style.CARD_HOVER, 5), Style.MUTED, Style.DANGER_INK if glyph == "×" else Style.INK) b.add_theme_color_override("font_disabled_color", Color(Style.MUTED, 0.35)) b.pressed.connect(on_press) return b @@ -187,7 +187,7 @@ func range_edit(e: TableEntry, is_lo: bool) -> LineEdit: edit.add_theme_font_override("font", Style.display(true)) edit.add_theme_font_size_override("font_size", 15) edit.add_theme_stylebox_override("normal", Style.bordered(Style.box(Color.WHITE, 4, [2, 2, 2, 2]), 1, Style.RULE)) - edit.add_theme_stylebox_override("focus", Style.bordered(Style.box(Color.WHITE, 4, [2, 2, 2, 2]), 1, Style.COPPER)) + edit.add_theme_stylebox_override("focus", Style.bordered(Style.box(Color.WHITE, 4, [2, 2, 2, 2]), 1, Style.TRIM)) var commit := func() -> void: # Any whole number: results past the dice are reached with a modifier. var typed := edit.text.strip_edges() diff --git a/ui/table_card_header.gd b/ui/table_card_header.gd index db71110..3c9dc0d 100644 --- a/ui/table_card_header.gd +++ b/ui/table_card_header.gd @@ -82,7 +82,7 @@ func make(build: bool, ranged: bool) -> Control: name_row.mouse_filter = Control.MOUSE_FILTER_IGNORE title.size_flags_horizontal = Control.SIZE_EXPAND_FILL name_row.add_child(title) - var mark := Style.make_label(RichText.INFO_MARK, Style.body(true), 12, Color("#9a9483")) + var mark := Style.make_label(RichText.INFO_MARK, Style.body(true), 12, Style.FAINT) mark.size_flags_vertical = Control.SIZE_SHRINK_CENTER name_row.add_child(mark) titles.add_child(name_row) @@ -157,7 +157,7 @@ func _make_go_button() -> Button: var icon := Control.new() icon.mouse_filter = Control.MOUSE_FILTER_IGNORE icon.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT) - icon.draw.connect(func() -> void: Icons.draw_loop(icon, icon.size / 2.0 + Vector2(0, -1), 7.0, Style.BRASS, 2.2)) + icon.draw.connect(func() -> void: Icons.draw_loop(icon, icon.size / 2.0 + Vector2(0, -1), 7.0, Style.ACCENT, 2.2)) b.add_child(icon) RollTable.KIND_ROUTER: b.custom_minimum_size = Vector2(38, 32) @@ -165,7 +165,7 @@ func _make_go_button() -> Button: var fork := Control.new() fork.mouse_filter = Control.MOUSE_FILTER_IGNORE fork.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT) - fork.draw.connect(func() -> void: draw_fork(fork, fork.size / 2.0 + Vector2(0, 0), 8.0, Style.BRASS, 2.2)) + fork.draw.connect(func() -> void: draw_fork(fork, fork.size / 2.0 + Vector2(0, 0), 8.0, Style.ACCENT, 2.2)) b.add_child(fork) RollTable.KIND_SHEET: b.text = "Print" @@ -186,16 +186,16 @@ func _make_go_button() -> Button: label = table.dice_label() if table.dice_label().length() <= 5 else "Roll" b.text = label b.tooltip_text = "Roll %s on %s\nShift-click to skip the animation" % [table.roll_text() if table.is_ranged() else table.dice_label(), table.name] - var rn := Style.box(Style.FELT, 8, [left, 6, 10, 6]) + var rn := Style.box(Style.BG, 8, [left, 6, 10, 6]) rn.border_width_bottom = 2 - rn.border_color = Style.FELT_DEEP + rn.border_color = Style.BG_DEEP var rh := rn.duplicate() as StyleBoxFlat - rh.bg_color = Style.FELT_HOVER + rh.bg_color = Style.BG_HOVER var rp := rn.duplicate() as StyleBoxFlat rp.border_width_bottom = 1 rp.content_margin_top = 7 rp.content_margin_bottom = 5 - Style.skin_button(b, rn, rh, rp, Style.BRASS) + Style.skin_button(b, rn, rh, rp, Style.ACCENT) if table.kind == RollTable.KIND_ROLL: var die := DieIcon.new() die.spinning = card._rolling @@ -229,7 +229,7 @@ func _make_kind_header(_build: bool) -> Control: v.add_child(l) if table.is_dynamic(): var bad := not Roller.lint_options(table).is_empty() - var ol := Style.make_label(RulesView.options_line(table, data, plain), Style.body_bold(true), 12, Style.DANGER_INK if bad else Style.COPPER_DARK) + var ol := Style.make_label(RulesView.options_line(table, data, plain), Style.body_bold(true), 12, Style.DANGER_INK if bad else Style.TRIM_DARK) ol.mouse_filter = Control.MOUSE_FILTER_PASS ol.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART ol.tooltip_text = "One option per %s; the Chosen result runs for whichever is picked (option, option_label and option_value hold it)" % table.options_description() @@ -243,10 +243,10 @@ func _make_kind_header(_build: bool) -> Control: var chip := PanelContainer.new() chip.mouse_filter = Control.MOUSE_FILTER_PASS chip.size_flags_horizontal = Control.SIZE_SHRINK_BEGIN - chip.add_theme_stylebox_override("panel", Style.bordered(Style.box(Color(Style.BRASS, 0.16), 6, [8, 1, 8, 2]), 1, Color(Style.BRASS_DARK, 0.35))) + chip.add_theme_stylebox_override("panel", Style.bordered(Style.box(Color(Style.ACCENT, 0.16), 6, [8, 1, 8, 2]), 1, Color(Style.ACCENT_DARK, 0.35))) var err := Expr.check(table.loop_expr) if table.loop_expr.strip_edges() != "" else "No rule yet" var rule := RulesView.loop_rule(table, data, plain) - var l := Style.make_label(rule, Style.display(true), 16, Style.DANGER_INK if err != "" else Style.COPPER_DARK) + var l := Style.make_label(rule, Style.display(true), 16, Style.DANGER_INK if err != "" else Style.TRIM_DARK) l.mouse_filter = Control.MOUSE_FILTER_IGNORE if rule.length() > 26: # A long plain rule wraps across the card instead of widening it. @@ -386,8 +386,8 @@ func _make_deck_row() -> Control: b.add_theme_font_size_override("font_size", 12) b.size_flags_vertical = Control.SIZE_SHRINK_CENTER var n := Style.box(Color(0, 0, 0, 0), 5, [5, 0, 5, 1]) - var hv := Style.box(Color("#e6dfcd"), 5, [5, 0, 5, 1]) - Style.skin_button(b, n, hv, hv, Style.COPPER, Style.INK) + var hv := Style.box(Style.CARD_HOVER, 5, [5, 0, 5, 1]) + Style.skin_button(b, n, hv, hv, Style.TRIM, Style.INK) b.pressed.connect(func() -> void: card.main.reshuffle_table(card.table.id)) h.add_child(b) update_deck() diff --git a/ui/table_card_rows.gd b/ui/table_card_rows.gd index 05cfcad..76b0dd4 100644 --- a/ui/table_card_rows.gd +++ b/ui/table_card_rows.gd @@ -39,7 +39,7 @@ func _init(p_card: TableCard) -> void: var sb := Style.box(c, 0, [12, 6, 22, 6]) if selected: sb.border_width_left = 3 - sb.border_color = Style.COPPER + sb.border_color = Style.TRIM sb.anti_aliasing = false _row_styles.append(sb) @@ -122,7 +122,7 @@ func make_row(e: TableEntry, index: int, build: bool, ranged: bool, numw: float) else: if chosen: # A caption over the text field, so the field keeps its width. - var cl := Style.make_label("Chosen · runs for the picked option", Style.body_italic(true), 11, Style.COPPER_DARK) + var cl := Style.make_label("Chosen · runs for the picked option", Style.body_italic(true), 11, Style.TRIM_DARK) cl.mouse_filter = Control.MOUSE_FILTER_PASS cl.tooltip_text = "Runs for whichever option from %s is picked: option, option_label and option_value hold it" % table.options_from.strip_edges() col.add_child(cl) @@ -169,7 +169,7 @@ func add_rule_chips(col: VBoxContainer, e: TableEntry) -> void: var plain := card.plain if _is_pick() and e.show_if.strip_edges() != "": var bad := Expr.check(TemplateKit.probe(e.show_if.strip_edges())) != "" - var si := Style.make_label(RulesView.show_if_line(e, card.main.data, plain), Style.body_bold(true), 12, Style.DANGER_INK if bad else Style.COPPER_DARK) + var si := Style.make_label(RulesView.show_if_line(e, card.main.data, plain), Style.body_bold(true), 12, Style.DANGER_INK if bad else Style.TRIM_DARK) si.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART si.mouse_filter = Control.MOUSE_FILTER_PASS si.tooltip_text = ("only if " + e.show_if.strip_edges()) if plain else "" @@ -247,7 +247,7 @@ func row_text(e: TableEntry) -> String: elif table.kind == RollTable.KIND_ROUTER: var bad := e.when.strip_edges() != "" and Expr.check(e.when.strip_edges()) != "" var label := RulesView.case_label(e, main.data, card.plain) - var cond := "[color=#%s][b]%s[/b][/color]" % [(Style.DANGER_INK if bad else Style.COPPER_DARK).to_html(false), RichText.plain(label)] + var cond := "[color=#%s][b]%s[/b][/color]" % [(Style.DANGER_INK if bad else Style.TRIM_DARK).to_html(false), RichText.plain(label)] var plain_text := Formatter.strip_tags(e.text).strip_edges() if plain_text == "" or plain_text == TableCardText.case_label(e) or plain_text == label or plain_text == "if …" or (plain_text == "Otherwise" and e.when.strip_edges() == ""): s = cond @@ -286,13 +286,13 @@ func _effects_chip(e: TableEntry) -> Control: var chip := PanelContainer.new() chip.mouse_filter = Control.MOUSE_FILTER_PASS chip.size_flags_horizontal = Control.SIZE_SHRINK_BEGIN - var bg := Color(Style.DANGER_INK, 0.1) if bad else Color(Style.BRASS, 0.2) - var line := Color(Style.DANGER_INK, 0.4) if bad else Color(Style.BRASS_DARK, 0.3) + var bg := Color(Style.DANGER_INK, 0.1) if bad else Color(Style.ACCENT, 0.2) + var line := Color(Style.DANGER_INK, 0.4) if bad else Color(Style.ACCENT_DARK, 0.3) chip.add_theme_stylebox_override("panel", Style.bordered(Style.box(bg, 5, [6, 0, 6, 1]), 1, line)) var summary := RulesView.effects_line(e.effects, card.main.data, card.table, plain) # Cut long summaries by hand: a clipped Label would collapse to nothing. summary = RulesView.cut(summary, PLAIN_CHIP_CHARS if plain else CHIP_CHARS) - var l := Style.make_label(summary, Style.body_bold(true) if plain else Style.body(true), 12, Style.DANGER_INK if bad else Style.COPPER_DARK) + var l := Style.make_label(summary, Style.body_bold(true) if plain else Style.body(true), 12, Style.DANGER_INK if bad else Style.TRIM_DARK) l.mouse_filter = Control.MOUSE_FILTER_IGNORE chip.add_child(l) chip.set_meta("effects_chip", summary) @@ -323,9 +323,9 @@ func make_sheet_row(e: TableEntry, build: bool) -> Control: te.add_theme_color_override("font_color", Style.INK) te.add_theme_color_override("font_placeholder_color", Style.MUTED) te.add_theme_color_override("caret_color", Style.INK) - te.add_theme_color_override("selection_color", Color(Style.BRASS, 0.55)) + te.add_theme_color_override("selection_color", Color(Style.ACCENT, 0.55)) te.add_theme_stylebox_override("normal", Style.bordered(Style.box(Color.WHITE, 5, [7, 4, 7, 4]), 1, Style.RULE)) - te.add_theme_stylebox_override("focus", Style.bordered(Style.box(Color.WHITE, 5, [7, 4, 7, 4]), 1, Style.COPPER)) + te.add_theme_stylebox_override("focus", Style.bordered(Style.box(Color.WHITE, 5, [7, 4, 7, 4]), 1, Style.TRIM)) te.tooltip_text = "The sheet's template: BBCode with {@var}, {@prefix_*} and {= expr}" te.text_changed.connect(func() -> void: e.text = te.text diff --git a/ui/table_card_text.gd b/ui/table_card_text.gd index 4c8d0e1..84dbe96 100644 --- a/ui/table_card_text.gd +++ b/ui/table_card_text.gd @@ -17,7 +17,7 @@ static func check_badge(t: RollTable) -> String: static func check_sentence(t: RollTable, board: TowerBoard, plain: bool) -> String: var s := RulesView.check_line(t, board, plain) if not plain: - return "[color=#%s]%s[/color]" % [Style.COPPER_DARK.to_html(false), RichText.plain(s)] + return "[color=#%s]%s[/color]" % [Style.TRIM_DARK.to_html(false), RichText.plain(s)] var at := s.rfind(", need ") if at < 0: return RichText.plain(s) diff --git a/ui/table_card_value.gd b/ui/table_card_value.gd index c42aaa8..3389683 100644 --- a/ui/table_card_value.gd +++ b/ui/table_card_value.gd @@ -58,8 +58,8 @@ func make_variable_body(build: bool) -> Control: reset.add_theme_font_override("font", Style.body(true)) reset.add_theme_font_size_override("font_size", 12) var n := Style.box(Color(0, 0, 0, 0), 5, [5, 0, 5, 1]) - var hv := Style.box(Color("#e6dfcd"), 5, [5, 0, 5, 1]) - Style.skin_button(reset, n, hv, hv, Style.COPPER, Style.INK) + var hv := Style.box(Style.CARD_HOVER, 5, [5, 0, 5, 1]) + Style.skin_button(reset, n, hv, hv, Style.TRIM, Style.INK) reset.pressed.connect(func() -> void: main.reset_variable(table.var_name)) h.add_child(reset) v.add_child(h) diff --git a/ui/table_preview.gd b/ui/table_preview.gd index be0eae4..c9d3a87 100644 --- a/ui/table_preview.gd +++ b/ui/table_preview.gd @@ -44,7 +44,7 @@ static func build(board: TowerBoard, table_id: String, opts: Dictionary = {}) -> head.add_child(name) var count := str(opts.get("count", "1")).strip_edges() if count != "" and count != "1": - head.add_child(_label("×" + (RulesView.cut(Describe.dice(count, board), 18) if plain else count), 15, Style.COPPER, true)) + head.add_child(_label("×" + (RulesView.cut(Describe.dice(count, board), 18) if plain else count), 15, Style.TRIM, true)) box.add_child(head) box.add_child(_label(str(opts["heading"]) if opts.has("heading") else kind_line(t), 12, Style.MUTED, false)) @@ -173,7 +173,7 @@ static func _row(t: RollTable, e: TableEntry, index: int, board: TowerBoard = nu var row := HBoxContainer.new() row.add_theme_constant_override("separation", 8) row.mouse_filter = Control.MOUSE_FILTER_IGNORE - var num := _label(row_label(t, e, index), 12, Style.COPPER, false) + var num := _label(row_label(t, e, index), 12, Style.TRIM, false) num.custom_minimum_size.x = 40 num.size_flags_vertical = Control.SIZE_SHRINK_BEGIN row.add_child(num) @@ -182,12 +182,12 @@ static func _row(t: RollTable, e: TableEntry, index: int, board: TowerBoard = nu col.size_flags_horizontal = Control.SIZE_EXPAND_FILL col.mouse_filter = Control.MOUSE_FILTER_IGNORE if t.kind == RollTable.KIND_ROUTER: - var cond := _label(RulesView.case_label(e, board, plain), 12, Style.COPPER_DARK, true, true) + var cond := _label(RulesView.case_label(e, board, plain), 12, Style.TRIM_DARK, true, true) cond.max_lines_visible = 2 cond.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS col.add_child(cond) if t.kind == RollTable.KIND_CHOICE and t.choice == "pick" and e.show_if.strip_edges() != "": - var si := _label(RulesView.show_if_line(e, board, plain), 12, Style.COPPER_DARK, true, true) + var si := _label(RulesView.show_if_line(e, board, plain), 12, Style.TRIM_DARK, true, true) si.max_lines_visible = 2 si.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS col.add_child(si) @@ -201,12 +201,12 @@ static func _row(t: RollTable, e: TableEntry, index: int, board: TowerBoard = nu text.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS col.add_child(text) if e.effects.strip_edges() != "": - var fx := _label(RulesView.effects_line(e.effects, board, t, plain), 11, Style.COPPER_DARK, true, true) + var fx := _label(RulesView.effects_line(e.effects, board, t, plain), 11, Style.TRIM_DARK, true, true) fx.max_lines_visible = 1 fx.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS col.add_child(fx) if not e.pipes.is_empty(): - col.add_child(_label(NEXT_HINT, 11, Style.COPPER, false)) + col.add_child(_label(NEXT_HINT, 11, Style.TRIM, false)) row.add_child(col) if t.kind == RollTable.KIND_ROLL: # The preview doesn't know the modifier's value, so it shows no chances. diff --git a/ui/template_forms.gd b/ui/template_forms.gd index 02c444c..a9ed51f 100644 --- a/ui/template_forms.gd +++ b/ui/template_forms.gd @@ -54,10 +54,10 @@ static func save_dialog(tpl: Dictionary, on_save: Callable) -> ModalCard: var row := HBoxContainer.new() row.add_theme_constant_override("separation", 8) var chip := PanelContainer.new() - chip.add_theme_stylebox_override("panel", Style.bordered(Style.box(Color(Style.BRASS, 0.18), 6, [8, 4, 8, 4]), 1, Color(Style.BRASS_DARK, 0.4))) + chip.add_theme_stylebox_override("panel", Style.bordered(Style.box(Color(Style.ACCENT, 0.18), 6, [8, 4, 8, 4]), 1, Color(Style.ACCENT_DARK, 0.4))) chip.custom_minimum_size = Vector2(120, 0) chip.size_flags_vertical = Control.SIZE_SHRINK_CENTER - chip.add_child(Style.make_label("{$%s}" % p["name"], Style.body_bold(), 14, Style.COPPER_DARK)) + chip.add_child(Style.make_label("{$%s}" % p["name"], Style.body_bold(), 14, Style.TRIM_DARK)) row.add_child(chip) var label := LineEdit.new() label.text = str(p.get("label", "")) @@ -131,7 +131,7 @@ static func preview(tpl: Dictionary, box: Vector2 = Vector2(120, 74)) -> Control c.custom_minimum_size = box c.mouse_filter = Control.MOUSE_FILTER_IGNORE c.draw.connect(func() -> void: - c.draw_style_box(Style.box(Style.FELT, 8), Rect2(Vector2.ZERO, box)) + c.draw_style_box(Style.box(Style.BG, 8), Rect2(Vector2.ZERO, box)) var ext := TemplateKit.extent(tpl) if ext.x <= 0.0 or ext.y <= 0.0: return @@ -149,9 +149,9 @@ static func preview(tpl: Dictionary, box: Vector2 = Vector2(120, 74)) -> Control if kind == "choice": fill = Style.LIT c.draw_style_box(Style.box(fill, 3), r) - var band := Color(Style.COPPER, 0.9) if kind == "loop" else (Style.FELT_HOVER if kind == "variable" else Style.RULE) + var band := Color(Style.TRIM, 0.9) if kind == "loop" else (Style.BG_HOVER if kind == "variable" else Style.RULE) if kind == "sheet": - band = Style.BRASS_DARK + band = Style.ACCENT_DARK c.draw_rect(Rect2(r.position + Vector2(0, 2), Vector2(r.size.x, maxf(2.0, r.size.y * 0.16))), band) ) return c diff --git a/ui/template_picker.gd b/ui/template_picker.gd index af8af06..efa9960 100644 --- a/ui/template_picker.gd +++ b/ui/template_picker.gd @@ -87,7 +87,7 @@ func select(id: String) -> void: func _paint() -> void: for id: String in _rows: var on := id == _selected - var sb := Style.bordered(Style.box(Style.LIT if on else Color("#f7f3e8"), 10, [12, 10, 12, 10]), 1, Style.COPPER if on else Style.DASH) + var sb := Style.bordered(Style.box(Style.LIT if on else Style.CARD_SOFT, 10, [12, 10, 12, 10]), 1, Style.TRIM if on else Style.DASH) (_rows[id] as PanelContainer).add_theme_stylebox_override("panel", sb) @@ -122,7 +122,7 @@ func _row(r: Dictionary) -> Control: var title := Style.make_label(str(r["name"]), Style.display(), 20, Style.INK) title.mouse_filter = MOUSE_FILTER_IGNORE title_row.add_child(title) - title_row.add_child(_badge(str({"card": "Card", "group": "Group", "selection": "Cards"}.get(r["kind"], "Cards")), Style.FELT, Style.BRASS)) + title_row.add_child(_badge(str({"card": "Card", "group": "Group", "selection": "Cards"}.get(r["kind"], "Cards")), Style.BG, Style.ACCENT)) if r["builtin"]: title_row.add_child(_badge("Built in", Color(0, 0, 0, 0.07), Style.MUTED)) v.add_child(title_row) diff --git a/ui/test_board_dialog.gd b/ui/test_board_dialog.gd index 4194b24..1c65a61 100644 --- a/ui/test_board_dialog.gd +++ b/ui/test_board_dialog.gd @@ -61,7 +61,7 @@ func _build() -> void: start_pick = OptionButton.new() start_pick.add_theme_stylebox_override("normal", Style.bordered(Style.box(Color.WHITE, 7, [10, 6, 10, 6]), 1, Style.DASH)) - var lit := Style.bordered(Style.box(Color.WHITE, 7, [10, 6, 10, 6]), 1, Style.COPPER) + var lit := Style.bordered(Style.box(Color.WHITE, 7, [10, 6, 10, 6]), 1, Style.TRIM) for n in ["hover", "pressed", "focus"]: start_pick.add_theme_stylebox_override(n, lit) Style.font_colors(start_pick, Style.INK) @@ -100,7 +100,7 @@ func _build() -> void: progress.show_percentage = false progress.custom_minimum_size = Vector2(0, 12) progress.add_theme_stylebox_override("background", Style.box(Color(0, 0, 0, 0.12), 6)) - progress.add_theme_stylebox_override("fill", Style.box(Style.FELT, 6)) + progress.add_theme_stylebox_override("fill", Style.box(Style.BG, 6)) _progress_row.add_child(progress) status = note("") _progress_row.add_child(status) diff --git a/ui/theme_dialog.gd b/ui/theme_dialog.gd new file mode 100644 index 0000000..22c7051 --- /dev/null +++ b/ui/theme_dialog.gd @@ -0,0 +1,150 @@ +class_name ThemeDialog +extends ModalCard +## View ▾ → Theme…: pick a theme set, edit its colours, background and panel +## fills, pattern and logo, and save it as your own. "Use theme" restyles the +## app (Main reloads its UI; the open spread is kept). + +var m: Main +var _sets: Array[Dictionary] = [] +## The set being edited: a deep copy with every colour filled in. +var _work: Dictionary = {} +var _dirty := false +var _picker: OptionButton +var _content: VBoxContainer +var _more := false + + +func _init(p_main: Main) -> void: + super._init("Theme", 640.0) + m = p_main + var top := HBoxContainer.new() + top.add_theme_constant_override("separation", 10) + body.add_child(top) + _picker = OptionButton.new() + _picker.size_flags_horizontal = SIZE_EXPAND_FILL + _picker.item_selected.connect(func(i: int) -> void: _load(_sets[i])) + ModalCard.style_popup(_picker.get_popup()) + top.add_child(_picker) + _content = VBoxContainer.new() + _content.add_theme_constant_override("separation", 14) + body.add_child(_content) + add_button("Delete", "plain", _delete) + add_button("Save as new…", "plain", _save_as_new) + add_button("Close", "plain", close) + add_button("Use theme", "primary", _use) + _refresh_sets(str(ThemeStore.current.get("id", ThemeStore.DEFAULT_ID))) + + +func _refresh_sets(select_id: String) -> void: + _sets = ThemeStore.all() + _picker.clear() + var at := 0 + for i in _sets.size(): + var t := _sets[i] + _picker.add_item(str(t.get("name", "?")) + (" (built in)" if t.get("builtin", false) else "")) + if str(t.get("id", "")) == select_id: + at = i + _picker.select(at) + _load(_sets[at]) + + +func _load(t: Dictionary) -> void: + _work = t.duplicate(true) + _work["colors"] = ThemeStore.resolved_colors(t) + _dirty = false + _rebuild() + + +func _rebuild() -> void: + for c in _content.get_children(): + c.queue_free() + if bool(_work.get("builtin", false)): + _content.add_child(ModalCard.note("This theme is built in. Changes to it are saved as a new theme of your own.")) + var bg := FillEditor.new(_work.get("background", {}), _color("BG")) + bg.changed.connect(func() -> void: _put("background", bg.fill)) + _content.add_child(ModalCard.field("Background", bg)) + var panel := FillEditor.new(_work.get("panel", {}), _color("PANEL")) + panel.changed.connect(func() -> void: _put("panel", panel.fill)) + _content.add_child(ModalCard.field("Panels (top bar and tray)", panel)) + var row := HBoxContainer.new() + row.add_theme_constant_override("separation", 24) + row.add_child(ModalCard.field("Background pattern", _choice(ThemeStore.PATTERNS, "pattern", "dots"))) + row.add_child(ModalCard.field("Logo", _choice(ThemeStore.LOGOS, "logo", "none"))) + _content.add_child(row) + _content.add_child(ModalCard.section("Colours")) + var grid := GridContainer.new() + grid.columns = 2 + grid.add_theme_constant_override("h_separation", 14) + grid.add_theme_constant_override("v_separation", 6) + _content.add_child(grid) + for r: Array in ThemeStore.TOKENS: + if bool(r[2]) or _more: + var tok: String = r[0] + grid.add_child(FillEditor.swatch(_color(tok), func(c: Color) -> void: + (_work["colors"] as Dictionary)[tok] = "#" + c.to_html(true) + _dirty = true)) + grid.add_child(ModalCard.note(str(r[1]), Style.INK)) + var more := ModalCard.make_button("Fewer colours" if _more else "More colours…") + more.size_flags_horizontal = SIZE_SHRINK_BEGIN + more.pressed.connect(func() -> void: + _more = not _more + _rebuild.call_deferred()) + _content.add_child(more) + + +func _color(tok: String) -> Color: + return Color.from_string(str((_work["colors"] as Dictionary).get(tok, "#000")), Color.BLACK) + + +func _put(key: String, value: Variant) -> void: + _work[key] = value + _dirty = true + + +func _choice(options: Array, key: String, fallback: String) -> OptionButton: + var ob := OptionButton.new() + ModalCard.style_popup(ob.get_popup()) + for i in options.size(): + ob.add_item(str(options[i][1]), i) + if options[i][0] == str(_work.get(key, fallback)): + ob.select(i) + ob.item_selected.connect(func(i: int) -> void: _put(key, options[i][0])) + return ob + + +## Saves (a built-in becomes a new set) and restyles the app with it. +func _use() -> void: + if not _dirty: + _apply(_work) + return + if bool(_work.get("builtin", false)): + _save_as_new() + return + _work["id"] = ThemeStore.save(_work) + _apply(_work) + + +func _save_as_new() -> void: + var start := str(_work.get("name", "Theme")) + " (mine)" + add_child(ModalCard.ask_text("Save theme", "Name", start, "Save", func(name: String) -> void: + var t := _work.duplicate(true) + t["name"] = name + t.erase("id") + t.erase("builtin") + t["id"] = ThemeStore.save(t) + _apply(t))) + + +func _delete() -> void: + if bool(_work.get("builtin", false)): + m.toast("Built-in themes can't be deleted.") + return + var id := str(_work.get("id", "")) + add_child(ModalCard.confirm("Delete theme", "Delete “%s”? This can't be undone." % _work.get("name", ""), "Delete", func() -> void: + ThemeStore.delete(id) + _refresh_sets(ThemeStore.DEFAULT_ID), true)) + + +func _apply(t: Dictionary) -> void: + close() + ThemeStore.use(m, t) diff --git a/ui/theme_dialog.gd.uid b/ui/theme_dialog.gd.uid new file mode 100644 index 0000000..367fafc --- /dev/null +++ b/ui/theme_dialog.gd.uid @@ -0,0 +1 @@ +uid://ch2xomexb78v5 diff --git a/ui/theme_store.gd b/ui/theme_store.gd new file mode 100644 index 0000000..c214ca2 --- /dev/null +++ b/ui/theme_store.gd @@ -0,0 +1,167 @@ +class_name ThemeStore +extends RefCounted +## Theme sets: the built-ins (BuiltinThemes) plus the user's own, saved as JSON +## in user://themes/. apply() writes a set into Style's tokens; the app then +## rebuilds its UI (Main.restyle) so every control picks the new colours up. + +## Where user sets live (a test points this elsewhere). +static var DIR := "user://themes/" +const DEFAULT_ID := "tarot" +const SETTING := "theme" + +## Editor rows, in order: [token, label, basic?]. Basic rows show first; the +## rest sit under "More colours". +const TOKENS := [ + ["ON_BG", "Text on the background", true], + ["CARD", "Card face", true], + ["INK", "Card text", true], + ["MUTED", "Card secondary text", true], + ["THREAD", "Threads", true], + ["ACCENT", "Highlight (lit and selected)", true], + ["TRIM", "Trim and headings", true], + ["GLOW", "Magic sparkles", true], + ["BG", "Background (flat)", false], + ["BG_DEEP", "Background shadow", false], + ["BG_HOVER", "Background buttons, hover", false], + ["PANEL", "Panels (flat)", false], + ["ON_BG_MUTED", "Secondary text on the background", false], + ["CARD_SOFT", "Boxes on cards", false], + ["CARD_HOVER", "Card buttons, hover", false], + ["CARD_SHADE", "Card shading", false], + ["FAINT", "Faint text", false], + ["RULE", "Lines on cards", false], + ["DASH", "Dashed outlines", false], + ["HOVER_ROW", "Result row, hover", false], + ["STRIPE", "Striped rows", false], + ["TRIM_DARK", "Trim, dark", false], + ["THREAD_DARK", "Threads, dark edge", false], + ["ACCENT_DARK", "Highlight, dark", false], + ["LIT", "Lit result", false], + ["FLICK", "Rolling flicker", false], + ["PULSE", "Thread pulse", false], + ["DANGER", "Danger", false], + ["DANGER_INK", "Danger text", false], + ["BAD_INK_ON_BG", "Problem text on the background", false], + ["WARN_BG", "Warning box", false], + ["WARN_INK", "Warning text", false], + ["OK_INK", "Success outlet", false], + ["NO_INK", "Failure outlet", false], + ["REF_INK", "Table link text", false], + ["REF_BG", "Table link box", false], + ["REF_INK_ON_BG", "Table link on the background", false], + ["VALUE_INK", "Value text", false], + ["VALUE_INK_ON_BG", "Value text on the background", false], + ["VALUE_BG", "Value box", false], + ["VALUE_BORDER", "Value box border", false], +] +const PATTERNS := [["none", "None"], ["dots", "Dots"], ["stars", "Stars"]] +const LOGOS := [["fortune_teller", "Fortune teller"], ["none", "None"]] + +## The open spread, handed across the scene reload that applies a theme. +static var carry_board: TowerBoard = null +## The active set (also kept here so --sample runs, which don't save, keep it). +static var current: Dictionary = {} +static var _fallback: Dictionary = {} + + +## Every set: built-ins first, then the user's, by name. +static func all() -> Array[Dictionary]: + var out: Array[Dictionary] = BuiltinThemes.all() + var mine: Array[Dictionary] = [] + var d := DirAccess.open(DIR) + if d: + for f in d.get_files(): + if f.ends_with(".json"): + var t: Variant = JSON.parse_string(FileAccess.get_file_as_string(DIR + f)) + if t is Dictionary: + t["builtin"] = false + mine.append(t) + mine.sort_custom(func(a: Dictionary, b: Dictionary) -> bool: return str(a.get("name", "")).naturalnocasecmp_to(str(b.get("name", ""))) < 0) + out.append_array(mine) + return out + + +static func find(id: String) -> Dictionary: + for t in all(): + if str(t.get("id", "")) == id: + return t + return BuiltinThemes.TAROT + + +## Saves a user set and returns its id. Built-in ids can't be overwritten: +## saving one makes a copy. +static func save(t: Dictionary) -> String: + var out := t.duplicate(true) + var id := str(out.get("id", "")) + if id == "" or bool(out.get("builtin", false)) or _is_builtin(id): + id = _new_id(str(out.get("name", "My theme"))) + out["id"] = id + out.erase("builtin") + DirAccess.make_dir_recursive_absolute(DIR) + var f := FileAccess.open(DIR + id + ".json", FileAccess.WRITE) + if f: + f.store_string(JSON.stringify(out, "\t")) + return id + + +static func delete(id: String) -> void: + if not _is_builtin(id): + DirAccess.remove_absolute(DIR + id + ".json") + + +## Writes a set into Style. Tokens the set doesn't list get the fallback value, +## so switching sets never leaves colours behind. +static func apply(t: Dictionary) -> void: + var sc: Script = Style + if _fallback.is_empty(): + for row: Array in TOKENS: + _fallback[row[0]] = sc.get(row[0]) + var colors: Dictionary = t.get("colors", {}) + for row: Array in TOKENS: + var tok: String = row[0] + sc.set(tok, Color.from_string(str(colors[tok]), _fallback[tok]) if colors.has(tok) else _fallback[tok]) + Style.BG_FILL = t.get("background", {}) + Style.PANEL_FILL = t.get("panel", {}) + Style.PATTERN = str(t.get("pattern", "dots")) + Style.LOGO = str(t.get("logo", "none")) + current = t + + +## Applies a set, remembers it, and rebuilds the app's UI around the open spread. +static func use(m: Main, t: Dictionary) -> void: + apply(t) + if m.state: + m.state.set_setting(SETTING, str(t.get("id", DEFAULT_ID))) + m.state.save() + m._save_now() + carry_board = m.data + m.get_tree().reload_current_scene.call_deferred() + + +## Every token's colour for a set (its own, else the fallback), as "#hex". +static func resolved_colors(t: Dictionary) -> Dictionary: + var colors: Dictionary = t.get("colors", {}) + var out := {} + for row: Array in TOKENS: + var fb: Color = _fallback.get(row[0], (Style as Script).get(row[0])) + out[row[0]] = str(colors[row[0]]) if colors.has(row[0]) else "#" + fb.to_html(true) + return out + + +static func _is_builtin(id: String) -> bool: + for t in BuiltinThemes.all(): + if t["id"] == id: + return true + return false + + +static func _new_id(name: String) -> String: + var base := name.to_lower().replace(" ", "-").validate_filename() + if base == "": + base = "theme" + var id := base + var n := 2 + while _is_builtin(id) or FileAccess.file_exists(DIR + id + ".json"): + id = "%s-%d" % [base, n] + n += 1 + return id diff --git a/ui/theme_store.gd.uid b/ui/theme_store.gd.uid new file mode 100644 index 0000000..3af2828 --- /dev/null +++ b/ui/theme_store.gd.uid @@ -0,0 +1 @@ +uid://dhv1fya25hqeg diff --git a/ui/tray_chips.gd b/ui/tray_chips.gd index b3b754f..40c23f6 100644 --- a/ui/tray_chips.gd +++ b/ui/tray_chips.gd @@ -18,7 +18,7 @@ static func chip(tray: ResultTray, step: Dictionary, last: bool, steps: Array = sb.shadow_size = 1 sb.shadow_offset = Vector2(0, 3) if last: - Style.bordered(sb, 2, Style.BRASS) + Style.bordered(sb, 2, Style.ACCENT) sb.set_expand_margin_all(2) if inline: sb.bg_color = sb.bg_color.darkened(0.04) @@ -72,8 +72,8 @@ static func _why_button() -> Button: b.size_flags_horizontal = Control.SIZE_SHRINK_BEGIN b.focus_mode = Control.FOCUS_NONE var n := Style.bordered(Style.box(Color.WHITE, 10, [9, 1, 9, 2]), 1, Style.RULE) - var h := Style.bordered(Style.box(Style.LIT, 10, [9, 1, 9, 2]), 1, Style.BRASS_DARK) - Style.skin_button(b, n, h, h, Style.COPPER_DARK, Style.INK) + var h := Style.bordered(Style.box(Style.LIT, 10, [9, 1, 9, 2]), 1, Style.ACCENT_DARK) + Style.skin_button(b, n, h, h, Style.TRIM_DARK, Style.INK) b.add_theme_font_override("font", Style.body_bold()) b.add_theme_font_size_override("font_size", 12) return b @@ -92,7 +92,7 @@ static func _effect_lines(fx: Array) -> Control: if shown >= EFFECT_LINES and not bad: continue var lab := Style.make_label(("⚠ " if bad else "") + str(d.get("text", "")), Style.body_bold() if bad else Style.body(), 12, - Style.DANGER_INK if bad else Style.COPPER_DARK) + Style.DANGER_INK if bad else Style.TRIM_DARK) lab.mouse_filter = Control.MOUSE_FILTER_IGNORE lab.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS lab.custom_minimum_size.x = 0 @@ -109,12 +109,12 @@ static func _effect_lines(fx: Array) -> Control: ## The brass pipe piece between two chips (thinner for an inline step). static func link(inline: bool = false) -> Control: var l := Panel.new() - var sb := Style.box(Style.BRASS) + var sb := Style.box(Style.ACCENT) sb.border_width_top = 2 sb.border_width_bottom = 2 - sb.border_color = Style.BRASS_DARK + sb.border_color = Style.ACCENT_DARK if inline: - sb = Style.box(Color(Style.BRASS, 0.55)) + sb = Style.box(Color(Style.ACCENT, 0.55)) l.add_theme_stylebox_override("panel", sb) l.custom_minimum_size = Vector2(16, 4) if inline else Vector2(22, 8) l.size_flags_vertical = Control.SIZE_SHRINK_CENTER @@ -126,14 +126,14 @@ static func link(inline: bool = false) -> Control: static func asking_chip(title: String) -> Control: var p := PanelContainer.new() var sb := Style.box(Color(1, 1, 1, 0.05), 9, [12, 7, 12, 8]) - Style.bordered(sb, 1, Color(Style.BRASS, 0.6)) + Style.bordered(sb, 1, Color(Style.ACCENT, 0.6)) p.add_theme_stylebox_override("panel", sb) p.size_flags_vertical = Control.SIZE_SHRINK_CENTER var v := VBoxContainer.new() v.add_theme_constant_override("separation", 1) p.add_child(v) - v.add_child(Style.make_label(title, Style.body(), 12, Style.ON_FELT_MUTED)) - v.add_child(Style.make_label("Waiting for your answer…", Style.display(), 20, Style.BRASS)) + v.add_child(Style.make_label(title, Style.body(), 12, Style.ON_BG_MUTED)) + v.add_child(Style.make_label("Waiting for your answer…", Style.display(), 20, Style.ACCENT)) return p @@ -147,8 +147,8 @@ static func earlier_toggle(tray: ResultTray, first: int, total: int) -> Control: b.tooltip_text = "This chain has %s steps" % TrayText.thousands(total) b.size_flags_vertical = Control.SIZE_SHRINK_CENTER var n := Style.bordered(Style.box(Color(1, 1, 1, 0.04), 8, [12, 6, 12, 6]), 1, Color(1, 1, 1, 0.16)) - var h := Style.bordered(Style.box(Color(1, 1, 1, 0.1), 8, [12, 6, 12, 6]), 1, Color(Style.BRASS, 0.5)) - Style.skin_button(b, n, h, h, Style.ON_FELT_MUTED, Style.ON_FELT) + var h := Style.bordered(Style.box(Color(1, 1, 1, 0.1), 8, [12, 6, 12, 6]), 1, Color(Style.ACCENT, 0.5)) + Style.skin_button(b, n, h, h, Style.ON_BG_MUTED, Style.ON_BG) b.add_theme_font_size_override("font_size", 14) b.pressed.connect(func() -> void: tray.expanded = not tray.expanded diff --git a/ui/value_picker.gd b/ui/value_picker.gd index 814a00b..570904a 100644 --- a/ui/value_picker.gd +++ b/ui/value_picker.gd @@ -35,8 +35,8 @@ var _shown: Array[String] = [] func _init(p_main: Main = null, p_value: String = "") -> void: main = p_main value = p_value - var n := Style.bordered(Style.box(InspectorKit.VAR_BG, 6, [8, 3, 8, 3]), 1, InspectorKit.VAR_BORDER) - var h := Style.bordered(Style.box(InspectorKit.VAR_BG.darkened(0.04), 6, [8, 3, 8, 3]), 1, Style.COPPER) + var n := Style.bordered(Style.box(Style.VALUE_BG, 6, [8, 3, 8, 3]), 1, Style.VALUE_BORDER) + var h := Style.bordered(Style.box(Style.VALUE_BG.darkened(0.04), 6, [8, 3, 8, 3]), 1, Style.TRIM) Style.skin_button(self, n, h, h, Style.INK) add_theme_font_override("font", Style.body_bold()) add_theme_font_size_override("font_size", 15) @@ -247,7 +247,7 @@ func _row_button(label: String, right: String, accent: bool) -> Button: b.clip_text = true var n := Style.box(Color(0, 0, 0, 0), 5, [8, 4, 8, 4]) var h := Style.box(Style.HOVER_ROW, 5, [8, 4, 8, 4]) - Style.skin_button(b, n, h, h, Style.COPPER_DARK if accent else Style.INK) + Style.skin_button(b, n, h, h, Style.TRIM_DARK if accent else Style.INK) b.add_theme_font_override("font", Style.body_bold() if accent else Style.body()) b.add_theme_font_size_override("font_size", 15) b.focus_mode = Control.FOCUS_NONE diff --git a/ui/variables_panel.gd b/ui/variables_panel.gd index 6059e8a..b1f3ce5 100644 --- a/ui/variables_panel.gd +++ b/ui/variables_panel.gd @@ -22,7 +22,7 @@ func setup(p_main: Main) -> void: add_theme_constant_override("separation", 6) size_flags_vertical = SIZE_EXPAND_FILL _field = Style.bordered(Style.box(Color(1, 1, 1, 0.05), 6, [8, 3, 8, 3]), 1, Color(1, 1, 1, 0.12)) - _field_focus = Style.bordered(Style.box(Color(1, 1, 1, 0.1), 6, [8, 3, 8, 3]), 1, Style.BRASS) + _field_focus = Style.bordered(Style.box(Color(1, 1, 1, 0.1), 6, [8, 3, 8, 3]), 1, Style.ACCENT) var scroll := ScrollContainer.new() scroll.horizontal_scroll_mode = ScrollContainer.SCROLL_MODE_DISABLED # The list fills the tray's height and scrolls (the tray is resizable). @@ -42,7 +42,7 @@ func setup(p_main: Main) -> void: _reset_all.add_theme_font_size_override("font_size", 13) var n := Style.bordered(Style.box(Color(1, 1, 1, 0.04), 6, [10, 2, 10, 3]), 1, Color(1, 1, 1, 0.12)) var h := Style.bordered(Style.box(Color(1, 1, 1, 0.1), 6, [10, 2, 10, 3]), 1, Color(Style.DANGER, 0.6)) - Style.skin_button(_reset_all, n, h, h, Style.ON_FELT_MUTED, Style.ON_FELT) + Style.skin_button(_reset_all, n, h, h, Style.ON_BG_MUTED, Style.ON_BG) _reset_all.pressed.connect(confirm_reset_all) foot.add_child(_reset_all) @@ -62,15 +62,15 @@ func render() -> void: var names := main.variable_names() _reset_all.disabled = names.is_empty() if names.is_empty(): - var empty := RichText.label("No saved variables yet. A pipe that saves as [color=#%s]@name[/color], a change such as [color=#%s]@hp = 10[/color], or [lb][lb]Table -> @name]] in a result, keeps its value here." % [Style.BRASS.to_html(false), Style.BRASS.to_html(false)], - 14, Style.ON_FELT_MUTED, false) + var empty := RichText.label("No saved variables yet. A pipe that saves as [color=#%s]@name[/color], a change such as [color=#%s]@hp = 10[/color], or [lb][lb]Table -> @name]] in a result, keeps its value here." % [Style.ACCENT.to_html(false), Style.ACCENT.to_html(false)], + 14, Style.ON_BG_MUTED, false) _list.add_child(empty) for n in names: _list.add_child(_var_row(n)) var chain: Dictionary = main.current.get("chain_vars", {}) if not chain.is_empty(): - var head := Style.make_label("THIS ROLL", Style.caps(), 11, Style.ON_FELT_MUTED) + var head := Style.make_label("THIS ROLL", Style.caps(), 11, Style.ON_BG_MUTED) head.add_theme_constant_override("line_spacing", 0) var gap := Control.new() gap.custom_minimum_size = Vector2(0, 4) @@ -79,8 +79,8 @@ func render() -> void: var keys: Array = chain.keys() keys.sort() for k in keys: - var line := RichText.label("[color=#%s]{%s}[/color] %s" % [RichText.VAR_INK_FELT.to_html(false), k, Expr.format_value(chain[k])], - 14, Style.ON_FELT, false) + var line := RichText.label("[color=#%s]{%s}[/color] %s" % [Style.VALUE_INK_ON_BG.to_html(false), k, Expr.format_value(chain[k])], + 14, Style.ON_BG, false) _list.add_child(line) @@ -98,7 +98,7 @@ func _var_row(name: String) -> Control: var card := main.variable_card(name) var row := HBoxContainer.new() row.add_theme_constant_override("separation", 6) - var label := Style.make_label("@" + name, Style.body_bold(), 14, RichText.VAR_INK_FELT) + var label := Style.make_label("@" + name, Style.body_bold(), 14, Style.VALUE_INK_ON_BG) label.custom_minimum_size = Vector2(84, 0) label.clip_text = true label.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS @@ -111,10 +111,10 @@ func _var_row(name: String) -> Control: edit.size_flags_horizontal = SIZE_EXPAND_FILL edit.custom_minimum_size = Vector2(60, 0) edit.add_theme_font_size_override("font_size", 14) - edit.add_theme_color_override("font_color", Style.ON_FELT) - edit.add_theme_color_override("caret_color", Style.ON_FELT) - edit.add_theme_color_override("selection_color", Color(Style.BRASS, 0.4)) - edit.add_theme_color_override("font_placeholder_color", Color(Style.ON_FELT_MUTED, 0.7)) + edit.add_theme_color_override("font_color", Style.ON_BG) + edit.add_theme_color_override("caret_color", Style.ON_BG) + edit.add_theme_color_override("selection_color", Color(Style.ACCENT, 0.4)) + edit.add_theme_color_override("font_placeholder_color", Color(Style.ON_BG_MUTED, 0.7)) edit.add_theme_stylebox_override("normal", _field) edit.add_theme_stylebox_override("focus", _field_focus) if not is_set and card: @@ -157,6 +157,6 @@ func _icon_button(text: String, tip: String) -> Button: b.add_theme_font_size_override("font_size", 16) var n := Style.bordered(Style.box(Color(1, 1, 1, 0.04), 6), 1, Color(1, 1, 1, 0.12)) var h := Style.bordered(Style.box(Color(1, 1, 1, 0.1), 6), 1, Color(1, 1, 1, 0.2)) - Style.skin_button(b, n, h, h, Style.ON_FELT_MUTED, Style.ON_FELT) - b.add_theme_color_override("font_disabled_color", Color(Style.ON_FELT_MUTED, 0.35)) + Style.skin_button(b, n, h, h, Style.ON_BG_MUTED, Style.ON_BG) + b.add_theme_color_override("font_disabled_color", Color(Style.ON_BG_MUTED, 0.35)) return b diff --git a/ui/view_menu.gd b/ui/view_menu.gd index b85f070..c8d5b0b 100644 --- a/ui/view_menu.gd +++ b/ui/view_menu.gd @@ -1,7 +1,7 @@ class_name ViewMenu extends MenuButton ## The top bar's "View ▾" menu: how rules read (plain words or rule text), -## collapsing or expanding every table, striped result rows and the minimap. +## collapsing or expanding every table, striped result rows, the minimap and the theme. ## These are view preferences, so they live in one menu instead of the bar. const ID_PLAIN := 0 @@ -9,6 +9,7 @@ const ID_TEXT := 1 const ID_COLLAPSE := 2 const ID_STRIPES := 3 const ID_MINIMAP := 4 +const ID_THEME := 5 var m: Main @@ -29,6 +30,9 @@ func setup(p_main: Main) -> void: pm.add_separator("Show") pm.add_check_item("Striped rows", ID_STRIPES) pm.add_check_item("Minimap (M)", ID_MINIMAP) + pm.add_separator() + pm.add_item("Theme…", ID_THEME) + pm.set_item_tooltip(pm.get_item_index(ID_THEME), "Colours, background, fonts and logo; save your own theme") pm.about_to_popup.connect(sync) pm.id_pressed.connect(activate) @@ -59,3 +63,5 @@ func activate(id: int) -> void: m.local_state.set_striped_rows(not m.local_state.striped_rows()) ID_MINIMAP: m.nav.set_minimap_visible(not m.board.minimap.visible, true) + ID_THEME: + m.add_child(ThemeDialog.new(m)) diff --git a/ui/why_popover.gd b/ui/why_popover.gd index e5f2c00..a792b6d 100644 --- a/ui/why_popover.gd +++ b/ui/why_popover.gd @@ -29,7 +29,7 @@ func _init() -> void: z_index = 90 mouse_filter = MOUSE_FILTER_STOP var sb := Style.box(Style.CARD, 9, [14, 10, 14, 12]) - Style.bordered(sb, 2, Style.BRASS) + Style.bordered(sb, 2, Style.ACCENT) sb.shadow_color = Color(0, 0, 0, 0.4) sb.shadow_size = 16 sb.shadow_offset = Vector2(0, 6)