Compare commits
3 Commits
04cb710d56
...
bb694b9b13
| Author | SHA1 | Date | |
|---|---|---|---|
| bb694b9b13 | |||
| 76a8499630 | |||
| 6680ffa7a8 |
@@ -2,12 +2,9 @@
|
||||
* 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 <ox/std/utility.hpp>
|
||||
|
||||
#include <keel/media.hpp>
|
||||
|
||||
@@ -15,7 +12,8 @@
|
||||
|
||||
namespace keel {
|
||||
|
||||
static ox::Error pathToInode(keel::Context *ctx, ox::FileSystem *dest, ox::ModelObject *obj) noexcept {
|
||||
static ox::Error pathToInode(
|
||||
[[maybe_unused]] 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>();
|
||||
@@ -32,8 +30,12 @@ static ox::Error pathToInode(keel::Context *ctx, ox::FileSystem *dest, ox::Model
|
||||
return {};
|
||||
}
|
||||
if (beginsWith(path, "uuid://")) {
|
||||
#ifndef OX_BARE_METAL
|
||||
const auto uuid = ox::StringView(path).substr(7);
|
||||
path = ctx->uuidToPath[uuid];
|
||||
#else
|
||||
return OxError(1, "UUID to path conversion not supported on this platform");
|
||||
#endif
|
||||
}
|
||||
oxRequire(s, dest->stat(path));
|
||||
oxReturnError(o["type"].set(static_cast<int8_t>(ox::FileAddressType::Inode)));
|
||||
@@ -76,7 +78,12 @@ static ox::Error transformFileAddressesObj(keel::Context *ctx, ox::FileSystem *d
|
||||
return {};
|
||||
}
|
||||
|
||||
static ox::Error doTransformations(keel::Context *ctx, ox::TypeStore *ts, ox::FileSystem *dest, ox::CRStringView filePath) noexcept {
|
||||
static ox::Error doTransformations(
|
||||
[[maybe_unused]] keel::Context *ctx,
|
||||
[[maybe_unused]] ox::TypeStore *ts,
|
||||
[[maybe_unused]] ox::FileSystem *dest,
|
||||
[[maybe_unused]] ox::CRStringView filePath) noexcept {
|
||||
#ifndef OX_BARE_METAL
|
||||
// load file
|
||||
oxRequire(s, dest->stat(filePath));
|
||||
// do transformations
|
||||
@@ -91,6 +98,9 @@ static ox::Error doTransformations(keel::Context *ctx, ox::TypeStore *ts, ox::Fi
|
||||
// write file to dest
|
||||
oxReturnError(dest->write(s.inode, buff.data(), buff.size()));
|
||||
return {};
|
||||
#else
|
||||
return OxError(1, "Transformations not supported on this platform");
|
||||
#endif
|
||||
}
|
||||
|
||||
// claw file transformations are broken out from copy because path to inode
|
||||
@@ -122,8 +132,8 @@ struct VerificationPair {
|
||||
ox::String path;
|
||||
ox::Buffer buff;
|
||||
VerificationPair(ox::String &&pPath, ox::Buffer &&pBuff) noexcept:
|
||||
path(std::forward<ox::String>(pPath)),
|
||||
buff(std::forward<ox::Buffer>(pBuff)) {
|
||||
path(ox::forward<ox::String>(pPath)),
|
||||
buff(ox::forward<ox::Buffer>(pBuff)) {
|
||||
}
|
||||
};
|
||||
|
||||
@@ -158,7 +168,7 @@ static ox::Error copyFS(ox::FileSystem *src, ox::FileSystem *dest) noexcept {
|
||||
ox::Vector<VerificationPair> verificationPairs;
|
||||
oxReturnError(copy(src, dest, "/", &verificationPairs));
|
||||
// verify all at once in addition to right after the files are written
|
||||
oxOutf("Verifying completed destination\n");
|
||||
oxOut("Verifying completed destination\n");
|
||||
for (const auto &v : verificationPairs) {
|
||||
oxReturnError(verifyFile(dest, v.path, v.buff));
|
||||
}
|
||||
@@ -173,5 +183,3 @@ ox::Error pack(keel::Context *ctx, ox::TypeStore *ts, ox::FileSystem *dest) noex
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4,11 +4,6 @@ add_library(
|
||||
typeconv.cpp
|
||||
)
|
||||
|
||||
target_include_directories(
|
||||
NostalgiaCore-Keel PUBLIC
|
||||
../include
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
NostalgiaCore-Keel PUBLIC
|
||||
Keel
|
||||
|
||||
@@ -14,12 +14,12 @@
|
||||
|
||||
namespace nostalgia::core {
|
||||
|
||||
class CoreModule: public keel::Module {
|
||||
class KeelModule: public keel::Module {
|
||||
private:
|
||||
NostalgiaPaletteToPaletteConverter nostalgiaPaletteToPaletteConverter;
|
||||
TileSheetV1ToTileSheetConverter nostalgiaGraphicToTileSheetConverter;
|
||||
TileSheetToCompactTileSheetConverter tileSheetToCompactTileSheetConverter;
|
||||
TileSheetV2ToTileSheetConverter tileSheetV2ToTileSheetConverter;
|
||||
NostalgiaPaletteToPaletteConverter m_nostalgiaPaletteToPaletteConverter;
|
||||
TileSheetV1ToTileSheetConverter m_tileSheetV1ToTileSheetV2Converter;
|
||||
TileSheetToCompactTileSheetConverter m_tileSheetToCompactTileSheetConverter;
|
||||
TileSheetV2ToTileSheetConverter m_tileSheetV2ToTileSheetConverter;
|
||||
|
||||
public:
|
||||
[[nodiscard]]
|
||||
@@ -29,7 +29,6 @@ class CoreModule: public keel::Module {
|
||||
keel::generateTypeDesc<TileSheetV2>,
|
||||
keel::generateTypeDesc<TileSheet>,
|
||||
keel::generateTypeDesc<CompactTileSheet>,
|
||||
keel::generateTypeDesc<NostalgiaPalette>,
|
||||
keel::generateTypeDesc<Palette>,
|
||||
};
|
||||
}
|
||||
@@ -37,10 +36,10 @@ class CoreModule: public keel::Module {
|
||||
[[nodiscard]]
|
||||
ox::Vector<const keel::BaseConverter*> converters() const noexcept final {
|
||||
return {
|
||||
&nostalgiaPaletteToPaletteConverter,
|
||||
&nostalgiaGraphicToTileSheetConverter,
|
||||
&tileSheetToCompactTileSheetConverter,
|
||||
&tileSheetV2ToTileSheetConverter,
|
||||
&m_nostalgiaPaletteToPaletteConverter,
|
||||
&m_tileSheetV1ToTileSheetV2Converter,
|
||||
&m_tileSheetV2ToTileSheetConverter,
|
||||
&m_tileSheetToCompactTileSheetConverter,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -50,7 +49,8 @@ class CoreModule: public keel::Module {
|
||||
// convert tilesheets to CompactTileSheets
|
||||
[](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);
|
||||
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>()) {
|
||||
@@ -63,7 +63,7 @@ class CoreModule: public keel::Module {
|
||||
}
|
||||
};
|
||||
|
||||
static CoreModule mod;
|
||||
static KeelModule mod;
|
||||
const keel::Module *keelModule() noexcept {
|
||||
return &mod;
|
||||
}
|
||||
|
||||
@@ -27,8 +27,6 @@ target_link_libraries(
|
||||
lodepng
|
||||
)
|
||||
|
||||
#target_compile_definitions(NostalgiaCore-Studio PRIVATE QT_QML_DEBUG)
|
||||
|
||||
install(
|
||||
TARGETS
|
||||
NostalgiaCore-Studio-ImGui
|
||||
|
||||
@@ -4,13 +4,14 @@ add_library(
|
||||
typeconv.cpp
|
||||
)
|
||||
|
||||
target_include_directories(
|
||||
NostalgiaScene-Keel PUBLIC
|
||||
../include
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
NostalgiaScene-Keel PUBLIC
|
||||
Keel
|
||||
NostalgiaScene
|
||||
)
|
||||
install(
|
||||
TARGETS
|
||||
NostalgiaScene-Keel
|
||||
LIBRARY DESTINATION
|
||||
${NOSTALGIA_DIST_MODULE}
|
||||
)
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace nostalgia::scene {
|
||||
|
||||
class SceneModule: public keel::Module {
|
||||
private:
|
||||
SceneDocToSceneStaticConverter sceneDocToSceneStaticConverter;
|
||||
SceneDocToSceneStaticConverter m_sceneDocToSceneStaticConverter;
|
||||
|
||||
public:
|
||||
[[nodiscard]]
|
||||
@@ -26,7 +26,7 @@ class SceneModule: public keel::Module {
|
||||
[[nodiscard]]
|
||||
ox::Vector<const keel::BaseConverter*> converters() const noexcept override {
|
||||
return {
|
||||
&sceneDocToSceneStaticConverter,
|
||||
&m_sceneDocToSceneStaticConverter,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user