mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-16 04:13:50 +00:00
Convert the tileset serialization format in its own type
To match the new SerialFormat enum (uint16_t), we now have TilesetSerialFormat enum (uint8_t).
This commit is contained in:
parent
cdea6004bd
commit
abe872aeb2
@ -523,9 +523,9 @@ private:
|
||||
}
|
||||
|
||||
Tileset* readTileset(std::ifstream& s) {
|
||||
uint32_t tilesetVer;
|
||||
TilesetSerialFormat tilesetVer = TilesetSerialFormat::Ver0;
|
||||
Tileset* tileset = read_tileset(s, m_sprite, false, &tilesetVer, m_serial);
|
||||
if (tileset && tilesetVer < TILESET_VER1)
|
||||
if (tileset && tilesetVer < TilesetSerialFormat::Ver1)
|
||||
m_updateOldTilemapWithTileset.insert(tileset->id());
|
||||
return tileset;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ bool write_tileset(std::ostream& os,
|
||||
write_image(os, tileset->get(ti).get(), cancel);
|
||||
}
|
||||
|
||||
write8(os, TILESET_VER3);
|
||||
write8(os, uint8_t(TilesetSerialFormat::LastVer));
|
||||
write_user_data(os, tileset->userData());
|
||||
write_string(os, tileset->name());
|
||||
|
||||
@ -58,7 +58,7 @@ bool write_tileset(std::ostream& os,
|
||||
Tileset* read_tileset(std::istream& is,
|
||||
Sprite* sprite,
|
||||
const bool setId,
|
||||
uint32_t* tilesetVer,
|
||||
TilesetSerialFormat* tilesetVer,
|
||||
const SerialFormat serial)
|
||||
{
|
||||
const ObjectId id = read32(is);
|
||||
@ -74,17 +74,17 @@ Tileset* read_tileset(std::istream& is,
|
||||
}
|
||||
|
||||
// Read extra version byte after tiles
|
||||
const uint32_t ver = read8(is);
|
||||
const auto ver = TilesetSerialFormat(read8(is));
|
||||
if (tilesetVer)
|
||||
*tilesetVer = ver;
|
||||
if (ver >= TILESET_VER1) {
|
||||
if (ver >= TilesetSerialFormat::Ver1) {
|
||||
tileset->setBaseIndex(1);
|
||||
|
||||
if (ver >= TILESET_VER2) {
|
||||
if (ver >= TilesetSerialFormat::Ver2) {
|
||||
const UserData userData = read_user_data(is, serial);
|
||||
tileset->setUserData(userData);
|
||||
|
||||
if (ver >= TILESET_VER3) {
|
||||
if (ver >= TilesetSerialFormat::Ver3) {
|
||||
tileset->setName(read_string(is));
|
||||
|
||||
for (tileset_index ti=0; ti<ntiles; ++ti) {
|
||||
|
@ -13,19 +13,27 @@
|
||||
|
||||
#include <iosfwd>
|
||||
|
||||
// Extra BYTE with special flags to check the tileset version. This
|
||||
// field didn't exist in Aseprite v1.3-alpha3 (so read8() fails = 0)
|
||||
#define TILESET_VER1 1
|
||||
|
||||
// Tileset has UserData now
|
||||
#define TILESET_VER2 2
|
||||
|
||||
// Tileset name (was missing originally) + each tileset's tile has
|
||||
// UserData now
|
||||
#define TILESET_VER3 3
|
||||
|
||||
namespace doc {
|
||||
|
||||
// Tileset serialization format. This field didn't exist in Aseprite
|
||||
// v1.3-alpha3 (so read8() fails = 0)
|
||||
enum class TilesetSerialFormat : uint8_t {
|
||||
// Without version field.
|
||||
Ver0 = 0,
|
||||
|
||||
// Extra BYTE with special flags to check the tileset version.
|
||||
Ver1 = 1,
|
||||
|
||||
// Tileset has UserData now.
|
||||
Ver2 = 2,
|
||||
|
||||
// Tileset name (was missing originally) + each tileset's tile has
|
||||
// UserData now.
|
||||
Ver3 = 3,
|
||||
|
||||
LastVer = Ver3
|
||||
};
|
||||
|
||||
class CancelIO;
|
||||
class Sprite;
|
||||
class Tileset;
|
||||
@ -37,7 +45,7 @@ namespace doc {
|
||||
Tileset* read_tileset(std::istream& is,
|
||||
Sprite* sprite,
|
||||
bool setId = true,
|
||||
uint32_t* tilesetVer = nullptr,
|
||||
TilesetSerialFormat* tilesetSerial = nullptr,
|
||||
SerialFormat serial = SerialFormat::LastVer);
|
||||
|
||||
} // namespace doc
|
||||
|
Loading…
Reference in New Issue
Block a user