Sunday, 9 March 2008

XML Code - Backward Engineering

I have to confess that I like the new GUI interface operations and how we can, as builders, develop various feedback and displays for our players. To me it adds a new dimension to the game, and allows me to help structure a module to keep players aware of events and help keep the plot focused. Or, I may also be able to design an interface to make use of new and complete independent systems that make the world of Althéa unique.

The only problem is that XML is new to me, much like script was when I first encountered it. However, whereas script appeared more logical, XML requires a little more forethought, as much of what you are doing is building something visual with numbers (or so it seems to me). In script the objects to code with were mostly already present, whereas XML is more like coding the object in the first place.

Therefore, if I wanted to make more use of the new GUI interface, I needed to start looking at what others have done and pull them apart to understand it. To help me in this project, I copied and printed off the small amount of information available at Obsidian's XML Blog. The XML information is on the first few pages (oldest) of the blog. I then opened up some XML files that others have written and started to try to make sense of everything.

I found that if I copied the text into something like Word and then highlighted different sections according to when each "function" appeared to start and end, I began to see a pattern among the otherwise just "rush" of text. Then, comparing the highlighted code with the information I copied from Obsidian, I could begin to see how the functions were being used, and even managed to start editing my example XML to test in game. The results were encouraging, and while I am not going to be making many of my own to begin with, I do believe I have enough knowledge now to be able to work on someone else's XML file and alter it for what I need. As there are quite a few official and unofficial files available, I should be able to do what I need when the time comes. (I will let you know.)

Here are some of the XML commands that I have started to get to grips with:

  • < !-- COMMENTS HERE -- > : How to make comments in the XML code.
  • UIScene : Defines the main GUI size, placing and function. (The box that appears.)
  • UIText : Places text within the main GUI.
  • UIButton : For placing a button, but appears to rely a lot of UIFrame for visual look.
  • UIFrame : Appears to be used with UIButton to define an image.

Feel free to comment on XML coding if you can help enlighten me to anything or lead me to a better understanding of it. There are still a few functions that I need to look at more closely and learn how all the different parameters interact with other, including:

  • UIObject : Appears to be used with most other functions in some way.
  • UIListBox : Has similarities with UIPane.
  • UIScrollBar : Appears to be used UIListBox (among others).

Readable Books

I am pleased to report that my Readable Books hak has been very well received from the NWN2 community, and so far, has received all tens for its contribution. :) (Link to the mod is on the left.) Note, I originally uploaded this module into the mods section, but later had it transferred to the Custom UI section, which is more appropriate. This has, however, made some of the comments normally shown within the "View Comments" section unavailable. They can, however, still be read from the comments below the module listing.

2 comments:

Elf des coquillages said...

A few tips on NWN2 GUI modding and XML. I'll assume you start with no background on these subjects, so don't fret if you already know some / most of these things. ^_~

XML basics
Wikipedia for a broader view, and this for the inner workings. The thing to keep in mind when creating custom GUIs is that Obsidian's XML files are not exactly what we would call "well-formed", and their parser is a bit unorthodox, or at least "lazy" when it comes to choose what's valid and what's not.

GUI Tutorial
See this one, it's quite simple but allow you to understand how GUI screens and server scripts can affect each other.

Documentation
- : the blog where the XML posts in the link you gave came from, in case you missed some. Plus it's easier to navigate.
-
: a must-have to quickly find what's in the existing GUI files.

Tools
If / when you're serious about doing custom GUIs, pick the right tool for this task : either a jack-of-all-trades text editor (I'm thinking along the line of PSPad and such, that at least provides syntax coloring and proper tab options), or a dedicated XML tool (no free tools comes to mind, but I'm pretty sure there are some).

--
Take all of this with a grain of salt though, as I have at most toyed with custom GUIs.

By the way, I really dig your "here's what I've stumbled upon" posts, such as the one on the readable book. Keep them coming !

The Bard of Althéa said...

Thanks elf des coquillages :)

That gives me a lot to look at, which I do need.

I'm glad you enjoy the blog. I will try to keep it as interesting as I can.

If anything catches your eye again, please comment.