2026-11-09 08:06:56 -06:00
|
|
|
class_name EarlierRolls
|
|
|
|
|
extends VBoxContainer
|
|
|
|
|
## ResultTray's Earlier tab: one row per past roll, newest first, as
|
2026-11-09 10:01:10 -06:00
|
|
|
## "12:04 Root: a → b → c". The rows scroll inside the tray.
|
2026-11-09 08:06:56 -06:00
|
|
|
|
|
|
|
|
var main: Main
|
2026-11-09 10:01:10 -06:00
|
|
|
var scroll: ScrollContainer
|
2026-11-09 08:06:56 -06:00
|
|
|
var _rows: VBoxContainer
|
|
|
|
|
var _empty: Label
|
2026-11-14 13:47:03 -06:00
|
|
|
## The rows built so far: [record, row], so a render only builds rows for new
|
|
|
|
|
## rolls (long results make each row slow to build).
|
|
|
|
|
var _built: Array = []
|
2026-11-09 08:06:56 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
func setup(p_main: Main) -> void:
|
|
|
|
|
main = p_main
|
|
|
|
|
add_theme_constant_override("separation", 6)
|
2026-11-09 10:01:10 -06:00
|
|
|
size_flags_vertical = SIZE_EXPAND_FILL
|
|
|
|
|
scroll = ScrollContainer.new()
|
|
|
|
|
scroll.horizontal_scroll_mode = ScrollContainer.SCROLL_MODE_DISABLED
|
|
|
|
|
scroll.size_flags_vertical = SIZE_EXPAND_FILL
|
|
|
|
|
add_child(scroll)
|
2026-11-09 08:06:56 -06:00
|
|
|
_rows = VBoxContainer.new()
|
|
|
|
|
_rows.add_theme_constant_override("separation", 6)
|
2026-11-09 10:01:10 -06:00
|
|
|
_rows.size_flags_horizontal = SIZE_EXPAND_FILL
|
|
|
|
|
scroll.add_child(_rows)
|
Theme system: runtime colour tokens, theme sets and a Theme dialog
Style's colours become static vars named by role (BG, PANEL, CARD, THREAD,
ACCENT, TRIM, GLOW…) instead of materials (felt, copper, brass), so a theme
can replace them. Stray hard-coded colours moved into tokens.
ThemeStore applies built-in sets (Tarot, the new default: jewel-purple
cloth with a shine; Felt, the old look) and the user's own sets from
user://themes/. Fills for the background and panels can be gradients; the
background pattern (dots, stars, none) and logo are per set. View ▾ →
Theme… edits a set; changes to a built-in save as a new set. Using a theme
reloads the UI and keeps the open spread.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 18:10:16 -06:00
|
|
|
_empty = Style.make_label("Older rolls show here.", Style.body(), 15, Style.ON_BG_MUTED)
|
2026-11-09 08:06:56 -06:00
|
|
|
add_child(_empty)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func render() -> void:
|
2026-11-14 13:47:03 -06:00
|
|
|
var kept: Array = []
|
|
|
|
|
for rec in main.history:
|
|
|
|
|
var row: Control = null
|
|
|
|
|
for pair: Array in _built:
|
|
|
|
|
if is_same(pair[0], rec):
|
|
|
|
|
row = pair[1]
|
|
|
|
|
break
|
|
|
|
|
if row == null:
|
|
|
|
|
row = _make_row(rec)
|
|
|
|
|
_rows.add_child(row)
|
|
|
|
|
kept.append([rec, row])
|
|
|
|
|
for pair: Array in _built:
|
|
|
|
|
if not kept.any(func(other: Array) -> bool: return is_same(other[1], pair[1])):
|
|
|
|
|
_rows.remove_child(pair[1])
|
|
|
|
|
(pair[1] as Node).queue_free()
|
|
|
|
|
for i in kept.size():
|
|
|
|
|
if (kept[i][1] as Node).get_index() != i:
|
|
|
|
|
_rows.move_child(kept[i][1], i)
|
|
|
|
|
_built = kept
|
2026-11-09 08:06:56 -06:00
|
|
|
_empty.visible = main.history.is_empty()
|
2026-11-09 10:01:10 -06:00
|
|
|
scroll.visible = not _empty.visible
|
|
|
|
|
scroll.scroll_vertical = 0
|
2026-11-14 13:47:03 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
func _make_row(rec: Dictionary) -> HBoxContainer:
|
|
|
|
|
var row := HBoxContainer.new()
|
|
|
|
|
row.add_theme_constant_override("separation", 8)
|
|
|
|
|
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_BG, false)
|
|
|
|
|
line.size_flags_horizontal = SIZE_EXPAND_FILL
|
|
|
|
|
RichText.hook_hover(line, main)
|
|
|
|
|
row.add_child(line)
|
|
|
|
|
return row
|
2026-11-09 08:06:56 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
## One Earlier row: "Root: a → b → c", with only the last few steps of a long
|
|
|
|
|
## chain.
|
|
|
|
|
static func earlier_line(rec: Dictionary) -> String:
|
|
|
|
|
var texts := PackedStringArray()
|
|
|
|
|
var all: Array = rec.get("steps", [])
|
|
|
|
|
var shown := 0
|
|
|
|
|
var skipped := 0
|
|
|
|
|
for k in range(all.size() - 1, -1, -1):
|
|
|
|
|
var s: Dictionary = all[k]
|
|
|
|
|
if s.get("inline", false):
|
|
|
|
|
continue
|
|
|
|
|
if shown >= 6:
|
|
|
|
|
skipped += 1
|
|
|
|
|
continue
|
|
|
|
|
texts.insert(0, RichText.decorate(TrayText.one_line(str(s["text"])), true))
|
|
|
|
|
shown += 1
|
2026-11-14 14:09:01 -06:00
|
|
|
var root := RichText.plain(Formatter.strip_tags(str(rec.get("root_name", ""))))
|
|
|
|
|
if str(rec.get("batch", "")) != "":
|
|
|
|
|
root += " (%s)" % rec["batch"]
|
|
|
|
|
var lead := "[color=#%s]%s:[/color] " % [Style.ON_BG_MUTED.to_html(false), root]
|
2026-11-09 08:06:56 -06:00
|
|
|
if skipped > 0:
|
Theme system: runtime colour tokens, theme sets and a Theme dialog
Style's colours become static vars named by role (BG, PANEL, CARD, THREAD,
ACCENT, TRIM, GLOW…) instead of materials (felt, copper, brass), so a theme
can replace them. Stray hard-coded colours moved into tokens.
ThemeStore applies built-in sets (Tarot, the new default: jewel-purple
cloth with a shine; Felt, the old look) and the user's own sets from
user://themes/. Fills for the background and panels can be gradients; the
background pattern (dots, stars, none) and logo are per set. View ▾ →
Theme… edits a set; changes to a built-in save as a new set. Using a theme
reloads the UI and keeps the open spread.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 18:10:16 -06:00
|
|
|
lead += "[color=#%s]… %d earlier →[/color] " % [Style.ON_BG_MUTED.to_html(false), skipped]
|
2026-11-09 08:06:56 -06:00
|
|
|
return lead + " → ".join(texts)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static func clock(unix: float) -> String:
|
|
|
|
|
var bias: int = Time.get_time_zone_from_system().get("bias", 0)
|
|
|
|
|
var d := Time.get_datetime_dict_from_unix_time(int(unix) + bias * 60)
|
|
|
|
|
return "%02d:%02d" % [d["hour"], d["minute"]]
|