From b0726568df6aaa37390906ca44ff1eee11735f98 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sun, 29 Jun 2025 17:33:27 -0500 Subject: [PATCH] Squashed 'deps/nostalgia/' changes from f847289b..671b8eda 671b8eda [ox/std] Make StringLiteral constructors consteval 952637a1 Merge commit 'cbf4414fcaf00c00a2abf73b5c04a055180ad980' 7569698e [nostalgia,studio] Add FileExts_TileSheet const, and corresponding FilePickerPopup constructor 21713ba9 [ox/std] Fix StringLiteral::operator= to work with DevkitARM 73273b6f [nostalgia/gfx] Add isTileSheet function for checking paths against both file extensions 9f040392 [olympic,nostalgia] Cleanup style f4f7e5d0 Merge commit '9b5f7886cadc5c3dc826d00fa5b2e71696151dfd' c27726a4 Merge commit '6bbcae10cc7b21b73171ec0ff196f4baf6304404' bd24a775 Merge commit '7371df429534f264c179684412f6197f7968ebfa' 4419dff2 Merge commit '7688c05bac8c20bc267cae62ec78d55e5d0c493b' 536999c0 Merge commit '47eee1d56d591e3631d16e95a78ea3629ee312ee' a5535ef5 Merge commit '08236fc790e711afe886b6ef545511d35e4e5c6c' a90380f3 Merge commit 'e90dd887477452922f783535edb3d4c55e9a0d2c' 2000b2de [nostalgia/gfx/studio] Cleanup 7d92400f [nostalgia/gfx/studio] Add type specific navigateTo functions git-subtree-dir: deps/nostalgia git-subtree-split: 671b8edaadefe1872fb8954ad13d221b24f676c0 --- deps/ox/src/ox/std/stringliteral.hpp | 23 +++++++----------- .../gfx/include/nostalgia/gfx/consts.hpp | 16 ++++++++++--- .../modules/gfx/include/nostalgia/gfx/gfx.hpp | 4 ++-- .../gfx/include/nostalgia/gfx/studio.hpp | 24 ++++++++++++++++++- src/nostalgia/modules/gfx/src/gfx.cpp | 4 ++-- .../tilesheeteditor/tilesheeteditor-imgui.cpp | 6 +++-- src/olympic/studio/applib/src/clawviewer.cpp | 10 ++++---- src/olympic/studio/applib/src/clawviewer.hpp | 6 ++--- .../studio/applib/src/popups/newmenu.cpp | 14 +++++------ .../studio/applib/src/popups/newmenu.hpp | 2 +- .../studio/applib/src/popups/newproject.hpp | 2 +- .../studio/modlib/include/studio/editor.hpp | 4 ++-- .../modlib/include/studio/filedialog.hpp | 2 +- .../modlib/include/studio/filepickerpopup.hpp | 2 ++ .../modlib/include/studio/filetreemodel.hpp | 8 +++---- .../modlib/include/studio/itemmaker.hpp | 16 ++++++------- .../studio/modlib/include/studio/popup.hpp | 4 ++-- .../studio/modlib/include/studio/project.hpp | 20 ++++++++-------- .../include/studio/selectiontracker.hpp | 8 +++---- .../modlib/include/studio/undocommand.hpp | 2 +- .../studio/modlib/src/filedialog_nfd.cpp | 6 ++--- .../studio/modlib/src/filepickerpopup.cpp | 16 +++++++++++++ .../studio/modlib/src/filetreemodel.cpp | 12 +++++----- src/olympic/studio/modlib/src/popup.cpp | 4 ++-- src/olympic/studio/modlib/src/project.cpp | 12 +++++----- .../turbine/include/turbine/clipboard.hpp | 2 +- .../turbine/include/turbine/context.hpp | 8 +++---- src/olympic/turbine/include/turbine/gfx.hpp | 2 +- .../turbine/include/turbine/turbine.hpp | 4 ++-- src/olympic/turbine/src/gba/clipboard.cpp | 2 +- src/olympic/turbine/src/gba/context.cpp | 6 ++--- src/olympic/turbine/src/gba/context.hpp | 4 ++-- src/olympic/turbine/src/glfw/clipboard.cpp | 2 +- src/olympic/turbine/src/glfw/context.cpp | 6 ++--- src/olympic/turbine/src/glfw/context.hpp | 4 ++-- src/olympic/turbine/src/glfw/turbine.cpp | 6 ++--- 36 files changed, 159 insertions(+), 114 deletions(-) diff --git a/deps/ox/src/ox/std/stringliteral.hpp b/deps/ox/src/ox/std/stringliteral.hpp index a498075..ec5d463 100644 --- a/deps/ox/src/ox/std/stringliteral.hpp +++ b/deps/ox/src/ox/std/stringliteral.hpp @@ -16,35 +16,28 @@ namespace ox { * StringLiteral is used for functions that want to ensure that they are taking * string literals, and not strings outside of the data section of the program * that might get deleted. - * This type cannot force you to use it correctly, so don't give it something - * that is not a literal. - * If you do this: - * StringLiteral(str.c_str()) - * the resulting segfault is on you. */ class StringLiteral: public detail::BaseStringView { public: - constexpr StringLiteral() noexcept = default; + consteval StringLiteral() noexcept = default; - constexpr StringLiteral(StringLiteral const&sv) noexcept = default; + constexpr StringLiteral(StringLiteral const &sv) noexcept = default; - constexpr explicit StringLiteral(std::nullptr_t) noexcept {} + consteval explicit StringLiteral(std::nullptr_t) noexcept {} - constexpr explicit StringLiteral(const char *str, std::size_t len) noexcept: BaseStringView(str, len) {} + consteval explicit StringLiteral(char const *str, std::size_t const len) noexcept: BaseStringView{str, len} {} OX_ALLOW_UNSAFE_BUFFERS_BEGIN - constexpr explicit StringLiteral(char const *str) noexcept: StringLiteral(str, ox::strlen(str)) {} + consteval explicit StringLiteral(char const *str) noexcept: StringLiteral{str, ox::strlen(str)} {} OX_ALLOW_UNSAFE_BUFFERS_END - constexpr StringLiteral &operator=(StringLiteral const&other) noexcept { - if (&other != this) { - set(other.data(), other.len()); - } + constexpr StringLiteral &operator=(StringLiteral const &other) noexcept { + set(other.data(), other.len()); return *this; } [[nodiscard]] - constexpr const char *c_str() const noexcept { + constexpr char const *c_str() const noexcept { return data(); } diff --git a/src/nostalgia/modules/gfx/include/nostalgia/gfx/consts.hpp b/src/nostalgia/modules/gfx/include/nostalgia/gfx/consts.hpp index 95799f7..887c7cc 100644 --- a/src/nostalgia/modules/gfx/include/nostalgia/gfx/consts.hpp +++ b/src/nostalgia/modules/gfx/include/nostalgia/gfx/consts.hpp @@ -12,8 +12,18 @@ constexpr auto TileWidth = 8; constexpr auto TileHeight = 8; constexpr auto PixelsPerTile = TileWidth * TileHeight; -constexpr ox::StringLiteral FileExt_ng("ng"); -constexpr ox::StringLiteral FileExt_nts("nts"); -constexpr ox::StringLiteral FileExt_npal("npal"); +constexpr ox::StringLiteral FileExt_ng{"ng"}; +constexpr ox::StringLiteral FileExt_nts{"nts"}; +constexpr ox::StringLiteral FileExt_npal{"npal"}; + +constexpr ox::Array FileExts_TileSheet{ + FileExt_nts, + FileExt_ng, +}; + +[[nodiscard]] +constexpr bool isTileSheet(ox::StringViewCR path) noexcept { + return endsWith(path, FileExt_nts) || endsWith(path, FileExt_ng); +} } diff --git a/src/nostalgia/modules/gfx/include/nostalgia/gfx/gfx.hpp b/src/nostalgia/modules/gfx/include/nostalgia/gfx/gfx.hpp index e80d3ba..978c0a9 100644 --- a/src/nostalgia/modules/gfx/include/nostalgia/gfx/gfx.hpp +++ b/src/nostalgia/modules/gfx/include/nostalgia/gfx/gfx.hpp @@ -114,10 +114,10 @@ struct InitParams { ox::Result> init(turbine::Context &tctx, InitParams const ¶ms = {}) noexcept; [[nodiscard]] -int tileColumns(Context&) noexcept; +int tileColumns(Context const&) noexcept; [[nodiscard]] -int tileRows(Context&) noexcept; +int tileRows(Context const&) noexcept; ox::Error loadBgPalette( Context &ctx, diff --git a/src/nostalgia/modules/gfx/include/nostalgia/gfx/studio.hpp b/src/nostalgia/modules/gfx/include/nostalgia/gfx/studio.hpp index 0e6ad2c..95e3062 100644 --- a/src/nostalgia/modules/gfx/include/nostalgia/gfx/studio.hpp +++ b/src/nostalgia/modules/gfx/include/nostalgia/gfx/studio.hpp @@ -6,6 +6,28 @@ #include -namespace nostalgia::core { +#include "tilesheet.hpp" + +namespace nostalgia::gfx { + +inline void navigateToTileSheet( + studio::Context &ctx, ox::StringParam path, SubSheetId const subsheetId) noexcept { + studio::navigateTo(ctx, std::move(path), ox::intToStr(subsheetId)); +} + +inline void navigateToPalette(studio::Context &ctx, ox::StringParam path) noexcept { + studio::navigateTo(ctx, std::move(path)); +} + +inline void navigateToPalette( + studio::Context &ctx, + ox::StringParam path, + size_t const colorIdx, + size_t const palPage) noexcept { + studio::navigateTo( + ctx, + std::move(path), + ox::sfmt("{};{}", colorIdx, palPage)); +} } diff --git a/src/nostalgia/modules/gfx/src/gfx.cpp b/src/nostalgia/modules/gfx/src/gfx.cpp index ac429b7..e52ac87 100644 --- a/src/nostalgia/modules/gfx/src/gfx.cpp +++ b/src/nostalgia/modules/gfx/src/gfx.cpp @@ -10,11 +10,11 @@ namespace nostalgia::gfx { constexpr auto GbaTileColumns = 32; constexpr auto GbaTileRows = 32; -int tileColumns(Context&) noexcept { +int tileColumns(Context const&) noexcept { return GbaTileColumns; } -int tileRows(Context&) noexcept { +int tileRows(Context const&) noexcept { return GbaTileRows; } diff --git a/src/nostalgia/modules/gfx/src/studio/tilesheeteditor/tilesheeteditor-imgui.cpp b/src/nostalgia/modules/gfx/src/studio/tilesheeteditor/tilesheeteditor-imgui.cpp index db2e248..6640c1e 100644 --- a/src/nostalgia/modules/gfx/src/studio/tilesheeteditor/tilesheeteditor-imgui.cpp +++ b/src/nostalgia/modules/gfx/src/studio/tilesheeteditor/tilesheeteditor-imgui.cpp @@ -9,6 +9,8 @@ #include #include +#include + #include "tilesheeteditor-imgui.hpp" namespace nostalgia::gfx { @@ -576,10 +578,10 @@ void TileSheetEditorImGui::drawPaletteMenu() noexcept { m_view.setPalIdx(i); } if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(0)) { - studio::navigateTo( + navigateToPalette( m_sctx, m_model.palPath(), - ox::sfmt("{};{}", i, m_model.palettePage())); + i, m_model.palettePage()); } // Column: color RGB ImGui::TableNextColumn(); diff --git a/src/olympic/studio/applib/src/clawviewer.cpp b/src/olympic/studio/applib/src/clawviewer.cpp index 5689ff2..0bb859e 100644 --- a/src/olympic/studio/applib/src/clawviewer.cpp +++ b/src/olympic/studio/applib/src/clawviewer.cpp @@ -28,7 +28,7 @@ void ClawEditor::draw(Context&) noexcept { ImGui::EndChild(); } -void ClawEditor::drawRow(ox::ModelValue const&value) noexcept { +void ClawEditor::drawRow(ox::ModelValue const &value) noexcept { using Str = ox::BasicString<100>; Str val, type; switch (value.type()) { @@ -93,13 +93,13 @@ void ClawEditor::drawRow(ox::ModelValue const&value) noexcept { ImGui::Text("%s", val.c_str()); } -void ClawEditor::drawVar(ObjPath &path, ox::StringViewCR name, ox::ModelValue const&value) noexcept { +void ClawEditor::drawVar(ObjPath &path, ox::StringViewCR name, ox::ModelValue const &value) noexcept { using Str = ox::BasicString<100>; path.push_back(name); if (value.type() == ox::ModelValue::Type::Object) { drawTree(path, value.get()); } else if (value.type() == ox::ModelValue::Type::Vector) { - auto const&vec = value.get(); + auto const &vec = value.get(); auto const pathStr = ox::join("##", path).unwrap(); auto const lbl = ox::sfmt("{}##{}", name, pathStr); auto const flags = ImGuiTreeNodeFlags_SpanFullWidth @@ -110,7 +110,7 @@ void ClawEditor::drawVar(ObjPath &path, ox::StringViewCR name, ox::ModelValue co ImGui::SameLine(); drawRow(value); if (open) { - for (auto i = 0lu; auto const&e: vec) { + for (auto i = 0lu; auto const &e: vec) { auto const iStr = ox::sfmt("{}", i); path.push_back(iStr); ImGui::TableNextRow(0, 5); @@ -138,7 +138,7 @@ void ClawEditor::drawVar(ObjPath &path, ox::StringViewCR name, ox::ModelValue co path.pop_back(); } -void ClawEditor::drawTree(ObjPath &path, ox::ModelObject const&obj) noexcept { +void ClawEditor::drawTree(ObjPath &path, ox::ModelObject const &obj) noexcept { using Str = ox::BasicString<100>; for (auto const &c : obj) { ImGui::TableNextRow(0, 5); diff --git a/src/olympic/studio/applib/src/clawviewer.hpp b/src/olympic/studio/applib/src/clawviewer.hpp index 19d0a16..7bbd92e 100644 --- a/src/olympic/studio/applib/src/clawviewer.hpp +++ b/src/olympic/studio/applib/src/clawviewer.hpp @@ -21,11 +21,11 @@ class ClawEditor: public Editor { void draw(Context&) noexcept final; private: - static void drawRow(ox::ModelValue const&value) noexcept; + static void drawRow(ox::ModelValue const &value) noexcept; - void drawVar(ObjPath &path, ox::StringViewCR name, ox::ModelValue const&value) noexcept; + void drawVar(ObjPath &path, ox::StringViewCR name, ox::ModelValue const &value) noexcept; - void drawTree(ObjPath &path, ox::ModelObject const&obj) noexcept; + void drawTree(ObjPath &path, ox::ModelObject const &obj) noexcept; }; } diff --git a/src/olympic/studio/applib/src/popups/newmenu.cpp b/src/olympic/studio/applib/src/popups/newmenu.cpp index e0b42a2..ded8fd7 100644 --- a/src/olympic/studio/applib/src/popups/newmenu.cpp +++ b/src/olympic/studio/applib/src/popups/newmenu.cpp @@ -24,7 +24,7 @@ void NewMenu::open() noexcept { m_useDefaultPath = true; m_explorer.setModel(buildFileTreeModel( m_explorer, - [](ox::StringViewCR, ox::FileStat const&s) { + [](ox::StringViewCR, ox::FileStat const &s) { return s.fileType == ox::FileType::Directory; }).or_value(ox::UPtr{})); } @@ -75,26 +75,26 @@ void NewMenu::addItemMaker(ox::UPtr &&im) noexcept { m_types.emplace_back(std::move(im)); std::sort( m_types.begin(), m_types.end(), - [](ox::UPtr const&im1, ox::UPtr const&im2) { + [](ox::UPtr const &im1, ox::UPtr const &im2) { return im1->typeDisplayName() < im2->typeDisplayName(); }); } void NewMenu::installItemTemplate(ox::UPtr &&tmplt) noexcept { - for (auto const&im : m_types) { + for (auto const &im : m_types) { if (im->installTemplate(std::move(tmplt))) { break; } } } -void NewMenu::drawNewItemType(Context const&sctx) noexcept { +void NewMenu::drawNewItemType(Context const &sctx) noexcept { setSize({280, 180}); drawWindow(sctx.tctx, m_open, [this] { ig::ListBox("Item Type", [&](size_t const i) -> ox::CStringView { return m_types[i]->typeDisplayName(); }, m_types.size(), m_selectedType, {200, 100}); - auto const&im = *m_types[m_selectedType]; + auto const &im = *m_types[m_selectedType]; drawFirstPageButtons(im.itemTemplates().size() == 1 ? Stage::NewItemTransitioningToPath : Stage::NewItemTemplate); if (m_stage == Stage::NewItemTransitioningToPath || m_stage == Stage::NewItemTemplate) { @@ -105,10 +105,10 @@ void NewMenu::drawNewItemType(Context const&sctx) noexcept { }); } -void NewMenu::drawNewItemTemplate(Context const&sctx) noexcept { +void NewMenu::drawNewItemTemplate(Context const &sctx) noexcept { setSize({280, 180}); drawWindow(sctx.tctx, m_open, [this] { - auto const&templates = + auto const &templates = m_types[m_selectedType]->itemTemplates(); ig::ListBox("Template", [&](size_t const i) -> ox::CStringView { return templates[i]->name(); diff --git a/src/olympic/studio/applib/src/popups/newmenu.hpp b/src/olympic/studio/applib/src/popups/newmenu.hpp index 1299151..0128c40 100644 --- a/src/olympic/studio/applib/src/popups/newmenu.hpp +++ b/src/olympic/studio/applib/src/popups/newmenu.hpp @@ -75,7 +75,7 @@ class NewMenu final: public Popup { void installItemTemplate(ox::UPtr &&tmplt) noexcept; private: - void drawNewItemType(Context const&sctx) noexcept; + void drawNewItemType(Context const &sctx) noexcept; void drawNewItemPath(Context &sctx) noexcept; diff --git a/src/olympic/studio/applib/src/popups/newproject.hpp b/src/olympic/studio/applib/src/popups/newproject.hpp index ee80249..317ef05 100644 --- a/src/olympic/studio/applib/src/popups/newproject.hpp +++ b/src/olympic/studio/applib/src/popups/newproject.hpp @@ -13,7 +13,7 @@ namespace studio { -class NewProject: public studio::Popup { +class NewProject: public Popup { public: enum class Stage { Closed, diff --git a/src/olympic/studio/modlib/include/studio/editor.hpp b/src/olympic/studio/modlib/include/studio/editor.hpp index 341fa2f..81610e9 100644 --- a/src/olympic/studio/modlib/include/studio/editor.hpp +++ b/src/olympic/studio/modlib/include/studio/editor.hpp @@ -140,7 +140,7 @@ class Editor: public studio::BaseEditor { ox::Error pushCommand(Args&&... args) noexcept { try { return m_undoStack.push(ox::make_unique(ox::forward(args)...)); - } catch (ox::Exception const&ex) { + } catch (ox::Exception const &ex) { return ex.toError(); } } @@ -148,7 +148,7 @@ class Editor: public studio::BaseEditor { private: ox::Error markUnsavedChanges(UndoCommand const*) noexcept; - ox::Error handleRename(ox::StringViewCR oldPath, ox::StringViewCR newPath, ox::UUID const&id) noexcept; + ox::Error handleRename(ox::StringViewCR oldPath, ox::StringViewCR newPath, ox::UUID const &id) noexcept; }; diff --git a/src/olympic/studio/modlib/include/studio/filedialog.hpp b/src/olympic/studio/modlib/include/studio/filedialog.hpp index c1a491f..6ca1f2b 100644 --- a/src/olympic/studio/modlib/include/studio/filedialog.hpp +++ b/src/olympic/studio/modlib/include/studio/filedialog.hpp @@ -21,7 +21,7 @@ struct FDFilterItem { FDFilterItem(ox::StringViewCR pName, ox::StringViewCR pSpec) noexcept; }; -ox::Result saveFile(ox::Vector const&exts) noexcept; +ox::Result saveFile(ox::Vector const &exts) noexcept; ox::Result chooseDirectory() noexcept; diff --git a/src/olympic/studio/modlib/include/studio/filepickerpopup.hpp b/src/olympic/studio/modlib/include/studio/filepickerpopup.hpp index acbebce..4829738 100644 --- a/src/olympic/studio/modlib/include/studio/filepickerpopup.hpp +++ b/src/olympic/studio/modlib/include/studio/filepickerpopup.hpp @@ -24,6 +24,8 @@ class FilePickerPopup { public: explicit FilePickerPopup(ox::StringParam name, keel::Context &kctx, ox::StringParam fileExt) noexcept; + explicit FilePickerPopup(ox::StringParam name, keel::Context &kctx, ox::SpanView fileExts) noexcept; + explicit FilePickerPopup(ox::StringParam name, keel::Context &kctx, ox::Vector fileExts) noexcept; void refresh() noexcept; diff --git a/src/olympic/studio/modlib/include/studio/filetreemodel.hpp b/src/olympic/studio/modlib/include/studio/filetreemodel.hpp index 74bd69d..75e62aa 100644 --- a/src/olympic/studio/modlib/include/studio/filetreemodel.hpp +++ b/src/olympic/studio/modlib/include/studio/filetreemodel.hpp @@ -78,7 +78,7 @@ class FileExplorer: public ox::SignalHandler { } private: - ox::Result setSelectedPath(ox::StringViewCR path, FileTreeModel const&node) noexcept; + ox::Result setSelectedPath(ox::StringViewCR path, FileTreeModel const &node) noexcept; }; @@ -106,7 +106,7 @@ class FileTreeModel { void setChildren(ox::Vector> children) noexcept; [[nodiscard]] - ox::Vector> const&children() const noexcept { + ox::Vector> const &children() const noexcept { return m_children; } @@ -129,13 +129,13 @@ ox::Result> buildFileTreeModel( ox::StringParam name, ox::StringViewCR path, FileTreeModel *parent = nullptr, - std::function const&filter = + std::function const &filter = [](ox::StringViewCR, ox::FileStat const&) {return true;}, bool showEmptyDirs = true) noexcept; ox::Result> buildFileTreeModel( FileExplorer &explorer, - std::function const&filter = + std::function const &filter = [](ox::StringViewCR, ox::FileStat const&) {return true;}, bool showEmptyDirs = true) noexcept; diff --git a/src/olympic/studio/modlib/include/studio/itemmaker.hpp b/src/olympic/studio/modlib/include/studio/itemmaker.hpp index ecd7be2..e4ad2ee 100644 --- a/src/olympic/studio/modlib/include/studio/itemmaker.hpp +++ b/src/olympic/studio/modlib/include/studio/itemmaker.hpp @@ -27,11 +27,11 @@ class ItemTemplate { virtual ~ItemTemplate() = default; [[nodiscard]] - constexpr ox::String const&name() const noexcept { + constexpr ox::String const &name() const noexcept { return m_name; } - constexpr bool operator<=>(ItemTemplate const&other) const noexcept { + constexpr bool operator<=>(ItemTemplate const &other) const noexcept { return m_name != other.name() ? (m_name < other.name() ? -1 : 1) : 0; } @@ -105,7 +105,7 @@ class ItemMaker { virtual ~ItemMaker() noexcept = default; [[nodiscard]] - ox::String const&typeDisplayName() const noexcept { + ox::String const &typeDisplayName() const noexcept { return m_typeDisplayName; } @@ -120,17 +120,17 @@ class ItemMaker { return false; } - constexpr ox::Vector> const&itemTemplates() const noexcept { + constexpr ox::Vector> const &itemTemplates() const noexcept { return m_templates; } [[nodiscard]] - ox::String const&fileExt() const noexcept { + ox::String const &fileExt() const noexcept { return m_fileExt; } [[nodiscard]] - ox::String const&defaultPath() const noexcept { + ox::String const &defaultPath() const noexcept { return m_parentDir; } @@ -212,7 +212,7 @@ class ItemMakerT final: public ItemMaker { ox::StringParam pDisplayName, ox::StringViewCR pParentDir, ox::StringParam fileExt, - T const&pItem, + T const &pItem, ox::ClawFormat const pFmt) noexcept: ItemMaker( std::move(pDisplayName), @@ -249,7 +249,7 @@ class ItemMakerT final: public ItemMaker { ox::StringViewCR pPath, size_t const pTemplateIdx) const noexcept override { createUuidMapping(keelCtx(ctx.tctx), pPath, ox::UUID::generate().unwrap()); - auto const&templates = itemTemplates(); + auto const &templates = itemTemplates(); auto const tmplIdx = pTemplateIdx < templates.size() ? pTemplateIdx : 0; OX_REQUIRE_M(tmpl, templates[tmplIdx]->getItem( keelCtx(ctx), typeName(), typeVersion())); diff --git a/src/olympic/studio/modlib/include/studio/popup.hpp b/src/olympic/studio/modlib/include/studio/popup.hpp index 0695a7a..eb9f064 100644 --- a/src/olympic/studio/modlib/include/studio/popup.hpp +++ b/src/olympic/studio/modlib/include/studio/popup.hpp @@ -43,11 +43,11 @@ class Popup: public Widget { m_title = std::move(title); } - constexpr ox::String const&title() const noexcept { + constexpr ox::String const &title() const noexcept { return m_title; } - void drawWindow(turbine::Context &ctx, bool &open, std::function const&drawContents); + void drawWindow(turbine::Context &ctx, bool &open, std::function const &drawContents); }; diff --git a/src/olympic/studio/modlib/include/studio/project.hpp b/src/olympic/studio/modlib/include/studio/project.hpp index 204f67e..dda1eab 100644 --- a/src/olympic/studio/modlib/include/studio/project.hpp +++ b/src/olympic/studio/modlib/include/studio/project.hpp @@ -64,7 +64,7 @@ class Project: public ox::SignalHandler { ox::Error create() noexcept; [[nodiscard]] - ox::String const&projectPath() const noexcept; + ox::String const &projectPath() const noexcept; [[nodiscard]] ox::FileSystem &romFs() noexcept; @@ -77,7 +77,7 @@ class Project: public ox::SignalHandler { template ox::Error writeObj( ox::StringViewCR path, - T const&obj, + T const &obj, ox::ClawFormat fmt) noexcept; /** @@ -86,7 +86,7 @@ class Project: public ox::SignalHandler { template ox::Error writeObj( ox::StringViewCR path, - T const&obj) noexcept; + T const &obj) noexcept; template ox::Result loadObj(ox::StringViewCR path) const noexcept; @@ -108,7 +108,7 @@ class Project: public ox::SignalHandler { ox::Error subscribe(ProjectEvent e, ox::SignalHandler *tgt, Functor &&slot) const noexcept; [[nodiscard]] - ox::Vector const&fileList(ox::StringViewCR ext) noexcept; + ox::Vector const &fileList(ox::StringViewCR ext) noexcept; ox::Error writeTypeStore() noexcept; @@ -117,7 +117,7 @@ class Project: public ox::SignalHandler { void indexFile(ox::StringViewCR path) noexcept; - ox::Error writeBuff(ox::StringViewCR path, ox::BufferView const&buff) noexcept; + ox::Error writeBuff(ox::StringViewCR path, ox::BufferView const &buff) noexcept; ox::Result loadBuff(ox::StringViewCR path) const noexcept; @@ -136,13 +136,13 @@ class Project: public ox::SignalHandler { ox::Signal fileRecognized; ox::Signal fileDeleted; ox::Signal dirDeleted; - ox::Signal fileUpdated; - ox::Signal fileMoved; + ox::Signal fileUpdated; + ox::Signal fileMoved; }; template -ox::Error Project::writeObj(ox::StringViewCR path, T const&obj, ox::ClawFormat fmt) noexcept { +ox::Error Project::writeObj(ox::StringViewCR path, T const &obj, ox::ClawFormat fmt) noexcept { OX_REQUIRE_M(buff, ox::writeClaw(obj, fmt)); if (fmt == ox::ClawFormat::Organic) { buff.pop_back(); @@ -167,7 +167,7 @@ ox::Error Project::writeObj(ox::StringViewCR path, T const&obj, ox::ClawFormat f } template -ox::Error Project::writeObj(ox::StringViewCR path, T const&obj) noexcept { +ox::Error Project::writeObj(ox::StringViewCR path, T const &obj) noexcept { OX_REQUIRE(ext, fileExt(path)); auto const fmt = m_typeFmt[ext].or_value(ox::ClawFormat::Metal); return writeObj(path, obj, fmt); @@ -197,7 +197,7 @@ ox::Error Project::subscribe(ProjectEvent e, ox::SignalHandler *tgt, Functor &&s case ProjectEvent::FileRecognized: { OX_REQUIRE(files, listFiles()); - for (auto const&f : files) { + for (auto const &f : files) { slot(f); } connect(this, &Project::fileRecognized, tgt, slot); diff --git a/src/olympic/studio/modlib/include/studio/selectiontracker.hpp b/src/olympic/studio/modlib/include/studio/selectiontracker.hpp index aa07b1a..0838eaf 100644 --- a/src/olympic/studio/modlib/include/studio/selectiontracker.hpp +++ b/src/olympic/studio/modlib/include/studio/selectiontracker.hpp @@ -16,19 +16,19 @@ namespace studio { struct Selection { ox::Point a, b; constexpr Selection() noexcept = default; - constexpr Selection(ox::Point const&pA, ox::Point const&pB) noexcept: a(pA), b(pB) {} + constexpr Selection(ox::Point const &pA, ox::Point const &pB) noexcept: a(pA), b(pB) {} [[nodiscard]] constexpr ox::Size size() const noexcept { return {b.x - a.x, b.y - a.y}; } [[nodiscard]] - constexpr bool contains(ox::Point const&pt) const noexcept { + constexpr bool contains(ox::Point const &pt) const noexcept { return a.x <= pt.x && a.y <= pt.y && b.x >= pt.x && b.y >= pt.y; } }; -constexpr auto iterateSelection(studio::Selection const&sel, auto const&cb) { +constexpr auto iterateSelection(Selection const &sel, auto const &cb) { constexpr auto retErr = ox::is_same_v; for (auto x = sel.a.x; x <= sel.b.x; ++x) { for (auto y = sel.a.y; y <= sel.b.y; ++y) { @@ -44,7 +44,7 @@ constexpr auto iterateSelection(studio::Selection const&sel, auto const&cb) { } }; -constexpr auto iterateSelectionRows(studio::Selection const&sel, auto const&cb) { +constexpr auto iterateSelectionRows(Selection const &sel, auto const &cb) { constexpr auto retErr = ox::is_same_v; for (auto y = sel.a.y; y <= sel.b.y; ++y) { for (auto x = sel.a.x; x <= sel.b.x; ++x) { diff --git a/src/olympic/studio/modlib/include/studio/undocommand.hpp b/src/olympic/studio/modlib/include/studio/undocommand.hpp index c7271b2..cb6df72 100644 --- a/src/olympic/studio/modlib/include/studio/undocommand.hpp +++ b/src/olympic/studio/modlib/include/studio/undocommand.hpp @@ -12,7 +12,7 @@ namespace studio { class NoChangesException: public ox::Exception { public: - inline NoChangesException(std::source_location sloc = std::source_location::current()): + explicit NoChangesException(std::source_location sloc = std::source_location::current()): ox::Exception(1, "Command makes no changes.", sloc) {} }; diff --git a/src/olympic/studio/modlib/src/filedialog_nfd.cpp b/src/olympic/studio/modlib/src/filedialog_nfd.cpp index 0869761..f298621 100644 --- a/src/olympic/studio/modlib/src/filedialog_nfd.cpp +++ b/src/olympic/studio/modlib/src/filedialog_nfd.cpp @@ -20,7 +20,7 @@ FDFilterItem::FDFilterItem(ox::StringViewCR pName, ox::StringViewCR pSpec) noexc OX_ALLOW_UNSAFE_BUFFERS_END } -static ox::Result toResult(nfdresult_t r, NFD::UniquePathN const&path) noexcept { +static ox::Result toResult(nfdresult_t r, NFD::UniquePathN const &path) noexcept { switch (r) { case NFD_OKAY: { ox::String out; @@ -39,11 +39,11 @@ OX_ALLOW_UNSAFE_BUFFERS_END } } -ox::Result saveFile(ox::Vector const&exts) noexcept { +ox::Result saveFile(ox::Vector const &exts) noexcept { NFD::Guard const guard; NFD::UniquePathN path; ox::Vector filterItems(exts.size()); - for (auto i = 0u; auto const&f : exts) { + for (auto i = 0u; auto const &f : exts) { filterItems[i].name = f.name.data(); filterItems[i].spec = f.spec.data(); ++i; diff --git a/src/olympic/studio/modlib/src/filepickerpopup.cpp b/src/olympic/studio/modlib/src/filepickerpopup.cpp index e4390ff..c965c0e 100644 --- a/src/olympic/studio/modlib/src/filepickerpopup.cpp +++ b/src/olympic/studio/modlib/src/filepickerpopup.cpp @@ -26,6 +26,22 @@ FilePickerPopup::FilePickerPopup( m_fileExts{std::move(fileExt)} { } +FilePickerPopup::FilePickerPopup( + ox::StringParam name, + keel::Context &kctx, + ox::SpanView fileExts) noexcept: + m_name{std::move(name)}, + m_explorer{kctx}, + m_fileExts{[fileExts] { + ox::Vector out; + out.reserve(fileExts.size()); + for (auto &s : fileExts) { + out.emplace_back(s); + } + return out; + }()} { +} + FilePickerPopup::FilePickerPopup( ox::StringParam name, keel::Context &kctx, diff --git a/src/olympic/studio/modlib/src/filetreemodel.cpp b/src/olympic/studio/modlib/src/filetreemodel.cpp index a32e119..2ec08c6 100644 --- a/src/olympic/studio/modlib/src/filetreemodel.cpp +++ b/src/olympic/studio/modlib/src/filetreemodel.cpp @@ -60,7 +60,7 @@ void FileExplorer::fileContextMenu(ox::StringViewCR) const noexcept {} void FileExplorer::dirContextMenu(ox::StringViewCR) const noexcept {} ox::Result FileExplorer::setSelectedPath( - ox::StringViewCR path, FileTreeModel const&node) noexcept { + ox::StringViewCR path, FileTreeModel const &node) noexcept { if (path == node.path()) { m_selected = &node; return {}; @@ -117,7 +117,7 @@ void FileTreeModel::draw(turbine::Context &tctx) const noexcept { } } if (nodeOpen) { - for (auto const&child : m_children) { + for (auto const &child : m_children) { child->draw(tctx); } ImGui::TreePop(); @@ -160,16 +160,16 @@ ox::Result> buildFileTreeModel( ox::StringParam name, ox::StringViewCR path, FileTreeModel *parent, - std::function const &filter, + std::function const &filter, bool const showEmptyDirs) noexcept { - auto const&fs = explorer.romFs(); + auto const &fs = explorer.romFs(); OX_REQUIRE(stat, fs.stat(path)); auto out = ox::make_unique(explorer, std::move(name), stat.fileType, parent); if (stat.fileType == ox::FileType::Directory) { OX_REQUIRE_M(children, fs.ls(path)); std::sort(children.begin(), children.end()); ox::Vector> outChildren; - for (auto const&childName : children) { + for (auto const &childName : children) { if (childName[0] != '.') { auto const childPath = ox::sfmt("{}/{}", path, childName); OX_REQUIRE(childStat, fs.stat(childPath)); @@ -195,7 +195,7 @@ ox::Result> buildFileTreeModel( ox::Result> buildFileTreeModel( FileExplorer &explorer, - std::function const&filter, + std::function const &filter, bool const showEmptyDirs) noexcept { return buildFileTreeModel(explorer, "Project", "/", nullptr, filter, showEmptyDirs); } diff --git a/src/olympic/studio/modlib/src/popup.cpp b/src/olympic/studio/modlib/src/popup.cpp index 04e7ba1..8868a56 100644 --- a/src/olympic/studio/modlib/src/popup.cpp +++ b/src/olympic/studio/modlib/src/popup.cpp @@ -7,8 +7,8 @@ namespace studio { -void Popup::drawWindow(turbine::Context &ctx, bool &open, std::function const&drawContents) { - studio::ig::centerNextWindow(ctx); +void Popup::drawWindow(turbine::Context &ctx, bool &open, std::function const &drawContents) { + ig::centerNextWindow(ctx); ImGui::SetNextWindowSize(static_cast(m_size)); constexpr auto modalFlags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize; if (ImGui::BeginPopupModal(m_title.c_str(), &open, modalFlags)) { diff --git a/src/olympic/studio/modlib/src/project.cpp b/src/olympic/studio/modlib/src/project.cpp index 214902e..0ccb2f4 100644 --- a/src/olympic/studio/modlib/src/project.cpp +++ b/src/olympic/studio/modlib/src/project.cpp @@ -75,7 +75,7 @@ ox::Error Project::create() noexcept { return ox::Error(static_cast(ec.value()), "PassThroughFS: mkdir failed"); } -ox::String const&Project::projectPath() const noexcept { +ox::String const &Project::projectPath() const noexcept { return m_path; } @@ -137,7 +137,7 @@ ox::Error Project::deleteItem(ox::StringViewCR path) noexcept { if (stat.fileType == ox::FileType::Directory) { bool partialRemoval{}; OX_REQUIRE(members, m_fs.ls(path)); - for (auto const&p : members) { + for (auto const &p : members) { partialRemoval = m_fs.remove(ox::sfmt("{}/{}", path, p)) || partialRemoval; } if (partialRemoval) { @@ -161,7 +161,7 @@ bool Project::exists(ox::StringViewCR path) const noexcept { return m_fs.stat(path).error == 0; } -ox::Vector const&Project::fileList(ox::StringViewCR ext) noexcept { +ox::Vector const &Project::fileList(ox::StringViewCR ext) noexcept { return m_fileExtFileMap[ext]; } @@ -185,7 +185,7 @@ void Project::buildFileIndex() noexcept { } m_fileExtFileMap.clear(); std::sort(files.begin(), files.end()); - for (auto const&file : files) { + for (auto const &file : files) { if (!beginsWith(file, ox::sfmt("/.{}/", m_projectDataDir))) { indexFile(file); } @@ -200,7 +200,7 @@ void Project::indexFile(ox::StringViewCR path) noexcept { m_fileExtFileMap[ext].emplace_back(path); } -ox::Error Project::writeBuff(ox::StringViewCR path, ox::BufferView const&buff) noexcept { +ox::Error Project::writeBuff(ox::StringViewCR path, ox::BufferView const &buff) noexcept { constexpr auto HdrSz = 40; ox::Buffer outBuff; outBuff.reserve(buff.size() + HdrSz); @@ -227,7 +227,7 @@ ox::Result Project::loadBuff(ox::StringViewCR path) const noexcept { ox::Error Project::lsProcDir(ox::Vector &paths, ox::StringViewCR path) const noexcept { OX_REQUIRE(files, m_fs.ls(path)); - for (auto const&name : files) { + for (auto const &name : files) { auto fullPath = ox::sfmt("{}/{}", path, name); OX_REQUIRE(stat, m_fs.stat(ox::StringView(fullPath))); switch (stat.fileType) { diff --git a/src/olympic/turbine/include/turbine/clipboard.hpp b/src/olympic/turbine/include/turbine/clipboard.hpp index 7e89548..5685763 100644 --- a/src/olympic/turbine/include/turbine/clipboard.hpp +++ b/src/olympic/turbine/include/turbine/clipboard.hpp @@ -28,7 +28,7 @@ class ClipboardObject: public BaseClipboardObject { } }; -ox::String getClipboardText(Context &ctx) noexcept; +ox::String getClipboardText(Context const &ctx) noexcept; void setClipboardText(Context &ctx, ox::StringViewCR text) noexcept; diff --git a/src/olympic/turbine/include/turbine/context.hpp b/src/olympic/turbine/include/turbine/context.hpp index bc8a8e0..31fe9f4 100644 --- a/src/olympic/turbine/include/turbine/context.hpp +++ b/src/olympic/turbine/include/turbine/context.hpp @@ -15,11 +15,11 @@ class Context; void safeDelete(Context *p); -keel::Context const&keelCtx(Context const&ctx) noexcept; +keel::Context const &keelCtx(Context const &ctx) noexcept; keel::Context &keelCtx(Context &ctx) noexcept; -inline ox::FileSystem const*rom(Context const&ctx) noexcept { +inline ox::FileSystem const*rom(Context const &ctx) noexcept { return keelCtx(ctx).rom.get(); } @@ -27,7 +27,7 @@ inline ox::FileSystem *rom(Context &ctx) noexcept { return keelCtx(ctx).rom.get(); } -void setApplicationDataRaw(Context &ctx, ox::AnyPtr const&applicationData) noexcept; +void setApplicationDataRaw(Context &ctx, ox::AnyPtr const &applicationData) noexcept; template void setApplicationData(Context &ctx, T *applicationData) noexcept { @@ -35,7 +35,7 @@ void setApplicationData(Context &ctx, T *applicationData) noexcept { } [[nodiscard]] -ox::AnyPtr const&applicationDataRaw(Context &ctx) noexcept; +ox::AnyPtr const &applicationDataRaw(Context &ctx) noexcept; template [[nodiscard]] diff --git a/src/olympic/turbine/include/turbine/gfx.hpp b/src/olympic/turbine/include/turbine/gfx.hpp index 1b2a55c..1dab7e2 100644 --- a/src/olympic/turbine/include/turbine/gfx.hpp +++ b/src/olympic/turbine/include/turbine/gfx.hpp @@ -41,7 +41,7 @@ ox::Size getScreenSize(Context const &ctx) noexcept; ox::Bounds getWindowBounds(Context const &ctx) noexcept; -ox::Error setWindowBounds(Context &ctx, ox::Bounds const&bnds) noexcept; +ox::Error setWindowBounds(Context &ctx, ox::Bounds const &bnds) noexcept; /** * Tells Turbine to refresh the screen within the specified period of time. diff --git a/src/olympic/turbine/include/turbine/turbine.hpp b/src/olympic/turbine/include/turbine/turbine.hpp index 65cce5d..ed98b85 100644 --- a/src/olympic/turbine/include/turbine/turbine.hpp +++ b/src/olympic/turbine/include/turbine/turbine.hpp @@ -89,7 +89,7 @@ void setMouseButtonEventHandler(Context &ctx, MouseButtonEventHandler h) noexcep KeyEventHandler keyEventHandler(Context const &ctx) noexcept; [[nodiscard]] -bool buttonDown(Context const&ctx, Key) noexcept; +bool buttonDown(Context const &ctx, Key) noexcept; ox::Result> init(ox::UPtr &&fs, ox::StringViewCR appName) noexcept; @@ -100,7 +100,7 @@ ox::Error run(Context &ctx) noexcept; // Returns the number of milliseconds that have passed since the start of the // program. [[nodiscard]] -TimeMs ticksMs(Context const&ctx) noexcept; +TimeMs ticksMs(Context const &ctx) noexcept; void requestShutdown(Context &ctx, bool force = false) noexcept; diff --git a/src/olympic/turbine/src/gba/clipboard.cpp b/src/olympic/turbine/src/gba/clipboard.cpp index 92cdd8a..f91b0da 100644 --- a/src/olympic/turbine/src/gba/clipboard.cpp +++ b/src/olympic/turbine/src/gba/clipboard.cpp @@ -9,7 +9,7 @@ namespace turbine { -ox::String getClipboardText(Context&) noexcept { +ox::String getClipboardText(Context const &) noexcept { return {}; } diff --git a/src/olympic/turbine/src/gba/context.cpp b/src/olympic/turbine/src/gba/context.cpp index 2d00512..d87101a 100644 --- a/src/olympic/turbine/src/gba/context.cpp +++ b/src/olympic/turbine/src/gba/context.cpp @@ -10,7 +10,7 @@ void safeDelete(Context *p) { delete p; } -keel::Context const&keelCtx(Context const&ctx) noexcept { +keel::Context const &keelCtx(Context const &ctx) noexcept { return ctx.keelCtx; } @@ -18,11 +18,11 @@ keel::Context &keelCtx(Context &ctx) noexcept { return ctx.keelCtx; } -void setApplicationDataRaw(Context &ctx, ox::AnyPtr const&applicationData) noexcept { +void setApplicationDataRaw(Context &ctx, ox::AnyPtr const &applicationData) noexcept { ctx.applicationData = applicationData; } -ox::AnyPtr const&applicationDataRaw(Context &ctx) noexcept { +ox::AnyPtr const &applicationDataRaw(Context &ctx) noexcept { return ctx.applicationData; } diff --git a/src/olympic/turbine/src/gba/context.hpp b/src/olympic/turbine/src/gba/context.hpp index e59eb39..2675db7 100644 --- a/src/olympic/turbine/src/gba/context.hpp +++ b/src/olympic/turbine/src/gba/context.hpp @@ -23,8 +23,8 @@ class Context final { Context() noexcept = default; Context(Context &other) noexcept = delete; - Context(Context const&other) noexcept = delete; - Context(Context const&&other) noexcept = delete; + Context(Context const &other) noexcept = delete; + Context(Context const &&other) noexcept = delete; }; diff --git a/src/olympic/turbine/src/glfw/clipboard.cpp b/src/olympic/turbine/src/glfw/clipboard.cpp index 7e45cf8..14026b4 100644 --- a/src/olympic/turbine/src/glfw/clipboard.cpp +++ b/src/olympic/turbine/src/glfw/clipboard.cpp @@ -12,7 +12,7 @@ namespace turbine { -ox::String getClipboardText(Context &ctx) noexcept { +ox::String getClipboardText(Context const &ctx) noexcept { return ox::String(glfwGetClipboardString(ctx.window)); } diff --git a/src/olympic/turbine/src/glfw/context.cpp b/src/olympic/turbine/src/glfw/context.cpp index 1aa34a2..83011fc 100644 --- a/src/olympic/turbine/src/glfw/context.cpp +++ b/src/olympic/turbine/src/glfw/context.cpp @@ -12,7 +12,7 @@ void safeDelete(Context *p) { delete p; } -keel::Context const&keelCtx(Context const&ctx) noexcept { +keel::Context const &keelCtx(Context const &ctx) noexcept { return ctx.keelCtx; } @@ -20,11 +20,11 @@ keel::Context &keelCtx(Context &ctx) noexcept { return ctx.keelCtx; } -void setApplicationDataRaw(Context &ctx, ox::AnyPtr const&applicationData) noexcept { +void setApplicationDataRaw(Context &ctx, ox::AnyPtr const &applicationData) noexcept { ctx.applicationData = applicationData; } -ox::AnyPtr const&applicationDataRaw(Context &ctx) noexcept { +ox::AnyPtr const &applicationDataRaw(Context &ctx) noexcept { return ctx.applicationData; } diff --git a/src/olympic/turbine/src/glfw/context.hpp b/src/olympic/turbine/src/glfw/context.hpp index a9e1d31..4490946 100644 --- a/src/olympic/turbine/src/glfw/context.hpp +++ b/src/olympic/turbine/src/glfw/context.hpp @@ -35,8 +35,8 @@ class Context { Context() noexcept = default; - Context(Context const&other) noexcept = delete; - Context(Context const&&other) noexcept = delete; + Context(Context const &other) noexcept = delete; + Context(Context const &&other) noexcept = delete; }; diff --git a/src/olympic/turbine/src/glfw/turbine.cpp b/src/olympic/turbine/src/glfw/turbine.cpp index 716e703..6efb6dd 100644 --- a/src/olympic/turbine/src/glfw/turbine.cpp +++ b/src/olympic/turbine/src/glfw/turbine.cpp @@ -214,7 +214,7 @@ ox::Bounds getWindowBounds(Context const &ctx) noexcept { return bnds; } -ox::Error setWindowBounds(Context &ctx, ox::Bounds const&bnds) noexcept { +ox::Error setWindowBounds(Context &ctx, ox::Bounds const &bnds) noexcept { glfwSetWindowPos(ctx.window, bnds.x, bnds.y); glfwSetWindowSize(ctx.window, bnds.width, bnds.height); return {}; @@ -430,13 +430,13 @@ ox::Error run(Context &ctx) noexcept { return {}; } -TimeMs ticksMs(Context const&ctx) noexcept { +TimeMs ticksMs(Context const &ctx) noexcept { using namespace std::chrono; auto const now = duration_cast(system_clock::now().time_since_epoch()).count(); return static_cast(now) - ctx.startTime; } -bool buttonDown(Context const&ctx, Key const key) noexcept { +bool buttonDown(Context const &ctx, Key const key) noexcept { return (ctx.keysDown >> static_cast(key)) & 1; }