As I said previously, this process wasn’t very efficient. So I rewrote large parts of the code for the conversion of NXT RPG XML data files.
File system
All files have so far been placed in the same folder. So I decided to organize it a bit:
- [folder] “global” : Contains all XML files that is used throughout the game
- [folder] “graphics” : Contains all graphics used in the game
- [folder] “levels” : Contains all levels used in the game
- [folder] “shared” : Contains all XSLT files used for previewing/converting files
- [folder] “strings” : Contains all strings used in the game
- fileindex.xml : Contains a list over all game files
fileindex.xml
I wanted it to be possible to choose your own names, so “level42.xml” could instead be “Scary shopping mall.xml”. So fileindex.xml contains these names. It looks like this:
<files>
<global>
<gamestart>gamestart.xml</gamestart>
<gamedata>Gamedata.xml</gamedata>
<character_list>character list.xml</character_list>
<attack_list>attack list.xml</attack_list>
</global><levels>
<level id="1">lvl_1.xml</level>
<level id="2">lvl_2.xml</level>
<level id="3">lvl_3.xml</level>
</levels><graphics>
<sprite id="1">bg1.xml</sprite>
<sprite id="2">bg2.xml</sprite>
<characters>characters.xml</characters>
</graphics><strings>
<string id="1">strings_1.xml</string>
</strings>
</files>
It should be rather straight forward.
<global>
- <gamestart> Filename of the file containing information needed for starting a new game.
- <gamedata> Filename of the file containing information about the game, the name of the game and such.
- <character_list> Filename of the file containing a list over all characters available in the game.
- <attack_list> Filename of the file containing a list over all attacks available in the the game.
<levels>
- <level id=”x”> Filename of the file containing the level data. “x” is a number from 1 to 254 which is used to identify the level.
<graphics>
- <sprite id=”x”> Filename of the file containing information about the graphics used for level maps. “x” is a number from 1 to 254 which is used to identify the graphic sprites.
- <characters> Filename of the file containing information about the graphics used for characters.
<strings>
- <string id=”x” > Filename of the file containing a list of strings. “x” is a number from 1 to 254 which is used to identify the string list.
Issue in Firefox
This just doesn’t work that well in Firefox. Style sheets accessed by “../” are blocked so basically nothing shows up if you try to open it. There is more about it here.
You can work abound the issue by opening “about:config” and change “security.fileuri.strict_origin_policy” to false. I don’t like it, but I’m not using Firefox so I’m not going to use time on it. However if any knows about a fix where it isn’t needed to move the files, inform me about it and I might fix it.
Graphic files
This needed to be a bit more organized. Up to now I had created a folder which was called the same as the ID for the level sprites (so something like “1”, “2” and so on…). Inside that folder was a image for each sprite, so quite a bit…
In NXT RPG however the graphics are stored in one .RIC file. So I wanted to do the same here so the file looks like this:
Together with the image there is a XML file like this:
<graphic>
<filename>Lv1_bg.png</filename><type>bg</type>
<id>1</id>
<sprites>30</sprites>
<size_x>10</size_x>
</graphic>
<graphic>
- <filename> The filename of the image containing the graphic.
- <type> The type of graphics. This can contain one of two values. “bg” is used for level sprites and “characters” is used for character sprites.
- <id> The ID of “bg” graphics. If <type> is “characters” this value must be “0”.
- <sprites> The amount of sprites contained in the image.
- <size_x> The size of each sprite in pixels. All sprites are quadratic at this point.
Implementation in HTML and CSS
An empty <div> is given a class called “[type][id]_[number]” where “[type]” is <type> (“bg” or “characters”), [id] is <id> and “[number]” is the sprite you want. An example could be “bg1_4” if you want the sign sprite in the image above.
The CSS is created dynamically and looks like this:
[class*="bg1_"]{
height:10px;
width:10px;
background-image:url('../graphics/Lv1_bg.png');
}
.bg1_4{
background-position: -40px 0px;
}
A “.bg1_x” selector is created for each value of “x”
Level files
Those were main reason for rewriting it all. In Opera 10.50 beta it got corrupted if the HTML file became too large. Well, it really was large from the start, but most of it was just level previews that where repeated. So I wanted to remove those of course. (It didn’t work properly in IE either, but who cares…)
I don’t fell like writing more right now, so I will make it short.
Every level in fileindex.xml is created and assigned a (html) id based on the level (XML) ID. Then some CSS is assigned dynamically to connect the Events with the correct level preview. I will update this part later…
Last heading
There is still a few things to get done, but most of the functionality is already done.
Any suggestions are welcomed.