HOWTO: Multiple .ini configurations for the Layout Editor

Use this forum for:
- Discussion regarding unofficial CEGUI related tools, scripts and utilities.
- User to user help for the obsoleted CELayoutEditor and CEImagesetEditor tools.

Moderators: CEGUI MVP, CEGUI Team

Rackle
CEGUI Team (Retired)
Posts: 534
Joined: Mon Jan 16, 2006 11:59
Location: Montréal

HOWTO: Multiple .ini configurations for the Layout Editor

Postby Rackle » Sun Dec 17, 2006 18:11

In the past I would create multiple folders in order to maintain multiple probjects. For example one folder for my Wiki projects and another folder for my own personal project, with its own set of resource files. However when I update my version of the Layout Editor I then have to update multiple folders. Not the best of situations. And once I switched to the SVN version, which updates much more frequently than the downloadable version, this becomes a nightmare. So I made this little batch file to help manage these multiple .ini files:

CELayoutEditor.bat

Code: Select all

@echo off

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
CELayoutEditor.exe /k

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:

C:\Ogre\CEGUI\CEGUI_head\bin\CELayoutEditor.bat

becomes:

C:\Ogre\CEGUI\CEGUI_head\bin\CELayoutEditor.bat CELayoutEditor-MyCustomINI.ini

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.

Pompei2
Home away from home
Home away from home
Posts: 489
Joined: Tue May 23, 2006 16:31

Postby Pompei2 » Thu Dec 21, 2006 00:24

sounds very useful, good idea !


Return to “Unofficial CEGUI-Related Tools”

Who is online

Users browsing this forum: No registered users and 9 guests