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 const ID_BOOK := 7 const ID_SOUND := 8 const ID_CONFIRM_DELETE := 9 const ID_SKIP_ANIM := 10 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.add_check_item("Lore Index", ID_BOOK) pm.add_check_item("Ask before deleting", ID_CONFIRM_DELETE) pm.set_item_tooltip(pm.get_item_index(ID_CONFIRM_DELETE), "The Delete key asks “Are you sure?” first") pm.add_check_item("Skip animations", ID_SKIP_ANIM) pm.set_item_tooltip(pm.get_item_index(ID_SKIP_ANIM), "Rolls show their result at once, with no flicker, beads or pop-up motion.\nShift-click a die to skip them for one roll.") pm.set_item_tooltip(pm.get_item_index(ID_BOOK), "Reusable results (Lore Entries) to drag onto tables") pm.set_item_tooltip(pm.get_item_index(ID_LIST), "The cards as a list with their groups, 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.add_item("Sound…", ID_SOUND) pm.set_item_tooltip(pm.get_item_index(ID_SOUND), "How loud the theme's sounds are") 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) pm.set_item_checked(pm.get_item_index(ID_BOOK), m.book.visible) pm.set_item_checked(pm.get_item_index(ID_CONFIRM_DELETE), DeleteKey.asks(m)) pm.set_item_checked(pm.get_item_index(ID_SKIP_ANIM), SkipAnimations.on(m)) 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_BOOK: m.book.toggle() ID_THEME: m.add_child(ThemeDialog.new(m)) ID_CONFIRM_DELETE: DeleteKey.set_asks(m, not DeleteKey.asks(m)) ID_SKIP_ANIM: SkipAnimations.set_on(m, not SkipAnimations.on(m)) ID_SOUND: SoundPanel.open(m, get_global_rect().position + Vector2(0, size.y + 4))