[nostalgia/gfx] Cleanup

This commit is contained in:
2025-05-30 23:32:27 -05:00
parent 2ca77173d3
commit 4b5218c4f1
4 changed files with 40 additions and 40 deletions

View File

@@ -126,7 +126,7 @@ void TileSheetEditorModel::paste() {
auto const pt1 = m_selection->a; auto const pt1 = m_selection->a;
auto const pt2 = ox::Point{s.columns * TileWidth, s.rows * TileHeight}; auto const pt2 = ox::Point{s.columns * TileWidth, s.rows * TileHeight};
if (auto const cmd = ox::makeCatch<CutPasteCommand>( if (auto const cmd = ox::makeCatch<CutPasteCommand>(
CommandId::Paste, m_img, m_activeSubsSheetIdx, pt1, pt2, *cb); cmd.ok()) { CommandId::Paste, m_img, m_activeSubsSheetIdx, pt1, pt2, *cb); cmd.value) {
std::ignore = pushCommand(cmd.value); std::ignore = pushCommand(cmd.value);
} }
} }
@@ -233,7 +233,7 @@ void TileSheetEditorModel::setActiveSubsheet(TileSheet::SubSheetIdx const&idx) n
clearSelection(); clearSelection();
} }
void TileSheetEditorModel::fill(ox::Point const&pt, int const palIdx) noexcept { void TileSheetEditorModel::fill(ox::Point const &pt, uint8_t const palIdx) noexcept {
auto const&activeSubSheet = getSubSheet(m_img, m_activeSubsSheetIdx); auto const&activeSubSheet = getSubSheet(m_img, m_activeSubsSheetIdx);
// build idx list // build idx list
if (pt.x >= activeSubSheet.columns * TileWidth || pt.y >= activeSubSheet.rows * TileHeight) { if (pt.x >= activeSubSheet.columns * TileWidth || pt.y >= activeSubSheet.rows * TileHeight) {
@@ -394,9 +394,9 @@ ox::Error TileSheetEditorModel::moveSubSheet(TileSheet::SubSheetIdx src, TileShe
void TileSheetEditorModel::getFillPixels( void TileSheetEditorModel::getFillPixels(
TileSheet::SubSheet const&activeSubSheet, TileSheet::SubSheet const&activeSubSheet,
ox::Span<bool> pixels, ox::Span<bool> const pixels,
ox::Point const &pt, ox::Point const &pt,
int const oldColor) const noexcept { uint8_t const oldColor) noexcept {
auto const idx = ptToIdx(pt, activeSubSheet.columns); auto const idx = ptToIdx(pt, activeSubSheet.columns);
auto const relIdx = idx % PixelsPerTile; auto const relIdx = idx % PixelsPerTile;
if (pixels[relIdx] || activeSubSheet.pixels[idx] != oldColor) { if (pixels[relIdx] || activeSubSheet.pixels[idx] != oldColor) {

View File

@@ -14,7 +14,7 @@
namespace nostalgia::gfx { namespace nostalgia::gfx {
class TileSheetEditorModel: public ox::SignalHandler { class TileSheetEditorModel final: public ox::SignalHandler {
public: public:
ox::Signal<ox::Error(const TileSheet::SubSheetIdx&)> activeSubsheetChanged; ox::Signal<ox::Error(const TileSheet::SubSheetIdx&)> activeSubsheetChanged;
@@ -104,7 +104,7 @@ class TileSheetEditorModel: public ox::SignalHandler {
return m_activeSubsSheetIdx; return m_activeSubsSheetIdx;
} }
void fill(ox::Point const&pt, int palIdx) noexcept; void fill(ox::Point const &pt, uint8_t palIdx) noexcept;
ox::Error rotateLeft() noexcept; ox::Error rotateLeft() noexcept;
@@ -144,11 +144,11 @@ class TileSheetEditorModel: public ox::SignalHandler {
ox::Error moveSubSheet(TileSheet::SubSheetIdx src, TileSheet::SubSheetIdx dst) noexcept; ox::Error moveSubSheet(TileSheet::SubSheetIdx src, TileSheet::SubSheetIdx dst) noexcept;
private: private:
void getFillPixels( static void getFillPixels(
TileSheet::SubSheet const &activeSubSheet, TileSheet::SubSheet const &activeSubSheet,
ox::Span<bool> pixels, ox::Span<bool> pixels,
ox::Point const &pt, ox::Point const &pt,
int oldColor) const noexcept; uint8_t oldColor) noexcept;
void setPalPath() noexcept; void setPalPath() noexcept;

View File

@@ -89,7 +89,7 @@ void TileSheetEditorView::clickSelect(ox::Vec2 const&paneSize, ox::Vec2 const&cl
void TileSheetEditorView::clickFill(ox::Vec2 const&paneSize, ox::Vec2 const&clickPos) noexcept { void TileSheetEditorView::clickFill(ox::Vec2 const&paneSize, ox::Vec2 const&clickPos) noexcept {
auto const pt = clickPoint(paneSize, clickPos); auto const pt = clickPoint(paneSize, clickPos);
m_model.fill(pt, static_cast<int>(m_palIdx)); m_model.fill(pt, static_cast<uint8_t>(m_palIdx));
} }
void TileSheetEditorView::releaseMouseButton(TileSheetTool tool) noexcept { void TileSheetEditorView::releaseMouseButton(TileSheetTool tool) noexcept {