[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::SubSheetIdx subSheetIdx,
|
||||
std::size_t idx,
|
||||
int palIdx) noexcept:
|
||||
int const palIdx) noexcept:
|
||||
m_img(img),
|
||||
m_subSheetIdx(std::move(subSheetIdx)),
|
||||
m_palIdx(palIdx) {
|
||||
@ -75,7 +75,7 @@ DrawCommand::DrawCommand(
|
||||
TileSheet &img,
|
||||
TileSheet::SubSheetIdx subSheetIdx,
|
||||
ox::SpanView<std::size_t> const&idxList,
|
||||
int palIdx) noexcept:
|
||||
int const palIdx) noexcept:
|
||||
m_img(img),
|
||||
m_subSheetIdx(std::move(subSheetIdx)),
|
||||
m_palIdx(palIdx) {
|
||||
@ -123,7 +123,9 @@ void DrawCommand::lineUpdate(ox::Point a, ox::Point b) noexcept {
|
||||
for (int32_t i{}; i < range; ++i) {
|
||||
auto const idx = ptToIdx(x, y + i * mod, ss.columns * TileWidth);
|
||||
if (idx < ss.pixels.size()) {
|
||||
m_changes.emplace_back(static_cast<uint32_t>(idx), getPixel(ss, idx));
|
||||
if (m_palIdx != getPixel(ss, idx)) {
|
||||
m_changes.emplace_back(static_cast<uint32_t>(idx), getPixel(ss, idx));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -154,4 +156,8 @@ TileSheet::SubSheetIdx const&DrawCommand::subsheetIdx() const noexcept {
|
||||
return m_subSheetIdx;
|
||||
}
|
||||
|
||||
void DrawCommand::finish() noexcept {
|
||||
setObsolete(m_changes.empty());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -52,6 +52,8 @@ class DrawCommand: public TileSheetCommand {
|
||||
[[nodiscard]]
|
||||
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) {
|
||||
m_ongoingDrawCommand->lineUpdate(m_lineStartPt, pt);
|
||||
m_updated = true;
|
||||
} else if (getPixel(activeSubSheet, idx) != palIdx) {
|
||||
} else {
|
||||
std::ignore = pushCommand(ox::make<DrawCommand>(
|
||||
m_img, m_activeSubsSheetIdx, idx, static_cast<int>(palIdx)));
|
||||
m_lineStartPt = pt;
|
||||
@ -180,7 +180,10 @@ void TileSheetEditorModel::drawLineCommand(ox::Point const &pt, std::size_t cons
|
||||
}
|
||||
|
||||
void TileSheetEditorModel::endDrawCommand() noexcept {
|
||||
m_ongoingDrawCommand = nullptr;
|
||||
if (m_ongoingDrawCommand) {
|
||||
m_ongoingDrawCommand->finish();
|
||||
m_ongoingDrawCommand = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void TileSheetEditorModel::addSubsheet(TileSheet::SubSheetIdx const&parentIdx) noexcept {
|
||||
|
Loading…
x
Reference in New Issue
Block a user