That thing would be a smoldering pile of ash right there in the middle in of the bedroom while I would wave a cursed rubber chicken at it, smirking malevolently, but savoring an inner victory.
I like the feel of what I have seen of Nifty. It looks, well, nifty.
But the damn thing don’t wanna run! Yes, I know, it’s my fault. Somehow. But I blame void! There, I said it.
Ok. Most of my venting is done. Now, here are some little pointers I would love to be looked at and, hopefully fixed. Those are heavy deficiencies that is stopping me from even liking the darn thing in the first place (except when I see it running elsewhere).
The most important point is:
A fully understandable tutorial that would explain how to properly integrate nifty into a game (jME3).
Yes, yes. I hear you saying there’s already tutorials.
First, none of those 2 test files run.
Second, these two “tutorials” are not integrated into anything. I want to see and learn how it can interact with the rest of a game or whatnot. So even if they wouldn’t work, you still could follow the logic…
So, that makes it pretty damn hard to test, but that’s fine. jME3 is still in devel, it’s alpha. But I would expect void’s tutorials on his site to be more involved with jME3. (Oh and by the way void, please lose the bubbles in that demo, distracting as hell, or at least send them in the background). I tried using the “loop” integration shown in that demo, but it didn’t want to work here. As I said, it’s probably my fault.
What I did:
Created xml file.
Created “loadingScreen” class implementing the ScreenController.
Added the following to update()
[java]
if (nifty.render(true)){
}
[/java]
as the demo/tutorial suggested. Nothing. Zilch. Nada. (I also tried nifty.render(false) with same result, or lack thereof).
So, what happens when I run my game is: It instantiates nifty, but the whole thing flies by then crash, the screen is never shown. The crash is normal because at that point the game expect a galaxy to work with but there’s none. And there’s nothing to work with because the nifty screen is supposed to be a menu asking the player what to do, like create a galaxy…
I’m getting very very frustrated with something that should be simple. The underlying workings are not really interesting me. I just want it to run with the less hassle as possible.
I swear and promise that if I get nifty working properly I will write the best damn tutorial EVAH! on implementing nifty with jME3. But right now, all I want is burn the damn thing!
Alright. I’m done.
I’m sorry if that whole thing above sounds like I feel like murdering someone, but I’m not. I’m just frustrated. I’m not pissed at anyone except me for not clearly seeing the picture here. I’m sure it’s a small tiny thing missing in my game that is stopping me from having the desired result. But nifty’s docs are obscure at best. Void, I would highly suggest you make a tutorial that goes from A to Z starting with simple things to stuff that is more complicated, all that within a working framework like jME3 for example (or whatever you chose really).
The saddest part is, I yearn for nifty to work. It looks great really.
If need be I can paste code but the ScreenController is pretty much empty of code, only the necessary methods are there, but they’re empty. Which, shouldn’t matter since the screen doesn’t show in the first place right? But, anyway, if you want me to paste some code I will, just ask me what it is you need/want.
You don’t need to add nifty.render(true) (afaik).
Here’s my method that instantiates my nifty gui (note that i’m running an applet):
[java]public void createNiftyGui(){
NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(jmeApp.getAssetManager(),
jmeApp.getInputManager(),
jmeApp.getAudioRenderer(),
jmeApp.getRenderManager().getPostView(“Gui Default”));
nifty = niftyDisplay.getNifty();
niftyController = new NiftyController();
nifty.fromXml(“Interface/UiElements.xml”, “mainui”, niftyController);
niftyController.bind(nifty, nifty.getCurrentScreen());
// attach the nifty display to the gui view port as a processor
jmeApp.getRenderManager().getPostView(“Gui Default”).addProcessor(niftyDisplay);
}[/java]
That’s really all that there’s to it. If there’s any problem, it’s most likely in the xml file. Strip it down to bare minimum, or try one that you know works to see if you can isolate the problem.
@normen
I dissected that tutorial inside and out. Nothing in there made my loading screen load…
@rickard
I will try that ASAP, but first I’ve got to work on planets generation. I’ll report when I’ll get results.
Making progress…
It still isn’t appearing but I’ve put:
[java]
nifty.validateXml(“Interface/loadingScreen.xml”);
[/java]
in there and according to this, I have a problem in my xml…
Here’s the error:
[java]
Starting the game…
Nov 15, 2010 3:09:16 AM StellarConquest.Game initialize
SEVERE: null
org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element ‘nifty’.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384)
[/java]
Following is the whole xml. As you can see the “nifty” tag is indeed present. I tried removing the xmlns… part but got the same result.:
PS: Forget that. The forum refuses to display anything with tags and I sure won’t replace them all by hand. Here’s a link to it. http://www.danyrioux.com/files/loadingScreen.xml
Is it possible it’s not finding the that tag because it simply can’t find the xml file? A bit like it’s doing right now in the jme3tests? Of course the error is different, but that might be the cause.
Isn’t it possible that fromXml(“file.xml”) doesn’t properly hookup with the assets?
Also, just noticed that both TestNiftyGui and TestNiftyToMesh are trying to load the wrong xml file.
They’re looking for:
[java]
nifty.fromXml(“all/intro.xml”, “start”);
[/java]
but should be looking for:
[java]
nifty.fromXml(“Interface/hellojme.xml”, “start”);
[/java]
I guess it doesn’t really matter what they’re looking for since jme3test.niftygui doesn’t have an assets pack.
Did you get it working? Yes you have to be careful where your xml files are and how you call them. But what’s your current status? I am fairly new to Nifty as well but I HAVE gotten it working fairly well after Void answered my one question a week or so ago. (Though I did just post a new one lol). I was even able to integrate everything, have my Nifty code completely separate from my JMonkey code, and have guice auto-inject all the nifty classes (and everything else) all automatically (if you are unfamiliar with Google Guice, its kinda like the Spring Framework and its Autowiring). If you still can’t get it working I can provide example code. Just let me know what your looking for
~David
Sadly I wasn’t able to get it to work. I was pretty worked up so I decided to move on to something else for the time being before things got worse. There is still many many things to get done, so it’s not an emergency. I wish I could display something while the game loads, generate a galaxy, and have a basic HUD.
Oh well.
As for help, that’d be great.
The goal is to load a nifty gui after the screen has loaded and present the user with basic choices for now. Like quit and generate a galaxy. Maybe even a button for showing a help screen with the basic keys to use.
Ideally I’d love to have a separate class into which all the nifty stuff is done so that wouldn’t clutter the game class itself. For now I’d be happy to simply have something, anything, load up and show a menu. From there I can tweak and fix and augment until I’m reasonably happy.
So, for now, a method that I can use in my “main” class that would bring a menu would be great.
Here’s what I have right now:
[java]
public void startGUI() throws Exception {
NiftyJmeDisplay hud = new NiftyJmeDisplay(app.getAssetManager(),
app.getInputManager(),
app.getAudioRenderer(),
app.getRenderManager().getPostView(“Gui Default”));
nifty = hud.getNifty();
loadingScreen = new LoadingScreen();
nifty.validateXml(“Interface/loadingScreen.xml”);
nifty.fromXml(“Interface/loadingScreen.xml”, “Loading”, loadingScreen);
loadingScreen.bind(nifty, nifty.getCurrentScreen());
app.getRenderManager().getPostView(“Gui Default”).addProcessor(hud);
}
[/java]
That’s all for the main class.
As for the ScreenController class, it’s pretty empty.
[java]
package GUI;
import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.screen.Screen;
import de.lessvoid.nifty.screen.ScreenController;
/**
*
-
@author Dany
*/
public class LoadingScreen implements ScreenController {
public LoadingScreen() {
}
protected void genGalaxy() {
}
protected void quit() {
}
@Override
public void bind(final Nifty niftyBind, final Screen niftyScreen) {
}
@Override
public void onStartScreen() {
}
@Override
public void onEndScreen() {
}
}
[/java]
but as I have said, since it doesn’t seem to load, I don’t think it’s important. From what I have read, if it would load and that ScreenController was bad, whatever is in it wouldn’t work… I might be wrong, but that’s how I understood it.
As for the XML file, it’s linked above.
Thanks for the help.
Well for one thing, I am pretty sure your not supposed to be calling:
loadingScreen.bind(nifty, nifty.getCurrentScreen());
That is Nifty’s job and is called automatically.
Second, in your xml, you have the screen id as “start” but in your java code:
nifty.fromXml(“Interface/loadingScreen.xml”, “Loading”, loadingScreen);
You are telling it to use “Loading”
Try fixing those and let me know if it still doesn’t work and I will look at it further
~David
hmm… I see.
Well, I was trying Rickard’s suggestion. shrug
Before I try, my question is: Why does using nifty.validateXml(“Interface/loadingScreen.xml”); complains about not seeing the nifty tag then? Hmmm… Maybe seeing some other error triggered that.
Let me try…
Alright!
We’re making progress. sigh
It seems that validateXml barfs somewhere… I had to comment it out. The screen loaded but went down immediately as it tried to run genGalaxy (on its own?! Without a click!?). But it worked. At least I have a foot in the doorway.
Thanks It’s very appreciated!
I haven’t used validateXml so I don’t know what kind of information it gives or whatnot. But no problem and good luck with it, glad I could help. Lemme know if you get stuck again.
~David
Oooook…
We’re getting somewhere now.
It seems I do need to stop the update loop while nifty is up and running. If I don’t the game will simply try to run whatever is in update method and of course crashes with a null pointer…
I think I’ll be able to make that work. Finally.
Depending on how your doing the loop, it still should work WITH Nifty. For example in my app I have a 3d Model slowly spinning in the background (I keep rotating it in the loop) and my Nifty Menu Screen in front.
Glad you got some things to work though ^_^. Happy Coding.
~David
Hehe, yeah, that would work, but there are things on the screen that needs to be updated, like coordinates, ship’s speed and many other things. Doing that while there’s nothing initialized isn’t a good thing.
Anyway. I’ll say it again. Thanks!
Well for one thing, I am pretty sure your not supposed to be calling:
loadingScreen.bind(nifty, nifty.getCurrentScreen());
That is Nifty’s job and is called automatically.
Must be some redundant code from when _I_ tried to get my nifty working ;) Sorry for the confusion, but i don't think it breaks anything either.
Glad you got it working eventually.
hey, no harm done rickard and yes, I ran the code with and without that line and apparently jME3 nor Nifty mind, so… shrug
Alright.
I need help.
The GUI is displaying. I’ve got 4 buttons. Generate a galaxy, save game, load game and quit. Clicking on buttons work, except for an annoying thing…
When I generate a galaxy, the GUI doesn’t respond at all except at one point where it repaints itself at a point where 75% of the stuff is done. All that remains is to create the player’s ship, pin the stars on the canvas then kill the GUI so we can see what it looks like, move the ship, etc.
I’m trying to implement the ProgressBarControl I found on nifty’s site. It’s kinda working although for some reason it’s not updating. But that’s something I can probably fix by myself. We’ll see. My concern is that the whole thing stops… My 4 CPU cores are going at it like they are working mostly full time, video card is heating up a bit. It looks like everything is “working” but of course I can’t see the screen because something stopped mid-way and the “bye()” method isn’t reached.
I know that the galaxy and its stars are generated. I print out on the console what’s the result for each galaxy when adding stars to the octree. I guess I’ll add more System.out lines so I can see if the process gets really stopped along the way.
While I try to find the problem, anyone of you have an idea by what nifty’s behavior might be caused by?
What type of code do you have on the button callback function? Like I said before, the way I have things set up, JMonkey code and Nifty code are almost completely independent with the exception of some interaction calls between one another of course. Nifty just displays on top of whatever Is going on in my main run loop, completely isolated.
Now with the progress bar, I haven’t tried to use that yet so I donno specifics about it.
~David
PS: Yah I didn’t even notice that you had the bind call rickard, I was just looking through the code and trying to spot what didn’t look right. It seems that call indeed doesn’t break anything but doesn’t do anything either. It was the screen ID that was the main problem apparently.