diff --git a/src/nostalgia/modules/core/src/studio/paletteeditor-imgui.cpp b/src/nostalgia/modules/core/src/studio/paletteeditor-imgui.cpp index 893986f9..3e68fd9b 100644 --- a/src/nostalgia/modules/core/src/studio/paletteeditor-imgui.cpp +++ b/src/nostalgia/modules/core/src/studio/paletteeditor-imgui.cpp @@ -15,7 +15,7 @@ namespace nostalgia::core { -PaletteEditorImGui::PaletteEditorImGui(turbine::Context &ctx, ox::String path): +PaletteEditorImGui::PaletteEditorImGui(turbine::Context &ctx, ox::CRStringView path): m_ctx(ctx), m_itemPath(std::move(path)), m_itemName(m_itemPath.substr(std::find(m_itemPath.rbegin(), m_itemPath.rend(), '/').offset() + 1)), diff --git a/src/nostalgia/modules/core/src/studio/paletteeditor-imgui.hpp b/src/nostalgia/modules/core/src/studio/paletteeditor-imgui.hpp index 0f03c1c6..03ea77b7 100644 --- a/src/nostalgia/modules/core/src/studio/paletteeditor-imgui.hpp +++ b/src/nostalgia/modules/core/src/studio/paletteeditor-imgui.hpp @@ -21,7 +21,7 @@ class PaletteEditorImGui: public studio::Editor { std::size_t m_selectedRow = 0; public: - PaletteEditorImGui(turbine::Context &ctx, ox::String path); + PaletteEditorImGui(turbine::Context &ctx, ox::CRStringView path); /** * Returns the name of item being edited. diff --git a/src/nostalgia/modules/core/src/studio/tilesheeteditor-imgui.cpp b/src/nostalgia/modules/core/src/studio/tilesheeteditor-imgui.cpp index f0281438..450023b3 100644 --- a/src/nostalgia/modules/core/src/studio/tilesheeteditor-imgui.cpp +++ b/src/nostalgia/modules/core/src/studio/tilesheeteditor-imgui.cpp @@ -13,7 +13,7 @@ namespace nostalgia::core { template -ox::Error toPngFile(const ox::String &path, const TileSheet::SubSheet &s, const Palette &pal, int8_t bpp) noexcept { +ox::Error toPngFile(ox::CStringView const&path, TileSheet::SubSheet const&s, Palette const&pal, int8_t bpp) noexcept { ox::Vector pixels; s.readPixelsTo(&pixels, bpp); const unsigned rows = s.rows == -1 ? static_cast(pixels.size()) / PixelsPerTile : static_cast(s.rows); @@ -38,9 +38,9 @@ ox::Error toPngFile(const ox::String &path, const TileSheet::SubSheet &s, const return OxError(static_cast(lodepng_encode_file(path.c_str(), outData.data(), width, height, fmt, 8))); } -TileSheetEditorImGui::TileSheetEditorImGui(turbine::Context &ctx, ox::String path): +TileSheetEditorImGui::TileSheetEditorImGui(turbine::Context &ctx, ox::CRStringView path): m_ctx(ctx), - m_itemPath(std::move(path)), + m_itemPath(path), m_tileSheetEditor(m_ctx, m_itemPath) { const auto lastSlash = ox::find(m_itemPath.rbegin(), m_itemPath.rend(), '/').offset(); m_itemName = m_itemPath.substr(lastSlash + 1); @@ -242,7 +242,7 @@ studio::UndoStack *TileSheetEditorImGui::undoStack() noexcept { } [[nodiscard]] -ox::Vec2 TileSheetEditorImGui::clickPos(const ImVec2 &winPos, ox::Vec2 clickPos) noexcept { +ox::Vec2 TileSheetEditorImGui::clickPos(ImVec2 const&winPos, ox::Vec2 clickPos) noexcept { clickPos.x -= winPos.x + 10; clickPos.y -= winPos.y + 10; return clickPos; @@ -276,7 +276,7 @@ void TileSheetEditorImGui::exportSubhseetToPng() noexcept { } } -void TileSheetEditorImGui::drawTileSheet(const ox::Vec2 &fbSize) noexcept { +void TileSheetEditorImGui::drawTileSheet(ox::Vec2 const&fbSize) noexcept { const auto winPos = ImGui::GetWindowPos(); const auto fbSizei = ox::Size(static_cast(fbSize.x), static_cast(fbSize.y)); if (m_framebuffer.width != fbSizei.width || m_framebuffer.height != fbSizei.height) { @@ -394,7 +394,7 @@ void TileSheetEditorImGui::drawPaletteSelector() noexcept { } } -ox::Error TileSheetEditorImGui::updateActiveSubsheet(const ox::StringView &name, int cols, int rows) noexcept { +ox::Error TileSheetEditorImGui::updateActiveSubsheet(ox::StringView const&name, int cols, int rows) noexcept { return model()->updateSubsheet(model()->activeSubSheetIdx(), name, cols, rows); } diff --git a/src/nostalgia/modules/core/src/studio/tilesheeteditor-imgui.hpp b/src/nostalgia/modules/core/src/studio/tilesheeteditor-imgui.hpp index 9fbde86b..4d490f66 100644 --- a/src/nostalgia/modules/core/src/studio/tilesheeteditor-imgui.hpp +++ b/src/nostalgia/modules/core/src/studio/tilesheeteditor-imgui.hpp @@ -32,10 +32,10 @@ class TileSheetEditorImGui: public studio::BaseEditor { int m_rows = 0; bool m_show = false; public: - ox::Signal inputSubmitted; - constexpr void show(const ox::String &name, int cols, int rows) noexcept { + ox::Signal inputSubmitted; + constexpr void show(ox::StringView const&name, int cols, int rows) noexcept { m_show = true; - m_name = name.c_str(); + m_name = name; m_cols = cols; m_rows = rows; } @@ -55,7 +55,7 @@ class TileSheetEditorImGui: public studio::BaseEditor { Tool m_tool = Tool::Draw; public: - TileSheetEditorImGui(turbine::Context &ctx, ox::String path); + TileSheetEditorImGui(turbine::Context &ctx, ox::CRStringView path); ~TileSheetEditorImGui() override = default; @@ -80,7 +80,7 @@ class TileSheetEditorImGui: public studio::BaseEditor { studio::UndoStack *undoStack() noexcept final; [[nodiscard]] - static ox::Vec2 clickPos(const ImVec2 &winPos, ox::Vec2 clickPos) noexcept; + static ox::Vec2 clickPos(ImVec2 const&winPos, ox::Vec2 clickPos) noexcept; protected: ox::Error saveItem() noexcept override; @@ -100,28 +100,14 @@ class TileSheetEditorImGui: public studio::BaseEditor { return m_tileSheetEditor.model(); } - void setPalette(); - - void saveState(); - - void restoreState(); - - [[nodiscard]] - ox::String paletteName(const ox::String &palettePath) const; - - [[nodiscard]] - ox::String palettePath(const ox::String &palettePath) const; - - void drawTileSheet(const ox::Vec2 &fbSize) noexcept; + void drawTileSheet(ox::Vec2 const&fbSize) noexcept; void drawPaletteSelector() noexcept; - ox::Error updateActiveSubsheet(const ox::StringView &name, int cols, int rows) noexcept; + ox::Error updateActiveSubsheet(ox::StringView const&name, int cols, int rows) noexcept; // slots private: - ox::Error updateAfterClicked() noexcept; - ox::Error markUnsavedChanges(const studio::UndoCommand*) noexcept; }; diff --git a/src/nostalgia/modules/scene/src/studio/studiomodule.cpp b/src/nostalgia/modules/scene/src/studio/studiomodule.cpp index ee69c9f2..773a1e4d 100644 --- a/src/nostalgia/modules/scene/src/studio/studiomodule.cpp +++ b/src/nostalgia/modules/scene/src/studio/studiomodule.cpp @@ -8,23 +8,22 @@ namespace nostalgia::scene { +constexpr ox::StringLiteral FileExt_nscn("nscn"); + class StudioModule: public studio::Module { public: - ox::Vector editors(turbine::Context &ctx) const noexcept override; - ox::Vector> itemMakers(turbine::Context&) const noexcept override; + ox::Vector editors(turbine::Context &ctx) const noexcept override { + return { + studio::editorMaker(ctx, FileExt_nscn), + }; + } + ox::Vector> itemMakers(turbine::Context&) const noexcept override { + ox::Vector> out; + out.emplace_back(ox::make>("Scene", "Scenes", FileExt_nscn)); + return out; + } }; -ox::Vector StudioModule::editors(turbine::Context &ctx) const noexcept { - return { - studio::editorMaker(ctx, "nscn"), - }; -} - -ox::Vector> StudioModule::itemMakers(turbine::Context&) const noexcept { - ox::Vector> out; - return out; -} - static StudioModule mod; const studio::Module *studioModule() noexcept { return &mod; diff --git a/src/studio/modlib/include/studio/module.hpp b/src/studio/modlib/include/studio/module.hpp index 2359cb26..9766d3b5 100644 --- a/src/studio/modlib/include/studio/module.hpp +++ b/src/studio/modlib/include/studio/module.hpp @@ -39,18 +39,7 @@ studio::EditorMaker editorMaker(turbine::Context &ctx, ox::CRStringView ext) noe return { {ox::String(ext)}, [&ctx](ox::CRStringView path) -> ox::Result { - return ox::makeCatch(ctx, ox::String(path)); - } - }; -} - -template -[[nodiscard]] -studio::EditorMaker editorMaker(turbine::Context *ctx, ox::Vector exts) noexcept { - return { - std::move(exts), - [ctx](ox::CRStringView path) -> ox::Result { - return ox::makeCatch(ctx, ox::String(path)); + return ox::makeCatch(ctx, path); } }; } diff --git a/src/studio/modlib/include/studio/project.hpp b/src/studio/modlib/include/studio/project.hpp index a0b302f7..1a21b545 100644 --- a/src/studio/modlib/include/studio/project.hpp +++ b/src/studio/modlib/include/studio/project.hpp @@ -106,7 +106,6 @@ class Project { template ox::Error Project::writeObj(ox::CRStringView path, T const&obj, ox::ClawFormat fmt) noexcept { - // write MetalClaw oxRequireM(buff, ox::writeClaw(obj, fmt)); // write to FS oxReturnError(writeBuff(path, buff)); @@ -117,7 +116,7 @@ ox::Error Project::writeObj(ox::CRStringView path, T const&obj, ox::ClawFormat f // write out type store const auto descPath = ox::sfmt("/{}/type_descriptors", m_projectDataDir); oxReturnError(mkdir(descPath)); - for (const auto &t : m_typeStore.typeList()) { + for (auto const&t : m_typeStore.typeList()) { oxRequireM(typeOut, ox::writeClaw(*t, ox::ClawFormat::Organic)); // replace garbage last character with new line *typeOut.back().value = '\n';