[keel] Split out Nostalgia Foundation and Pack lib into Keel
This commit is contained in:
@@ -23,7 +23,7 @@ constexpr auto ConfigDir = [] {
|
||||
}
|
||||
}();
|
||||
|
||||
ox::String configPath(const foundation::Context *ctx) noexcept {
|
||||
ox::String configPath(const keel::Context *ctx) noexcept {
|
||||
const auto homeDir = std::getenv(ox::defines::OS == ox::OS::Windows ? "USERPROFILE" : "HOME");
|
||||
return ox::sfmt(ConfigDir, homeDir, ctx->appName);
|
||||
}
|
||||
|
@@ -18,10 +18,10 @@
|
||||
namespace nostalgia::studio {
|
||||
|
||||
[[nodiscard]]
|
||||
ox::String configPath(const foundation::Context *ctx) noexcept;
|
||||
ox::String configPath(const keel::Context *ctx) noexcept;
|
||||
|
||||
template<typename T>
|
||||
ox::Result<T> readConfig(foundation::Context *ctx, ox::CRStringView name) noexcept {
|
||||
ox::Result<T> readConfig(keel::Context *ctx, ox::CRStringView name) noexcept {
|
||||
oxAssert(name != "", "Config type has no TypeName");
|
||||
const auto path = ox::sfmt("/{}.json", name);
|
||||
ox::PassThroughFS fs(configPath(ctx));
|
||||
@@ -34,13 +34,13 @@ ox::Result<T> readConfig(foundation::Context *ctx, ox::CRStringView name) noexce
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
ox::Result<T> readConfig(foundation::Context *ctx) noexcept {
|
||||
ox::Result<T> readConfig(keel::Context *ctx) noexcept {
|
||||
constexpr auto TypeName = ox::requireModelTypeName<T>();
|
||||
return readConfig<T>(ctx, TypeName);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
ox::Error writeConfig(foundation::Context *ctx, ox::CRStringView name, T *data) noexcept {
|
||||
ox::Error writeConfig(keel::Context *ctx, ox::CRStringView name, T *data) noexcept {
|
||||
oxAssert(name != "", "Config type has no TypeName");
|
||||
const auto path = ox::sfmt("/{}.json", name);
|
||||
ox::PassThroughFS fs(configPath(ctx));
|
||||
@@ -58,13 +58,13 @@ ox::Error writeConfig(foundation::Context *ctx, ox::CRStringView name, T *data)
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
ox::Error writeConfig(foundation::Context *ctx, T *data) noexcept {
|
||||
ox::Error writeConfig(keel::Context *ctx, T *data) noexcept {
|
||||
constexpr auto TypeName = ox::requireModelTypeName<T>();
|
||||
return writeConfig(ctx, TypeName, data);
|
||||
}
|
||||
|
||||
template<typename T, typename Func>
|
||||
void openConfig(foundation::Context *ctx, const auto &name, Func f) noexcept {
|
||||
void openConfig(keel::Context *ctx, const auto &name, Func f) noexcept {
|
||||
oxAssert(name != "", "Config type has no TypeName");
|
||||
const auto [c, err] = readConfig<T>(ctx, name);
|
||||
oxLogError(err);
|
||||
@@ -72,13 +72,13 @@ void openConfig(foundation::Context *ctx, const auto &name, Func f) noexcept {
|
||||
}
|
||||
|
||||
template<typename T, typename Func>
|
||||
void openConfig(foundation::Context *ctx, Func f) noexcept {
|
||||
void openConfig(keel::Context *ctx, Func f) noexcept {
|
||||
constexpr auto TypeName = ox::requireModelTypeName<T>();
|
||||
openConfig<T>(ctx, TypeName, f);
|
||||
}
|
||||
|
||||
template<typename T, typename Func>
|
||||
void editConfig(foundation::Context *ctx, const auto &name, Func f) noexcept {
|
||||
void editConfig(keel::Context *ctx, const auto &name, Func f) noexcept {
|
||||
oxAssert(ox_strcmp(name, ""), "Config type has no TypeName");
|
||||
auto [c, err] = readConfig<T>(ctx, name);
|
||||
oxLogError(err);
|
||||
@@ -87,7 +87,7 @@ void editConfig(foundation::Context *ctx, const auto &name, Func f) noexcept {
|
||||
}
|
||||
|
||||
template<typename T, typename Func>
|
||||
void editConfig(foundation::Context *ctx, Func f) noexcept {
|
||||
void editConfig(keel::Context *ctx, Func f) noexcept {
|
||||
constexpr auto TypeName = ox::requireModelTypeName<T>();
|
||||
editConfig<T>(ctx, TypeName, f);
|
||||
}
|
||||
|
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <ox/claw/claw.hpp>
|
||||
|
||||
#include <nostalgia/foundation/media.hpp>
|
||||
#include <keel/media.hpp>
|
||||
#include <nostalgia/core/context.hpp>
|
||||
|
||||
#include "context.hpp"
|
||||
@@ -50,7 +50,7 @@ class ItemMakerT: public ItemMaker {
|
||||
ox::Error write(core::Context *ctx, ox::CRStringView pName) const noexcept override {
|
||||
const auto path = ox::sfmt("/{}/{}.{}", parentDir, pName, fileExt);
|
||||
auto sctx = core::applicationData<studio::StudioContext>(ctx);
|
||||
foundation::createUuidMapping(ctx, path, ox::UUID::generate().unwrap());
|
||||
keel::createUuidMapping(ctx, path, ox::UUID::generate().unwrap());
|
||||
return sctx->project->writeObj(path, &item, fmt);
|
||||
}
|
||||
};
|
||||
|
@@ -7,21 +7,21 @@
|
||||
|
||||
#include <ox/std/std.hpp>
|
||||
|
||||
#include <nostalgia/foundation/module.hpp>
|
||||
#include <keel/module.hpp>
|
||||
|
||||
#include "project.hpp"
|
||||
|
||||
namespace nostalgia::studio {
|
||||
|
||||
static void generateTypes(ox::TypeStore *ts) noexcept {
|
||||
for (const auto mod : foundation::modules()) {
|
||||
for (const auto mod : keel::modules()) {
|
||||
for (auto gen : mod->types()) {
|
||||
oxLogError(gen(ts));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Project::Project(foundation::Context *ctx, ox::String path) noexcept:
|
||||
Project::Project(keel::Context *ctx, ox::String path) noexcept:
|
||||
m_path(std::move(path)),
|
||||
m_typeStore(ctx->rom.get()),
|
||||
m_fs(ctx->rom.get()),
|
||||
@@ -89,7 +89,7 @@ ox::Error Project::writeBuff(const ox::StringView &path, const ox::Buffer &buff)
|
||||
ox::BufferWriter writer(&outBuff);
|
||||
const auto [uuid, err] = m_ctx->pathToUuid.at(path);
|
||||
if (!err) {
|
||||
oxReturnError(foundation::writeUuidHeader(&writer, *uuid));
|
||||
oxReturnError(keel::writeUuidHeader(&writer, *uuid));
|
||||
}
|
||||
oxReturnError(writer.write(buff.data(), buff.size()));
|
||||
const auto newFile = m_fs->stat(path).error != 0;
|
||||
|
@@ -13,7 +13,7 @@
|
||||
#include <ox/std/hashmap.hpp>
|
||||
|
||||
#include <nostalgia/core/typestore.hpp>
|
||||
#include <nostalgia/foundation/media.hpp>
|
||||
#include <keel/media.hpp>
|
||||
|
||||
#include "nostalgiastudio_export.h"
|
||||
|
||||
@@ -43,11 +43,11 @@ class NOSTALGIASTUDIO_EXPORT Project {
|
||||
ox::String m_path;
|
||||
mutable core::TypeStore m_typeStore;
|
||||
mutable ox::FileSystem *m_fs = nullptr;
|
||||
foundation::Context *m_ctx = nullptr;
|
||||
keel::Context *m_ctx = nullptr;
|
||||
ox::HashMap<ox::String, ox::Vector<ox::String>> m_fileExtFileMap;
|
||||
|
||||
public:
|
||||
explicit Project(foundation::Context *ctx, ox::String path) noexcept;
|
||||
explicit Project(keel::Context *ctx, ox::String path) noexcept;
|
||||
|
||||
ox::Error create() noexcept;
|
||||
|
||||
@@ -131,9 +131,9 @@ template<typename T>
|
||||
ox::Result<T> Project::loadObj(const ox::String &path) const noexcept {
|
||||
oxRequire(buff, loadBuff(path));
|
||||
if constexpr (ox::is_same_v<T, ox::ModelObject>) {
|
||||
return foundation::readAsset(&m_typeStore, buff);
|
||||
return keel::readAsset(&m_typeStore, buff);
|
||||
} else {
|
||||
return foundation::readAsset<T>(buff);
|
||||
return keel::readAsset<T>(buff);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -10,7 +10,7 @@
|
||||
|
||||
#include <nostalgia/appmodules/appmodules.hpp>
|
||||
#include <nostalgia/core/core.hpp>
|
||||
#include <nostalgia/foundation/media.hpp>
|
||||
#include <keel/media.hpp>
|
||||
|
||||
#include "lib/context.hpp"
|
||||
#include "studioapp.hpp"
|
||||
|
@@ -5,7 +5,7 @@
|
||||
#include <imgui.h>
|
||||
|
||||
#include <nostalgia/core/core.hpp>
|
||||
#include <nostalgia/foundation/media.hpp>
|
||||
#include <keel/media.hpp>
|
||||
|
||||
#include "lib/configio.hpp"
|
||||
#include "builtinmodules.hpp"
|
||||
@@ -290,8 +290,8 @@ void StudioUI::save() noexcept {
|
||||
}
|
||||
|
||||
ox::Error StudioUI::openProject(ox::CRStringView path) noexcept {
|
||||
oxRequireM(fs, foundation::loadRomFs(path));
|
||||
oxReturnError(foundation::setRomFs(m_ctx, std::move(fs)));
|
||||
oxRequireM(fs, keel::loadRomFs(path));
|
||||
oxReturnError(keel::setRomFs(m_ctx, std::move(fs)));
|
||||
core::setWindowTitle(m_ctx, ox::sfmt("Nostalgia Studio - {}", path));
|
||||
m_project = ox::make_unique<studio::Project>(m_ctx, path);
|
||||
auto sctx = applicationData<studio::StudioContext>(m_ctx);
|
||||
|
Reference in New Issue
Block a user