Hi!
I’ve just implemented the nifty console to display some in game messages.
I’ve encountered a problem that i think is within nifty.
Here’s the repro:
I have two different nifty “screens”. One has a console, one hasn’t.
- I launch the game with the one that hasn’t a console.
- I switch to the one with the console. Console is fine.
- I switch back to the screen without a console.
- I switch back to the console screen. Bang!
Exception in thread "LWJGL Renderer Thread" java.lang.NullPointerException
at de.lessvoid.nifty.controls.listbox.ListBoxControl.applyWidthConstraints(ListBoxControl.java:304)
at de.lessvoid.nifty.controls.listbox.ListBoxControl.ensureWidthConstraints(ListBoxControl.java:284)
at de.lessvoid.nifty.controls.listbox.ListBoxControl.display(ListBoxControl.java:207)
at de.lessvoid.nifty.controls.listbox.ListBoxImpl.updateView(ListBoxImpl.java:42)
at de.lessvoid.nifty.controls.listbox.ListBoxImpl.changeSelectionMode(ListBoxImpl.java:81)
at de.lessvoid.nifty.controls.listbox.ListBoxControl.initSelectionMode(ListBoxControl.java:482)
at de.lessvoid.nifty.controls.listbox.ListBoxControl.bind(ListBoxControl.java:106)
at de.lessvoid.nifty.controls.NiftyInputControl.bindControl(NiftyInputControl.java:124)
at de.lessvoid.nifty.elements.Element.bindControls(Element.java:1704)
at de.lessvoid.nifty.elements.Element.bindControls(Element.java:1708)
at de.lessvoid.nifty.elements.Element.bindControls(Element.java:1708)
at de.lessvoid.nifty.screen.Screen.bindControls(Screen.java:752)
at de.lessvoid.nifty.screen.Screen.startScreen(Screen.java:192)
at de.lessvoid.nifty.Nifty.gotoScreenInternal(Nifty.java:587)
at de.lessvoid.nifty.Nifty.access$200(Nifty.java:70)
at de.lessvoid.nifty.Nifty$1.perform(Nifty.java:561)
at de.lessvoid.nifty.screen.Screen$EndScreenEndNotify.perform(Screen.java:600)
at de.lessvoid.nifty.screen.Screen$LocalEndNotify.perform(Screen.java:557)
at de.lessvoid.nifty.elements.Element$LocalEndNotify.perform(Element.java:1652)
at de.lessvoid.nifty.elements.Element$LocalEndNotify.perform(Element.java:1652)
at de.lessvoid.nifty.elements.Element$LocalEndNotify.perform(Element.java:1652)
at de.lessvoid.nifty.effects.EffectProcessor.checkFinish(EffectProcessor.java:299)
at de.lessvoid.nifty.effects.EffectProcessor.renderActive(EffectProcessor.java:84)
at de.lessvoid.nifty.effects.EffectProcessor.renderPre(EffectProcessor.java:57)
at de.lessvoid.nifty.effects.EffectManager$RenderPhasePre.render(EffectManager.java:318)
at de.lessvoid.nifty.effects.EffectManager.render(EffectManager.java:120)
at de.lessvoid.nifty.effects.EffectManager.renderPre(EffectManager.java:135)
at de.lessvoid.nifty.elements.Element.render(Element.java:569)
at de.lessvoid.nifty.elements.Element.renderInternalChildElements(Element.java:604)
at de.lessvoid.nifty.elements.Element.renderChildren(Element.java:597)
at de.lessvoid.nifty.elements.Element.render(Element.java:564)
at de.lessvoid.nifty.elements.Element.renderInternalChildElements(Element.java:604)
at de.lessvoid.nifty.elements.Element.renderChildren(Element.java:597)
at de.lessvoid.nifty.elements.Element.render(Element.java:564)
at de.lessvoid.nifty.screen.Screen.renderLayers(Screen.java:293)
at de.lessvoid.nifty.Nifty.render(Nifty.java:265)
at com.jme3.niftygui.NiftyJmeDisplay.postQueue(NiftyJmeDisplay.java:164)
at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:740)
ListBoxControl.java:
[java]
302 SizeValue newWidthSizeValue = new SizeValue(width + "px");
303 for (Element element : labelElements) {
304 element.setConstraintWidth(newWidthSizeValue);
305 }[/java]
On a slightly other topic, but worth mentioning:
I downloaded the latest nifty nightly build (from the 29th), and it seems the pop up menu doesn't register clicks on menu items (neither in my project, or the test app). Didn't want to create a whole new topic since it's still a "nightly".
And thirdly, for anyone reading this far, i can really recommend checking out the examples jar, if you haven't. It's a gold mine when it comes to nifty development :)