Archive for sightings

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 &#01;&#255;&#0;&#0;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

Nifty GUI sightings – 4our

// February 15th, 2010 // No Comments » // sightings

Another game with a nifty gui

4our game screenshot

4our game screenshot

good work jattra! :)

Nifty GUI sightings – Shiring

// October 6th, 2009 // 1 Comment » // sightings

Shiring is a 2D MMORPG that uses Nifty GUI for it’s user interface. Check out it’s blog

http://blog.shiring.de

and especially the current GUI demo:

This is pretty awesome :D

Nifty-GUI Sightings :)

// October 21st, 2008 // No Comments » // sightings

Take a look at XSpace . A game that uses Nifty for it’s game GUI. Looks great, isn’t it?

I’m looking forward to the finished game too! :)