mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-01 09:04:02 +00:00
Refactor AsepriteExternalFiles usage
This commit is contained in:
parent
243fbc3fbc
commit
8b4b803a22
@ -1235,10 +1235,7 @@ static void ase_file_write_external_files_chunk(
|
||||
{
|
||||
for (const Tileset* tileset : *sprite->tilesets()) {
|
||||
if (!tileset->externalFilename().empty()) {
|
||||
auto id = ++ext_files.lastid;
|
||||
auto fn = tileset->externalFilename();
|
||||
ext_files.to_fn[id] = fn;
|
||||
ext_files.to_id[fn] = id;
|
||||
ext_files.put(tileset->externalFilename());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,6 +104,17 @@ struct AsepriteExternalFiles {
|
||||
std::map<uint32_t, std::string> to_fn; // ID -> filename
|
||||
std::map<std::string, uint32_t> to_id; // filename -> ID
|
||||
uint32_t lastid = 0;
|
||||
// Adds the external filename with the next autogenerated ID.
|
||||
void put(const std::string& filename) {
|
||||
auto id = ++lastid;
|
||||
to_fn[id] = filename;
|
||||
to_id[filename] = id;
|
||||
}
|
||||
// Adds the external filename using the specified ID.
|
||||
void put(uint32_t id, const std::string& filename) {
|
||||
to_fn[id] = filename;
|
||||
to_id[filename] = id;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace dio
|
||||
|
@ -940,8 +940,7 @@ void AsepriteDecoder::readExternalFiles(AsepriteExternalFiles& extFiles)
|
||||
uint32_t id = read32();
|
||||
readPadding(8);
|
||||
std::string fn = readString();
|
||||
extFiles.to_fn[id] = fn;
|
||||
extFiles.to_id[fn] = id;
|
||||
extFiles.put(id, fn);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user