User Tools

Site Tools


This is an old revision of the document!

Changing the default application configuration file

When an Orx game or application starts, the matching config data file is expected to reside in the same folder as the executable, and to have the same name as the executable, minus the extension. For example:


When first executing the AlienAttack.exe file, the default bootstrapping seeks for the AlienAttack.ini file and begins processing it before Orx processes the init() function.

This default behaviour can be changed, allowing you to load your root configuration file from a completely different location, and with a completely different name.

This is done by adding a Bootstrapping function like so:

orxSTATUS orxFASTCALL Bootstrap() 
	// Add "../../data/config" to the list of locations that config files can be loaded from
	orxResource_AddStorage(orxCONFIG_KZ_RESOURCE_GROUP, "../../data/config", orxFALSE); 
	// Loads a specific config file 
	return orxSTATUS_FAILURE; 

orxConfig_Load is used to call the new root config file of MyRootConfig.ini. Because we added the new config resource path previously, Orx knows where to try and find the config file.

The return status is set to orxSTATUS_FAILURE. This effectively stops Orx from continuing to look for a default config, after the Bootstrap function has completed. If orxSTATUS_SUCCESS is returned, Orx will still try and load the default config located next to the executable, eg: AlienAttack.ini

Next, in the main() function, set the Bootstrapping function before the orxExecute line:

int main(int argc, char **argv) 
  orx_Execute(argc, argv, Init, Run, Exit); 
  return EXIT_SUCCESS; 

Your application will now call its root .ini file from some other location relative to the .exe.

en/tutorials/changing_default_config_file.1495599392.txt.gz · Last modified: 2017/05/30 07:50 (3 years ago) (external edit)