mapeditor / tiled

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

Ability to re-arrange tilesets in tileset window is broken. #1613

Open JamesO2x opened 7 years ago

JamesO2x commented 7 years ago

In older versions of Tiled, you were able to re-arrange the tilesets in Tiled's tileset window by click-n-dragging on the the tileset's tab. This also restructured the "firstgid" value in the TMX file, and reorganized the map's data accordingly.

As of 1.0.0 and 1.0.1, this feature no longer works. The only way to re-arrange tilesets now is to delete the tileset, and re-add it at the end of the list. This obviously also breaks your maps, and will remove any tile data on the map.

To verify that this feature did work in past versions, I re-downloaded version 0.18.2 and recorded this GIF: tiled 18

This feature is vital to me, because my game engine expects certain tilesets to be loaded in a certain order (for example: collision_tileset > level_specific_tilesets > tilesets_only_used_wihle_level_editing)

bjorn commented 7 years ago

Hmm, this feature was removed because the Tilesets view now displays all loaded external tilesets regardless of which map is selected. Since it no longer reflects just the tilesets used by a single map, I chose to simply order them alphabetically, though that's just for display purposes.

The order in which the tilesets appear in the map file should be irrelevant so I'd rather not introduce additional UI for having this option again. How hard would it be for you to use something else than the tileset order to determine when to load each tileset, like a custom tileset property for example?

JamesO2x commented 7 years ago

Well I'm using a plugin that loads TMX files, and I don't have the source to it. I think the plugin simply reads the tilesets in the order that they are listed in the file, incrementally. There are certain tilesets that I skip loading, and I think this is causing errors that didn't manifest before I installed Tiled 1.0 for some reason.

This may be more of an issue on how the plugin I'm using is reading the TMX file, and not necessarily Tiled's fault. Or it could be my own error. I'm gonna play around with it and see if I can find anything. I'll report back if I can figure out what went wrong on my end.

Regardless, I do miss the ability to organize my tilesets how I want. But I suppose it is a minor issue, and I can adjust.

Keep up the great work! Tiled is such a time saver!

alaa-eddine commented 6 years ago

Just updated from Tiled 0.18 to 1.0.3 and noticed that the feature is missing it was driving me crazy :D in my case, I was using the possibility to rearrange tab to optimize the work. for example, this allows to arrange all interrior tilesets then exterrior , or putting the most used tilesets to the left so we don't have to scroll each time between all the imported tilesets to find the ones we are using ... we can live without it, but I think it can still make sense .

another usage I had with this, is that I put a special tileset at index zero, this allows me to handle a special set of tile in my code starting from index zero ... this is very specific tho, and I have a workaround for it as the special tileset is only imported once.

bjorn commented 6 years ago

Just updated from Tiled 0.18 to 1.0.3 and noticed that the feature is missing it was driving me crazy :D in my case, I was using the possibility to rearrange tab to optimize the work. for example, this allows to arrange all interrior tilesets then exterrior , or putting the most used tilesets to the left so we don't have to scroll each time between all the imported tilesets to find the ones we are using ... we can live without it, but I think it can still make sense .

Thanks for adding another note to this. I definitely agree we need to improve the efficiency of tileset selection, I'm just not sure if manual ordering is still the way to go now that all loaded tilesets are displayed. At least, it would currently be complex to implement since there are both embedded and external tilesets, and the view is not showing tilesets embedded in other loaded maps, since that would lead to a lot of duplicates.

Some alternative solutions I could think of:

another usage I had with this, is that I put a special tileset at index zero, this allows me to handle a special set of tile in my code starting from index zero ... this is very specific tho, and I have a workaround for it as the special tileset is only imported once.

For this scenario I would say it's preferable to use a custom property to mark your custom tileset rather than its position in the map file.

alaa-eddine commented 6 years ago

Make the list of displayed tilesets manually controlled. So there's the complete list somewhere, and then you could put the ones you'd like to use in the tileset view (and control their order). I think this could work well in combination with support for Projects (#1665).

This would be a perfect solution, the complete tilesets list could be showed in a checkboxes list, when you can select the visible ones, the arrangement could be done using tabs or within the checkboxes list ... then if a project is used, the checked tilesets list will represent the project tilesets.

bjorn commented 5 years ago

Feature also asked for on the Tiled forum. I've now put it on the roadmap so that it isn't forgotten when I get around to working on project support.

KitteyWolf commented 1 year ago

Replying to questions from here: https://github.com/mapeditor/tiled/issues/3552#issuecomment-1373411275

On the wiki its mentioned in the editing map section that if you are editing a pre-existing map that you can't reorder the tilesets [it suggests adding a Z or something to make sure they load after- but its frustrating that you have to do that] https://stardewvalleywiki.com/Modding:Maps#Map_edits Screenshot 2023-01-06 at 03-09-28 Modding Maps - Stardew Valley Wiki and in addition smapi says this: update

bjorn commented 1 year ago

@KitteyWolf Hmm, this documentation is rather misleading. When you add a tileset to a map, Tiled always adds it to the end of the list in the map file. There is no way to change the order of any existing tilesets used by the map at all, apart from removing one of them.

The Tilesets view will show the tilesets ordered by their name alphabetically, but this is independent of the order in which the tilesets are referenced by the map, so prefixing the name with "z_" seems rather pointless, apart from making it clear that it is an added tileset.

KitteyWolf commented 1 year ago

@bjorn the issue is that whenever i add a new tileset it doesnt add it to the end... it adds it whereever it wants- normally between for example 'paths' and 'untitled' so the ONLY way to make it appear correctly after the initial tilesets is to add 'z_' to the name.

bjorn commented 1 year ago

@KitteyWolf I think you're confusing the display order of the tilesets with the order in which they are saved in the map file. These are independent. New tilesets are always added to the end of the list of tilesets in the map file, but the tilesets are displayed in alphabetical order in the Tilesets view. Since the latter does not affect the order in the file, the renaming should not be needed and is also not expected to fix anything.

KitteyWolf commented 1 year ago

@bjorn the way i got that error read out in SMAPI was i added a new tileset [which was added BEFORE 'paths' in the viewer. then i did nothing else but SAVE the document, and then i got the unable to load error.

So something is wrong with what you're saying.... Because the ONLY way to make it not crash any longer was to append z_ onto the tileset, reopen the map, and then save it with the tilesets having been renamed...

eishiya commented 1 year ago

What bjorn described is correct - if it wasn't, all of my maps would be completely broken in my janky game engine xP

Does SMAPI read TMX files, or TBIN files? Perhaps there is an issue with the TBIN exporter sorting tilesets by name. What bjorn said applies to Tiled's own map formats (TMX, TMJ), plugins may behave differently. If it is reading TMX/TMJ files, then it may be an issue with SMAPI - perhaps it sorts the tilesets by name for some reason (this can happen by accident in some languages, e.g. by storing the tilesets in a dictionary by name instead of in an array).

KitteyWolf commented 1 year ago

@eishiya
sorry eishiya but this has nothing to do with your random stuff, this is clearly something to due with the way stardew valley loads...

The maps are TBIN in file-type. I'll upload a video showing proof once youtube processes it.

KitteyWolf commented 1 year ago

@bjorn proof of the issue. and proof that adding z fixes my problem. I load the game and it works fine. i add a new tileset [which adds it to the tileset viewer in the middle] i load the game and get the crash log i rename the tileset with z and save the map again and it loads perfectly fine.

I don't think i can be any more clear about how broken this is. https://www.youtube.com/watch?v=poyrHmWvJ-E

eishiya commented 1 year ago

As I wrote above, what bjorn said applies to Tiled's native formats, such as TMX. It's possible TBIN stores tilesets in a different order. Looking at the TBIN write() code, it doesn't look like that's the case thoughm so it still seems more likely that the issue is with Stardew Valley or with SMAPI sorting the tilesets by name.

Have you looked at the files that Tiled writes to see whether the issue is actually the file and not the loader? Although TBIN is a binary format, the tileset names and order are still visible if you view it in a text editor. (And of course, if you look at a TMX file, the order will be exactly as Bjorn said - but that's not relevant in this case.)

Edit: I did some tests. Tiled's TBINs have the exact same order as the TMX files - i.e. the order you add the tilesets in. The issue you're experiencing comes from either Stardew Valley or SMAPI, and has nothing to do with Tiled. Tiled is doing what it's supposed to, and behaves exactly as bjorn described. It seems like SV sorts tilesets alphabetically, which is why you need the z_ prefix to make sure your tilesets are last in its loading order, regardless of the tileset order in the file output by Tiled.

KitteyWolf commented 1 year ago

@eishiya its almost like part of the reason why i wanted to bring this to peoples attentions is to bring up the want for reordering your tilesets manually... originally it was said that they wouldn't put it back in because it "didn't matter" but it clearly /does/ matter.

eishiya commented 1 year ago

originally it was said that they wouldn't put it back in because it "didn't matter" but it clearly /does/ matter.

Again, this reordering is happening in SV/SMAPI. Even if the ordering was manual in Tiled, SV would still mess it up by sorting the tilesets alphabetically! SV/SMAPI are the problem here, and the only way around their alphabetical ordering is renaming the tilesets as per their instructions.