[nostalgia/tools/pack] Fix nost-pack to pass in proper Context
This commit is contained in:
parent
7868b0678f
commit
8bcffc73ff
@ -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;
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include <nostalgia/appmodules/appmodules.hpp>
|
||||
#include <nostalgia/core/typestore.hpp>
|
||||
#include <nostalgia/foundation/foundation.hpp>
|
||||
|
||||
#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<ox::PassThroughFS>(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());
|
||||
|
@ -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<core::CompactTileSheet>(nullptr, buff, ox::ClawFormat::Metal).moveTo(&buff));
|
||||
oxReturnError(foundation::convertBuffToBuff<core::CompactTileSheet>(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<core::CompactTileSheet>(ts));
|
||||
oxReturnError(transformClaw(ts, dest, "/"));
|
||||
oxReturnError(transformClaw(ctx, ts, dest, "/"));
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -2,10 +2,15 @@
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#include <ox/fs/fs.hpp>
|
||||
#include <ox/preloader/preloader.hpp>
|
||||
|
||||
namespace nostalgia {
|
||||
|
||||
namespace foundation {
|
||||
class Context;
|
||||
}
|
||||
|
||||
namespace core {
|
||||
class TypeStore;
|
||||
}
|
||||
@ -90,7 +95,7 @@ using GbaPreloader = ox::Preloader<GbaPlatSpec>;
|
||||
|
||||
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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user