This commit is contained in:
@@ -5,14 +5,14 @@
|
||||
#include "cutpastecommand.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
|
||||
TileSheetClipboard::Pixel::Pixel(uint16_t pColorIdx, ox::Point pPt) noexcept {
|
||||
colorIdx = pColorIdx;
|
||||
pt = pPt;
|
||||
}
|
||||
TileSheetClipboard::Pixel::Pixel(
|
||||
uint16_t const pColorIdx,
|
||||
ox::Point const pPt) noexcept:
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -25,19 +25,19 @@ CutPasteCommand::CutPasteCommand(
|
||||
CommandId commandId,
|
||||
TileSheet &img,
|
||||
TileSheet::SubSheetIdx subSheetIdx,
|
||||
ox::Point const&dstStart,
|
||||
ox::Point const &dstStart,
|
||||
ox::Point dstEnd,
|
||||
TileSheetClipboard const&cb):
|
||||
TileSheetClipboard const &cb):
|
||||
m_commandId(commandId),
|
||||
m_img(img),
|
||||
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) {
|
||||
throw ox::Exception{1, "paste starts beyond the bounds of target"};
|
||||
}
|
||||
dstEnd.x = std::min(ss.columns * TileWidth - 1, dstEnd.x);
|
||||
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;
|
||||
if (dstPt.x <= dstEnd.x && dstPt.y <= dstEnd.y) {
|
||||
auto const idx = gfx::idx(ss, dstPt);
|
||||
@@ -66,7 +66,7 @@ int CutPasteCommand::commandId() const noexcept {
|
||||
return static_cast<int>(m_commandId);
|
||||
}
|
||||
|
||||
TileSheet::SubSheetIdx const&CutPasteCommand::subsheetIdx() const noexcept {
|
||||
TileSheet::SubSheetIdx const &CutPasteCommand::subsheetIdx() const noexcept {
|
||||
return m_subSheetIdx;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user