Fast switching between your game and Weltmeister (ImpactJS)
For JIPPI I created a couple of tools to ease the development, one of them being a handy drop down menu which allowed me to open Weltmeister with the config file set to a particular sub folder of the levels and entities folders. This is something I intend to make into a ImpactJS plugin, but the state of the code is not quite ready. So it'll have to wait.
In Weltmeister's config file, you'll find a couple of lines that define which folders Weltmeister will look for entities and levels in. You can change these if you'd like to edit levels that are in a different folder than the default lib/game/levels. The config looks like this:
As you can see here, I've added two folders to the entityFolder settings. This makes Weltmeister look for entities in both. In my case, this was exactly what I wanted, because at the root of the entities folder, I had all the common entities, and under each sub folder were all the level specific entities.
In order to make Weltmeister open with the correct settings, I used a PHP script that edited the config file before routing the user to Weltmeister. I'm no expert in regex, so I simply copied the default config file to a separate folder, added a couple of strings for where I wanted to insert the name of the subfolder, and then let PHP do a simple search and replace before overwriting Weltmeister's config file.
My template file looked like this:
Here you can see the strings I added as placeholders.
The drop down menu was created by a PHP script that simply listed all the subfolders of the levels folder. When I clicked on one of the options in the drop down menu, the name of the subfolder was posted to a PHP script that created the new config file, and used PHP's header() function to route the user to Weltmeister.
To get back to the game, I added a play button to Weltmeister's toolbar that would route me to the index file.
I have no idea how much or little time this has saved me from either typing the full address of Weltmeister or switching between browser windows and manually editing the config file, but it sure feels like a lot of time has been saved.
When open Weltmeister from the drop down menu, Weltmeister will still remember the last opened level and open that. But when you save the level, it will be saved to the subfolder you clicked on the drop down menu. Very confusing! For now, you'd have to remember to load the level you want to edit once you've opened Weltmeister.
I'd like the drop down to be able to list levels in each subfolder so that I can jump directly to a level without having to manually load it from Weltmeister. I would also like the play button in Weltmeister to not only take me to the game but make the game load the level I'm editing. That way you can switch between the game and the editor with two clicks.