[nostalgia/core/studio] Put TileSheetEditor draw command in UndoCommand
This commit is contained in:
@@ -9,12 +9,33 @@
|
||||
namespace nostalgia::core {
|
||||
|
||||
TileSheetEditorModel::TileSheetEditorModel(Context *ctx, const ox::String &path) {
|
||||
// build shaders
|
||||
oxRequireT(img, readObj<NostalgiaGraphic>(ctx, path.c_str()));
|
||||
m_img = std::move(*img);
|
||||
m_img = *img;
|
||||
oxThrowError(readObj<NostalgiaPalette>(ctx, m_img.defaultPalette).moveTo(&m_pal));
|
||||
}
|
||||
|
||||
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 {
|
||||
m_updated = m_ongoingDrawCommand->append(ptToIdx(pt, m_img.columns));
|
||||
}
|
||||
}
|
||||
|
||||
void TileSheetEditorModel::endDraw() noexcept {
|
||||
m_ongoingDrawCommand = nullptr;
|
||||
}
|
||||
|
||||
bool TileSheetEditorModel::updated() const noexcept {
|
||||
return m_updated;
|
||||
}
|
||||
|
||||
void TileSheetEditorModel::ackUpdate() noexcept {
|
||||
m_updated = false;
|
||||
}
|
||||
|
||||
void TileSheetEditorModel::getFillPixels(bool *pixels, geo::Point pt, int oldColor) const noexcept {
|
||||
const auto tileIdx = [this](const geo::Point &pt) noexcept {
|
||||
return ptToIdx(pt, img().columns) / PixelsPerTile;
|
||||
|
||||
Reference in New Issue
Block a user