0.7 Strategy on multiple tgui::GUI objects
« on: 09 October 2014, 13:59:07 »
Are there pitfalls on having multiple GUI objects? Or is it recommended to have one and only one GUI object (and access it via Singleton or something).



  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: 0.7 Strategy on multiple tgui::GUI objects
« Reply #1 on: 09 October 2014, 15:26:36 »
You are not meant to use multiple Gui objects (at least not on the same window).

If you would, each would have its own list of widgets and you have to call handleEvent and draw on the correct gui. So this is only good for when you have multiple windows as well.

In order to have multiple screens in a single window, you should use the Panel widget. You create several panels, each for the different game states. Then you hide all of them except one. When changing state, you just hide the visible panel and show another one.