Compare commits
19 Commits
25a7873ea2
...
release-d2
Author | SHA1 | Date | |
---|---|---|---|
c6fdf19055 | |||
ed5f424eb0 | |||
a44c5acc4b | |||
13e256b3a9 | |||
6bd74611cd | |||
c3f9cf9a64 | |||
646ab1283f | |||
74cf055610 | |||
0d8ba1b154 | |||
20edbb7f38 | |||
6febc7cc73 | |||
b94d6b5061 | |||
b3952cabbc | |||
2ffc11b04e | |||
96cace2cbb | |||
472f5702bd | |||
c0ac4345d3 | |||
fbebf4ef83 | |||
20513f7749 |
@ -17,3 +17,10 @@ jobs:
|
||||
- run: make purge configure-release
|
||||
- run: make build
|
||||
- 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
|
||||
|
30
deps/buildcore/scripts/file-to-cpp.py
vendored
Executable file
30
deps/buildcore/scripts/file-to-cpp.py
vendored
Executable file
@ -0,0 +1,30 @@
|
||||
#! /usr/bin/env python3
|
||||
|
||||
#
|
||||
# Copyright 2016 - 2025 gary@drinkingtea.net
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--file', help='path to file')
|
||||
parser.add_argument('--out-cpp', help='path to output cpp file')
|
||||
parser.add_argument('--out-hpp', help='path to output hpp file')
|
||||
parser.add_argument('--namespace', help='path to output hpp file')
|
||||
args = parser.parse_args()
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
err = main()
|
||||
sys.exit(err)
|
||||
except KeyboardInterrupt:
|
||||
sys.exit(1)
|
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()
|
||||
if arch == 'amd64':
|
||||
arch = 'x86_64'
|
||||
elif arch == 'aarch64':
|
||||
arch = 'arm64'
|
||||
return arch
|
||||
|
@ -10,6 +10,8 @@
|
||||
* Add draw line tool to TileSheet editor
|
||||
* Replace file picker combo boxes with a browse button and file picker, and
|
||||
support for dragging files from the project explorer.
|
||||
* Add ability to jump to a color in a Palette by double clicking on the
|
||||
color from the TileSheet editor
|
||||
* Add ability to create directories.
|
||||
* Add ability to add files to specific directories.
|
||||
* Add ability to delete files from the project explorer.
|
||||
|
@ -0,0 +1,23 @@
|
||||
O1;net.drinkingtea.ox.TypeDescriptor;1;{
|
||||
"fieldList" :
|
||||
[
|
||||
{
|
||||
"fieldName" : "pages",
|
||||
"subscriptLevels" : 2,
|
||||
"subscriptStack" :
|
||||
[
|
||||
{
|
||||
"subscriptType" : 4
|
||||
},
|
||||
{
|
||||
"subscriptType" : 4
|
||||
}
|
||||
],
|
||||
"typeId" : "B.uint16;0"
|
||||
}
|
||||
],
|
||||
"preloadable" : true,
|
||||
"primitiveType" : 5,
|
||||
"typeName" : "net.drinkingtea.nostalgia.gfx.CompactPalette",
|
||||
"typeVersion" : 1
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
O1;net.drinkingtea.ox.TypeDescriptor;1;{
|
||||
"fieldList" :
|
||||
[
|
||||
{
|
||||
"fieldName" : "bpp",
|
||||
"typeId" : "B.int8;0"
|
||||
},
|
||||
{
|
||||
"fieldName" : "defaultPalette",
|
||||
"typeId" : "net.drinkingtea.ox.FileAddress;1"
|
||||
},
|
||||
{
|
||||
"fieldName" : "pixels",
|
||||
"subscriptLevels" : 1,
|
||||
"subscriptStack" :
|
||||
[
|
||||
{
|
||||
"subscriptType" : 4
|
||||
}
|
||||
],
|
||||
"typeId" : "B.uint8;0"
|
||||
}
|
||||
],
|
||||
"preloadable" : true,
|
||||
"primitiveType" : 5,
|
||||
"typeName" : "net.drinkingtea.nostalgia.gfx.CompactTileSheet",
|
||||
"typeVersion" : 1
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
O1;net.drinkingtea.ox.TypeDescriptor;1;{
|
||||
"fieldList" :
|
||||
[
|
||||
{
|
||||
"fieldName" : "name",
|
||||
"typeId" : "net.drinkingtea.ox.BasicString#8#;1"
|
||||
},
|
||||
{
|
||||
"fieldName" : "colors",
|
||||
"subscriptLevels" : 1,
|
||||
"subscriptStack" :
|
||||
[
|
||||
{
|
||||
"subscriptType" : 4
|
||||
}
|
||||
],
|
||||
"typeId" : "net.drinkingtea.nostalgia.gfx.PaletteColor;2"
|
||||
}
|
||||
],
|
||||
"primitiveType" : 5,
|
||||
"typeName" : "net.drinkingtea.nostalgia.gfx.Palette.PalettePage",
|
||||
"typeVersion" : 2
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
O1;net.drinkingtea.ox.TypeDescriptor;1;{
|
||||
"fieldList" :
|
||||
[
|
||||
{
|
||||
"fieldName" : "colorNames",
|
||||
"subscriptLevels" : 1,
|
||||
"subscriptStack" :
|
||||
[
|
||||
{
|
||||
"subscriptType" : 4
|
||||
}
|
||||
],
|
||||
"typeId" : "net.drinkingtea.ox.BasicString#8#;1"
|
||||
},
|
||||
{
|
||||
"fieldName" : "pages",
|
||||
"subscriptLevels" : 1,
|
||||
"subscriptStack" :
|
||||
[
|
||||
{
|
||||
"subscriptType" : 4
|
||||
}
|
||||
],
|
||||
"typeId" : "net.drinkingtea.nostalgia.gfx.Palette.PalettePage;2"
|
||||
}
|
||||
],
|
||||
"preloadable" : true,
|
||||
"primitiveType" : 5,
|
||||
"typeName" : "net.drinkingtea.nostalgia.gfx.Palette",
|
||||
"typeVersion" : 5
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
O1;net.drinkingtea.ox.TypeDescriptor;1;{
|
||||
"fieldList" :
|
||||
[
|
||||
{
|
||||
"fieldName" : "r",
|
||||
"typeId" : "B.uint8;0"
|
||||
},
|
||||
{
|
||||
"fieldName" : "g",
|
||||
"typeId" : "B.uint8;0"
|
||||
},
|
||||
{
|
||||
"fieldName" : "b",
|
||||
"typeId" : "B.uint8;0"
|
||||
},
|
||||
{
|
||||
"fieldName" : "a",
|
||||
"typeId" : "B.uint8;0"
|
||||
}
|
||||
],
|
||||
"primitiveType" : 5,
|
||||
"typeName" : "net.drinkingtea.nostalgia.gfx.PaletteColor",
|
||||
"typeVersion" : 2
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
O1;net.drinkingtea.ox.TypeDescriptor;1;{
|
||||
"fieldList" :
|
||||
[
|
||||
{
|
||||
"fieldName" : "id",
|
||||
"typeId" : "B.int32;0"
|
||||
},
|
||||
{
|
||||
"fieldName" : "name",
|
||||
"typeId" : "net.drinkingtea.ox.BasicString#8#;1"
|
||||
},
|
||||
{
|
||||
"fieldName" : "rows",
|
||||
"typeId" : "B.int32;0"
|
||||
},
|
||||
{
|
||||
"fieldName" : "columns",
|
||||
"typeId" : "B.int32;0"
|
||||
},
|
||||
{
|
||||
"fieldName" : "subsheets",
|
||||
"subscriptLevels" : 1,
|
||||
"subscriptStack" :
|
||||
[
|
||||
{
|
||||
"subscriptType" : 4
|
||||
}
|
||||
],
|
||||
"typeId" : "net.drinkingtea.nostalgia.gfx.TileSheet.SubSheet;5"
|
||||
},
|
||||
{
|
||||
"fieldName" : "pixels",
|
||||
"subscriptLevels" : 1,
|
||||
"subscriptStack" :
|
||||
[
|
||||
{
|
||||
"subscriptType" : 4
|
||||
}
|
||||
],
|
||||
"typeId" : "B.uint8;0"
|
||||
}
|
||||
],
|
||||
"primitiveType" : 5,
|
||||
"typeName" : "net.drinkingtea.nostalgia.gfx.TileSheet.SubSheet",
|
||||
"typeVersion" : 5
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
O1;net.drinkingtea.ox.TypeDescriptor;1;{
|
||||
"fieldList" :
|
||||
[
|
||||
{
|
||||
"fieldName" : "bpp",
|
||||
"typeId" : "B.int8;0"
|
||||
},
|
||||
{
|
||||
"fieldName" : "idIt",
|
||||
"typeId" : "B.int32;0"
|
||||
},
|
||||
{
|
||||
"fieldName" : "defaultPalette",
|
||||
"typeId" : "net.drinkingtea.ox.BasicString#8#;1"
|
||||
},
|
||||
{
|
||||
"fieldName" : "subsheet",
|
||||
"typeId" : "net.drinkingtea.nostalgia.gfx.TileSheet.SubSheet;5"
|
||||
}
|
||||
],
|
||||
"primitiveType" : 5,
|
||||
"typeName" : "net.drinkingtea.nostalgia.gfx.TileSheet",
|
||||
"typeVersion" : 5
|
||||
}
|
@ -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
|
||||
|
@ -16,23 +16,6 @@
|
||||
|
||||
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
|
||||
struct TileSheetV1 {
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
ts.pixels.resize(bytes);
|
||||
return {};
|
||||
@ -101,7 +84,7 @@ constexpr bool valid(TileSheetV2 const&ts) noexcept {
|
||||
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);
|
||||
ss.pixels.resize(bytes);
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
ss.pixels.resize(bytes);
|
||||
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);
|
||||
}
|
||||
|
||||
constexpr void repair(TileSheetV4::SubSheet &ss, int bpp) noexcept {
|
||||
constexpr void repair(TileSheetV4::SubSheet &ss, int const bpp) noexcept {
|
||||
if (ss.subsheets.empty()) {
|
||||
auto const bytes = static_cast<size_t>(ss.columns * ss.rows * PixelsPerTile) / (bpp == 4 ? 2 : 1);
|
||||
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);
|
||||
}
|
||||
|
||||
constexpr void repair(TileSheetV5::SubSheet &ss, int const bpp) noexcept {
|
||||
constexpr void repair(TileSheetV5::SubSheet &ss) noexcept {
|
||||
if (ss.subsheets.empty()) {
|
||||
auto const bytes = static_cast<size_t>(ss.columns * ss.rows * PixelsPerTile);
|
||||
ss.pixels.resize(bytes);
|
||||
@ -377,7 +360,7 @@ constexpr void repair(TileSheetV5::SubSheet &ss, int const bpp) noexcept {
|
||||
ss.rows = -1;
|
||||
}
|
||||
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) {
|
||||
return ox::Error{1, "Unable to repair TileSheet"};
|
||||
}
|
||||
repair(ts.subsheet, ts.bpp);
|
||||
repair(ts.subsheet);
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,7 @@ void TileSheetV4ToTileSheetV5Converter::convertSubsheet(
|
||||
dst.pixels.emplace_back(static_cast<uint8_t>(p & 0xf));
|
||||
dst.pixels.emplace_back(static_cast<uint8_t>(p >> 4));
|
||||
}
|
||||
oxAssert(dst.pixels.size() == src.pixels.size() *2, "mismatch");
|
||||
oxAssert(dst.pixels.size() == src.pixels.size() * 2, "mismatch");
|
||||
} else {
|
||||
dst.pixels = std::move(src.pixels);
|
||||
}
|
||||
|
@ -36,21 +36,12 @@ OX_MODEL_BEGIN(TileSheetEditorConfig)
|
||||
OX_MODEL_END()
|
||||
|
||||
static ox::Vector<uint32_t> normalizePixelSizes(
|
||||
ox::Vector<uint8_t> const&inPixels,
|
||||
int const bpp) noexcept {
|
||||
uint_t const bytesPerTile = bpp == 8 ? PixelsPerTile : PixelsPerTile / 2;
|
||||
ox::Vector<uint8_t> const&inPixels) noexcept {
|
||||
ox::Vector<uint32_t> outPixels;
|
||||
if (bytesPerTile == 64) { // 8 BPP
|
||||
outPixels.resize(inPixels.size());
|
||||
for (std::size_t i = 0; i < inPixels.size(); ++i) {
|
||||
outPixels[i] = inPixels[i];
|
||||
}
|
||||
} else { // 4 BPP
|
||||
outPixels.resize(inPixels.size() * 2);
|
||||
for (std::size_t i = 0; i < inPixels.size(); ++i) {
|
||||
outPixels[i * 2 + 0] = inPixels[i] & 0xF;
|
||||
outPixels[i * 2 + 1] = inPixels[i] >> 4;
|
||||
}
|
||||
outPixels.reserve(inPixels.size());
|
||||
outPixels.resize(inPixels.size());
|
||||
for (std::size_t i = 0; i < inPixels.size(); ++i) {
|
||||
outPixels[i] = inPixels[i];
|
||||
}
|
||||
return outPixels;
|
||||
}
|
||||
@ -409,12 +400,11 @@ void TileSheetEditorImGui::showSubsheetEditor() noexcept {
|
||||
ox::Error TileSheetEditorImGui::exportSubhseetToPng(int const scale) const noexcept {
|
||||
OX_REQUIRE(path, studio::saveFile({{"PNG", "png"}}));
|
||||
// subsheet to png
|
||||
auto const&img = m_model.img();
|
||||
auto const&s = m_model.activeSubSheet();
|
||||
auto const&pal = m_model.pal();
|
||||
auto const width = s.columns * TileWidth;
|
||||
auto const height = s.rows * TileHeight;
|
||||
auto pixels = normalizePixelSizes(s.pixels, img.bpp);
|
||||
auto pixels = normalizePixelSizes(s.pixels);
|
||||
pixels = normalizePixelArrangement(pixels, s.columns, scale);
|
||||
auto const err = toPngFile(
|
||||
path,
|
||||
@ -652,7 +642,7 @@ void TileSheetEditorImGui::ExportMenu::draw(turbine::Context &tctx) noexcept {
|
||||
constexpr auto popupSz = ImVec2{popupWidth, popupHeight};
|
||||
if (ig::BeginPopup(tctx, popupName, m_show, popupSz)) {
|
||||
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) {
|
||||
inputSubmitted.emit(m_scale);
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
#include <nostalgia/gfx/keelmodule.hpp>
|
||||
#include <nostalgia/scene/keelmodule.hpp>
|
||||
#include <nostalgia/sound/keelmodule.hpp>
|
||||
|
||||
namespace nostalgia {
|
||||
|
||||
@ -14,7 +14,7 @@ void registerKeelModules() noexcept {
|
||||
}
|
||||
modulesRegistered = true;
|
||||
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>
|
||||
|
||||
namespace nostalgia::scene {
|
||||
namespace nostalgia::sound {
|
||||
|
||||
const keel::Module *keelModule() noexcept;
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include <studio/studio.hpp>
|
||||
|
||||
namespace nostalgia::scene {
|
||||
namespace nostalgia::sound {
|
||||
|
||||
const studio::Module *studioModule() noexcept;
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include <studio/studio.hpp>
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::sound {
|
||||
|
||||
static class: public studio::Module {
|
||||
ox::Vector<studio::EditorMaker> editors(studio::StudioContext&) const noexcept final {
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include <studioapp/studioapp.hpp>
|
||||
|
||||
#include <nostalgia/gfx/studiomodule.hpp>
|
||||
#include <nostalgia/scene/studiomodule.hpp>
|
||||
#include <nostalgia/sound/studiomodule.hpp>
|
||||
|
||||
namespace nostalgia {
|
||||
|
||||
@ -16,7 +16,7 @@ void registerStudioModules() noexcept {
|
||||
}
|
||||
modulesRegistered = true;
|
||||
studio::registerModule(gfx::studioModule());
|
||||
studio::registerModule(scene::studioModule());
|
||||
studio::registerModule(sound::studioModule());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include <turbine/turbine.hpp>
|
||||
|
||||
#include <nostalgia/gfx/core.hpp>
|
||||
#include <nostalgia/scene/scene.hpp>
|
||||
|
||||
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(
|
||||
[[maybe_unused]] ox::StringView project,
|
||||
[[maybe_unused]] ox::StringView appName,
|
||||
[[maybe_unused]] ox::StringView projectDataDir,
|
||||
ox::SpanView<char const*> args) noexcept {
|
||||
ox::SpanView<ox::CString> args) noexcept {
|
||||
if (args.size() < 2) {
|
||||
return ox::Error{1, "Please provide path to project directory or OxFS file."};
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ target_link_libraries(
|
||||
|
||||
target_compile_definitions(
|
||||
NostalgiaStudio PUBLIC
|
||||
OLYMPIC_APP_VERSION="dev build"
|
||||
OLYMPIC_APP_VERSION="d2025.02.1"
|
||||
)
|
||||
|
||||
install(
|
||||
|
@ -18,7 +18,7 @@
|
||||
<string>APPL</string>
|
||||
|
||||
<key>CFBundleVersion</key>
|
||||
<string>dev build</string>
|
||||
<string>d2025.02.1</string>
|
||||
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>12.0.0</string>
|
||||
|
@ -68,7 +68,7 @@ constexpr auto makeLoader(Context &ctx) {
|
||||
if (!beginsWith(assetId, "/")) {
|
||||
auto const p = ctx.uuidToPath.at(assetId);
|
||||
if (p.error) {
|
||||
oxErrf("Could not find asset: {}", assetId);
|
||||
oxErrf("Could not find asset: {}\n", assetId);
|
||||
return ox::Error{1, "Asset ID not found"};
|
||||
}
|
||||
assetId = *p.value;
|
||||
|
@ -1,17 +1,17 @@
|
||||
add_library(
|
||||
StudioAppLib
|
||||
aboutpopup.cpp
|
||||
app.cpp
|
||||
clawviewer.cpp
|
||||
deleteconfirmation.cpp
|
||||
filedialogmanager.cpp
|
||||
main.cpp
|
||||
makecopypopup.cpp
|
||||
newdir.cpp
|
||||
newmenu.cpp
|
||||
newproject.cpp
|
||||
projectexplorer.cpp
|
||||
renamefile.cpp
|
||||
studioapp.cpp
|
||||
studioui.cpp
|
||||
)
|
||||
target_compile_definitions(
|
||||
StudioAppLib PUBLIC
|
||||
|
@ -11,8 +11,7 @@
|
||||
#include <turbine/turbine.hpp>
|
||||
|
||||
#include <studio/context.hpp>
|
||||
#include <studioapp/studioapp.hpp>
|
||||
#include "studioapp.hpp"
|
||||
#include "studioui.hpp"
|
||||
|
||||
namespace studio {
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include <studio/configio.hpp>
|
||||
#include "clawviewer.hpp"
|
||||
#include "filedialogmanager.hpp"
|
||||
#include "studioapp.hpp"
|
||||
#include "studioui.hpp"
|
||||
|
||||
namespace studio {
|
||||
|
||||
@ -156,7 +156,7 @@ void StudioUI::draw() noexcept {
|
||||
void StudioUI::drawMenu() noexcept {
|
||||
if (ImGui::BeginMainMenuBar()) {
|
||||
if (ImGui::BeginMenu("File")) {
|
||||
if (ImGui::MenuItem("New...", "Ctrl+N")) {
|
||||
if (ImGui::MenuItem("New...", "Ctrl+N", false, m_project)) {
|
||||
m_newMenu.open();
|
||||
}
|
||||
if (ImGui::MenuItem("New Project...", "Ctrl+Shift+N")) {
|
||||
@ -254,6 +254,7 @@ void StudioUI::drawTabs() noexcept {
|
||||
if (!open) {
|
||||
if (e->unsavedChanges()) {
|
||||
m_closeFileConfirm.open();
|
||||
++it;
|
||||
} else {
|
||||
e->close();
|
||||
if (m_activeEditor == (*it).get()) {
|
@ -44,5 +44,5 @@ install(
|
||||
DIRECTORY
|
||||
../include/studio
|
||||
DESTINATION
|
||||
include/studio/
|
||||
include/studio
|
||||
)
|
||||
|
@ -84,10 +84,11 @@ ox::FileSystem &Project::romFs() noexcept {
|
||||
}
|
||||
|
||||
ox::Error Project::mkdir(ox::StringViewCR path) const noexcept {
|
||||
auto const [stat, err] = m_fs.stat(path);
|
||||
auto [stat, err] = m_fs.stat(path);
|
||||
if (err) {
|
||||
OX_RETURN_ERROR(m_fs.mkdir(path, true));
|
||||
dirAdded.emit(path);
|
||||
OX_RETURN_ERROR(m_fs.stat(path).moveTo(stat));
|
||||
}
|
||||
return stat.fileType == ox::FileType::Directory ?
|
||||
ox::Error{} : ox::Error{1, "path exists as normal file"};
|
||||
|
Reference in New Issue
Block a user