Bit Blot Forum

Aquaria => Modding => Topic started by: Yogoda on May 22, 2010, 11:00:21 pm

Title: Aquaria Editor Changes
Post by: Yogoda on May 22, 2010, 11:00:21 pm
When Aquaria goes open source, I would like to add some features to the editor so it is easier to use.

I think the most needed features would be :

- Being able to create a new map from the editor menu (specify map name)
- Being able to resize the map (specify new height/width)
- Being able to modify the terrain directly in the editor. For example press F8 to go in map edit mod, left clic to paint terrain, right clic to erase.

The following features would also be very cool to implement :

From the menu :
- Change the back color (top and bottom colors)
- Set the music
- Set the waterlevel

Something maybe a bit more difficult to do would be able to modify the tileset.

Any other ideas of cool modifications we could do ?
Title: Re: Aquaria Editor Changes
Post by: Lady-Succubus on May 22, 2010, 11:04:14 pm
Wouldn't the latter three be easier to do than the former? xD
Title: Re: Aquaria Editor Changes
Post by: Yogoda on May 22, 2010, 11:20:09 pm
I'm not sure, because we need to create a color picker for the color. But I did put them in the bottom because the 3 first seem more important ;)
Title: Re: Aquaria Editor Changes
Post by: Yogoda on May 22, 2010, 11:24:24 pm
And of course I would like to enable the debugger ! :)
Title: Re: Aquaria Editor Changes
Post by: Gobbo on May 22, 2010, 11:34:46 pm
I'd make it an out-game editor, like doombuilder is, and change the shortcuts to the more common ones, like Ctrl-c and Ctrl-v for copying stuff rather than shift-click or something. The layers could be easy tabs on the top of the screen. Alas, even simple stuff as lua is like portugese to me right now.
Title: Re: Aquaria Editor Changes
Post by: Lady-Succubus on May 22, 2010, 11:44:41 pm
I think leaving the editor in game is better. :3

What's the debugger? :3
Title: Re: Aquaria Editor Changes
Post by: Yogoda on May 23, 2010, 02:22:17 am
I'd make it an out-game editor, like doombuilder is, and change the shortcuts to the more common ones, like Ctrl-c and Ctrl-v for copying stuff rather than shift-click or something. The layers could be easy tabs on the top of the screen. Alas, even simple stuff as lua is like portugese to me right now.

Yeah, I thought about creating an external editor in C# for example, but that would definitely take me too much time ^^. Now that we are able to change the editor code, that's perfect.
Title: Re: Aquaria Editor Changes
Post by: Yogoda on May 23, 2010, 02:26:02 am
What's the debugger? :3

There is a debug.txt file in the Aquaria directory where you have all the things the engine does and the errors. It is possible to have those information displayed directly in the game in real time but this feature is disabled in Aquaria for now.
Title: Re: Aquaria Editor Changes
Post by: RoadCrewWorker on May 23, 2010, 03:09:45 am
Enabling the onscreen debug would be easy if you could inject the code of setControlHint in the debugLog function. I'd be more interested in enabling the Editor Gui in the main game (instead of working on the native mod and manually copying altered files back to the main game), but i fear the frameworks vary too much to easily be conjoined.
- Being able to create a new map from the editor menu (specify map name)
This is just a trivial file create, since an empty level contains nothing but the <level/> element.
Quote
- Being able to resize the map (specify new height/width)
Nothing in the map files contains specific maxwidth or maxheight. There is an obstruction layer containing all black unpassable areas of the map as "Row Line Length" segments which are generated from the maptemplate png using a simple loop over lines/rows of the image (using SDL hence requiring powers-of-two images im assuming). Ingame coordinates seem to be roughly 10*10 units per 1 template pixel (a 2048x2048 image results in a map from 0,0 top left to ~20000,20000 as the bottom right corner) so the mapsize is technically limited by the coordinate datatype (probably 32bit signed int). I'm not perfectly certain how well the game culls rendering/processing offscreen tiles,entities and nodes, so performance may take a huge dive.
Quote
- Being able to modify the terrain directly in the editor. For example press F8 to go in map edit mod, left clic to paint terrain, right clic to erase.
Considering the features of image editing software and the map storage format ("Terrain" itself is actually stored on two layers)  it's honestly easier to just alter the template file and regenerate the obstructions and attached border tiles (on layer 4) than build a brush based editor into the game.
Quote
- Change the back color (top and bottom colors)
- Set the music
- Set the waterlevel
These are all trivial plaintext values in the header section. A full blown HSV colorpicker would be considerably more effort than a simple "R G B" float string.
Quote
Something maybe a bit more difficult to do would be able to modify the tileset.
Well, you can easily switch out the tileset in the header of the level since its just a plaintext name of the referenced .txt file. Reading both old and new tileset lists and matching strings to identify the new IDs would be more difficult though. For most of my testing im using a complete tileset containing every png in the gfx folder and as far as i can tell the performance hasn't suffered too much. So you could theoretically allow the complete tileset in the editor and cull unused tileids while saving.
Title: Re: Aquaria Editor Changes
Post by: Lady-Succubus on May 23, 2010, 06:11:00 am
Showoff. :3

but it's nice to see how im/possible everything on the list is. Well done! ^.^
Title: Re: Aquaria Editor Changes
Post by: Dolphin's Cry on May 23, 2010, 06:39:01 pm
Ingame coordinates seem to be roughly 10*10 units per 1 template pixel (a 2048x2048 image results in a map from 0,0 top left to ~20000,20000 as the bottom right corner) so the mapsize is technically limited by the coordinate datatype (probably 32bit signed int).
I've researched the map file format for a private project, and I determined the scaling factor for the obstruction layer to be 20. Basically, I extracted the obstruction mask from the map file and plotted it against the node coordinates. Factor 20 makes everything line up nicely. ;)

By the way, the code that generates the obstruction mask seems to ignore the rightmost column of the source images. So if you use an image with 256 by 256 pixels, the obstruction mask only covers 255 by 256 units...

(http://img34.imageshack.us/img34/9196/tide.th.png) (http://img34.imageshack.us/img34/9196/tide.png)
Title: Re: Aquaria Editor Changes
Post by: Guy on May 23, 2010, 11:47:01 pm
That looks like a sweet program. Please tell me it's cross-platform :)
Title: Re: Aquaria Editor Changes
Post by: Dolphin's Cry on May 24, 2010, 12:21:31 am
It's written in Java, so it should run on Windows, Mac and Linux. Also the user must configure the path to the Aquaria installation and mod folder. ;)

As far as code quality goes it's not up to par with my usual code. I wrote it to learn SWT while exploring the Aquaria file formats. Right now it can display the contents of tile sets and (partially) of maps.
Title: Re: Aquaria Editor Changes
Post by: Yogoda on May 24, 2010, 12:59:43 am
Looks great :) Will you share it with us when it is ready ?
Title: Re: Aquaria Editor Changes
Post by: RoadCrewWorker on May 24, 2010, 03:45:40 am
Yeah you're correct, i think i mixed my testfiles 1024 and 2048 up.
(http://img34.imageshack.us/img34/9196/tide.th.png) (http://img34.imageshack.us/img34/9196/tide.png)
Thats really damn cool.

As an aside, Entities are stored as [ent_id+" "+x+" "+y+" "+r+" "+groupid+" "+scene_id+" "]* in the mapfile.
ent_id is a reference to the scripts/entities/entities.txt list,
x y r are coordinates and rotation (0-360 degrees = 0 to 12 o'clock) as used in tiles or nodes,
scene_id seems to be a unique id in the map.
Not sure what the groupid is used for ingame, or where the flags are stored.

For benchmarking reasons i've been able to populate maps with roughly 500 entities, although that predictably brought the game to it's knees. (Here's a hint: Generating a map that contains every boss entity in the game 25 times is a bad idea.)
Runs fine for me with up to ~300 though.

Title: Re: Aquaria Editor Changes
Post by: Dolphin's Cry on May 24, 2010, 11:11:59 am
Looks great :) Will you share it with us when it is ready ?
Sure, for a certain value of ready. ;) My original motivation for researching the Aquaria file formats was to create a mod editor, or in the case of Tide a "mod(est) editor". Aquaria already has a built-in editor for maps and animations, but there is nothing to help new users a create a mod. You have to create certain files and directories before you can start, and mostly this is done via copy&paste. Tide was supposed to fill in that blank by automating these menial tasks. :)

Right now I would be content if it would read all the mod files correctly without crashing on broken files. For the sake of making some progress with the level rendering, I have neglected the error handling. Now that's becoming a pain in the neck. ;)
Title: Re: Aquaria Editor Changes
Post by: Dolphin's Cry on May 24, 2010, 11:17:21 am
As an aside, Entities are stored as [ent_id+" "+x+" "+y+" "+r+" "+groupid+" "+scene_id+" "]* in the mapfile.
ent_id is a reference to the scripts/entities/entities.txt list,
x y r are coordinates and rotation (0-360 degrees = 0 to 12 o'clock) as used in tiles or nodes,
scene_id seems to be a unique id in the map.
Not sure what the groupid is used for ingame, or where the flags are stored.
Cool, thanks for the info. I expect the flags to be stored in the save files.
Title: Re: Aquaria Editor Changes
Post by: Dolphin's Cry on May 24, 2010, 02:23:20 pm
The format for entities that are not referenced in the entities.txt file seems to be a bit different. Apparently the ent_id value is replaced by "-1 "+ent_name, where ent_name is the name of the entity, i.e. the name of its script file with the ".lua" extension.
Title: Re: Aquaria Editor Changes
Post by: Guy on May 25, 2010, 03:12:40 am
I don't know what group id for entities is but the editor used to allow you to set a group number for nodes. It was removed though because it didn't actually do anything.
Title: Re: Aquaria Editor Changes
Post by: RoadCrewWorker on May 25, 2010, 09:03:41 pm
I don't know what group id for entities is but the editor used to allow you to set a group number for nodes. It was removed though because it didn't actually do anything.
Yeah, that sounds like a leftover UI element. Neither Paths (having only name attr) nor their contained list of Node elements (with x,y,width,height and shape id) seem to store a groupid attribute.

I wonder if the mentioned "-1 fallbackname" id syntax works for tiles as well.