diff --git a/src/nostalgia/appmodules/CMakeLists.txt b/src/nostalgia/appmodules/CMakeLists.txt index 23bc4e32..d63c2ae2 100644 --- a/src/nostalgia/appmodules/CMakeLists.txt +++ b/src/nostalgia/appmodules/CMakeLists.txt @@ -1,22 +1,35 @@ add_library( - NostalgiaAppModules OBJECT - appmodules.cpp + NostalgiaKeelModules OBJECT + keelmodules.cpp ) - -if(NOT MSVC) - target_compile_options(NostalgiaAppModules PRIVATE -Wsign-conversion) -endif() - target_link_libraries( - NostalgiaAppModules PUBLIC + NostalgiaKeelModules PUBLIC Keel NostalgiaCore NostalgiaScene ) - +if(NOT MSVC) + target_compile_options(NostalgiaKeelModules PRIVATE -Wsign-conversion) +endif() install( FILES - appmodules.hpp + keelmodules.hpp DESTINATION include/nostalgia/appmodules ) + +if(NOSTALGIA_BUILD_TYPE STREQUAL "Native") + add_library( + NostalgiaStudioModules + studiomodules.cpp + ) + target_link_libraries( + NostalgiaStudioModules PUBLIC + StudioAppLib + NostalgiaCore-Studio + NostalgiaScene-Studio + ) + if(NOT MSVC) + target_compile_options(NostalgiaStudioModules PRIVATE -Wsign-conversion) + endif() +endif() \ No newline at end of file diff --git a/src/nostalgia/appmodules/appmodules.cpp b/src/nostalgia/appmodules/appmodules.cpp deleted file mode 100644 index cac111f5..00000000 --- a/src/nostalgia/appmodules/appmodules.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. - */ - -#include - -#include -#include - -namespace nostalgia { - -static bool modulesLoaded = false; -void loadModules() noexcept { - if (modulesLoaded) { - return; - } - keel::registerModule(core::module()); - keel::registerModule(scene::module()); - modulesLoaded = true; -} - -} diff --git a/src/nostalgia/appmodules/keelmodules.cpp b/src/nostalgia/appmodules/keelmodules.cpp new file mode 100644 index 00000000..cff29958 --- /dev/null +++ b/src/nostalgia/appmodules/keelmodules.cpp @@ -0,0 +1,22 @@ +/* + * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. + */ + +#include + +#include +#include + +namespace nostalgia { + +static bool modulesRegistered = false; +void registerKeelModules() noexcept { + if (modulesRegistered) { + return; + } + keel::registerModule(core::keelModule()); + keel::registerModule(scene::keelModule()); + modulesRegistered = true; +} + +} diff --git a/src/nostalgia/appmodules/appmodules.hpp b/src/nostalgia/appmodules/keelmodules.hpp similarity index 77% rename from src/nostalgia/appmodules/appmodules.hpp rename to src/nostalgia/appmodules/keelmodules.hpp index cf82c6d6..6c8ea012 100644 --- a/src/nostalgia/appmodules/appmodules.hpp +++ b/src/nostalgia/appmodules/keelmodules.hpp @@ -6,6 +6,6 @@ namespace nostalgia { -void loadModules() noexcept; +void registerKeelModules() noexcept; } diff --git a/src/nostalgia/appmodules/studiomodules.cpp b/src/nostalgia/appmodules/studiomodules.cpp new file mode 100644 index 00000000..f22c7c23 --- /dev/null +++ b/src/nostalgia/appmodules/studiomodules.cpp @@ -0,0 +1,24 @@ +/* + * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. + */ + +#include + +#include + +#include +#include + +namespace nostalgia { + +static bool modulesRegistered = false; +void registerStudioModules() noexcept { + if (modulesRegistered) { + return; + } + studio::registerModule(core::studioModule()); + studio::registerModule(scene::studioModule()); + modulesRegistered = true; +} + +} diff --git a/src/nostalgia/appmodules/studiomodules.hpp b/src/nostalgia/appmodules/studiomodules.hpp new file mode 100644 index 00000000..86328df9 --- /dev/null +++ b/src/nostalgia/appmodules/studiomodules.hpp @@ -0,0 +1,11 @@ +/* + * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. + */ + +#pragma once + +namespace nostalgia { + +void registerStudioModules() noexcept; + +} \ No newline at end of file diff --git a/src/nostalgia/core/CMakeLists.txt b/src/nostalgia/core/CMakeLists.txt index 3c6035c7..e8288180 100644 --- a/src/nostalgia/core/CMakeLists.txt +++ b/src/nostalgia/core/CMakeLists.txt @@ -2,7 +2,7 @@ add_library( NostalgiaCore context.cpp gfx.cpp - module.cpp + keelmodule.cpp tilesheet.cpp typeconv.cpp ) diff --git a/src/nostalgia/core/keelmodule.cpp b/src/nostalgia/core/keelmodule.cpp new file mode 100644 index 00000000..622e4b3e --- /dev/null +++ b/src/nostalgia/core/keelmodule.cpp @@ -0,0 +1,71 @@ +/* + * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. + */ + +#include + +#include +#include + +#include "gfx.hpp" +#include "typeconv.hpp" + +#include "keelmodule.hpp" + +namespace nostalgia::core { + +class CoreModule: public keel::Module { + private: + NostalgiaPaletteToPaletteConverter nostalgiaPaletteToPaletteConverter; + TileSheetV1ToTileSheetConverter nostalgiaGraphicToTileSheetConverter; + TileSheetToCompactTileSheetConverter tileSheetToCompactTileSheetConverter; + TileSheetV2ToTileSheetConverter tileSheetV2ToTileSheetConverter; + + public: + [[nodiscard]] + ox::Vector types() const noexcept final { + return { + keel::generateTypeDesc, + keel::generateTypeDesc, + keel::generateTypeDesc, + keel::generateTypeDesc, + keel::generateTypeDesc, + keel::generateTypeDesc, + }; + } + + [[nodiscard]] + ox::Vector converters() const noexcept final { + return { + &nostalgiaPaletteToPaletteConverter, + &nostalgiaGraphicToTileSheetConverter, + &tileSheetToCompactTileSheetConverter, + &tileSheetV2ToTileSheetConverter, + }; + } + + [[nodiscard]] + ox::Vector packTransforms() const noexcept final { + return { + // convert tilesheets to CompactTileSheets + [](keel::Context *ctx, ox::Buffer *buff) -> ox::Error { + oxRequire(hdr, keel::readAssetHeader(*buff)); + const auto typeId = ox::buildTypeId(hdr.clawHdr.typeName, hdr.clawHdr.typeVersion, hdr.clawHdr.typeParams); + if (typeId == ox::buildTypeId() || + typeId == ox::buildTypeId() || + typeId == ox::buildTypeId()) { + oxReturnError(keel::convertBuffToBuff( + ctx, *buff, ox::ClawFormat::Metal).moveTo(buff)); + } + return {}; + }, + }; + } +}; + +static CoreModule mod; +const keel::Module *keelModule() noexcept { + return &mod; +} + +} diff --git a/src/nostalgia/core/module.hpp b/src/nostalgia/core/keelmodule.hpp similarity index 79% rename from src/nostalgia/core/module.hpp rename to src/nostalgia/core/keelmodule.hpp index 447fefb4..fb692b7a 100644 --- a/src/nostalgia/core/module.hpp +++ b/src/nostalgia/core/keelmodule.hpp @@ -8,6 +8,6 @@ namespace nostalgia::core { -const keel::Module *module() noexcept; +const keel::Module *keelModule() noexcept; } diff --git a/src/nostalgia/core/module.cpp b/src/nostalgia/core/module.cpp deleted file mode 100644 index a6bb768d..00000000 --- a/src/nostalgia/core/module.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. - */ - -#include - -#include -#include - -#include "gfx.hpp" -#include "typeconv.hpp" - -#include "module.hpp" - -namespace nostalgia::core { - -class CoreModule: public keel::Module { - private: - NostalgiaPaletteToPaletteConverter nostalgiaPaletteToPaletteConverter; - TileSheetV1ToTileSheetConverter nostalgiaGraphicToTileSheetConverter; - TileSheetToCompactTileSheetConverter tileSheetToCompactTileSheetConverter; - TileSheetV2ToTileSheetConverter tileSheetV2ToTileSheetConverter; - - public: - static CoreModule mod; - [[nodiscard]] - ox::Vector types() const noexcept override; - [[nodiscard]] - ox::Vector converters() const noexcept override; - [[nodiscard]] - ox::Vector packTransforms() const noexcept override; -}; - -CoreModule CoreModule::mod; - -const keel::Module *module() noexcept { - return &CoreModule::mod; -} - -ox::Vector CoreModule::types() const noexcept { - return { - keel::generateTypeDesc, - keel::generateTypeDesc, - keel::generateTypeDesc, - keel::generateTypeDesc, - keel::generateTypeDesc, - keel::generateTypeDesc, - }; -} - -ox::Vector CoreModule::converters() const noexcept { - return { - &nostalgiaPaletteToPaletteConverter, - &nostalgiaGraphicToTileSheetConverter, - &tileSheetToCompactTileSheetConverter, - &tileSheetV2ToTileSheetConverter, - }; -} - -ox::Vector CoreModule::packTransforms() const noexcept { - return { - // convert tilesheets to CompactTileSheets - [](keel::Context *ctx, ox::Buffer *buff) -> ox::Error { - oxRequire(hdr, keel::readAssetHeader(*buff)); - const auto typeId = ox::buildTypeId(hdr.clawHdr.typeName, hdr.clawHdr.typeVersion, hdr.clawHdr.typeParams); - if (typeId == ox::buildTypeId() || - typeId == ox::buildTypeId() || - typeId == ox::buildTypeId()) { - oxReturnError(keel::convertBuffToBuff( - ctx, *buff, ox::ClawFormat::Metal).moveTo(buff)); - } - return {}; - }, - }; -} - -} diff --git a/src/nostalgia/core/studio/CMakeLists.txt b/src/nostalgia/core/studio/CMakeLists.txt index b9a4cc65..d7f6629e 100644 --- a/src/nostalgia/core/studio/CMakeLists.txt +++ b/src/nostalgia/core/studio/CMakeLists.txt @@ -1,6 +1,6 @@ add_library( NostalgiaCore-Studio OBJECT - module.cpp + studiomodule.cpp paletteeditor.cpp paletteeditor-imgui.cpp tilesheeteditor-imgui.cpp diff --git a/src/nostalgia/core/studio/module.hpp b/src/nostalgia/core/studio/module.hpp deleted file mode 100644 index bee37421..00000000 --- a/src/nostalgia/core/studio/module.hpp +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. - */ - -#pragma once - -#include - -namespace nostalgia::core { - -class StudioModule: public studio::Module { - public: - ox::Vector editors(turbine::Context *ctx) noexcept override; - ox::Vector> itemMakers(turbine::Context*) noexcept override; -}; - -} diff --git a/src/nostalgia/core/studio/module.cpp b/src/nostalgia/core/studio/studiomodule.cpp similarity index 69% rename from src/nostalgia/core/studio/module.cpp rename to src/nostalgia/core/studio/studiomodule.cpp index 54f47ce3..2b665a20 100644 --- a/src/nostalgia/core/studio/module.cpp +++ b/src/nostalgia/core/studio/studiomodule.cpp @@ -7,11 +7,17 @@ #include "paletteeditor-imgui.hpp" #include "tilesheeteditor-imgui.hpp" -#include "module.hpp" +#include "studiomodule.hpp" namespace nostalgia::core { -ox::Vector StudioModule::editors(turbine::Context *ctx) noexcept { +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 StudioModule::editors(turbine::Context *ctx) const noexcept { return { { {FileExt_ng}, @@ -32,11 +38,16 @@ ox::Vector StudioModule::editors(turbine::Context *ctx) noe }; } -ox::Vector> StudioModule::itemMakers(turbine::Context*) noexcept { +ox::Vector> StudioModule::itemMakers(turbine::Context*) const noexcept { ox::Vector> out; out.emplace_back(ox::make>("Tile Sheet", "TileSheets", "ng")); out.emplace_back(ox::make>("Palette", "Palettes", "npal")); return out; } +static StudioModule mod; +const studio::Module *studioModule() noexcept { + return &mod; +} + } diff --git a/src/nostalgia/core/studio/studiomodule.hpp b/src/nostalgia/core/studio/studiomodule.hpp new file mode 100644 index 00000000..c14b11ce --- /dev/null +++ b/src/nostalgia/core/studio/studiomodule.hpp @@ -0,0 +1,13 @@ +/* + * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. + */ + +#pragma once + +#include + +namespace nostalgia::core { + +const studio::Module *studioModule() noexcept; + +} diff --git a/src/nostalgia/player/CMakeLists.txt b/src/nostalgia/player/CMakeLists.txt index ea225292..06dced64 100644 --- a/src/nostalgia/player/CMakeLists.txt +++ b/src/nostalgia/player/CMakeLists.txt @@ -22,7 +22,7 @@ endif() target_link_libraries( nostalgia - NostalgiaAppModules + NostalgiaKeelModules OxLogConn ) diff --git a/src/nostalgia/player/main.cpp b/src/nostalgia/player/main.cpp index 5417ceb6..1da2bd87 100644 --- a/src/nostalgia/player/main.cpp +++ b/src/nostalgia/player/main.cpp @@ -8,7 +8,7 @@ #include -#include +#include #include "app.hpp" @@ -17,7 +17,7 @@ static ox::Error run(int argc, const char **argv) noexcept { #ifdef OX_USE_STDLIB // GBA doesn't need the modules and calling this doubles the size of the // binary. - nostalgia::loadModules(); + nostalgia::registerKeelModules(); #endif if (argc < 2) { oxErr("Please provide path to project directory or OxFS file.\n"); diff --git a/src/nostalgia/scene/CMakeLists.txt b/src/nostalgia/scene/CMakeLists.txt index 565cf22f..7af14f35 100644 --- a/src/nostalgia/scene/CMakeLists.txt +++ b/src/nostalgia/scene/CMakeLists.txt @@ -3,7 +3,7 @@ add_library( NostalgiaScene scene.cpp scenestatic.cpp - scenemodule.cpp + keelmodule.cpp typeconv.cpp ) @@ -15,7 +15,7 @@ target_link_libraries( install( FILES scenestatic.hpp - scenemodule.hpp + keelmodule.hpp typeconv.hpp DESTINATION include/nostalgia/scene diff --git a/src/nostalgia/scene/scenemodule.cpp b/src/nostalgia/scene/keelmodule.cpp similarity index 89% rename from src/nostalgia/scene/scenemodule.cpp rename to src/nostalgia/scene/keelmodule.cpp index 478b5f49..730a671f 100644 --- a/src/nostalgia/scene/scenemodule.cpp +++ b/src/nostalgia/scene/keelmodule.cpp @@ -2,12 +2,10 @@ * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. */ -#include - #include "scenestatic.hpp" #include "typeconv.hpp" -#include "scenemodule.hpp" +#include "keelmodule.hpp" namespace nostalgia::scene { @@ -41,7 +39,7 @@ class SceneModule: public keel::Module { }; static SceneModule mod; -const keel::Module *module() noexcept { +const keel::Module *keelModule() noexcept { return &mod; } diff --git a/src/nostalgia/scene/scenemodule.hpp b/src/nostalgia/scene/keelmodule.hpp similarity index 79% rename from src/nostalgia/scene/scenemodule.hpp rename to src/nostalgia/scene/keelmodule.hpp index 397591cc..8e1c46c1 100644 --- a/src/nostalgia/scene/scenemodule.hpp +++ b/src/nostalgia/scene/keelmodule.hpp @@ -8,6 +8,6 @@ namespace nostalgia::scene { -const keel::Module *module() noexcept; +const keel::Module *keelModule() noexcept; } diff --git a/src/nostalgia/scene/studio/CMakeLists.txt b/src/nostalgia/scene/studio/CMakeLists.txt index 8a551282..c3df0280 100644 --- a/src/nostalgia/scene/studio/CMakeLists.txt +++ b/src/nostalgia/scene/studio/CMakeLists.txt @@ -1,6 +1,6 @@ add_library( NostalgiaScene-Studio OBJECT - module.cpp + studiomodule.cpp sceneeditor-imgui.cpp sceneeditor.cpp sceneeditorview.cpp diff --git a/src/nostalgia/scene/studio/module.hpp b/src/nostalgia/scene/studio/module.hpp deleted file mode 100644 index 5c8a194d..00000000 --- a/src/nostalgia/scene/studio/module.hpp +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. - */ - -#pragma once - -#include -#include - -namespace nostalgia::scene { - -class StudioModule: public studio::Module { - public: - ox::Vector editors(turbine::Context *ctx) noexcept override; - ox::Vector> itemMakers(turbine::Context*) noexcept override; -}; - -} diff --git a/src/nostalgia/scene/studio/module.cpp b/src/nostalgia/scene/studio/studiomodule.cpp similarity index 54% rename from src/nostalgia/scene/studio/module.cpp rename to src/nostalgia/scene/studio/studiomodule.cpp index a3ae188d..834ae32e 100644 --- a/src/nostalgia/scene/studio/module.cpp +++ b/src/nostalgia/scene/studio/studiomodule.cpp @@ -3,11 +3,17 @@ */ #include "sceneeditor-imgui.hpp" -#include "module.hpp" +#include "studiomodule.hpp" namespace nostalgia::scene { -ox::Vector StudioModule::editors(turbine::Context *ctx) noexcept { +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 StudioModule::editors(turbine::Context *ctx) const noexcept { return { { {"nscn"}, @@ -18,9 +24,14 @@ ox::Vector StudioModule::editors(turbine::Context *ctx) noe }; } -ox::Vector> StudioModule::itemMakers(turbine::Context*) noexcept { +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/nostalgia/scene/studio/studiomodule.hpp b/src/nostalgia/scene/studio/studiomodule.hpp new file mode 100644 index 00000000..0d83e3ed --- /dev/null +++ b/src/nostalgia/scene/studio/studiomodule.hpp @@ -0,0 +1,14 @@ +/* + * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. + */ + +#pragma once + +#include +#include + +namespace nostalgia::scene { + +const studio::Module *studioModule() noexcept; + +} diff --git a/src/nostalgia/studio/CMakeLists.txt b/src/nostalgia/studio/CMakeLists.txt index 4d1b12eb..167ab738 100644 --- a/src/nostalgia/studio/CMakeLists.txt +++ b/src/nostalgia/studio/CMakeLists.txt @@ -7,9 +7,8 @@ add_executable( target_link_libraries( nostalgia-studio - NostalgiaAppModules - NostalgiaCore-Studio - NostalgiaScene-Studio + NostalgiaStudioModules + NostalgiaKeelModules StudioAppLib ) @@ -35,4 +34,4 @@ install( RUNTIME DESTINATION ${NOSTALGIA_DIST_BIN} BUNDLE DESTINATION . -) \ No newline at end of file +) diff --git a/src/nostalgia/studio/main.cpp b/src/nostalgia/studio/main.cpp index d990ef9d..e47919cc 100644 --- a/src/nostalgia/studio/main.cpp +++ b/src/nostalgia/studio/main.cpp @@ -2,27 +2,13 @@ * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. */ -#include - -#include -#include -#include +#include +#include #include -using namespace nostalgia; - -[[maybe_unused]] // GCC warns about the existence of this "unused" inline list in a header file... -ox::Vector()>> BuiltinModules = { - []() -> ox::UPtr { - return ox::UPtr(new core::StudioModule()); - }, - []() -> ox::UPtr { - return ox::UPtr(new scene::StudioModule()); - }, -}; - int main(int argc, const char **argv) { - nostalgia::loadModules(); + nostalgia::registerKeelModules(); + nostalgia::registerStudioModules(); return studio::main("Nostalgia Studio", ".nostalgia", argc, argv); -} \ No newline at end of file +} diff --git a/src/nostalgia/tools/CMakeLists.txt b/src/nostalgia/tools/CMakeLists.txt index 7bca9bd6..5a966c16 100644 --- a/src/nostalgia/tools/CMakeLists.txt +++ b/src/nostalgia/tools/CMakeLists.txt @@ -5,7 +5,7 @@ target_link_libraries( OxClArgs OxLogConn Keel - NostalgiaAppModules + NostalgiaKeelModules ) if(CMAKE_BUILD_TYPE STREQUAL "Release" AND NOT WIN32) diff --git a/src/nostalgia/tools/pack.cpp b/src/nostalgia/tools/pack.cpp index 5c758f32..c9e0f7d5 100644 --- a/src/nostalgia/tools/pack.cpp +++ b/src/nostalgia/tools/pack.cpp @@ -10,7 +10,7 @@ #include -#include +#include using namespace nostalgia; @@ -52,7 +52,7 @@ static ox::Error generateTypes(ox::TypeStore *ts) noexcept { } static ox::Error run(const ox::ClArgs &args) noexcept { - loadModules(); + registerKeelModules(); const auto argSrc = args.getString("src", ""); const auto argRomBin = args.getString("rom-bin", ""); if (argSrc == "") { diff --git a/src/studio/applib/include/studioapp/studioapp.hpp b/src/studio/applib/include/studioapp/studioapp.hpp index a1d2f398..8935a631 100644 --- a/src/studio/applib/include/studioapp/studioapp.hpp +++ b/src/studio/applib/include/studioapp/studioapp.hpp @@ -6,12 +6,16 @@ #include +#include + namespace studio { +void registerModule(const studio::Module*) noexcept; + int main( const char *appName, ox::String projectDataDir, - [[maybe_unused]] int argc, - [[maybe_unused]] const char **argv); + int argc, + const char **argv); } diff --git a/src/studio/applib/src/CMakeLists.txt b/src/studio/applib/src/CMakeLists.txt index cdeaf253..1301156e 100644 --- a/src/studio/applib/src/CMakeLists.txt +++ b/src/studio/applib/src/CMakeLists.txt @@ -1,5 +1,3 @@ -set(CMAKE_INCLUDE_CURRENT_DIR ON) - add_library( StudioAppLib aboutpopup.cpp diff --git a/src/studio/applib/src/main.cpp b/src/studio/applib/src/main.cpp index 735f6b9f..03cc052f 100644 --- a/src/studio/applib/src/main.cpp +++ b/src/studio/applib/src/main.cpp @@ -10,8 +10,6 @@ #include #include -#include - #include #include "studioapp.hpp" @@ -65,8 +63,8 @@ namespace studio { int main( const char *appName, ox::String projectDataDir, - [[maybe_unused]] int argc, - [[maybe_unused]] const char **argv) { + int, + const char **) { #ifdef DEBUG ox::LoggerConn loggerConn; const auto loggerErr = loggerConn.initConn(appName); @@ -88,4 +86,4 @@ int main( return static_cast(err); } -} \ No newline at end of file +} diff --git a/src/studio/applib/src/studioapp.cpp b/src/studio/applib/src/studioapp.cpp index 8dc62bff..1b64625d 100644 --- a/src/studio/applib/src/studioapp.cpp +++ b/src/studio/applib/src/studioapp.cpp @@ -13,6 +13,8 @@ #include "filedialogmanager.hpp" #include "studioapp.hpp" +ox::Vector modules; + struct StudioConfig { static constexpr auto TypeName = "net.drinkingtea.studio.StudioConfig"; static constexpr auto TypeVersion = 1; @@ -246,7 +248,7 @@ void StudioUI::loadEditorMaker(const studio::EditorMaker &editorMaker) noexcept } } -void StudioUI::loadModule(studio::Module *mod) noexcept { +void StudioUI::loadModule(const studio::Module *mod) noexcept { for (const auto &editorMaker : mod->editors(m_ctx)) { loadEditorMaker(editorMaker); } @@ -256,9 +258,8 @@ void StudioUI::loadModule(studio::Module *mod) noexcept { } void StudioUI::loadModules() noexcept { - for (auto &moduleMaker : BuiltinModules) { - const auto mod = moduleMaker(); - loadModule(mod.get()); + for (auto &mod : modules) { + loadModule(mod); } } @@ -369,3 +370,11 @@ ox::Error StudioUI::closeFile(const ox::String &path) noexcept { }); return OxError(0); } + +namespace studio { + +void registerModule(const studio::Module *mod) noexcept { + modules.emplace_back(mod); +} + +} diff --git a/src/studio/applib/src/studioapp.hpp b/src/studio/applib/src/studioapp.hpp index e63059ab..0be512b0 100644 --- a/src/studio/applib/src/studioapp.hpp +++ b/src/studio/applib/src/studioapp.hpp @@ -65,7 +65,7 @@ class StudioUI: public ox::SignalHandler { void loadEditorMaker(const studio::EditorMaker &editorMaker) noexcept; - void loadModule(studio::Module *mod) noexcept; + void loadModule(const studio::Module *mod) noexcept; void loadModules() noexcept; diff --git a/src/studio/modlib/include/studio/module.hpp b/src/studio/modlib/include/studio/module.hpp index 3688c3cd..c0b302f3 100644 --- a/src/studio/modlib/include/studio/module.hpp +++ b/src/studio/modlib/include/studio/module.hpp @@ -25,9 +25,9 @@ class Module { public: virtual ~Module() noexcept = default; - virtual ox::Vector editors(turbine::Context *ctx); + virtual ox::Vector editors(turbine::Context *ctx) const; - virtual ox::Vector> itemMakers(turbine::Context*); + virtual ox::Vector> itemMakers(turbine::Context*) const; }; diff --git a/src/studio/modlib/src/module.cpp b/src/studio/modlib/src/module.cpp index c733a627..18f3a001 100644 --- a/src/studio/modlib/src/module.cpp +++ b/src/studio/modlib/src/module.cpp @@ -6,11 +6,11 @@ namespace studio { -ox::Vector Module::editors(turbine::Context*) { +ox::Vector Module::editors(turbine::Context*) const { return {}; } -ox::Vector> Module::itemMakers(turbine::Context*) { +ox::Vector> Module::itemMakers(turbine::Context*) const { return {}; }