TableTower/ui/view_menu.gd
RobinFiredrake 0ede1d7cd1 List view: the spread as a list with folders
A left-docked panel (View ▾ → List view, ☰ or right-click the spread)
lists every card, with groups as folders. Rows show threads in and out
(hover for where they lead) and a Roll cell; click selects in Build,
double-click shows the card on the spread, right-click opens its menu.
Drag to reorder (the spread's own order, saved and undoable), onto a
folder to move in, folder into folder to nest. Own search, + Folder,
resizable edge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 18:50:32 -06:00

73 lines
2.6 KiB
GDScript

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, the minimap and the theme.
## These are view preferences, so they live in one menu instead of the bar.
const ID_PLAIN := 0
const ID_TEXT := 1
const ID_COLLAPSE := 2
const ID_STRIPES := 3
const ID_MINIMAP := 4
const ID_THEME := 5
const ID_LIST := 6
var m: Main
func setup(p_main: Main) -> void:
m = p_main
Style.menu_button("View ▾", false, self)
tooltip_text = "How rules read, collapsing tables, striped rows and the minimap"
var pm := get_popup()
ModalCard.style_popup(pm)
pm.add_separator("Rules")
pm.add_radio_check_item("Plain words", ID_PLAIN)
pm.set_item_tooltip(pm.get_item_index(ID_PLAIN), "Show rules in plain words: “Subtract 1 from Luck”")
pm.add_radio_check_item("Rule text", ID_TEXT)
pm.set_item_tooltip(pm.get_item_index(ID_TEXT), "Show rules as the text they're stored as: @luck -= 1")
pm.add_separator("Tables")
pm.add_item("Collapse all tables", ID_COLLAPSE)
pm.add_separator("Show")
pm.add_check_item("Striped rows", ID_STRIPES)
pm.add_check_item("Minimap (M)", ID_MINIMAP)
pm.add_check_item("List view", ID_LIST)
pm.set_item_tooltip(pm.get_item_index(ID_LIST), "The cards as a list with folders, beside the spread")
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)
## Brings the checks and the Collapse/Expand label up to date.
func sync() -> void:
var pm := get_popup()
pm.set_item_checked(pm.get_item_index(ID_PLAIN), m.rules_plain())
pm.set_item_checked(pm.get_item_index(ID_TEXT), not m.rules_plain())
pm.set_item_text(pm.get_item_index(ID_COLLAPSE), collapse_label())
pm.set_item_checked(pm.get_item_index(ID_STRIPES), m.local_state.striped_rows())
pm.set_item_checked(pm.get_item_index(ID_MINIMAP), m.board.minimap.visible)
pm.set_item_checked(pm.get_item_index(ID_LIST), m.list_view.visible)
func collapse_label() -> String:
return "Collapse all tables" if m._any_expanded() else "Expand all tables"
func activate(id: int) -> void:
match id:
ID_PLAIN:
m.set_rules_view("plain")
ID_TEXT:
m.set_rules_view("text")
ID_COLLAPSE:
m.set_all_collapsed(m._any_expanded())
ID_STRIPES:
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_LIST:
m.list_view.toggle()
ID_THEME:
m.add_child(ThemeDialog.new(m))