diff --git a/src/keel/CMakeLists.txt b/src/keel/CMakeLists.txt index bed781ca..ce01e383 100644 --- a/src/keel/CMakeLists.txt +++ b/src/keel/CMakeLists.txt @@ -6,6 +6,7 @@ add_library( module.cpp pack.cpp typeconv.cpp + typestore.cpp ) target_link_libraries( @@ -28,6 +29,7 @@ install( module.hpp pack.hpp typeconv.hpp + typestore.hpp DESTINATION include/keel ) diff --git a/src/keel/keel.hpp b/src/keel/keel.hpp index ab048e12..68017b62 100644 --- a/src/keel/keel.hpp +++ b/src/keel/keel.hpp @@ -10,6 +10,7 @@ #include "media.hpp" #include "module.hpp" #include "pack.hpp" +#include "typestore.hpp" namespace keel { diff --git a/src/nostalgia/core/typestore.cpp b/src/keel/typestore.cpp similarity index 74% rename from src/nostalgia/core/typestore.cpp rename to src/keel/typestore.cpp index d61e0f85..9fdd799f 100644 --- a/src/nostalgia/core/typestore.cpp +++ b/src/keel/typestore.cpp @@ -4,11 +4,10 @@ #include "typestore.hpp" -namespace nostalgia::core { +namespace keel { ox::Result<ox::UniquePtr<ox::DescriptorType>> TypeStore::loadDescriptor(ox::CRStringView typeId) noexcept { - constexpr auto descPath = "/.nostalgia/type_descriptors"; - auto path = ox::sfmt("{}/{}", descPath, typeId); + auto path = ox::sfmt("{}/{}", m_descPath, typeId); oxRequire(buff, m_fs->read(path)); auto dt = ox::make_unique<ox::DescriptorType>(); oxReturnError(ox::readClaw<ox::DescriptorType>(buff, dt.get())); diff --git a/src/nostalgia/core/typestore.hpp b/src/keel/typestore.hpp similarity index 67% rename from src/nostalgia/core/typestore.hpp rename to src/keel/typestore.hpp index 2ebf0c8e..1bacb743 100644 --- a/src/nostalgia/core/typestore.hpp +++ b/src/keel/typestore.hpp @@ -8,14 +8,17 @@ #include <ox/fs/fs.hpp> #include <ox/model/typestore.hpp> -namespace nostalgia::core { +namespace keel { class TypeStore: public ox::TypeStore { private: ox::FileSystem *m_fs = nullptr; + ox::String m_descPath; public: - constexpr explicit TypeStore(ox::FileSystem *fs) noexcept: m_fs(fs) { + constexpr explicit TypeStore(ox::FileSystem *fs, ox::String descPath = "/.keel/type_descriptors") noexcept: + m_fs(fs), + m_descPath(std::move(descPath)) { } protected: diff --git a/src/nostalgia/core/CMakeLists.txt b/src/nostalgia/core/CMakeLists.txt index 0c3948bb..034f5684 100644 --- a/src/nostalgia/core/CMakeLists.txt +++ b/src/nostalgia/core/CMakeLists.txt @@ -5,7 +5,6 @@ add_library( module.cpp tilesheet.cpp typeconv.cpp - typestore.cpp ) if(NOSTALGIA_BUILD_TYPE STREQUAL "GBA") @@ -40,7 +39,6 @@ install( ptidxconv.hpp tilesheet.hpp typeconv.hpp - typestore.hpp DESTINATION include/nostalgia/core ) diff --git a/src/nostalgia/studio/lib/project.cpp b/src/nostalgia/studio/lib/project.cpp index d99919c3..1ca4327d 100644 --- a/src/nostalgia/studio/lib/project.cpp +++ b/src/nostalgia/studio/lib/project.cpp @@ -23,7 +23,7 @@ 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()), + m_typeStore(ctx->rom.get(), "/.nostalgia/type_descriptors"), m_fs(ctx->rom.get()), m_ctx(ctx) { oxTracef("nostalgia::studio", "Project: {}", m_path); diff --git a/src/nostalgia/studio/lib/project.hpp b/src/nostalgia/studio/lib/project.hpp index 7fb157d3..befe0310 100644 --- a/src/nostalgia/studio/lib/project.hpp +++ b/src/nostalgia/studio/lib/project.hpp @@ -12,7 +12,7 @@ #include <ox/model/descwrite.hpp> #include <ox/std/hashmap.hpp> -#include <nostalgia/core/typestore.hpp> +#include <keel/typestore.hpp> #include <keel/media.hpp> #include "nostalgiastudio_export.h" @@ -41,7 +41,7 @@ constexpr ox::Result<ox::StringView> fileExt(ox::CRStringView path) noexcept { class NOSTALGIASTUDIO_EXPORT Project { private: ox::String m_path; - mutable core::TypeStore m_typeStore; + mutable keel::TypeStore m_typeStore; mutable ox::FileSystem *m_fs = nullptr; keel::Context *m_ctx = nullptr; ox::HashMap<ox::String, ox::Vector<ox::String>> m_fileExtFileMap; diff --git a/src/nostalgia/tools/pack.cpp b/src/nostalgia/tools/pack.cpp index baec38df..5c758f32 100644 --- a/src/nostalgia/tools/pack.cpp +++ b/src/nostalgia/tools/pack.cpp @@ -11,7 +11,6 @@ #include <keel/keel.hpp> #include <nostalgia/appmodules/appmodules.hpp> -#include <nostalgia/core/typestore.hpp> using namespace nostalgia; @@ -68,7 +67,7 @@ static ox::Error run(const ox::ClArgs &args) noexcept { oxReturnError(ox::FileSystem32::format(dstBuff.data(), dstBuff.size())); ox::FileSystem32 dst(ox::FileStore32(dstBuff.data(), dstBuff.size())); oxRequire(ctx, keel::init(ox::make_unique<ox::PassThroughFS>(argSrc), "nost-pack")); - core::TypeStore ts(ctx->rom.get()); + keel::TypeStore ts(ctx->rom.get(), "/.nostalgia/type_descriptors"); oxReturnError(generateTypes(&ts)); oxReturnError(keel::pack(ctx.get(), &ts, &dst)); oxRequireM(pl, keel::GbaPreloader::make());