[nostalgia] Add module for Scene

This commit is contained in:
2023-02-03 23:07:31 -06:00
parent ccf47c0e4b
commit 78798f69af
9 changed files with 110 additions and 11 deletions
+4
View File
@@ -2,6 +2,8 @@
add_library(
NostalgiaScene
scene.cpp
scenemodule.cpp
typeconv.cpp
)
target_link_libraries(
@@ -12,6 +14,8 @@ target_link_libraries(
install(
FILES
scene.hpp
scenemodule.hpp
typeconv.hpp
DESTINATION
include/nostalgia/scene
)
+10 -10
View File
@@ -11,9 +11,9 @@
namespace nostalgia::scene {
struct Tile {
struct TileDoc {
constexpr static auto TypeName = "net.drinkingtea.nostalgia.scene.Tile";
constexpr static auto TypeName = "net.drinkingtea.nostalgia.scene.TileDoc";
constexpr static auto TypeVersion = 1;
constexpr static auto Preloadable = true;
@@ -22,18 +22,18 @@ struct Tile {
};
oxModelBegin(Tile)
oxModelBegin(TileDoc)
oxModelFieldRename(sheet_idx, sheetIdx);
oxModelField(type);
oxModelEnd()
struct Scene {
struct SceneDoc {
using TileMapRow = ox::Vector<Tile>;
using TileMapRow = ox::Vector<TileDoc>;
using TileMapLayer = ox::Vector<TileMapRow>;
using TileMap = ox::Vector<TileMapLayer>;
constexpr static auto TypeName = "net.drinkingtea.nostalgia.scene.Scene";
constexpr static auto TypeName = "net.drinkingtea.nostalgia.scene.SceneDoc";
constexpr static auto TypeVersion = 1;
constexpr static auto Preloadable = true;
@@ -43,15 +43,15 @@ struct Scene {
};
oxModelBegin(Scene)
oxModelBegin(SceneDoc)
oxModelField(tilesheet)
oxModelField(palette)
oxModelField(tiles)
oxModelEnd()
struct SceneInstance {
struct Scene {
constexpr static auto TypeName = "net.drinkingtea.nostalgia.scene.SceneInstance";
constexpr static auto TypeName = "net.drinkingtea.nostalgia.scene.Scene";
constexpr static auto TypeVersion = 1;
constexpr static auto Preloadable = true;
@@ -96,7 +96,7 @@ struct SceneInstance {
};
oxModelBegin(SceneInstance)
oxModelBegin(Scene)
oxModelField(layers)
oxModelField(columns)
oxModelField(rows)
+25
View File
@@ -0,0 +1,25 @@
/*
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/
#include <ox/model/model.hpp>
#include "scenemodule.hpp"
namespace nostalgia::scene {
SceneModule SceneModule::mod;
ox::Vector<foundation::BaseConverter*> SceneModule::converters() const noexcept {
return {
&sceneToSceneInstaceConverter,
};
}
ox::Vector<foundation::PackTransform> SceneModule::packTransforms() const noexcept {
return {
foundation::transformRule<SceneDoc, Scene>,
};
}
}
+25
View File
@@ -0,0 +1,25 @@
/*
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/
#pragma once
#include <nostalgia/foundation/module.hpp>
#include "typeconv.hpp"
namespace nostalgia::scene {
class SceneModule: public foundation::Module {
private:
mutable SceneDocToSceneConverter sceneToSceneInstaceConverter;
public:
static SceneModule mod;
[[nodiscard]]
ox::Vector<foundation::BaseConverter*> converters() const noexcept override;
[[nodiscard]]
ox::Vector<foundation::PackTransform> packTransforms() const noexcept override;
};
}
+15
View File
@@ -0,0 +1,15 @@
/*
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/
#include "typeconv.hpp"
namespace nostalgia::scene {
// Type converters
ox::Error SceneDocToSceneConverter::convert(foundation::Context*, SceneDoc *, Scene *) noexcept {
return {};
}
}
+17
View File
@@ -0,0 +1,17 @@
/*
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/
#pragma once
#include <nostalgia/foundation/typeconv.hpp>
#include "scene.hpp"
namespace nostalgia::scene {
struct SceneDocToSceneConverter: public foundation::Converter<SceneDoc, Scene> {
ox::Error convert(foundation::Context*, SceneDoc *src, Scene *dst) noexcept final;
};
}