TableTower/ui/help_menu.gd

26 lines
717 B
GDScript3
Raw Normal View History

class_name HelpMenu
extends MenuButton
## The top bar's "Help ▾" menu: one item per help topic, each opening the
## Help window at that topic. F1 opens it at the first topic.
var m: Main
func setup(p_main: Main) -> void:
m = p_main
Style.menu_button("Help ▾", false, self)
tooltip_text = "How to use Table Tarot (F1)"
var pm := get_popup()
ModalCard.style_popup(pm)
var titles := HelpDialog.titles()
for i in titles.size():
pm.add_item(titles[i], i)
pm.id_pressed.connect(func(id: int) -> void: open(titles[id]))
## Opens the Help window at `topic` (the first topic when blank) and returns it.
func open(topic: String = "") -> HelpDialog:
var d := HelpDialog.new(topic)
m._add_modal(d)
return d