[nostalgia/core] Cleanup, revert CompactTileSheet version to 1
All checks were successful
Build / build (push) Successful in 2m2s
All checks were successful
Build / build (push) Successful in 2m2s
This commit is contained in:
parent
e2d0a784f1
commit
d83e392964
@ -242,7 +242,7 @@ struct TileSheet {
|
|||||||
SubSheetIdx validateSubSheetIdx(
|
SubSheetIdx validateSubSheetIdx(
|
||||||
SubSheetIdx const&pIdx,
|
SubSheetIdx const&pIdx,
|
||||||
std::size_t pIdxIt,
|
std::size_t pIdxIt,
|
||||||
const SubSheet *pSubsheet) noexcept;
|
SubSheet const&pSubsheet) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* validateSubSheetIdx takes a SubSheetIdx and moves the index to the
|
* validateSubSheetIdx takes a SubSheetIdx and moves the index to the
|
||||||
@ -252,19 +252,19 @@ struct TileSheet {
|
|||||||
* @return a valid version of idx
|
* @return a valid version of idx
|
||||||
*/
|
*/
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
SubSheetIdx validateSubSheetIdx(const SubSheetIdx &idx) noexcept;
|
SubSheetIdx validateSubSheetIdx(SubSheetIdx const&idx) noexcept;
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
static SubSheet const&getSubSheet(
|
static SubSheet const&getSubSheet(
|
||||||
SubSheetIdx const&idx,
|
SubSheetIdx const&idx,
|
||||||
std::size_t idxIt,
|
std::size_t idxIt,
|
||||||
const SubSheet *pSubsheet) noexcept;
|
SubSheet const&pSubsheet) noexcept;
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
static SubSheet &getSubSheet(
|
static SubSheet &getSubSheet(
|
||||||
SubSheetIdx const&idx,
|
SubSheetIdx const&idx,
|
||||||
std::size_t idxIt,
|
std::size_t idxIt,
|
||||||
SubSheet *pSubsheet) noexcept;
|
SubSheet &pSubsheet) noexcept;
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
const SubSheet &getSubSheet(SubSheetIdx const&idx) const noexcept;
|
const SubSheet &getSubSheet(SubSheetIdx const&idx) const noexcept;
|
||||||
@ -278,7 +278,7 @@ struct TileSheet {
|
|||||||
static ox::Error rmSubSheet(
|
static ox::Error rmSubSheet(
|
||||||
SubSheetIdx const&idx,
|
SubSheetIdx const&idx,
|
||||||
std::size_t idxIt,
|
std::size_t idxIt,
|
||||||
SubSheet *pSubsheet) noexcept;
|
SubSheet &pSubsheet) noexcept;
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
ox::Error rmSubSheet(SubSheetIdx const&idx) noexcept;
|
ox::Error rmSubSheet(SubSheetIdx const&idx) noexcept;
|
||||||
@ -308,7 +308,7 @@ using TileSheetV4 = TileSheet;
|
|||||||
|
|
||||||
struct CompactTileSheet {
|
struct CompactTileSheet {
|
||||||
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.CompactTileSheet";
|
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.CompactTileSheet";
|
||||||
static constexpr auto TypeVersion = 2;
|
static constexpr auto TypeVersion = 1;
|
||||||
int8_t bpp = 0;
|
int8_t bpp = 0;
|
||||||
ox::FileAddress defaultPalette;
|
ox::FileAddress defaultPalette;
|
||||||
ox::Vector<uint8_t> pixels = {};
|
ox::Vector<uint8_t> pixels = {};
|
||||||
|
@ -254,59 +254,59 @@ TileSheet &TileSheet::operator=(TileSheet &&other) noexcept {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TileSheet::SubSheetIdx TileSheet::validateSubSheetIdx(
|
TileSheet::SubSheetIdx TileSheet::validateSubSheetIdx(
|
||||||
const SubSheetIdx &pIdx,
|
SubSheetIdx const&pIdx,
|
||||||
std::size_t pIdxIt,
|
std::size_t pIdxIt,
|
||||||
const SubSheet *pSubsheet) noexcept {
|
SubSheet const&pSubsheet) noexcept {
|
||||||
if (pIdxIt == pIdx.size()) {
|
if (pIdxIt == pIdx.size()) {
|
||||||
return pIdx;
|
return pIdx;
|
||||||
}
|
}
|
||||||
const auto currentIdx = pIdx[pIdxIt];
|
const auto currentIdx = pIdx[pIdxIt];
|
||||||
if (pSubsheet->subsheets.size() <= currentIdx) {
|
if (pSubsheet.subsheets.size() <= currentIdx) {
|
||||||
auto out = pIdx;
|
auto out = pIdx;
|
||||||
if (!pSubsheet->subsheets.empty()) {
|
if (!pSubsheet.subsheets.empty()) {
|
||||||
*out.back().value = pSubsheet->subsheets.size() - 1;
|
*out.back().value = pSubsheet.subsheets.size() - 1;
|
||||||
} else {
|
} else {
|
||||||
out.pop_back();
|
out.pop_back();
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
return validateSubSheetIdx(pIdx, pIdxIt + 1, &pSubsheet->subsheets[pIdx[pIdxIt]]);
|
return validateSubSheetIdx(pIdx, pIdxIt + 1, pSubsheet.subsheets[pIdx[pIdxIt]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
TileSheet::SubSheetIdx TileSheet::validateSubSheetIdx(const SubSheetIdx &idx) noexcept {
|
TileSheet::SubSheetIdx TileSheet::validateSubSheetIdx(SubSheetIdx const&idx) noexcept {
|
||||||
return validateSubSheetIdx(idx, 0, &subsheet);
|
return validateSubSheetIdx(idx, 0, subsheet);
|
||||||
}
|
}
|
||||||
|
|
||||||
const TileSheet::SubSheet &TileSheet::getSubSheet(
|
const TileSheet::SubSheet &TileSheet::getSubSheet(
|
||||||
TileSheet::SubSheetIdx const&idx,
|
TileSheet::SubSheetIdx const&idx,
|
||||||
std::size_t idxIt,
|
std::size_t idxIt,
|
||||||
SubSheet const*pSubsheet) noexcept {
|
SubSheet const&pSubsheet) noexcept {
|
||||||
if (idxIt == idx.size()) {
|
if (idxIt == idx.size()) {
|
||||||
return *pSubsheet;
|
return pSubsheet;
|
||||||
}
|
}
|
||||||
const auto currentIdx = idx[idxIt];
|
const auto currentIdx = idx[idxIt];
|
||||||
if (pSubsheet->subsheets.size() < currentIdx) {
|
if (pSubsheet.subsheets.size() < currentIdx) {
|
||||||
return *pSubsheet;
|
return pSubsheet;
|
||||||
}
|
}
|
||||||
return getSubSheet(idx, idxIt + 1, &pSubsheet->subsheets[currentIdx]);
|
return getSubSheet(idx, idxIt + 1, pSubsheet.subsheets[currentIdx]);
|
||||||
}
|
}
|
||||||
|
|
||||||
TileSheet::SubSheet &TileSheet::getSubSheet(
|
TileSheet::SubSheet &TileSheet::getSubSheet(
|
||||||
TileSheet::SubSheetIdx const&idx,
|
TileSheet::SubSheetIdx const&idx,
|
||||||
std::size_t idxIt,
|
std::size_t idxIt,
|
||||||
TileSheet::SubSheet *pSubsheet) noexcept {
|
TileSheet::SubSheet &pSubsheet) noexcept {
|
||||||
if (idxIt == idx.size()) {
|
if (idxIt == idx.size()) {
|
||||||
return *pSubsheet;
|
return pSubsheet;
|
||||||
}
|
}
|
||||||
return getSubSheet(idx, idxIt + 1, &pSubsheet->subsheets[idx[idxIt]]);
|
return getSubSheet(idx, idxIt + 1, pSubsheet.subsheets[idx[idxIt]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const TileSheet::SubSheet &TileSheet::getSubSheet(TileSheet::SubSheetIdx const&idx) const noexcept {
|
const TileSheet::SubSheet &TileSheet::getSubSheet(TileSheet::SubSheetIdx const&idx) const noexcept {
|
||||||
return getSubSheet(idx, 0, &subsheet);
|
return getSubSheet(idx, 0, subsheet);
|
||||||
}
|
}
|
||||||
|
|
||||||
TileSheet::SubSheet &TileSheet::getSubSheet(TileSheet::SubSheetIdx const&idx) noexcept {
|
TileSheet::SubSheet &TileSheet::getSubSheet(TileSheet::SubSheetIdx const&idx) noexcept {
|
||||||
return getSubSheet(idx, 0, &subsheet);
|
return getSubSheet(idx, 0, subsheet);
|
||||||
}
|
}
|
||||||
|
|
||||||
ox::Error TileSheet::addSubSheet(TileSheet::SubSheetIdx const&idx) noexcept {
|
ox::Error TileSheet::addSubSheet(TileSheet::SubSheetIdx const&idx) noexcept {
|
||||||
@ -323,15 +323,15 @@ ox::Error TileSheet::addSubSheet(TileSheet::SubSheetIdx const&idx) noexcept {
|
|||||||
ox::Error TileSheet::rmSubSheet(
|
ox::Error TileSheet::rmSubSheet(
|
||||||
SubSheetIdx const&idx,
|
SubSheetIdx const&idx,
|
||||||
std::size_t idxIt,
|
std::size_t idxIt,
|
||||||
SubSheet *pSubsheet) noexcept {
|
SubSheet &pSubsheet) noexcept {
|
||||||
if (idxIt == idx.size() - 1) {
|
if (idxIt == idx.size() - 1) {
|
||||||
return pSubsheet->subsheets.erase(idx[idxIt]).error;
|
return pSubsheet.subsheets.erase(idx[idxIt]).error;
|
||||||
}
|
}
|
||||||
return rmSubSheet(idx, idxIt + 1, &pSubsheet->subsheets[idx[idxIt]]);
|
return rmSubSheet(idx, idxIt + 1, pSubsheet.subsheets[idx[idxIt]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
ox::Error TileSheet::rmSubSheet(TileSheet::SubSheetIdx const&idx) noexcept {
|
ox::Error TileSheet::rmSubSheet(TileSheet::SubSheetIdx const&idx) noexcept {
|
||||||
return rmSubSheet(idx, 0, &subsheet);
|
return rmSubSheet(idx, 0, subsheet);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t TileSheet::getPixel4Bpp(
|
uint8_t TileSheet::getPixel4Bpp(
|
||||||
|
Loading…
Reference in New Issue
Block a user