diff --git a/src/nostalgia/core/studio/tilesheeteditormodel.cpp b/src/nostalgia/core/studio/tilesheeteditormodel.cpp index 91261b1e..b692a972 100644 --- a/src/nostalgia/core/studio/tilesheeteditormodel.cpp +++ b/src/nostalgia/core/studio/tilesheeteditormodel.cpp @@ -19,7 +19,6 @@ void TileSheetEditorModel::draw(const geo::Point &pt, std::size_t palIdx) noexce m_updated = m_ongoingDrawCommand->append(ptToIdx(pt, m_img.columns)); } else { pushCommand(new DrawCommand(&m_img, ptToIdx(pt, m_img.columns), palIdx)); - m_updated = true; } } @@ -70,6 +69,7 @@ void TileSheetEditorModel::getFillPixels(bool *pixels, const geo::Point &pt, int void TileSheetEditorModel::pushCommand(studio::UndoCommand *cmd) noexcept { m_undoStack.push(cmd); m_ongoingDrawCommand = dynamic_cast(cmd); + m_updated = true; } } \ No newline at end of file diff --git a/src/nostalgia/core/studio/tilesheeteditormodel.hpp b/src/nostalgia/core/studio/tilesheeteditormodel.hpp index 04cedeca..22bee50a 100644 --- a/src/nostalgia/core/studio/tilesheeteditormodel.hpp +++ b/src/nostalgia/core/studio/tilesheeteditormodel.hpp @@ -68,9 +68,15 @@ struct DrawCommand: public studio::UndoCommand { constexpr bool append(std::size_t idx) noexcept { if (m_changes.back().value.idx != idx) { - m_changes.emplace_back(idx, m_img->pixels[idx]); - m_img->setPixel(idx, m_palIdx); - return true; + // duplicate entries are bad + auto existing = std::find_if(m_changes.cbegin(), m_changes.cend(), [idx](const auto &c) { + return c.idx == idx; + }); + if (existing == m_changes.cend()) { + m_changes.emplace_back(idx, m_img->pixels[idx]); + m_img->setPixel(idx, m_palIdx); + return true; + } } return false; }