Tileset Edit Mode
- Dominant language
- C++
- Stars
- 12.9k
- Forks
- 2k
- Avg merge
- 4h 27m
- Merged PRs (30d)
- 8
Description
It would be EXTREMELY useful to be able to select a TILESET and enter EDIT MODE.
While in TILESET EDIT MODE, we would be able to:
- SWAP tiles (or groups of tiles) within the tileset (physically editing the base image), so that we could re-arrange the disposition of the base tiles, while preserving all the correct indexes in the MAP.
- SLIDE tiles (or groups of tiles) like if it is "Sliding puzzle game" (https://en.wikipedia.org/wiki/Sliding_puzzle), while preserving all the correct indexes in the MAP.
- Save (Replace pre-existing tileset image) or revert/abort all changes on exit EDIT MODE.
NOTE: a backup copy of the previous (original) tileset image file, would be a plus, in case of errors.
Sliding tiles, would be very useful to move tiles or tile blobs (groups of tiles) around using cursor keys or mouse drag.
A group or blob move, can always be decomposed as a sequence of single one tile moves (actual sequence depends on direction of move), which makes it easy to implement and support undo.
A simple one tile move, can be implemented to something similar to two calls to existing Map Tile Swap feature.
NOTE: might require an intermediate fictitious tile index, to avoid losing existing tile locations, after first Map Tile Swap call.
--- Further improvements ----
An alternative solution to actually physically editing the image, which would be more flexible, in case the image is used by several maps, is to support a "Tileset ReMap".
A tileset ReMap, is nothing more than an array to cross index or map all tileset tiles into new indexes.
By default this mapping (when defined), would create an "identity" map, which is a map function implemented by an array of indexes, where each index refers/maps to itself.
So that:
0 => 0
1 => 1
2 => 2
...
N =>N
Now if we enter Tileset Edit Mode, with an Identity ReMap and swap tile index 2 with tile index 0, we would get:
0 => 2
1 => 1
2 => 0
...
N =>N
So in Tiled, when this "Tileset ReMap" is active, we would see a "virtual" Tileset Image, instead of the real Image, so that a user can keep using Tiled as usual, but now he can remap/relocate tiles at will.
This allows for an optional layer of indirection, that allows to re-use the same image for several maps, without changes to the image.
Eventually, one will want to actually "apply" the "Tileset ReMap", which will consist in collapsing the ReMap by applying it's changes, by updating and saving the tileset image on filesystem and updating tiled real map indexes.
NOTE: If image is being used on other Maps, there are two choices:
- save with another name only for this Tiled Project, hence not affecting other maps.
- if the other map is using the same ReMap index, it can just be deleted in that map, since the image change/update will make it correct, once the ReMap is deleted.
This, implictly requires two more features:
- Cancel/Delete a ReMap, which leaves the tileset image and real Tiled Map untouched, i.e. just removes the ReMap.
- Have a way to import/export(save) a ReMap, so that it can be re-used on another Tiled Map
FINALLY, the better part :)
A ReMap can be implemented using another Tiled Map, like is similarly done by AutoMapping, with the only constraint, that this ReMap, must be the Exact same size (width x height) as the tileset image, and only have a single tileset.
This provides an easy implementation path, since editing this ReMap is already implemented in Tiled.
Only the re-indexing feature would need to be implemented, by using another Tiled Map as Re-Map.
This would also make it a lot easier for artist to provide a Re-Map, when they physically edit a tileset image, to correct/update existing Maps that use the tileset image.
This will be a very useful and powerful feature.
Contributor guide
Research direction
Start by reviewing the existing Map Tile Swap and AutoMapping features mentioned in the issue, then determine whether the scope is physical tileset editing, a Tileset ReMap, or both. Define the supported edit, save, revert, undo, and map-index behavior before implementation. Done means a user can rearrange tiles without breaking existing map indexes and can safely cancel or apply the changes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- desktop
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100