Changing values in nifty gui

Hi,

How can I change the value of a certain element in my gui at runtime without always having to iterate through the whole screen element?



Another question: Assume I have a screen which shows a menue with buttons for settings, singleplayer, multiplayer, quit etc. Would I create a seperate screen for each submenue or just another layer?

a) Save a reference to the screen element once instead of getting it each time

b) Depends but I’d say a layer should work as well

pk123 said:
Hi,
How can I change the value of a certain element in my gui at runtime without always having to iterate through the whole screen element?

Nifty offers findNiftyControl(...) or findElementByID(...) methods. Not sure if that's what you're asking. Unless you have hundreds and hundreds of elements within your screen iterating through the screen shouldn't be a performance problem.


Another question: Assume I have a screen which shows a menu with buttons for settings, singleplayer, multiplayer, quit etc. Would I create a seperate screen for each submenu or just another layer?

You definitively don't want to segregate each button screen to a different screen. The best way to do this is to use either a popup or an "absolute" layer or a plain layer/panel. There are other ways but I find those two to be the best.

By using a popup you can bring that menu up/close it whenever the user hits ESC for example so this would always be accessible within the same screen. By having that in a popup you can also easily "port" it (copy/paste it) to other screens if you have several. Only the popup methods would also have to be copied.

One way you could do this is:

When user click on "Settings", you close that popup, bring the "Settings" popup. When user click "Close" on the settings popup, you do your stuff (save, apply, whatever) then close that popup and bring back the first popup (or alternatively bring the game back), so on and so forth for each button's actions.

This is a simple matter of preferences. I personally try to do things in a standardized fashion while trying to stay original. So, in short, it's up to you how you'll implement your interface.

The usage of popups sounds like a good idea, I’ll give it a try. Thank you.