[nostalgia/gfx/studio/tilesheet] Mark DrawCommands as obsolete if no changes
All checks were successful
Build / build (push) Successful in 3m37s
All checks were successful
Build / build (push) Successful in 3m37s
This commit is contained in:
parent
e002109829
commit
00638bc812
@ -63,7 +63,7 @@ DrawCommand::DrawCommand(
|
|||||||
TileSheet &img,
|
TileSheet &img,
|
||||||
TileSheet::SubSheetIdx subSheetIdx,
|
TileSheet::SubSheetIdx subSheetIdx,
|
||||||
std::size_t idx,
|
std::size_t idx,
|
||||||
int palIdx) noexcept:
|
int const palIdx) noexcept:
|
||||||
m_img(img),
|
m_img(img),
|
||||||
m_subSheetIdx(std::move(subSheetIdx)),
|
m_subSheetIdx(std::move(subSheetIdx)),
|
||||||
m_palIdx(palIdx) {
|
m_palIdx(palIdx) {
|
||||||
@ -75,7 +75,7 @@ DrawCommand::DrawCommand(
|
|||||||
TileSheet &img,
|
TileSheet &img,
|
||||||
TileSheet::SubSheetIdx subSheetIdx,
|
TileSheet::SubSheetIdx subSheetIdx,
|
||||||
ox::SpanView<std::size_t> const&idxList,
|
ox::SpanView<std::size_t> const&idxList,
|
||||||
int palIdx) noexcept:
|
int const palIdx) noexcept:
|
||||||
m_img(img),
|
m_img(img),
|
||||||
m_subSheetIdx(std::move(subSheetIdx)),
|
m_subSheetIdx(std::move(subSheetIdx)),
|
||||||
m_palIdx(palIdx) {
|
m_palIdx(palIdx) {
|
||||||
@ -123,9 +123,11 @@ void DrawCommand::lineUpdate(ox::Point a, ox::Point b) noexcept {
|
|||||||
for (int32_t i{}; i < range; ++i) {
|
for (int32_t i{}; i < range; ++i) {
|
||||||
auto const idx = ptToIdx(x, y + i * mod, ss.columns * TileWidth);
|
auto const idx = ptToIdx(x, y + i * mod, ss.columns * TileWidth);
|
||||||
if (idx < ss.pixels.size()) {
|
if (idx < ss.pixels.size()) {
|
||||||
|
if (m_palIdx != getPixel(ss, idx)) {
|
||||||
m_changes.emplace_back(static_cast<uint32_t>(idx), getPixel(ss, idx));
|
m_changes.emplace_back(static_cast<uint32_t>(idx), getPixel(ss, idx));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
std::ignore = redo();
|
std::ignore = redo();
|
||||||
}
|
}
|
||||||
@ -154,4 +156,8 @@ TileSheet::SubSheetIdx const&DrawCommand::subsheetIdx() const noexcept {
|
|||||||
return m_subSheetIdx;
|
return m_subSheetIdx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DrawCommand::finish() noexcept {
|
||||||
|
setObsolete(m_changes.empty());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,8 @@ class DrawCommand: public TileSheetCommand {
|
|||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
TileSheet::SubSheetIdx const&subsheetIdx() const noexcept override;
|
TileSheet::SubSheetIdx const&subsheetIdx() const noexcept override;
|
||||||
|
|
||||||
|
void finish() noexcept;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -172,7 +172,7 @@ void TileSheetEditorModel::drawLineCommand(ox::Point const &pt, std::size_t cons
|
|||||||
if (m_ongoingDrawCommand) {
|
if (m_ongoingDrawCommand) {
|
||||||
m_ongoingDrawCommand->lineUpdate(m_lineStartPt, pt);
|
m_ongoingDrawCommand->lineUpdate(m_lineStartPt, pt);
|
||||||
m_updated = true;
|
m_updated = true;
|
||||||
} else if (getPixel(activeSubSheet, idx) != palIdx) {
|
} else {
|
||||||
std::ignore = pushCommand(ox::make<DrawCommand>(
|
std::ignore = pushCommand(ox::make<DrawCommand>(
|
||||||
m_img, m_activeSubsSheetIdx, idx, static_cast<int>(palIdx)));
|
m_img, m_activeSubsSheetIdx, idx, static_cast<int>(palIdx)));
|
||||||
m_lineStartPt = pt;
|
m_lineStartPt = pt;
|
||||||
@ -180,8 +180,11 @@ void TileSheetEditorModel::drawLineCommand(ox::Point const &pt, std::size_t cons
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TileSheetEditorModel::endDrawCommand() noexcept {
|
void TileSheetEditorModel::endDrawCommand() noexcept {
|
||||||
|
if (m_ongoingDrawCommand) {
|
||||||
|
m_ongoingDrawCommand->finish();
|
||||||
m_ongoingDrawCommand = nullptr;
|
m_ongoingDrawCommand = nullptr;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TileSheetEditorModel::addSubsheet(TileSheet::SubSheetIdx const&parentIdx) noexcept {
|
void TileSheetEditorModel::addSubsheet(TileSheet::SubSheetIdx const&parentIdx) noexcept {
|
||||||
std::ignore = pushCommand(ox::make<AddSubSheetCommand>(m_img, parentIdx));
|
std::ignore = pushCommand(ox::make<AddSubSheetCommand>(m_img, parentIdx));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user