Godot Version
v4.3.stable.official [77dcf97d8]
Question
What's the best way to create Menus with many Sub-Menus?
I prototyped a project that lets me simulate a browser so I can click buttons and links to access various subpages and go back to the page I clicked from.
I achieved this by hiding/unhiding nodes from button signals, this isn’t very efficient and is pretty tedious so what would be the best way to manage so many pages and subpages and their respective “return” buttons?
The script was a long list of button functions so that wasn’t the best way, any tips would be appreciated, thanks
If you need more details to understand my situation, ask away
wdym with “submenus”. Try the “window” node and use $window.queue_free() to delete the window. if u want to create a window do window.new(). if u want to create a child of a window do $window.add_child(label.new())
Have each page as its own scene.
Use a global ‘page_history’ autoload to keep a dictionary of pages visited. When the back button is pressed, use the list to find the previous page. Queue free the current page and load the new page, then amend the dictionary appropriately. Just like a browser, except instead of http requests you are loading scenes into your parent browser scene.
That could work very nicely I think.
EDIT: Just reread your question, which does not seem to match the question title. As for ‘return’ buttons on the actual page, when you load them send them the node reference of the referring page. Use that reference on the loaded page for the return button. That would work nicely too.
2nd Edit: For many children, you could combine both of the above methods, so that a history of ‘return’ pages is kept. You could also use this to make a page-trail from all the dictionary entries too.
1 Like