mapeditor / tiled

Flexible level editor
https://www.mapeditor.org/
Other
11.24k stars 1.76k forks source link

Use source image size on unscaled objects after exchanging the source image. #2985

Open TrunXGIT opened 3 years ago

TrunXGIT commented 3 years ago

(Thats an issue we already discussed in Discord a few weeks or months ago, but I forgot to open an issue as suggested. So I catch up on it now.)

Right now, if you place (image-) objects on a map the absolute size of the objects gets stored for each individual instance of the object. If you exchange the source image with a new one. All the placed objects will keep their old absolute size. So if the new image source is wider or higher all the objects will appear stretched or compressed.

Example: I have a map with a lot of decorative flowers and some bigger trees (alignment bottom-center). After I replaced the source images of the flowers and trees with new more beautiful ones that have a slightly different image size all the flowers and trees will appear stretched or compressed on the existing maps.

My suggestion for a (long-term solution) was to use scale variables instead of absolutes sizes, so a scale of 1 keeps always the original image size and a scale of 2 will always double it (keeping the integer scaling for pixel art games) even after changing the source image or its canvas sizes. But I understand that it might be a too fundamental change to the object properties.

The solution @bjorn suggested instead was to not store the width and height values if the object has not been resized which would solve the problem for unscaled objects at least.

eishiya commented 3 years ago

While applying the same scale to the new size may work for decorative objects, it's inappropriate for objects that were given specific sizes for gameplay purposes, such as platforms and doors. Because of this, I think the current behaviour (keep the old size for unscaled objects) makes for a good default, but a behaviour toggle would be great for dealing with decorations.

TrunXGIT commented 3 years ago

I see what you mean. But even in this case I see more benefits in the scale instead of size solution. In a game with a 16x16 grid I would use a 16x16px² basic object to represent the smallest possible platform that can be scaled on one or both axis. A xscale of 5 would mean that that the platform is 5 tiles wide and a scale of 10 would mean its 10 tiles wide. So its easier to edit and read how big the object is by looking at the scale property. In game I would replace that scaled image with corner and looping middle parts, so it will look nice.

Edit: I think I misunderstood your reply. It was just referring to the last sentence and in this case I can agree, that some might prefer to keep their old absolute size. So an option would be indeed nice.

bjorn commented 3 years ago

Just to make to sure, the current workaround for this, if you don't actually want to scale any of your objects, is to select all objects on the map and choose "Reset Tile Size" from the context menu.

Indeed it's a little bit hard to decide what to do by default given the different use-cases of tile objects. I think it's reasonable to derive an object's size from its image and adjust it accordingly when it changes, as long as the object hasn't been resized. It may be a little tricky to implement though. One downside of using the presence of the attributes is that in case of a broken tileset reference, we'd no longer know the intended size of the object, but this just means we need to adjust the way objects are rendered in this case to be size-agnostic (currently a dynamically drawn marker the size of the object, but could be an icon instead).

I hope we can avoid a "Use persistent size for tile objects" option... it's extra work and needs extra explanation and is there really somebody who needs it?

patchuby commented 1 year ago

I'd like to answer to that last question! I'm doing an isometric game, so all of my tile uses are 'decoration' (purely graphical in purpose) and I use big backgrounds (that I slice up later for the actual game engine). So the slightest change in the source image will offset my maps in a visible way, due to the scaling that occurs. So I think pretty much everybody doing isometric maps needs this ?