Hello! I’m trying to learn the niftyGui but i ran into a problem. I choose a font for my text and an error pops when i run the code:
[java]com.jme3.asset.AssetNotFoundException: Console.fnt[/java]
the xml code for the niftyGui :
[xml]<?xml version=“1.0” encoding=“UTF-8”?>
<nifty>
<screen id=“start” controller=“de.lessvoid.nifty.examples.helloworld.HelloWorldStartScreen”>
<layer id=“layer” backgroundColor="#003f" childLayout=“center”>
<panel height=“25%” width=“35%” align=“center” valign=“center” backgroundColor="#f60f"
childLayout=“center” visibleToMouse=“true”>
<text font=“Console.fnt” text=“Hello World!”
align=“center” valign=“center” />
</panel>
</layer>
</screen>
</nifty>[/xml]
Where is the proper folder to keep my fonts?
In assets folder.If You want to put in the Interface folder change line:
<text font=“Console.fnt” text=“Hello World!”
in
<text font=“Interface/Console.fnt” text=“Hello World!”
I’ve done what you told me but i was getting the same error. But i found out that problem was the capital C on the xml and font name . Why is that? Even if it is case sensible it was the same case…
I don’t know,I use only fonts from nifty svn(at resources),and I never changed a letter from name.You must have the .png file in the same folder as .fnt,you know…
I retested it with changing only the capital C to c in the xml file and it worked…the font C remains capital. And one more question,im studying the examples at niftygui’s page and when i use this example :
[xml]<?xml version=“1.0” encoding=“UTF-8”?>
<nifty>
<useStyles filename=“nifty-default-styles.xml” />
<useControls filename=“nifty-default-controls.xml” />
<screen id=“start” controller=“de.tum.nifty.State_LayoutTest”>
<layer id=“firstLayer” childLayout=“center”>
<panel id=“firstPanelParent” width=“100%” height=“50%” backgroundColor="#003f" childLayout=“vertical”>
<panel id=“firstPanel1” width=“100%” height=“50%” backgroundColor="#003a" childLayout=“center”>
<label id=“deepestLabel” text=“blue:firstLayerPanel1” align=“right”/>
</panel>
<panel id=“firstPanel2” width =“100%” height="" backgroundColor="#002a" childLayout=“center”>
<label id=“deepestLabel2” text=“blue:firstLayerPanel2” align=“right”/>
</panel>
</panel>
</layer>
<layer id=“upperLayer” childLayout=“center”>
<panel id=“upperPanel” width=“50%” height=“100%” backgroundColor="#ff000030" childLayout=“center”>
<panel id=“upperAnotherPanel” width=“100%” height=“100%” childLayout=“center”>
<label id=“upperLabel” text=“red:secondLayerPanel1” align=“right”/>
</panel>
</panel>
</layer>
<layer id=“uppestLayer” childLayout=“center” height=“50%”>
<panel id=“uppestPanel” width=“100%” height=“100%” childLayout=“vertical”>
<panel heigth=""/>
<panel id=“uppestAnotherPanel” childLayout=“vertical” width=“100%” height=“73%” backgroundColor="#00ff0030" >
<label id=“uppestLabel” text=“green:thirdLayerPanel2” valign=“bottom” align=“right”/>
</panel>
</panel>
</layer>
</screen>
</nifty>[/xml]
it doesn’t work,it displays only a blue square all along the top of the screen, but when i change the label tags like this :
[xml]<?xml version=“1.0” encoding=“UTF-8”?>
<nifty>
<useStyles filename=“nifty-default-styles.xml” />
<useControls filename=“nifty-default-controls.xml” />
<screen id=“start” controller=“de.tum.nifty.State_LayoutTest”>
<layer id=“firstLayer” childLayout=“center”>
<panel id=“firstPanelParent” width=“100%” height=“50%” backgroundColor="#003f" childLayout=“vertical”>
<panel id=“firstPanel1” width=“100%” height=“50%” backgroundColor="#003a" childLayout=“center”>
<text id=“deepestLabel” text=“blue:firstLayerPanel1” font=“console.fnt” align=“right”/>
</panel>
<panel id=“firstPanel2” width =“100%” height="" backgroundColor="#002a" childLayout=“center”>
<text id=“deepestLabel2” text=“blue:firstLayerPanel2” font=“console.fnt” align=“right”/>
</panel>
</panel>
</layer>
<layer id=“upperLayer” childLayout=“center”>
<panel id=“upperPanel” width=“50%” height=“100%” backgroundColor="#ff000030" childLayout=“center”>
<panel id=“upperAnotherPanel” width=“100%” height=“100%” childLayout=“center”>
<text id=“upperLabel” text=“red:secondLayerPanel1” font=“console.fnt” align=“right”/>
</panel>
</panel>
</layer>
<layer id=“uppestLayer” childLayout=“center” height=“50%”>
<panel id=“uppestPanel” width=“100%” height=“100%” childLayout=“vertical”>
<panel heigth=""/>
<panel id=“uppestAnotherPanel” childLayout=“vertical” width=“100%” height=“73%” backgroundColor="#00ff0030" >
<text id=“uppestLabel” text=“green:thirdLayerPanel2” font=“console.fnt” valign=“bottom” align=“right”/>
</panel>
</panel>
</layer>
</screen>
</nifty>[/xml]
it works fine as shown at their site.
Am i doing something wrong? or only the label works on jmonkey?
You want to display a text,and for text you use that(second example).I don’t use yet labels in JME,so I don’t know whats the deal with it.
I’ve found something about labels in wiki: https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:nifty_gui_xml_layout?s[]=label
Thank for all your replies !! I’ll ask you something last , if you know the answer ill be glad !
So , the line guiViewPort.addProcessor(niftyDisplay); adds the gui, the guiViewPort.removeProcessor(niftyDisplay); removes the gui, but is there a way to check if niftyDisplay is already added to the guiViewport?
I’ve found the method guiViewPort.getProcessors(); ,then you must to return all the processors,and
if (niftyDisplay is attached to guiViewPort) { run this
}
This is the idea,but I don’t know how to implement it.
I figured it out a few minutes after i posted,thank you very much for your help