- A Sheet card can show a sheet file (sheet, prefix): first-tab preview, Open sheet with a way back, the spread's Play/Build in the editor. - Rolls read and write "Use in tables" boxes as @name or @prefix_name; locked boxes and formulas/lists keep their values; changed boxes glow. - A roll reaching the card shows the sheet's text (SheetText) in the tray; text boxes also show spread values when on the spread. - Old template Sheet cards migrate to a sheet with one text box (not in Help demos). Card palette lists your sheets. - Sheet canvas: tiled grid (smooth panning); boxes no longer overlap (nearest free spot, drags stop short; Alt places freely). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
78 lines
2.1 KiB
GDScript
78 lines
2.1 KiB
GDScript
class_name MainScreens
|
|
extends RefCounted
|
|
## Which full-window screen shows: the main menu (MainMenu), the spread
|
|
## editor (Main's own top bar, board and tray) or Sheets (SheetsScreen).
|
|
## Real use starts on the main menu; tests, --sample and screenshots start
|
|
## on the spread unless --menu or --sheets is given.
|
|
|
|
const MENU := "menu"
|
|
const SPREAD := "spread"
|
|
const SHEETS := "sheets"
|
|
|
|
var m: Main
|
|
var spread_root: Control
|
|
var menu: MainMenu
|
|
var sheets: SheetsScreen
|
|
var current := SPREAD
|
|
## Kept across a theme change (which reloads the app): the screen to come back
|
|
## to and the sheet that was open. Empty = start as usual.
|
|
static var resume := {}
|
|
|
|
|
|
func _init(p_main: Main) -> void:
|
|
m = p_main
|
|
|
|
|
|
## Called once the spread editor is built (`root` is its top-level box).
|
|
func setup(root: Control) -> void:
|
|
spread_root = root
|
|
menu = MainMenu.new()
|
|
menu.setup(m)
|
|
menu.visible = false
|
|
m.add_child(menu)
|
|
sheets = SheetsScreen.new()
|
|
sheets.setup(m)
|
|
sheets.visible = false
|
|
m.add_child(sheets)
|
|
|
|
|
|
func show(which: String) -> void:
|
|
if which == current:
|
|
return
|
|
if current == SHEETS:
|
|
sheets.leave()
|
|
current = which
|
|
spread_root.visible = which == SPREAD
|
|
menu.visible = which == MENU
|
|
sheets.visible = which == SHEETS
|
|
if which == SHEETS:
|
|
sheets.enter()
|
|
if which == SPREAD:
|
|
m.sheet_links.refresh_previews()
|
|
|
|
|
|
func showing(which: String) -> bool:
|
|
return current == which
|
|
|
|
|
|
## Where the app opens: back where it was after a theme change; otherwise the
|
|
## main menu in real use, the spread for tests and screenshots (--menu and
|
|
## --sheets pick a screen).
|
|
func start(args: PackedStringArray) -> void:
|
|
if not resume.is_empty():
|
|
var back := resume
|
|
resume = {}
|
|
show(str(back.get("screen", MENU)))
|
|
if str(back.get("sheet", "")) != "":
|
|
sheets.open_sheet(str(back["sheet"]))
|
|
return
|
|
if args.has("--sheets"):
|
|
show(SHEETS)
|
|
elif args.has("--menu") or m._saving_enabled:
|
|
show(MENU)
|
|
|
|
|
|
## Remembers the screen (and open sheet) before the app reloads for a theme.
|
|
func keep_for_reload() -> void:
|
|
sheets.leave()
|
|
resume = {"screen": current, "sheet": sheets.editor.doc.id if current == SHEETS and sheets.editor.doc else ""}
|