Review rules for resolving map tilesheet
Pathoschild opened this issue ยท 3 comments
Game logic
The game's logic for finding tilesheets boils down to this:
- If the location is indoors or the desert, or the tilesheet path contains
path
orobject
, it's loaded as-is relative to theContent
folder. - Else it's loaded from
Content\Maps
with a seasonal prefix (e.g.spring_outdoorsTileSheet
).
Most game maps reference a simple file name (like townInterior
). Only the mines have a folder path (e.g. Mines\mine
).
We can't use this logic in SMAPI because we don't have location info at that point, and modders often have more complex tilesheet paths.
Current SMAPI logic
SMAPI checks for an existing relative path match (with and without seasonal prefix) relative to three locations (map file, Content\Maps
, and Content
).
That works for most maps, but fails with workstation-specific paths like ..\..\Steam\Stardew Valley\Content\townInterior.png
.
Option A: restrict tilesheet paths
Keep the logic as-is, and require modders to copy tilesheets into the same folder when editing the map. Detect paths containing ..\
, and show an error saying tilesheets should in or under the map folder.
This keeps the SMAPI logic simple and predictable and avoids path ambiguity, but modders need to copy vanilla tilesheets into the map folder to reference it.
Option B: add filename matching
Check four variations (relative path and filename with/without seasonal prefix) relative to three locations (map file, Content\Maps
, and Content
). If the path contains ..\
, disable relative path searches.
Advantages:
- That will work fine in the vast majority of cases (including the case screenshot'd above).
- Modders don't need to do anything special in most cases.
Disadvantages:
- In some cases, modders still need to copy the tilesheet into the map folder to avoid conflict (e.g.
..\..\Steam\Stardew Valley\Content\Mines\mine.xnb
would matchContent\mine.xnb
). - This significantly complicates SMAPI's tilesheet finding code.
We'll go with option A per discussion.
The recommended map editor is Tiled, which correctly uses a relative path if the tilesheet is under the map's folder (otherwise it uses an absolute path). SMAPI should detect if the path is rooted or contains ..\
, and show an appropriate error.