[nostalgia/core/studio] Add function to remove unused data from TileSheets
This commit is contained in:
parent
1dff26d895
commit
9c026e1a6c
@ -30,6 +30,17 @@ 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),
|
||||
@ -37,6 +48,7 @@ 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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user