Page 1 of 4

test gui (source + binaries available)

Posted: 22 Oct 2005 02:19
by Alltaken
don't know how easy or hard it would be to code. i was just wondering if it was possible for a coder to write a standalone tile based drag and drop program.

it need not have any smarts as to what is what. all it needs IMO is to understand tile sizes, offsets (from a file), 32bpp, and be drag and dropable.

although perhaps that is a pretty larger task to do.

perhaps a 32bpp test version of the game would do that already LOL.

i was hoping i could test concepts for things such as sub-way systems (how they would look)....

Alltaken

Posted: 22 Oct 2005 07:44
by lucaspiller
Hmm, shouldn't be too hard to do.

Could you give a few examples of the tile graphics in the size they will be (if that makes any sense :P).

Posted: 22 Oct 2005 13:14
by Alltaken
sure i will try to sort it out (in a few weeks i finish uni on the 1st).

basicly i was hoping to test at multiple zoom levels. (so it would need to know them)

64x31
128x63
256x127

and i guess it would have a base grid where the offsets are taken from, then would need for each tile to be moved up a level. (16 pixel offset@ 128x63 i think)

i think thats about all it would need.

this is what i have currently on it.
http://wiki.openttd.org/index.php/Groun ... raphics%29
http://wiki.openttd.org/index.php/Groun ... raphics%29

thanks

Alltaken

Posted: 23 Oct 2005 23:40
by lucaspiller
Righty, I have done a little tool that does basically all of this, so here is a bit of documentation to wet your appetite. The download is at the bottom.

File Format
The data files are stored in the data/ directory, and then each tileset is stored it its own directory. A tileset consists of three different images for each tile, one for each zoom level, and a data file.

So you end up with something like this:

Code: Select all

data/
|-- blank
|   |-- blank0.bmp
|   |-- blank1.bmp
|   |-- blank2.bmp
|   `-- info
`-- shoreline
    |-- info
    |-- shore0.bmp
    |-- shore1.bmp
    `-- shore2.bmp
The images have to be in bitmap format, and have a colour set as the transparency colour - this is just for simplicity, and could quite easily be changed if needed.

The data file itself needs to be called info, and holds the image file name, transparency colour, what zoom level it is for, and offsets. An example of this is below:

Code: Select all

shore0.bmp R255 G0 B0 Z0 X0 Y-32
shore1.bmp R255 G0 B0 Z1 X0 Y-16
shore2.bmp R255 G0 B0 Z2 X0 Y-8
The first part is the image name, the numbers after R G and B refer to the transparency colour for each colour, t he number after Z refers to the zoom level, and the numbers after X and Y refer to the tile offset. This could quite easily be in any sort of format you want, but again for simplicity I chose this format.

The blank and big_tile_select tilesets are used for displaying the grid, and as such you cannot place them as tiles, but if you want you could make the images a bit nicer.

Default view
When you first load up the program you will be presented with the following. It may not look very colourfull, but it is fully 32bpp and does the job.

Image

The isometric view will show you the tiles when loaded, and the bit on the right lets you select tiles. If you are lucky enough to have a web browser that can display images you will be able to see that the spacebar, arrow keys, and page up / page down keys do special tasks.

Adding a tile
To put a new tile down press the space bar, and then click on a tile name that sounds tasty. These refer to the folder names that we were talking about earlier. Once you have clicked a name the bit on the right hand side will change, like this:

Image

These refer to the positions of the tiles on the grid. Unfortunately there is one problem, it is 12:30 in the morning, and I can't be bothered to fix it: The tiles in the top left of the small grid refer to the tiles in the bottom right of the big grid (and vice versa), this isn't that much of a problem though and you get used to it after a while. So select an position, and voila - you should have something like this:

Image

Now place a few more tiles so it looks nice, and then move on to the next bit.

Selecting tiles
If you click on one of the tiles in the small grid, the coresponding one (note the bug) in the big grid will now have a funny little indicator over it. This will stay there for around 15 seconds and then dissapear.

Image

All you can actually do to a tile at the moment if change the height of it, so before the indicator disapears press Q or A - after you have pressed these it will stay there for another 15 seconds.

Image

As you can see the tile has magically gone up one height level (the offsets are slightly screwed, but as I said earlier I can't be arsed to fix it).

I think that is about it, but I probably forgot something so here are some more screenshots.

Image
Image

Credits
It is all done by me, except:
- Font stuff (font.cpp and font.h) by Cone3D
- Sample tiles, by Alltaken

Download is below, released under the GPL so do basically whatever you like with it. Binaries will probably be posted tommorow unless anyone beats me.

Posted: 24 Oct 2005 01:38
by scrooge
Wow, what a nice program :D Makes me really excited for the 32bit version of OTTD :D

Posted: 24 Oct 2005 08:19
by Alltaken
will test it out when i get off uni.

in the mean time. 32bpp PNG support would be "fantastic", i can of course convert to BMP with black borders, however i would like the images going into the program to be as close as possible to the game ones.

great work BTW, looks like just what i needed.

if this is good enough/developed into the future it would be able to be turned into the tile/image editing software that artists can graphically set up offsets and this spits out the results for the game.

did i say great work :D

Alltaken

Posted: 24 Oct 2005 10:42
by lucaspiller
Windows binary (at last)...

It is compiled with Cygwin which is why it is so big, for some reason the Dev C++ version didn't work, and I haven't got much time to sort it at the moment.

Also don't forget to get the data files from the soure package above.

Posted: 24 Oct 2005 12:38
by Bjarni
here is a mac binary

I changed it a bit to make it link statically to SDL, so it will work for everybody that can run OpenTTD

Basically I changed one line

Code: Select all

LIBS = $(shell sdl127-config --static-libs)
the reason why it's sdl127-config is that I got both 1.2.7 and 1.2.8 and I appear to have static linking problems with 1.2.8

You will still need the data files from the source as this is just the binary (with OTTD icon... looks better than the generic one)

I also added an app package so it can be opened from finder (instead of terminal only). See the OTTD makefile on how to do that if you want to know

Posted: 24 Oct 2005 14:50
by Alltaken
BTW your structure for files is really good :D i.e. having three zoom levels loadable at the same time.

thanks to whoever made this sticky.

Alltaken

Posted: 24 Oct 2005 14:55
by Bjarni
Alltaken wrote:thanks to whoever made this sticky.
I did that. I hate searching a forum because somebody posted a file a while ago

Posted: 24 Oct 2005 15:50
by lucaspiller
Ok, here is the second version. Not much has changed except for PNG support, and a slight restructuring of the files.

New File Structure
All the data files now needed for the program to run are now in the data/ directory, because of the searching stuff all the tilesets need to be in a seperate directory, so are now in data/tiles/. Also the blank tileset has been renamed to bnk and the big_tile_select tileset has been renamed to bts.

More image format support
We also now have PNG support, but you also need SDL Image in order to compile the game. This means you can load a variety of other formats as well, see this for a full list. For simplicity sake I also removed the bit from the info file to specify which colour is transparent, so unless the format you are using supports transparency, you will not have transparent tiles (can any other than PNG on the list?). The new info file format looks like this:

Code: Select all

shore0.png Z0 X0 Y-32
shore1.png Z1 X0 Y-16
shore2.png Z2 X0 Y-8
Another thing I don't think I said about zoom levels was that zoom level 0 is the biggest, and zoom level 2 is the smallest.

Tile Creator
If you are on a Unix-based system and you have Image Magick and Wget installed you can use the auto tile creator tool. It takes a 128x63 image and resizes it to the bigger and smaller versions, and creates all the directories and files needed. It is in the data/ directory and called ctile.sh. It takes two arguments, the first the URL of the image, the second the directory you would like the image to be placed in. For example:

Code: Select all

$ ./ctile.sh http://doug.mudpuddle.co.nz/albums/ground/dark.png water1
Other stuff
Makefile changes, program icon and caption, some random rubbish I forgot...

For now it is just a source release as I am waiting for Bjarni to compile it on his Mac. This version requires SDL Image, which he is having a few problems with. There is also a wiki page.

Posted: 24 Oct 2005 16:06
by Darkvater
I must say (haven't tried it yet) but from the screenshots it looks really nice :)

When I have time (yes when), I'll see if i can fix the offsets as it seems easy enough.

Posted: 24 Oct 2005 16:56
by dmh_mac
Great little program.
Don't know much about coding (yet) but I think the x offset shouldn't change when you change the height levels.
Maybe it's in line 188 of main.cpp (I'm probably completely wrong though).

Posted: 24 Oct 2005 18:19
by Darkvater
Okay, voila

It can now compile on windows (you need SDL_image and SDL, both present in the executable zip). If you want to compile you need the SDL devel files as said before. Put them in the SDL\ subdirectory of your includes or change the settings :)

I fixed the x-offset with tiles; just as dmh_mac said, x doesn't change when you move your tile. I also added a new() to the _tile_image..name thingie since on windows (when you close the directory) the file points to the same thing. Didn't bother deleting it, I'll leave that up to the person that wants to put this product into production ;P

Image

Look for binary/source on page #2

Posted: 24 Oct 2005 19:11
by Bjarni
finally I managed to solve the lib/linking issues when porting to OSX :D

So here it is. I applied darkvater's diff so the offset is fixed

Posted: 24 Oct 2005 19:47
by osai
Bjarni wrote:finally I managed to solve the lib/linking issues when porting to OSX :D

So here it is. I applied darkvater's diff so the offset is fixed
I am using OSX 10.4.2 and it doesnt work for me.
When trying to start it, it immediately closes.
Maybe i am missing some files :?:

Posted: 24 Oct 2005 20:21
by nicfer
I too have that problem but in winXpSp2. I think that I am lacking the data folder from the source.
EDIT: Continues closing the program after copying the data folder. This is the error that the program gives:

Code: Select all

Loaded tileset `shoreline` (2)
Loaded tileset `water` (3)
ERROR!
Failed to open image `tile_select.bmp`
ERROR!
Failed to open image `filled_tile_select.bmp`
     10 [main] tt 3612 handle_exceptions: Exception: STATUS_ACCESS_VIOLATION
   3434 [main] tt 3612 open_stackdumpfile: Dumping stack trace to TT.exe.stackdump

Posted: 24 Oct 2005 20:48
by Bjarni
osai wrote:
Bjarni wrote:finally I managed to solve the lib/linking issues when porting to OSX :D

So here it is. I applied darkvater's diff so the offset is fixed
I am using OSX 10.4.2 and it doesnt work for me.
When trying to start it, it immediately closes.
Maybe i am missing some files :?:
you need the data files from the source
it will tell you that in console (/applications/utilities/console). That's generally a good place to look if an app behaves odd

Posted: 24 Oct 2005 21:42
by Darkvater
Yeah, you guys need the data/ folder from lucaspillers original files. It seems a waste posting the same binary stuff a dozen of times, doesn't it ;) ?

Posted: 24 Oct 2005 21:48
by lucaspiller
Ok, thanks Bjarni and Darkvater - this really shows the beauty of FOSS. :D

I have a couple of questions about your patch though DV (ok one):

Code: Select all

@@ -159,7 +190,7 @@
 					}
 				} else {
 					if (y > 10 && y < 210 && x > screen->w - 210 && x < screen->w - 10) {	
-						x2 = (screen->w - x - 10) / 40;
+						x2 = 4 - (screen->w - x - 10) / 40;
 						y2 = (y - 10) / 40;
 						printf("Tile X: %d Tile Y: %d\n", x2, y2);
 						if (tile_to_place == NULL) {
Firstly, where did this 4 come from?
DV wrote:Didn't bother deleting it, I'll leave that up to the person that wants to put this product into production ;P
Deleting what now? :shock:

Also I can't believe I forgot to add fclose and closedir. :x

SLaY3r: Make sure you have the data files from tile_tool-2.tar.bz2 and you are using the binary in tile2_140.zip.