Code: Select all
REM This batch file manages multiple .ini for the Layout Editor
REM It takes one parameter, the name of the .ini file to use for this session
REM Note that there can only be one instance of the Layout Editor running
REM Running multiple instances will corrupt the active .ini file
REM Delete the previous ini file
REM This should not happen once the system gets going
DEL CELayoutEditor.ini 2>NUL
REM The batch file was passed the ini to use
REM Rename it to the name the Layout Editor expects
REN %1 CELayoutEditor.ini
REM Start the Layout Editor and wait for it to finish
REM Restore the ini file (in case the Layout Editor modified it)
REN CELayoutEditor.ini %1
This batch file runs under Windows and it should not be too difficult to create a version to run under Unix; there's not that much code going on.
I've modified the solution (CELayoutEditor.sln) for the SVN Layout Editor such that the executable is placed within CEGUI_head\bin, where you'll also find CEGUIBase.dll (among other). This setting is under Configurations Properties, Linker, Output File. I've also placed the CELayoutEditor.bat batch file in that same directory. Next I created a shortcut of the CELayoutEditor.bat file on my desktop. Finally I edited the properties (right click on the shortcut, go to the Shortcut tab) and added a parameter within the Target field, such that:
Your specific directory path will differ (the portion not in bold). The underlined text is the name of the .ini file I wish to use.
Here's a run down of the actions performed by the batch file.
1) Delete the existing CELayoutEditor.ini file. This removes an old .ini file. Once the batch file has been run at least once there should never be a CELayoutEditor.ini file anymore.
2) Rename the desired .ini file, the one specified through the parameter (CELayoutEditor-MyCustomINI.ini in my example above) to CELayoutEditor.ini, which is the name of the .ini file the Layout Editor expects.
3) Start the Layout Editor and wait for it to finish executing. This pauses the batch file while the Layout Editor is running. Once it is closed, the Layout Editor updates the .ini file (the CurrentLayout value) and the batch file is allowed to continue.
4) Rename the CELayoutEditor.ini to the name specified through the parameter. This removes the CELayoutEditor.ini and restores our custom .ini file (CELayoutEditor-MyCustomINI.ini in my example above).
5) The batch file closes.
There is a big gotcha when using this batch file. If a second instance is started then the .ini file will become corrupted; the second instance will delete the .ini of the first instance, activate the .ini of the second instance, and whichever instance finishes first will use that .ini the next time it is run and the second instance will have lost its .ini file.
There is also a small gotcha. When starting the Layout Editor through this batch file there will now be two tasks appearing alongside the Start menu; one for the Batch File and another for the Layout Editor application.