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