My Writings. My Thoughts.
Set Back …
// November 19th, 2010 // 1 Comment » // Uncategorized
Crashing Hard Drives suck!
Just wanted to let you know, that one of my Hard Drives suddenly stopped working yesterday evening. Too bad it was part of a two disc RAID 0 =) And too bad most of the sources that I was working on where stored there too >_< Well, most of it is of course commited to the sourceforge.net svn server so there is not much data lost but it’s annoying to set everything up again.
Really. Annoying.
void
Two new Tutorials added to the Nifty wiki
// October 20th, 2010 // 13 Comments » // Uncategorized
I’ve planned that since a long time but was not able to finish this for several reasons. But now two new tutorials are available in the tutorial section of the nifty wiki:
Enjoy,
void
Consider voting in PacktPub’s annual Open Source Awards
// October 5th, 2010 // 1 Comment » // Uncategorized
Well, not for Nifty itself =) but jMonkeyEngine is nominated in the category “Best Open Source Graphics Software”. So maybe you can help jMonkeyEngine which is one of the best java 3d engines available to win this award?
Voting will only take a couple of seconds: https://www.packtpub.com/open-source-awards-home/vote-open-source-graphics-software
Tired of Nifty XML? Try the new Nifty Builder Java classes! :D
// September 4th, 2010 // 11 Comments » // design, docs
In order to improve the usability of Nifty, Nifty user arielsan of gemserk has started creating a “Builder Pattern” based way to create Nifty GUIs. These classes can be used from within java to create a Nifty GUI without the need for an external xml file.
We have improved the solution together and there is a Nifty ScreenBuilder class available as your starting point. Here is a quick example what you can do with it:
Screen mainScreen = new ScreenBuilder("main") {{
controller(new ScreenControllerExample());
layer(new LayerBuilder("layer") {{
backgroundColor("#003f");
childLayoutCenter();
panel(new PanelBuilder() {{
id("panel");
childLayoutCenter();
height(percentage(25));
width(percentage(80));
}});
}});
}}.build(nifty);
This should really read very well. We create a new Nifty Screen, add a ScreenController, a single Layer with a backgroundColor and a panel which is centered in the middle of the layer.
Please Note:
As we’re creating annonymous inner classes each time we add a new xxxBuilder() {{ }} method and we’re nesting them it’s possible to access methods from the previous annonymous class and that could be confusing because we could misconfigure the parent element. So it’s probably best to only use methods from the current Builder class.
Ariel also wrote an example GUI using the Builder mechanism which is part of the Java2d Renderer tests but can be used with other renderer systems too of course. You can find it in svn or use this direkt link to the file: http://nifty-gui.svn.sourceforge.net/viewvc/nifty-gui/nifty-java2d-renderer/trunk/tests/src/main/java/de/lessvoid/nifty/java2d/tests/GameExampleApp.java?view=markup
Every thing you always wanted to know about the Nifty screen-Tag
// August 19th, 2010 // No Comments » // docs
You want to use the ESC key to skip a Nifty screen?
You need to handle a keyboard event for the whole screen and not just when a single element has the keyboard focus?
Or do you need to change the default focus element for a Nifty screen?
Look no further!
The Nifty GUI Wiki has been updated and the <screen> Tag and all of its attributes have been explained and documented!
You can find the reference here: http://sourceforge.net/apps/mediawiki/nifty-gui/index.php?title=Elements
Have fun,
void
Nifty 1.2 released
// August 2nd, 2010 // 19 Comments » // demo, release
Nifty 1.2 – Download it
Nifty 1.2 – View Changelog
Nifty 1.2 – Enjoy the Examples
And there is an updated tutorial/demo available too:
Nifty 1.2 – Updated Tutorial/Demo
The Tutorial/Demo has been greatly improved and updated with Nifty 1.2 informations and is *THE* source to learn how to use Nifty!
Important Information
Please note that starting with Nifty 1.2 the main nifty.jar is now independend of lwjgl and slick2d. This means you need a nifty-<system>-renderer.jar for your rendering system! For instance, if you would like to use Nifty with a Lwjgl based rendering backend you will now need to download nifty-1.2.jar as well as nifty-lwjgl-renderer-1.0.jar!
Please note that we assume that all of the required jars of your rendering system, like lwjgl.jar, slick.jar and so on are downloaded by yourself. The nifty-<system>-renderer.jar only acts as the adapter between nifty and your rendering backend. They don’t come with all the required libs. This decision was simply done under the assumption that Nifty comes as an add on to an existing application.
The Nifty 1.2 compatible jme2 renderer will be available soon after the 1.2 release and Nifty 1.2 will be integrated into jme3 soon as well.
have fun
Nifty User zozo64 creates Basis Drag and Drop Demo!
// June 28th, 2010 // 1 Comment » // bubble, demo, design
See! This is what I’ve meant!
Nifty gives you an easy to use framework that you can extend with your own ideas. Just like Nifty user zozo64 did. Nifty is missing drag and drop support? No problem! He created his own!
To be honest, he found some bugs too
but all of that improved Niftys core systems. So that’s a good thing. We’ll probably bring his work as a standard drag and drop control into the standard controls project soon.
For the moment you can take a look at the code. It’s part of the nifty examples project:
And here is a first preview of zozo64 work:
Nifty Basic Drag and Drop from void on Vimeo.
Localization support and some more cool stuff!
// June 19th, 2010 // 7 Comments » // Uncategorized
A feature request made Nifty user lynorics create a patch that solved the issue and it directly point to solve the localization feature request too
Every attribute of every Nifty element can now contain a special markup “${…}” that gets replaced with something else when the xml is loaded.
Example:
<text text="your home directory: ${ENV.HOME}" />
The “${ENV.HOME}” will be replaced with your $HOME environment variable!
You have the following options now to use this new feature:
- ${id.key} lookup resource bundle with “id” and request “key” from it. This is explained in more detail below.
- ${ENV.key} lookup “key” in the environment variables (System.getEnv()) and replace ${ENV.key} with the value received.
- ${PROP.key} lookup “key” in the new Nifty.setGlobalProperties(Properties) properties or if the properties are not set this will use System.getProperties() to lookup “key”
- ${CALL.method()} call method() at the current ScreenController and it is replaced with the value that method() returns. method() should return a String in this case.
If for some reason the replacement does not work out then nothing is replaced and you’ll get the original ${…} String back.
Localization Details
Currently Nifty Localization is using standard Property file based Resourcebundles. This simply means you can create a property file containing keys that are referenced from the xml files.
Example:
dialog.properties: hello = Hello World in Default Language dialog_de.properties: hello = Hallo Welt in Deutsch dialog_en.properties: hello = hello world in english
Once you have created these files you need to register the resourceBundle “dialog” with Nifty so that Nifty knows that it exists. You can do that with the new “resourceBundle” tag:
<resourceBundle id="dialog" filename="src/main/resources/dialog" />
Now that Nifty knows about your resourceBundle you can access it with the method mentioned above:
<text text="${dialog.hello}" />
Now Nifty will use the current set default locale to access the ResourceBundle with the id “dialog” and looks up the value for “hello”. If you don’t like that Nifty uses the default Locale you can set the Locale that Nifty should use with the “nifty.setLocale(Locale)” method.
Nifty stuff and Kudos goes out to lynorics!
void
If you liked the black nifty style, you will love this!
// May 28th, 2010 // 3 Comments » // Uncategorized
The old Nifty default style nifty-style-black was pretty nifty but the new style simply rocks \o/
Nifty GUI New Grey Style from void on Vimeo.
… and being very creative with style names we call this one “nifty-style-grey”
You can already svn checkout the project from svn here: https://nifty-gui.svn.sourceforge.net/svnroot/nifty-gui/nifty-style-grey/trunk or browse the source online here http://nifty-gui.svn.sourceforge.net/viewvc/nifty-gui/nifty-style-grey/trunk/.
Together with the “nifty-default-controls” project – which provides the Standard Controls – you can already start to use the shiny new awesome grey design!
A released version will be available together with the upcoming Nifty 1.2 Release.
But remember, Nifty is not at all about the controls only. You can build whatever GUI you like! This new style is meant as another demonstration how shiny and nifty you can make GUIs look with Nifty GUI. But when you are happy with the look of the new style you are of course free to use it or modify it or just stare at it, like I do
Have fun,
void
XML-Validation and Text Rendering with In-Text change of the Textcolor
// May 18th, 2010 // 1 Comment » // Uncategorized, sightings
XML-Validation
The actual parsing of Nifty-XML files is still using a XPP3 based parser and does not require a XML-Schema Definition. The nifty.xsd was only added to validate Nifty XML-Files … as well as for special support of the jMonkeyEngine3 SDK but that will be explained somewhere else
XML-Validation is now build into Nifty but is still an optional step you can use to ensure your Nifty XML is well formed and valid. To perform the actual validation two new methods have been added to the Nifty class:
public void validateXml(final String filename) throws Exception public void validateXml(final InputStream stream) throws Exception
Both methods will simply return or will throw an Exception when any errors have been detected.
To successfully validate the nifty xml file, your xml file should start with the two following lines:
<?xml version="1.0" encoding="UTF-8"?> <nifty xmlns="http://nifty-gui.sourceforge.net/nifty.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://nifty-gui.sourceforge.net/nifty.xsd http://nifty-gui.sourceforge.net/nifty.xsd">
This way the XML-File is using the correct Nifty Namespace. If you would omit these declarations your XML-File can still be parsed but it will probably not validate against the XSD.
The namespace that has been definied for nifty is actually the URL where you can download the xsd too: http://nifty-gui.sourceforge.net/nifty.xsd
In-Text changes of Textcolor
Up until now Nifty uses the “binary” character value 0×01 directly in the text to indicate that the next three bytes in the text will contain red, green and blue values that represent the color of the text that follows after the color definition.
So you could write a red word, example:
<text text="a word in ÿ��red"/>
This works but is unfortunatly not a valid XML file when trying to validate it with an XML-Schema Definition
The problem is, that a valid XML attribute value must not contain values below binary 0×20 (with only a couple of exceptions, like the tab character 0×09). 0×01 is not allowed and will always create a validation error! So the current solution is to use a new format that doesn’t use 0×01 as a indicator anymore. Instead Nifty will now watch for the special String “\#” to mark the beginning of a color definition and “#” as the end. So instead of the xml example given above you can now write:
<text text="a word in \#F00#red"/>
Which is more readable too!
There is a short Version supported “\#F00#” as well as a long version “\#FF0000#”. Both are not case sensitive so you could write “\#fa9#” too. But remember the trailing #
Have fun,
void






