[nostalgia/core] Cleanup headers, TileSheet versioning

This commit is contained in:
Gary Talent 2023-12-05 22:37:22 -06:00
parent 54fcbb1a33
commit a5bdad448f
5 changed files with 31 additions and 37 deletions

View File

@ -7,8 +7,6 @@
#include <ox/std/types.hpp>
#include <ox/std/point.hpp>
#include "context.hpp"
namespace nostalgia::core {
using Color16 = uint16_t;

View File

@ -12,9 +12,6 @@
#include <ox/model/def.hpp>
#include "color.hpp"
#include "context.hpp"
#include "ptidxconv.hpp"
#include "palette.hpp"
namespace nostalgia::core {
@ -278,6 +275,8 @@ struct TileSheet {
};
using TileSheetV3 = TileSheet;
struct CompactTileSheet {
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.CompactTileSheet";
static constexpr auto TypeVersion = 1;

View File

@ -17,9 +17,9 @@ namespace nostalgia::core {
class KeelModule: public keel::Module {
private:
NostalgiaPaletteToPaletteConverter m_nostalgiaPaletteToPaletteConverter;
TileSheetV1ToTileSheetConverter m_tileSheetV1ToTileSheetV2Converter;
TileSheetV1ToTileSheetV2Converter m_tileSheetV1ToTileSheetV2Converter;
TileSheetV2ToTileSheetV3Converter m_tileSheetV2ToTileSheetConverter;
TileSheetToCompactTileSheetConverter m_tileSheetToCompactTileSheetConverter;
TileSheetV2ToTileSheetConverter m_tileSheetV2ToTileSheetConverter;
public:
[[nodiscard]]

View File

@ -14,10 +14,10 @@ ox::Error NostalgiaPaletteToPaletteConverter::convert(
return {};
}
ox::Error TileSheetV1ToTileSheetConverter::convert(
ox::Error TileSheetV1ToTileSheetV2Converter::convert(
keel::Context&,
TileSheetV1 &src,
TileSheet &dst) const noexcept {
TileSheetV2 &dst) const noexcept {
dst.bpp = src.bpp;
dst.defaultPalette = std::move(src.defaultPalette);
dst.subsheet.name = "Root";
@ -27,20 +27,9 @@ ox::Error TileSheetV1ToTileSheetConverter::convert(
return {};
}
ox::Error TileSheetToCompactTileSheetConverter::convert(
keel::Context&,
TileSheet &src,
CompactTileSheet &dst) const noexcept {
dst.bpp = src.bpp;
dst.defaultPalette = std::move(src.defaultPalette);
dst.pixels = src.pixels();
return {};
}
void TileSheetV2ToTileSheetConverter::convertSubsheet(
void TileSheetV2ToTileSheetV3Converter::convertSubsheet(
TileSheetV2::SubSheet &src,
TileSheet::SubSheet &dst,
TileSheetV3::SubSheet &dst,
SubSheetId &idIt) noexcept {
dst.id = idIt;
dst.name = std::move(src.name);
@ -54,14 +43,24 @@ void TileSheetV2ToTileSheetConverter::convertSubsheet(
}
}
ox::Error TileSheetV2ToTileSheetConverter::convert(
ox::Error TileSheetV2ToTileSheetV3Converter::convert(
keel::Context&,
TileSheetV2 &src,
TileSheet &dst) const noexcept {
TileSheetV3 &dst) const noexcept {
dst.bpp = src.bpp;
dst.defaultPalette = std::move(src.defaultPalette);
convertSubsheet(src.subsheet, dst.subsheet, dst.idIt);
return {};
}
ox::Error TileSheetToCompactTileSheetConverter::convert(
keel::Context&,
TileSheet &src,
CompactTileSheet &dst) const noexcept {
dst.bpp = src.bpp;
dst.defaultPalette = std::move(src.defaultPalette);
dst.pixels = src.pixels();
return {};
}
}

View File

@ -20,22 +20,20 @@ class NostalgiaPaletteToPaletteConverter: public keel::Converter<NostalgiaPalett
ox::Error convert(keel::Context&, NostalgiaPalette &src, Palette &dst) const noexcept final;
};
class TileSheetV1ToTileSheetConverter: public keel::Converter<TileSheetV1, TileSheet> {
ox::Error convert(keel::Context&, TileSheetV1 &src, TileSheet &dst) const noexcept final;
class TileSheetV1ToTileSheetV2Converter: public keel::Converter<TileSheetV1, TileSheetV2> {
ox::Error convert(keel::Context&, TileSheetV1 &src, TileSheetV2 &dst) const noexcept final;
};
class TileSheetV2ToTileSheetV3Converter: public keel::Converter<TileSheetV2, TileSheetV3> {
static void convertSubsheet(
TileSheetV2::SubSheet &src,
TileSheetV3::SubSheet &dst,
SubSheetId &idIt) noexcept;
ox::Error convert(keel::Context&, TileSheetV2 &src, TileSheetV3 &dst) const noexcept final;
};
class TileSheetToCompactTileSheetConverter: public keel::Converter<TileSheet, CompactTileSheet> {
ox::Error convert(keel::Context&, TileSheet &src, CompactTileSheet &dst) const noexcept final;
};
class TileSheetV2ToTileSheetConverter: public keel::Converter<TileSheetV2, TileSheet> {
static void convertSubsheet(
TileSheetV2::SubSheet &src,
TileSheet::SubSheet &dst,
SubSheetId &idIt) noexcept;
ox::Error convert(keel::Context&, TileSheetV2 &src, TileSheet &dst) const noexcept final;
ox::Error convert(keel::Context&, TileSheet &src, CompactTileSheet &dst) const noexcept final;
};
}