[nostalgia/gfx/studio/tilesheet] Cleanup
All checks were successful
Build / build (push) Successful in 1m16s

This commit is contained in:
Gary Talent 2025-06-08 16:26:55 -05:00
parent e78c405046
commit c3e75bdb55
2 changed files with 25 additions and 25 deletions

View File

@ -84,9 +84,9 @@ void TileSheetEditorModel::cut() {
auto const pt1 = m_selection->a;
auto const pt2 = ox::Point{s.columns * TileWidth, s.rows * TileHeight};
turbine::setClipboardObject(m_tctx, std::move(cb));
if (auto const cmd = ox::makeCatch<CutPasteCommand>(
if (auto cmd = ox::make_unique_catch<CutPasteCommand>(
CommandId::Cut, m_img, m_activeSubsSheetIdx, pt1, pt2, blankCb); cmd.ok()) {
std::ignore = pushCommand(cmd.value);
std::ignore = pushCommand(std::move(cmd.value));
}
}
@ -125,9 +125,9 @@ void TileSheetEditorModel::paste() {
auto const&s = activeSubSheet();
auto const pt1 = m_selection->a;
auto const pt2 = ox::Point{s.columns * TileWidth, s.rows * TileHeight};
if (auto const cmd = ox::makeCatch<CutPasteCommand>(
if (auto cmd = ox::make_unique_catch<CutPasteCommand>(
CommandId::Paste, m_img, m_activeSubsSheetIdx, pt1, pt2, *cb); cmd.value) {
std::ignore = pushCommand(cmd.value);
std::ignore = pushCommand(std::move(cmd.value));
}
}
@ -142,7 +142,7 @@ ox::String const &TileSheetEditorModel::palPath() const & noexcept {
ox::Error TileSheetEditorModel::setPalette(ox::StringViewCR path) noexcept {
OX_REQUIRE(uuid, keelCtx(m_tctx).pathToUuid.at(path));
std::ignore = pushCommand(ox::make<PaletteChangeCommand>(
std::ignore = pushCommand(ox::make_unique<PaletteChangeCommand>(
activeSubSheetIdx(), m_img, uuid->toString()));
return {};
}
@ -169,7 +169,7 @@ void TileSheetEditorModel::drawCommand(ox::Point const &pt, std::size_t const pa
if (m_ongoingDrawCommand) {
m_updated = m_updated || m_ongoingDrawCommand->append(idx);
} else if (activeSubSheet.pixels[idx] != palIdx) {
std::ignore = pushCommand(ox::make<DrawCommand>(
std::ignore = pushCommand(ox::make_unique<DrawCommand>(
m_img, m_activeSubsSheetIdx, idx, static_cast<int>(palIdx)));
}
}
@ -188,7 +188,7 @@ void TileSheetEditorModel::drawLineCommand(ox::Point const &pt, std::size_t cons
m_ongoingDrawCommand->lineUpdate(m_lineStartPt, pt);
m_updated = true;
} else {
std::ignore = pushCommand(ox::make<DrawCommand>(
std::ignore = pushCommand(ox::make_unique<DrawCommand>(
m_img, m_activeSubsSheetIdx, idx, static_cast<int>(palIdx)));
m_lineStartPt = pt;
}
@ -203,27 +203,27 @@ void TileSheetEditorModel::endDrawCommand() noexcept {
}
void TileSheetEditorModel::addSubsheet(TileSheet::SubSheetIdx const &parentIdx) noexcept {
std::ignore = pushCommand(ox::make<AddSubSheetCommand>(m_img, parentIdx));
std::ignore = pushCommand(ox::make_unique<AddSubSheetCommand>(m_img, parentIdx));
}
void TileSheetEditorModel::rmSubsheet(TileSheet::SubSheetIdx const &idx) noexcept {
std::ignore = pushCommand(ox::make<RmSubSheetCommand>(m_img, idx));
std::ignore = pushCommand(ox::make_unique<RmSubSheetCommand>(m_img, idx));
}
void TileSheetEditorModel::insertTiles(
TileSheet::SubSheetIdx const &idx, std::size_t const tileIdx, std::size_t const tileCnt) noexcept {
std::ignore = pushCommand(ox::make<InsertTilesCommand>(m_img, idx, tileIdx, tileCnt));
std::ignore = pushCommand(ox::make_unique<InsertTilesCommand>(m_img, idx, tileIdx, tileCnt));
}
void TileSheetEditorModel::deleteTiles(
TileSheet::SubSheetIdx const &idx, std::size_t const tileIdx, std::size_t const tileCnt) noexcept {
std::ignore = pushCommand(ox::make<DeleteTilesCommand>(m_img, idx, tileIdx, tileCnt));
std::ignore = pushCommand(ox::make_unique<DeleteTilesCommand>(m_img, idx, tileIdx, tileCnt));
}
ox::Error TileSheetEditorModel::updateSubsheet(
TileSheet::SubSheetIdx const &idx, ox::StringViewCR name, int const cols, int const rows) noexcept {
OX_REQUIRE(cmd, ox::makeCatch<UpdateSubSheetCommand>(m_img, idx, name, cols, rows));
std::ignore = pushCommand(cmd);
OX_REQUIRE_M(cmd, ox::make_unique_catch<UpdateSubSheetCommand>(m_img, idx, name, cols, rows));
std::ignore = pushCommand(std::move(cmd));
return {};
}
@ -255,29 +255,29 @@ void TileSheetEditorModel::fill(ox::Point const &pt, uint8_t const palIdx) noexc
if (m_ongoingDrawCommand) {
m_updated = m_updated || m_ongoingDrawCommand->append(idxList);
} else if (getPixel(activeSubSheet, pt) != palIdx) {
std::ignore = pushCommand(ox::make<DrawCommand>(m_img, m_activeSubsSheetIdx, idxList, palIdx));
std::ignore = pushCommand(ox::make_unique<DrawCommand>(m_img, m_activeSubsSheetIdx, idxList, palIdx));
}
}
ox::Error TileSheetEditorModel::rotateLeft() noexcept {
auto &ss = activeSubSheet();
auto const &ss = activeSubSheet();
ox::Point pt1, pt2{ss.columns * TileWidth - 1, ss.rows * TileHeight - 1};
if (m_selection) {
pt1 = m_selection->a;
pt2 = m_selection->b;
}
return pushCommand(ox::make<RotateCommand>(
return pushCommand(ox::make_unique<RotateCommand>(
m_img, m_activeSubsSheetIdx, pt1, pt2, RotateCommand::Direction::Left));
}
ox::Error TileSheetEditorModel::rotateRight() noexcept {
auto &ss = activeSubSheet();
auto const &ss = activeSubSheet();
ox::Point pt1, pt2{ss.columns * TileWidth - 1, ss.rows * TileHeight - 1};
if (m_selection) {
pt1 = m_selection->a;
pt2 = m_selection->b;
}
return pushCommand(ox::make<RotateCommand>(
return pushCommand(ox::make_unique<RotateCommand>(
m_img, m_activeSubsSheetIdx, pt1, pt2, RotateCommand::Direction::Right));
}
@ -365,7 +365,7 @@ ox::Error TileSheetEditorModel::flipX() noexcept {
a = m_selection->a;
b = m_selection->b;
}
return pushCommand(ox::make<FlipXCommand>(m_img, m_activeSubsSheetIdx, a, b));
return pushCommand(ox::make_unique<FlipXCommand>(m_img, m_activeSubsSheetIdx, a, b));
}
ox::Error TileSheetEditorModel::flipY() noexcept {
@ -376,7 +376,7 @@ ox::Error TileSheetEditorModel::flipY() noexcept {
a = m_selection->a;
b = m_selection->b;
}
return pushCommand(ox::make<FlipYCommand>(m_img, m_activeSubsSheetIdx, a, b));
return pushCommand(ox::make_unique<FlipYCommand>(m_img, m_activeSubsSheetIdx, a, b));
}
bool TileSheetEditorModel::rotateEligible() const noexcept {
@ -390,7 +390,7 @@ bool TileSheetEditorModel::rotateEligible() const noexcept {
}
ox::Error TileSheetEditorModel::moveSubSheet(TileSheet::SubSheetIdx src, TileSheet::SubSheetIdx dst) noexcept {
return pushCommand(ox::make<MoveSubSheetCommand>(m_img, std::move(src), std::move(dst)));
return pushCommand(ox::make_unique<MoveSubSheetCommand>(m_img, std::move(src), std::move(dst)));
}
void TileSheetEditorModel::getFillPixels(
@ -437,9 +437,9 @@ void TileSheetEditorModel::setPalPath() noexcept {
}
}
ox::Error TileSheetEditorModel::pushCommand(studio::UndoCommand *cmd) noexcept {
std::ignore = m_undoStack.push(ox::UPtr{cmd});
m_ongoingDrawCommand = dynamic_cast<DrawCommand*>(cmd);
ox::Error TileSheetEditorModel::pushCommand(ox::UPtr<studio::UndoCommand> &&cmd) noexcept {
m_ongoingDrawCommand = dynamic_cast<DrawCommand*>(cmd.get());
std::ignore = m_undoStack.push(std::move(cmd));
m_updated = true;
return {};
}

View File

@ -152,7 +152,7 @@ class TileSheetEditorModel final: public ox::SignalHandler {
void setPalPath() noexcept;
ox::Error pushCommand(studio::UndoCommand *cmd) noexcept;
ox::Error pushCommand(ox::UPtr<studio::UndoCommand> &&cmd) noexcept;
ox::Error handleFileRename(ox::StringViewCR, ox::StringViewCR newPath, ox::UUID const &id) noexcept;