From 6b7c002a10e2e86faaa1d7200b336f5ee8d962a4 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sun, 3 Dec 2023 21:14:20 -0600 Subject: [PATCH] [nostalgia] Style updates --- .../core/include/nostalgia/core/config.hpp | 11 ---- .../core/include/nostalgia/core/context.hpp | 4 +- .../core/include/nostalgia/core/tilesheet.hpp | 34 +++++------ .../modules/core/src/gba/context.cpp | 4 +- .../modules/core/src/gba/context.hpp | 6 +- src/nostalgia/modules/core/src/gba/gfx.cpp | 2 +- src/nostalgia/modules/core/src/gfx.cpp | 2 +- .../core/src/studio/paletteeditor-imgui.cpp | 4 +- .../core/src/studio/paletteeditor-imgui.hpp | 4 +- .../core/src/studio/tilesheeteditor-imgui.cpp | 4 +- .../core/src/studio/tilesheeteditor-imgui.hpp | 4 +- .../core/src/studio/tilesheeteditormodel.cpp | 59 +++++++++---------- .../core/src/studio/tilesheeteditormodel.hpp | 12 ++-- .../core/src/studio/tilesheeteditorview.cpp | 20 +++---- .../core/src/studio/tilesheeteditorview.hpp | 24 ++++---- .../core/src/studio/tilesheetpixelgrid.cpp | 10 ++-- .../core/src/studio/tilesheetpixelgrid.hpp | 10 ++-- .../core/src/studio/tilesheetpixels.cpp | 6 +- .../core/src/studio/tilesheetpixels.hpp | 8 +-- src/nostalgia/modules/core/src/tilesheet.cpp | 36 +++++------ 20 files changed, 126 insertions(+), 138 deletions(-) delete mode 100644 src/nostalgia/modules/core/include/nostalgia/core/config.hpp diff --git a/src/nostalgia/modules/core/include/nostalgia/core/config.hpp b/src/nostalgia/modules/core/include/nostalgia/core/config.hpp deleted file mode 100644 index 57276d2a..00000000 --- a/src/nostalgia/modules/core/include/nostalgia/core/config.hpp +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. - */ - -#pragma once - -#include - -namespace nostalgia::core::config { - -} diff --git a/src/nostalgia/modules/core/include/nostalgia/core/context.hpp b/src/nostalgia/modules/core/include/nostalgia/core/context.hpp index 789f73bb..ae001348 100644 --- a/src/nostalgia/modules/core/include/nostalgia/core/context.hpp +++ b/src/nostalgia/modules/core/include/nostalgia/core/context.hpp @@ -21,8 +21,8 @@ class Context { public: Context() noexcept = default; Context(Context &other) noexcept = delete; - Context(const Context &other) noexcept = delete; - Context(const Context &&other) noexcept = delete; + Context(Context const&other) noexcept = delete; + Context(Context const&&other) noexcept = delete; virtual ~Context() noexcept = default; }; diff --git a/src/nostalgia/modules/core/include/nostalgia/core/tilesheet.hpp b/src/nostalgia/modules/core/include/nostalgia/core/tilesheet.hpp index b7a731d1..91f22839 100644 --- a/src/nostalgia/modules/core/include/nostalgia/core/tilesheet.hpp +++ b/src/nostalgia/modules/core/include/nostalgia/core/tilesheet.hpp @@ -96,7 +96,7 @@ struct TileSheet { SubSheet &operator=(SubSheet &&other) noexcept; [[nodiscard]] - std::size_t idx(const ox::Point &pt) const noexcept; + std::size_t idx(ox::Point const&pt) const noexcept; /** * Reads all pixels of this sheet or its children into the given pixel list @@ -160,7 +160,7 @@ struct TileSheet { void setPixel(int8_t pBpp, uint64_t idx, uint8_t palIdx) noexcept; - void setPixel(int8_t pBpp, const ox::Point &pt, uint8_t palIdx) noexcept; + void setPixel(int8_t pBpp, ox::Point const&pt, uint8_t palIdx) noexcept; ox::Error setPixelCount(int8_t pBpp, std::size_t cnt) noexcept; @@ -200,7 +200,7 @@ struct TileSheet { SubSheet subsheet{0, "Root", 1, 1, bpp}; constexpr TileSheet() noexcept = default; - TileSheet(const TileSheet &other) noexcept = default; + TileSheet(TileSheet const&other) noexcept = default; inline TileSheet(TileSheet &&other) noexcept: bpp(other.bpp), idIt(other.idIt), @@ -208,13 +208,13 @@ struct TileSheet { subsheet(std::move(other.subsheet)) { } - TileSheet &operator=(const TileSheet &other) noexcept; + TileSheet &operator=(TileSheet const&other) noexcept; TileSheet &operator=(TileSheet &&other) noexcept; [[nodiscard]] SubSheetIdx validateSubSheetIdx( - const SubSheetIdx &pIdx, + SubSheetIdx const&pIdx, std::size_t pIdxIt, const SubSheet *pSubsheet) noexcept; @@ -229,43 +229,43 @@ struct TileSheet { SubSheetIdx validateSubSheetIdx(const SubSheetIdx &idx) noexcept; [[nodiscard]] - static const SubSheet &getSubSheet( - const SubSheetIdx &idx, + static SubSheet const&getSubSheet( + SubSheetIdx const&idx, std::size_t idxIt, const SubSheet *pSubsheet) noexcept; [[nodiscard]] static SubSheet &getSubSheet( - const SubSheetIdx &idx, + SubSheetIdx const&idx, std::size_t idxIt, SubSheet *pSubsheet) noexcept; [[nodiscard]] - const SubSheet &getSubSheet(const SubSheetIdx &idx) const noexcept; + const SubSheet &getSubSheet(SubSheetIdx const&idx) const noexcept; [[nodiscard]] - SubSheet &getSubSheet(const SubSheetIdx &idx) noexcept; + SubSheet &getSubSheet(SubSheetIdx const&idx) noexcept; - ox::Error addSubSheet(const SubSheetIdx &idx) noexcept; + ox::Error addSubSheet(SubSheetIdx const&idx) noexcept; [[nodiscard]] static ox::Error rmSubSheet( - const SubSheetIdx &idx, + SubSheetIdx const&idx, std::size_t idxIt, SubSheet *pSubsheet) noexcept; [[nodiscard]] - ox::Error rmSubSheet(const SubSheetIdx &idx) noexcept; + ox::Error rmSubSheet(SubSheetIdx const&idx) noexcept; [[nodiscard]] uint8_t getPixel4Bpp( - const ox::Point &pt, - const SubSheetIdx &subsheetIdx) const noexcept; + ox::Point const&pt, + SubSheetIdx const&subsheetIdx) const noexcept; [[nodiscard]] uint8_t getPixel8Bpp( - const ox::Point &pt, - const SubSheetIdx &subsheetIdx) const noexcept; + ox::Point const&pt, + SubSheetIdx const&subsheetIdx) const noexcept; ox::Result getIdFor(ox::CRStringView path) const noexcept; diff --git a/src/nostalgia/modules/core/src/gba/context.cpp b/src/nostalgia/modules/core/src/gba/context.cpp index 9f01721a..dec6c390 100644 --- a/src/nostalgia/modules/core/src/gba/context.cpp +++ b/src/nostalgia/modules/core/src/gba/context.cpp @@ -8,13 +8,13 @@ namespace nostalgia::core { -GbaContext::GbaContext(turbine::Context *tctx) noexcept: turbineCtx(tctx) { +GbaContext::GbaContext(turbine::Context &tctx) noexcept: turbineCtx(tctx) { } ox::Error initGfx(Context &ctx, InitParams const&) noexcept; ox::Result> init(turbine::Context &tctx, InitParams const¶ms) noexcept { - auto ctx = ox::make_unique(&tctx); + auto ctx = ox::make_unique(tctx); oxReturnError(initGfx(*ctx, params)); return ox::UPtr(std::move(ctx)); } diff --git a/src/nostalgia/modules/core/src/gba/context.hpp b/src/nostalgia/modules/core/src/gba/context.hpp index 1347c773..eea7efb8 100644 --- a/src/nostalgia/modules/core/src/gba/context.hpp +++ b/src/nostalgia/modules/core/src/gba/context.hpp @@ -10,13 +10,13 @@ namespace nostalgia::core { struct GbaContext: public core::Context { - turbine::Context const*turbineCtx = nullptr; + turbine::Context &turbineCtx; - explicit GbaContext(turbine::Context *tctx) noexcept; + explicit GbaContext(turbine::Context &tctx) noexcept; [[nodiscard]] auto const&rom() const noexcept { - return *turbine::rom(*turbineCtx); + return *turbine::rom(turbineCtx); } }; diff --git a/src/nostalgia/modules/core/src/gba/gfx.cpp b/src/nostalgia/modules/core/src/gba/gfx.cpp index fd3ed4ce..198d3374 100644 --- a/src/nostalgia/modules/core/src/gba/gfx.cpp +++ b/src/nostalgia/modules/core/src/gba/gfx.cpp @@ -109,7 +109,7 @@ void setBgCbb(Context&, unsigned bgIdx, unsigned cbb) noexcept { } static ox::Error loadBgTileSheet( - const ox::MemFS &rom, + ox::MemFS const&rom, unsigned cbb, ox::FileAddress const&tilesheetAddr, ox::FileAddress const&paletteAddr) noexcept { diff --git a/src/nostalgia/modules/core/src/gfx.cpp b/src/nostalgia/modules/core/src/gfx.cpp index e0b6b872..fbe34977 100644 --- a/src/nostalgia/modules/core/src/gfx.cpp +++ b/src/nostalgia/modules/core/src/gfx.cpp @@ -137,7 +137,7 @@ ox::Array charMap = { 0, // ~ }; -void setSprite(Context &c, const Sprite &s) noexcept { +void setSprite(Context &c, Sprite const&s) noexcept { setSprite(c, s.idx, s.x, s.y, s.tileIdx, s.spriteShape, s.spriteSize, s.flipX); } diff --git a/src/nostalgia/modules/core/src/studio/paletteeditor-imgui.cpp b/src/nostalgia/modules/core/src/studio/paletteeditor-imgui.cpp index e0212800..893986f9 100644 --- a/src/nostalgia/modules/core/src/studio/paletteeditor-imgui.cpp +++ b/src/nostalgia/modules/core/src/studio/paletteeditor-imgui.cpp @@ -22,11 +22,11 @@ PaletteEditorImGui::PaletteEditorImGui(turbine::Context &ctx, ox::String path): m_pal(*keel::readObj(m_ctx.keelCtx, ox::FileAddress(m_itemPath.c_str())).unwrapThrow()) { } -const ox::String &PaletteEditorImGui::itemName() const noexcept { +ox::String const&PaletteEditorImGui::itemName() const noexcept { return m_itemPath; } -const ox::String &PaletteEditorImGui::itemDisplayName() const noexcept { +ox::String const&PaletteEditorImGui::itemDisplayName() const noexcept { return m_itemName; } diff --git a/src/nostalgia/modules/core/src/studio/paletteeditor-imgui.hpp b/src/nostalgia/modules/core/src/studio/paletteeditor-imgui.hpp index 834e654d..0f03c1c6 100644 --- a/src/nostalgia/modules/core/src/studio/paletteeditor-imgui.hpp +++ b/src/nostalgia/modules/core/src/studio/paletteeditor-imgui.hpp @@ -26,9 +26,9 @@ class PaletteEditorImGui: public studio::Editor { /** * Returns the name of item being edited. */ - const ox::String &itemName() const noexcept final; + ox::String const&itemName() const noexcept final; - const ox::String &itemDisplayName() const noexcept final; + ox::String const&itemDisplayName() const noexcept final; void draw(turbine::Context*) noexcept final; diff --git a/src/nostalgia/modules/core/src/studio/tilesheeteditor-imgui.cpp b/src/nostalgia/modules/core/src/studio/tilesheeteditor-imgui.cpp index 600c09a6..f0281438 100644 --- a/src/nostalgia/modules/core/src/studio/tilesheeteditor-imgui.cpp +++ b/src/nostalgia/modules/core/src/studio/tilesheeteditor-imgui.cpp @@ -60,11 +60,11 @@ TileSheetEditorImGui::TileSheetEditorImGui(turbine::Context &ctx, ox::String pat m_subsheetEditor.inputSubmitted.connect(this, &TileSheetEditorImGui::updateActiveSubsheet); } -const ox::String &TileSheetEditorImGui::itemName() const noexcept { +ox::String const&TileSheetEditorImGui::itemName() const noexcept { return m_itemPath; } -const ox::String &TileSheetEditorImGui::itemDisplayName() const noexcept { +ox::String const&TileSheetEditorImGui::itemDisplayName() const noexcept { return m_itemName; } diff --git a/src/nostalgia/modules/core/src/studio/tilesheeteditor-imgui.hpp b/src/nostalgia/modules/core/src/studio/tilesheeteditor-imgui.hpp index cfe25002..9fbde86b 100644 --- a/src/nostalgia/modules/core/src/studio/tilesheeteditor-imgui.hpp +++ b/src/nostalgia/modules/core/src/studio/tilesheeteditor-imgui.hpp @@ -59,9 +59,9 @@ class TileSheetEditorImGui: public studio::BaseEditor { ~TileSheetEditorImGui() override = default; - const ox::String &itemName() const noexcept override; + ox::String const&itemName() const noexcept override; - const ox::String &itemDisplayName() const noexcept override; + ox::String const&itemDisplayName() const noexcept override; void exportFile() override; diff --git a/src/nostalgia/modules/core/src/studio/tilesheeteditormodel.cpp b/src/nostalgia/modules/core/src/studio/tilesheeteditormodel.cpp index a7babd99..6ea64fad 100644 --- a/src/nostalgia/modules/core/src/studio/tilesheeteditormodel.cpp +++ b/src/nostalgia/modules/core/src/studio/tilesheeteditormodel.cpp @@ -40,12 +40,12 @@ class TileSheetClipboard: public turbine::ClipboardObject { ox::Vector m_pixels; public: - constexpr void addPixel(const ox::Point &pt, uint16_t colorIdx) noexcept { + constexpr void addPixel(ox::Point const&pt, uint16_t colorIdx) noexcept { m_pixels.emplace_back(colorIdx, pt); } [[nodiscard]] - constexpr const ox::Vector &pixels() const noexcept { + constexpr ox::Vector const&pixels() const noexcept { return m_pixels; } }; @@ -84,7 +84,7 @@ constexpr bool operator==(int i, CommandId c) noexcept { class TileSheetCommand: public studio::UndoCommand { public: [[nodiscard]] - virtual const TileSheet::SubSheetIdx &subsheetIdx() const noexcept = 0; + virtual TileSheet::SubSheetIdx const&subsheetIdx() const noexcept = 0; }; class DrawCommand: public TileSheetCommand { @@ -129,7 +129,7 @@ class DrawCommand: public TileSheetCommand { m_palIdx = palIdx; } - auto append(std::size_t idx) noexcept { + bool append(std::size_t idx) noexcept { auto &subsheet = m_img.getSubSheet(m_subSheetIdx); if (m_changes.back().value->idx != idx && subsheet.getPixel(m_img.bpp, idx) != m_palIdx) { // duplicate entries are bad @@ -173,7 +173,7 @@ class DrawCommand: public TileSheetCommand { } [[nodiscard]] - const TileSheet::SubSheetIdx &subsheetIdx() const noexcept override { + TileSheet::SubSheetIdx const&subsheetIdx() const noexcept override { return m_subSheetIdx; } @@ -200,9 +200,9 @@ class CutPasteCommand: public TileSheetCommand { constexpr CutPasteCommand( TileSheet &img, TileSheet::SubSheetIdx subSheetIdx, - const ox::Point &dstStart, - const ox::Point &dstEnd, - const TileSheetClipboard &cb) noexcept: + ox::Point const&dstStart, + ox::Point const&dstEnd, + TileSheetClipboard const&cb) noexcept: m_img(img), m_subSheetIdx(std::move(subSheetIdx)) { const auto &subsheet = m_img.getSubSheet(m_subSheetIdx); @@ -235,7 +235,7 @@ class CutPasteCommand: public TileSheetCommand { } [[nodiscard]] - const TileSheet::SubSheetIdx &subsheetIdx() const noexcept override { + TileSheet::SubSheetIdx const&subsheetIdx() const noexcept override { return m_subSheetIdx; } @@ -249,8 +249,7 @@ class AddSubSheetCommand: public TileSheetCommand { public: AddSubSheetCommand(TileSheet &img, TileSheet::SubSheetIdx parentIdx) noexcept: - m_img(img), - m_parentIdx(std::move(parentIdx)) { + m_img(img), m_parentIdx(std::move(parentIdx)) { auto &parent = m_img.getSubSheet(m_parentIdx); if (parent.subsheets.size()) { auto idx = m_parentIdx; @@ -299,7 +298,7 @@ class AddSubSheetCommand: public TileSheetCommand { } [[nodiscard]] - const TileSheet::SubSheetIdx &subsheetIdx() const noexcept override { + TileSheet::SubSheetIdx const&subsheetIdx() const noexcept override { return m_parentIdx; } @@ -314,8 +313,8 @@ class RmSubSheetCommand: public TileSheetCommand { public: RmSubSheetCommand(TileSheet &img, TileSheet::SubSheetIdx idx) noexcept: - m_img(img), - m_idx(std::move(idx)) { + m_img(img), + m_idx(std::move(idx)) { m_parentIdx = idx; m_parentIdx.pop_back(); auto &parent = m_img.getSubSheet(m_parentIdx); @@ -339,7 +338,7 @@ class RmSubSheetCommand: public TileSheetCommand { } [[nodiscard]] - const TileSheet::SubSheetIdx &subsheetIdx() const noexcept override { + TileSheet::SubSheetIdx const&subsheetIdx() const noexcept override { return m_idx; } @@ -404,7 +403,7 @@ class InsertTilesCommand: public TileSheetCommand { } [[nodiscard]] - const TileSheet::SubSheetIdx &subsheetIdx() const noexcept override { + TileSheet::SubSheetIdx const&subsheetIdx() const noexcept override { return m_idx; } @@ -469,7 +468,7 @@ class DeleteTilesCommand: public TileSheetCommand { } [[nodiscard]] - const TileSheet::SubSheetIdx &subsheetIdx() const noexcept override { + TileSheet::SubSheetIdx const&subsheetIdx() const noexcept override { return m_idx; } @@ -518,7 +517,7 @@ class UpdateSubSheetCommand: public TileSheetCommand { } [[nodiscard]] - const TileSheet::SubSheetIdx &subsheetIdx() const noexcept override { + TileSheet::SubSheetIdx const&subsheetIdx() const noexcept override { return m_idx; } @@ -556,7 +555,7 @@ class PaletteChangeCommand: public TileSheetCommand { } [[nodiscard]] - const TileSheet::SubSheetIdx &subsheetIdx() const noexcept override { + TileSheet::SubSheetIdx const&subsheetIdx() const noexcept override { return m_idx; } @@ -643,13 +642,13 @@ ox::StringView TileSheetEditorModel::palPath() const noexcept { } } -ox::Error TileSheetEditorModel::setPalette(const ox::String &path) noexcept { +ox::Error TileSheetEditorModel::setPalette(ox::String const&path) noexcept { oxRequire(uuid, m_ctx.keelCtx.pathToUuid.at(path)); pushCommand(ox::make(activeSubSheetIdx(), m_img, uuid->toString())); return {}; } -void TileSheetEditorModel::drawCommand(const ox::Point &pt, std::size_t palIdx) noexcept { +void TileSheetEditorModel::drawCommand(ox::Point const&pt, std::size_t palIdx) noexcept { const auto &activeSubSheet = m_img.getSubSheet(m_activeSubsSheetIdx); if (pt.x >= activeSubSheet.columns * TileWidth || pt.y >= activeSubSheet.rows * TileHeight) { return; @@ -666,33 +665,33 @@ void TileSheetEditorModel::endDrawCommand() noexcept { m_ongoingDrawCommand = nullptr; } -void TileSheetEditorModel::addSubsheet(const TileSheet::SubSheetIdx &parentIdx) noexcept { +void TileSheetEditorModel::addSubsheet(TileSheet::SubSheetIdx const&parentIdx) noexcept { pushCommand(ox::make(m_img, parentIdx)); } -void TileSheetEditorModel::rmSubsheet(const TileSheet::SubSheetIdx &idx) noexcept { +void TileSheetEditorModel::rmSubsheet(TileSheet::SubSheetIdx const&idx) noexcept { pushCommand(ox::make(m_img, idx)); } -void TileSheetEditorModel::insertTiles(const TileSheet::SubSheetIdx &idx, std::size_t tileIdx, std::size_t tileCnt) noexcept { +void TileSheetEditorModel::insertTiles(TileSheet::SubSheetIdx const&idx, std::size_t tileIdx, std::size_t tileCnt) noexcept { pushCommand(ox::make(m_img, idx, tileIdx, tileCnt)); } -void TileSheetEditorModel::deleteTiles(const TileSheet::SubSheetIdx &idx, std::size_t tileIdx, std::size_t tileCnt) noexcept { +void TileSheetEditorModel::deleteTiles(TileSheet::SubSheetIdx const&idx, std::size_t tileIdx, std::size_t tileCnt) noexcept { pushCommand(ox::make(m_img, idx, tileIdx, tileCnt)); } -ox::Error TileSheetEditorModel::updateSubsheet(const TileSheet::SubSheetIdx &idx, const ox::StringView &name, int cols, int rows) noexcept { +ox::Error TileSheetEditorModel::updateSubsheet(TileSheet::SubSheetIdx const&idx, const ox::StringView &name, int cols, int rows) noexcept { pushCommand(ox::make(m_img, idx, ox::String(name), cols, rows)); return {}; } -void TileSheetEditorModel::setActiveSubsheet(const TileSheet::SubSheetIdx &idx) noexcept { +void TileSheetEditorModel::setActiveSubsheet(TileSheet::SubSheetIdx const&idx) noexcept { m_activeSubsSheetIdx = idx; this->activeSubsheetChanged.emit(m_activeSubsSheetIdx); } -void TileSheetEditorModel::fill(const ox::Point &pt, int palIdx) noexcept { +void TileSheetEditorModel::fill(ox::Point const&pt, int palIdx) noexcept { const auto &s = m_img.getSubSheet(m_activeSubsSheetIdx); // build idx list ox::Array updateMap = {}; @@ -717,7 +716,7 @@ void TileSheetEditorModel::fill(const ox::Point &pt, int palIdx) noexcept { } } -void TileSheetEditorModel::select(const ox::Point &pt) noexcept { +void TileSheetEditorModel::select(ox::Point const&pt) noexcept { if (!m_selectionOngoing) { m_selectionOrigin = pt; m_selectionOngoing = true; @@ -782,7 +781,7 @@ bool TileSheetEditorModel::pixelSelected(std::size_t idx) const noexcept { return m_selectionBounds.contains(pt); } -void TileSheetEditorModel::getFillPixels(bool *pixels, const ox::Point &pt, int oldColor) const noexcept { +void TileSheetEditorModel::getFillPixels(bool *pixels, ox::Point const&pt, int oldColor) const noexcept { const auto &activeSubSheet = *this->activeSubSheet(); const auto tileIdx = [activeSubSheet](const ox::Point &pt) noexcept { return ptToIdx(pt, activeSubSheet.columns) / PixelsPerTile; diff --git a/src/nostalgia/modules/core/src/studio/tilesheeteditormodel.hpp b/src/nostalgia/modules/core/src/studio/tilesheeteditormodel.hpp index 3eb37c0e..f4ecbc4b 100644 --- a/src/nostalgia/modules/core/src/studio/tilesheeteditormodel.hpp +++ b/src/nostalgia/modules/core/src/studio/tilesheeteditormodel.hpp @@ -89,13 +89,13 @@ class TileSheetEditorModel: public ox::SignalHandler { } [[nodiscard]] - constexpr const TileSheet::SubSheetIdx &activeSubSheetIdx() const noexcept { + constexpr TileSheet::SubSheetIdx const&activeSubSheetIdx() const noexcept { return m_activeSubsSheetIdx; } - void fill(const ox::Point &pt, int palIdx) noexcept; + void fill(ox::Point const&pt, int palIdx) noexcept; - void select(const ox::Point &pt) noexcept; + void select(ox::Point const&pt) noexcept; void completeSelection() noexcept; @@ -118,7 +118,7 @@ class TileSheetEditorModel: public ox::SignalHandler { bool pixelSelected(std::size_t idx) const noexcept; protected: - void getFillPixels(bool *pixels, const ox::Point &pt, int oldColor) const noexcept; + void getFillPixels(bool *pixels, ox::Point const&pt, int oldColor) const noexcept; private: void pushCommand(studio::UndoCommand *cmd) noexcept; @@ -130,10 +130,10 @@ class TileSheetEditorModel: public ox::SignalHandler { void restoreState(); [[nodiscard]] - ox::String paletteName(const ox::String &palettePath) const; + ox::String paletteName(ox::String const&palettePath) const; [[nodiscard]] - ox::String palettePath(const ox::String &palettePath) const; + ox::String palettePath(ox::String const&palettePath) const; }; diff --git a/src/nostalgia/modules/core/src/studio/tilesheeteditorview.cpp b/src/nostalgia/modules/core/src/studio/tilesheeteditorview.cpp index 4852ec0b..65724a94 100644 --- a/src/nostalgia/modules/core/src/studio/tilesheeteditorview.cpp +++ b/src/nostalgia/modules/core/src/studio/tilesheeteditorview.cpp @@ -28,7 +28,7 @@ void TileSheetEditorView::draw() noexcept { m_pixelGridDrawer.draw(updated(), m_scrollOffset); } -void TileSheetEditorView::scrollV(const ox::Vec2 &paneSz, float wheel, bool zoomMod) noexcept { +void TileSheetEditorView::scrollV(ox::Vec2 const&paneSz, float wheel, bool zoomMod) noexcept { const auto pixelSize = m_pixelsDrawer.pixelSize(paneSz); const ImVec2 sheetSize(pixelSize.x * static_cast(m_model.activeSubSheet()->columns) * TileWidth, pixelSize.y * static_cast(m_model.activeSubSheet()->rows) * TileHeight); @@ -45,7 +45,7 @@ void TileSheetEditorView::scrollV(const ox::Vec2 &paneSz, float wheel, bool zoom m_scrollOffset.y = ox::clamp(m_scrollOffset.y, 0.f, sheetSize.y / 2); } -void TileSheetEditorView::scrollH(const ox::Vec2 &paneSz, float wheelh) noexcept { +void TileSheetEditorView::scrollH(ox::Vec2 const&paneSz, float wheelh) noexcept { const auto pixelSize = m_pixelsDrawer.pixelSize(paneSz); const ImVec2 sheetSize(pixelSize.x * static_cast(m_model.activeSubSheet()->columns) * TileWidth, pixelSize.y * static_cast(m_model.activeSubSheet()->rows) * TileHeight); @@ -53,31 +53,31 @@ void TileSheetEditorView::scrollH(const ox::Vec2 &paneSz, float wheelh) noexcept m_scrollOffset.x = ox::clamp(m_scrollOffset.x, -(sheetSize.x / 2), 0.f); } -void TileSheetEditorView::insertTile(const ox::Vec2 &paneSize, const ox::Vec2 &clickPos) noexcept { +void TileSheetEditorView::insertTile(ox::Vec2 const&paneSize, ox::Vec2 const&clickPos) noexcept { const auto pt = clickPoint(paneSize, clickPos); const auto s = m_model.activeSubSheet(); const auto tileIdx = ptToIdx(pt, s->columns) / PixelsPerTile; m_model.insertTiles(m_model.activeSubSheetIdx(), tileIdx, 1); } -void TileSheetEditorView::deleteTile(const ox::Vec2 &paneSize, const ox::Vec2 &clickPos) noexcept { +void TileSheetEditorView::deleteTile(ox::Vec2 const&paneSize, ox::Vec2 const&clickPos) noexcept { const auto pt = clickPoint(paneSize, clickPos); const auto s = m_model.activeSubSheet(); const auto tileIdx = ptToIdx(pt, s->columns) / PixelsPerTile; m_model.deleteTiles(m_model.activeSubSheetIdx(), tileIdx, 1); } -void TileSheetEditorView::clickDraw(const ox::Vec2 &paneSize, const ox::Vec2 &clickPos) noexcept { +void TileSheetEditorView::clickDraw(ox::Vec2 const &paneSize, ox::Vec2 const&clickPos) noexcept { const auto pt = clickPoint(paneSize, clickPos); m_model.drawCommand(pt, m_palIdx); } -void TileSheetEditorView::clickSelect(const ox::Vec2 &paneSize, const ox::Vec2 &clickPos) noexcept { +void TileSheetEditorView::clickSelect(ox::Vec2 const&paneSize, ox::Vec2 const&clickPos) noexcept { const auto pt = clickPoint(paneSize, clickPos); m_model.select(pt); } -void TileSheetEditorView::clickFill(const ox::Vec2 &paneSize, const ox::Vec2 &clickPos) noexcept { +void TileSheetEditorView::clickFill(ox::Vec2 const&paneSize, ox::Vec2 const&clickPos) noexcept { const auto pt = clickPoint(paneSize, clickPos); m_model.fill(pt, static_cast(m_palIdx)); } @@ -87,7 +87,7 @@ void TileSheetEditorView::releaseMouseButton() noexcept { m_model.completeSelection(); } -void TileSheetEditorView::resizeView(const ox::Vec2 &sz) noexcept { +void TileSheetEditorView::resizeView(ox::Vec2 const&sz) noexcept { m_viewSize = sz; initView(); } @@ -113,7 +113,7 @@ void TileSheetEditorView::initView() noexcept { m_pixelGridDrawer.initBufferSet(m_viewSize, *m_model.activeSubSheet()); } -ox::Point TileSheetEditorView::clickPoint(const ox::Vec2 &paneSize, const ox::Vec2 &clickPos) const noexcept { +ox::Point TileSheetEditorView::clickPoint(ox::Vec2 const&paneSize, ox::Vec2 const&clickPos) const noexcept { auto [x, y] = clickPos; const auto pixDrawSz = m_pixelsDrawer.pixelSize(paneSize); x /= paneSize.x; @@ -125,7 +125,7 @@ ox::Point TileSheetEditorView::clickPoint(const ox::Vec2 &paneSize, const ox::Ve return {static_cast(x * 2), static_cast(y * 2)}; } -ox::Error TileSheetEditorView::setActiveSubsheet(const TileSheet::SubSheetIdx&) noexcept { +ox::Error TileSheetEditorView::setActiveSubsheet(TileSheet::SubSheetIdx const&) noexcept { initView(); return {}; } diff --git a/src/nostalgia/modules/core/src/studio/tilesheeteditorview.hpp b/src/nostalgia/modules/core/src/studio/tilesheeteditorview.hpp index e5e73a3f..4de3fb6c 100644 --- a/src/nostalgia/modules/core/src/studio/tilesheeteditorview.hpp +++ b/src/nostalgia/modules/core/src/studio/tilesheeteditorview.hpp @@ -56,26 +56,26 @@ class TileSheetEditorView: public ox::SignalHandler { void draw() noexcept; - void insertTile(const ox::Vec2 &paneSize, const ox::Vec2 &clickPos) noexcept; + void insertTile(ox::Vec2 const&paneSize, ox::Vec2 const&clickPos) noexcept; - void deleteTile(const ox::Vec2 &paneSize, const ox::Vec2 &clickPos) noexcept; + void deleteTile(ox::Vec2 const&paneSize, ox::Vec2 const&clickPos) noexcept; - void clickDraw(const ox::Vec2 &paneSize, const ox::Vec2 &clickPos) noexcept; + void clickDraw(ox::Vec2 const&paneSize, ox::Vec2 const&clickPos) noexcept; - void clickSelect(const ox::Vec2 &paneSize, const ox::Vec2 &clickPos) noexcept; + void clickSelect(ox::Vec2 const&paneSize, ox::Vec2 const&clickPos) noexcept; - void clickFill(const ox::Vec2 &paneSize, const ox::Vec2 &clickPos) noexcept; + void clickFill(ox::Vec2 const&paneSize, ox::Vec2 const&clickPos) noexcept; void releaseMouseButton() noexcept; - void scrollV(const ox::Vec2 &paneSz, float wheel, bool zoomMod) noexcept; + void scrollV(ox::Vec2 const&paneSz, float wheel, bool zoomMod) noexcept; - void scrollH(const ox::Vec2 &paneSz, float wheel) noexcept; + void scrollH(ox::Vec2 const&paneSz, float wheel) noexcept; - void resizeView(const ox::Vec2 &sz) noexcept; + void resizeView(ox::Vec2 const&sz) noexcept; [[nodiscard]] - constexpr const TileSheet &img() const noexcept; + constexpr TileSheet const&img() const noexcept; [[nodiscard]] constexpr TileSheet &img() noexcept; @@ -112,13 +112,13 @@ class TileSheetEditorView: public ox::SignalHandler { private: void initView() noexcept; - ox::Point clickPoint(const ox::Vec2 &paneSize, const ox::Vec2 &clickPos) const noexcept; + ox::Point clickPoint(ox::Vec2 const&paneSize, ox::Vec2 const&clickPos) const noexcept; - ox::Error setActiveSubsheet(const TileSheet::SubSheetIdx &idx) noexcept; + ox::Error setActiveSubsheet(TileSheet::SubSheetIdx const&idx) noexcept; }; -constexpr const TileSheet &TileSheetEditorView::img() const noexcept { +constexpr TileSheet const&TileSheetEditorView::img() const noexcept { return m_model.img(); } diff --git a/src/nostalgia/modules/core/src/studio/tilesheetpixelgrid.cpp b/src/nostalgia/modules/core/src/studio/tilesheetpixelgrid.cpp index 14d81d0d..6ac504e4 100644 --- a/src/nostalgia/modules/core/src/studio/tilesheetpixelgrid.cpp +++ b/src/nostalgia/modules/core/src/studio/tilesheetpixelgrid.cpp @@ -21,7 +21,7 @@ ox::Error TileSheetGrid::buildShader() noexcept { return glutils::buildShaderProgram(pixelLineVshad, pixelLineFshad, pixelLineGshad).moveTo(&m_shader); } -void TileSheetGrid::draw(bool update, const ox::Vec2 &scroll) noexcept { +void TileSheetGrid::draw(bool update, ox::Vec2 const&scroll) noexcept { glLineWidth(3 * m_pixelSizeMod * 0.5f); glUseProgram(m_shader); glBindVertexArray(m_bufferSet.vao); @@ -35,7 +35,7 @@ void TileSheetGrid::draw(bool update, const ox::Vec2 &scroll) noexcept { glUseProgram(0); } -void TileSheetGrid::initBufferSet(const ox::Vec2 &paneSize, const TileSheet::SubSheet &subsheet) noexcept { +void TileSheetGrid::initBufferSet(ox::Vec2 const&paneSize, TileSheet::SubSheet const&subsheet) noexcept { // vao m_bufferSet.vao = glutils::generateVertexArrayObject(); glBindVertexArray(m_bufferSet.vao); @@ -64,7 +64,7 @@ void TileSheetGrid::update(ox::Vec2 const&paneSize, TileSheet::SubSheet const&su glutils::sendEbo(m_bufferSet); } -void TileSheetGrid::setBufferObject(ox::Point pt1, ox::Point pt2, Color32 c, float *vbo, const ox::Vec2 &pixSize) noexcept { +void TileSheetGrid::setBufferObject(ox::Point pt1, ox::Point pt2, Color32 c, float *vbo, ox::Vec2 const&pixSize) noexcept { const auto x1 = static_cast(pt1.x) * pixSize.x - 1.f; const auto y1 = 1.f - static_cast(pt1.y) * pixSize.y; const auto x2 = static_cast(pt2.x) * pixSize.x - 1.f; @@ -74,7 +74,7 @@ void TileSheetGrid::setBufferObject(ox::Point pt1, ox::Point pt2, Color32 c, flo memcpy(vbo, vertices.data(), sizeof(vertices)); } -void TileSheetGrid::setBufferObjects(const ox::Vec2 &paneSize, const TileSheet::SubSheet &subsheet) noexcept { +void TileSheetGrid::setBufferObjects(ox::Vec2 const&paneSize, TileSheet::SubSheet const&subsheet) noexcept { const auto pixSize = pixelSize(paneSize); const auto set = [&](std::size_t i, ox::Point pt1, ox::Point pt2, Color32 c) { const auto vbo = &m_bufferSet.vertices[i * VertexVboLength]; @@ -110,7 +110,7 @@ void TileSheetGrid::setBufferObjects(const ox::Vec2 &paneSize, const TileSheet:: } } -ox::Vec2 TileSheetGrid::pixelSize(const ox::Vec2 &paneSize) const noexcept { +ox::Vec2 TileSheetGrid::pixelSize(ox::Vec2 const&paneSize) const noexcept { const auto [sw, sh] = paneSize; constexpr float ymod = 0.35f / 10.0f; const auto xmod = ymod * sh / sw; diff --git a/src/nostalgia/modules/core/src/studio/tilesheetpixelgrid.hpp b/src/nostalgia/modules/core/src/studio/tilesheetpixelgrid.hpp index 77f0c5bf..96901d16 100644 --- a/src/nostalgia/modules/core/src/studio/tilesheetpixelgrid.hpp +++ b/src/nostalgia/modules/core/src/studio/tilesheetpixelgrid.hpp @@ -67,19 +67,19 @@ class TileSheetGrid { ox::Error buildShader() noexcept; - void draw(bool update, const ox::Vec2 &scroll) noexcept; + void draw(bool update, ox::Vec2 const&scroll) noexcept; - void initBufferSet(const ox::Vec2 &paneSize, TileSheet::SubSheet const&subsheet) noexcept; + void initBufferSet(ox::Vec2 const&paneSize, TileSheet::SubSheet const&subsheet) noexcept; void update(ox::Vec2 const&paneSize, TileSheet::SubSheet const&subsheet) noexcept; private: - static void setBufferObject(ox::Point pt1, ox::Point pt2, Color32 c, float *vbo, const ox::Vec2 &pixSize) noexcept; + static void setBufferObject(ox::Point pt1, ox::Point pt2, Color32 c, float *vbo, ox::Vec2 const&pixSize) noexcept; - void setBufferObjects(const ox::Vec2 &paneSize, const TileSheet::SubSheet &subsheet) noexcept; + void setBufferObjects(ox::Vec2 const&paneSize, TileSheet::SubSheet const&subsheet) noexcept; [[nodiscard]] - ox::Vec2 pixelSize(const ox::Vec2 &paneSize) const noexcept; + ox::Vec2 pixelSize(ox::Vec2 const&paneSize) const noexcept; }; diff --git a/src/nostalgia/modules/core/src/studio/tilesheetpixels.cpp b/src/nostalgia/modules/core/src/studio/tilesheetpixels.cpp index c0a0a9fd..00d58247 100644 --- a/src/nostalgia/modules/core/src/studio/tilesheetpixels.cpp +++ b/src/nostalgia/modules/core/src/studio/tilesheetpixels.cpp @@ -22,7 +22,7 @@ ox::Error TileSheetPixels::buildShader() noexcept { return glutils::buildShaderProgram(Vshad, Fshad).moveTo(&m_shader); } -void TileSheetPixels::draw(bool update, const ox::Vec2 &scroll) noexcept { +void TileSheetPixels::draw(bool update, ox::Vec2 const&scroll) noexcept { glUseProgram(m_shader); glBindVertexArray(m_bufferSet.vao); if (update) { @@ -57,7 +57,7 @@ void TileSheetPixels::update(ox::Vec2 const&paneSize) noexcept { glutils::sendEbo(m_bufferSet); } -ox::Vec2 TileSheetPixels::pixelSize(const ox::Vec2 &paneSize) const noexcept { +ox::Vec2 TileSheetPixels::pixelSize(ox::Vec2 const&paneSize) const noexcept { const auto [sw, sh] = paneSize; constexpr float ymod = 0.35f / 10.0f; const auto xmod = ymod * sh / sw; @@ -92,7 +92,7 @@ void TileSheetPixels::setPixelBufferObject( memcpy(ebo, elms.data(), sizeof(elms)); } -void TileSheetPixels::setBufferObjects(const ox::Vec2 &paneSize) noexcept { +void TileSheetPixels::setBufferObjects(ox::Vec2 const&paneSize) noexcept { // set buffer lengths const auto subSheet = m_model->activeSubSheet(); const auto pal = m_model->pal(); diff --git a/src/nostalgia/modules/core/src/studio/tilesheetpixels.hpp b/src/nostalgia/modules/core/src/studio/tilesheetpixels.hpp index 61a5ee13..80aa8ae5 100644 --- a/src/nostalgia/modules/core/src/studio/tilesheetpixels.hpp +++ b/src/nostalgia/modules/core/src/studio/tilesheetpixels.hpp @@ -52,19 +52,19 @@ class TileSheetPixels { ox::Error buildShader() noexcept; - void draw(bool update, const ox::Vec2 &scroll) noexcept; + void draw(bool update, ox::Vec2 const&scroll) noexcept; void initBufferSet(ox::Vec2 const&paneSize) noexcept; void update(ox::Vec2 const&paneSize) noexcept; [[nodiscard]] - ox::Vec2 pixelSize(const ox::Vec2 &paneSize) const noexcept; + ox::Vec2 pixelSize(ox::Vec2 const&paneSize) const noexcept; private: - void setPixelBufferObject(const ox::Vec2 &paneS, unsigned vertexRow, float x, float y, Color16 color, float *vbo, GLuint *ebo) const noexcept; + void setPixelBufferObject(ox::Vec2 const&paneS, unsigned vertexRow, float x, float y, Color16 color, float *vbo, GLuint *ebo) const noexcept; - void setBufferObjects(const ox::Vec2 &paneS) noexcept; + void setBufferObjects(ox::Vec2 const&paneS) noexcept; }; diff --git a/src/nostalgia/modules/core/src/tilesheet.cpp b/src/nostalgia/modules/core/src/tilesheet.cpp index c40a8267..98b1f782 100644 --- a/src/nostalgia/modules/core/src/tilesheet.cpp +++ b/src/nostalgia/modules/core/src/tilesheet.cpp @@ -57,7 +57,7 @@ TileSheet::SubSheet &TileSheet::SubSheet::operator=(TileSheet::SubSheet &&other) return *this; } -std::size_t TileSheet::SubSheet::idx(const ox::Point &pt) const noexcept { +std::size_t TileSheet::SubSheet::idx(ox::Point const&pt) const noexcept { return ptToIdx(pt, columns); } @@ -120,17 +120,17 @@ uint8_t TileSheet::SubSheet::getPixel(int8_t pBpp, std::size_t idx) const noexce } } -uint8_t TileSheet::SubSheet::getPixel4Bpp(const ox::Point &pt) const noexcept { +uint8_t TileSheet::SubSheet::getPixel4Bpp(ox::Point const&pt) const noexcept { const auto idx = ptToIdx(pt, columns); return getPixel4Bpp(idx); } -uint8_t TileSheet::SubSheet::getPixel8Bpp(const ox::Point &pt) const noexcept { +uint8_t TileSheet::SubSheet::getPixel8Bpp(ox::Point const&pt) const noexcept { const auto idx = ptToIdx(pt, columns); return getPixel8Bpp(idx); } -uint8_t TileSheet::SubSheet::getPixel(int8_t pBpp, const ox::Point &pt) const noexcept { +uint8_t TileSheet::SubSheet::getPixel(int8_t pBpp, ox::Point const&pt) const noexcept { const auto idx = ptToIdx(pt, columns); return getPixel(pBpp, idx); } @@ -148,7 +148,7 @@ void TileSheet::SubSheet::setPixel(int8_t pBpp, uint64_t idx, uint8_t palIdx) no } } -void TileSheet::SubSheet::setPixel(int8_t pBpp, const ox::Point &pt, uint8_t palIdx) noexcept { +void TileSheet::SubSheet::setPixel(int8_t pBpp, ox::Point const&pt, uint8_t palIdx) noexcept { const auto idx = ptToIdx(pt, columns); setPixel(pBpp, idx, palIdx); } @@ -222,7 +222,7 @@ ox::Result TileSheet::SubSheet::getNameFor(SubSheetId pId) const } -TileSheet &TileSheet::operator=(const TileSheet &other) noexcept { +TileSheet &TileSheet::operator=(TileSheet const&other) noexcept { if (this != &other) { bpp = other.bpp; idIt = other.idIt; @@ -265,9 +265,9 @@ TileSheet::SubSheetIdx TileSheet::validateSubSheetIdx(const SubSheetIdx &idx) no } const TileSheet::SubSheet &TileSheet::getSubSheet( - const TileSheet::SubSheetIdx &idx, + TileSheet::SubSheetIdx const&idx, std::size_t idxIt, - const SubSheet *pSubsheet) noexcept { + SubSheet const*pSubsheet) noexcept { if (idxIt == idx.size()) { return *pSubsheet; } @@ -279,7 +279,7 @@ const TileSheet::SubSheet &TileSheet::getSubSheet( } TileSheet::SubSheet &TileSheet::getSubSheet( - const TileSheet::SubSheetIdx &idx, + TileSheet::SubSheetIdx const&idx, std::size_t idxIt, TileSheet::SubSheet *pSubsheet) noexcept { if (idxIt == idx.size()) { @@ -288,15 +288,15 @@ TileSheet::SubSheet &TileSheet::getSubSheet( return getSubSheet(idx, idxIt + 1, &pSubsheet->subsheets[idx[idxIt]]); } -const TileSheet::SubSheet &TileSheet::getSubSheet(const TileSheet::SubSheetIdx &idx) const noexcept { +const TileSheet::SubSheet &TileSheet::getSubSheet(TileSheet::SubSheetIdx const&idx) const noexcept { return getSubSheet(idx, 0, &subsheet); } -TileSheet::SubSheet &TileSheet::getSubSheet(const TileSheet::SubSheetIdx &idx) noexcept { +TileSheet::SubSheet &TileSheet::getSubSheet(TileSheet::SubSheetIdx const&idx) noexcept { return getSubSheet(idx, 0, &subsheet); } -ox::Error TileSheet::addSubSheet(const TileSheet::SubSheetIdx &idx) noexcept { +ox::Error TileSheet::addSubSheet(TileSheet::SubSheetIdx const&idx) noexcept { auto &parent = getSubSheet(idx); if (parent.subsheets.size() < 2) { parent.subsheets.emplace_back(idIt++, ox::sfmt("Subsheet {}", parent.subsheets.size()), 1, 1, bpp); @@ -308,7 +308,7 @@ ox::Error TileSheet::addSubSheet(const TileSheet::SubSheetIdx &idx) noexcept { } ox::Error TileSheet::rmSubSheet( - const SubSheetIdx &idx, + SubSheetIdx const&idx, std::size_t idxIt, SubSheet *pSubsheet) noexcept { if (idxIt == idx.size() - 1) { @@ -317,13 +317,13 @@ ox::Error TileSheet::rmSubSheet( return rmSubSheet(idx, idxIt + 1, &pSubsheet->subsheets[idx[idxIt]]); } -ox::Error TileSheet::rmSubSheet(const TileSheet::SubSheetIdx &idx) noexcept { +ox::Error TileSheet::rmSubSheet(TileSheet::SubSheetIdx const&idx) noexcept { return rmSubSheet(idx, 0, &subsheet); } uint8_t TileSheet::getPixel4Bpp( - const ox::Point &pt, - const TileSheet::SubSheetIdx &subsheetIdx) const noexcept { + ox::Point const&pt, + TileSheet::SubSheetIdx const&subsheetIdx) const noexcept { oxAssert(bpp == 4, "TileSheet::getPixel4Bpp: wrong bpp"); auto &s = this->getSubSheet(subsheetIdx); const auto idx = ptToIdx(pt, s.columns); @@ -331,8 +331,8 @@ uint8_t TileSheet::getPixel4Bpp( } uint8_t TileSheet::getPixel8Bpp( - const ox::Point &pt, - const TileSheet::SubSheetIdx &subsheetIdx) const noexcept { + ox::Point const&pt, + TileSheet::SubSheetIdx const&subsheetIdx) const noexcept { oxAssert(bpp == 8, "TileSheet::getPixel8Bpp: wrong bpp"); auto &s = this->getSubSheet(subsheetIdx); const auto idx = ptToIdx(pt, s.columns);