If this is your first visit, be sure to check out the FAQ by clicking the link above. You have to register before you can post.

If you have recently signed up, please make sure you log in so that your activity is registered. This is required for automatic promotions to work and to ensure your account is not deleted during the registration process.

Not sure. I feel too comfortable with Allegro. And I'm used to the new API introduced in version 5, it wasn't so hard as I initially thought. I tried SDL before and I didn't like it too much.

there doesn't seem to be a big difference between the two. I choice Sdl 2 as it seem's the most popular. my needs are small since I work mostly with my own code. I am working on similar tools but more focus on procedural design. at the moment I am reworking the core a bit so it would be easier to adapt to other frameworks like Allegro. I had hoped that there would be a pdg game engine but it seem's the tweaker's killed any chance of that. I would have adapted my work to it. any progress in your work?

Interesting to read a thread like this...
@Ñuño Martínez, sorry for not replying, I don't remember ever seeing your mail.

Anyway, I've tried get Tile Studio to compile in Lazarus many times over the years and always failed, until this time.

Now I got the tile editor working (almost) completely. The map editor however doesn't do much. There are some really strange things going on with the Canvas.Draw function with transparent bitmaps.

It took me quite a while to figure out that the behavior of TabControl.TabIndex and Form.Resize are different from Delphi in whether events are fired or not. I don't know if such things are bugs or maybe intentional choices.

Interesting to read a thread like this...
@Ñuño Martínez, sorry for not replying, I don't remember ever seeing your mail.

Don't worry. You're here now!

Originally Posted by Wiering

Anyway, I've tried get Tile Studio to compile in Lazarus many times over the years and always failed, until this time.

Now I got the tile editor working (almost) completely. The map editor however doesn't do much. There are some really strange things going on with the Canvas.Draw function with transparent bitmaps.

I know, I had the same problems. No idea why it doesn't work correctly.

Originally Posted by Wiering

It took me quite a while to figure out that the behavior of TabControl.TabIndex and Form.Resize are different from Delphi in whether events are fired or not. I don't know if such things are bugs or maybe intentional choices.

I recommend to use TPageControl instead. The advantage is you don't need to "draw" the stuff by yourself tracking the tab changes. The bad thing is that it may need more memory but I think it is not your case.

Use subdirectories! Please. "src" for sources and "bin" for the final binary. And "docs" for documentation. Really, it will help a lot.

The main problem I had when I worked with your code is that most of it is in the main form. That mean thousand controls and it's hard to keep track of they all. You should split the stuff, using TFrame for different control groups (i.e. I did a TFrame for the "brush" selector, another one for the tiles selector, etc). This will also group your code and increase the order.

Also separate "logic" and "GUI" should help too. For example, split the "tile selector" in two units, one for the logic (i.e. add, remove, replace, load, save...) and the other will be the GUI that just renders the tiles and allows the user to select one of them.

There are some really strange things going on with the Canvas.Draw function with transparent bitmaps.

Originally Posted by Ñuño Martínez

I know, I had the same problems. No idea why it doesn't work correctly.

Can you guys provide some more information about this so together we might try to figure this out.

Originally Posted by Ñuño Martínez

Also separate "logic" and "GUI" should help too. For example, split the "tile selector" in two units, one for the logic (i.e. add, remove, replace, load, save...) and the other will be the GUI that just renders the tiles and allows the user to select one of them.

Separating logic from GUI is always a good approach. Why? Because by doing so you are making first step toward multiplatform support since usually the main difference between different platforms is the way how GUI is handled. Not to mention that you might also be opening yourself an option to start moving some lengthy operation into separate threads if needed.

I know the code isn't very well structured. The whole project started as a little tool for myself which I kept expanding.

Can you guys provide some more information about this so together we might try to figure this out.

Bitmap transparency doesn't seem to work properly in Lazarus (or very different from Delphi at least). At first I thought it didn't work at all (posted an issue here http://bugs.freepascal.org/view.php?id=31556 ), but now I see that it does work if you set up the transparent color first. However, once you draw the bitmap onto something else, it forgets its transparent color, but somehow does keep a mask of the transparency you had before. In Delphi, you can just set the transparent color at any time and it will draw the image accordingly. Here is a simple program that behaves differently in Lazarus and Delphi, see the result image below.

Bitmap transparency doesn't seem to work properly in Lazarus (or very different from Delphi at least). At first I thought it didn't work at all (posted an issue here http://bugs.freepascal.org/view.php?id=31556 ), but now I see that it does work if you set up the transparent color first. However, once you draw the bitmap onto something else, it forgets its transparent color, but somehow does keep a mask of the transparency you had before. In Delphi, you can just set the transparent color at any time and it will draw the image accordingly.

(...)

[Edit] I found a workaround by adding Bitmap.Mask() before every Draw, which is probably very inefficient, but now the maps are rendered correctly.

That may explain the erratic behaviour I had. Some times it works, some times it doesn't...

Two big red flags I noticed in the source: the "WriteBitmapToPNGFile" and "ReadBitmapFromPNGFile" procedures in Tiles.pas. They simply won't work as written, in Lazarus. No matter what extension you provide the write procedure, it will always be saved as an actual bitmap (open something you've saved like this in IrfanView if you want to confirm, it will show a message alerting you about the wrong extension.) The read procedure will just straight-up raise an exception that says "Wrong image format." Here's refactored versions of both that work as intended for me:

My game engine has its own simple and limited map editor but once TileStudio is up and running I'll work on one or two tsd files if possible (I'm using IFF file format and need to calculate sizes in bytes).