diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fdb87f6a..6b02e170 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,7 +2,8 @@ include_directories(".") if(NOSTALGIA_BUILD_TYPE STREQUAL "Native") add_subdirectory(glutils) + add_subdirectory(studio) endif() add_subdirectory(keel) add_subdirectory(nostalgia) -add_subdirectory(turbine) \ No newline at end of file +add_subdirectory(turbine) diff --git a/src/nostalgia/core/studio/module.hpp b/src/nostalgia/core/studio/module.hpp index 160fba32..bee37421 100644 --- a/src/nostalgia/core/studio/module.hpp +++ b/src/nostalgia/core/studio/module.hpp @@ -4,7 +4,7 @@ #pragma once -#include +#include namespace nostalgia::core { diff --git a/src/nostalgia/core/studio/paletteeditor-imgui.hpp b/src/nostalgia/core/studio/paletteeditor-imgui.hpp index b8559747..32e4b717 100644 --- a/src/nostalgia/core/studio/paletteeditor-imgui.hpp +++ b/src/nostalgia/core/studio/paletteeditor-imgui.hpp @@ -4,8 +4,9 @@ #pragma once +#include + #include -#include namespace nostalgia::core { diff --git a/src/nostalgia/core/studio/paletteeditor.hpp b/src/nostalgia/core/studio/paletteeditor.hpp index a3f5fcf1..bac0a262 100644 --- a/src/nostalgia/core/studio/paletteeditor.hpp +++ b/src/nostalgia/core/studio/paletteeditor.hpp @@ -4,8 +4,9 @@ #pragma once +#include + #include -#include namespace nostalgia::core { diff --git a/src/nostalgia/core/studio/tilesheeteditor-imgui.hpp b/src/nostalgia/core/studio/tilesheeteditor-imgui.hpp index 3f21fb13..2843ddfd 100644 --- a/src/nostalgia/core/studio/tilesheeteditor-imgui.hpp +++ b/src/nostalgia/core/studio/tilesheeteditor-imgui.hpp @@ -8,8 +8,7 @@ #include #include - -#include +#include #include "tilesheetpixelgrid.hpp" #include "tilesheetpixels.hpp" diff --git a/src/nostalgia/core/studio/tilesheeteditormodel.hpp b/src/nostalgia/core/studio/tilesheeteditormodel.hpp index d93b902a..1f6eb87b 100644 --- a/src/nostalgia/core/studio/tilesheeteditormodel.hpp +++ b/src/nostalgia/core/studio/tilesheeteditormodel.hpp @@ -9,8 +9,9 @@ #include #include +#include + #include -#include namespace nostalgia::core { diff --git a/src/nostalgia/core/studio/tilesheeteditorview.hpp b/src/nostalgia/core/studio/tilesheeteditorview.hpp index 7c298016..80b86d46 100644 --- a/src/nostalgia/core/studio/tilesheeteditorview.hpp +++ b/src/nostalgia/core/studio/tilesheeteditorview.hpp @@ -8,9 +8,9 @@ #include #include +#include #include -#include #include "tilesheeteditormodel.hpp" #include "tilesheetpixelgrid.hpp" diff --git a/src/nostalgia/core/studio/tilesheetpixelgrid.hpp b/src/nostalgia/core/studio/tilesheetpixelgrid.hpp index 3e77b786..5601458c 100644 --- a/src/nostalgia/core/studio/tilesheetpixelgrid.hpp +++ b/src/nostalgia/core/studio/tilesheetpixelgrid.hpp @@ -5,9 +5,9 @@ #pragma once #include +#include #include -#include namespace nostalgia::core { diff --git a/src/nostalgia/core/studio/tilesheetpixels.hpp b/src/nostalgia/core/studio/tilesheetpixels.hpp index 8729e4d6..5cca246d 100644 --- a/src/nostalgia/core/studio/tilesheetpixels.hpp +++ b/src/nostalgia/core/studio/tilesheetpixels.hpp @@ -7,9 +7,9 @@ #include #include +#include #include -#include namespace nostalgia::core { diff --git a/src/nostalgia/scene/studio/CMakeLists.txt b/src/nostalgia/scene/studio/CMakeLists.txt index ff87d409..8a551282 100644 --- a/src/nostalgia/scene/studio/CMakeLists.txt +++ b/src/nostalgia/scene/studio/CMakeLists.txt @@ -12,8 +12,8 @@ endif() target_link_libraries( NostalgiaScene-Studio PUBLIC - NostalgiaStudio NostalgiaScene + Studio ) install( diff --git a/src/nostalgia/scene/studio/module.hpp b/src/nostalgia/scene/studio/module.hpp index 0602e4c8..5c8a194d 100644 --- a/src/nostalgia/scene/studio/module.hpp +++ b/src/nostalgia/scene/studio/module.hpp @@ -5,8 +5,7 @@ #pragma once #include - -#include +#include namespace nostalgia::scene { diff --git a/src/nostalgia/scene/studio/sceneeditor-imgui.hpp b/src/nostalgia/scene/studio/sceneeditor-imgui.hpp index c63bbecb..9cbb4ddd 100644 --- a/src/nostalgia/scene/studio/sceneeditor-imgui.hpp +++ b/src/nostalgia/scene/studio/sceneeditor-imgui.hpp @@ -4,8 +4,9 @@ #pragma once +#include + #include -#include #include "sceneeditor.hpp" #include "sceneeditorview.hpp" diff --git a/src/nostalgia/scene/studio/sceneeditor.hpp b/src/nostalgia/scene/studio/sceneeditor.hpp index 6fac862c..3df3b59d 100644 --- a/src/nostalgia/scene/studio/sceneeditor.hpp +++ b/src/nostalgia/scene/studio/sceneeditor.hpp @@ -4,8 +4,9 @@ #pragma once +#include + #include -#include #include namespace nostalgia::scene { diff --git a/src/nostalgia/studio/CMakeLists.txt b/src/nostalgia/studio/CMakeLists.txt index ef14f695..4d1b12eb 100644 --- a/src/nostalgia/studio/CMakeLists.txt +++ b/src/nostalgia/studio/CMakeLists.txt @@ -2,25 +2,15 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) add_executable( nostalgia-studio MACOSX_BUNDLE - aboutpopup.cpp - builtinmodules.cpp - clawviewer.cpp - filedialogmanager.cpp main.cpp - newmenu.cpp - projectexplorer.cpp - projecttreemodel.cpp - studioapp.cpp ) target_link_libraries( nostalgia-studio - OxClArgs - OxLogConn NostalgiaAppModules - NostalgiaStudio NostalgiaCore-Studio NostalgiaScene-Studio + StudioAppLib ) if(CMAKE_BUILD_TYPE STREQUAL "Release" AND NOT WIN32) @@ -45,6 +35,4 @@ install( RUNTIME DESTINATION ${NOSTALGIA_DIST_BIN} BUNDLE DESTINATION . -) - -add_subdirectory(lib) +) \ No newline at end of file diff --git a/src/nostalgia/studio/builtinmodules.cpp b/src/nostalgia/studio/builtinmodules.cpp deleted file mode 100644 index 8391b4ff..00000000 --- a/src/nostalgia/studio/builtinmodules.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. - */ - -#include - -#include -#include - -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()); - }, -}; - -} diff --git a/src/nostalgia/studio/lib/CMakeLists.txt b/src/nostalgia/studio/lib/CMakeLists.txt deleted file mode 100644 index 1c693b8b..00000000 --- a/src/nostalgia/studio/lib/CMakeLists.txt +++ /dev/null @@ -1,58 +0,0 @@ -add_library( - NostalgiaStudio - configio.cpp - editor.cpp - imguiutil.cpp - module.cpp - popup.cpp - project.cpp - task.cpp - undostack.cpp - widget.cpp - filedialog_nfd.cpp -) - -if(NOT MSVC) - target_compile_options(NostalgiaStudio PUBLIC -Wsign-conversion) -endif() - -install( - TARGETS - NostalgiaStudio - DESTINATION - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib -) - -generate_export_header(NostalgiaStudio) -target_include_directories(NostalgiaStudio PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) - -include_directories( - SYSTEM - ${GTK3_INCLUDE_DIRS} -) - -target_link_libraries( - NostalgiaStudio PUBLIC - nfd - OxEvent - Turbine -) - -install( - FILES - configio.hpp - context.hpp - editor.hpp - filedialog.hpp - itemmaker.hpp - module.hpp - popup.hpp - project.hpp - task.hpp - undostack.hpp - widget.hpp - ${CMAKE_CURRENT_BINARY_DIR}/nostalgiastudio_export.h - DESTINATION - include/nostalgia/studio/lib -) diff --git a/src/nostalgia/studio/lib/popup.cpp b/src/nostalgia/studio/lib/popup.cpp deleted file mode 100644 index 9aea2842..00000000 --- a/src/nostalgia/studio/lib/popup.cpp +++ /dev/null @@ -1,9 +0,0 @@ -/* - * Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved. - */ - -#include "popup.hpp" - -namespace nostalgia::studio { - -} \ No newline at end of file diff --git a/src/nostalgia/studio/lib/widget.cpp b/src/nostalgia/studio/lib/widget.cpp deleted file mode 100644 index 893cedde..00000000 --- a/src/nostalgia/studio/lib/widget.cpp +++ /dev/null @@ -1,9 +0,0 @@ -/* - * Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved. - */ - -#include "widget.hpp" - -namespace nostalgia::studio { - -} \ No newline at end of file diff --git a/src/nostalgia/studio/main.cpp b/src/nostalgia/studio/main.cpp index 364b1489..d990ef9d 100644 --- a/src/nostalgia/studio/main.cpp +++ b/src/nostalgia/studio/main.cpp @@ -2,87 +2,27 @@ * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. */ -#include - -#include -#include -#include -#include -#include +#include #include +#include +#include -#include "lib/context.hpp" -#include "studioapp.hpp" +#include -namespace nostalgia { +using namespace nostalgia; -class StudioUIDrawer: public turbine::gl::Drawer { - private: - StudioUI *m_ui = nullptr; - public: - explicit StudioUIDrawer(StudioUI *ui) noexcept: m_ui(ui) { - } - protected: - void draw(turbine::Context&) noexcept final { - m_ui->draw(); - } +[[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()); + }, }; -static int updateHandler(turbine::Context &ctx) noexcept { - auto sctx = turbine::applicationData(ctx); - auto ui = dynamic_cast(sctx->ui); - ui->update(); - return 16; -} - -static void keyEventHandler(turbine::Context &ctx, turbine::Key key, bool down) noexcept { - auto sctx = turbine::applicationData(ctx); - auto ui = dynamic_cast(sctx->ui); - ui->handleKeyEvent(key, down); -} - -static ox::Error run(ox::UniquePtr fs) noexcept { - oxRequireM(ctx, turbine::init(std::move(fs), "NostalgiaStudio")); - turbine::setWindowTitle(*ctx, "Nostalgia Studio"); - turbine::setUpdateHandler(*ctx, updateHandler); - turbine::setKeyEventHandler(*ctx, keyEventHandler); - turbine::setConstantRefresh(*ctx, false); - studio::StudioContext studioCtx; - turbine::setApplicationData(*ctx, &studioCtx); - StudioUI ui(ctx.get()); - studioCtx.ui = &ui; - StudioUIDrawer drawer(&ui); - turbine::gl::addDrawer(*ctx, &drawer); - const auto err = turbine::run(*ctx); - turbine::gl::removeDrawer(*ctx, &drawer); - return err; -} - -static ox::Error run(int, const char**) noexcept { - ox::trace::init(); - const auto time = std::time(nullptr); - ox::UUID::seedGenerator({ - static_cast(time), - static_cast(time << 1) - }); - loadModules(); - return run(ox::UniquePtr(nullptr)); -} - -} - int main(int argc, const char **argv) { -#ifdef DEBUG - ox::LoggerConn loggerConn; - const auto loggerErr = loggerConn.initConn("Nostalgia Studio"); - if (loggerErr) { - oxErrf("Could not connect to logger: {}\n", toStr(loggerErr)); - } else { - ox::trace::setLogger(&loggerConn); - } -#endif - const auto err = nostalgia::run(argc, argv); - oxAssert(err, "Something went wrong..."); - return static_cast(err); -} + nostalgia::loadModules(); + return studio::main("Nostalgia Studio", ".nostalgia", argc, argv); +} \ No newline at end of file diff --git a/src/nostalgia/studio/studio.hpp b/src/nostalgia/studio/studio.hpp deleted file mode 100644 index 67f34958..00000000 --- a/src/nostalgia/studio/studio.hpp +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved. - */ - -#pragma once - -#include "lib/context.hpp" -#include "lib/editor.hpp" -#include "lib/filedialog.hpp" -#include "lib/imguiuitl.hpp" -#include "lib/module.hpp" -#include "lib/itemmaker.hpp" -#include "lib/popup.hpp" -#include "lib/project.hpp" -#include "lib/task.hpp" -#include "lib/undostack.hpp" -#include "lib/widget.hpp" diff --git a/src/studio/CMakeLists.txt b/src/studio/CMakeLists.txt new file mode 100644 index 00000000..256711a5 --- /dev/null +++ b/src/studio/CMakeLists.txt @@ -0,0 +1,2 @@ +add_subdirectory(applib) +add_subdirectory(modlib) diff --git a/src/studio/applib/CMakeLists.txt b/src/studio/applib/CMakeLists.txt new file mode 100644 index 00000000..febd4f0a --- /dev/null +++ b/src/studio/applib/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(src) diff --git a/src/studio/applib/include/studioapp/studioapp.hpp b/src/studio/applib/include/studioapp/studioapp.hpp new file mode 100644 index 00000000..a1d2f398 --- /dev/null +++ b/src/studio/applib/include/studioapp/studioapp.hpp @@ -0,0 +1,17 @@ +/* + * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. + */ + +#pragma once + +#include + +namespace studio { + +int main( + const char *appName, + ox::String projectDataDir, + [[maybe_unused]] int argc, + [[maybe_unused]] const char **argv); + +} diff --git a/src/studio/applib/src/CMakeLists.txt b/src/studio/applib/src/CMakeLists.txt new file mode 100644 index 00000000..cdeaf253 --- /dev/null +++ b/src/studio/applib/src/CMakeLists.txt @@ -0,0 +1,33 @@ +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +add_library( + StudioAppLib + aboutpopup.cpp + clawviewer.cpp + filedialogmanager.cpp + main.cpp + newmenu.cpp + projectexplorer.cpp + projecttreemodel.cpp + studioapp.cpp +) + +target_link_libraries( + StudioAppLib PUBLIC + OxClArgs + OxLogConn + Studio +) + +target_include_directories( + StudioAppLib PUBLIC + ../include +) + +install( + TARGETS + StudioAppLib + DESTINATION + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib +) diff --git a/src/nostalgia/studio/aboutpopup.cpp b/src/studio/applib/src/aboutpopup.cpp similarity index 86% rename from src/nostalgia/studio/aboutpopup.cpp rename to src/studio/applib/src/aboutpopup.cpp index 0b3a3175..56ae3e52 100644 --- a/src/nostalgia/studio/aboutpopup.cpp +++ b/src/studio/applib/src/aboutpopup.cpp @@ -4,10 +4,12 @@ #include -#include "lib/imguiuitl.hpp" +#include #include "aboutpopup.hpp" -namespace nostalgia { +AboutPopup::AboutPopup(turbine::Context &ctx) noexcept { + m_text = ox::sfmt("{} - dev build", ctx.appName); +} void AboutPopup::open() noexcept { m_stage = Stage::Opening; @@ -36,7 +38,7 @@ void AboutPopup::draw(turbine::Context *ctx) noexcept { studio::ig::centerNextWindow(ctx); auto open = true; if (ImGui::BeginPopupModal("About", &open, modalFlags)) { - ImGui::Text("Nostalgia Studio - dev build"); + ImGui::Text("%s", m_text.c_str()); ImGui::NewLine(); ImGui::Dummy(ImVec2(148.0f, 0.0f)); ImGui::SameLine(); @@ -53,5 +55,3 @@ void AboutPopup::draw(turbine::Context *ctx) noexcept { } } } - -} diff --git a/src/nostalgia/studio/aboutpopup.hpp b/src/studio/applib/src/aboutpopup.hpp similarity index 83% rename from src/nostalgia/studio/aboutpopup.hpp rename to src/studio/applib/src/aboutpopup.hpp index 82e1f18e..8580a8d6 100644 --- a/src/nostalgia/studio/aboutpopup.hpp +++ b/src/studio/applib/src/aboutpopup.hpp @@ -9,9 +9,7 @@ #include -#include "lib/popup.hpp" - -namespace nostalgia { +#include class AboutPopup: public studio::Popup { public: @@ -23,8 +21,11 @@ class AboutPopup: public studio::Popup { private: Stage m_stage = Stage::Closed; + ox::String m_text; public: + explicit AboutPopup(turbine::Context &ctx) noexcept; + void open() noexcept override; void close() noexcept override; @@ -34,6 +35,4 @@ class AboutPopup: public studio::Popup { void draw(turbine::Context *ctx) noexcept override; -}; - -} +}; \ No newline at end of file diff --git a/src/nostalgia/studio/builtinmodules.hpp b/src/studio/applib/src/builtinmodules.hpp similarity index 75% rename from src/nostalgia/studio/builtinmodules.hpp rename to src/studio/applib/src/builtinmodules.hpp index 0b937d46..b4228c9e 100644 --- a/src/nostalgia/studio/builtinmodules.hpp +++ b/src/studio/applib/src/builtinmodules.hpp @@ -4,12 +4,8 @@ #pragma once -#include "lib/module.hpp" +#include #include -namespace nostalgia { - -extern ox::Vector()>> BuiltinModules; - -} \ No newline at end of file +extern ox::Vector()>> BuiltinModules; \ No newline at end of file diff --git a/src/nostalgia/studio/clawviewer.cpp b/src/studio/applib/src/clawviewer.cpp similarity index 99% rename from src/nostalgia/studio/clawviewer.cpp rename to src/studio/applib/src/clawviewer.cpp index ff0b77b4..f88a9279 100644 --- a/src/nostalgia/studio/clawviewer.cpp +++ b/src/studio/applib/src/clawviewer.cpp @@ -6,8 +6,6 @@ #include "clawviewer.hpp" -namespace nostalgia { - ClawEditor::ClawEditor(ox::CRStringView path, ox::ModelObject obj) noexcept: m_itemName(path), m_itemDisplayName(pathToItemName(path)), @@ -181,6 +179,4 @@ void ClawEditor::drawTree(ObjPath *path, const ox::ModelObject &obj) noexcept { } path->pop_back(); } -} - } \ No newline at end of file diff --git a/src/nostalgia/studio/clawviewer.hpp b/src/studio/applib/src/clawviewer.hpp similarity index 94% rename from src/nostalgia/studio/clawviewer.hpp rename to src/studio/applib/src/clawviewer.hpp index 30d8edc6..a136f49b 100644 --- a/src/nostalgia/studio/clawviewer.hpp +++ b/src/studio/applib/src/clawviewer.hpp @@ -7,9 +7,7 @@ #include #include -#include "lib/editor.hpp" - -namespace nostalgia { +#include class ClawEditor: public studio::Editor { private: @@ -37,4 +35,3 @@ class ClawEditor: public studio::Editor { void drawTree(ObjPath *path, const ox::ModelObject &obj) noexcept; }; -} diff --git a/src/nostalgia/studio/filedialogmanager.cpp b/src/studio/applib/src/filedialogmanager.cpp similarity index 89% rename from src/nostalgia/studio/filedialogmanager.cpp rename to src/studio/applib/src/filedialogmanager.cpp index 6eb23329..3cc88f98 100644 --- a/src/nostalgia/studio/filedialogmanager.cpp +++ b/src/studio/applib/src/filedialogmanager.cpp @@ -6,8 +6,6 @@ #include "filedialogmanager.hpp" -namespace nostalgia { - studio::TaskState FileDialogManager::update(turbine::Context *ctx) noexcept { switch (m_state) { case UpdateProjectPathState::EnableSystemCursor: { @@ -26,12 +24,11 @@ studio::TaskState FileDialogManager::update(turbine::Context *ctx) noexcept { oxAssert(err, "Path chosen response failed"); } m_state = UpdateProjectPathState::None; - return nostalgia::studio::TaskState::Done; + return studio::TaskState::Done; } case UpdateProjectPathState::None: break; } - return nostalgia::studio::TaskState::Running; + return studio::TaskState::Running; } -} diff --git a/src/nostalgia/studio/filedialogmanager.hpp b/src/studio/applib/src/filedialogmanager.hpp similarity index 75% rename from src/nostalgia/studio/filedialogmanager.hpp rename to src/studio/applib/src/filedialogmanager.hpp index be13067f..82ba309f 100644 --- a/src/nostalgia/studio/filedialogmanager.hpp +++ b/src/studio/applib/src/filedialogmanager.hpp @@ -9,12 +9,10 @@ #include -#include "lib/filedialog.hpp" -#include "lib/task.hpp" +#include +#include -namespace nostalgia { - -class FileDialogManager : public nostalgia::studio::Task { +class FileDialogManager : public studio::Task { private: enum class UpdateProjectPathState { None, @@ -33,11 +31,9 @@ class FileDialogManager : public nostalgia::studio::Task { ~FileDialogManager() noexcept override = default; - nostalgia::studio::TaskState update(turbine::Context *ctx) noexcept final; + studio::TaskState update(turbine::Context *ctx) noexcept final; // signals ox::Signal pathChosen; -}; - -} \ No newline at end of file +}; \ No newline at end of file diff --git a/src/studio/applib/src/main.cpp b/src/studio/applib/src/main.cpp new file mode 100644 index 00000000..735f6b9f --- /dev/null +++ b/src/studio/applib/src/main.cpp @@ -0,0 +1,91 @@ +/* + * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. + */ + +#include + +#include +#include +#include +#include +#include + +#include + +#include +#include "studioapp.hpp" + +class StudioUIDrawer: public turbine::gl::Drawer { + private: + StudioUI *m_ui = nullptr; + public: + explicit StudioUIDrawer(StudioUI *ui) noexcept: m_ui(ui) { + } + protected: + void draw(turbine::Context&) noexcept final { + m_ui->draw(); + } +}; + +static int updateHandler(turbine::Context &ctx) noexcept { + auto sctx = turbine::applicationData(ctx); + auto ui = dynamic_cast(sctx->ui); + ui->update(); + return 16; +} + +static void keyEventHandler(turbine::Context &ctx, turbine::Key key, bool down) noexcept { + auto sctx = turbine::applicationData(ctx); + auto ui = dynamic_cast(sctx->ui); + ui->handleKeyEvent(key, down); +} + +static ox::Error runApp( + ox::CRStringView appName, + ox::String projectDataDir, + ox::UniquePtr fs) noexcept { + oxRequireM(ctx, turbine::init(std::move(fs), appName)); + turbine::setWindowTitle(*ctx, ctx->appName); + turbine::setUpdateHandler(*ctx, updateHandler); + turbine::setKeyEventHandler(*ctx, keyEventHandler); + turbine::setConstantRefresh(*ctx, false); + studio::StudioContext studioCtx; + turbine::setApplicationData(*ctx, &studioCtx); + StudioUI ui(ctx.get(), std::move(projectDataDir)); + studioCtx.ui = &ui; + StudioUIDrawer drawer(&ui); + turbine::gl::addDrawer(*ctx, &drawer); + const auto err = turbine::run(*ctx); + turbine::gl::removeDrawer(*ctx, &drawer); + return err; +} + +namespace studio { + +int main( + const char *appName, + ox::String projectDataDir, + [[maybe_unused]] int argc, + [[maybe_unused]] const char **argv) { +#ifdef DEBUG + ox::LoggerConn loggerConn; + const auto loggerErr = loggerConn.initConn(appName); + if (loggerErr) { + oxErrf("Could not connect to logger: {}\n", toStr(loggerErr)); + } else { + ox::trace::setLogger(&loggerConn); + } +#endif + ox::trace::init(); + // run app + const auto time = std::time(nullptr); + ox::UUID::seedGenerator({ + static_cast(time), + static_cast(time << 1) + }); + const auto err = runApp(appName, std::move(projectDataDir), ox::UniquePtr(nullptr)); + oxAssert(err, "Something went wrong..."); + return static_cast(err); +} + +} \ No newline at end of file diff --git a/src/nostalgia/studio/newmenu.cpp b/src/studio/applib/src/newmenu.cpp similarity index 97% rename from src/nostalgia/studio/newmenu.cpp rename to src/studio/applib/src/newmenu.cpp index f6ec475b..dd3b6111 100644 --- a/src/nostalgia/studio/newmenu.cpp +++ b/src/studio/applib/src/newmenu.cpp @@ -4,13 +4,11 @@ #include -#include "lib/context.hpp" -#include "lib/imguiuitl.hpp" +#include +#include #include "newmenu.hpp" -namespace nostalgia { - NewMenu::NewMenu() noexcept { setTitle("New Item"); setSize({225, 110}); @@ -117,5 +115,3 @@ void NewMenu::finish(turbine::Context *ctx) noexcept { finished.emit(""); m_stage = Stage::Closed; } - -} diff --git a/src/nostalgia/studio/newmenu.hpp b/src/studio/applib/src/newmenu.hpp similarity index 96% rename from src/nostalgia/studio/newmenu.hpp rename to src/studio/applib/src/newmenu.hpp index d3197e5c..942a674b 100644 --- a/src/nostalgia/studio/newmenu.hpp +++ b/src/studio/applib/src/newmenu.hpp @@ -8,10 +8,8 @@ #include #include -#include "lib/itemmaker.hpp" -#include "lib/popup.hpp" - -namespace nostalgia { +#include +#include class NewMenu: public studio::Popup { public: @@ -75,5 +73,3 @@ template void NewMenu::addItemType(ox::String displayName, ox::String parentDir, ox::String fileExt, ox::ClawFormat pFmt) noexcept { m_types.emplace_back(ox::make>(std::move(displayName), std::move(parentDir), std::move(fileExt), pFmt)); } - -} diff --git a/src/nostalgia/studio/projectexplorer.cpp b/src/studio/applib/src/projectexplorer.cpp similarity index 98% rename from src/nostalgia/studio/projectexplorer.cpp rename to src/studio/applib/src/projectexplorer.cpp index d652ac3f..8b271ded 100644 --- a/src/nostalgia/studio/projectexplorer.cpp +++ b/src/studio/applib/src/projectexplorer.cpp @@ -8,8 +8,6 @@ #include "projectexplorer.hpp" -namespace nostalgia { - static ox::Result> buildProjectTreeModel(ProjectExplorer *explorer, ox::CRStringView name, ox::CRStringView path, ProjectTreeModel *parent) noexcept { const auto fs = explorer->romFs(); @@ -61,6 +59,3 @@ ox::Error ProjectExplorer::refreshProjectTreeModel(ox::CRStringView) noexcept { setModel(std::move(model)); return OxError(0); } - -} - diff --git a/src/nostalgia/studio/projectexplorer.hpp b/src/studio/applib/src/projectexplorer.hpp similarity index 93% rename from src/nostalgia/studio/projectexplorer.hpp rename to src/studio/applib/src/projectexplorer.hpp index b98e8382..df25f0d9 100644 --- a/src/nostalgia/studio/projectexplorer.hpp +++ b/src/studio/applib/src/projectexplorer.hpp @@ -7,11 +7,9 @@ #include #include -#include "lib/widget.hpp" +#include #include "projecttreemodel.hpp" -namespace nostalgia { - class ProjectExplorer: public studio::Widget { private: ox::UniquePtr m_treeModel; @@ -33,6 +31,4 @@ class ProjectExplorer: public studio::Widget { // slots public: ox::Signal fileChosen; -}; - -} \ No newline at end of file +}; \ No newline at end of file diff --git a/src/nostalgia/studio/projecttreemodel.cpp b/src/studio/applib/src/projecttreemodel.cpp similarity index 98% rename from src/nostalgia/studio/projecttreemodel.cpp rename to src/studio/applib/src/projecttreemodel.cpp index c41d20c5..cf0d6106 100644 --- a/src/nostalgia/studio/projecttreemodel.cpp +++ b/src/studio/applib/src/projecttreemodel.cpp @@ -7,8 +7,6 @@ #include "projectexplorer.hpp" #include "projecttreemodel.hpp" -namespace nostalgia { - ProjectTreeModel::ProjectTreeModel(ProjectExplorer *explorer, ox::String name, ProjectTreeModel *parent) noexcept: m_explorer(explorer), @@ -53,6 +51,4 @@ ox::BasicString<255> ProjectTreeModel::fullPath() const noexcept { return m_parent->fullPath() + "/" + ox::StringView(m_name); } return ""; -} - } \ No newline at end of file diff --git a/src/nostalgia/studio/projecttreemodel.hpp b/src/studio/applib/src/projecttreemodel.hpp similarity index 96% rename from src/nostalgia/studio/projecttreemodel.hpp rename to src/studio/applib/src/projecttreemodel.hpp index bf70b853..a8290592 100644 --- a/src/nostalgia/studio/projecttreemodel.hpp +++ b/src/studio/applib/src/projecttreemodel.hpp @@ -9,8 +9,6 @@ #include -namespace nostalgia { - class ProjectTreeModel { private: class ProjectExplorer *m_explorer = nullptr; @@ -30,6 +28,4 @@ class ProjectTreeModel { private: [[nodiscard]] ox::BasicString<255> fullPath() const noexcept; -}; - -} \ No newline at end of file +}; \ No newline at end of file diff --git a/src/nostalgia/studio/studioapp.cpp b/src/studio/applib/src/studioapp.cpp similarity index 95% rename from src/nostalgia/studio/studioapp.cpp rename to src/studio/applib/src/studioapp.cpp index 0fdf1b15..8dc62bff 100644 --- a/src/nostalgia/studio/studioapp.cpp +++ b/src/studio/applib/src/studioapp.cpp @@ -7,16 +7,14 @@ #include #include -#include "lib/configio.hpp" +#include #include "builtinmodules.hpp" #include "clawviewer.hpp" #include "filedialogmanager.hpp" #include "studioapp.hpp" -namespace nostalgia { - struct StudioConfig { - static constexpr auto TypeName = "net.drinkingtea.nostalgia.studio.StudioConfig"; + static constexpr auto TypeName = "net.drinkingtea.studio.StudioConfig"; static constexpr auto TypeVersion = 1; ox::String projectPath; ox::String activeTabItemName; @@ -31,9 +29,11 @@ oxModelBegin(StudioConfig) oxModelFieldRename(show_project_explorer, showProjectExplorer) oxModelEnd() -StudioUI::StudioUI(turbine::Context *ctx) noexcept { - m_ctx = ctx; - m_projectExplorer = ox::make_unique(m_ctx); +StudioUI::StudioUI(turbine::Context *ctx, ox::String projectDir) noexcept: + m_ctx(ctx), + m_projectDir(std::move(projectDir)), + m_projectExplorer(ox::make_unique(m_ctx)), + m_aboutPopup(*ctx) { m_projectExplorer->fileChosen.connect(this, &StudioUI::openFile); ImGui::GetIO().IniFilename = nullptr; loadModules(); @@ -292,8 +292,8 @@ void StudioUI::save() noexcept { ox::Error StudioUI::openProject(ox::CRStringView path) noexcept { oxRequireM(fs, keel::loadRomFs(path)); oxReturnError(keel::setRomFs(m_ctx, std::move(fs))); - turbine::setWindowTitle(*m_ctx, ox::sfmt("Nostalgia Studio - {}", path)); - m_project = ox::make_unique(m_ctx, path); + turbine::setWindowTitle(*m_ctx, ox::sfmt("{} - {}", m_ctx->appName, path)); + m_project = ox::make_unique(m_ctx, path, m_projectDir); auto sctx = applicationData(*m_ctx); sctx->project = m_project.get(); m_project->fileAdded.connect(m_projectExplorer.get(), &ProjectExplorer::refreshProjectTreeModel); @@ -355,7 +355,7 @@ ox::Error StudioUI::openFileActiveTab(ox::CRStringView path, bool makeActiveTab) config->openFiles.emplace_back(path); } }); - return OxError(0); + return {}; } ox::Error StudioUI::closeFile(const ox::String &path) noexcept { @@ -369,5 +369,3 @@ ox::Error StudioUI::closeFile(const ox::String &path) noexcept { }); return OxError(0); } - -} diff --git a/src/nostalgia/studio/studioapp.hpp b/src/studio/applib/src/studioapp.hpp similarity index 84% rename from src/nostalgia/studio/studioapp.hpp rename to src/studio/applib/src/studioapp.hpp index 2b74bc01..e63059ab 100644 --- a/src/nostalgia/studio/studioapp.hpp +++ b/src/studio/applib/src/studioapp.hpp @@ -8,24 +8,23 @@ #include #include -#include "lib/editor.hpp" -#include "lib/module.hpp" -#include "lib/project.hpp" -#include "lib/task.hpp" +#include +#include +#include +#include #include "aboutpopup.hpp" #include "newmenu.hpp" #include "projectexplorer.hpp" #include "projecttreemodel.hpp" -namespace nostalgia { - class StudioUI: public ox::SignalHandler { friend class StudioUIDrawer; private: + turbine::Context *m_ctx = nullptr; + ox::String m_projectDir; ox::UniquePtr m_project; studio::TaskRunner m_taskRunner; - turbine::Context *m_ctx = nullptr; ox::Vector> m_editors; ox::Vector> m_widgets; ox::HashMap m_editorMakers; @@ -43,7 +42,7 @@ class StudioUI: public ox::SignalHandler { bool m_showProjectExplorer = true; public: - explicit StudioUI(turbine::Context *ctx) noexcept; + explicit StudioUI(turbine::Context *ctx, ox::String projectDir) noexcept; void update() noexcept; @@ -87,4 +86,12 @@ class StudioUI: public ox::SignalHandler { ox::Error closeFile(const ox::String &path) noexcept; }; +namespace studio { + +int main( + const char *appName, + ox::String projectDataDir, + [[maybe_unused]] int argc, + [[maybe_unused]] const char **argv); + } diff --git a/src/studio/modlib/CMakeLists.txt b/src/studio/modlib/CMakeLists.txt new file mode 100644 index 00000000..febd4f0a --- /dev/null +++ b/src/studio/modlib/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(src) diff --git a/src/nostalgia/studio/lib/configio.hpp b/src/studio/modlib/include/studio/configio.hpp similarity index 96% rename from src/nostalgia/studio/lib/configio.hpp rename to src/studio/modlib/include/studio/configio.hpp index 86ecebc2..bb9822c5 100644 --- a/src/nostalgia/studio/lib/configio.hpp +++ b/src/studio/modlib/include/studio/configio.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved. + * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once @@ -15,7 +15,7 @@ #include -namespace nostalgia::studio { +namespace studio { [[nodiscard]] ox::String configPath(const keel::Context *ctx) noexcept; diff --git a/src/nostalgia/studio/lib/context.hpp b/src/studio/modlib/include/studio/context.hpp similarity index 66% rename from src/nostalgia/studio/lib/context.hpp rename to src/studio/modlib/include/studio/context.hpp index 93754d11..a7611d31 100644 --- a/src/nostalgia/studio/lib/context.hpp +++ b/src/studio/modlib/include/studio/context.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved. + * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once @@ -8,7 +8,7 @@ #include "project.hpp" -namespace nostalgia::studio { +namespace studio { struct StudioContext { ox::SignalHandler *ui = nullptr; diff --git a/src/nostalgia/studio/lib/editor.hpp b/src/studio/modlib/include/studio/editor.hpp similarity index 94% rename from src/nostalgia/studio/lib/editor.hpp rename to src/studio/modlib/include/studio/editor.hpp index e083300a..2787cd6f 100644 --- a/src/nostalgia/studio/lib/editor.hpp +++ b/src/studio/modlib/include/studio/editor.hpp @@ -9,15 +9,11 @@ #include "undostack.hpp" #include "widget.hpp" -#include "nostalgiastudio_export.h" - -namespace nostalgia { class StudioUI; -} -namespace nostalgia::studio { +namespace studio { -class NOSTALGIASTUDIO_EXPORT BaseEditor: public Widget { +class BaseEditor: public Widget { friend StudioUI; diff --git a/src/nostalgia/studio/lib/filedialog.hpp b/src/studio/modlib/include/studio/filedialog.hpp similarity index 83% rename from src/nostalgia/studio/lib/filedialog.hpp rename to src/studio/modlib/include/studio/filedialog.hpp index 41410172..b1e805a4 100644 --- a/src/nostalgia/studio/lib/filedialog.hpp +++ b/src/studio/modlib/include/studio/filedialog.hpp @@ -1,12 +1,12 @@ /* - * Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved. + * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once #include -namespace nostalgia::studio { +namespace studio { struct FDFilterItem { #ifdef OX_OS_Windows diff --git a/src/nostalgia/studio/lib/imguiuitl.hpp b/src/studio/modlib/include/studio/imguiuitl.hpp similarity index 85% rename from src/nostalgia/studio/lib/imguiuitl.hpp rename to src/studio/modlib/include/studio/imguiuitl.hpp index 797db670..edeed509 100644 --- a/src/nostalgia/studio/lib/imguiuitl.hpp +++ b/src/studio/modlib/include/studio/imguiuitl.hpp @@ -6,7 +6,7 @@ #include -namespace nostalgia::studio::ig { +namespace studio::ig { void centerNextWindow(turbine::Context *ctx) noexcept; diff --git a/src/nostalgia/studio/lib/itemmaker.hpp b/src/studio/modlib/include/studio/itemmaker.hpp similarity index 98% rename from src/nostalgia/studio/lib/itemmaker.hpp rename to src/studio/modlib/include/studio/itemmaker.hpp index 52eb8599..52c02c7d 100644 --- a/src/nostalgia/studio/lib/itemmaker.hpp +++ b/src/studio/modlib/include/studio/itemmaker.hpp @@ -11,7 +11,7 @@ #include "context.hpp" -namespace nostalgia::studio { +namespace studio { class ItemMaker { public: diff --git a/src/nostalgia/studio/lib/module.hpp b/src/studio/modlib/include/studio/module.hpp similarity index 80% rename from src/nostalgia/studio/lib/module.hpp rename to src/studio/modlib/include/studio/module.hpp index c509d8ea..3688c3cd 100644 --- a/src/nostalgia/studio/lib/module.hpp +++ b/src/studio/modlib/include/studio/module.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved. + * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once @@ -11,9 +11,7 @@ #include -#include - -namespace nostalgia::studio { +namespace studio { class ItemMaker; diff --git a/src/nostalgia/studio/lib/popup.hpp b/src/studio/modlib/include/studio/popup.hpp similarity index 97% rename from src/nostalgia/studio/lib/popup.hpp rename to src/studio/modlib/include/studio/popup.hpp index f16a42dc..9f7a2f8e 100644 --- a/src/nostalgia/studio/lib/popup.hpp +++ b/src/studio/modlib/include/studio/popup.hpp @@ -12,7 +12,7 @@ #include "imguiuitl.hpp" -namespace nostalgia::studio { +namespace studio { class Popup { diff --git a/src/nostalgia/studio/lib/project.hpp b/src/studio/modlib/include/studio/project.hpp similarity index 95% rename from src/nostalgia/studio/lib/project.hpp rename to src/studio/modlib/include/studio/project.hpp index befe0310..12583ae3 100644 --- a/src/nostalgia/studio/lib/project.hpp +++ b/src/studio/modlib/include/studio/project.hpp @@ -15,9 +15,7 @@ #include #include -#include "nostalgiastudio_export.h" - -namespace nostalgia::studio { +namespace studio { enum class ProjectEvent { None, @@ -38,16 +36,17 @@ constexpr ox::Result fileExt(ox::CRStringView path) noexcept { return path.substr(extStart + 1); } -class NOSTALGIASTUDIO_EXPORT Project { +class Project { private: + keel::Context *m_ctx = nullptr; ox::String m_path; + ox::String m_projectDataDir; mutable keel::TypeStore m_typeStore; mutable ox::FileSystem *m_fs = nullptr; - keel::Context *m_ctx = nullptr; ox::HashMap> m_fileExtFileMap; public: - explicit Project(keel::Context *ctx, ox::String path) noexcept; + explicit Project(keel::Context *ctx, ox::String path, ox::CRStringView projectDir) noexcept; ox::Error create() noexcept; @@ -113,7 +112,7 @@ ox::Error Project::writeObj(const ox::String &path, const T *obj, ox::ClawFormat oxReturnError(ox::buildTypeDef(&m_typeStore, obj)); } // write out type store - static constexpr auto descPath = "/.nostalgia/type_descriptors"; + const auto descPath = ox::sfmt("/.{}/type_descriptors", m_projectDataDir); oxReturnError(mkdir(descPath)); for (const auto &t : m_typeStore.typeList()) { oxRequireM(typeOut, ox::writeClaw(t, ox::ClawFormat::Organic)); diff --git a/src/studio/modlib/include/studio/studio.hpp b/src/studio/modlib/include/studio/studio.hpp new file mode 100644 index 00000000..cc2fd34a --- /dev/null +++ b/src/studio/modlib/include/studio/studio.hpp @@ -0,0 +1,17 @@ +/* + * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/src/nostalgia/studio/lib/task.hpp b/src/studio/modlib/include/studio/task.hpp similarity index 84% rename from src/nostalgia/studio/lib/task.hpp rename to src/studio/modlib/include/studio/task.hpp index 5810c570..1da1575d 100644 --- a/src/nostalgia/studio/lib/task.hpp +++ b/src/studio/modlib/include/studio/task.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved. + * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once @@ -8,7 +8,7 @@ #include -namespace nostalgia::studio { +namespace studio { enum class TaskState { Running, diff --git a/src/nostalgia/studio/lib/undostack.hpp b/src/studio/modlib/include/studio/undostack.hpp similarity index 91% rename from src/nostalgia/studio/lib/undostack.hpp rename to src/studio/modlib/include/studio/undostack.hpp index 9de48142..55234ac0 100644 --- a/src/nostalgia/studio/lib/undostack.hpp +++ b/src/studio/modlib/include/studio/undostack.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved. + * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once @@ -9,7 +9,7 @@ #include #include -namespace nostalgia::studio { +namespace studio { class UndoCommand { public: diff --git a/src/nostalgia/studio/lib/widget.hpp b/src/studio/modlib/include/studio/widget.hpp similarity index 73% rename from src/nostalgia/studio/lib/widget.hpp rename to src/studio/modlib/include/studio/widget.hpp index 3f13aac4..ec571ecb 100644 --- a/src/nostalgia/studio/lib/widget.hpp +++ b/src/studio/modlib/include/studio/widget.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved. + * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once @@ -8,7 +8,7 @@ #include -namespace nostalgia::studio { +namespace studio { class Widget: public ox::SignalHandler { public: diff --git a/src/studio/modlib/src/CMakeLists.txt b/src/studio/modlib/src/CMakeLists.txt new file mode 100644 index 00000000..2419535c --- /dev/null +++ b/src/studio/modlib/src/CMakeLists.txt @@ -0,0 +1,60 @@ +add_library( + Studio + configio.cpp + editor.cpp + imguiutil.cpp + module.cpp + popup.cpp + project.cpp + task.cpp + undostack.cpp + widget.cpp + filedialog_nfd.cpp +) + +if(NOT MSVC) + target_compile_options(Studio PUBLIC -Wsign-conversion) +endif() + +install( + TARGETS + Studio + DESTINATION + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib +) + +target_include_directories( + Studio PUBLIC + ../include +) + +include_directories( + SYSTEM + ${GTK3_INCLUDE_DIRS} +) + +target_link_libraries( + Studio PUBLIC + nfd + OxEvent + Turbine +) + +install( + FILES + ../include/studio/configio.hpp + ../include/studio/context.hpp + ../include/studio/editor.hpp + ../include/studio/filedialog.hpp + ../include/studio/itemmaker.hpp + ../include/studio/module.hpp + ../include/studio/popup.hpp + ../include/studio/project.hpp + ../include/studio/studio.hpp + ../include/studio/task.hpp + ../include/studio/undostack.hpp + ../include/studio/widget.hpp + DESTINATION + include/studio/ +) diff --git a/src/nostalgia/studio/lib/configio.cpp b/src/studio/modlib/src/configio.cpp similarity index 84% rename from src/nostalgia/studio/lib/configio.cpp rename to src/studio/modlib/src/configio.cpp index 50554ee9..589c212b 100644 --- a/src/nostalgia/studio/lib/configio.cpp +++ b/src/studio/modlib/src/configio.cpp @@ -1,10 +1,10 @@ /* - * Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved. + * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. */ -#include "configio.hpp" +#include -namespace nostalgia::studio { +namespace studio { constexpr auto ConfigDir = [] { switch (ox::defines::OS) { diff --git a/src/nostalgia/studio/lib/editor.cpp b/src/studio/modlib/src/editor.cpp similarity index 97% rename from src/nostalgia/studio/lib/editor.cpp rename to src/studio/modlib/src/editor.cpp index 3d4b1bc2..8fadb13b 100644 --- a/src/nostalgia/studio/lib/editor.cpp +++ b/src/studio/modlib/src/editor.cpp @@ -6,9 +6,9 @@ #include -#include "editor.hpp" +#include -namespace nostalgia::studio { +namespace studio { const ox::String &BaseEditor::itemDisplayName() const noexcept { return itemName(); diff --git a/src/nostalgia/studio/lib/filedialog_nfd.cpp b/src/studio/modlib/src/filedialog_nfd.cpp similarity index 91% rename from src/nostalgia/studio/lib/filedialog_nfd.cpp rename to src/studio/modlib/src/filedialog_nfd.cpp index a5d18fae..363cca2a 100644 --- a/src/nostalgia/studio/lib/filedialog_nfd.cpp +++ b/src/studio/modlib/src/filedialog_nfd.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved. + * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include @@ -7,9 +7,9 @@ #include #include -#include "filedialog.hpp" +#include -namespace nostalgia::studio { +namespace studio { FDFilterItem::FDFilterItem(ox::CRStringView pName, ox::CRStringView pSpec) noexcept { name.resize(pName.len() + 1); diff --git a/src/nostalgia/studio/lib/imguiutil.cpp b/src/studio/modlib/src/imguiutil.cpp similarity index 81% rename from src/nostalgia/studio/lib/imguiutil.cpp rename to src/studio/modlib/src/imguiutil.cpp index 316f88d9..abe402e2 100644 --- a/src/nostalgia/studio/lib/imguiutil.cpp +++ b/src/studio/modlib/src/imguiutil.cpp @@ -1,12 +1,12 @@ /* - * Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved. + * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include #include -namespace nostalgia::studio::ig { +namespace studio::ig { void centerNextWindow(turbine::Context *ctx) noexcept { const auto sz = turbine::getScreenSize(*ctx); diff --git a/src/nostalgia/studio/lib/module.cpp b/src/studio/modlib/src/module.cpp similarity index 63% rename from src/nostalgia/studio/lib/module.cpp rename to src/studio/modlib/src/module.cpp index 07657e07..c733a627 100644 --- a/src/nostalgia/studio/lib/module.cpp +++ b/src/studio/modlib/src/module.cpp @@ -1,10 +1,10 @@ /* - * Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved. + * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. */ -#include "module.hpp" +#include -namespace nostalgia::studio { +namespace studio { ox::Vector Module::editors(turbine::Context*) { return {}; diff --git a/src/studio/modlib/src/popup.cpp b/src/studio/modlib/src/popup.cpp new file mode 100644 index 00000000..357ca17a --- /dev/null +++ b/src/studio/modlib/src/popup.cpp @@ -0,0 +1,7 @@ +/* + * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. + */ + +namespace studio { + +} \ No newline at end of file diff --git a/src/nostalgia/studio/lib/project.cpp b/src/studio/modlib/src/project.cpp similarity index 87% rename from src/nostalgia/studio/lib/project.cpp rename to src/studio/modlib/src/project.cpp index 1ca4327d..2f12e8f8 100644 --- a/src/nostalgia/studio/lib/project.cpp +++ b/src/studio/modlib/src/project.cpp @@ -9,9 +9,9 @@ #include -#include "project.hpp" +#include -namespace nostalgia::studio { +namespace studio { static void generateTypes(ox::TypeStore *ts) noexcept { for (const auto mod : keel::modules()) { @@ -21,12 +21,13 @@ static void generateTypes(ox::TypeStore *ts) noexcept { } } -Project::Project(keel::Context *ctx, ox::String path) noexcept: - m_path(std::move(path)), - m_typeStore(ctx->rom.get(), "/.nostalgia/type_descriptors"), - m_fs(ctx->rom.get()), - m_ctx(ctx) { - oxTracef("nostalgia::studio", "Project: {}", m_path); +Project::Project(keel::Context *ctx, ox::String path, ox::CRStringView projectDataDir) noexcept: + m_ctx(ctx), + m_path(path), + m_projectDataDir(projectDataDir), + m_typeStore(ctx->rom.get(), ox::sfmt("/.{}/type_descriptors", projectDataDir)), + m_fs(ctx->rom.get()) { + oxTracef("studio", "Project: {}", m_path); generateTypes(&m_typeStore); buildFileIndex(); } @@ -68,7 +69,7 @@ void Project::buildFileIndex() noexcept { m_fileExtFileMap.clear(); std::sort(files.begin(), files.end()); for (const auto &file : files) { - if (!beginsWith(file, "/.nostalgia/")) { + if (!beginsWith(file, ox::sfmt("/.{}/", m_projectDataDir))) { indexFile(file); } } diff --git a/src/nostalgia/studio/lib/task.cpp b/src/studio/modlib/src/task.cpp similarity index 78% rename from src/nostalgia/studio/lib/task.cpp rename to src/studio/modlib/src/task.cpp index 84c8f921..d57e3290 100644 --- a/src/nostalgia/studio/lib/task.cpp +++ b/src/studio/modlib/src/task.cpp @@ -1,12 +1,12 @@ /* - * Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved. + * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include -#include "task.hpp" +#include -namespace nostalgia::studio { +namespace studio { void TaskRunner::update(turbine::Context *ctx) noexcept { oxIgnoreError(m_tasks.erase(std::remove_if(m_tasks.begin(), m_tasks.end(), [&](ox::UPtr &t) { diff --git a/src/nostalgia/studio/lib/undostack.cpp b/src/studio/modlib/src/undostack.cpp similarity index 87% rename from src/nostalgia/studio/lib/undostack.cpp rename to src/studio/modlib/src/undostack.cpp index 17c71c61..1032227d 100644 --- a/src/nostalgia/studio/lib/undostack.cpp +++ b/src/studio/modlib/src/undostack.cpp @@ -1,10 +1,10 @@ /* - * Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved. + * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. */ -#include "undostack.hpp" +#include -namespace nostalgia::studio { +namespace studio { bool UndoCommand::mergeWith(const UndoCommand*) noexcept { return false; diff --git a/src/studio/modlib/src/widget.cpp b/src/studio/modlib/src/widget.cpp new file mode 100644 index 00000000..fa5f8607 --- /dev/null +++ b/src/studio/modlib/src/widget.cpp @@ -0,0 +1,9 @@ +/* + * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. + */ + +#include + +namespace studio { + +} \ No newline at end of file