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

This commit is contained in:
2026-01-29 19:30:32 -06:00
parent ca851e1059
commit 3c07eb2df7

View File

@@ -5,14 +5,14 @@
#include "cutpastecommand.hpp" #include "cutpastecommand.hpp"
namespace nostalgia::gfx { namespace nostalgia::gfx {
TileSheetClipboard::Pixel::Pixel(
TileSheetClipboard::Pixel::Pixel(uint16_t pColorIdx, ox::Point pPt) noexcept { uint16_t const pColorIdx,
colorIdx = pColorIdx; ox::Point const pPt) noexcept:
pt = pPt; colorIdx(pColorIdx),
} pt(pPt) {}
void TileSheetClipboard::addPixel(ox::Point const&pt, uint16_t colorIdx) noexcept { void TileSheetClipboard::addPixel(ox::Point const &pt, uint16_t colorIdx) noexcept {
m_pixels.emplace_back(colorIdx, pt); m_pixels.emplace_back(colorIdx, pt);
} }
@@ -25,19 +25,19 @@ CutPasteCommand::CutPasteCommand(
CommandId commandId, CommandId commandId,
TileSheet &img, TileSheet &img,
TileSheet::SubSheetIdx subSheetIdx, TileSheet::SubSheetIdx subSheetIdx,
ox::Point const&dstStart, ox::Point const &dstStart,
ox::Point dstEnd, ox::Point dstEnd,
TileSheetClipboard const&cb): TileSheetClipboard const &cb):
m_commandId(commandId), m_commandId(commandId),
m_img(img), m_img(img),
m_subSheetIdx(std::move(subSheetIdx)) { m_subSheetIdx(std::move(subSheetIdx)) {
auto const&ss = getSubSheet(m_img, m_subSheetIdx); auto const &ss = getSubSheet(m_img, m_subSheetIdx);
if (dstStart.x >= ss.columns * TileWidth || dstStart.y >= ss.rows * TileHeight) { if (dstStart.x >= ss.columns * TileWidth || dstStart.y >= ss.rows * TileHeight) {
throw ox::Exception{1, "paste starts beyond the bounds of target"}; throw ox::Exception{1, "paste starts beyond the bounds of target"};
} }
dstEnd.x = std::min(ss.columns * TileWidth - 1, dstEnd.x); dstEnd.x = std::min(ss.columns * TileWidth - 1, dstEnd.x);
dstEnd.y = std::min(ss.rows * TileHeight - 1, dstEnd.y); dstEnd.y = std::min(ss.rows * TileHeight - 1, dstEnd.y);
for (auto const&p : cb.pixels()) { for (auto const &p : cb.pixels()) {
auto const dstPt = p.pt + dstStart; auto const dstPt = p.pt + dstStart;
if (dstPt.x <= dstEnd.x && dstPt.y <= dstEnd.y) { if (dstPt.x <= dstEnd.x && dstPt.y <= dstEnd.y) {
auto const idx = gfx::idx(ss, dstPt); auto const idx = gfx::idx(ss, dstPt);
@@ -66,7 +66,7 @@ int CutPasteCommand::commandId() const noexcept {
return static_cast<int>(m_commandId); return static_cast<int>(m_commandId);
} }
TileSheet::SubSheetIdx const&CutPasteCommand::subsheetIdx() const noexcept { TileSheet::SubSheetIdx const &CutPasteCommand::subsheetIdx() const noexcept {
return m_subSheetIdx; return m_subSheetIdx;
} }