diff --git a/src/nostalgia/scene/scene.hpp b/src/nostalgia/scene/scene.hpp index 1a00fec9..80ebea72 100644 --- a/src/nostalgia/scene/scene.hpp +++ b/src/nostalgia/scene/scene.hpp @@ -18,7 +18,7 @@ struct Tile { constexpr static auto Preloadable = true; ox::String sheetIdx; - uint8_t type = 0; + uint8_t type = 0; }; @@ -51,6 +51,10 @@ oxModelEnd() struct SceneInstance { + constexpr static auto TypeName = "net.drinkingtea.nostalgia.scene.SceneInstance"; + constexpr static auto TypeVersion = 1; + constexpr static auto Preloadable = true; + struct Tile { uint16_t &tileMapIdx; uint8_t &tileType; diff --git a/src/nostalgia/tools/pack.cpp b/src/nostalgia/tools/pack.cpp index ef2471fa..ecf7bab9 100644 --- a/src/nostalgia/tools/pack.cpp +++ b/src/nostalgia/tools/pack.cpp @@ -10,6 +10,7 @@ #include #include +#include #include "pack/pack.hpp" @@ -57,10 +58,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::PassThroughFS src(argSrc); + auto src = ox::make_unique(argSrc); ox::FileSystem32 dst(ox::FileStore32(dstBuff.data(), dstBuff.size())); - core::TypeStore ts(&src); - oxReturnError(pack(&ts, &src, &dst)); + core::TypeStore ts(src.get()); + auto ctx = foundation::init(std::move(src), "nost-pack"); + oxReturnError(pack(ctx.get(), &ts, ctx->rom.get(), &dst)); oxRequireM(pl, GbaPreloader::make()); oxReturnError(preload(&ts, &dst, pl.get())); oxReturnError(dst.resize()); diff --git a/src/nostalgia/tools/pack/pack.cpp b/src/nostalgia/tools/pack/pack.cpp index a1f880db..8f036860 100644 --- a/src/nostalgia/tools/pack/pack.cpp +++ b/src/nostalgia/tools/pack/pack.cpp @@ -58,13 +58,13 @@ static ox::Error transformObj(ox::FileSystem *dest, ox::ModelObject *obj) noexce return {}; } -static ox::Error doTransformations(core::TypeStore *ts, ox::FileSystem *dest, ox::CRStringView filePath) noexcept { +static ox::Error doTransformations(foundation::Context *ctx, core::TypeStore *ts, ox::FileSystem *dest, ox::CRStringView filePath) noexcept { if (endsWith(filePath, ".ng") || endsWith(filePath, ".npal")) { // load file oxRequire(s, dest->stat(filePath)); oxRequireM(buff, dest->read(s.inode)); if (endsWith(filePath, ".ng")) { - oxReturnError(foundation::convertBuffToBuff(nullptr, buff, ox::ClawFormat::Metal).moveTo(&buff)); + oxReturnError(foundation::convertBuffToBuff(ctx, buff, ox::ClawFormat::Metal).moveTo(&buff)); } oxRequireM(obj, ox::readClaw(ts, buff)); // do transformations @@ -78,7 +78,7 @@ static ox::Error doTransformations(core::TypeStore *ts, ox::FileSystem *dest, ox // claw file transformations are broken out because path to inode // transformations need to be done after the copy to the new FS is complete -static ox::Error transformClaw(core::TypeStore *ts, ox::FileSystem *dest, ox::CRStringView path) noexcept { +static ox::Error transformClaw(foundation::Context *ctx, core::TypeStore *ts, ox::FileSystem *dest, ox::CRStringView path) noexcept { // copy oxTracef("pack::transformClaw", "path: {}", path); oxRequire(fileList, dest->ls(path)); @@ -87,9 +87,9 @@ static ox::Error transformClaw(core::TypeStore *ts, ox::FileSystem *dest, ox::CR oxRequire(stat, dest->stat(filePath)); if (stat.fileType == ox::FileType::Directory) { const auto dir = ox::sfmt("{}{}/", path, name); - oxReturnError(transformClaw(ts, dest, dir)); + oxReturnError(transformClaw(ctx, ts, dest, dir)); } else { - oxReturnError(doTransformations(ts, dest, filePath)); + oxReturnError(doTransformations(ctx, ts, dest, filePath)); } } return {}; @@ -204,10 +204,10 @@ ox::Error appendBinary(ox::Buffer *binBuff, ox::Buffer *fsBuff, GbaPreloader *pl return {}; } -ox::Error pack(core::TypeStore *ts, ox::FileSystem *src, ox::FileSystem *dest) noexcept { +ox::Error pack(foundation::Context *ctx, core::TypeStore *ts, ox::FileSystem *src, ox::FileSystem *dest) noexcept { oxReturnError(copy(src, dest, "/")); oxReturnError(ox::buildTypeDef(ts)); - oxReturnError(transformClaw(ts, dest, "/")); + oxReturnError(transformClaw(ctx, ts, dest, "/")); return {}; } diff --git a/src/nostalgia/tools/pack/pack.hpp b/src/nostalgia/tools/pack/pack.hpp index aa3bc03b..9a668713 100644 --- a/src/nostalgia/tools/pack/pack.hpp +++ b/src/nostalgia/tools/pack/pack.hpp @@ -2,10 +2,15 @@ * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. */ +#include #include namespace nostalgia { +namespace foundation { +class Context; +} + namespace core { class TypeStore; } @@ -90,7 +95,7 @@ using GbaPreloader = ox::Preloader; ox::Error appendBinary(ox::Buffer *binBuff, ox::Buffer *fsBuff, GbaPreloader *pl) noexcept; -auto pack(core::TypeStore *ts, ox::FileSystem *src, ox::FileSystem *dest) noexcept -> ox::Error; +auto pack(foundation::Context *ctx, core::TypeStore *ts, ox::FileSystem *src, ox::FileSystem *dest) noexcept -> ox::Error; auto preload(core::TypeStore *ts, ox::FileSystem *src, GbaPreloader *ph) noexcept -> ox::Error;