Squashed 'deps/nostalgia/' changes from fbebf4ef..646ab128
646ab128 [nostalgia/gfx] Cleanup 74cf0556 [nostalgia] Cleanup 0d8ba1b1 [nostalgia/gfx] Cleanup formatting mistake 20edbb7f [buildcore] Map aarch64 to arm64 6febc7cc [nostalgia] Fix build b94d6b50 [nostalgia] Remove scene package, finish stubbing out sound b3952cab [nostalgia] Add build upload step to CI 2ffc11b0 Merge commit 'e723ead864edb4bc160e4d69713309174ad9e82e' 96cace2c [studio] Cleanup 472f5702 [nostalgia/gfx/studio/tilesheet] Change max export scale to 135 c0ac4345 [studio] Cleanup git-subtree-dir: deps/nostalgia git-subtree-split: 646ab1283f1f486d301e742459467e7bbfdfc8f5
This commit is contained in:
parent
bceb2acc64
commit
54de52e6c5
@ -17,3 +17,10 @@ jobs:
|
|||||||
- run: make purge configure-release
|
- run: make purge configure-release
|
||||||
- run: make build
|
- run: make build
|
||||||
- run: make test
|
- run: make test
|
||||||
|
- run: make install
|
||||||
|
- run: mv dist/linux-x86_64-release nostalgia-linux-x86_64
|
||||||
|
- run: tar cf nostalgia-linux-x86_64.tar nostalgia-linux-x86_64
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: nostalgia-linux-x86_64
|
||||||
|
path: nostalgia-linux-x86_64.tar
|
||||||
|
2
deps/buildcore/scripts/util.py
vendored
2
deps/buildcore/scripts/util.py
vendored
@ -35,4 +35,6 @@ def get_arch() -> str:
|
|||||||
arch = platform.machine().lower()
|
arch = platform.machine().lower()
|
||||||
if arch == 'amd64':
|
if arch == 'amd64':
|
||||||
arch = 'x86_64'
|
arch = 'x86_64'
|
||||||
|
elif arch == 'aarch64':
|
||||||
|
arch = 'arm64'
|
||||||
return arch
|
return arch
|
||||||
|
@ -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
|
||||||
|
@ -16,23 +16,6 @@
|
|||||||
|
|
||||||
namespace nostalgia::gfx {
|
namespace nostalgia::gfx {
|
||||||
|
|
||||||
struct SubSheetTemplate {
|
|
||||||
static constexpr auto TypeName = "net.drinkingtea.nostalgia.gfx.SubSheetTemplate";
|
|
||||||
static constexpr auto TypeVersion = 1;
|
|
||||||
ox::String name;
|
|
||||||
int32_t width{};
|
|
||||||
int32_t height{};
|
|
||||||
ox::Vector<SubSheetTemplate> subsheets;
|
|
||||||
};
|
|
||||||
|
|
||||||
OX_MODEL_BEGIN(SubSheetTemplate)
|
|
||||||
OX_MODEL_FIELD(name)
|
|
||||||
OX_MODEL_FIELD(width)
|
|
||||||
OX_MODEL_FIELD(height)
|
|
||||||
OX_MODEL_FIELD(subsheets)
|
|
||||||
OX_MODEL_END()
|
|
||||||
|
|
||||||
|
|
||||||
// Predecessor to TileSheet, kept for backward compatibility
|
// Predecessor to TileSheet, kept for backward compatibility
|
||||||
struct TileSheetV1 {
|
struct TileSheetV1 {
|
||||||
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.NostalgiaGraphic";
|
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.NostalgiaGraphic";
|
||||||
@ -52,7 +35,7 @@ constexpr bool valid(TileSheetV1 const&ts) noexcept {
|
|||||||
return (ts.bpp == 4 || ts.bpp == 8) && ts.pixels.size() == bytes;
|
return (ts.bpp == 4 || ts.bpp == 8) && ts.pixels.size() == bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr ox::Error repair(TileSheetV1 &ts, int bpp) noexcept {
|
constexpr ox::Error repair(TileSheetV1 &ts, int const bpp) noexcept {
|
||||||
auto const bytes = static_cast<size_t>(ts.columns * ts.rows * PixelsPerTile) / (bpp == 4 ? 2 : 1);
|
auto const bytes = static_cast<size_t>(ts.columns * ts.rows * PixelsPerTile) / (bpp == 4 ? 2 : 1);
|
||||||
ts.pixels.resize(bytes);
|
ts.pixels.resize(bytes);
|
||||||
return {};
|
return {};
|
||||||
@ -101,7 +84,7 @@ constexpr bool valid(TileSheetV2 const&ts) noexcept {
|
|||||||
return (ts.bpp == 4 || ts.bpp == 8) && valid(ts.subsheet, ts.bpp);
|
return (ts.bpp == 4 || ts.bpp == 8) && valid(ts.subsheet, ts.bpp);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr void repair(TileSheetV2::SubSheet &ss, int bpp) noexcept {
|
constexpr void repair(TileSheetV2::SubSheet &ss, int const bpp) noexcept {
|
||||||
auto const bytes = static_cast<size_t>(ss.columns * ss.rows * PixelsPerTile) / (bpp == 4 ? 2 : 1);
|
auto const bytes = static_cast<size_t>(ss.columns * ss.rows * PixelsPerTile) / (bpp == 4 ? 2 : 1);
|
||||||
ss.pixels.resize(bytes);
|
ss.pixels.resize(bytes);
|
||||||
for (auto &s : ss.subsheets) {
|
for (auto &s : ss.subsheets) {
|
||||||
@ -171,7 +154,7 @@ constexpr bool valid(TileSheetV3 const&ts) noexcept {
|
|||||||
return (ts.bpp == 4 || ts.bpp == 8) && valid(ts.subsheet, ts.bpp);
|
return (ts.bpp == 4 || ts.bpp == 8) && valid(ts.subsheet, ts.bpp);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr void repair(TileSheetV3::SubSheet &ss, int bpp) noexcept {
|
constexpr void repair(TileSheetV3::SubSheet &ss, int const bpp) noexcept {
|
||||||
auto const bytes = static_cast<size_t>(ss.columns * ss.rows * PixelsPerTile) / (bpp == 4 ? 2 : 1);
|
auto const bytes = static_cast<size_t>(ss.columns * ss.rows * PixelsPerTile) / (bpp == 4 ? 2 : 1);
|
||||||
ss.pixels.resize(bytes);
|
ss.pixels.resize(bytes);
|
||||||
for (auto &s : ss.subsheets) {
|
for (auto &s : ss.subsheets) {
|
||||||
@ -265,7 +248,7 @@ constexpr bool valid(TileSheetV4 const&ts) noexcept {
|
|||||||
return (ts.bpp == 4 || ts.bpp == 8) && valid(ts.subsheet, ts.bpp);
|
return (ts.bpp == 4 || ts.bpp == 8) && valid(ts.subsheet, ts.bpp);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr void repair(TileSheetV4::SubSheet &ss, int bpp) noexcept {
|
constexpr void repair(TileSheetV4::SubSheet &ss, int const bpp) noexcept {
|
||||||
if (ss.subsheets.empty()) {
|
if (ss.subsheets.empty()) {
|
||||||
auto const bytes = static_cast<size_t>(ss.columns * ss.rows * PixelsPerTile) / (bpp == 4 ? 2 : 1);
|
auto const bytes = static_cast<size_t>(ss.columns * ss.rows * PixelsPerTile) / (bpp == 4 ? 2 : 1);
|
||||||
ss.pixels.resize(bytes);
|
ss.pixels.resize(bytes);
|
||||||
@ -367,7 +350,7 @@ constexpr bool valid(TileSheetV5 const&ts) noexcept {
|
|||||||
return (ts.bpp == 4 || ts.bpp == 8) && valid(ts.subsheet);
|
return (ts.bpp == 4 || ts.bpp == 8) && valid(ts.subsheet);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr void repair(TileSheetV5::SubSheet &ss, int const bpp) noexcept {
|
constexpr void repair(TileSheetV5::SubSheet &ss) noexcept {
|
||||||
if (ss.subsheets.empty()) {
|
if (ss.subsheets.empty()) {
|
||||||
auto const bytes = static_cast<size_t>(ss.columns * ss.rows * PixelsPerTile);
|
auto const bytes = static_cast<size_t>(ss.columns * ss.rows * PixelsPerTile);
|
||||||
ss.pixels.resize(bytes);
|
ss.pixels.resize(bytes);
|
||||||
@ -377,7 +360,7 @@ constexpr void repair(TileSheetV5::SubSheet &ss, int const bpp) noexcept {
|
|||||||
ss.rows = -1;
|
ss.rows = -1;
|
||||||
}
|
}
|
||||||
for (auto &s : ss.subsheets) {
|
for (auto &s : ss.subsheets) {
|
||||||
repair(s, bpp);
|
repair(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -385,7 +368,7 @@ constexpr ox::Error repair(TileSheetV5 &ts) noexcept {
|
|||||||
if (ts.bpp != 4 && ts.bpp != 8) {
|
if (ts.bpp != 4 && ts.bpp != 8) {
|
||||||
return ox::Error{1, "Unable to repair TileSheet"};
|
return ox::Error{1, "Unable to repair TileSheet"};
|
||||||
}
|
}
|
||||||
repair(ts.subsheet, ts.bpp);
|
repair(ts.subsheet);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -642,7 +642,7 @@ void TileSheetEditorImGui::ExportMenu::draw(turbine::Context &tctx) noexcept {
|
|||||||
constexpr auto popupSz = ImVec2{popupWidth, popupHeight};
|
constexpr auto popupSz = ImVec2{popupWidth, popupHeight};
|
||||||
if (ig::BeginPopup(tctx, popupName, m_show, popupSz)) {
|
if (ig::BeginPopup(tctx, popupName, m_show, popupSz)) {
|
||||||
ImGui::InputInt("Scale", &m_scale);
|
ImGui::InputInt("Scale", &m_scale);
|
||||||
m_scale = ox::clamp(m_scale, 1, 50);
|
m_scale = ox::clamp(m_scale, 1, 135);
|
||||||
if (ig::PopupControlsOkCancel(popupWidth, m_show) == ig::PopupResponse::OK) {
|
if (ig::PopupControlsOkCancel(popupWidth, m_show) == ig::PopupResponse::OK) {
|
||||||
inputSubmitted.emit(m_scale);
|
inputSubmitted.emit(m_scale);
|
||||||
}
|
}
|
||||||
|
@ -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());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
#include <turbine/turbine.hpp>
|
#include <turbine/turbine.hpp>
|
||||||
|
|
||||||
#include <nostalgia/gfx/core.hpp>
|
#include <nostalgia/gfx/core.hpp>
|
||||||
#include <nostalgia/scene/scene.hpp>
|
|
||||||
|
|
||||||
using namespace nostalgia;
|
using namespace nostalgia;
|
||||||
|
|
||||||
@ -126,41 +125,11 @@ static ox::Error runTileSheetSetTest(turbine::Context &tctx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int sceneUpdateHandler(turbine::Context&) noexcept {
|
|
||||||
constexpr auto sleepTime = 16;
|
|
||||||
if (s_paused) {
|
|
||||||
return sleepTime;
|
|
||||||
}
|
|
||||||
// do stuff
|
|
||||||
return sleepTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void sceneKeyEventHandler(turbine::Context &tctx, turbine::Key key, bool down) noexcept {
|
|
||||||
if (down) {
|
|
||||||
if (key == turbine::Key::Alpha_Q) {
|
|
||||||
turbine::requestShutdown(tctx);
|
|
||||||
} else if (key == turbine::Key::Alpha_P) {
|
|
||||||
s_paused = !s_paused;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[[maybe_unused]]
|
|
||||||
static ox::Error runScene(turbine::Context &tctx) {
|
|
||||||
OX_REQUIRE_M(cctx, gfx::init(tctx));
|
|
||||||
OX_REQUIRE(scn, keel::readObj<scene::SceneStatic>(keelCtx(tctx), "/Scenes/Chester.nscn"));
|
|
||||||
turbine::setUpdateHandler(tctx, sceneUpdateHandler);
|
|
||||||
turbine::setKeyEventHandler(tctx, sceneKeyEventHandler);
|
|
||||||
scene::Scene const scene(*scn);
|
|
||||||
OX_RETURN_ERROR(scene.setupDisplay(*cctx));
|
|
||||||
return turbine::run(tctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
ox::Error run(
|
ox::Error run(
|
||||||
[[maybe_unused]] ox::StringView project,
|
[[maybe_unused]] ox::StringView project,
|
||||||
[[maybe_unused]] ox::StringView appName,
|
[[maybe_unused]] ox::StringView appName,
|
||||||
[[maybe_unused]] ox::StringView projectDataDir,
|
[[maybe_unused]] ox::StringView projectDataDir,
|
||||||
ox::SpanView<char const*> args) noexcept {
|
ox::SpanView<ox::CString> args) noexcept {
|
||||||
if (args.size() < 2) {
|
if (args.size() < 2) {
|
||||||
return ox::Error{1, "Please provide path to project directory or OxFS file."};
|
return ox::Error{1, "Please provide path to project directory or OxFS file."};
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
add_library(
|
add_library(
|
||||||
StudioAppLib
|
StudioAppLib
|
||||||
aboutpopup.cpp
|
aboutpopup.cpp
|
||||||
|
app.cpp
|
||||||
clawviewer.cpp
|
clawviewer.cpp
|
||||||
deleteconfirmation.cpp
|
deleteconfirmation.cpp
|
||||||
filedialogmanager.cpp
|
filedialogmanager.cpp
|
||||||
main.cpp
|
|
||||||
makecopypopup.cpp
|
makecopypopup.cpp
|
||||||
newdir.cpp
|
newdir.cpp
|
||||||
newmenu.cpp
|
newmenu.cpp
|
||||||
newproject.cpp
|
newproject.cpp
|
||||||
projectexplorer.cpp
|
projectexplorer.cpp
|
||||||
renamefile.cpp
|
renamefile.cpp
|
||||||
studioapp.cpp
|
studioui.cpp
|
||||||
)
|
)
|
||||||
target_compile_definitions(
|
target_compile_definitions(
|
||||||
StudioAppLib PUBLIC
|
StudioAppLib PUBLIC
|
||||||
|
@ -11,8 +11,7 @@
|
|||||||
#include <turbine/turbine.hpp>
|
#include <turbine/turbine.hpp>
|
||||||
|
|
||||||
#include <studio/context.hpp>
|
#include <studio/context.hpp>
|
||||||
#include <studioapp/studioapp.hpp>
|
#include "studioui.hpp"
|
||||||
#include "studioapp.hpp"
|
|
||||||
|
|
||||||
namespace studio {
|
namespace studio {
|
||||||
|
|
@ -14,7 +14,7 @@
|
|||||||
#include <studio/configio.hpp>
|
#include <studio/configio.hpp>
|
||||||
#include "clawviewer.hpp"
|
#include "clawviewer.hpp"
|
||||||
#include "filedialogmanager.hpp"
|
#include "filedialogmanager.hpp"
|
||||||
#include "studioapp.hpp"
|
#include "studioui.hpp"
|
||||||
|
|
||||||
namespace studio {
|
namespace studio {
|
||||||
|
|
@ -44,5 +44,5 @@ install(
|
|||||||
DIRECTORY
|
DIRECTORY
|
||||||
../include/studio
|
../include/studio
|
||||||
DESTINATION
|
DESTINATION
|
||||||
include/studio/
|
include/studio
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user