To any Nifty-experts out there:
After a while not doing stuff in jME, I got back to do something with Nifty, and (of course) I doesn’t work.
I’m trying to make a ListBox
(“listBox”), and place it in the middle of the screen.
At the first try, it didn’t work.
I added a few controls, and it still didn’t work.
Added a panel, same result,
Afterwards, I wondered if the order is wrong. I changed the order, and now the controls showed up.
This sounds like a typical nifty-knows-whats-wrong-but-wont-tell-you-problem. Here’s the XML:
<?xml version="1.0" encoding="UTF-8"?>
<nifty xmlns="http://nifty-gui.lessvoid.com/nifty-gui" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://raw.githubusercontent.com/void256/nifty-gui/1.4/nifty-core/src/main/resources/nifty.xsd https://raw.githubusercontent.com/void256/nifty-gui/1.4/nifty-core/src/main/resources/nifty.xsd">
<useStyles filename="nifty-default-styles.xml" />
<useControls filename="nifty-default-controls.xml" />
<screen id="start" controller="nl.mrcave.console.NiftyState">
<layer id="foreground" childLayout="center">
<panel id="mainPanel" width="80%" height="80%" childLayout="center">
<panel id="some panel" childLayout="horizontal" width="100%" height="100%">
<control id="text" name="label" text="Some text"/>
</panel>
<contol id="chatlist" name="listBox" displayItems="12"/>
<!-- Where I placed the panel before -->
</panel>
</layer>
</screen>
</nifty>
Here’s the code relevant to Nifty (called from an AppState):
NiftyJmeDisplay fakeNifty = new NiftyJmeDisplay(this.app.getAssetManager(), this.app.getInputManager(), this.app.getAudioRenderer(), this.app.getGuiViewPort());
nifty = fakeNifty.getNifty();
nifty.fromXml("Interface/console.xml", "start", this);
this.app.getGuiViewPort().addProcessor(fakeNifty);