Game Development Reference
In-Depth Information
Defining new ICF settings
One of the best things about ICF files is that we are able to make use of them
ourselves by creating our own custom settings. To define new settings we just need
to add them to the file app.config.txt , which is automatically generated for us
when creating a new project using an MKB file.
When defining new settings, we can also provide a string of text that explains
what this setting is for. While this description isn't actually used or needed by the
Marmalade SDK, it's a good way of documenting what a setting is supposed to do!
It is, however, important to add definitions for all our settings to
the app.config.txt file because it will prevent the application
generating lots of asserts when it is executed. In a Windows Debug
build, Marmalade checks to see if an ICF setting has been declared
both when loading the ICF file at the start of execution and also
whenever we try to access a setting from within our own code.
We can also define our own section identifiers in the app.config.txt file simply
by listing the name of the section in square brackets and following it with the
new setting definitions. Here's an example illustrating how to create new section
identifiers and settings:
[GAME_DEBUG]
SkipToLevel Skip to a level at game start
[GAME]
FrameRate The frame rate we want the game to run at
MaximumHealth Amount of energy the player has at game start
Defining our own section identifiers can be extremely useful when creating library
modules, such as the GUI and Localise modules created in Chapter 6 , Implementing
Fonts, User Interfaces, and Localization . The only difference when creating a module
is that the app.config.txt file changes to modulename.config.txt and it should
reside in a subdirectory called docs in the module's main directory. As an example,
if we were to add our own settings to the GUI module we would create a directory
called GUI\docs , and the file that lists the settings would be called GUI.config.txt .
Accessing ICF settings in code
It's very little use to be able to provide settings in the ICF files without some way of
accessing them. This is where the s3eConfig API comes into play and we can use it
by just including the s3eConfig.h header file.
 
Search WWH ::




Custom Search