[nostalgia/core] Cleanup

This commit is contained in:
Gary Talent 2024-09-27 02:31:54 -05:00
parent 396fecab5b
commit bdfb5e972a
2 changed files with 33 additions and 31 deletions

View File

@ -67,12 +67,22 @@ struct NostalgiaPalette {
ox::Vector<Color16> colors = {}; ox::Vector<Color16> colors = {};
}; };
oxModelBegin(NostalgiaPalette)
oxModelField(colors)
oxModelEnd()
struct PaletteV1 { struct PaletteV1 {
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.Palette"; static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.Palette";
static constexpr auto TypeVersion = 1; static constexpr auto TypeVersion = 1;
ox::Vector<Color16> colors; ox::Vector<Color16> colors;
}; };
oxModelBegin(PaletteV1)
oxModelField(colors)
oxModelEnd()
struct PaletteV2 { struct PaletteV2 {
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.Palette"; static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.Palette";
static constexpr auto TypeVersion = 2; static constexpr auto TypeVersion = 2;
@ -80,6 +90,10 @@ struct PaletteV2 {
ox::Vector<ox::Vector<Color16>> pages; ox::Vector<ox::Vector<Color16>> pages;
}; };
oxModelBegin(PaletteV2)
oxModelField(pages)
oxModelEnd()
struct PaletteV3 { struct PaletteV3 {
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.Palette"; static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.Palette";
@ -96,6 +110,15 @@ struct PaletteV3 {
ox::Vector<ox::Vector<Color16>> pages; ox::Vector<ox::Vector<Color16>> pages;
}; };
oxModelBegin(PaletteV3::ColorInfo)
oxModelField(name)
oxModelEnd()
oxModelBegin(PaletteV3)
oxModelField(colorInfo)
oxModelField(pages)
oxModelEnd()
[[nodiscard]] [[nodiscard]]
constexpr bool valid(PaletteV3 const&p) noexcept { constexpr bool valid(PaletteV3 const&p) noexcept {
auto const colors = p.colorInfo.size(); auto const colors = p.colorInfo.size();
@ -121,6 +144,11 @@ struct PaletteV4 {
ox::Vector<PalettePageV1> pages; ox::Vector<PalettePageV1> pages;
}; };
oxModelBegin(PaletteV4)
oxModelField(colorNames)
oxModelField(pages)
oxModelEnd()
[[nodiscard]] [[nodiscard]]
constexpr bool valid(PaletteV4 const&p) noexcept { constexpr bool valid(PaletteV4 const&p) noexcept {
auto const colors = p.colorNames.size(); auto const colors = p.colorNames.size();
@ -148,6 +176,10 @@ struct CompactPaletteV1 {
ox::Vector<ox::Vector<Color16>> pages{}; ox::Vector<ox::Vector<Color16>> pages{};
}; };
oxModelBegin(CompactPaletteV1)
oxModelField(pages)
oxModelEnd()
[[nodiscard]] [[nodiscard]]
constexpr bool valid(CompactPaletteV1 const&p) noexcept { constexpr bool valid(CompactPaletteV1 const&p) noexcept {
size_t colors{}; size_t colors{};
@ -254,34 +286,4 @@ constexpr size_t largestPage(CompactPalette const&pal) noexcept {
return out; return out;
} }
oxModelBegin(NostalgiaPalette)
oxModelField(colors)
oxModelEnd()
oxModelBegin(PaletteV1)
oxModelField(colors)
oxModelEnd()
oxModelBegin(PaletteV2)
oxModelField(pages)
oxModelEnd()
oxModelBegin(PaletteV3::ColorInfo)
oxModelField(name)
oxModelEnd()
oxModelBegin(PaletteV3)
oxModelField(colorInfo)
oxModelField(pages)
oxModelEnd()
oxModelBegin(PaletteV4)
oxModelField(colorNames)
oxModelField(pages)
oxModelEnd()
oxModelBegin(CompactPaletteV1)
oxModelField(pages)
oxModelEnd()
} }

View File

@ -41,7 +41,7 @@ PaletteEditorImGui::PaletteEditorImGui(studio::StudioContext &sctx, ox::StringPa
m_sctx(sctx), m_sctx(sctx),
m_tctx(sctx.tctx), m_tctx(sctx.tctx),
m_pal(*keel::readObj<Palette>(keelCtx(m_tctx), itemPath()).unwrapThrow()) { m_pal(*keel::readObj<Palette>(keelCtx(m_tctx), itemPath()).unwrapThrow()) {
if (!valid(m_pal)) { if (keel::ensureValid(m_pal).errCode) {
throw OxException(1, "PaletteEditorImGui: invalid Palette object"); throw OxException(1, "PaletteEditorImGui: invalid Palette object");
} }
undoStack()->changeTriggered.connect(this, &PaletteEditorImGui::handleCommand); undoStack()->changeTriggered.connect(this, &PaletteEditorImGui::handleCommand);