Nifty Slick Integration in Nifty Version 0.0.4
Slick 2D is a great library for game development. With the upcoming release of Nifty GUI 0.0.4 there will be an even easier way to integrate your Nifty GUI into your Slick application.
The current Nifty GUI Version 0.0.3 can already be used with Slick but it might become a little tricky to save/restore OpenGL state when switching between Slick and Nifty rendering. The basic approach would be to call niftys render() method after you’ve rendered all of your Slick graphics. This “manual” rendering is the usual way for Nifty integration and is shown in the Hello World example on the Nifty Project Website.
With the Release of Nifty Version 0.0.4 there will be a Slick GameState implementation available for easy of use. If you’re new to Slick GameStates there’s an article in the Slick wiki about the basic principles. With Nifty 0.0.4 you get a NiftyGameState class that extends the Slick BasicGameState. So you can simply use an instance of this new class (or a subclass) and voila you have the ability to add a Nifty GUI to your Slick app in no time
Example:
public void initStatesList(final GameContainer container) throws SlickException { NiftyGameState state = new NiftyGameState(MENU_ID); state.fromXml("mainmenu.xml", new ScreenController() { public void bind(Nifty nifty, Screen screen) { } public void onEndScreen() { } public void onStartScreen() { } }); addState(state); }
Nifty! ![]()
August 10th, 200812:49 am at
I tested Nifty v0.3 and it looks really great! I’am anxious for your next release. This is the GUI I needed for my game development. Keep it up!
August 28th, 20089:28 am at
I’ll wait for next release. When Nifty GUI 0.4 released ?
I will try it in my game project.
void: today
September 7th, 20081:07 pm at
Nifty looks really great. But imho it would be better to set the scope of the lwjgl and slick dependencies to provided.
September 8th, 20089:46 pm at
why the provided scope dlx? this would mean you would need to know which version of slick and lwjgl are required and add these dependencies to your pom.xml on your own. especially the lwjgl stuff gets pretty tricky because there are actual three libs used (lwjg, jinput and lwjgl-util).
why do you need this? at the moment the only thing I can imagine is, when you’d need a special version of the libs and you can do that easily within your pom.xml
anything I am missing? o_O
September 9th, 20088:50 am at
I’m using slick from svn and ideally I’d like to just add a jar to my classpath to use nifty. Modifying the pom doesn’t sound optimal.
September 9th, 20089:37 pm at
Why?
The whole point of maven is, that you don’t need to manually manage or know the dependencies. Just add nifty to your pom.xml as a dependency in your project and you’re done because it *knows* what it needs to compile, run and even downloads missing jar files automatically for you.
Take for instance the tapestry pom.xml: http://mirrors.ibiblio.org/pub/mirrors/maven/tapestry/poms/tapestry-4.0.2.pom. Imagine all of the dependencies would have the scope provided … I would probably have a hard time figuring out all the dependencies with the right version on my own! o_O
Of course you can use your own version of slick. Why not just add your “slick-build-from-svn-jar” to your pom.xml as a seperate dependency to make sure that maven will use the right version?
The slick and lwjgl version is tested with nifty and works. I don’t know what will happen if you use another version :/
September 11th, 20088:12 am at
Yes, but those dependencies are not transient but direct dependencies of my project, so I do want and need to know about them.
September 11th, 20089:21 pm at
Ok, lets sort this out =)
First: You can always download nifty-<version>.jar, install it into your local maven repository (mvn install:install …) and use it as is. In this case there won’t be any transient dependencies. Exactly what you want!
Second: You will get the nifty dependencies only if you actually use a remote repository, f.i. http://nifty-gui.sourceforge.net/nifty-maven-repo (like the nifty-examples).
In this case let’s look at your pom.xml before nifty:
<dependencies>
...
<dependency>
<groupId>slick</groupId>
<artifactId>slick</artifactId>
<version>your-version-from-svn-xxx</version>
</dependency>
</dependencies>
and with nifty:
<dependencies>
...
<dependency>
<groupId>slick</groupId>
<artifactId>slick</artifactId>
<version>your-version-from-svn-xxx</version>
</dependency>
<dependency>
<groupId>lessvoid</groupId>
<artifactId>nifty</artifactId>
<version>0.0.4</version>
</dependency>
</dependencies>
In this case Maven should use your-version-from-svn-xxx independent from the one nifty uses! Isn’t this what you want?