class_name SideTabs extends RefCounted ## In Build, the Inspector and the Lore Index share the right-hand dock as two ## tabs ("Inspector | Lore Index"); only one shows at a time. In Play there is ## no inspector, so the Lore Index opens on its own (no tab row). ## The Lore Index is BookPanel in code (TowerBoard.book, BookPage). const INSPECTOR := "inspector" const LORE := "lore" ## The tab row put at the top of both panels. `active` is the panel it sits on. static func make_row(m: Main, active: String) -> HBoxContainer: var row := HBoxContainer.new() row.add_theme_constant_override("separation", 4) for tab: Array in [[INSPECTOR, "Inspector"], [LORE, "Lore Index"]]: var b := Button.new() b.text = tab[1] b.toggle_mode = true b.button_pressed = tab[0] == active b.focus_mode = Control.FOCUS_NONE b.size_flags_horizontal = Control.SIZE_EXPAND_FILL b.add_theme_font_override("font", Style.body_bold()) b.add_theme_font_size_override("font_size", 14) var normal := Style.box(Color(0, 0, 0, 0.06), 6, [10, 5, 10, 5]) var hover := Style.box(Color(0, 0, 0, 0.12), 6, [10, 5, 10, 5]) var on := Style.bordered(Style.box(Style.CARD, 6, [10, 5, 10, 5]), 2, Style.TRIM) Style.skin_button(b, normal, hover, on, Style.MUTED, Style.INK, Style.INK) var which: String = tab[0] b.pressed.connect(func() -> void: show_tab(m, which)) row.add_child(b) return row ## Shows one tab. The Lore Index tab opens the Lore Index; the Inspector tab closes it. static func show_tab(m: Main, which: String) -> void: if m.book: m.book.set_shown(which == LORE) ## Brings the dock in line with the mode: in Build an open Lore Index hides the ## inspector; in Play the inspector is always hidden. static func sync(m: Main) -> void: if m.inspector == null or m.book == null: return var build := m.mode == Main.Mode.BUILD m.inspector.visible = build and not m.book.visible m.inspector._sync_splitter() m.book.show_tabs(build)