[nostalgia] Remove scene package, finish stubbing out sound
Some checks failed
Build / build (push) Failing after 21s
Some checks failed
Build / build (push) Failing after 21s
This commit is contained in:
parent
b3952cabbc
commit
b94d6b5061
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
add_subdirectory(gfx)
|
add_subdirectory(gfx)
|
||||||
add_subdirectory(sound)
|
add_subdirectory(sound)
|
||||||
add_subdirectory(scene)
|
|
||||||
|
|
||||||
# module libraries
|
# module libraries
|
||||||
|
|
||||||
@ -15,7 +14,7 @@ target_link_libraries(
|
|||||||
NostalgiaKeelModules PUBLIC
|
NostalgiaKeelModules PUBLIC
|
||||||
Keel
|
Keel
|
||||||
NostalgiaGfx-Keel
|
NostalgiaGfx-Keel
|
||||||
NostalgiaScene-Keel
|
NostalgiaSound-Keel
|
||||||
)
|
)
|
||||||
install(
|
install(
|
||||||
FILES
|
FILES
|
||||||
@ -35,7 +34,6 @@ if(NOSTALGIA_BUILD_STUDIO)
|
|||||||
StudioAppLib
|
StudioAppLib
|
||||||
NostalgiaGfx-Studio-ImGui
|
NostalgiaGfx-Studio-ImGui
|
||||||
NostalgiaSound-Studio-ImGui
|
NostalgiaSound-Studio-ImGui
|
||||||
NostalgiaScene-Studio
|
|
||||||
)
|
)
|
||||||
install(
|
install(
|
||||||
FILES
|
FILES
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <nostalgia/gfx/keelmodule.hpp>
|
#include <nostalgia/gfx/keelmodule.hpp>
|
||||||
#include <nostalgia/scene/keelmodule.hpp>
|
#include <nostalgia/sound/keelmodule.hpp>
|
||||||
|
|
||||||
namespace nostalgia {
|
namespace nostalgia {
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ void registerKeelModules() noexcept {
|
|||||||
}
|
}
|
||||||
modulesRegistered = true;
|
modulesRegistered = true;
|
||||||
keel::registerModule(gfx::keelModule());
|
keel::registerModule(gfx::keelModule());
|
||||||
keel::registerModule(scene::keelModule());
|
keel::registerModule(sound::keelModule());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
add_subdirectory(src)
|
|
||||||
|
|
||||||
target_include_directories(
|
|
||||||
NostalgiaScene PUBLIC
|
|
||||||
include
|
|
||||||
)
|
|
||||||
|
|
||||||
install(
|
|
||||||
DIRECTORY
|
|
||||||
include/nostalgia
|
|
||||||
DESTINATION
|
|
||||||
include
|
|
||||||
)
|
|
@ -1,27 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <nostalgia/gfx/context.hpp>
|
|
||||||
|
|
||||||
#include "scenestatic.hpp"
|
|
||||||
|
|
||||||
namespace nostalgia::scene {
|
|
||||||
|
|
||||||
class Scene {
|
|
||||||
private:
|
|
||||||
SceneStatic const&m_sceneStatic;
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit Scene(SceneStatic const&sceneStatic) noexcept;
|
|
||||||
|
|
||||||
ox::Error setupDisplay(gfx::Context &ctx) const noexcept;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void setupLayer(gfx::Context&, ox::Vector<uint16_t> const&layer, unsigned layerNo) const noexcept;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
@ -1,228 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <ox/fs/fs.hpp>
|
|
||||||
#include <ox/std/error.hpp>
|
|
||||||
#include <ox/std/size.hpp>
|
|
||||||
#include <ox/std/types.hpp>
|
|
||||||
#include <ox/std/vector.hpp>
|
|
||||||
|
|
||||||
#include <nostalgia/gfx/tilesheet.hpp>
|
|
||||||
|
|
||||||
namespace nostalgia::scene {
|
|
||||||
|
|
||||||
struct SpriteDoc {
|
|
||||||
|
|
||||||
constexpr static auto TypeName = "net.drinkingtea.nostalgia.scene.SpriteDoc";
|
|
||||||
constexpr static auto TypeVersion = 1;
|
|
||||||
constexpr static auto Preloadable = true;
|
|
||||||
|
|
||||||
ox::String tilesheetPath;
|
|
||||||
ox::Vector<gfx::SubSheetId> subsheetId;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
struct TileDoc {
|
|
||||||
|
|
||||||
constexpr static auto TypeName = "net.drinkingtea.nostalgia.scene.TileDoc";
|
|
||||||
constexpr static auto TypeVersion = 1;
|
|
||||||
constexpr static auto Preloadable = true;
|
|
||||||
|
|
||||||
gfx::SubSheetId subsheetId = -1;
|
|
||||||
ox::String subsheetPath;
|
|
||||||
uint8_t type = 0;
|
|
||||||
ox::Array<uint8_t, 4> layerAttachments;
|
|
||||||
|
|
||||||
[[nodiscard]]
|
|
||||||
constexpr ox::Result<gfx::SubSheetId> getSubsheetId(gfx::TileSheet const&ts) const noexcept {
|
|
||||||
// prefer the already present ID
|
|
||||||
if (subsheetId > -1) {
|
|
||||||
return subsheetId;
|
|
||||||
}
|
|
||||||
return getIdFor(ts, subsheetPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]]
|
|
||||||
constexpr ox::Result<ox::StringView> getSubsheetPath(
|
|
||||||
gfx::TileSheet const&ts) const noexcept {
|
|
||||||
// prefer the already present path
|
|
||||||
if (!subsheetPath.len()) {
|
|
||||||
return gfx::getNameFor(ts, subsheetId);
|
|
||||||
}
|
|
||||||
return ox::StringView(subsheetPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
OX_MODEL_BEGIN(TileDoc)
|
|
||||||
OX_MODEL_FIELD_RENAME(subsheetId, subsheet_id)
|
|
||||||
OX_MODEL_FIELD_RENAME(subsheetPath, subsheet_path)
|
|
||||||
OX_MODEL_FIELD(type)
|
|
||||||
OX_MODEL_FIELD_RENAME(layerAttachments, layer_attachments)
|
|
||||||
OX_MODEL_END()
|
|
||||||
|
|
||||||
struct SceneDoc {
|
|
||||||
|
|
||||||
using TileMapRow = ox::Vector<TileDoc>;
|
|
||||||
using TileMapLayer = ox::Vector<TileMapRow>;
|
|
||||||
using TileMap = ox::Vector<TileMapLayer>;
|
|
||||||
|
|
||||||
constexpr static auto TypeName = "net.drinkingtea.nostalgia.scene.SceneDoc";
|
|
||||||
constexpr static auto TypeVersion = 1;
|
|
||||||
constexpr static auto Preloadable = true;
|
|
||||||
|
|
||||||
ox::String tilesheet; // path
|
|
||||||
ox::Vector<ox::String> palettes; // paths
|
|
||||||
TileMap tiles;
|
|
||||||
|
|
||||||
[[nodiscard]]
|
|
||||||
constexpr ox::Size size(std::size_t layerIdx) const noexcept {
|
|
||||||
const auto &layer = this->tiles[layerIdx];
|
|
||||||
const auto rowCnt = static_cast<int>(layer.size());
|
|
||||||
if (!rowCnt) {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
auto colCnt = layer[0].size();
|
|
||||||
// find shortest row (they should all be the same, but you know this data
|
|
||||||
// could come from a file)
|
|
||||||
for (auto const&row : layer) {
|
|
||||||
colCnt = ox::min(colCnt, row.size());
|
|
||||||
}
|
|
||||||
return {static_cast<int>(colCnt), rowCnt};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
OX_MODEL_BEGIN(SceneDoc)
|
|
||||||
OX_MODEL_FIELD(tilesheet)
|
|
||||||
OX_MODEL_FIELD(palettes)
|
|
||||||
OX_MODEL_FIELD(tiles)
|
|
||||||
OX_MODEL_END()
|
|
||||||
|
|
||||||
|
|
||||||
constexpr void setTopEdge(uint8_t &layerAttachments, unsigned val) noexcept {
|
|
||||||
const auto val8 = static_cast<uint8_t>(val);
|
|
||||||
layerAttachments = (layerAttachments & 0b11111100) | val8;
|
|
||||||
}
|
|
||||||
constexpr void setBottomEdge(uint8_t &layerAttachments, unsigned val) noexcept {
|
|
||||||
const auto val8 = static_cast<uint8_t>(val);
|
|
||||||
layerAttachments = (layerAttachments & 0b11110011) | static_cast<uint8_t>(val8 << 2);
|
|
||||||
}
|
|
||||||
constexpr void setLeftEdge(uint8_t &layerAttachments, unsigned val) noexcept {
|
|
||||||
const auto val8 = static_cast<uint8_t>(val);
|
|
||||||
layerAttachments = (layerAttachments & 0b11001111) | static_cast<uint8_t>(val8 << 4);
|
|
||||||
}
|
|
||||||
constexpr void setRightEdge(uint8_t &layerAttachments, unsigned val) noexcept {
|
|
||||||
const auto val8 = static_cast<uint8_t>(val);
|
|
||||||
layerAttachments = (layerAttachments & 0b00111111) | static_cast<uint8_t>(val8 << 6);
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]]
|
|
||||||
constexpr unsigned topEdge(uint8_t layerAttachments) noexcept {
|
|
||||||
return layerAttachments & 0b11;
|
|
||||||
}
|
|
||||||
[[nodiscard]]
|
|
||||||
constexpr unsigned bottomEdge(uint8_t layerAttachments) noexcept {
|
|
||||||
return (layerAttachments >> 2) & 0b11;
|
|
||||||
}
|
|
||||||
[[nodiscard]]
|
|
||||||
constexpr unsigned leftEdge(uint8_t layerAttachments) noexcept {
|
|
||||||
return (layerAttachments >> 4) & 0b11;
|
|
||||||
}
|
|
||||||
[[nodiscard]]
|
|
||||||
constexpr unsigned rightEdge(uint8_t layerAttachments) noexcept {
|
|
||||||
return (layerAttachments >> 6) & 0b11;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
struct SceneStatic {
|
|
||||||
|
|
||||||
constexpr static auto TypeName = "net.drinkingtea.nostalgia.scene.SceneStatic";
|
|
||||||
constexpr static auto TypeVersion = 1;
|
|
||||||
constexpr static auto Preloadable = true;
|
|
||||||
|
|
||||||
struct Tile {
|
|
||||||
uint16_t &tileMapIdx;
|
|
||||||
uint8_t &tileType;
|
|
||||||
uint8_t &layerAttachments;
|
|
||||||
constexpr Tile(uint16_t &pTileMapIdx, uint8_t &pTileType, uint8_t &pLayerAttachments) noexcept:
|
|
||||||
tileMapIdx(pTileMapIdx),
|
|
||||||
tileType(pTileType),
|
|
||||||
layerAttachments(pLayerAttachments) {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
struct Layer {
|
|
||||||
uint16_t &columns;
|
|
||||||
uint16_t &rows;
|
|
||||||
ox::Vector<uint16_t> &tileMapIdx;
|
|
||||||
ox::Vector<uint8_t> &tileType;
|
|
||||||
ox::Vector<uint8_t> &layerAttachments;
|
|
||||||
constexpr Layer(
|
|
||||||
uint16_t &pColumns,
|
|
||||||
uint16_t &pRows,
|
|
||||||
ox::Vector<uint16_t> &pTileMapIdx,
|
|
||||||
ox::Vector<uint8_t> &pTileType,
|
|
||||||
ox::Vector<uint8_t> &pLayerAttachments) noexcept:
|
|
||||||
columns(pColumns),
|
|
||||||
rows(pRows),
|
|
||||||
tileMapIdx(pTileMapIdx),
|
|
||||||
tileType(pTileType),
|
|
||||||
layerAttachments(pLayerAttachments) {
|
|
||||||
}
|
|
||||||
[[nodiscard]]
|
|
||||||
constexpr Tile tile(std::size_t i) noexcept {
|
|
||||||
return {tileMapIdx[i], tileType[i], layerAttachments[i]};
|
|
||||||
}
|
|
||||||
constexpr auto setDimensions(ox::Size dim) noexcept {
|
|
||||||
columns = static_cast<uint16_t>(dim.width);
|
|
||||||
rows = static_cast<uint16_t>(dim.height);
|
|
||||||
const auto tileCnt = static_cast<unsigned>(columns * rows);
|
|
||||||
tileMapIdx.resize(tileCnt);
|
|
||||||
tileType.resize(tileCnt);
|
|
||||||
layerAttachments.resize(tileCnt);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ox::FileAddress tilesheet;
|
|
||||||
ox::Vector<ox::FileAddress> palettes;
|
|
||||||
// tile layer data
|
|
||||||
ox::Vector<uint16_t> columns;
|
|
||||||
ox::Vector<uint16_t> rows;
|
|
||||||
ox::Vector<ox::Vector<uint16_t>> tileMapIdx;
|
|
||||||
ox::Vector<ox::Vector<uint8_t>> tileType;
|
|
||||||
ox::Vector<ox::Vector<uint8_t>> layerAttachments;
|
|
||||||
|
|
||||||
[[nodiscard]]
|
|
||||||
constexpr Layer layer(std::size_t i) noexcept {
|
|
||||||
return {
|
|
||||||
columns[i],
|
|
||||||
rows[i],
|
|
||||||
tileMapIdx[i],
|
|
||||||
tileType[i],
|
|
||||||
layerAttachments[i],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr auto setLayerCnt(std::size_t layerCnt) noexcept {
|
|
||||||
this->layerAttachments.resize(layerCnt);
|
|
||||||
this->columns.resize(layerCnt);
|
|
||||||
this->rows.resize(layerCnt);
|
|
||||||
this->tileMapIdx.resize(layerCnt);
|
|
||||||
this->tileType.resize(layerCnt);
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
OX_MODEL_BEGIN(SceneStatic)
|
|
||||||
OX_MODEL_FIELD(tilesheet)
|
|
||||||
OX_MODEL_FIELD(palettes)
|
|
||||||
OX_MODEL_FIELD(columns)
|
|
||||||
OX_MODEL_FIELD(rows)
|
|
||||||
OX_MODEL_FIELD(tileMapIdx)
|
|
||||||
OX_MODEL_FIELD(tileType)
|
|
||||||
OX_MODEL_FIELD(layerAttachments)
|
|
||||||
OX_MODEL_END()
|
|
||||||
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
|
|
||||||
add_library(
|
|
||||||
NostalgiaScene
|
|
||||||
scene.cpp
|
|
||||||
scenestatic.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
target_include_directories(
|
|
||||||
NostalgiaScene PUBLIC
|
|
||||||
../include
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(
|
|
||||||
NostalgiaScene PUBLIC
|
|
||||||
NostalgiaGfx
|
|
||||||
)
|
|
||||||
|
|
||||||
add_subdirectory(keel)
|
|
||||||
if(NOSTALGIA_BUILD_STUDIO)
|
|
||||||
add_subdirectory(studio)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
install(
|
|
||||||
TARGETS
|
|
||||||
NostalgiaScene
|
|
||||||
DESTINATION
|
|
||||||
LIBRARY DESTINATION lib
|
|
||||||
ARCHIVE DESTINATION lib
|
|
||||||
)
|
|
@ -1,17 +0,0 @@
|
|||||||
add_library(
|
|
||||||
NostalgiaScene-Keel
|
|
||||||
keelmodule.cpp
|
|
||||||
typeconv.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(
|
|
||||||
NostalgiaScene-Keel PUBLIC
|
|
||||||
Keel
|
|
||||||
NostalgiaScene
|
|
||||||
)
|
|
||||||
install(
|
|
||||||
TARGETS
|
|
||||||
NostalgiaScene-Keel
|
|
||||||
LIBRARY DESTINATION
|
|
||||||
${NOSTALGIA_DIST_MODULE}
|
|
||||||
)
|
|
@ -1,51 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <keel/module.hpp>
|
|
||||||
|
|
||||||
#include <nostalgia/scene/scenestatic.hpp>
|
|
||||||
|
|
||||||
#include "typeconv.hpp"
|
|
||||||
|
|
||||||
namespace nostalgia::scene {
|
|
||||||
|
|
||||||
static class: public keel::Module {
|
|
||||||
private:
|
|
||||||
SceneDocToSceneStaticConverter m_sceneDocToSceneStaticConverter;
|
|
||||||
|
|
||||||
public:
|
|
||||||
[[nodiscard]]
|
|
||||||
ox::String id() const noexcept override {
|
|
||||||
return ox::String("net.drinkingtea.nostalgia.scene");
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]]
|
|
||||||
ox::Vector<keel::TypeDescGenerator> types() const noexcept override {
|
|
||||||
return {
|
|
||||||
keel::generateTypeDesc<SceneDoc>,
|
|
||||||
keel::generateTypeDesc<SceneStatic>,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]]
|
|
||||||
ox::Vector<const keel::BaseConverter*> converters() const noexcept override {
|
|
||||||
return {
|
|
||||||
&m_sceneDocToSceneStaticConverter,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]]
|
|
||||||
ox::Vector<keel::PackTransform> packTransforms() const noexcept override {
|
|
||||||
return {
|
|
||||||
keel::transformRule<SceneDoc, SceneStatic>,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
} mod;
|
|
||||||
|
|
||||||
const keel::Module *keelModule() noexcept {
|
|
||||||
return &mod;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,68 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <nostalgia/gfx/gfx.hpp>
|
|
||||||
#include <keel/media.hpp>
|
|
||||||
|
|
||||||
#include "typeconv.hpp"
|
|
||||||
|
|
||||||
namespace nostalgia::scene {
|
|
||||||
|
|
||||||
[[nodiscard]]
|
|
||||||
constexpr unsigned adjustLayerAttachment(unsigned layer, unsigned attachment) noexcept {
|
|
||||||
if (attachment == 0) {
|
|
||||||
return layer;
|
|
||||||
} else {
|
|
||||||
return attachment - 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr void setLayerAttachments(unsigned layer, TileDoc const&srcTile, SceneStatic::Tile &dstTile) noexcept {
|
|
||||||
setTopEdge(
|
|
||||||
dstTile.layerAttachments,
|
|
||||||
adjustLayerAttachment(layer, srcTile.layerAttachments[0]));
|
|
||||||
setBottomEdge(
|
|
||||||
dstTile.layerAttachments,
|
|
||||||
adjustLayerAttachment(layer, srcTile.layerAttachments[1]));
|
|
||||||
setLeftEdge(
|
|
||||||
dstTile.layerAttachments,
|
|
||||||
adjustLayerAttachment(layer, srcTile.layerAttachments[2]));
|
|
||||||
setRightEdge(
|
|
||||||
dstTile.layerAttachments,
|
|
||||||
adjustLayerAttachment(layer, srcTile.layerAttachments[3]));
|
|
||||||
}
|
|
||||||
|
|
||||||
ox::Error SceneDocToSceneStaticConverter::convert(
|
|
||||||
keel::Context &ctx,
|
|
||||||
SceneDoc &src,
|
|
||||||
SceneStatic &dst) const noexcept {
|
|
||||||
OX_REQUIRE(ts, keel::readObj<gfx::TileSheet>(ctx, src.tilesheet));
|
|
||||||
const auto layerCnt = src.tiles.size();
|
|
||||||
dst.setLayerCnt(layerCnt);
|
|
||||||
dst.tilesheet = ox::FileAddress(src.tilesheet);
|
|
||||||
dst.palettes.reserve(src.palettes.size());
|
|
||||||
for (const auto &pal : src.palettes) {
|
|
||||||
dst.palettes.emplace_back(pal);
|
|
||||||
}
|
|
||||||
for (auto layerIdx = 0u; const auto &layer : src.tiles) {
|
|
||||||
const auto layerDim = src.size(layerIdx);
|
|
||||||
auto dstLayer = dst.layer(layerIdx);
|
|
||||||
dstLayer.setDimensions(layerDim);
|
|
||||||
for (auto tileIdx = 0u; const auto &row : layer) {
|
|
||||||
for (const auto &srcTile : row) {
|
|
||||||
auto dstTile = dstLayer.tile(tileIdx);
|
|
||||||
dstTile.tileType = srcTile.type;
|
|
||||||
OX_REQUIRE(path, srcTile.getSubsheetPath(*ts));
|
|
||||||
OX_REQUIRE(mapIdx, getTileOffset(*ts, path));
|
|
||||||
dstTile.tileMapIdx = static_cast<uint16_t>(mapIdx);
|
|
||||||
setLayerAttachments(layerIdx, srcTile, dstTile);
|
|
||||||
++tileIdx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
++layerIdx;
|
|
||||||
}
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <keel/typeconv.hpp>
|
|
||||||
|
|
||||||
#include <nostalgia/scene/scenestatic.hpp>
|
|
||||||
|
|
||||||
namespace nostalgia::scene {
|
|
||||||
|
|
||||||
class SceneDocToSceneStaticConverter: public keel::Converter<SceneDoc, SceneStatic> {
|
|
||||||
ox::Error convert(keel::Context&, SceneDoc &src, SceneStatic &dst) const noexcept final;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <nostalgia/gfx/gfx.hpp>
|
|
||||||
|
|
||||||
#include <nostalgia/scene/scene.hpp>
|
|
||||||
|
|
||||||
namespace nostalgia::scene {
|
|
||||||
|
|
||||||
Scene::Scene(SceneStatic const&sceneStatic) noexcept:
|
|
||||||
m_sceneStatic(sceneStatic) {
|
|
||||||
}
|
|
||||||
|
|
||||||
ox::Error Scene::setupDisplay(gfx::Context &ctx) const noexcept {
|
|
||||||
if (m_sceneStatic.palettes.empty()) {
|
|
||||||
return ox::Error(1, "Scene has no palettes");
|
|
||||||
}
|
|
||||||
auto const&palette = m_sceneStatic.palettes[0];
|
|
||||||
OX_RETURN_ERROR(gfx::loadBgTileSheet(ctx, 0, m_sceneStatic.tilesheet));
|
|
||||||
OX_RETURN_ERROR(gfx::loadBgPalette(ctx, 0, palette));
|
|
||||||
// disable all backgrounds
|
|
||||||
gfx::setBgStatus(ctx, 0);
|
|
||||||
for (auto layerNo = 0u; auto const&layer : m_sceneStatic.tileMapIdx) {
|
|
||||||
setupLayer(ctx, layer, layerNo);
|
|
||||||
++layerNo;
|
|
||||||
}
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
void Scene::setupLayer(
|
|
||||||
gfx::Context &ctx,
|
|
||||||
ox::Vector<uint16_t> const&layer,
|
|
||||||
unsigned layerNo) const noexcept {
|
|
||||||
gfx::setBgStatus(ctx, layerNo, true);
|
|
||||||
gfx::setBgCbb(ctx, layerNo, 0);
|
|
||||||
auto x = 0;
|
|
||||||
auto y = 0;
|
|
||||||
const auto width = m_sceneStatic.rows[layerNo];
|
|
||||||
for (auto const&tile : layer) {
|
|
||||||
const auto tile8 = static_cast<uint8_t>(tile);
|
|
||||||
gfx::setBgTile(ctx, layerNo, x, y, tile8);
|
|
||||||
gfx::setBgTile(ctx, layerNo, x + 1, y, tile8 + 1);
|
|
||||||
gfx::setBgTile(ctx, layerNo, x, y + 1, tile8 + 2);
|
|
||||||
gfx::setBgTile(ctx, layerNo, x + 1, y + 1, tile8 + 3);
|
|
||||||
x += 2;
|
|
||||||
if (x >= width * 2) {
|
|
||||||
x = 0;
|
|
||||||
y += 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <nostalgia/scene/scenestatic.hpp>
|
|
||||||
|
|
||||||
namespace nostalgia::scene {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
add_library(
|
|
||||||
NostalgiaScene-Studio
|
|
||||||
studiomodule.cpp
|
|
||||||
sceneeditor-imgui.cpp
|
|
||||||
sceneeditor.cpp
|
|
||||||
sceneeditorview.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(
|
|
||||||
NostalgiaScene-Studio PUBLIC
|
|
||||||
NostalgiaScene
|
|
||||||
Studio
|
|
||||||
)
|
|
||||||
|
|
||||||
install(
|
|
||||||
TARGETS
|
|
||||||
NostalgiaScene-Studio
|
|
||||||
LIBRARY DESTINATION
|
|
||||||
${NOSTALGIA_DIST_MODULE}
|
|
||||||
)
|
|
@ -1,55 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <imgui.h>
|
|
||||||
|
|
||||||
#include <keel/media.hpp>
|
|
||||||
|
|
||||||
#include "sceneeditor-imgui.hpp"
|
|
||||||
|
|
||||||
namespace nostalgia::scene {
|
|
||||||
|
|
||||||
SceneEditorImGui::SceneEditorImGui(studio::StudioContext &ctx, ox::StringView path):
|
|
||||||
Editor(ctx, path),
|
|
||||||
m_ctx(ctx.tctx),
|
|
||||||
m_editor(m_ctx, path),
|
|
||||||
m_view(m_ctx, m_editor.scene()) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void SceneEditorImGui::draw(studio::StudioContext&) noexcept {
|
|
||||||
auto const paneSize = ImGui::GetContentRegionAvail();
|
|
||||||
m_view.draw(ox::Size{static_cast<int>(paneSize.x), static_cast<int>(paneSize.y)});
|
|
||||||
auto &fb = m_view.framebuffer();
|
|
||||||
auto const srcH = static_cast<float>(fb.height) / static_cast<float>(fb.width);
|
|
||||||
auto const dstH = paneSize.y / paneSize.x;
|
|
||||||
float xScale{}, yScale{};
|
|
||||||
if (dstH > srcH) {
|
|
||||||
// crop off width
|
|
||||||
xScale = srcH / dstH;
|
|
||||||
yScale = 1;
|
|
||||||
} else {
|
|
||||||
auto const srcW = static_cast<float>(fb.width) / static_cast<float>(fb.height);
|
|
||||||
auto const dstW = (paneSize.x / paneSize.y);
|
|
||||||
xScale = 1;
|
|
||||||
yScale = srcW / dstW;
|
|
||||||
}
|
|
||||||
uintptr_t const buffId = fb.color.id;
|
|
||||||
ImGui::Image(
|
|
||||||
std::bit_cast<void*>(buffId),
|
|
||||||
paneSize,
|
|
||||||
ImVec2(0, 1),
|
|
||||||
ImVec2(xScale, 1 - yScale));
|
|
||||||
}
|
|
||||||
|
|
||||||
void SceneEditorImGui::onActivated() noexcept {
|
|
||||||
oxLogError(m_view.setupScene());
|
|
||||||
}
|
|
||||||
|
|
||||||
ox::Error SceneEditorImGui::saveItem() noexcept {
|
|
||||||
const auto sctx = applicationData<studio::StudioContext>(m_ctx);
|
|
||||||
OX_RETURN_ERROR(sctx->project->writeObj(itemPath(), m_editor.scene()));
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <studio/studio.hpp>
|
|
||||||
|
|
||||||
#include <turbine/context.hpp>
|
|
||||||
|
|
||||||
#include "sceneeditor.hpp"
|
|
||||||
#include "sceneeditorview.hpp"
|
|
||||||
|
|
||||||
namespace nostalgia::scene {
|
|
||||||
|
|
||||||
class SceneEditorImGui: public studio::Editor {
|
|
||||||
|
|
||||||
private:
|
|
||||||
turbine::Context &m_ctx;
|
|
||||||
SceneEditor m_editor;
|
|
||||||
SceneEditorView m_view;
|
|
||||||
|
|
||||||
public:
|
|
||||||
SceneEditorImGui(studio::StudioContext &ctx, ox::StringView path);
|
|
||||||
|
|
||||||
void draw(studio::StudioContext&) noexcept final;
|
|
||||||
|
|
||||||
void onActivated() noexcept override;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
ox::Error saveItem() noexcept final;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <keel/keel.hpp>
|
|
||||||
|
|
||||||
#include "sceneeditor.hpp"
|
|
||||||
|
|
||||||
namespace nostalgia::scene {
|
|
||||||
|
|
||||||
SceneEditor::SceneEditor(turbine::Context &ctx, ox::StringViewCR path):
|
|
||||||
m_ctx(ctx),
|
|
||||||
m_scene(*keel::readObj<SceneStatic>(keelCtx(m_ctx), path).unwrapThrow()) {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,34 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <turbine/context.hpp>
|
|
||||||
|
|
||||||
#include <nostalgia/scene/scene.hpp>
|
|
||||||
|
|
||||||
namespace nostalgia::scene {
|
|
||||||
|
|
||||||
class SceneEditor {
|
|
||||||
|
|
||||||
private:
|
|
||||||
turbine::Context &m_ctx;
|
|
||||||
ox::String m_itemName;
|
|
||||||
ox::String m_itemPath;
|
|
||||||
SceneStatic m_scene;
|
|
||||||
|
|
||||||
public:
|
|
||||||
SceneEditor(turbine::Context &ctx, ox::StringViewCR path);
|
|
||||||
|
|
||||||
[[nodiscard]]
|
|
||||||
SceneStatic const&scene() const noexcept {
|
|
||||||
return m_scene;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
ox::Error saveItem() noexcept;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <nostalgia/gfx/gfx.hpp>
|
|
||||||
|
|
||||||
#include "sceneeditorview.hpp"
|
|
||||||
|
|
||||||
namespace nostalgia::scene {
|
|
||||||
|
|
||||||
SceneEditorView::SceneEditorView(turbine::Context &tctx, SceneStatic const&sceneStatic):
|
|
||||||
m_cctx(gfx::init(tctx, {.glInstallDrawer = false}).unwrapThrow()),
|
|
||||||
m_sceneStatic(sceneStatic),
|
|
||||||
m_scene(m_sceneStatic) {
|
|
||||||
}
|
|
||||||
|
|
||||||
ox::Error SceneEditorView::setupScene() noexcept {
|
|
||||||
glutils::resizeInitFrameBuffer(m_frameBuffer, gfx::gl::drawSize(m_scale));
|
|
||||||
return m_scene.setupDisplay(*m_cctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SceneEditorView::draw(ox::Size const&targetSz) noexcept {
|
|
||||||
auto const scaleSz = targetSz / gfx::gl::drawSize(1);
|
|
||||||
if (m_scaleSz != scaleSz) [[unlikely]] {
|
|
||||||
m_scale = ox::max(1, ox::max(scaleSz.width, scaleSz.height));
|
|
||||||
glutils::resizeInitFrameBuffer(m_frameBuffer, gfx::gl::drawSize(m_scale));
|
|
||||||
}
|
|
||||||
glutils::FrameBufferBind const frameBufferBind(m_frameBuffer);
|
|
||||||
gfx::gl::draw(*m_cctx, m_scale);
|
|
||||||
}
|
|
||||||
|
|
||||||
glutils::FrameBuffer const&SceneEditorView::framebuffer() const noexcept {
|
|
||||||
return m_frameBuffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <glutils/glutils.hpp>
|
|
||||||
|
|
||||||
#include <nostalgia/gfx/context.hpp>
|
|
||||||
#include <nostalgia/gfx/gfx.hpp>
|
|
||||||
#include <nostalgia/scene/scene.hpp>
|
|
||||||
|
|
||||||
namespace nostalgia::scene {
|
|
||||||
|
|
||||||
class SceneEditorView {
|
|
||||||
|
|
||||||
private:
|
|
||||||
ox::UPtr<gfx::Context> m_cctx;
|
|
||||||
SceneStatic const&m_sceneStatic;
|
|
||||||
Scene m_scene;
|
|
||||||
glutils::FrameBuffer m_frameBuffer;
|
|
||||||
int m_scale = 1;
|
|
||||||
ox::Size m_scaleSz = gfx::gl::drawSize(m_scale);
|
|
||||||
|
|
||||||
public:
|
|
||||||
SceneEditorView(turbine::Context &ctx, SceneStatic const&sceneStatic);
|
|
||||||
|
|
||||||
ox::Error setupScene() noexcept;
|
|
||||||
|
|
||||||
void draw(ox::Size const&targetSz) noexcept;
|
|
||||||
|
|
||||||
[[nodiscard]]
|
|
||||||
glutils::FrameBuffer const&framebuffer() const noexcept;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <studio/studio.hpp>
|
|
||||||
|
|
||||||
#include "sceneeditor-imgui.hpp"
|
|
||||||
|
|
||||||
namespace nostalgia::scene {
|
|
||||||
|
|
||||||
constexpr ox::StringLiteral FileExt_nscn("nscn");
|
|
||||||
|
|
||||||
static class: public studio::Module {
|
|
||||||
public:
|
|
||||||
ox::Vector<studio::EditorMaker> editors(studio::StudioContext &ctx) const noexcept override {
|
|
||||||
return {
|
|
||||||
studio::editorMaker<SceneEditorImGui>(ctx, FileExt_nscn),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
ox::Vector<ox::UPtr<studio::ItemMaker>> itemMakers(studio::StudioContext&) const noexcept override {
|
|
||||||
ox::Vector<ox::UPtr<studio::ItemMaker>> out;
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
} mod;
|
|
||||||
|
|
||||||
const studio::Module *studioModule() noexcept {
|
|
||||||
return &mod;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
#include <keel/module.hpp>
|
#include <keel/module.hpp>
|
||||||
|
|
||||||
namespace nostalgia::scene {
|
namespace nostalgia::sound {
|
||||||
|
|
||||||
const keel::Module *keelModule() noexcept;
|
const keel::Module *keelModule() noexcept;
|
||||||
|
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
#include <studio/studio.hpp>
|
#include <studio/studio.hpp>
|
||||||
|
|
||||||
namespace nostalgia::scene {
|
namespace nostalgia::sound {
|
||||||
|
|
||||||
const studio::Module *studioModule() noexcept;
|
const studio::Module *studioModule() noexcept;
|
||||||
|
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
#include <studio/studio.hpp>
|
#include <studio/studio.hpp>
|
||||||
|
|
||||||
namespace nostalgia::gfx {
|
namespace nostalgia::sound {
|
||||||
|
|
||||||
static class: public studio::Module {
|
static class: public studio::Module {
|
||||||
ox::Vector<studio::EditorMaker> editors(studio::StudioContext&) const noexcept final {
|
ox::Vector<studio::EditorMaker> editors(studio::StudioContext&) const noexcept final {
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include <studioapp/studioapp.hpp>
|
#include <studioapp/studioapp.hpp>
|
||||||
|
|
||||||
#include <nostalgia/gfx/studiomodule.hpp>
|
#include <nostalgia/gfx/studiomodule.hpp>
|
||||||
#include <nostalgia/scene/studiomodule.hpp>
|
#include <nostalgia/sound/studiomodule.hpp>
|
||||||
|
|
||||||
namespace nostalgia {
|
namespace nostalgia {
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ void registerStudioModules() noexcept {
|
|||||||
}
|
}
|
||||||
modulesRegistered = true;
|
modulesRegistered = true;
|
||||||
studio::registerModule(gfx::studioModule());
|
studio::registerModule(gfx::studioModule());
|
||||||
studio::registerModule(scene::studioModule());
|
studio::registerModule(sound::studioModule());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user