Game Development Reference
In-Depth Information
To add this functionality to our own project, we just need to add iwutil to the
subprojects list of the MKB file and then add a call to IwUtilInit at the start of
our program, and IwUtilTerminate in our shutdown code.
Before we can use the text parser, we will need to create an instance of it by using
new CIwTextParserITX . This class is a singleton class, so we can create an instance
of it at the start of our program and then reuse it as much as we like in the rest of our
code (don't forget to release it on shutdown!). The instance can be accessed using the
IwGetTextParserITX function, and we can then load and parse an ITX file using the
following code:
IwGetTextParserITX()->ParseFile("myfile.itx");
An ITX file is little more than a big collection of class definitions. An instance
of a class is defined by first putting the name of the class followed by a list of
parameters for that instance enclosed in curly braces. Let's say we had a class called
WidgetClass that was defined as follows (don't worry about the CIwManaged class
and the IW_MANAGED_DECLARE macro for now, we'll come to these in a bit):
class WidgetClass : public CIwManaged
{
public:
IW_MANAGED_DECLARE(WidgetClass)
WidgetClass();
private:
uint8 mColor[3];
int32 mSize;
bool mSparkly;
WidgetClass* mpNextWidget;
uint32 mNextWidgetHash;
};
Here is an example of how we might instantiate this class from within an ITX file:
WidgetClass
{
name "red_widget"
color { 255 0 0 }
size 10
sparkly true
}
WidgetClass
{
name "green_widget"
color { 0 255 0 }
 
Search WWH ::




Custom Search