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
class_name SheetsScreen
extends PanelContainer
## The Sheets screen: your sheets and sheet templates as lists, "+ New sheet"
## (NewSheetDialog), and the sheet editor (SheetEditor) once one is open.
## Sheets live in user://sheets/ (SheetStore). When the app isn't saving
## (--sample, tests) they go to a scratch folder that starts empty.
const SCRATCH : = " user://scratch_sheets/ "
var m : Main
var store : SheetStore
Sheets phase E: export/import, text toolbar and Lore links, Lore library and items, phone view
- E1: Export ▾ (share file with embedded pictures, print/PDF web page,
PNG of the tab); Import a sheet file from Sheets and New sheet.
- E2: formatting toolbar (FormatMenu) in sheet text boxes; Lore links
([url=lore:ID]) with hover excerpt and the details panel.
- E3: Lore Index in Play and in sheets (shared LoreList); This spread |
My library; item sheets on Lore Entries; drag entries into lists,
slots and notes (copy, Shift keeps linked).
- E4: phone stacked view in phone order, Stacked | Canvas switch, 44 px
touch sizes, bottom panels; sheet CLI flags split out.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 17:25:09 -06:00
## "My library": the shared Lore Index level, beside the sheets (same root).
var library : LoreLibrary
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
var editor : SheetEditor
var list_page : VBoxContainer
2026-11-29 16:52:41 -06:00
var scratch : = SCRATCH
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
var _sheet_rows : VBoxContainer
var _template_rows : VBoxContainer
func setup ( p_main : Main ) - > void :
m = p_main
set_anchors_and_offsets_preset ( Control . PRESET_FULL_RECT )
add_theme_stylebox_override ( " panel " , Style . box ( Style . BG_DEEP , 0 , [ 0 , 0 , 0 , 0 ] ) )
if m . _saving_enabled :
store = SheetStore . new ( )
else :
2026-11-29 16:52:41 -06:00
# One scratch folder per process: test workers run side by side.
scratch = SCRATCH . path_join ( str ( OS . get_process_id ( ) ) )
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
_wipe_scratch ( )
2026-11-29 16:52:41 -06:00
store = SheetStore . new ( scratch )
Sheets phase E: export/import, text toolbar and Lore links, Lore library and items, phone view
- E1: Export ▾ (share file with embedded pictures, print/PDF web page,
PNG of the tab); Import a sheet file from Sheets and New sheet.
- E2: formatting toolbar (FormatMenu) in sheet text boxes; Lore links
([url=lore:ID]) with hover excerpt and the details panel.
- E3: Lore Index in Play and in sheets (shared LoreList); This spread |
My library; item sheets on Lore Entries; drag entries into lists,
slots and notes (copy, Shift keeps linked).
- E4: phone stacked view in phone order, Stacked | Canvas switch, 44 px
touch sizes, bottom panels; sheet CLI flags split out.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 17:25:09 -06:00
library = LoreLibrary . new ( store . root )
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
var stack : = Control . new ( )
add_child ( stack )
list_page = _make_list_page ( )
list_page . set_anchors_and_offsets_preset ( Control . PRESET_FULL_RECT )
stack . add_child ( list_page )
editor = SheetEditor . new ( )
editor . setup ( m , self )
editor . set_anchors_and_offsets_preset ( Control . PRESET_FULL_RECT )
editor . visible = false
stack . add_child ( editor )
func enter ( ) - > void :
if not editor . visible :
refresh ( )
func leave ( ) - > void :
editor . save_now ( )
func _make_list_page ( ) - > VBoxContainer :
var page : = VBoxContainer . new ( )
page . add_theme_constant_override ( " separation " , 0 )
var bar : = PanelContainer . new ( )
bar . add_theme_stylebox_override ( " panel " , Style . panel_box ( [ 16 , 10 , 16 , 10 ] ) )
page . add_child ( bar )
var head : = HBoxContainer . new ( )
head . add_theme_constant_override ( " separation " , 12 )
bar . add_child ( head )
head . add_child ( MainTopBar . make_brand ( func ( ) - > void : m . screens . show ( MainScreens . MENU ) ) )
var where : = Style . make_label ( " Sheets " , Style . body ( ) , 15 , Style . ON_BG_MUTED )
where . size_flags_horizontal = SIZE_EXPAND_FILL
head . add_child ( where )
Sheets phase E: export/import, text toolbar and Lore links, Lore library and items, phone view
- E1: Export ▾ (share file with embedded pictures, print/PDF web page,
PNG of the tab); Import a sheet file from Sheets and New sheet.
- E2: formatting toolbar (FormatMenu) in sheet text boxes; Lore links
([url=lore:ID]) with hover excerpt and the details panel.
- E3: Lore Index in Play and in sheets (shared LoreList); This spread |
My library; item sheets on Lore Entries; drag entries into lists,
slots and notes (copy, Shift keeps linked).
- E4: phone stacked view in phone order, Stacked | Canvas switch, 44 px
touch sizes, bottom panels; sheet CLI flags split out.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 17:25:09 -06:00
var import_button : = Style . bar_button ( " Import… " )
import_button . name = " ImportSheet "
import_button . tooltip_text = " Add a sheet from a share file someone sent you "
import_button . pressed . connect ( import_sheet )
head . add_child ( import_button )
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
var add : = Style . bar_button ( " + New sheet " , true )
add . name = " NewSheet "
add . pressed . connect ( open_new_sheet )
head . add_child ( add )
var back : = Control . new ( )
back . size_flags_vertical = SIZE_EXPAND_FILL
var backdrop : = BoardBackdrop . new ( ThemeStore . current )
back . draw . connect ( func ( ) - > void : backdrop . draw ( back , Rect2 ( Vector2 . ZERO , back . size ) ) )
back . resized . connect ( back . queue_redraw )
page . add_child ( back )
var scroll : = ScrollContainer . new ( )
scroll . set_anchors_and_offsets_preset ( Control . PRESET_FULL_RECT )
scroll . horizontal_scroll_mode = ScrollContainer . SCROLL_MODE_DISABLED
back . add_child ( scroll )
var center : = HBoxContainer . new ( )
center . size_flags_horizontal = SIZE_EXPAND_FILL
center . alignment = BoxContainer . ALIGNMENT_CENTER
scroll . add_child ( center )
var col : = VBoxContainer . new ( )
col . custom_minimum_size . x = 900
col . add_theme_constant_override ( " separation " , 10 )
var margin : = MarginContainer . new ( )
for side in [ " left " , " right " , " top " , " bottom " ] :
margin . add_theme_constant_override ( " margin_ " + side , 32 )
margin . add_child ( col )
center . add_child ( margin )
col . add_child ( Style . make_label ( " Sheets " , Style . display ( ) , 40 , Style . ON_BG ) )
_sheet_rows = VBoxContainer . new ( )
_sheet_rows . add_theme_constant_override ( " separation " , 10 )
col . add_child ( _sheet_rows )
var gap : = Control . new ( )
gap . custom_minimum_size . y = 18
col . add_child ( gap )
col . add_child ( Style . make_label ( " Templates " , Style . display ( ) , 28 , Style . ON_BG ) )
_template_rows = VBoxContainer . new ( )
_template_rows . add_theme_constant_override ( " separation " , 10 )
col . add_child ( _template_rows )
return page
## Rebuilds both lists from the files.
func refresh ( ) - > void :
for rows : VBoxContainer in [ _sheet_rows , _template_rows ] :
for c in rows . get_children ( ) :
rows . remove_child ( c )
c . queue_free ( )
var sheets : = store . list ( )
for row : Dictionary in sheets :
var kind : = _template_name ( str ( row [ " from_template " ] ) ) if str ( row [ " from_template " ] ) != " " else " Blank "
_sheet_rows . add_child ( _row ( str ( row [ " name " ] ) , kind , " Standalone " , open_sheet . bind ( str ( row [ " id " ] ) ) , _delete . bind ( str ( row [ " id " ] ) , str ( row [ " name " ] ) , false ) ) )
if sheets . is_empty ( ) :
_sheet_rows . add_child ( _empty_note ( " No sheets yet. Press + New sheet to make one. " ) )
var templates : = store . list ( true )
for row : Dictionary in templates :
_template_rows . add_child ( _row ( str ( row [ " name " ] ) , " Template " , " New sheet from it " , open_new_sheet . bind ( str ( row [ " id " ] ) ) , _delete . bind ( str ( row [ " id " ] ) , str ( row [ " name " ] ) , true ) ) )
if templates . is_empty ( ) :
_template_rows . add_child ( _empty_note ( " No templates yet. In a sheet, press Save as template… in the top bar. " ) )
func _template_name ( id : String ) - > String :
var doc : = store . load_sheet ( id , true )
return doc . name if doc else id
## A whole-row button: "Name · kind" on the left, `where` on the right, ⋯ to delete.
func _row ( title : String , kind : String , where : String , on_open : Callable , on_delete : Callable ) - > Button :
var b : = Button . new ( )
b . name = title . validate_node_name ( )
b . focus_mode = Control . FOCUS_NONE
b . custom_minimum_size = Vector2 ( 0 , 50 )
Style . skin_button ( b , Style . box ( Style . CARD , 8 , [ 14 , 12 , 14 , 12 ] ) , Style . box ( Style . CARD_HOVER , 8 , [ 14 , 12 , 14 , 12 ] ) ,
Style . box ( Style . CARD_HOVER , 8 , [ 14 , 12 , 14 , 12 ] ) , Style . INK )
b . pressed . connect ( on_open )
var h : = HBoxContainer . new ( )
h . set_anchors_and_offsets_preset ( Control . PRESET_FULL_RECT )
h . offset_left = 14
h . offset_right = - 8
h . add_theme_constant_override ( " separation " , 6 )
h . mouse_filter = Control . MOUSE_FILTER_IGNORE
b . add_child ( h )
var name_label : = Style . make_label ( title , Style . body_bold ( ) , 15 , Style . INK )
name_label . size_flags_vertical = SIZE_SHRINK_CENTER
h . add_child ( name_label )
var kind_label : = Style . make_label ( " · " + kind , Style . body ( ) , 15 , Style . INK )
kind_label . size_flags_horizontal = SIZE_EXPAND_FILL
kind_label . size_flags_vertical = SIZE_SHRINK_CENTER
h . add_child ( kind_label )
var where_label : = Style . make_label ( where , Style . body ( ) , 14 , Style . MUTED )
where_label . size_flags_vertical = SIZE_SHRINK_CENTER
h . add_child ( where_label )
var more : = Style . overflow_button ( " More " )
more . name = " More "
Actions . fill ( more . get_popup ( ) , [ { " text " : " Open " if where == " Standalone " else " New sheet from it " , " do " : on_open } , { " text " : " Delete… " , " do " : on_delete } ] )
h . add_child ( more )
return b
func _empty_note ( text : String ) - > Label :
var l : = Style . make_label ( text , Style . body ( ) , 15 , Style . ON_BG_MUTED )
l . autowrap_mode = TextServer . AUTOWRAP_WORD_SMART
return l
## "+ New sheet": asks for a name and a start (blank or a template).
2026-11-29 16:52:41 -06:00
## `on_made` gets the new sheet instead of opening it (the card palette
Sheets phase E: export/import, text toolbar and Lore links, Lore library and items, phone view
- E1: Export ▾ (share file with embedded pictures, print/PDF web page,
PNG of the tab); Import a sheet file from Sheets and New sheet.
- E2: formatting toolbar (FormatMenu) in sheet text boxes; Lore links
([url=lore:ID]) with hover excerpt and the details panel.
- E3: Lore Index in Play and in sheets (shared LoreList); This spread |
My library; item sheets on Lore Entries; drag entries into lists,
slots and notes (copy, Shift keeps linked).
- E4: phone stacked view in phone order, Stacked | Canvas switch, 44 px
touch sizes, bottom panels; sheet CLI flags split out.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 17:25:09 -06:00
## places it on the spread). The dialog can also import a sheet file.
2026-11-29 16:52:41 -06:00
func open_new_sheet ( template_id : String = " " , on_made : Callable = Callable ( ) ) - > void :
Sheets phase E: export/import, text toolbar and Lore links, Lore library and items, phone view
- E1: Export ▾ (share file with embedded pictures, print/PDF web page,
PNG of the tab); Import a sheet file from Sheets and New sheet.
- E2: formatting toolbar (FormatMenu) in sheet text boxes; Lore links
([url=lore:ID]) with hover excerpt and the details panel.
- E3: Lore Index in Play and in sheets (shared LoreList); This spread |
My library; item sheets on Lore Entries; drag entries into lists,
slots and notes (copy, Shift keeps linked).
- E4: phone stacked view in phone order, Stacked | Canvas switch, 44 px
touch sizes, bottom panels; sheet CLI flags split out.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 17:25:09 -06:00
var on_create : = func ( name : String , tpl : String ) - > void :
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
var doc : = store . create ( name , tpl )
2026-11-29 16:52:41 -06:00
if on_made . is_valid ( ) :
on_made . call ( doc )
else :
Sheets phase E: export/import, text toolbar and Lore links, Lore library and items, phone view
- E1: Export ▾ (share file with embedded pictures, print/PDF web page,
PNG of the tab); Import a sheet file from Sheets and New sheet.
- E2: formatting toolbar (FormatMenu) in sheet text boxes; Lore links
([url=lore:ID]) with hover excerpt and the details panel.
- E3: Lore Index in Play and in sheets (shared LoreList); This spread |
My library; item sheets on Lore Entries; drag entries into lists,
slots and notes (copy, Shift keeps linked).
- E4: phone stacked view in phone order, Stacked | Canvas switch, 44 px
touch sizes, bottom panels; sheet CLI flags split out.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 17:25:09 -06:00
open_doc ( doc )
m . _add_modal ( NewSheetDialog . new ( store , template_id , on_create , import_sheet . bind ( on_made ) ) )
## "Import a sheet file…": asks for a share file (SheetFile), saves it as a
## new sheet and opens it (or hands it to `on_made`, as above).
func import_sheet ( on_made : Callable = Callable ( ) ) - > void :
m . layout . file_dialog ( " Import a sheet file " , [ SheetFile . FILTER ] , FileDialog . FILE_MODE_OPEN_FILE , func ( path : String ) - > void :
var doc : = SheetFile . import_path ( store , path )
if doc == null :
m . toast ( " That isn ' t a sheet file " )
return
m . toast ( " Imported “ %s ” " % doc . name )
if on_made . is_valid ( ) :
on_made . call ( doc )
else :
open_doc ( doc ) )
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
func open_sheet ( id : String ) - > void :
var doc : = store . load_sheet ( id )
if doc == null :
m . toast ( " Couldn ' t read that sheet " )
refresh ( )
return
open_doc ( doc )
func open_doc ( doc : SheetDoc ) - > void :
editor . open ( doc )
list_page . visible = false
editor . visible = true
## Closes the editor (saving) and shows the lists.
func show_list ( ) - > void :
editor . close ( )
editor . visible = false
list_page . visible = true
refresh ( )
func _delete ( id : String , name : String , templates : bool ) - > void :
var what : = " template " if templates else " sheet "
m . _add_modal ( ModalCard . confirm ( " Delete %s ? " % what , " Delete the %s “ %s ”? This can ' t be undone. " % [ what , name ] , " Delete " , func ( ) - > void :
store . delete ( id , templates )
refresh ( ) , true ) )
func _wipe_scratch ( ) - > void :
Sheets phase E: export/import, text toolbar and Lore links, Lore library and items, phone view
- E1: Export ▾ (share file with embedded pictures, print/PDF web page,
PNG of the tab); Import a sheet file from Sheets and New sheet.
- E2: formatting toolbar (FormatMenu) in sheet text boxes; Lore links
([url=lore:ID]) with hover excerpt and the details panel.
- E3: Lore Index in Play and in sheets (shared LoreList); This spread |
My library; item sheets on Lore Entries; drag entries into lists,
slots and notes (copy, Shift keeps linked).
- E4: phone stacked view in phone order, Stacked | Canvas switch, 44 px
touch sizes, bottom panels; sheet CLI flags split out.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 17:25:09 -06:00
DirAccess . remove_absolute ( scratch . path_join ( LoreLibrary . FILE ) )
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
for templates : bool in [ false , true ] :
2026-11-29 16:52:41 -06:00
var dir : = scratch . path_join ( SheetStore . TEMPLATES if templates else SheetStore . SHEETS )
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 DirAccess . dir_exists_absolute ( dir ) :
for file in DirAccess . get_files_at ( dir ) :
DirAccess . remove_absolute ( dir . path_join ( file ) )