JME3 Nifty Basic - Lightnet/openwizcoder GitHub Wiki

The Basic of the Nifty GUI:(work in progress)

The first part is the basic setup up. To get the skin and and controls.

<nifty xmlns="http://nifty-gui.sourceforge.net/nifty-1.3.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://nifty-gui.sourceforge.net/nifty-1.3.xsd http://nifty-gui.sourceforge.net/nifty-1.3.xsd">
    <useStyles filename="nifty-default-styles.xml" />
    <useControls filename="nifty-default-controls.xml" />
</nifty>

Layer

Layer is the frame or border. (work in progress)

Screen

Nifty Screen have many layers to show and hide to easy to create GUI quickly. Screen go by their ID. Or screen name to identity which screen to show up. There will first entry point. To show up. Like head up display or pause screen. Those will have to be name. Here an example.

<screen id="start">
<!-- SOME CONTENT HERE -->
</screen>
<screen id="end">

You will notice there is another screen. You can stack them as long the screen id name is different.

ScreenController

Next where does control go in? Each screen id has it own controller class and controller define class. Define class controller is later on. So where to assign it? It right next to the screen id tag.

''' ''' ScreenController handle events that trigger screen GUI.

When put together: UI_console.xml

Here an example of console GUI and end screen. The end screen to deal with input handle when controls are frozen that you need to exit nifty menu.

To get into app working with nifty: ... public Nifty nifty; ...

//init app ... NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(assetManager, inputManager, audioRenderer, guiViewPort); nifty = niftyDisplay.getNifty();

UIConsoleScreenController screenControl = new UIConsoleScreenController(); nifty.fromXml("Interface/UI_console.xml", "startconsole", screenControl); //note the screen id must match the screen id that is in the list. Else it will not know where your screen id is. That will not show up. //as well controller class. //this for game start menu in case your wonder about it.

guiViewPort.addProcessor(niftyDisplay); ...

That should be simple.

So how do we close the screen menu? nifty.gotoScreen("end");

But how to get the menu back up again? nifty.gotoScreen("startconsole"); //note the control are disable but depend your config and setting you set to.

Since we loaded up the nifty xml file. It should be in the nifty init set up variable.

Working on the interacting next.

⚠️ **GitHub.com Fallback** ⚠️