26 lines
716 B
GDScript3
26 lines
716 B
GDScript3
|
|
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 TableTower (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
|