[nostalgia/core/studio] Cleanup TileSheetEditorModel update tracking
This commit is contained in:
@@ -31,17 +31,15 @@ struct DrawCommand: public studio::UndoCommand {
|
||||
TileSheet *m_img = nullptr;
|
||||
ox::Vector<Change, 8> m_changes;
|
||||
int m_palIdx = 0;
|
||||
bool *m_modelUpdated = nullptr;
|
||||
|
||||
public:
|
||||
constexpr DrawCommand(bool *updated, TileSheet *img, std::size_t idx, int palIdx) noexcept {
|
||||
m_modelUpdated = updated;
|
||||
constexpr DrawCommand(TileSheet *img, std::size_t idx, int palIdx) noexcept {
|
||||
m_img = img;
|
||||
m_changes.emplace_back(idx, m_img->getPixel(idx));
|
||||
m_palIdx = palIdx;
|
||||
}
|
||||
|
||||
constexpr bool append(std::size_t idx) noexcept {
|
||||
constexpr auto append(std::size_t idx) noexcept {
|
||||
if (m_changes.back().value.idx != idx && m_img->getPixel(idx) != m_palIdx) {
|
||||
// duplicate entries are bad
|
||||
auto existing = std::find_if(m_changes.cbegin(), m_changes.cend(), [idx](const auto &c) {
|
||||
@@ -60,14 +58,12 @@ struct DrawCommand: public studio::UndoCommand {
|
||||
for (const auto &c : m_changes) {
|
||||
m_img->setPixel(c.idx, m_palIdx);
|
||||
}
|
||||
*m_modelUpdated = true;
|
||||
}
|
||||
|
||||
void undo() noexcept final {
|
||||
for (const auto &c : m_changes) {
|
||||
m_img->setPixel(c.idx, c.oldPalIdx);
|
||||
}
|
||||
*m_modelUpdated = true;
|
||||
}
|
||||
|
||||
};
|
||||
@@ -111,7 +107,7 @@ oxModelBegin(TileSheetClipboard)
|
||||
oxModelFieldRename(p2, m_p2)
|
||||
oxModelEnd()
|
||||
|
||||
class TileSheetEditorModel {
|
||||
class TileSheetEditorModel: public ox::SignalHandler {
|
||||
|
||||
private:
|
||||
TileSheet m_img;
|
||||
@@ -149,6 +145,8 @@ class TileSheetEditorModel {
|
||||
[[nodiscard]]
|
||||
bool updated() const noexcept;
|
||||
|
||||
ox::Error markUpdated() noexcept;
|
||||
|
||||
void ackUpdate() noexcept;
|
||||
|
||||
ox::Error saveFile() noexcept;
|
||||
|
||||
Reference in New Issue
Block a user