Was wondering if someone could help me get my resolution selection drop down to work. When I step through the code in the debugger, I can see that 17 items are added to the dropdown’s items. But they dont show up, even if I select one myself. The strings are non zero length.
Yes I know jMonkeyEngine has a built in settings dialog, I prefer to use internal settings from a look and feel point of view. Here is a screenshot, WIP obviously.
The TextColor effect - it doesnt seem to work. Doesnt change the colour of the text. As you can see, the font I use allows for its colour to be changed.
Also, what is the recommended way for changing GUI screens and hiding the GUI when not needed? I’m using fromXML to load the screens because gotoScreen could not find my start screen (its id is start, it was loaded from the XML prior to calling gotoScreen). I use nifty.exit() to hide the gui.
Also, what is the recommended way for changing GUI screens and hiding the GUI when not needed? I’m using fromXML to load the screens because gotoScreen could not find my start screen (its id is start, it was loaded from the XML prior to calling gotoScreen). I use nifty.exit() to hide the gui.
I'm now using this method :
each of my GUI are controls ( and not screen anymore ) and I use only one screen inside which I add the GUI I need with methods like
[java]
ControlBuilder builder = new ControlBuilder( "myControlName" );
Element myGUI = builder.build( nifty, screen, myOverlayPanel );
[/java]
That way I can easily destroy the GUI I don't want, hide them when they are not needed but will serve in the future, etc...
[java]
myGUI.markForRemoval();
myGUI.hide()
[...]
[/java]
I think it's the most efficient and flexible way to manage multiple GUI.
Only drawback :
If one of your controlDefinition is corrupted ( you miss to close a panel tag for example ), Nifty will not initialize itself.
I may not be a real drawback in fact : If your Nifty initialize, it means all of your control definition are 'correct'.
I tried to do it in the constructor, but I dont think any of the elements existed at that point. Will try onStartScreen. Whats puzzling is that the checkboxes for vsync and fullscreen change correctly.
The getResolutions function is in fact borrowed from the settings dialog, it returns an ArrayList of Strings. The original returned an array of Strings, I changed it to an array list because addAllItems expects a list of Strings.
I’ll look into that, at the moment I like having a separate screen controller for my screens to handle the custom logic needed for each screen. I could make it more generic though, something like clicking on a panel calls loadScreen(“newPanelName”) instead of loadSinglePlayerMenu, for instance.
What I also want to do is write something that will process the XML files and do string replacements from a string table. This will help with language localization.
The other thing I need to do is define my own styles, and maybe even custom controls. I want to have a central place to change fonts and colours from, instead of specifying them on the elements, as they are now. Maybe I’ll do that tonight before doing any other GUI work, as well as the localization thing.
Does everything have to have a style? I tried running without a style last night, as well as defining my own button style but still importing the rest of the styles. Neither seemed to work. I suppose I’ll have to redefine every style mentioned in the default style.
EDIT: Having thought about this a bit more, I dont think nifty’s localization solution is adequate for me, because I need string substitution for more than just localization. I’ll have dialogs and popups with item descriptions, these need to be populated dynamically and not hardcoded. I’ll have to write a component to automatically insert the correct string based on localization settings.