Mod HQ

A fair bit of progress has been made over the last few days with loading the proto.xml data file, and more importantly, building an awesome looking GUI. The xml structure is fairly straight forward and simple enough to use an generic serialization class for most parts. I’ve found 3 unique mappings between XML and their object model representations:

  • Attributes packed in the parent node, such as the name of a unit
    <unit name=”Hawk”>…</unit>
  • Data stored in the value of nested elements, such as the line of sight of units
    <unit> <los> 12.000 </los> </unit>
  • Data stored in attributes within nested elements with complex selections, such as the action parameters
    <action> <param name=”MaximumRange” value1=”7.5″> </param> </action>

The first two are trivial to implement, and mostly cross-compatible, allowing a generic solution to cover almost all cases. The last one is much more difficult, as it requires looking into other attributes to select the correct element, and another attribute to get the value. To support these 3 cases, the following attributes were added to properties of classes.

ElementXml(tagName, requiredAttributes)

The first case will use just an AttributeXml, the second would use an ElementXml, and the third would use both, signifying that an element must be found, and an attribute from that element used. This combination has turned out to be extremely flexible, and has covered all cases in the file so far.

A game developer I follow spoke about how trying to break large ideas down into small projects can help see the idea through to completion, so I’ve used this xml loading to start building an AOM-compatible mod creator. The program will load the data from proto.xml and display all of the units inside, along with their data. It is incomplete at the moment, but should serve as a proof of concept.

Download (includes source, will require .Net 4.5)


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s