Compare commits
No commits in common. "10a12f2ab20199df580da5bd7d8d22bae0a58cf0" and "28b1c6dcf4b2d7d1e3c50850f5886ab8d85c9c96" have entirely different histories.
10a12f2ab2
...
28b1c6dcf4
@ -73,7 +73,7 @@ struct TileSheetSetEntrySection {
|
||||
|
||||
oxModelBegin(TileSheetSetEntrySection)
|
||||
oxModelField(begin)
|
||||
oxModelField(tiles)
|
||||
oxModelField(size)
|
||||
oxModelEnd()
|
||||
|
||||
struct TileSheetSetEntry {
|
||||
@ -92,7 +92,7 @@ struct TileSheetSet {
|
||||
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.TileSheetSet";
|
||||
static constexpr auto TypeVersion = 1;
|
||||
static constexpr auto Preloadable = true;
|
||||
int32_t bpp = 0;
|
||||
int bpp = 0;
|
||||
ox::Vector<TileSheetSetEntry> entries;
|
||||
};
|
||||
|
||||
@ -101,8 +101,6 @@ oxModelBegin(TileSheetSet)
|
||||
oxModelField(entries)
|
||||
oxModelEnd()
|
||||
|
||||
void addEntry(TileSheetSet &set, ox::FileAddress path, int32_t begin = 0, int32_t size = -1) noexcept;
|
||||
|
||||
ox::Error loadBgPalette(
|
||||
Context &ctx,
|
||||
size_t palBank,
|
||||
|
@ -60,15 +60,6 @@ constexpr size_t colors(Palette const&pal, size_t page = 0) noexcept {
|
||||
return 0;
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr size_t largestPage(Palette const&pal) noexcept {
|
||||
size_t out{};
|
||||
for (auto const&page : pal.pages) {
|
||||
out = ox::max(out, page.size());
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
oxModelBegin(NostalgiaPalette)
|
||||
oxModelField(colors)
|
||||
oxModelEnd()
|
||||
|
@ -159,10 +159,7 @@ struct TileSheet {
|
||||
std::size_t idx(TileSheet::SubSheet const&ss, ox::Point const&pt) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
size_t getTileCnt(TileSheet const&ts) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
TileSheet::SubSheet const*getSubsheet(TileSheet const&ts, SubSheetId id) noexcept;
|
||||
TileSheet::SubSheet const*getSubsheet(TileSheet const&ts, SubSheetId const id) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
size_t getTileIdx(TileSheet const&ts, SubSheetId id) noexcept;
|
||||
|
@ -30,17 +30,6 @@ Palette const TileSheetEditorModel::s_defaultPalette = {
|
||||
.pages = {ox::Vector<Color16>(128)},
|
||||
};
|
||||
|
||||
// delete pixels of all non-leaf nodes
|
||||
static void normalizeSubsheets(TileSheet::SubSheet &ss) noexcept {
|
||||
if (ss.subsheets.empty()) {
|
||||
for (auto &child : ss.subsheets) {
|
||||
normalizeSubsheets(child);
|
||||
}
|
||||
} else {
|
||||
ss.pixels.clear();
|
||||
}
|
||||
}
|
||||
|
||||
TileSheetEditorModel::TileSheetEditorModel(turbine::Context &ctx, ox::StringView path, studio::UndoStack &undoStack):
|
||||
m_ctx(ctx),
|
||||
m_path(path),
|
||||
@ -48,7 +37,6 @@ TileSheetEditorModel::TileSheetEditorModel(turbine::Context &ctx, ox::StringView
|
||||
// ignore failure to load palette
|
||||
m_pal(readObj<Palette>(keelCtx(m_ctx), m_img.defaultPalette).value),
|
||||
m_undoStack(undoStack) {
|
||||
normalizeSubsheets(m_img.subsheet);
|
||||
m_pal.updated.connect(this, &TileSheetEditorModel::markUpdated);
|
||||
m_undoStack.changeTriggered.connect(this, &TileSheetEditorModel::markUpdatedCmdId);
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ std::size_t idx(TileSheet::SubSheet const&ss, ox::Point const&pt) noexcept {
|
||||
return ptToIdx(pt, ss.columns);
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
static TileSheet::SubSheet const*getSubsheet(TileSheet::SubSheet const&ss, SubSheetId const id) noexcept {
|
||||
if (ss.id == id) {
|
||||
return &ss;
|
||||
@ -27,24 +26,6 @@ static TileSheet::SubSheet const*getSubsheet(TileSheet::SubSheet const&ss, SubSh
|
||||
return {};
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
static size_t getTileCnt(TileSheet::SubSheet const&ss, int const bpp) noexcept {
|
||||
if (ss.subsheets.empty()) {
|
||||
auto const bytesPerTile = bpp == 4 ? 32u : 64u;
|
||||
return ss.pixels.size() / bytesPerTile;
|
||||
} else {
|
||||
size_t out{};
|
||||
for (auto const&child : ss.subsheets) {
|
||||
out += getTileCnt(child, bpp);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
||||
size_t getTileCnt(TileSheet const&ts) noexcept {
|
||||
return getTileCnt(ts.subsheet, ts.bpp);
|
||||
}
|
||||
|
||||
TileSheet::SubSheet const*getSubsheet(TileSheet const&ts, SubSheetId const id) noexcept {
|
||||
return getSubsheet(ts.subsheet, id);
|
||||
}
|
||||
@ -61,7 +42,7 @@ static ox::Optional<size_t> getPixelIdx(
|
||||
if (auto out = getPixelIdx(child, id, idx, bpp)) {
|
||||
return out;
|
||||
}
|
||||
idx += pixelCnt(child, bpp);
|
||||
idx += pixelCnt(ss, bpp);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
@ -284,6 +284,10 @@ class AssetRef {
|
||||
return *m_obj;
|
||||
}
|
||||
|
||||
constexpr T const&&operator*() const && noexcept {
|
||||
return *m_obj;
|
||||
}
|
||||
|
||||
constexpr T const*operator->() const noexcept {
|
||||
return m_obj;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user