TGUI Forum

General Category => Help requests => Topic started by: Heinrich on 09 October 2014, 13:59:07

Title: 0.7 Strategy on multiple tgui::GUI objects
Post by: Heinrich 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).
Title: Re: 0.7 Strategy on multiple tgui::GUI objects
Post by: texus 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.