[keel] Split out Nostalgia Foundation and Pack lib into Keel
This commit is contained in:
parent
4a95a79926
commit
7beb3cc6fc
@ -1,3 +1,4 @@
|
||||
include_directories(".")
|
||||
|
||||
add_subdirectory(keel)
|
||||
add_subdirectory(nostalgia)
|
||||
|
@ -1,18 +1,20 @@
|
||||
|
||||
add_library(
|
||||
NostalgiaFoundation
|
||||
Keel
|
||||
asset.cpp
|
||||
media.cpp
|
||||
module.cpp
|
||||
pack.cpp
|
||||
typeconv.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
NostalgiaFoundation PUBLIC
|
||||
Keel PUBLIC
|
||||
OxClaw
|
||||
OxEvent
|
||||
OxFS
|
||||
OxModel
|
||||
OxPreloader
|
||||
OxStd
|
||||
)
|
||||
|
||||
@ -20,11 +22,12 @@ install(
|
||||
FILES
|
||||
assetmanager.hpp
|
||||
context.hpp
|
||||
foundation.hpp
|
||||
keel.hpp
|
||||
asset.hpp
|
||||
media.hpp
|
||||
module.hpp
|
||||
pack.hpp
|
||||
typeconv.hpp
|
||||
DESTINATION
|
||||
include/nostalgia/foundation
|
||||
include/keel
|
||||
)
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include "asset.hpp"
|
||||
|
||||
namespace nostalgia::foundation {
|
||||
namespace keel {
|
||||
|
||||
ox::Result<ox::UUID> readUuidHeader(const ox::Buffer &buff) noexcept {
|
||||
return readUuidHeader(buff.data(), buff.size());
|
@ -9,7 +9,7 @@
|
||||
#include <ox/claw/claw.hpp>
|
||||
#include <ox/fs/fs.hpp>
|
||||
|
||||
namespace nostalgia::foundation {
|
||||
namespace keel {
|
||||
|
||||
constexpr auto N1HdrSz = 40;
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include <ox/std/hashmap.hpp>
|
||||
#include <ox/std/utility.hpp>
|
||||
|
||||
namespace nostalgia::foundation {
|
||||
namespace keel {
|
||||
|
||||
class AssetManager;
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
#include "assetmanager.hpp"
|
||||
|
||||
namespace nostalgia::foundation {
|
||||
namespace keel {
|
||||
|
||||
class Context;
|
||||
using PackTransform = ox::Error(*)(Context*, ox::Buffer *clawData);
|
@ -9,10 +9,11 @@
|
||||
#include "context.hpp"
|
||||
#include "media.hpp"
|
||||
#include "module.hpp"
|
||||
#include "pack.hpp"
|
||||
|
||||
namespace nostalgia::foundation {
|
||||
namespace keel {
|
||||
|
||||
template<typename Ctx = foundation::Context>
|
||||
template<typename Ctx = keel::Context>
|
||||
ox::Result<ox::UPtr<Ctx>> init(ox::UPtr<ox::FileSystem> &&fs, ox::CRStringView appName) noexcept {
|
||||
auto ctx = ox::make_unique<Ctx>();
|
||||
ctx->appName = appName;
|
@ -10,9 +10,9 @@
|
||||
|
||||
#include <ox/std/trace.hpp>
|
||||
|
||||
#include <nostalgia/foundation/media.hpp>
|
||||
#include "media.hpp"
|
||||
|
||||
namespace nostalgia::foundation {
|
||||
namespace keel {
|
||||
|
||||
ox::Result<char*> loadRom(ox::CRStringView path) noexcept {
|
||||
std::ifstream file(std::string(toStdStringView(path)), std::ios::binary | std::ios::ate);
|
||||
@ -85,7 +85,7 @@ ox::Error buildUuidMap(Context *ctx) noexcept {
|
||||
|
||||
#define MEM_ROM reinterpret_cast<char*>(0x0800'0000)
|
||||
|
||||
namespace nostalgia::foundation {
|
||||
namespace keel {
|
||||
|
||||
static void clearUuidMap(Context*) noexcept {
|
||||
}
|
||||
@ -114,7 +114,7 @@ ox::Result<char*> loadRom(ox::CRStringView) noexcept {
|
||||
void unloadRom(char*) noexcept {
|
||||
}
|
||||
|
||||
ox::Result<std::size_t> getPreloadAddr(foundation::Context *ctx, ox::CRStringView path) noexcept {
|
||||
ox::Result<std::size_t> getPreloadAddr(keel::Context *ctx, ox::CRStringView path) noexcept {
|
||||
oxRequire(stat, ctx->rom->stat(path));
|
||||
oxRequire(buff, static_cast<ox::MemFS*>(ctx->rom.get())->directAccess(path));
|
||||
PreloadPtr p;
|
||||
@ -122,7 +122,7 @@ ox::Result<std::size_t> getPreloadAddr(foundation::Context *ctx, ox::CRStringVie
|
||||
return p.preloadAddr + ctx->preloadSectionOffset;
|
||||
}
|
||||
|
||||
ox::Result<std::size_t> getPreloadAddr(foundation::Context *ctx, const ox::FileAddress &file) noexcept {
|
||||
ox::Result<std::size_t> getPreloadAddr(keel::Context *ctx, const ox::FileAddress &file) noexcept {
|
||||
oxRequire(stat, ctx->rom->stat(file));
|
||||
oxRequire(buff, static_cast<ox::MemFS*>(ctx->rom.get())->directAccess(file));
|
||||
PreloadPtr p;
|
||||
@ -134,7 +134,7 @@ ox::Result<std::size_t> getPreloadAddr(foundation::Context *ctx, const ox::FileA
|
||||
|
||||
#endif
|
||||
|
||||
namespace nostalgia::foundation {
|
||||
namespace keel {
|
||||
|
||||
ox::Error setRomFs(Context *ctx, ox::UPtr<ox::FileSystem> fs) noexcept {
|
||||
ctx->rom = std::move(fs);
|
@ -15,7 +15,7 @@
|
||||
#include "context.hpp"
|
||||
#include "typeconv.hpp"
|
||||
|
||||
namespace nostalgia::foundation {
|
||||
namespace keel {
|
||||
|
||||
// Pointer to preloaded data that can be stored in FS in place of the actual
|
||||
// data.
|
||||
@ -29,14 +29,14 @@ oxModelBegin(PreloadPtr)
|
||||
oxModelField(preloadAddr)
|
||||
oxModelEnd()
|
||||
|
||||
ox::Result<std::size_t> getPreloadAddr(foundation::Context *ctx, const ox::FileAddress &file) noexcept;
|
||||
ox::Result<std::size_t> getPreloadAddr(foundation::Context *ctx, ox::CRStringView file) noexcept;
|
||||
ox::Result<std::size_t> getPreloadAddr(keel::Context *ctx, const ox::FileAddress &file) noexcept;
|
||||
ox::Result<std::size_t> getPreloadAddr(keel::Context *ctx, ox::CRStringView file) noexcept;
|
||||
|
||||
#ifndef OX_BARE_METAL
|
||||
|
||||
template<typename T>
|
||||
ox::Result<foundation::AssetRef<T>> readObjFile(
|
||||
foundation::Context *ctx,
|
||||
ox::Result<keel::AssetRef<T>> readObjFile(
|
||||
keel::Context *ctx,
|
||||
ox::StringView assetId,
|
||||
bool forceLoad) noexcept {
|
||||
constexpr auto readConvert = [](Context *ctx, const ox::Buffer &buff) -> ox::Result<T> {
|
||||
@ -78,12 +78,12 @@ ox::Result<foundation::AssetRef<T>> readObjFile(
|
||||
#else
|
||||
|
||||
template<typename T>
|
||||
ox::Result<foundation::AssetRef<T>> readObjNoCache(
|
||||
foundation::Context *ctx,
|
||||
ox::Result<keel::AssetRef<T>> readObjNoCache(
|
||||
keel::Context *ctx,
|
||||
ox::CRStringView assetId) noexcept {
|
||||
if constexpr(ox::preloadable<T>::value) {
|
||||
oxRequire(addr, getPreloadAddr(ctx, assetId));
|
||||
return foundation::AssetRef<T>(reinterpret_cast<const T*>(addr));
|
||||
return keel::AssetRef<T>(reinterpret_cast<const T*>(addr));
|
||||
} else {
|
||||
return OxError(1);
|
||||
}
|
||||
@ -96,8 +96,8 @@ void createUuidMapping(Context *ctx, const ox::String &filePath, const ox::UUID
|
||||
ox::Error buildUuidMap(Context *ctx) noexcept;
|
||||
|
||||
template<typename T>
|
||||
ox::Result<foundation::AssetRef<T>> readObj(
|
||||
[[maybe_unused]] foundation::Context *ctx,
|
||||
ox::Result<keel::AssetRef<T>> readObj(
|
||||
[[maybe_unused]] keel::Context *ctx,
|
||||
[[maybe_unused]] ox::CRStringView assetId,
|
||||
[[maybe_unused]] bool forceLoad = false) noexcept {
|
||||
#ifndef OX_BARE_METAL
|
||||
@ -108,8 +108,8 @@ ox::Result<foundation::AssetRef<T>> readObj(
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
ox::Result<foundation::AssetRef<T>> readObj(
|
||||
foundation::Context *ctx,
|
||||
ox::Result<keel::AssetRef<T>> readObj(
|
||||
keel::Context *ctx,
|
||||
const ox::FileAddress &file,
|
||||
[[maybe_unused]] bool forceLoad = false) noexcept {
|
||||
#ifndef OX_BARE_METAL
|
||||
@ -118,7 +118,7 @@ ox::Result<foundation::AssetRef<T>> readObj(
|
||||
#else
|
||||
if constexpr(ox::preloadable<T>::value) {
|
||||
oxRequire(addr, getPreloadAddr(ctx, file));
|
||||
return foundation::AssetRef<T>(reinterpret_cast<const T*>(addr));
|
||||
return keel::AssetRef<T>(reinterpret_cast<const T*>(addr));
|
||||
} else {
|
||||
return OxError(1);
|
||||
}
|
||||
@ -127,7 +127,7 @@ ox::Result<foundation::AssetRef<T>> readObj(
|
||||
|
||||
template<typename T>
|
||||
ox::Error writeObj(
|
||||
foundation::Context *ctx,
|
||||
keel::Context *ctx,
|
||||
const ox::FileAddress &file,
|
||||
const T &obj,
|
||||
ox::ClawFormat fmt = ox::ClawFormat::Metal) noexcept {
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include "module.hpp"
|
||||
|
||||
namespace nostalgia::foundation {
|
||||
namespace keel {
|
||||
|
||||
static ox::Vector<const Module*> mods;
|
||||
|
||||
@ -22,7 +22,7 @@ ox::Vector<TypeDescGenerator> Module::types() const noexcept {
|
||||
return {};
|
||||
}
|
||||
|
||||
ox::Vector<const foundation::BaseConverter*> Module::converters() const noexcept {
|
||||
ox::Vector<const keel::BaseConverter*> Module::converters() const noexcept {
|
||||
return {};
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
#include "typeconv.hpp"
|
||||
|
||||
namespace nostalgia::foundation {
|
||||
namespace keel {
|
||||
|
||||
using TypeDescGenerator = ox::Error(*)(ox::TypeStore*);
|
||||
|
||||
@ -30,7 +30,7 @@ class Module {
|
||||
[[nodiscard]]
|
||||
virtual ox::Vector<TypeDescGenerator> types() const noexcept;
|
||||
[[nodiscard]]
|
||||
virtual ox::Vector<const foundation::BaseConverter*> converters() const noexcept;
|
||||
virtual ox::Vector<const keel::BaseConverter*> converters() const noexcept;
|
||||
[[nodiscard]]
|
||||
virtual ox::Vector<PackTransform> packTransforms() const noexcept;
|
||||
};
|
||||
@ -38,6 +38,6 @@ class Module {
|
||||
void registerModule(const Module *mod) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
const ox::Vector<const foundation::Module*> &modules() noexcept;
|
||||
const ox::Vector<const keel::Module*> &modules() noexcept;
|
||||
|
||||
}
|
@ -2,18 +2,20 @@
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef OX_BARE_METAL
|
||||
|
||||
#include <ox/claw/read.hpp>
|
||||
#include <ox/fs/fs.hpp>
|
||||
#include <ox/model/descwrite.hpp>
|
||||
#include <ox/model/modelvalue.hpp>
|
||||
|
||||
#include <nostalgia/foundation/media.hpp>
|
||||
#include <keel/media.hpp>
|
||||
|
||||
#include "pack.hpp"
|
||||
|
||||
namespace nostalgia {
|
||||
namespace keel {
|
||||
|
||||
static ox::Error pathToInode(foundation::Context *ctx, ox::FileSystem *dest, ox::ModelObject *obj) noexcept {
|
||||
static ox::Error pathToInode(keel::Context *ctx, ox::FileSystem *dest, ox::ModelObject *obj) noexcept {
|
||||
auto &o = *obj;
|
||||
auto type = static_cast<ox::FileAddressType>(o["type"].get<int8_t>());
|
||||
auto &data = o["data"].get<ox::ModelUnion>();
|
||||
@ -38,10 +40,10 @@ static ox::Error pathToInode(foundation::Context *ctx, ox::FileSystem *dest, ox:
|
||||
return data.set(2, s.inode);
|
||||
}
|
||||
|
||||
static ox::Error transformFileAddressesObj(foundation::Context *ctx, ox::FileSystem *dest, ox::ModelObject *obj) noexcept;
|
||||
static ox::Error transformFileAddressesVec(foundation::Context *ctx, ox::FileSystem *dest, ox::ModelValueVector *v) noexcept;
|
||||
static ox::Error transformFileAddressesObj(keel::Context *ctx, ox::FileSystem *dest, ox::ModelObject *obj) noexcept;
|
||||
static ox::Error transformFileAddressesVec(keel::Context *ctx, ox::FileSystem *dest, ox::ModelValueVector *v) noexcept;
|
||||
|
||||
static ox::Error transformFileAddresses(foundation::Context *ctx, ox::FileSystem *dest, ox::ModelValue *v) noexcept {
|
||||
static ox::Error transformFileAddresses(keel::Context *ctx, ox::FileSystem *dest, ox::ModelValue *v) noexcept {
|
||||
if (v->type() == ox::ModelValue::Type::Object) {
|
||||
auto &obj = v->get<ox::ModelObject>();
|
||||
return transformFileAddressesObj(ctx, dest, &obj);
|
||||
@ -52,7 +54,7 @@ static ox::Error transformFileAddresses(foundation::Context *ctx, ox::FileSystem
|
||||
return {};
|
||||
}
|
||||
|
||||
static ox::Error transformFileAddressesVec(foundation::Context *ctx, ox::FileSystem *dest, ox::ModelValueVector *v) noexcept {
|
||||
static ox::Error transformFileAddressesVec(keel::Context *ctx, ox::FileSystem *dest, ox::ModelValueVector *v) noexcept {
|
||||
for (auto &f : *v) {
|
||||
oxReturnError(transformFileAddresses(ctx, dest, &f));
|
||||
}
|
||||
@ -63,7 +65,7 @@ static ox::Error transformFileAddressesVec(foundation::Context *ctx, ox::FileSys
|
||||
* Convert path references in Claw data to inodes to save space
|
||||
* @return error
|
||||
*/
|
||||
static ox::Error transformFileAddressesObj(foundation::Context *ctx, ox::FileSystem *dest, ox::ModelObject *obj) noexcept {
|
||||
static ox::Error transformFileAddressesObj(keel::Context *ctx, ox::FileSystem *dest, ox::ModelObject *obj) noexcept {
|
||||
if (obj->typeName() == "net.drinkingtea.ox.FileAddress" && obj->typeVersion() == 1) {
|
||||
return pathToInode(ctx, dest, obj);
|
||||
}
|
||||
@ -74,7 +76,7 @@ static ox::Error transformFileAddressesObj(foundation::Context *ctx, ox::FileSys
|
||||
return {};
|
||||
}
|
||||
|
||||
static ox::Error doTransformations(foundation::Context *ctx, ox::TypeStore *ts, ox::FileSystem *dest, ox::CRStringView filePath) noexcept {
|
||||
static ox::Error doTransformations(keel::Context *ctx, ox::TypeStore *ts, ox::FileSystem *dest, ox::CRStringView filePath) noexcept {
|
||||
// load file
|
||||
oxRequire(s, dest->stat(filePath));
|
||||
// do transformations
|
||||
@ -83,7 +85,7 @@ static ox::Error doTransformations(foundation::Context *ctx, ox::TypeStore *ts,
|
||||
oxReturnError(tr(ctx, &buff));
|
||||
}
|
||||
// transform FileAddresses
|
||||
oxRequireM(obj, foundation::readAsset(ts, buff));
|
||||
oxRequireM(obj, keel::readAsset(ts, buff));
|
||||
oxReturnError(transformFileAddressesObj(ctx, dest, &obj));
|
||||
oxReturnError(ox::writeClaw(&obj).moveTo(&buff));
|
||||
// write file to dest
|
||||
@ -93,7 +95,7 @@ static ox::Error doTransformations(foundation::Context *ctx, ox::TypeStore *ts,
|
||||
|
||||
// claw file transformations are broken out from copy because path to inode
|
||||
// transformations need to be done after the copy to the new FS is complete
|
||||
static ox::Error transformClaw(foundation::Context *ctx, ox::TypeStore *ts, ox::FileSystem *dest, ox::CRStringView path) noexcept {
|
||||
static ox::Error transformClaw(keel::Context *ctx, ox::TypeStore *ts, ox::FileSystem *dest, ox::CRStringView path) noexcept {
|
||||
// copy
|
||||
oxTracef("pack::transformClaw", "path: {}", path);
|
||||
oxRequire(fileList, dest->ls(path));
|
||||
@ -131,7 +133,7 @@ static ox::Error copy(ox::FileSystem *src, ox::FileSystem *dest, ox::CRStringVie
|
||||
oxRequire(fileList, src->ls(path));
|
||||
for (const auto &name : fileList) {
|
||||
auto currentFile = ox::sfmt("{}{}", path, name);
|
||||
if (currentFile == "/.nostalgia") {
|
||||
if (beginsWith(name, ".")) {
|
||||
continue;
|
||||
}
|
||||
oxOutf("reading {}\n", currentFile);
|
||||
@ -169,7 +171,7 @@ static ox::Error preloadObj(
|
||||
GbaPreloader *pl, ox::CRStringView path) noexcept {
|
||||
// load file
|
||||
oxRequireM(buff, romFs->read(path));
|
||||
oxRequireM(obj, foundation::readAsset(ts, buff));
|
||||
oxRequireM(obj, keel::readAsset(ts, buff));
|
||||
if (obj.type()->preloadable) {
|
||||
oxOutf("preloading {}\n", path);
|
||||
// preload
|
||||
@ -177,7 +179,7 @@ static ox::Error preloadObj(
|
||||
const auto err = ox::preload<GbaPlatSpec, decltype(obj)>(pl, &obj);
|
||||
oxReturnError(pl->endAlloc());
|
||||
oxReturnError(err);
|
||||
const foundation::PreloadPtr p{.preloadAddr = static_cast<uint32_t>(a)};
|
||||
const keel::PreloadPtr p{.preloadAddr = static_cast<uint32_t>(a)};
|
||||
oxReturnError(ox::writeMC(&p).moveTo(&buff));
|
||||
} else {
|
||||
// strip the Claw header (it is not needed after preloading) and write back out to dest fs
|
||||
@ -228,7 +230,7 @@ ox::Error appendBinary(ox::Buffer *binBuff, ox::Buffer *fsBuff, GbaPreloader *pl
|
||||
return {};
|
||||
}
|
||||
|
||||
ox::Error pack(foundation::Context *ctx, ox::TypeStore *ts, ox::FileSystem *dest) noexcept {
|
||||
ox::Error pack(keel::Context *ctx, ox::TypeStore *ts, ox::FileSystem *dest) noexcept {
|
||||
oxReturnError(copyFS(ctx->rom.get(), dest));
|
||||
oxOut("Doing transforms\n");
|
||||
oxReturnError(transformClaw(ctx, ts, dest, "/"));
|
||||
@ -241,3 +243,5 @@ ox::Error preload(ox::TypeStore *ts, ox::FileSystem *src, GbaPreloader *pl) noex
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -2,15 +2,17 @@
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ox/fs/fs.hpp>
|
||||
#include <ox/preloader/preloader.hpp>
|
||||
|
||||
namespace nostalgia {
|
||||
|
||||
namespace foundation {
|
||||
namespace keel {
|
||||
class Context;
|
||||
}
|
||||
|
||||
namespace keel {
|
||||
|
||||
struct GbaPlatSpec {
|
||||
using PtrType = uint32_t;
|
||||
using size_t = uint32_t;
|
||||
@ -78,8 +80,8 @@ using GbaPreloader = ox::Preloader<GbaPlatSpec>;
|
||||
|
||||
ox::Error appendBinary(ox::Buffer *binBuff, ox::Buffer *fsBuff, GbaPreloader *pl) noexcept;
|
||||
|
||||
auto pack(foundation::Context *ctx, ox::TypeStore *ts, ox::FileSystem *dest) noexcept -> ox::Error;
|
||||
ox::Error pack(keel::Context *ctx, ox::TypeStore *ts, ox::FileSystem *dest) noexcept;
|
||||
|
||||
auto preload(ox::TypeStore *ts, ox::FileSystem *src, GbaPreloader *ph) noexcept -> ox::Error;
|
||||
ox::Error preload(ox::TypeStore *ts, ox::FileSystem *src, GbaPreloader *ph) noexcept;
|
||||
|
||||
}
|
@ -7,13 +7,13 @@
|
||||
#include "media.hpp"
|
||||
#include "typeconv.hpp"
|
||||
|
||||
namespace nostalgia::foundation {
|
||||
namespace keel {
|
||||
|
||||
#ifndef OX_BARE_METAL
|
||||
|
||||
[[nodiscard]]
|
||||
static ox::Result<const BaseConverter*> findConverter(
|
||||
foundation::Context *ctx,
|
||||
keel::Context *ctx,
|
||||
ox::CRStringView srcTypeName, int srcTypeVersion,
|
||||
ox::CRStringView dstTypeName, int dstTypeVersion) noexcept {
|
||||
for (auto &c : ctx->converters) {
|
||||
@ -25,7 +25,7 @@ static ox::Result<const BaseConverter*> findConverter(
|
||||
};
|
||||
|
||||
static ox::Result<ox::UniquePtr<Wrap>> convert(
|
||||
foundation::Context *ctx, const ox::Buffer &srcBuffer,
|
||||
keel::Context *ctx, const ox::Buffer &srcBuffer,
|
||||
ox::CRStringView srcTypeName, int srcTypeVersion,
|
||||
ox::CRStringView dstTypeName, int dstTypeVersion) noexcept {
|
||||
// look for direct converter
|
||||
@ -49,7 +49,7 @@ static ox::Result<ox::UniquePtr<Wrap>> convert(
|
||||
}
|
||||
|
||||
ox::Result<ox::UniquePtr<Wrap>> convert(
|
||||
foundation::Context *ctx,
|
||||
keel::Context *ctx,
|
||||
const ox::Buffer &srcBuffer,
|
||||
ox::CRStringView dstTypeName,
|
||||
int dstTypeVersion) noexcept {
|
@ -13,7 +13,7 @@
|
||||
#include "context.hpp"
|
||||
#include "media.hpp"
|
||||
|
||||
namespace nostalgia::foundation {
|
||||
namespace keel {
|
||||
|
||||
class Wrap {
|
||||
public:
|
||||
@ -87,9 +87,9 @@ class BaseConverter {
|
||||
[[nodiscard]]
|
||||
virtual bool dstMatches(ox::CRStringView dstTypeName, int dstTypeVersion) const noexcept = 0;
|
||||
|
||||
virtual ox::Result<ox::UniquePtr<Wrap>> convertPtrToPtr(foundation::Context *ctx, Wrap *src) const noexcept = 0;
|
||||
virtual ox::Result<ox::UniquePtr<Wrap>> convertPtrToPtr(keel::Context *ctx, Wrap *src) const noexcept = 0;
|
||||
|
||||
virtual ox::Result<ox::UniquePtr<Wrap>> convertBuffToPtr(foundation::Context *ctx, const ox::Buffer &srcBuff) const noexcept = 0;
|
||||
virtual ox::Result<ox::UniquePtr<Wrap>> convertBuffToPtr(keel::Context *ctx, const ox::Buffer &srcBuff) const noexcept = 0;
|
||||
|
||||
[[nodiscard]]
|
||||
inline bool matches(ox::CRStringView srcTypeName, int srcTypeVersion,
|
||||
@ -129,13 +129,13 @@ class Converter: public BaseConverter {
|
||||
&& dstTypeVersion == DstTypeVersion;
|
||||
}
|
||||
|
||||
ox::Result<ox::UniquePtr<Wrap>> convertPtrToPtr(foundation::Context *ctx, Wrap *src) const noexcept final {
|
||||
ox::Result<ox::UniquePtr<Wrap>> convertPtrToPtr(keel::Context *ctx, Wrap *src) const noexcept final {
|
||||
auto dst = makeWrap<DstType>();
|
||||
oxReturnError(convert(ctx, wrapCast<SrcType>(src), wrapCast<DstType>(dst.get())));
|
||||
return ox::Result<ox::UniquePtr<Wrap>>(std::move(dst));
|
||||
}
|
||||
|
||||
ox::Result<ox::UniquePtr<Wrap>> convertBuffToPtr(foundation::Context *ctx, const ox::Buffer &srcBuff) const noexcept final {
|
||||
ox::Result<ox::UniquePtr<Wrap>> convertBuffToPtr(keel::Context *ctx, const ox::Buffer &srcBuff) const noexcept final {
|
||||
oxRequireM(src, readAsset<SrcType>(srcBuff));
|
||||
auto dst = makeWrap<DstType>();
|
||||
oxReturnError(convert(ctx, &src, wrapCast<DstType>(dst.get())));
|
||||
@ -143,15 +143,15 @@ class Converter: public BaseConverter {
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual ox::Error convert(foundation::Context *ctx, SrcType*, DstType*) const noexcept = 0;
|
||||
virtual ox::Error convert(keel::Context *ctx, SrcType*, DstType*) const noexcept = 0;
|
||||
|
||||
};
|
||||
|
||||
ox::Result<ox::UniquePtr<Wrap>> convert(foundation::Context *ctx, const ox::Buffer &srcBuffer,
|
||||
ox::Result<ox::UniquePtr<Wrap>> convert(keel::Context *ctx, const ox::Buffer &srcBuffer,
|
||||
ox::CRStringView dstTypeName, int dstTypeVersion) noexcept;
|
||||
|
||||
template<typename DstType>
|
||||
ox::Result<DstType> convert(foundation::Context *ctx, const ox::Buffer &srcBuffer) noexcept {
|
||||
ox::Result<DstType> convert(keel::Context *ctx, const ox::Buffer &srcBuffer) noexcept {
|
||||
static constexpr auto DstTypeName = ox::requireModelTypeName<DstType>();
|
||||
static constexpr auto DstTypeVersion = ox::requireModelTypeVersion<DstType>();
|
||||
oxRequire(out, convert(ctx, srcBuffer, DstTypeName, DstTypeVersion));
|
||||
@ -159,7 +159,7 @@ ox::Result<DstType> convert(foundation::Context *ctx, const ox::Buffer &srcBuffe
|
||||
}
|
||||
|
||||
template<typename DstType>
|
||||
ox::Error convert(foundation::Context *ctx, const ox::Buffer &buff, DstType *outObj) noexcept {
|
||||
ox::Error convert(keel::Context *ctx, const ox::Buffer &buff, DstType *outObj) noexcept {
|
||||
static constexpr auto DstTypeName = ox::requireModelTypeName<DstType>();
|
||||
static constexpr auto DstTypeVersion = ox::requireModelTypeVersion<DstType>();
|
||||
oxRequire(outPtr, convert(ctx, buff, DstTypeName, DstTypeVersion));
|
||||
@ -168,7 +168,7 @@ ox::Error convert(foundation::Context *ctx, const ox::Buffer &buff, DstType *out
|
||||
}
|
||||
|
||||
template<typename DstType>
|
||||
ox::Result<ox::Buffer> convertBuffToBuff(foundation::Context *ctx, const ox::Buffer &srcBuffer, ox::ClawFormat fmt) noexcept {
|
||||
ox::Result<ox::Buffer> convertBuffToBuff(keel::Context *ctx, const ox::Buffer &srcBuffer, ox::ClawFormat fmt) noexcept {
|
||||
static constexpr auto DstTypeName = ox::requireModelTypeName<DstType>();
|
||||
static constexpr auto DstTypeVersion = ox::requireModelTypeVersion<DstType>();
|
||||
oxRequire(out, convert(ctx, srcBuffer, DstTypeName, DstTypeVersion));
|
||||
@ -176,12 +176,12 @@ ox::Result<ox::Buffer> convertBuffToBuff(foundation::Context *ctx, const ox::Buf
|
||||
}
|
||||
|
||||
template<typename From, typename To, ox::ClawFormat fmt = ox::ClawFormat::Metal>
|
||||
auto transformRule(foundation::Context *ctx, ox::Buffer *buff) noexcept -> ox::Error {
|
||||
auto transformRule(keel::Context *ctx, ox::Buffer *buff) noexcept -> ox::Error {
|
||||
oxRequire(hdr, readAssetHeader(*buff));
|
||||
const auto typeId = ox::buildTypeId(
|
||||
hdr.clawHdr.typeName, hdr.clawHdr.typeVersion, hdr.clawHdr.typeParams);
|
||||
if (typeId == ox::buildTypeId<From>()) {
|
||||
oxReturnError(foundation::convertBuffToBuff<To>(ctx, *buff, fmt).moveTo(buff));
|
||||
oxReturnError(keel::convertBuffToBuff<To>(ctx, *buff, fmt).moveTo(buff));
|
||||
}
|
||||
return {};
|
||||
};
|
@ -3,7 +3,6 @@
|
||||
|
||||
add_subdirectory(appmodules)
|
||||
add_subdirectory(core)
|
||||
add_subdirectory(foundation)
|
||||
add_subdirectory(geo)
|
||||
add_subdirectory(scene)
|
||||
|
||||
|
@ -10,7 +10,7 @@ endif()
|
||||
target_link_libraries(
|
||||
NostalgiaAppModules PUBLIC
|
||||
NostalgiaCore
|
||||
NostalgiaFoundation
|
||||
Keel
|
||||
NostalgiaScene
|
||||
)
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#include <nostalgia/foundation/module.hpp>
|
||||
#include <keel/module.hpp>
|
||||
|
||||
#include <nostalgia/core/module.hpp>
|
||||
#include <nostalgia/scene/scenemodule.hpp>
|
||||
@ -14,8 +14,8 @@ void loadModules() noexcept {
|
||||
if (modulesLoaded) {
|
||||
return;
|
||||
}
|
||||
foundation::registerModule(core::module());
|
||||
foundation::registerModule(scene::module());
|
||||
keel::registerModule(core::module());
|
||||
keel::registerModule(scene::module());
|
||||
modulesLoaded = true;
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ endif()
|
||||
|
||||
target_link_libraries(
|
||||
NostalgiaCore-Common PUBLIC
|
||||
NostalgiaFoundation
|
||||
Keel
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include <ox/model/desctypes.hpp>
|
||||
#include <ox/std/buffer.hpp>
|
||||
|
||||
#include <nostalgia/foundation/context.hpp>
|
||||
#include <keel/context.hpp>
|
||||
#include <nostalgia/geo/size.hpp>
|
||||
|
||||
#include "event.hpp"
|
||||
@ -59,7 +59,7 @@ struct BgCbbData {
|
||||
};
|
||||
|
||||
// User Input Output
|
||||
class Context: public foundation::Context {
|
||||
class Context: public keel::Context {
|
||||
friend constexpr void setApplicationData(Context *ctx, void *applicationData) noexcept;
|
||||
template<typename T>
|
||||
friend constexpr T *applicationData(Context *ctx) noexcept;
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <ox/mc/mc.hpp>
|
||||
#include <ox/std/array.hpp>
|
||||
|
||||
#include <nostalgia/foundation/media.hpp>
|
||||
#include <keel/media.hpp>
|
||||
#include <nostalgia/core/context.hpp>
|
||||
#include <nostalgia/core/gfx.hpp>
|
||||
|
||||
@ -130,7 +130,7 @@ ox::Error initConsole(Context *ctx) noexcept {
|
||||
setBgStatus(ctx, 0b0001);
|
||||
if (!ctx) {
|
||||
ctx = new (ox_alloca(sizeof(Context))) Context();
|
||||
oxRequire(rom, foundation::loadRom());
|
||||
oxRequire(rom, keel::loadRom());
|
||||
ox::FileStore32 fs(rom, 32 * ox::units::MB);
|
||||
auto romFs = new (ox_alloca(sizeof(ox::FileSystem32))) ox::FileSystem32(fs);
|
||||
new (&ctx->rom) ox::UniquePtr<ox::FileSystem>(romFs);
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include <glad/glad.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#include <nostalgia/foundation/foundation.hpp>
|
||||
#include <keel/keel.hpp>
|
||||
#include <nostalgia/core/gfx.hpp>
|
||||
#include <nostalgia/core/input.hpp>
|
||||
#include <nostalgia/core/opengl/gfx.hpp>
|
||||
@ -15,7 +15,7 @@
|
||||
namespace nostalgia::core {
|
||||
|
||||
ox::Result<ox::UPtr<Context>> init(ox::UPtr<ox::FileSystem> fs, ox::CRStringView appName) noexcept {
|
||||
oxRequireM(ctx, foundation::init<Context>(std::move(fs), appName));
|
||||
oxRequireM(ctx, keel::init<Context>(std::move(fs), appName));
|
||||
const auto id = ox::make<GlfwImplData>();
|
||||
ctx->setWindowerData(id);
|
||||
using namespace std::chrono;
|
||||
|
@ -4,8 +4,8 @@
|
||||
|
||||
#include <ox/model/model.hpp>
|
||||
|
||||
#include <nostalgia/foundation/asset.hpp>
|
||||
#include <nostalgia/foundation/module.hpp>
|
||||
#include <keel/asset.hpp>
|
||||
#include <keel/module.hpp>
|
||||
|
||||
#include "gfx.hpp"
|
||||
#include "typeconv.hpp"
|
||||
@ -14,7 +14,7 @@
|
||||
|
||||
namespace nostalgia::core {
|
||||
|
||||
class CoreModule: public foundation::Module {
|
||||
class CoreModule: public keel::Module {
|
||||
private:
|
||||
NostalgiaPaletteToPaletteConverter nostalgiaPaletteToPaletteConverter;
|
||||
TileSheetV1ToTileSheetConverter nostalgiaGraphicToTileSheetConverter;
|
||||
@ -24,31 +24,31 @@ class CoreModule: public foundation::Module {
|
||||
public:
|
||||
static CoreModule mod;
|
||||
[[nodiscard]]
|
||||
ox::Vector<foundation::TypeDescGenerator> types() const noexcept override;
|
||||
ox::Vector<keel::TypeDescGenerator> types() const noexcept override;
|
||||
[[nodiscard]]
|
||||
ox::Vector<const foundation::BaseConverter*> converters() const noexcept override;
|
||||
ox::Vector<const keel::BaseConverter*> converters() const noexcept override;
|
||||
[[nodiscard]]
|
||||
ox::Vector<foundation::PackTransform> packTransforms() const noexcept override;
|
||||
ox::Vector<keel::PackTransform> packTransforms() const noexcept override;
|
||||
};
|
||||
|
||||
CoreModule CoreModule::mod;
|
||||
|
||||
const foundation::Module *module() noexcept {
|
||||
const keel::Module *module() noexcept {
|
||||
return &CoreModule::mod;
|
||||
}
|
||||
|
||||
ox::Vector<foundation::TypeDescGenerator> CoreModule::types() const noexcept {
|
||||
ox::Vector<keel::TypeDescGenerator> CoreModule::types() const noexcept {
|
||||
return {
|
||||
foundation::generateTypeDesc<TileSheetV1>,
|
||||
foundation::generateTypeDesc<TileSheetV2>,
|
||||
foundation::generateTypeDesc<TileSheet>,
|
||||
foundation::generateTypeDesc<CompactTileSheet>,
|
||||
foundation::generateTypeDesc<NostalgiaPalette>,
|
||||
foundation::generateTypeDesc<Palette>,
|
||||
keel::generateTypeDesc<TileSheetV1>,
|
||||
keel::generateTypeDesc<TileSheetV2>,
|
||||
keel::generateTypeDesc<TileSheet>,
|
||||
keel::generateTypeDesc<CompactTileSheet>,
|
||||
keel::generateTypeDesc<NostalgiaPalette>,
|
||||
keel::generateTypeDesc<Palette>,
|
||||
};
|
||||
}
|
||||
|
||||
ox::Vector<const foundation::BaseConverter*> CoreModule::converters() const noexcept {
|
||||
ox::Vector<const keel::BaseConverter*> CoreModule::converters() const noexcept {
|
||||
return {
|
||||
&nostalgiaPaletteToPaletteConverter,
|
||||
&nostalgiaGraphicToTileSheetConverter,
|
||||
@ -57,16 +57,16 @@ ox::Vector<const foundation::BaseConverter*> CoreModule::converters() const noex
|
||||
};
|
||||
}
|
||||
|
||||
ox::Vector<foundation::PackTransform> CoreModule::packTransforms() const noexcept {
|
||||
ox::Vector<keel::PackTransform> CoreModule::packTransforms() const noexcept {
|
||||
return {
|
||||
// convert tilesheets to CompactTileSheets
|
||||
[](foundation::Context *ctx, ox::Buffer *buff) -> ox::Error {
|
||||
oxRequire(hdr, foundation::readAssetHeader(*buff));
|
||||
[](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<TileSheetV1>() ||
|
||||
typeId == ox::buildTypeId<TileSheetV2>() ||
|
||||
typeId == ox::buildTypeId<TileSheet>()) {
|
||||
oxReturnError(foundation::convertBuffToBuff<core::CompactTileSheet>(
|
||||
oxReturnError(keel::convertBuffToBuff<core::CompactTileSheet>(
|
||||
ctx, *buff, ox::ClawFormat::Metal).moveTo(buff));
|
||||
}
|
||||
return {};
|
||||
|
@ -4,10 +4,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <nostalgia/foundation/module.hpp>
|
||||
#include <keel/module.hpp>
|
||||
|
||||
namespace nostalgia::core {
|
||||
|
||||
const foundation::Module *module() noexcept;
|
||||
const keel::Module *module() noexcept;
|
||||
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
#include <nostalgia/core/gfx.hpp>
|
||||
#include <nostalgia/foundation/media.hpp>
|
||||
#include <keel/media.hpp>
|
||||
|
||||
#include "gfx.hpp"
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include <imgui.h>
|
||||
|
||||
#include <nostalgia/core/gfx.hpp>
|
||||
#include <nostalgia/foundation/media.hpp>
|
||||
#include <keel/media.hpp>
|
||||
#include <ox/std/memory.hpp>
|
||||
|
||||
#include "paletteeditor.hpp"
|
||||
@ -19,7 +19,7 @@ ox::Result<PaletteEditorImGui*> PaletteEditorImGui::make(Context *ctx, ox::CRStr
|
||||
out->m_itemPath = path;
|
||||
const auto lastSlash = std::find(out->m_itemPath.rbegin(), out->m_itemPath.rend(), '/').offset();
|
||||
out->m_itemName = out->m_itemPath.substr(lastSlash + 1);
|
||||
oxRequire(pal, foundation::readObj<Palette>(out->m_ctx, ox::FileAddress(out->m_itemPath.c_str())));
|
||||
oxRequire(pal, keel::readObj<Palette>(out->m_ctx, ox::FileAddress(out->m_itemPath.c_str())));
|
||||
out->m_pal = *pal;
|
||||
return out.release();
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include <imgui.h>
|
||||
#include <lodepng.h>
|
||||
|
||||
#include <nostalgia/foundation/media.hpp>
|
||||
#include <keel/media.hpp>
|
||||
#include <nostalgia/geo/point.hpp>
|
||||
|
||||
#include "tilesheeteditor-imgui.hpp"
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include <ox/std/memory.hpp>
|
||||
|
||||
#include <nostalgia/core/clipboard.hpp>
|
||||
#include <nostalgia/foundation/media.hpp>
|
||||
#include <keel/media.hpp>
|
||||
|
||||
#include "tilesheeteditormodel.hpp"
|
||||
|
||||
|
@ -23,7 +23,7 @@ class TileSheetEditorModel: public ox::SignalHandler {
|
||||
static const Palette s_defaultPalette;
|
||||
TileSheet m_img;
|
||||
TileSheet::SubSheetIdx m_activeSubsSheetIdx;
|
||||
foundation::AssetRef<Palette> m_pal;
|
||||
keel::AssetRef<Palette> m_pal;
|
||||
studio::UndoStack m_undoStack;
|
||||
class DrawCommand *m_ongoingDrawCommand = nullptr;
|
||||
bool m_updated = false;
|
||||
|
@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
#include <nostalgia/core/consts.hpp>
|
||||
#include <nostalgia/foundation/media.hpp>
|
||||
#include <keel/media.hpp>
|
||||
#include <nostalgia/geo/point.hpp>
|
||||
|
||||
#include "tilesheeteditorview.hpp"
|
||||
|
@ -7,7 +7,7 @@
|
||||
namespace nostalgia::core {
|
||||
|
||||
ox::Error NostalgiaPaletteToPaletteConverter::convert(
|
||||
foundation::Context*,
|
||||
keel::Context*,
|
||||
NostalgiaPalette *src,
|
||||
Palette *dst) const noexcept {
|
||||
dst->colors = std::move(src->colors);
|
||||
@ -15,7 +15,7 @@ ox::Error NostalgiaPaletteToPaletteConverter::convert(
|
||||
}
|
||||
|
||||
ox::Error TileSheetV1ToTileSheetConverter::convert(
|
||||
foundation::Context*,
|
||||
keel::Context*,
|
||||
TileSheetV1 *src,
|
||||
TileSheet *dst) const noexcept {
|
||||
dst->bpp = src->bpp;
|
||||
@ -28,7 +28,7 @@ ox::Error TileSheetV1ToTileSheetConverter::convert(
|
||||
}
|
||||
|
||||
ox::Error TileSheetToCompactTileSheetConverter::convert(
|
||||
foundation::Context*,
|
||||
keel::Context*,
|
||||
TileSheet *src,
|
||||
CompactTileSheet *dst) const noexcept {
|
||||
dst->bpp = src->bpp;
|
||||
@ -55,7 +55,7 @@ void TileSheetV2ToTileSheetConverter::convertSubsheet(
|
||||
}
|
||||
|
||||
ox::Error TileSheetV2ToTileSheetConverter::convert(
|
||||
foundation::Context*,
|
||||
keel::Context*,
|
||||
TileSheetV2 *src,
|
||||
TileSheet *dst) const noexcept {
|
||||
dst->bpp = src->bpp;
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include <ox/std/def.hpp>
|
||||
|
||||
#include <nostalgia/foundation/typeconv.hpp>
|
||||
#include <keel/typeconv.hpp>
|
||||
|
||||
#include "context.hpp"
|
||||
#include "gfx.hpp"
|
||||
@ -15,25 +15,25 @@ namespace nostalgia::core {
|
||||
|
||||
// Type converters
|
||||
|
||||
class NostalgiaPaletteToPaletteConverter: public foundation::Converter<NostalgiaPalette, Palette> {
|
||||
ox::Error convert(foundation::Context*, NostalgiaPalette *src, Palette *dst) const noexcept final;
|
||||
class NostalgiaPaletteToPaletteConverter: public keel::Converter<NostalgiaPalette, Palette> {
|
||||
ox::Error convert(keel::Context*, NostalgiaPalette *src, Palette *dst) const noexcept final;
|
||||
};
|
||||
|
||||
class TileSheetV1ToTileSheetConverter: public foundation::Converter<TileSheetV1, TileSheet> {
|
||||
ox::Error convert(foundation::Context*, TileSheetV1 *src, TileSheet *dst) const noexcept final;
|
||||
class TileSheetV1ToTileSheetConverter: public keel::Converter<TileSheetV1, TileSheet> {
|
||||
ox::Error convert(keel::Context*, TileSheetV1 *src, TileSheet *dst) const noexcept final;
|
||||
};
|
||||
|
||||
class TileSheetToCompactTileSheetConverter: public foundation::Converter<TileSheet, CompactTileSheet> {
|
||||
ox::Error convert(foundation::Context*, TileSheet *src, CompactTileSheet *dst) const noexcept final;
|
||||
class TileSheetToCompactTileSheetConverter: public keel::Converter<TileSheet, CompactTileSheet> {
|
||||
ox::Error convert(keel::Context*, TileSheet *src, CompactTileSheet *dst) const noexcept final;
|
||||
};
|
||||
|
||||
class TileSheetV2ToTileSheetConverter: public foundation::Converter<TileSheetV2, TileSheet> {
|
||||
class TileSheetV2ToTileSheetConverter: public keel::Converter<TileSheetV2, TileSheet> {
|
||||
static void convertSubsheet(
|
||||
TileSheetV2::SubSheet *src,
|
||||
TileSheet::SubSheet *dst,
|
||||
SubSheetId *idIt) noexcept;
|
||||
|
||||
ox::Error convert(foundation::Context*, TileSheetV2 *src, TileSheet *dst) const noexcept final;
|
||||
ox::Error convert(keel::Context*, TileSheetV2 *src, TileSheet *dst) const noexcept final;
|
||||
|
||||
};
|
||||
|
||||
|
@ -33,7 +33,7 @@ ox::Error run(ox::UniquePtr<ox::FileSystem> fs) noexcept {
|
||||
oxTraceInitHook();
|
||||
oxRequireM(ctx, core::init(std::move(fs)));
|
||||
constexpr ox::FileAddress SceneAddr("/Scenes/Chester.nscn");
|
||||
oxRequire(scn, foundation::readObj<scene::SceneStatic>(ctx.get(), SceneAddr));
|
||||
oxRequire(scn, keel::readObj<scene::SceneStatic>(ctx.get(), SceneAddr));
|
||||
core::setUpdateHandler(ctx.get(), updateHandler);
|
||||
core::setKeyEventHandler(ctx.get(), keyEventHandler);
|
||||
s_scene.emplace(*scn);
|
||||
|
@ -22,7 +22,7 @@ static ox::Error run(int argc, const char **argv) noexcept {
|
||||
return OxError(1);
|
||||
}
|
||||
const auto path = argv[1];
|
||||
oxRequireM(fs, nostalgia::foundation::loadRomFs(path));
|
||||
oxRequireM(fs, keel::loadRomFs(path));
|
||||
return run(std::move(fs));
|
||||
}
|
||||
|
||||
|
@ -11,37 +11,37 @@
|
||||
|
||||
namespace nostalgia::scene {
|
||||
|
||||
class SceneModule: public foundation::Module {
|
||||
class SceneModule: public keel::Module {
|
||||
private:
|
||||
SceneDocToSceneStaticConverter sceneDocToSceneStaticConverter;
|
||||
|
||||
public:
|
||||
[[nodiscard]]
|
||||
ox::Vector<foundation::TypeDescGenerator> types() const noexcept override {
|
||||
ox::Vector<keel::TypeDescGenerator> types() const noexcept override {
|
||||
return {
|
||||
foundation::generateTypeDesc<SceneDoc>,
|
||||
foundation::generateTypeDesc<SceneStatic>,
|
||||
keel::generateTypeDesc<SceneDoc>,
|
||||
keel::generateTypeDesc<SceneStatic>,
|
||||
};
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
ox::Vector<const foundation::BaseConverter*> converters() const noexcept override {
|
||||
ox::Vector<const keel::BaseConverter*> converters() const noexcept override {
|
||||
return {
|
||||
&sceneDocToSceneStaticConverter,
|
||||
};
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
ox::Vector<foundation::PackTransform> packTransforms() const noexcept override {
|
||||
ox::Vector<keel::PackTransform> packTransforms() const noexcept override {
|
||||
return {
|
||||
foundation::transformRule<SceneDoc, SceneStatic>,
|
||||
keel::transformRule<SceneDoc, SceneStatic>,
|
||||
};
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
static SceneModule mod;
|
||||
const foundation::Module *module() noexcept {
|
||||
const keel::Module *module() noexcept {
|
||||
return &mod;
|
||||
}
|
||||
|
||||
|
@ -4,10 +4,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <nostalgia/foundation/module.hpp>
|
||||
#include <keel/module.hpp>
|
||||
|
||||
namespace nostalgia::scene {
|
||||
|
||||
const foundation::Module *module() noexcept;
|
||||
const keel::Module *module() noexcept;
|
||||
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include <imgui.h>
|
||||
|
||||
#include <nostalgia/core/gfx.hpp>
|
||||
#include <nostalgia/foundation/media.hpp>
|
||||
#include <keel/media.hpp>
|
||||
#include <ox/std/memory.hpp>
|
||||
|
||||
#include "sceneeditor-imgui.hpp"
|
||||
|
@ -8,7 +8,7 @@ namespace nostalgia::scene {
|
||||
|
||||
SceneEditor::SceneEditor(core::Context *ctx, ox::CRStringView path) {
|
||||
m_ctx = ctx;
|
||||
oxRequireT(scn, foundation::readObj<SceneStatic>(m_ctx, path));
|
||||
oxRequireT(scn, keel::readObj<SceneStatic>(m_ctx, path));
|
||||
m_scene = *scn;
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
#include <nostalgia/core/gfx.hpp>
|
||||
#include <nostalgia/foundation/media.hpp>
|
||||
#include <keel/media.hpp>
|
||||
|
||||
#include "typeconv.hpp"
|
||||
|
||||
@ -34,10 +34,10 @@ constexpr void setLayerAttachments(unsigned layer, const TileDoc &srcTile, Scene
|
||||
}
|
||||
|
||||
ox::Error SceneDocToSceneStaticConverter::convert(
|
||||
foundation::Context *ctx,
|
||||
keel::Context *ctx,
|
||||
SceneDoc *src,
|
||||
SceneStatic *dst) const noexcept {
|
||||
oxRequire(ts, foundation::readObj<core::TileSheet>(ctx, src->tilesheet));
|
||||
oxRequire(ts, keel::readObj<core::TileSheet>(ctx, src->tilesheet));
|
||||
const auto layerCnt = src->tiles.size();
|
||||
dst->setLayerCnt(layerCnt);
|
||||
dst->tilesheet = ox::FileAddress(src->tilesheet);
|
||||
|
@ -4,14 +4,14 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <nostalgia/foundation/typeconv.hpp>
|
||||
#include <keel/typeconv.hpp>
|
||||
|
||||
#include "scenestatic.hpp"
|
||||
|
||||
namespace nostalgia::scene {
|
||||
|
||||
class SceneDocToSceneStaticConverter: public foundation::Converter<SceneDoc, SceneStatic> {
|
||||
ox::Error convert(foundation::Context*, SceneDoc *src, SceneStatic *dst) const noexcept final;
|
||||
class SceneDocToSceneStaticConverter: public keel::Converter<SceneDoc, SceneStatic> {
|
||||
ox::Error convert(keel::Context*, SceneDoc *src, SceneStatic *dst) const noexcept final;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -4,7 +4,7 @@ target_link_libraries(
|
||||
nost-pack
|
||||
OxClArgs
|
||||
OxLogConn
|
||||
NostalgiaPack
|
||||
Keel
|
||||
NostalgiaAppModules
|
||||
)
|
||||
|
||||
@ -19,6 +19,3 @@ install(
|
||||
RUNTIME DESTINATION
|
||||
bin
|
||||
)
|
||||
|
||||
|
||||
add_subdirectory(pack)
|
||||
|
@ -8,12 +8,9 @@
|
||||
#include <ox/fs/fs.hpp>
|
||||
#include <ox/logconn/logconn.hpp>
|
||||
|
||||
#include <keel/keel.hpp>
|
||||
#include <nostalgia/appmodules/appmodules.hpp>
|
||||
#include <nostalgia/core/typestore.hpp>
|
||||
#include <nostalgia/foundation/foundation.hpp>
|
||||
#include <nostalgia/foundation/module.hpp>
|
||||
|
||||
#include "pack/pack.hpp"
|
||||
|
||||
using namespace nostalgia;
|
||||
|
||||
@ -46,7 +43,7 @@ static ox::Result<ox::Buffer> readFileBuff(ox::CRStringView path) noexcept {
|
||||
}
|
||||
|
||||
static ox::Error generateTypes(ox::TypeStore *ts) noexcept {
|
||||
for (const auto mod : foundation::modules()) {
|
||||
for (const auto mod : keel::modules()) {
|
||||
for (auto gen : mod->types()) {
|
||||
oxReturnError(gen(ts));
|
||||
}
|
||||
@ -69,11 +66,11 @@ static ox::Error run(const ox::ClArgs &args) noexcept {
|
||||
ox::Buffer dstBuff(32 * ox::units::MB);
|
||||
oxReturnError(ox::FileSystem32::format(dstBuff.data(), dstBuff.size()));
|
||||
ox::FileSystem32 dst(ox::FileStore32(dstBuff.data(), dstBuff.size()));
|
||||
oxRequire(ctx, foundation::init(ox::make_unique<ox::PassThroughFS>(argSrc), "nost-pack"));
|
||||
oxRequire(ctx, keel::init(ox::make_unique<ox::PassThroughFS>(argSrc), "nost-pack"));
|
||||
core::TypeStore ts(ctx->rom.get());
|
||||
oxReturnError(generateTypes(&ts));
|
||||
oxReturnError(pack(ctx.get(), &ts, &dst));
|
||||
oxRequireM(pl, GbaPreloader::make());
|
||||
oxReturnError(keel::pack(ctx.get(), &ts, &dst));
|
||||
oxRequireM(pl, keel::GbaPreloader::make());
|
||||
oxReturnError(preload(&ts, &dst, pl.get()));
|
||||
oxReturnError(dst.resize());
|
||||
// resize buffer
|
||||
|
@ -1,25 +0,0 @@
|
||||
|
||||
add_library(
|
||||
NostalgiaPack
|
||||
pack.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
NostalgiaPack PUBLIC
|
||||
NostalgiaFoundation
|
||||
OxPreloader
|
||||
)
|
||||
|
||||
install(
|
||||
TARGETS
|
||||
NostalgiaPack
|
||||
ARCHIVE DESTINATION
|
||||
lib/nostalgia
|
||||
)
|
||||
|
||||
install(
|
||||
FILES
|
||||
pack.hpp
|
||||
DESTINATION
|
||||
include/nostalgia/tools/pack
|
||||
)
|
Loading…
x
Reference in New Issue
Block a user