- CardCatalog: one list of card kinds for the palette, right-click New card and new-card names; Dice table and Deck are their own items. - LeftDock holds the palette and List view in the shared dock tab style. - Play greys the palette under a Switch to Build notice (replaces the greyed + Card button); + Card menu removed; Card palette button in Build. - Templates dropped from the palette land where they are let go. - Phones: + opens the palette full screen. - docs/SHEETS.md: the Sheets and unified editor plan. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
108 lines
3 KiB
GDScript
108 lines
3 KiB
GDScript
class_name LeftDock
|
||
extends PanelContainer
|
||
## The left-hand dock with two tabs, "Cards | List" (the same tab style as the
|
||
## right dock's "Inspector | Lore Index", SideTabs.tab_row). Cards is the card
|
||
## palette (CardPalette); List is List view (ListView). On phones the dock
|
||
## fills the screen and swaps with the spread (MobileLayout).
|
||
## The local setting `left_dock` keeps the open tab ("" = closed).
|
||
|
||
const WIDTH := 320.0
|
||
const MIN_WIDTH := 220.0
|
||
const SETTING := "left_dock"
|
||
const CARDS := "cards"
|
||
const LIST := "list"
|
||
|
||
var m: Main
|
||
var splitter: PanelSplitter
|
||
var palette: CardPalette
|
||
var list: ListView
|
||
var close_button: Button
|
||
var tab := CARDS
|
||
var _tabs: HBoxContainer
|
||
|
||
|
||
func setup(p_main: Main) -> void:
|
||
m = p_main
|
||
add_theme_stylebox_override("panel", Style.panel_box([10, 10, 10, 10]))
|
||
var col := VBoxContainer.new()
|
||
col.add_theme_constant_override("separation", 8)
|
||
add_child(col)
|
||
var head := HBoxContainer.new()
|
||
head.add_theme_constant_override("separation", 6)
|
||
col.add_child(head)
|
||
_tabs = SideTabs.tab_row([[CARDS, "Cards"], [LIST, "List"]], tab, show_tab)
|
||
_tabs.size_flags_horizontal = SIZE_EXPAND_FILL
|
||
head.add_child(_tabs)
|
||
close_button = Style.bar_button("×")
|
||
close_button.tooltip_text = "Close this panel (View ▾ opens it again)"
|
||
close_button.pressed.connect(hide_dock)
|
||
head.add_child(close_button)
|
||
palette = CardPalette.new()
|
||
palette.setup(m)
|
||
palette.size_flags_vertical = SIZE_EXPAND_FILL
|
||
col.add_child(palette)
|
||
list = ListView.new()
|
||
list.setup(m)
|
||
list.size_flags_vertical = SIZE_EXPAND_FILL
|
||
col.add_child(list)
|
||
|
||
|
||
func set_width(px: float) -> void:
|
||
custom_minimum_size.x = px
|
||
|
||
|
||
## The tab open when the app starts. First run: Cards, so new players see where
|
||
## cards come from. Older settings that only kept "List view on" open List.
|
||
func restore() -> void:
|
||
var saved: Variant = m.state.get_setting(SETTING, null) if m.state else null
|
||
if saved == null:
|
||
var old_list := m.state != null and bool(m.state.get_setting(ListView.SETTING, false))
|
||
saved = LIST if old_list else CARDS
|
||
if str(saved) == "":
|
||
_show(false, tab)
|
||
else:
|
||
_show(true, LIST if str(saved) == LIST else CARDS)
|
||
|
||
|
||
## True when the dock is open on `which`.
|
||
func showing(which: String) -> bool:
|
||
return visible and tab == which
|
||
|
||
|
||
func show_tab(which: String) -> void:
|
||
_show(true, which)
|
||
_remember()
|
||
|
||
|
||
func hide_dock() -> void:
|
||
_show(false, tab)
|
||
_remember()
|
||
|
||
|
||
## Opens `which`, or closes the dock when it is already showing.
|
||
func toggle_tab(which: String) -> void:
|
||
if showing(which):
|
||
hide_dock()
|
||
else:
|
||
show_tab(which)
|
||
|
||
|
||
func _show(on: bool, which: String) -> void:
|
||
tab = which
|
||
visible = on
|
||
if splitter:
|
||
splitter.visible = on and not (m.mobile != null)
|
||
palette.visible = which == CARDS
|
||
list.visible = which == LIST
|
||
SideTabs.press(_tabs, which)
|
||
list._rev = -1
|
||
if on and which == CARDS:
|
||
palette.refresh_templates()
|
||
if m.top_bar.palette_button:
|
||
m.top_bar.palette_button.set_pressed_no_signal(showing(CARDS))
|
||
|
||
|
||
func _remember() -> void:
|
||
if m.state and m.mobile == null:
|
||
m.state.set_setting(SETTING, tab if visible else "")
|
||
m.state.save()
|