diff --git a/src/nostalgia/modules/gfx/include/nostalgia/gfx/tilesheet.hpp b/src/nostalgia/modules/gfx/include/nostalgia/gfx/tilesheet.hpp index 176fe39e..4b5b9499 100644 --- a/src/nostalgia/modules/gfx/include/nostalgia/gfx/tilesheet.hpp +++ b/src/nostalgia/modules/gfx/include/nostalgia/gfx/tilesheet.hpp @@ -339,9 +339,13 @@ struct TileSheetV5 { static constexpr auto TypeName = "net.drinkingtea.nostalgia.gfx.TileSheet"; static constexpr auto TypeVersion = 5; + /** + * bpp is unused for TileSheet, but it does get used in CompactTileSheet. + * All pixel in TileSheet are 8 bpp, regardless of what the bpp field says. + */ int8_t bpp = 4; SubSheetId idIt = 0; - ox::FileAddress defaultPalette; + ox::String defaultPalette; SubSheet subsheet{0, "Root", 1, 1}; }; diff --git a/src/nostalgia/modules/gfx/src/keel/typeconv.cpp b/src/nostalgia/modules/gfx/src/keel/typeconv.cpp index e3b20569..93b92b48 100644 --- a/src/nostalgia/modules/gfx/src/keel/typeconv.cpp +++ b/src/nostalgia/modules/gfx/src/keel/typeconv.cpp @@ -185,7 +185,7 @@ ox::Error TileSheetV4ToTileSheetV5Converter::convert( TileSheetV5 &dst) const noexcept { dst.bpp = src.bpp; dst.idIt = src.idIt; - dst.defaultPalette = std::move(src.defaultPalette); + OX_RETURN_ERROR(src.defaultPalette.getPath().moveTo(dst.defaultPalette)); convertSubsheet(dst.bpp, src.subsheet, dst.subsheet); return {}; } @@ -196,7 +196,7 @@ ox::Error TileSheetToCompactTileSheetConverter::convert( TileSheet &src, CompactTileSheet &dst) const noexcept { dst.bpp = src.bpp; - dst.defaultPalette = std::move(src.defaultPalette); + dst.defaultPalette = ox::FileAddress{src.defaultPalette}; dst.pixels = pixels(src); return {}; } diff --git a/src/nostalgia/modules/gfx/src/studio/tilesheeteditor/commands/palettechangecommand.cpp b/src/nostalgia/modules/gfx/src/studio/tilesheeteditor/commands/palettechangecommand.cpp index 6b17871a..d8a6d2d2 100644 --- a/src/nostalgia/modules/gfx/src/studio/tilesheeteditor/commands/palettechangecommand.cpp +++ b/src/nostalgia/modules/gfx/src/studio/tilesheeteditor/commands/palettechangecommand.cpp @@ -13,7 +13,7 @@ gfx::PaletteChangeCommand::PaletteChangeCommand( m_img(img), m_idx(std::move(idx)), m_oldPalette(m_img.defaultPalette), - m_newPalette(ox::FileAddress(ox::sfmt>("uuid://{}", newPalette))) { + m_newPalette(ox::sfmt>("uuid://{}", newPalette)) { } ox::Error PaletteChangeCommand::redo() noexcept { diff --git a/src/nostalgia/modules/gfx/src/studio/tilesheeteditor/commands/palettechangecommand.hpp b/src/nostalgia/modules/gfx/src/studio/tilesheeteditor/commands/palettechangecommand.hpp index f79f1c7c..4e2a06a4 100644 --- a/src/nostalgia/modules/gfx/src/studio/tilesheeteditor/commands/palettechangecommand.hpp +++ b/src/nostalgia/modules/gfx/src/studio/tilesheeteditor/commands/palettechangecommand.hpp @@ -12,8 +12,8 @@ class PaletteChangeCommand: public TileSheetCommand { private: TileSheet &m_img; TileSheet::SubSheetIdx m_idx; - ox::FileAddress m_oldPalette; - ox::FileAddress m_newPalette; + ox::String m_oldPalette; + ox::String m_newPalette; public: PaletteChangeCommand( diff --git a/src/nostalgia/modules/gfx/src/studio/tilesheeteditor/tilesheeteditormodel.cpp b/src/nostalgia/modules/gfx/src/studio/tilesheeteditor/tilesheeteditormodel.cpp index 00e603c0..04cb839e 100644 --- a/src/nostalgia/modules/gfx/src/studio/tilesheeteditor/tilesheeteditormodel.cpp +++ b/src/nostalgia/modules/gfx/src/studio/tilesheeteditor/tilesheeteditormodel.cpp @@ -118,13 +118,10 @@ bool TileSheetEditorModel::acceptsClipboardPayload() const noexcept { } ox::StringView TileSheetEditorModel::palPath() const noexcept { - auto [path, err] = m_img.defaultPalette.getPath(); - if (err) { - return {}; - } + auto &path = m_img.defaultPalette; constexpr ox::StringView uuidPrefix = "uuid://"; if (ox::beginsWith(path, uuidPrefix)) { - auto const uuid = ox::StringView(&path[uuidPrefix.bytes()], path.bytes() - uuidPrefix.bytes()); + auto const uuid = substr(path, uuidPrefix.bytes()); auto const out = keelCtx(m_tctx).uuidToPath.at(uuid); if (out.error) { return {};