Split ui/main.gd into area helpers (no behaviour change)
Main (3679 lines) becomes a shell: shared state, start-up, cards, input,
rules view and one-line delegators for the methods other files call. Each
area moves with its state into a RefCounted helper holding a back-reference
(m: Main):
main_cli.gd command-line and screenshot flags
main_top_bar.gd top bar, toast, endless-loop chip
main_editing.gd add/delete cards, results and pipes, selection bar
main_groups.gd groups and card drags
main_templates.gd templates
main_rolling.gd rolling, choice questions, playback, session seed, copy
main_collections.gd collections, import/export, table settings, test board
main_state.gd decks, variables, roll history (local state)
main_navigation.gd search, focus, minimap, arrange/pack
main_history.gd undo/redo and mark_dirty
main_inspector.gd inspector selection and refresh
Tests that reached moved private members now go through the helper
(main.undo_redo.edits, main.rolling.pending_choice(), ...).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:14:19 -06:00
|
|
|
class_name MainCli
|
|
|
|
|
extends RefCounted
|
|
|
|
|
## Main's command-line flags, used for screenshots and checks (see
|
|
|
|
|
## docs/DESIGN.md §5). Only automation needs this file.
|
|
|
|
|
|
|
|
|
|
var m: Main
|
2026-11-14 13:18:48 -06:00
|
|
|
## The group, template and inspector flags (MainCliBuild).
|
|
|
|
|
var _build: MainCliBuild
|
|
|
|
|
## The --perf timings (MainCliPerf).
|
|
|
|
|
var _perf: MainCliPerf
|
Split ui/main.gd into area helpers (no behaviour change)
Main (3679 lines) becomes a shell: shared state, start-up, cards, input,
rules view and one-line delegators for the methods other files call. Each
area moves with its state into a RefCounted helper holding a back-reference
(m: Main):
main_cli.gd command-line and screenshot flags
main_top_bar.gd top bar, toast, endless-loop chip
main_editing.gd add/delete cards, results and pipes, selection bar
main_groups.gd groups and card drags
main_templates.gd templates
main_rolling.gd rolling, choice questions, playback, session seed, copy
main_collections.gd collections, import/export, table settings, test board
main_state.gd decks, variables, roll history (local state)
main_navigation.gd search, focus, minimap, arrange/pack
main_history.gd undo/redo and mark_dirty
main_inspector.gd inspector selection and refresh
Tests that reached moved private members now go through the helper
(main.undo_redo.edits, main.rolling.pending_choice(), ...).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:14:19 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
func _init(p_main: Main) -> void:
|
|
|
|
|
m = p_main
|
2026-11-14 13:18:48 -06:00
|
|
|
_build = MainCliBuild.new(p_main)
|
|
|
|
|
_perf = MainCliPerf.new(p_main)
|
Split ui/main.gd into area helpers (no behaviour change)
Main (3679 lines) becomes a shell: shared state, start-up, cards, input,
rules view and one-line delegators for the methods other files call. Each
area moves with its state into a RefCounted helper holding a back-reference
(m: Main):
main_cli.gd command-line and screenshot flags
main_top_bar.gd top bar, toast, endless-loop chip
main_editing.gd add/delete cards, results and pipes, selection bar
main_groups.gd groups and card drags
main_templates.gd templates
main_rolling.gd rolling, choice questions, playback, session seed, copy
main_collections.gd collections, import/export, table settings, test board
main_state.gd decks, variables, roll history (local state)
main_navigation.gd search, focus, minimap, arrange/pack
main_history.gd undo/redo and mark_dirty
main_inspector.gd inspector selection and refresh
Tests that reached moved private members now go through the helper
(main.undo_redo.edits, main.rolling.pending_choice(), ...).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:14:19 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
# ---------- Command line (used for screenshots and checks) ----------
|
|
|
|
|
# godot --path . -- --screenshot=/tmp/shot.png [--build] [--expand-all] [--collapse-all]
|
|
|
|
|
# [--roll=<table id>] [--fast] [--shot-delay=<seconds>]
|
|
|
|
|
# [--board=<collection.json>] (with --sample/--screenshot only: show that board instead)
|
2026-11-09 08:21:26 -06:00
|
|
|
# [--tray=variables] [--hover=<x>,<y>] [--details=<table id>] [--pipe=<pipe key>]
|
Split ui/main.gd into area helpers (no behaviour change)
Main (3679 lines) becomes a shell: shared state, start-up, cards, input,
rules view and one-line delegators for the methods other files call. Each
area moves with its state into a RefCounted helper holding a back-reference
(m: Main):
main_cli.gd command-line and screenshot flags
main_top_bar.gd top bar, toast, endless-loop chip
main_editing.gd add/delete cards, results and pipes, selection bar
main_groups.gd groups and card drags
main_templates.gd templates
main_rolling.gd rolling, choice questions, playback, session seed, copy
main_collections.gd collections, import/export, table settings, test board
main_state.gd decks, variables, roll history (local state)
main_navigation.gd search, focus, minimap, arrange/pack
main_history.gd undo/redo and mark_dirty
main_inspector.gd inspector selection and refresh
Tests that reached moved private members now go through the helper
(main.undo_redo.edits, main.rolling.pending_choice(), ...).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:14:19 -06:00
|
|
|
|
|
|
|
|
static func _arg_value(args: PackedStringArray, name: String) -> String:
|
|
|
|
|
for a in args:
|
|
|
|
|
if a.begins_with(name + "="):
|
|
|
|
|
return a.substr(name.length() + 1)
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _run_cli(args: PackedStringArray) -> void:
|
|
|
|
|
var board_file := _arg_value(args, "--board")
|
|
|
|
|
if board_file != "" and not m._saving_enabled:
|
|
|
|
|
await _load_board_file(board_file)
|
|
|
|
|
if args.has("--build"):
|
|
|
|
|
m.set_mode(Main.Mode.BUILD)
|
|
|
|
|
if args.has("--expand-all"):
|
|
|
|
|
m.set_all_collapsed(false)
|
|
|
|
|
if args.has("--collapse-all"):
|
|
|
|
|
m.set_all_collapsed(true)
|
|
|
|
|
_run_shell_cli(args)
|
|
|
|
|
_run_logic_cli(args)
|
2026-11-14 13:18:48 -06:00
|
|
|
await _build.run_group_cli(args)
|
Split ui/main.gd into area helpers (no behaviour change)
Main (3679 lines) becomes a shell: shared state, start-up, cards, input,
rules view and one-line delegators for the methods other files call. Each
area moves with its state into a RefCounted helper holding a back-reference
(m: Main):
main_cli.gd command-line and screenshot flags
main_top_bar.gd top bar, toast, endless-loop chip
main_editing.gd add/delete cards, results and pipes, selection bar
main_groups.gd groups and card drags
main_templates.gd templates
main_rolling.gd rolling, choice questions, playback, session seed, copy
main_collections.gd collections, import/export, table settings, test board
main_state.gd decks, variables, roll history (local state)
main_navigation.gd search, focus, minimap, arrange/pack
main_history.gd undo/redo and mark_dirty
main_inspector.gd inspector selection and refresh
Tests that reached moved private members now go through the helper
(main.undo_redo.edits, main.rolling.pending_choice(), ...).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:14:19 -06:00
|
|
|
var roll := _arg_value(args, "--roll")
|
|
|
|
|
if roll != "":
|
|
|
|
|
m.start_roll(roll, args.has("--fast"))
|
|
|
|
|
_run_cli_extras(args)
|
|
|
|
|
_run_test_board_cli(args)
|
|
|
|
|
var shot := _arg_value(args, "--screenshot")
|
|
|
|
|
if shot == "":
|
|
|
|
|
return
|
|
|
|
|
var delay := _arg_value(args, "--shot-delay")
|
|
|
|
|
if args.has("--fit") or _arg_value(args, "--view") != "":
|
|
|
|
|
# Let the tray settle first (it can change the board's size).
|
|
|
|
|
await m.get_tree().process_frame
|
|
|
|
|
await m.get_tree().process_frame
|
|
|
|
|
if args.has("--fit"):
|
|
|
|
|
m.board.fit()
|
|
|
|
|
_apply_view_flag(args)
|
|
|
|
|
await m.get_tree().create_timer(delay.to_float() if delay != "" else (2.5 if roll != "" else 0.8)).timeout
|
|
|
|
|
var img := m.get_viewport().get_texture().get_image()
|
|
|
|
|
img.save_png(shot)
|
|
|
|
|
print("Saved screenshot to ", shot)
|
|
|
|
|
m.get_tree().quit()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ----- Extra screenshot flags -----
|
|
|
|
|
# --open-settings=<table id> open the settings dialog
|
|
|
|
|
# --demo-import=<file> show the import report for a file (nothing is saved)
|
|
|
|
|
# --demo-endless pipe the first two tables into each other
|
UI pass: striped rows, View/Help menus, zoom control, card ⋯ menu, fuller sample
- Striped result rows (parchment tint, on by default, `striped_rows` setting).
- Top bar: View ▾ (Plain words / Rule text, Collapse/Expand all, Striped rows,
Minimap) and a "− 90% ▾ +" zoom control replace the Plain|Text switch,
Collapse all, −/Fit/+ and Map. Arrange ▾ folds into Board ▾; Search is an icon.
- Help ▾ and F1 open a Help window; the 17 topics live in help/topics.txt.
- Build cards get a ⋯ menu (settings, template, collapse, delete) instead of
the gear and footer Delete, sharing Style.overflow_button with group cards.
Row × buttons show only on hover, focus or selection.
- Sample: Luck value card, Make Camp (pick card) and Search the Ruins
(1d6 + Luck, with results only a modifier reaches).
- New test suite test_top_bar; Canvas/GraphML round-trip tests compare plain
tables only, since logic keys are JSON-only.
- DESIGN.md: open items, including the Card Mode UI redesign.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 10:36:38 -06:00
|
|
|
# --menu=board|collections|view|help|zoom|add|card pop up a menu (card: the
|
|
|
|
|
# first card's ⋯ menu, in Build)
|
|
|
|
|
# --help[=<topic>] open the Help window
|
Split ui/main.gd into area helpers (no behaviour change)
Main (3679 lines) becomes a shell: shared state, start-up, cards, input,
rules view and one-line delegators for the methods other files call. Each
area moves with its state into a RefCounted helper holding a back-reference
(m: Main):
main_cli.gd command-line and screenshot flags
main_top_bar.gd top bar, toast, endless-loop chip
main_editing.gd add/delete cards, results and pipes, selection bar
main_groups.gd groups and card drags
main_templates.gd templates
main_rolling.gd rolling, choice questions, playback, session seed, copy
main_collections.gd collections, import/export, table settings, test board
main_state.gd decks, variables, roll history (local state)
main_navigation.gd search, focus, minimap, arrange/pack
main_history.gd undo/redo and mark_dirty
main_inspector.gd inspector selection and refresh
Tests that reached moved private members now go through the helper
(main.undo_redo.edits, main.rolling.pending_choice(), ...).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:14:19 -06:00
|
|
|
|
|
|
|
|
func _run_shell_cli(args: PackedStringArray) -> void:
|
|
|
|
|
var tid := _arg_value(args, "--open-settings")
|
|
|
|
|
if tid != "":
|
|
|
|
|
m.open_table_settings(tid)
|
|
|
|
|
var file := _arg_value(args, "--demo-import")
|
|
|
|
|
if file != "":
|
|
|
|
|
var text := FileAccess.get_file_as_string(file)
|
|
|
|
|
var r := IoMenu.parse_import(text, IoMenu.detect_format(file, text))
|
|
|
|
|
m._add_modal(IoMenu.report_dialog("Imported “%s”" % file.get_file().get_basename(), r))
|
|
|
|
|
if args.has("--demo-endless") and m.data.tables.size() >= 2:
|
|
|
|
|
var a := m.data.tables[0]
|
|
|
|
|
var b := m.data.tables[1]
|
|
|
|
|
for e in a.entries:
|
|
|
|
|
e.pipes = [b.id] as Array[String]
|
|
|
|
|
for e in b.entries:
|
|
|
|
|
e.pipes = [a.id] as Array[String]
|
|
|
|
|
m._rebuild_cards()
|
|
|
|
|
m.mark_dirty()
|
|
|
|
|
var menu := _arg_value(args, "--menu")
|
|
|
|
|
if menu == "board":
|
|
|
|
|
m.top_bar._board_menu.show_popup()
|
|
|
|
|
elif menu == "collections":
|
|
|
|
|
m.top_bar._switcher.show_popup()
|
UI pass: striped rows, View/Help menus, zoom control, card ⋯ menu, fuller sample
- Striped result rows (parchment tint, on by default, `striped_rows` setting).
- Top bar: View ▾ (Plain words / Rule text, Collapse/Expand all, Striped rows,
Minimap) and a "− 90% ▾ +" zoom control replace the Plain|Text switch,
Collapse all, −/Fit/+ and Map. Arrange ▾ folds into Board ▾; Search is an icon.
- Help ▾ and F1 open a Help window; the 17 topics live in help/topics.txt.
- Build cards get a ⋯ menu (settings, template, collapse, delete) instead of
the gear and footer Delete, sharing Style.overflow_button with group cards.
Row × buttons show only on hover, focus or selection.
- Sample: Luck value card, Make Camp (pick card) and Search the Ruins
(1d6 + Luck, with results only a modifier reaches).
- New test suite test_top_bar; Canvas/GraphML round-trip tests compare plain
tables only, since logic keys are JSON-only.
- DESIGN.md: open items, including the Card Mode UI redesign.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 10:36:38 -06:00
|
|
|
elif menu == "view":
|
|
|
|
|
m.top_bar.view_menu.show_popup()
|
|
|
|
|
elif menu == "help":
|
|
|
|
|
m.top_bar.help_menu.show_popup()
|
|
|
|
|
elif menu == "zoom":
|
|
|
|
|
m.top_bar.zoom.menu.show_popup()
|
|
|
|
|
elif menu == "card":
|
|
|
|
|
# The first card's ⋯ menu (Build mode).
|
|
|
|
|
await m.get_tree().process_frame
|
|
|
|
|
var card := m.card_for(m.data.tables[0].id)
|
|
|
|
|
var more := card.find_children("*", "MenuButton", true, false) if card else []
|
|
|
|
|
if not more.is_empty():
|
|
|
|
|
(more[0] as MenuButton).show_popup()
|
2026-11-16 10:41:13 -06:00
|
|
|
if args.has("--welcome"):
|
|
|
|
|
WelcomeDialog.open(m)
|
UI pass: striped rows, View/Help menus, zoom control, card ⋯ menu, fuller sample
- Striped result rows (parchment tint, on by default, `striped_rows` setting).
- Top bar: View ▾ (Plain words / Rule text, Collapse/Expand all, Striped rows,
Minimap) and a "− 90% ▾ +" zoom control replace the Plain|Text switch,
Collapse all, −/Fit/+ and Map. Arrange ▾ folds into Board ▾; Search is an icon.
- Help ▾ and F1 open a Help window; the 17 topics live in help/topics.txt.
- Build cards get a ⋯ menu (settings, template, collapse, delete) instead of
the gear and footer Delete, sharing Style.overflow_button with group cards.
Row × buttons show only on hover, focus or selection.
- Sample: Luck value card, Make Camp (pick card) and Search the Ruins
(1d6 + Luck, with results only a modifier reaches).
- New test suite test_top_bar; Canvas/GraphML round-trip tests compare plain
tables only, since logic keys are JSON-only.
- DESIGN.md: open items, including the Card Mode UI redesign.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 10:36:38 -06:00
|
|
|
if args.has("--help") or _arg_value(args, "--help") != "":
|
|
|
|
|
m.top_bar.help_menu.open(_arg_value(args, "--help"))
|
|
|
|
|
if menu == "add":
|
Split ui/main.gd into area helpers (no behaviour change)
Main (3679 lines) becomes a shell: shared state, start-up, cards, input,
rules view and one-line delegators for the methods other files call. Each
area moves with its state into a RefCounted helper holding a back-reference
(m: Main):
main_cli.gd command-line and screenshot flags
main_top_bar.gd top bar, toast, endless-loop chip
main_editing.gd add/delete cards, results and pipes, selection bar
main_groups.gd groups and card drags
main_templates.gd templates
main_rolling.gd rolling, choice questions, playback, session seed, copy
main_collections.gd collections, import/export, table settings, test board
main_state.gd decks, variables, roll history (local state)
main_navigation.gd search, focus, minimap, arrange/pack
main_history.gd undo/redo and mark_dirty
main_inspector.gd inspector selection and refresh
Tests that reached moved private members now go through the helper
(main.undo_redo.edits, main.rolling.pending_choice(), ...).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:14:19 -06:00
|
|
|
# The Build tools were only just shown; let them lay out first.
|
|
|
|
|
await m.get_tree().process_frame
|
2026-11-29 14:58:56 -06:00
|
|
|
m.left_dock.show_tab(LeftDock.CARDS)
|
Split ui/main.gd into area helpers (no behaviour change)
Main (3679 lines) becomes a shell: shared state, start-up, cards, input,
rules view and one-line delegators for the methods other files call. Each
area moves with its state into a RefCounted helper holding a back-reference
(m: Main):
main_cli.gd command-line and screenshot flags
main_top_bar.gd top bar, toast, endless-loop chip
main_editing.gd add/delete cards, results and pipes, selection bar
main_groups.gd groups and card drags
main_templates.gd templates
main_rolling.gd rolling, choice questions, playback, session seed, copy
main_collections.gd collections, import/export, table settings, test board
main_state.gd decks, variables, roll history (local state)
main_navigation.gd search, focus, minimap, arrange/pack
main_history.gd undo/redo and mark_dirty
main_inspector.gd inspector selection and refresh
Tests that reached moved private members now go through the helper
(main.undo_redo.edits, main.rolling.pending_choice(), ...).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:14:19 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
# ----- Logic-card screenshot flags -----
|
|
|
|
|
# --answers=<a>|<b>|… answer the first questions automatically, in order
|
|
|
|
|
# (an option index or -1 for a pick, a number, or text);
|
|
|
|
|
# later questions open the pop-up
|
|
|
|
|
# --demo-long=<n> add a table that pipes into itself n times, and fast-roll it
|
|
|
|
|
# --confirm-reset open the Variables tab's "Reset all…" confirmation
|
|
|
|
|
|
|
|
|
|
func _run_logic_cli(args: PackedStringArray) -> void:
|
|
|
|
|
var answers := _arg_value(args, "--answers")
|
|
|
|
|
if answers != "":
|
|
|
|
|
var queue: Array = Array(answers.split("|"))
|
|
|
|
|
m.prompt_hook = func(req: Dictionary) -> Variant:
|
|
|
|
|
if queue.is_empty():
|
|
|
|
|
return await m.rolling._ask_player(req)
|
|
|
|
|
var a := str(queue.pop_front())
|
|
|
|
|
return a if str(req.get("kind", "")) == "text" else a.to_int()
|
|
|
|
|
var n := _arg_value(args, "--demo-long").to_int()
|
|
|
|
|
if n > 0:
|
|
|
|
|
var head := RollTable.create(RollTable.KIND_ROLL, "long_start", "Long chain")
|
|
|
|
|
head.entries.resize(1)
|
|
|
|
|
head.entries[0].text = "Off we go"
|
|
|
|
|
head.entries[0].effects = "@k = 0"
|
|
|
|
|
head.entries[0].add_pipe("long_link")
|
|
|
|
|
var link := RollTable.create(RollTable.KIND_ROLL, "long_link", "Link")
|
|
|
|
|
link.entries.resize(1)
|
|
|
|
|
link.entries[0].text = "Link {@k}"
|
|
|
|
|
link.entries[0].effects = "@k += 1"
|
|
|
|
|
link.entries[0].add_pipe("long_link", "@k < %d" % n)
|
|
|
|
|
var y := 40.0
|
|
|
|
|
for t in m.data.tables:
|
|
|
|
|
y = maxf(y, t.position.y + 80.0)
|
|
|
|
|
head.position = Vector2(40, y + 400)
|
|
|
|
|
link.position = Vector2(360, y + 400)
|
|
|
|
|
m.data.tables.append(head)
|
|
|
|
|
m.data.tables.append(link)
|
|
|
|
|
m._rebuild_cards()
|
|
|
|
|
m.start_roll("long_start", true)
|
|
|
|
|
if args.has("--confirm-reset"):
|
|
|
|
|
m.tray.set_side(ResultTray.Side.VARIABLES)
|
|
|
|
|
m.tray._vars.confirm_reset_all()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# --clear-result empty the tray (the board stays lit)
|
|
|
|
|
# --view=<x>,<y>[,<zoom>] centre the view on a world point (after Fit)
|
|
|
|
|
|
|
|
|
|
func _apply_view_flag(args: PackedStringArray) -> void:
|
|
|
|
|
var v := _arg_value(args, "--view")
|
|
|
|
|
if v == "":
|
|
|
|
|
return
|
|
|
|
|
var parts := v.split(",")
|
|
|
|
|
if parts.size() >= 3:
|
|
|
|
|
m.board.set_zoom(parts[2].to_float())
|
|
|
|
|
var p := Vector2(parts[0].to_float(), parts[1].to_float())
|
|
|
|
|
m.board.world.position = m.board.size / 2.0 - p * m.board.zoom
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ---------- Command line extras ----------
|
|
|
|
|
|
|
|
|
|
## Shows a collection file instead of the sample (screenshots only; nothing is saved).
|
|
|
|
|
func _load_board_file(path: String) -> void:
|
|
|
|
|
var text := FileAccess.get_file_as_string(path)
|
|
|
|
|
if text == "" or not m.data.load_json(text):
|
|
|
|
|
push_warning("Couldn't load board file %s" % path)
|
|
|
|
|
return
|
|
|
|
|
m.rolling._token += 1
|
|
|
|
|
m.rolling.cancel_choice()
|
|
|
|
|
m.top_bar._switcher.refresh()
|
|
|
|
|
m._rebuild_cards()
|
|
|
|
|
m.rolling._seed_session()
|
|
|
|
|
await m.get_tree().process_frame
|
|
|
|
|
await m.get_tree().process_frame
|
|
|
|
|
m.board.fit()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _run_cli_extras(args: PackedStringArray) -> void:
|
|
|
|
|
if args.has("--perf"):
|
2026-11-14 13:18:48 -06:00
|
|
|
_perf.run_perf()
|
Split ui/main.gd into area helpers (no behaviour change)
Main (3679 lines) becomes a shell: shared state, start-up, cards, input,
rules view and one-line delegators for the methods other files call. Each
area moves with its state into a RefCounted helper holding a back-reference
(m: Main):
main_cli.gd command-line and screenshot flags
main_top_bar.gd top bar, toast, endless-loop chip
main_editing.gd add/delete cards, results and pipes, selection bar
main_groups.gd groups and card drags
main_templates.gd templates
main_rolling.gd rolling, choice questions, playback, session seed, copy
main_collections.gd collections, import/export, table settings, test board
main_state.gd decks, variables, roll history (local state)
main_navigation.gd search, focus, minimap, arrange/pack
main_history.gd undo/redo and mark_dirty
main_inspector.gd inspector selection and refresh
Tests that reached moved private members now go through the helper
(main.undo_redo.edits, main.rolling.pending_choice(), ...).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:14:19 -06:00
|
|
|
await _run_undo_cli(args)
|
|
|
|
|
_run_nav_cli(args)
|
|
|
|
|
if args.has("--clear-result"):
|
|
|
|
|
# Keeps the board lit but empties the tray (a tall sheet result can fill it).
|
|
|
|
|
m.current = {}
|
|
|
|
|
m.tray.render()
|
|
|
|
|
if _arg_value(args, "--tray") == "variables":
|
|
|
|
|
m.tray.set_side(ResultTray.Side.VARIABLES)
|
|
|
|
|
var pipe := _arg_value(args, "--pipe")
|
|
|
|
|
if pipe != "":
|
|
|
|
|
m.open_pipe_options(pipe, Vector2(m.size.x * 0.45, m.size.y * 0.3))
|
2026-11-14 13:18:48 -06:00
|
|
|
await _build.run_inspector_cli(args)
|
Split ui/main.gd into area helpers (no behaviour change)
Main (3679 lines) becomes a shell: shared state, start-up, cards, input,
rules view and one-line delegators for the methods other files call. Each
area moves with its state into a RefCounted helper holding a back-reference
(m: Main):
main_cli.gd command-line and screenshot flags
main_top_bar.gd top bar, toast, endless-loop chip
main_editing.gd add/delete cards, results and pipes, selection bar
main_groups.gd groups and card drags
main_templates.gd templates
main_rolling.gd rolling, choice questions, playback, session seed, copy
main_collections.gd collections, import/export, table settings, test board
main_state.gd decks, variables, roll history (local state)
main_navigation.gd search, focus, minimap, arrange/pack
main_history.gd undo/redo and mark_dirty
main_inspector.gd inspector selection and refresh
Tests that reached moved private members now go through the helper
(main.undo_redo.edits, main.rolling.pending_choice(), ...).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:14:19 -06:00
|
|
|
var hover := _arg_value(args, "--hover")
|
|
|
|
|
if hover.contains(","):
|
|
|
|
|
# Synthetic mouse move, to check hover pop-ups in screenshots.
|
|
|
|
|
await m.get_tree().create_timer(0.3).timeout
|
|
|
|
|
var ev := InputEventMouseMotion.new()
|
|
|
|
|
ev.position = Vector2(hover.get_slice(",", 0).to_float(), hover.get_slice(",", 1).to_float())
|
|
|
|
|
ev.global_position = ev.position
|
|
|
|
|
m.get_viewport().notification(Control.NOTIFICATION_VP_MOUSE_ENTER)
|
|
|
|
|
m.get_viewport().push_input(ev)
|
|
|
|
|
var det := _arg_value(args, "--details")
|
|
|
|
|
var card := m.card_for(det)
|
|
|
|
|
if card:
|
|
|
|
|
await m.get_tree().process_frame
|
|
|
|
|
m.details().show_table(card, det)
|
|
|
|
|
m.details().pin(card.get_global_rect().position + Vector2(60, 46))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# --test-board open the Test board dialog (shows the last report if any)
|
|
|
|
|
# --test-board-run=<runs> ... and start a test with that many runs (100, 500 or 1000)
|
|
|
|
|
func _run_test_board_cli(args: PackedStringArray) -> void:
|
|
|
|
|
var n := _arg_value(args, "--test-board-run")
|
|
|
|
|
if not args.has("--test-board") and n == "":
|
|
|
|
|
return
|
|
|
|
|
m.set_mode(Main.Mode.BUILD)
|
|
|
|
|
var d := TestBoardDialog.new(m)
|
|
|
|
|
m._add_modal(d)
|
|
|
|
|
if n != "":
|
|
|
|
|
d.runs = n.to_int()
|
|
|
|
|
d.run_test()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ----- Navigation screenshot flags -----
|
|
|
|
|
# --search=<text> open the search panel with that query
|
|
|
|
|
# --focus=<table id>[:<entry id>] jump to a card (and result)
|
|
|
|
|
# --minimap / --no-minimap show or hide the overview
|
|
|
|
|
# --pack Build ▸ Arrange ▸ Pack collapsed groups
|
|
|
|
|
# --perf print load and frame timings, then quit
|
2026-11-10 19:02:46 -06:00
|
|
|
# --list, --book show List view, the Book
|
Help: topics for every new feature, a cheat sheet, and Try a demo spreads
Twelve new Help topics (menus, selecting and resizing, nested groups,
themes, List view, the Book, rolling more than once, pausing, costs,
one table adjusting another, sheets and saving, pictures, phones), and a
Keyboard shortcuts topic split into keys, mouse and touch. Topics with
[demo]key[/demo] get a 'Try a demo spread' link: DemoSpreads builds a
small example, DemoMode shows it unsaved and unlisted with Keep a copy
and Back to my spread. --demo=KEY opens one from the command line.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 19:24:57 -06:00
|
|
|
# --demo=KEY open a Help demo spread (DemoSpreads)
|
Split ui/main.gd into area helpers (no behaviour change)
Main (3679 lines) becomes a shell: shared state, start-up, cards, input,
rules view and one-line delegators for the methods other files call. Each
area moves with its state into a RefCounted helper holding a back-reference
(m: Main):
main_cli.gd command-line and screenshot flags
main_top_bar.gd top bar, toast, endless-loop chip
main_editing.gd add/delete cards, results and pipes, selection bar
main_groups.gd groups and card drags
main_templates.gd templates
main_rolling.gd rolling, choice questions, playback, session seed, copy
main_collections.gd collections, import/export, table settings, test board
main_state.gd decks, variables, roll history (local state)
main_navigation.gd search, focus, minimap, arrange/pack
main_history.gd undo/redo and mark_dirty
main_inspector.gd inspector selection and refresh
Tests that reached moved private members now go through the helper
(main.undo_redo.edits, main.rolling.pending_choice(), ...).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:14:19 -06:00
|
|
|
|
|
|
|
|
func _run_nav_cli(args: PackedStringArray) -> void:
|
|
|
|
|
if args.has("--minimap"):
|
|
|
|
|
m.nav.set_minimap_visible(true)
|
|
|
|
|
if args.has("--no-minimap"):
|
|
|
|
|
m.nav.set_minimap_visible(false)
|
Help: topics for every new feature, a cheat sheet, and Try a demo spreads
Twelve new Help topics (menus, selecting and resizing, nested groups,
themes, List view, the Book, rolling more than once, pausing, costs,
one table adjusting another, sheets and saving, pictures, phones), and a
Keyboard shortcuts topic split into keys, mouse and touch. Topics with
[demo]key[/demo] get a 'Try a demo spread' link: DemoSpreads builds a
small example, DemoMode shows it unsaved and unlisted with Keep a copy
and Back to my spread. --demo=KEY opens one from the command line.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 19:24:57 -06:00
|
|
|
var demo := _arg_value(args, "--demo")
|
|
|
|
|
if demo != "":
|
|
|
|
|
m.demo.open(demo)
|
2026-11-10 19:02:46 -06:00
|
|
|
if args.has("--book"):
|
|
|
|
|
m.book.set_shown(true)
|
Sheets phase B: main menu, Sheets list, sheet editor
- Main menu (Spreads, Sheets, Settings, Quit) on the theme background,
with recent spreads and sheets; logo or ☰ returns to it.
- Sheets: data model, store, templates, snapshot undo; New sheet dialog
(blank or a template); editor with folder tabs, snap-grid canvas on the
spread background, field palette, inspector, Play/Build, status strip.
- Field kinds: Number, Text box (BBCode, live {@name}), Heading.
- PaletteList shared by the card and field palettes; shared top bar brand.
- Keys go to the screen that shows; theme reloads keep the screen.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 15:53:56 -06:00
|
|
|
if args.has("--sheet-demo"):
|
|
|
|
|
# The example sheet in the Sheets screen; --sheet-build opens it in Build.
|
|
|
|
|
m.screens.show(MainScreens.SHEETS)
|
|
|
|
|
var sheet := SheetDemo.create()
|
|
|
|
|
m.screens.sheets.store.save(sheet)
|
|
|
|
|
m.screens.sheets.open_doc(sheet)
|
|
|
|
|
if args.has("--sheet-build"):
|
|
|
|
|
m.screens.sheets.editor.set_mode(Main.Mode.BUILD)
|
Sheets phase C: every field kind, details panel, canvas panning
- 25 palette items over 23 kinds: basics, trackers (bars, ticks, clocks,
dots, step/usage dice, ladders), formulas and dice buttons (rule
language with sheet @names), lists (rows, mini table, chips, point pool
that may go negative, bonds), slots, conditions, spell slots, XP,
currency, heading, divider, picture.
- Per-kind settings in the inspector; hover excerpts and an in-app
details panel for list entries; live redraw of dependent boxes.
- Canvas: the page stays put after edits (boxes can go anywhere), a
screen of room past the boxes, drag-to-pan and edge scrolling.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 16:28:04 -06:00
|
|
|
var sheet_tab := _arg_value(args, "--sheet-tab")
|
|
|
|
|
if sheet_tab != "":
|
|
|
|
|
m.screens.sheets.editor.show_tab(str(sheet.tabs[clampi(sheet_tab.to_int(), 0, sheet.tabs.size() - 1)]["id"]))
|
|
|
|
|
var select := _arg_value(args, "--sheet-select")
|
|
|
|
|
for tab in sheet.tabs:
|
|
|
|
|
for b: SheetBox in tab["boxes"]:
|
|
|
|
|
if select != "" and b.title == select:
|
|
|
|
|
m.screens.sheets.editor.select(b.id) if args.has("--sheet-build") else m.screens.sheets.editor.show_details(b.id, 0)
|
2026-11-29 16:52:41 -06:00
|
|
|
if args.has("--sheet-node"):
|
|
|
|
|
# The example sheet placed on the spread, as a Sheet card.
|
|
|
|
|
var placed := SheetDemo.create()
|
|
|
|
|
m.screens.sheets.store.save(placed)
|
|
|
|
|
m.sheet_links.add_card(placed.id, m.board.screen_to_world(m.board.size * Vector2(0.62, 0.3)))
|
Sheets phase B: main menu, Sheets list, sheet editor
- Main menu (Spreads, Sheets, Settings, Quit) on the theme background,
with recent spreads and sheets; logo or ☰ returns to it.
- Sheets: data model, store, templates, snapshot undo; New sheet dialog
(blank or a template); editor with folder tabs, snap-grid canvas on the
spread background, field palette, inspector, Play/Build, status strip.
- Field kinds: Number, Text box (BBCode, live {@name}), Heading.
- PaletteList shared by the card and field palettes; shared top bar brand.
- Keys go to the screen that shows; theme reloads keep the screen.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 15:53:56 -06:00
|
|
|
if args.has("--new-sheet"):
|
|
|
|
|
m.screens.show(MainScreens.SHEETS)
|
|
|
|
|
m.screens.sheets.store.save_as_template(SheetDemo.create(), "OSR Character")
|
|
|
|
|
m.screens.sheets.refresh()
|
|
|
|
|
m.screens.sheets.open_new_sheet()
|
2026-11-10 18:50:32 -06:00
|
|
|
if args.has("--list"):
|
|
|
|
|
m.list_view.set_shown(true)
|
Split ui/main.gd into area helpers (no behaviour change)
Main (3679 lines) becomes a shell: shared state, start-up, cards, input,
rules view and one-line delegators for the methods other files call. Each
area moves with its state into a RefCounted helper holding a back-reference
(m: Main):
main_cli.gd command-line and screenshot flags
main_top_bar.gd top bar, toast, endless-loop chip
main_editing.gd add/delete cards, results and pipes, selection bar
main_groups.gd groups and card drags
main_templates.gd templates
main_rolling.gd rolling, choice questions, playback, session seed, copy
main_collections.gd collections, import/export, table settings, test board
main_state.gd decks, variables, roll history (local state)
main_navigation.gd search, focus, minimap, arrange/pack
main_history.gd undo/redo and mark_dirty
main_inspector.gd inspector selection and refresh
Tests that reached moved private members now go through the helper
(main.undo_redo.edits, main.rolling.pending_choice(), ...).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:14:19 -06:00
|
|
|
if args.has("--pack"):
|
|
|
|
|
await m.nav.pack_collapsed_groups()
|
|
|
|
|
var f := _arg_value(args, "--focus")
|
|
|
|
|
if f != "":
|
|
|
|
|
await m.get_tree().process_frame
|
|
|
|
|
m.focus_table(f.get_slice(":", 0), f.get_slice(":", 1) if f.contains(":") else "")
|
|
|
|
|
var q := _arg_value(args, "--search")
|
|
|
|
|
if q != "":
|
|
|
|
|
await m.get_tree().process_frame
|
|
|
|
|
var p := m.nav.open_search()
|
|
|
|
|
p.field.text = q
|
|
|
|
|
p.refresh()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ----- Undo screenshot flags -----
|
|
|
|
|
# --undo-demo=<table id> delete that table (or the last one), then undo: the toast says so
|
|
|
|
|
# --undo-tooltip make an edit, then hover the Undo button so its tooltip shows
|
|
|
|
|
|
|
|
|
|
func _run_undo_cli(args: PackedStringArray) -> void:
|
|
|
|
|
var demo := _arg_value(args, "--undo-demo")
|
|
|
|
|
if args.has("--undo-demo") or demo != "":
|
|
|
|
|
m.set_mode(Main.Mode.BUILD)
|
|
|
|
|
var t: RollTable = m.data.get_table(demo) if demo != "" else (m.data.tables.back() if not m.data.tables.is_empty() else null)
|
|
|
|
|
if t:
|
|
|
|
|
m.delete_table(t.id)
|
|
|
|
|
await m.get_tree().process_frame
|
|
|
|
|
m.undo_redo.undo()
|
|
|
|
|
if args.has("--undo-tooltip"):
|
|
|
|
|
m.set_mode(Main.Mode.BUILD)
|
|
|
|
|
if not m.data.tables.is_empty():
|
|
|
|
|
m.delete_table(m.data.tables.back().id)
|
|
|
|
|
m.top_bar._toast.hide()
|
|
|
|
|
for i in 3:
|
|
|
|
|
await m.get_tree().process_frame
|
|
|
|
|
var at := m.undo_redo._undo_button.get_global_rect().get_center()
|
|
|
|
|
m.get_viewport().notification(Control.NOTIFICATION_VP_MOUSE_ENTER)
|
|
|
|
|
for i in 2:
|
|
|
|
|
var ev := InputEventMouseMotion.new()
|
|
|
|
|
ev.position = at + Vector2(i, 0)
|
|
|
|
|
ev.global_position = ev.position
|
|
|
|
|
m.get_viewport().push_input(ev)
|
|
|
|
|
await m.get_tree().process_frame
|