diff --git a/src/nostalgia/modules/CMakeLists.txt b/src/nostalgia/modules/CMakeLists.txt index 2a26b349..94d88cf3 100644 --- a/src/nostalgia/modules/CMakeLists.txt +++ b/src/nostalgia/modules/CMakeLists.txt @@ -2,7 +2,6 @@ add_subdirectory(gfx) add_subdirectory(sound) -add_subdirectory(scene) # module libraries @@ -15,7 +14,7 @@ target_link_libraries( NostalgiaKeelModules PUBLIC Keel NostalgiaGfx-Keel - NostalgiaScene-Keel + NostalgiaSound-Keel ) install( FILES @@ -35,7 +34,6 @@ if(NOSTALGIA_BUILD_STUDIO) StudioAppLib NostalgiaGfx-Studio-ImGui NostalgiaSound-Studio-ImGui - NostalgiaScene-Studio ) install( FILES diff --git a/src/nostalgia/modules/keelmodules.cpp b/src/nostalgia/modules/keelmodules.cpp index c296b7c2..0c3f9ab6 100644 --- a/src/nostalgia/modules/keelmodules.cpp +++ b/src/nostalgia/modules/keelmodules.cpp @@ -3,7 +3,7 @@ */ #include -#include +#include namespace nostalgia { @@ -14,7 +14,7 @@ void registerKeelModules() noexcept { } modulesRegistered = true; keel::registerModule(gfx::keelModule()); - keel::registerModule(scene::keelModule()); + keel::registerModule(sound::keelModule()); } } diff --git a/src/nostalgia/modules/scene/CMakeLists.txt b/src/nostalgia/modules/scene/CMakeLists.txt deleted file mode 100644 index bdd3812b..00000000 --- a/src/nostalgia/modules/scene/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -add_subdirectory(src) - -target_include_directories( - NostalgiaScene PUBLIC - include -) - -install( - DIRECTORY - include/nostalgia - DESTINATION - include -) diff --git a/src/nostalgia/modules/scene/include/nostalgia/scene/scene.hpp b/src/nostalgia/modules/scene/include/nostalgia/scene/scene.hpp deleted file mode 100644 index 46ba1a41..00000000 --- a/src/nostalgia/modules/scene/include/nostalgia/scene/scene.hpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved. - */ - -#pragma once - -#include - -#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 const&layer, unsigned layerNo) const noexcept; - -}; - -} diff --git a/src/nostalgia/modules/scene/include/nostalgia/scene/scenestatic.hpp b/src/nostalgia/modules/scene/include/nostalgia/scene/scenestatic.hpp deleted file mode 100644 index 1291c1c8..00000000 --- a/src/nostalgia/modules/scene/include/nostalgia/scene/scenestatic.hpp +++ /dev/null @@ -1,228 +0,0 @@ -/* - * Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved. - */ - -#pragma once - -#include -#include -#include -#include -#include - -#include - -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 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 layerAttachments; - - [[nodiscard]] - constexpr ox::Result 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 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; - using TileMapLayer = ox::Vector; - using TileMap = ox::Vector; - - 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 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(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(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(val); - layerAttachments = (layerAttachments & 0b11111100) | val8; -} -constexpr void setBottomEdge(uint8_t &layerAttachments, unsigned val) noexcept { - const auto val8 = static_cast(val); - layerAttachments = (layerAttachments & 0b11110011) | static_cast(val8 << 2); -} -constexpr void setLeftEdge(uint8_t &layerAttachments, unsigned val) noexcept { - const auto val8 = static_cast(val); - layerAttachments = (layerAttachments & 0b11001111) | static_cast(val8 << 4); -} -constexpr void setRightEdge(uint8_t &layerAttachments, unsigned val) noexcept { - const auto val8 = static_cast(val); - layerAttachments = (layerAttachments & 0b00111111) | static_cast(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 &tileMapIdx; - ox::Vector &tileType; - ox::Vector &layerAttachments; - constexpr Layer( - uint16_t &pColumns, - uint16_t &pRows, - ox::Vector &pTileMapIdx, - ox::Vector &pTileType, - ox::Vector &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(dim.width); - rows = static_cast(dim.height); - const auto tileCnt = static_cast(columns * rows); - tileMapIdx.resize(tileCnt); - tileType.resize(tileCnt); - layerAttachments.resize(tileCnt); - } - }; - - ox::FileAddress tilesheet; - ox::Vector palettes; - // tile layer data - ox::Vector columns; - ox::Vector rows; - ox::Vector> tileMapIdx; - ox::Vector> tileType; - ox::Vector> 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() - -} diff --git a/src/nostalgia/modules/scene/src/CMakeLists.txt b/src/nostalgia/modules/scene/src/CMakeLists.txt deleted file mode 100644 index a8181e47..00000000 --- a/src/nostalgia/modules/scene/src/CMakeLists.txt +++ /dev/null @@ -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 -) diff --git a/src/nostalgia/modules/scene/src/keel/CMakeLists.txt b/src/nostalgia/modules/scene/src/keel/CMakeLists.txt deleted file mode 100644 index 463ce4fb..00000000 --- a/src/nostalgia/modules/scene/src/keel/CMakeLists.txt +++ /dev/null @@ -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} -) diff --git a/src/nostalgia/modules/scene/src/keel/keelmodule.cpp b/src/nostalgia/modules/scene/src/keel/keelmodule.cpp deleted file mode 100644 index f99d28d8..00000000 --- a/src/nostalgia/modules/scene/src/keel/keelmodule.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved. - */ - -#include - -#include - -#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 types() const noexcept override { - return { - keel::generateTypeDesc, - keel::generateTypeDesc, - }; - } - - [[nodiscard]] - ox::Vector converters() const noexcept override { - return { - &m_sceneDocToSceneStaticConverter, - }; - } - - [[nodiscard]] - ox::Vector packTransforms() const noexcept override { - return { - keel::transformRule, - }; - } - -} mod; - -const keel::Module *keelModule() noexcept { - return &mod; -} - -} diff --git a/src/nostalgia/modules/scene/src/keel/typeconv.cpp b/src/nostalgia/modules/scene/src/keel/typeconv.cpp deleted file mode 100644 index 9ab112fe..00000000 --- a/src/nostalgia/modules/scene/src/keel/typeconv.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved. - */ - -#include -#include - -#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(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(mapIdx); - setLayerAttachments(layerIdx, srcTile, dstTile); - ++tileIdx; - } - } - ++layerIdx; - } - return {}; -} - -} diff --git a/src/nostalgia/modules/scene/src/keel/typeconv.hpp b/src/nostalgia/modules/scene/src/keel/typeconv.hpp deleted file mode 100644 index 0654d00c..00000000 --- a/src/nostalgia/modules/scene/src/keel/typeconv.hpp +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved. - */ - -#pragma once - -#include - -#include - -namespace nostalgia::scene { - -class SceneDocToSceneStaticConverter: public keel::Converter { - ox::Error convert(keel::Context&, SceneDoc &src, SceneStatic &dst) const noexcept final; -}; - -} diff --git a/src/nostalgia/modules/scene/src/scene.cpp b/src/nostalgia/modules/scene/src/scene.cpp deleted file mode 100644 index 99c8d42b..00000000 --- a/src/nostalgia/modules/scene/src/scene.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved. - */ - -#include - -#include - -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 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(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; - } - } -} - -} diff --git a/src/nostalgia/modules/scene/src/scenestatic.cpp b/src/nostalgia/modules/scene/src/scenestatic.cpp deleted file mode 100644 index 18e3aaaf..00000000 --- a/src/nostalgia/modules/scene/src/scenestatic.cpp +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved. - */ - -#include - -namespace nostalgia::scene { - - - -} diff --git a/src/nostalgia/modules/scene/src/studio/CMakeLists.txt b/src/nostalgia/modules/scene/src/studio/CMakeLists.txt deleted file mode 100644 index 97a57703..00000000 --- a/src/nostalgia/modules/scene/src/studio/CMakeLists.txt +++ /dev/null @@ -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} -) diff --git a/src/nostalgia/modules/scene/src/studio/sceneeditor-imgui.cpp b/src/nostalgia/modules/scene/src/studio/sceneeditor-imgui.cpp deleted file mode 100644 index 70ccc6c3..00000000 --- a/src/nostalgia/modules/scene/src/studio/sceneeditor-imgui.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved. - */ - -#include - -#include - -#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(paneSize.x), static_cast(paneSize.y)}); - auto &fb = m_view.framebuffer(); - auto const srcH = static_cast(fb.height) / static_cast(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(fb.width) / static_cast(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(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(m_ctx); - OX_RETURN_ERROR(sctx->project->writeObj(itemPath(), m_editor.scene())); - return {}; -} - -} diff --git a/src/nostalgia/modules/scene/src/studio/sceneeditor-imgui.hpp b/src/nostalgia/modules/scene/src/studio/sceneeditor-imgui.hpp deleted file mode 100644 index 26dc62ac..00000000 --- a/src/nostalgia/modules/scene/src/studio/sceneeditor-imgui.hpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved. - */ - -#pragma once - -#include - -#include - -#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; - -}; - -} diff --git a/src/nostalgia/modules/scene/src/studio/sceneeditor.cpp b/src/nostalgia/modules/scene/src/studio/sceneeditor.cpp deleted file mode 100644 index 7c5c0177..00000000 --- a/src/nostalgia/modules/scene/src/studio/sceneeditor.cpp +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved. - */ - -#include - -#include "sceneeditor.hpp" - -namespace nostalgia::scene { - -SceneEditor::SceneEditor(turbine::Context &ctx, ox::StringViewCR path): - m_ctx(ctx), - m_scene(*keel::readObj(keelCtx(m_ctx), path).unwrapThrow()) { -} - -} diff --git a/src/nostalgia/modules/scene/src/studio/sceneeditor.hpp b/src/nostalgia/modules/scene/src/studio/sceneeditor.hpp deleted file mode 100644 index 7d7962a7..00000000 --- a/src/nostalgia/modules/scene/src/studio/sceneeditor.hpp +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved. - */ - -#pragma once - -#include - -#include - -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; - -}; - -} diff --git a/src/nostalgia/modules/scene/src/studio/sceneeditorview.cpp b/src/nostalgia/modules/scene/src/studio/sceneeditorview.cpp deleted file mode 100644 index 7a15f84e..00000000 --- a/src/nostalgia/modules/scene/src/studio/sceneeditorview.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved. - */ - -#include - -#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; -} - -} diff --git a/src/nostalgia/modules/scene/src/studio/sceneeditorview.hpp b/src/nostalgia/modules/scene/src/studio/sceneeditorview.hpp deleted file mode 100644 index 83c887b8..00000000 --- a/src/nostalgia/modules/scene/src/studio/sceneeditorview.hpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved. - */ - -#pragma once - -#include - -#include -#include -#include - -namespace nostalgia::scene { - -class SceneEditorView { - - private: - ox::UPtr 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; - -}; - -} diff --git a/src/nostalgia/modules/scene/src/studio/studiomodule.cpp b/src/nostalgia/modules/scene/src/studio/studiomodule.cpp deleted file mode 100644 index 564fd194..00000000 --- a/src/nostalgia/modules/scene/src/studio/studiomodule.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved. - */ - -#include - -#include "sceneeditor-imgui.hpp" - -namespace nostalgia::scene { - -constexpr ox::StringLiteral FileExt_nscn("nscn"); - -static class: public studio::Module { - public: - ox::Vector editors(studio::StudioContext &ctx) const noexcept override { - return { - studio::editorMaker(ctx, FileExt_nscn), - }; - } - ox::Vector> itemMakers(studio::StudioContext&) const noexcept override { - ox::Vector> out; - return out; - } -} mod; - -const studio::Module *studioModule() noexcept { - return &mod; -} - -} diff --git a/src/nostalgia/modules/scene/include/nostalgia/scene/keelmodule.hpp b/src/nostalgia/modules/sound/include/nostalgia/sound/keelmodule.hpp similarity index 86% rename from src/nostalgia/modules/scene/include/nostalgia/scene/keelmodule.hpp rename to src/nostalgia/modules/sound/include/nostalgia/sound/keelmodule.hpp index e972b851..197e1f3f 100644 --- a/src/nostalgia/modules/scene/include/nostalgia/scene/keelmodule.hpp +++ b/src/nostalgia/modules/sound/include/nostalgia/sound/keelmodule.hpp @@ -6,7 +6,7 @@ #include -namespace nostalgia::scene { +namespace nostalgia::sound { const keel::Module *keelModule() noexcept; diff --git a/src/nostalgia/modules/scene/include/nostalgia/scene/studiomodule.hpp b/src/nostalgia/modules/sound/include/nostalgia/sound/studiomodule.hpp similarity index 86% rename from src/nostalgia/modules/scene/include/nostalgia/scene/studiomodule.hpp rename to src/nostalgia/modules/sound/include/nostalgia/sound/studiomodule.hpp index 82902e04..f7e68e1f 100644 --- a/src/nostalgia/modules/scene/include/nostalgia/scene/studiomodule.hpp +++ b/src/nostalgia/modules/sound/include/nostalgia/sound/studiomodule.hpp @@ -6,7 +6,7 @@ #include -namespace nostalgia::scene { +namespace nostalgia::sound { const studio::Module *studioModule() noexcept; diff --git a/src/nostalgia/modules/sound/src/studio/studiomodule.cpp b/src/nostalgia/modules/sound/src/studio/studiomodule.cpp index fe133a74..ba8d98a1 100644 --- a/src/nostalgia/modules/sound/src/studio/studiomodule.cpp +++ b/src/nostalgia/modules/sound/src/studio/studiomodule.cpp @@ -6,7 +6,7 @@ #include -namespace nostalgia::gfx { +namespace nostalgia::sound { static class: public studio::Module { ox::Vector editors(studio::StudioContext&) const noexcept final { diff --git a/src/nostalgia/modules/studiomodules.cpp b/src/nostalgia/modules/studiomodules.cpp index 516e2cee..219478cd 100644 --- a/src/nostalgia/modules/studiomodules.cpp +++ b/src/nostalgia/modules/studiomodules.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include namespace nostalgia { @@ -16,7 +16,7 @@ void registerStudioModules() noexcept { } modulesRegistered = true; studio::registerModule(gfx::studioModule()); - studio::registerModule(scene::studioModule()); + studio::registerModule(sound::studioModule()); } }