[nostalgia/core/studio] Cleanup to ensure ongoing draw command ending
This commit is contained in:
parent
d792e4c515
commit
95f3c5b62a
@ -15,12 +15,11 @@ TileSheetEditorModel::TileSheetEditorModel(Context *ctx, const ox::String &path)
|
||||
}
|
||||
|
||||
void TileSheetEditorModel::draw(const geo::Point &pt, std::size_t palIdx) noexcept {
|
||||
if (!m_ongoingDrawCommand) {
|
||||
m_ongoingDrawCommand = new DrawCommand(&m_img, ptToIdx(pt, m_img.columns), palIdx);
|
||||
m_undoStack.push(m_ongoingDrawCommand);
|
||||
m_updated = true;
|
||||
} else {
|
||||
if (m_ongoingDrawCommand) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,7 +35,7 @@ void TileSheetEditorModel::ackUpdate() noexcept {
|
||||
m_updated = false;
|
||||
}
|
||||
|
||||
void TileSheetEditorModel::getFillPixels(bool *pixels, geo::Point pt, int oldColor) const noexcept {
|
||||
void TileSheetEditorModel::getFillPixels(bool *pixels, const geo::Point &pt, int oldColor) const noexcept {
|
||||
const auto tileIdx = [this](const geo::Point &pt) noexcept {
|
||||
return ptToIdx(pt, img().columns) / PixelsPerTile;
|
||||
};
|
||||
@ -68,4 +67,9 @@ void TileSheetEditorModel::getFillPixels(bool *pixels, geo::Point pt, int oldCol
|
||||
}
|
||||
}
|
||||
|
||||
void TileSheetEditorModel::pushCommand(studio::UndoCommand *cmd) noexcept {
|
||||
m_undoStack.push(cmd);
|
||||
m_ongoingDrawCommand = dynamic_cast<DrawCommand*>(cmd);
|
||||
}
|
||||
|
||||
}
|
@ -174,9 +174,11 @@ class TileSheetEditorModel {
|
||||
protected:
|
||||
void saveItem();
|
||||
|
||||
void getFillPixels(bool *pixels, geo::Point pt, int oldColor) const noexcept;
|
||||
void getFillPixels(bool *pixels, const geo::Point &pt, int oldColor) const noexcept;
|
||||
|
||||
private:
|
||||
void pushCommand(studio::UndoCommand *cmd) noexcept;
|
||||
|
||||
void setPalette();
|
||||
|
||||
void saveState();
|
||||
|
Loading…
x
Reference in New Issue
Block a user