User Tools

Site Tools


en:tutorials:changing_default_config_file

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

en:tutorials:changing_default_config_file [2018/02/14 04:46 (2 years ago)]
iarwain ↷ Page moved from tutorials:changing_default_config_file to en:tutorials:changing_default_config_file
en:tutorials:changing_default_config_file [2018/07/03 16:09 (22 months ago)]
Line 1: Line 1:
-====== 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: 
- 
-<​code>​ 
-bin/​AlienAttack.exe 
-bin/​AlienAttack.ini 
-</​code>​ 
- 
-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: 
- 
-<code c> 
-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  
- orxConfig_Load("​MyRootConfig.ini"​); ​ 
-  
- return orxSTATUS_FAILURE; ​ 
-} 
-</​code>​ 
- 
-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. 
- 
-<WRAP center round important 60%> 
-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 
-</​WRAP>​ 
- 
- 
-Next, in the main() function, set the Bootstrapping function before the orxExecute line: 
- 
-<code c> 
-int main(int argc, char **argv) ​ 
- 
-  orxConfig_SetBootstrap(Bootstrap); ​ 
-  
-  orx_Execute(argc,​ argv, Init, Run, Exit); ​ 
-  
-  return EXIT_SUCCESS; ​ 
-}    
-</​code>​ 
- 
-Your application will now call its root .ini file from some other location relative to the .exe. 
en/tutorials/changing_default_config_file.txt · Last modified: 2018/07/03 16:09 (22 months ago) (external edit)