[nostalgia] Split part of Core out into Foundation, add module system

This commit is contained in:
2023-02-03 00:41:24 -06:00
parent 83589287bc
commit 7868b0678f
50 changed files with 742 additions and 470 deletions
+21 -13
View File
@@ -1,42 +1,41 @@
/*
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/
#pragma once
#include <ox/fs/fs.hpp>
#include <ox/preloader/preloader.hpp>
#include <ox/std/error.hpp>
#include <ox/std/types.hpp>
#include <ox/std/vector.hpp>
namespace nostalgia::scene {
struct TileDoc {
struct Tile {
constexpr static auto Preloadable = true;
constexpr static auto TypeName = "net.drinkingtea.nostalgia.scene.Tile";
constexpr static auto TypeVersion = 1;
constexpr static auto Preloadable = true;
uint16_t sheetIdx = 0;
ox::String sheetIdx;
uint8_t type = 0;
};
oxModelBegin(TileDoc)
oxModelField(sheetIdx);
oxModelBegin(Tile)
oxModelFieldRename(sheet_idx, sheetIdx);
oxModelField(type);
oxModelEnd()
struct SceneDoc {
struct Scene {
using TileMapRow = ox::Vector<TileDoc>;
using TileMapRow = ox::Vector<Tile>;
using TileMapLayer = ox::Vector<TileMapRow>;
using TileMap = ox::Vector<TileMapLayer>;
constexpr static auto Preloadable = true;
constexpr static auto TypeName = "net.drinkingtea.nostalgia.scene.Scene";
constexpr static auto TypeVersion = 1;
constexpr static auto Preloadable = true;
ox::FileAddress tilesheet;
ox::FileAddress palette;
@@ -44,7 +43,7 @@ struct SceneDoc {
};
oxModelBegin(SceneDoc)
oxModelBegin(Scene)
oxModelField(tilesheet)
oxModelField(palette)
oxModelField(tiles)
@@ -63,8 +62,8 @@ struct SceneInstance {
struct Layer {
uint16_t &columns;
uint16_t &rows;
uint16_t *tileMapIdx;
uint8_t *tileType;
uint16_t *tileMapIdx = nullptr;
uint8_t *tileType = nullptr;
constexpr Layer(uint16_t &pColumns,
uint16_t &pRows,
uint16_t *pTileMapIdx,
@@ -90,6 +89,15 @@ struct SceneInstance {
constexpr Layer layer(std::size_t i) noexcept {
return {columns[i], rows[i], tileMapIdx[i].data(), tileType[i].data()};
}
};
oxModelBegin(SceneInstance)
oxModelField(layers)
oxModelField(columns)
oxModelField(rows)
oxModelFieldRename(tile_map_idx, tileMapIdx)
oxModelFieldRename(tile_type, tileType)
oxModelEnd()
}