Compare commits
46 Commits
b7202a2b0d
...
release-d2
Author | SHA1 | Date | |
---|---|---|---|
13e256b3a9 | |||
6bd74611cd | |||
c3f9cf9a64 | |||
646ab1283f | |||
74cf055610 | |||
0d8ba1b154 | |||
20edbb7f38 | |||
6febc7cc73 | |||
b94d6b5061 | |||
b3952cabbc | |||
2ffc11b04e | |||
96cace2cbb | |||
472f5702bd | |||
c0ac4345d3 | |||
fbebf4ef83 | |||
20513f7749 | |||
25a7873ea2 | |||
d0a32e247e | |||
03d4a5736e | |||
a2e41e6527 | |||
40a7caff90 | |||
26fc5565e8 | |||
388541ce32 | |||
6c194667b9 | |||
62d0579f40 | |||
202595b2a6 | |||
cb21ff3f04 | |||
2a8e3c2dc4 | |||
998066d377 | |||
fefb876fe7 | |||
5979e9885e | |||
a17abe4639 | |||
d62f913855 | |||
12bb7475fc | |||
df2c7e2b67 | |||
713aec887b | |||
3089cd7afc | |||
00638bc812 | |||
e002109829 | |||
b4798fd2ab | |||
3c804bf62a | |||
d39d552bd9 | |||
8459d3baea | |||
8d04af691e | |||
6c34198f58 | |||
f63c58169f |
@ -4,7 +4,7 @@ on: [push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: nostalgia
|
||||
runs-on: olympic
|
||||
steps:
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v3
|
||||
@ -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
|
||||
|
2
deps/buildcore/base.mk
vendored
2
deps/buildcore/base.mk
vendored
@ -93,7 +93,7 @@ purge:
|
||||
${BC_CMD_RM_RF} compile_commands.json
|
||||
.PHONY: test
|
||||
test: build
|
||||
${BC_CMD_ENVRUN} mypy ${BC_VAR_SCRIPTS}
|
||||
${BC_CMD_ENVRUN} ${BC_CMD_PY3} -m mypy ${BC_VAR_SCRIPTS}
|
||||
${BC_CMD_CMAKE_BUILD} ${BC_VAR_BUILD_PATH} test
|
||||
.PHONY: test-verbose
|
||||
test-verbose: build
|
||||
|
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
|
||||
|
2
deps/nfde/CMakeLists.txt
vendored
2
deps/nfde/CMakeLists.txt
vendored
@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
cmake_minimum_required(VERSION 3.19)
|
||||
project(nativefiledialog-extended VERSION 1.1.1)
|
||||
|
||||
set(nfd_ROOT_PROJECT OFF)
|
||||
|
2
deps/ox/deps/jsoncpp/CMakeLists.txt
vendored
2
deps/ox/deps/jsoncpp/CMakeLists.txt
vendored
@ -12,7 +12,7 @@
|
||||
# CMake versions greater than the JSONCPP_NEWEST_VALIDATED_POLICIES_VERSION policies will
|
||||
# continue to generate policy warnings "CMake Warning (dev)...Policy CMP0XXX is not set:"
|
||||
#
|
||||
set(JSONCPP_OLDEST_VALIDATED_POLICIES_VERSION "3.8.0")
|
||||
set(JSONCPP_OLDEST_VALIDATED_POLICIES_VERSION "3.13.2")
|
||||
set(JSONCPP_NEWEST_VALIDATED_POLICIES_VERSION "3.13.2")
|
||||
cmake_minimum_required(VERSION ${JSONCPP_OLDEST_VALIDATED_POLICIES_VERSION})
|
||||
if("${CMAKE_VERSION}" VERSION_LESS "${JSONCPP_NEWEST_VALIDATED_POLICIES_VERSION}")
|
||||
|
@ -93,7 +93,9 @@ Result<FileStat> PassThroughFS::statPath(StringViewCR path) const noexcept {
|
||||
oxTracef("ox.fs.PassThroughFS.statInode", "{} {}", ec.message(), path);
|
||||
const uint64_t size = type == FileType::Directory ? 0 : std::filesystem::file_size(p, ec);
|
||||
oxTracef("ox.fs.PassThroughFS.statInode.size", "{} {}", path, size);
|
||||
OX_RETURN_ERROR(ox::Error(static_cast<ox::ErrorCode>(ec.value()), "PassThroughFS: stat failed"));
|
||||
if (auto err = ec.value()) {
|
||||
return ox::Error{static_cast<ox::ErrorCode>(err), "PassThroughFS: stat failed"};
|
||||
}
|
||||
return FileStat{0, 0, size, type};
|
||||
}
|
||||
|
||||
|
4
deps/ox/src/ox/std/array.hpp
vendored
4
deps/ox/src/ox/std/array.hpp
vendored
@ -181,13 +181,13 @@ constexpr Array<T, ArraySize> &Array<T, ArraySize>::operator=(Array &&other) noe
|
||||
|
||||
template<typename T, std::size_t ArraySize>
|
||||
constexpr T &Array<T, ArraySize>::operator[](std::size_t i) noexcept {
|
||||
ox::primitiveAssert(__FILE__, __LINE__, i < size(), "Array access overflow");
|
||||
boundsCheck(__FILE__, __LINE__, i, size(), "Array access overflow");
|
||||
return m_items[i];
|
||||
}
|
||||
|
||||
template<typename T, std::size_t ArraySize>
|
||||
constexpr const T &Array<T, ArraySize>::operator[](std::size_t i) const noexcept {
|
||||
ox::primitiveAssert(__FILE__, __LINE__, i < size(), "Array access overflow");
|
||||
boundsCheck(__FILE__, __LINE__, i, size(), "Array access overflow");
|
||||
return m_items[i];
|
||||
}
|
||||
|
||||
|
6
deps/ox/src/ox/std/defines.hpp
vendored
6
deps/ox/src/ox/std/defines.hpp
vendored
@ -41,6 +41,12 @@ constexpr auto Debug = true;
|
||||
constexpr auto Debug = false;
|
||||
#endif
|
||||
|
||||
#if defined(OX_CHECK_BOUNDS)
|
||||
constexpr auto CheckBounds = true;
|
||||
#else
|
||||
constexpr auto CheckBounds = Debug;
|
||||
#endif
|
||||
|
||||
#if defined(NDEBUG)
|
||||
constexpr auto NDebug = true;
|
||||
#else
|
||||
|
13
deps/ox/src/ox/std/error.hpp
vendored
13
deps/ox/src/ox/std/error.hpp
vendored
@ -330,4 +330,17 @@ constexpr void primitiveAssert(char const*file, int line, bool pass, char const*
|
||||
}
|
||||
}
|
||||
|
||||
constexpr void boundsCheck(
|
||||
char const*file,
|
||||
int const line,
|
||||
size_t const i,
|
||||
size_t const sz,
|
||||
char const*msg) noexcept {
|
||||
if constexpr(defines::CheckBounds) {
|
||||
if (i >= sz) [[unlikely]] {
|
||||
panic(file, line, msg, ox::Error{1});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
6
deps/ox/src/ox/std/iterator.hpp
vendored
6
deps/ox/src/ox/std/iterator.hpp
vendored
@ -133,17 +133,17 @@ struct SpanIterator {
|
||||
}
|
||||
|
||||
constexpr PtrType operator->() const noexcept {
|
||||
ox::primitiveAssert(__FILE__, __LINE__, m_offset < m_max, "SpanIterator access overflow");
|
||||
boundsCheck(__FILE__, __LINE__, m_offset, m_max, "SpanIterator access overflow");
|
||||
return &m_t[m_offset];
|
||||
}
|
||||
|
||||
constexpr RefType operator*() const noexcept {
|
||||
ox::primitiveAssert(__FILE__, __LINE__, m_offset < m_max, "SpanIterator access overflow");
|
||||
boundsCheck(__FILE__, __LINE__, m_offset, m_max, "SpanIterator access overflow");
|
||||
return m_t[m_offset];
|
||||
}
|
||||
|
||||
constexpr RefType operator[](std::size_t s) const noexcept {
|
||||
ox::primitiveAssert(__FILE__, __LINE__, s < m_max, "SpanIterator access overflow");
|
||||
boundsCheck(__FILE__, __LINE__, s, m_max, "SpanIterator access overflow");
|
||||
return m_t[s];
|
||||
}
|
||||
|
||||
|
8
deps/ox/src/ox/std/span.hpp
vendored
8
deps/ox/src/ox/std/span.hpp
vendored
@ -129,22 +129,22 @@ class Span {
|
||||
}
|
||||
|
||||
constexpr T &operator[](std::size_t i) noexcept {
|
||||
ox::primitiveAssert(__FILE__, __LINE__, i < size(), "Span access overflow");
|
||||
boundsCheck(__FILE__, __LINE__, i, size(), "Span access overflow");
|
||||
return m_items[i];
|
||||
}
|
||||
|
||||
constexpr T const&operator[](std::size_t i) const noexcept {
|
||||
ox::primitiveAssert(__FILE__, __LINE__, i < size(), "Span access overflow");
|
||||
boundsCheck(__FILE__, __LINE__, i, size(), "Span access overflow");
|
||||
return m_items[i];
|
||||
}
|
||||
|
||||
constexpr Span operator+(size_t i) const noexcept {
|
||||
ox::primitiveAssert(__FILE__, __LINE__, i < size(), "Span access overflow");
|
||||
boundsCheck(__FILE__, __LINE__, i, size(), "Span access overflow");
|
||||
return {m_items + i, m_size - i};
|
||||
}
|
||||
|
||||
constexpr Span operator+=(size_t i) noexcept {
|
||||
ox::primitiveAssert(__FILE__, __LINE__, i < size(), "Span access overflow");
|
||||
boundsCheck(__FILE__, __LINE__, i, size(), "Span access overflow");
|
||||
m_items += i;
|
||||
m_size -= i;
|
||||
return *this;
|
||||
|
42
deps/ox/src/ox/std/utility.hpp
vendored
42
deps/ox/src/ox/std/utility.hpp
vendored
@ -27,6 +27,48 @@ constexpr void swap(T &a, T &b) noexcept {
|
||||
b = std::move(temp);
|
||||
}
|
||||
|
||||
template<typename T, typename U>
|
||||
constexpr bool cmp_equal(T const t, U const u) noexcept {
|
||||
if constexpr(ox::is_signed_v<T> == ox::is_signed_v<U>) {
|
||||
return t == u;
|
||||
} else if constexpr(ox::is_signed_v<T>) {
|
||||
return ox::Signed<T>{t} == u;
|
||||
} else {
|
||||
return t == ox::Signed<U>{u};
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T, typename U>
|
||||
constexpr bool cmp_less(T const t, U const u) noexcept {
|
||||
if constexpr(ox::is_signed_v<T> == ox::is_signed_v<U>) {
|
||||
return t < u;
|
||||
} else if constexpr(ox::is_signed_v<T>) {
|
||||
return ox::Signed<T>{t} < u;
|
||||
} else {
|
||||
return t < ox::Signed<U>{u};
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T, typename U>
|
||||
constexpr bool cmp_not_equal(T const t, U const u) noexcept {
|
||||
return !std::cmp_equal(t, u);
|
||||
}
|
||||
|
||||
template<typename T, typename U>
|
||||
constexpr bool cmp_greater(T const t, U const u) noexcept {
|
||||
return std::cmp_less(u, t);
|
||||
}
|
||||
|
||||
template<typename T, typename U>
|
||||
constexpr bool cmp_less_equal(T const t, U const u) noexcept {
|
||||
return !std::cmp_less(u, t);
|
||||
}
|
||||
|
||||
template<typename T, typename U>
|
||||
constexpr bool cmp_greater_equal(T const t, U const u) noexcept {
|
||||
return !std::cmp_less(t, u);
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
17
deps/ox/src/ox/std/vector.hpp
vendored
17
deps/ox/src/ox/std/vector.hpp
vendored
@ -311,6 +311,8 @@ class Vector: detail::VectorAllocator<T, Allocator, SmallVectorSize> {
|
||||
*/
|
||||
constexpr Error unordered_erase(std::size_t pos) noexcept(useNoexcept);
|
||||
|
||||
constexpr Error remove(T const &val);
|
||||
|
||||
constexpr void reserve(std::size_t cap) noexcept(useNoexcept);
|
||||
|
||||
constexpr void shrink_to_fit() noexcept(useNoexcept);
|
||||
@ -427,13 +429,13 @@ constexpr Vector<T, SmallVectorSize, Allocator> &Vector<T, SmallVectorSize, Allo
|
||||
|
||||
template<typename T, std::size_t SmallVectorSize, typename Allocator>
|
||||
constexpr T &Vector<T, SmallVectorSize, Allocator>::operator[](std::size_t i) noexcept {
|
||||
ox::primitiveAssert(__FILE__, __LINE__, i < size(), "Vector access overflow");
|
||||
boundsCheck(__FILE__, __LINE__, i, size(), "Vector access overflow");
|
||||
return m_items[i];
|
||||
}
|
||||
|
||||
template<typename T, std::size_t SmallVectorSize, typename Allocator>
|
||||
constexpr const T &Vector<T, SmallVectorSize, Allocator>::operator[](std::size_t i) const noexcept {
|
||||
ox::primitiveAssert(__FILE__, __LINE__, i < size(), "Vector access overflow");
|
||||
boundsCheck(__FILE__, __LINE__, i, size(), "Vector access overflow");
|
||||
return m_items[i];
|
||||
}
|
||||
|
||||
@ -659,6 +661,17 @@ constexpr Error Vector<T, SmallVectorSize, Allocator>::unordered_erase(std::size
|
||||
return ox::Error(0);
|
||||
}
|
||||
|
||||
template<typename T, std::size_t SmallVectorSize, typename Allocator>
|
||||
constexpr ox::Error Vector<T, SmallVectorSize, Allocator>::remove(T const &val) {
|
||||
for (size_t i{}; auto const &v : *this) {
|
||||
if (v == val) {
|
||||
return erase(i).error;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
return ox::Error{1, "element not found"};
|
||||
}
|
||||
|
||||
template<typename T, std::size_t SmallVectorSize, typename Allocator>
|
||||
constexpr void Vector<T, SmallVectorSize, Allocator>::reserve(std::size_t cap) noexcept(useNoexcept) {
|
||||
if (cap <= m_cap) {
|
||||
|
@ -5,9 +5,13 @@
|
||||
* Add TileSheetV5. TileSheetV5 retains the bpp field for the sake of
|
||||
CompactTileSheet, but always store it pixel as 8 bpp for itself.
|
||||
* Add ability to move subsheets in the subsheet tree.
|
||||
* Add Flip X and Flip Y button for TileSheet Editor.
|
||||
* Add Flip X and Flip Y functionality to TileSheet Editor.
|
||||
* Add rotate functionality to TileSheet Editor.
|
||||
* 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.
|
||||
@ -15,3 +19,5 @@
|
||||
* Fix Palette Editor to ignore keyboard input when popups are open.
|
||||
* Palette Editor move color mechanism now uses drag and drop.
|
||||
* Add ability to reorder Palette pages.
|
||||
* Add warning for closing a tab with unsaved changes.
|
||||
* Add ability to close a tab with Ctrl/Cmd-W
|
||||
|
@ -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
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
# module dir list
|
||||
|
||||
add_subdirectory(gfx)
|
||||
add_subdirectory(scene)
|
||||
add_subdirectory(sound)
|
||||
|
||||
# module libraries
|
||||
|
||||
@ -13,8 +13,8 @@ add_library(
|
||||
target_link_libraries(
|
||||
NostalgiaKeelModules PUBLIC
|
||||
Keel
|
||||
NostalgiaCore-Keel
|
||||
NostalgiaScene-Keel
|
||||
NostalgiaGfx-Keel
|
||||
NostalgiaSound-Keel
|
||||
)
|
||||
install(
|
||||
FILES
|
||||
@ -32,8 +32,8 @@ if(NOSTALGIA_BUILD_STUDIO)
|
||||
target_link_libraries(
|
||||
NostalgiaStudioModules PUBLIC
|
||||
StudioAppLib
|
||||
NostalgiaCore-Studio-ImGui
|
||||
NostalgiaScene-Studio
|
||||
NostalgiaGfx-Studio-ImGui
|
||||
NostalgiaSound-Studio-ImGui
|
||||
)
|
||||
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 {};
|
||||
}
|
||||
|
||||
@ -443,23 +426,24 @@ ox::Error resizeSubsheet(TileSheet::SubSheet &ss, ox::Size const&sz) noexcept;
|
||||
[[nodiscard]]
|
||||
TileSheet::SubSheetIdx validateSubSheetIdx(TileSheet const&ts, TileSheet::SubSheetIdx idx) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
TileSheet::SubSheet const&getSubSheet(
|
||||
ox::SpanView<uint32_t> const&idx,
|
||||
std::size_t idxIt,
|
||||
TileSheet::SubSheet const&pSubsheet) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
TileSheet::SubSheet &getSubSheet(
|
||||
ox::SpanView<uint32_t> const&idx,
|
||||
std::size_t idxIt,
|
||||
TileSheet::SubSheet &pSubsheet) noexcept;
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__ >= 13
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdangling-reference"
|
||||
#endif
|
||||
[[nodiscard]]
|
||||
TileSheet::SubSheet const&getSubSheet(TileSheet const&ts, ox::SpanView<uint32_t> const &idx) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
TileSheet::SubSheet &getSubSheet(TileSheet &ts, ox::SpanView<uint32_t> const &idx) noexcept;
|
||||
#if defined(__GNUC__) && __GNUC__ >= 13
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
ox::Error addSubSheet(TileSheet &ts, TileSheet::SubSheetIdx const &idx) noexcept;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
add_library(
|
||||
NostalgiaCore
|
||||
NostalgiaGfx
|
||||
gfx.cpp
|
||||
tilesheet.cpp
|
||||
)
|
||||
@ -10,12 +10,12 @@ if(NOT BUILDCORE_TARGET STREQUAL "gba")
|
||||
endif()
|
||||
|
||||
target_include_directories(
|
||||
NostalgiaCore PUBLIC
|
||||
NostalgiaGfx PUBLIC
|
||||
../include
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
NostalgiaCore PUBLIC
|
||||
NostalgiaGfx PUBLIC
|
||||
Turbine
|
||||
)
|
||||
|
||||
@ -26,7 +26,7 @@ endif()
|
||||
|
||||
install(
|
||||
TARGETS
|
||||
NostalgiaCore
|
||||
NostalgiaGfx
|
||||
DESTINATION
|
||||
LIBRARY DESTINATION lib
|
||||
ARCHIVE DESTINATION lib
|
||||
|
@ -1,15 +1,15 @@
|
||||
add_library(
|
||||
NostalgiaCore-GBA OBJECT
|
||||
NostalgiaGfx-GBA OBJECT
|
||||
context.cpp
|
||||
gfx.cpp
|
||||
panic.cpp
|
||||
)
|
||||
target_include_directories(
|
||||
NostalgiaCore-GBA PUBLIC
|
||||
NostalgiaGfx-GBA PUBLIC
|
||||
../../include
|
||||
)
|
||||
target_link_libraries(
|
||||
NostalgiaCore-GBA PUBLIC
|
||||
NostalgiaGfx-GBA PUBLIC
|
||||
TeaGBA
|
||||
Keel
|
||||
Turbine
|
||||
@ -17,5 +17,5 @@ target_link_libraries(
|
||||
|
||||
if(BUILDCORE_TARGET STREQUAL "gba")
|
||||
set_source_files_properties(gfx.cpp PROPERTIES COMPILE_FLAGS -marm)
|
||||
target_link_libraries(NostalgiaCore PUBLIC NostalgiaCore-GBA)
|
||||
target_link_libraries(NostalgiaGfx PUBLIC NostalgiaGfx-GBA)
|
||||
endif()
|
||||
|
@ -1,18 +1,18 @@
|
||||
add_library(
|
||||
NostalgiaCore-Keel
|
||||
NostalgiaGfx-Keel
|
||||
keelmodule.cpp
|
||||
typeconv.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
NostalgiaCore-Keel PUBLIC
|
||||
NostalgiaGfx-Keel PUBLIC
|
||||
Keel
|
||||
NostalgiaCore
|
||||
NostalgiaGfx
|
||||
)
|
||||
|
||||
install(
|
||||
TARGETS
|
||||
NostalgiaCore-Keel
|
||||
NostalgiaGfx-Keel
|
||||
DESTINATION
|
||||
LIBRARY DESTINATION lib
|
||||
ARCHIVE DESTINATION lib
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
target_sources(
|
||||
NostalgiaCore PRIVATE
|
||||
NostalgiaGfx PRIVATE
|
||||
context.cpp
|
||||
gfx.cpp
|
||||
)
|
||||
target_link_libraries(
|
||||
NostalgiaCore PUBLIC
|
||||
NostalgiaGfx PUBLIC
|
||||
GlUtils
|
||||
)
|
||||
|
@ -449,7 +449,7 @@ static void setSprite(
|
||||
++i;
|
||||
};
|
||||
if (!s.flipX) {
|
||||
for (auto yIt = 0; yIt < static_cast<int>(dim.y); ++yIt) {
|
||||
for (auto yIt = 0u; yIt < dim.y; ++yIt) {
|
||||
for (auto xIt = 0u; xIt < dim.x; ++xIt) {
|
||||
set(static_cast<int>(xIt), static_cast<int>(yIt), s.enabled);
|
||||
}
|
||||
|
@ -1,25 +1,25 @@
|
||||
add_library(NostalgiaCore-Studio)
|
||||
add_library(NostalgiaGfx-Studio)
|
||||
|
||||
add_library(
|
||||
NostalgiaCore-Studio-ImGui
|
||||
NostalgiaGfx-Studio-ImGui
|
||||
studiomodule.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
NostalgiaCore-Studio PUBLIC
|
||||
NostalgiaCore
|
||||
NostalgiaGfx-Studio PUBLIC
|
||||
NostalgiaGfx
|
||||
Studio
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
NostalgiaCore-Studio-ImGui PUBLIC
|
||||
NostalgiaCore-Studio
|
||||
NostalgiaGfx-Studio-ImGui PUBLIC
|
||||
NostalgiaGfx-Studio
|
||||
)
|
||||
|
||||
install(
|
||||
TARGETS
|
||||
NostalgiaCore-Studio-ImGui
|
||||
NostalgiaCore-Studio
|
||||
NostalgiaGfx-Studio-ImGui
|
||||
NostalgiaGfx-Studio
|
||||
LIBRARY DESTINATION
|
||||
${NOSTALGIA_DIST_MODULE}
|
||||
)
|
||||
|
@ -1,5 +1,5 @@
|
||||
target_sources(
|
||||
NostalgiaCore-Studio-ImGui PRIVATE
|
||||
NostalgiaGfx-Studio-ImGui PRIVATE
|
||||
paletteeditor-imgui.cpp
|
||||
)
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
target_sources(
|
||||
NostalgiaCore-Studio PRIVATE
|
||||
NostalgiaGfx-Studio PRIVATE
|
||||
addcolorcommand.cpp
|
||||
addpagecommand.cpp
|
||||
applycolorallpagescommand.cpp
|
||||
|
@ -94,6 +94,27 @@ ox::Error PaletteEditorImGui::saveItem() noexcept {
|
||||
return m_sctx.project->writeObj(itemPath(), m_pal, ox::ClawFormat::Organic);
|
||||
}
|
||||
|
||||
void PaletteEditorImGui::navigateTo(ox::StringViewCR arg) noexcept {
|
||||
auto const args = ox::split<2>(arg, ';');
|
||||
if (args.size() < 2) {
|
||||
return;
|
||||
}
|
||||
auto const &color = args[0];
|
||||
auto const &page = args[1];
|
||||
{
|
||||
auto const [c, err] = atoi(color);
|
||||
if (!err && static_cast<size_t>(c) < colorCnt(m_pal)) {
|
||||
m_selectedColorRow = static_cast<size_t>(c);
|
||||
}
|
||||
}
|
||||
{
|
||||
auto const [pg, err] = atoi(page);
|
||||
if (!err && static_cast<size_t>(pg) < m_pal.pages.size()) {
|
||||
m_page = static_cast<size_t>(pg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PaletteEditorImGui::drawColumnLeftAlign(ox::CStringView txt) noexcept {
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%s", txt.c_str());
|
||||
|
@ -45,6 +45,8 @@ class PaletteEditorImGui: public studio::Editor {
|
||||
protected:
|
||||
ox::Error saveItem() noexcept final;
|
||||
|
||||
void navigateTo(ox::StringViewCR arg) noexcept override;
|
||||
|
||||
private:
|
||||
static void drawColumnLeftAlign(ox::CStringView txt) noexcept;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
target_sources(
|
||||
NostalgiaCore-Studio PRIVATE
|
||||
NostalgiaGfx-Studio PRIVATE
|
||||
tilesheeteditorview.cpp
|
||||
tilesheeteditormodel.cpp
|
||||
tilesheetpixelgrid.cpp
|
||||
@ -7,12 +7,12 @@ target_sources(
|
||||
)
|
||||
|
||||
target_sources(
|
||||
NostalgiaCore-Studio-ImGui PRIVATE
|
||||
NostalgiaGfx-Studio-ImGui PRIVATE
|
||||
tilesheeteditor-imgui.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
NostalgiaCore-Studio-ImGui PUBLIC
|
||||
NostalgiaGfx-Studio-ImGui PUBLIC
|
||||
lodepng
|
||||
)
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
target_sources(
|
||||
NostalgiaCore-Studio PRIVATE
|
||||
NostalgiaGfx-Studio PRIVATE
|
||||
addsubsheetcommand.cpp
|
||||
cutpastecommand.cpp
|
||||
deletetilescommand.cpp
|
||||
|
@ -63,7 +63,7 @@ DrawCommand::DrawCommand(
|
||||
TileSheet &img,
|
||||
TileSheet::SubSheetIdx subSheetIdx,
|
||||
std::size_t idx,
|
||||
int palIdx) noexcept:
|
||||
int const palIdx) noexcept:
|
||||
m_img(img),
|
||||
m_subSheetIdx(std::move(subSheetIdx)),
|
||||
m_palIdx(palIdx) {
|
||||
@ -75,7 +75,7 @@ DrawCommand::DrawCommand(
|
||||
TileSheet &img,
|
||||
TileSheet::SubSheetIdx subSheetIdx,
|
||||
ox::SpanView<std::size_t> const&idxList,
|
||||
int palIdx) noexcept:
|
||||
int const palIdx) noexcept:
|
||||
m_img(img),
|
||||
m_subSheetIdx(std::move(subSheetIdx)),
|
||||
m_palIdx(palIdx) {
|
||||
@ -123,7 +123,9 @@ void DrawCommand::lineUpdate(ox::Point a, ox::Point b) noexcept {
|
||||
for (int32_t i{}; i < range; ++i) {
|
||||
auto const idx = ptToIdx(x, y + i * mod, ss.columns * TileWidth);
|
||||
if (idx < ss.pixels.size()) {
|
||||
m_changes.emplace_back(static_cast<uint32_t>(idx), getPixel(ss, idx));
|
||||
if (m_palIdx != getPixel(ss, idx)) {
|
||||
m_changes.emplace_back(static_cast<uint32_t>(idx), getPixel(ss, idx));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -154,4 +156,8 @@ TileSheet::SubSheetIdx const&DrawCommand::subsheetIdx() const noexcept {
|
||||
return m_subSheetIdx;
|
||||
}
|
||||
|
||||
void DrawCommand::finish() noexcept {
|
||||
setObsolete(m_changes.empty());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -52,6 +52,8 @@ class DrawCommand: public TileSheetCommand {
|
||||
[[nodiscard]]
|
||||
TileSheet::SubSheetIdx const&subsheetIdx() const noexcept override;
|
||||
|
||||
void finish() noexcept;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
@ -248,29 +239,22 @@ void TileSheetEditorImGui::draw(studio::StudioContext&) noexcept {
|
||||
ImGui::EndChild();
|
||||
ImGui::BeginChild("OperationsBox", {0, 35}, ImGuiWindowFlags_NoTitleBar);
|
||||
{
|
||||
size_t i{};
|
||||
if (ig::ComboBox("##Operations", ox::SpanView<ox::CStringView>{{
|
||||
ox::CStringView{"Operations"},
|
||||
ox::CStringView{"Flip X"},
|
||||
ox::CStringView{"Flip Y"},
|
||||
ox::CStringView{"Rotate Left"},
|
||||
ox::CStringView{"Rotate Right"},
|
||||
}}, i)) {
|
||||
switch (i) {
|
||||
case 1:
|
||||
oxLogError(m_model.flipX());
|
||||
break;
|
||||
case 2:
|
||||
oxLogError(m_model.flipY());
|
||||
break;
|
||||
case 3:
|
||||
oxLogError(m_model.rotateLeft());
|
||||
break;
|
||||
case 4:
|
||||
oxLogError(m_model.rotateRight());
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
if (ImGui::BeginCombo("##Operations", "Operations", 0)) {
|
||||
if (ImGui::Selectable("Flip X", false)) {
|
||||
oxLogError(m_model.flipX());
|
||||
}
|
||||
if (ImGui::Selectable("Flip Y", false)) {
|
||||
oxLogError(m_model.flipY());
|
||||
}
|
||||
ImGui::BeginDisabled(!m_model.rotateEligible());
|
||||
if (ImGui::Selectable("Rotate Left", false)) {
|
||||
oxLogError(m_model.rotateLeft());
|
||||
}
|
||||
if (ImGui::Selectable("Rotate Right", false)) {
|
||||
oxLogError(m_model.rotateRight());
|
||||
}
|
||||
ImGui::EndDisabled();
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
}
|
||||
ImGui::EndChild();
|
||||
@ -416,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,
|
||||
@ -572,9 +555,15 @@ void TileSheetEditorImGui::drawPaletteMenu() noexcept {
|
||||
label.c_str(), rowSelected, ImGuiSelectableFlags_SpanAllColumns)) {
|
||||
m_view.setPalIdx(i);
|
||||
}
|
||||
if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(0)) {
|
||||
studio::navigateTo(
|
||||
m_sctx,
|
||||
m_model.palPath(),
|
||||
ox::sfmt("{};{}", i, m_model.palettePage()));
|
||||
}
|
||||
// Column: color RGB
|
||||
ImGui::TableNextColumn();
|
||||
auto ic = ImGui::GetColorU32(ImVec4(redf(c), greenf(c), bluef(c), 1));
|
||||
auto const ic = ImGui::GetColorU32({redf(c), greenf(c), bluef(c), 1});
|
||||
ImGui::TableSetBgColor(ImGuiTableBgTarget_CellBg, ic);
|
||||
ImGui::TableNextColumn();
|
||||
auto const&name = i < pal.colorNames.size() ? pal.colorNames[i].c_str() : "";
|
||||
@ -653,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);
|
||||
}
|
||||
|
@ -18,14 +18,13 @@
|
||||
#include "commands/drawcommand.hpp"
|
||||
#include "commands/flipcommand.hpp"
|
||||
#include "commands/inserttilescommand.hpp"
|
||||
#include "commands/movesubsheetcommand.hpp"
|
||||
#include "commands/palettechangecommand.hpp"
|
||||
#include "commands/rmsubsheetcommand.hpp"
|
||||
#include "commands/rotatecommand.hpp"
|
||||
#include "commands/updatesubsheetcommand.hpp"
|
||||
#include "tilesheeteditormodel.hpp"
|
||||
|
||||
#include "commands/movesubsheetcommand.hpp"
|
||||
#include "commands/rotatecommand.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
|
||||
// delete pixels of all non-leaf nodes
|
||||
@ -172,7 +171,7 @@ void TileSheetEditorModel::drawLineCommand(ox::Point const &pt, std::size_t cons
|
||||
if (m_ongoingDrawCommand) {
|
||||
m_ongoingDrawCommand->lineUpdate(m_lineStartPt, pt);
|
||||
m_updated = true;
|
||||
} else if (getPixel(activeSubSheet, idx) != palIdx) {
|
||||
} else {
|
||||
std::ignore = pushCommand(ox::make<DrawCommand>(
|
||||
m_img, m_activeSubsSheetIdx, idx, static_cast<int>(palIdx)));
|
||||
m_lineStartPt = pt;
|
||||
@ -180,7 +179,10 @@ void TileSheetEditorModel::drawLineCommand(ox::Point const &pt, std::size_t cons
|
||||
}
|
||||
|
||||
void TileSheetEditorModel::endDrawCommand() noexcept {
|
||||
m_ongoingDrawCommand = nullptr;
|
||||
if (m_ongoingDrawCommand) {
|
||||
m_ongoingDrawCommand->finish();
|
||||
m_ongoingDrawCommand = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void TileSheetEditorModel::addSubsheet(TileSheet::SubSheetIdx const&parentIdx) noexcept {
|
||||
@ -352,6 +354,16 @@ ox::Error TileSheetEditorModel::flipY() noexcept {
|
||||
return pushCommand(ox::make<FlipYCommand>(m_img, m_activeSubsSheetIdx, a, b));
|
||||
}
|
||||
|
||||
bool TileSheetEditorModel::rotateEligible() const noexcept {
|
||||
if (m_selection) {
|
||||
auto const w = m_selection->b.x - m_selection->a.x;
|
||||
auto const h = m_selection->b.y - m_selection->a.y;
|
||||
return w == h;
|
||||
}
|
||||
auto const &ss = activeSubSheet();
|
||||
return ss.rows == ss.columns;
|
||||
}
|
||||
|
||||
ox::Error TileSheetEditorModel::moveSubSheet(TileSheet::SubSheetIdx src, TileSheet::SubSheetIdx dst) noexcept {
|
||||
return pushCommand(ox::make<MoveSubSheetCommand>(m_img, std::move(src), std::move(dst)));
|
||||
}
|
||||
|
@ -138,6 +138,9 @@ class TileSheetEditorModel: public ox::SignalHandler {
|
||||
|
||||
ox::Error flipY() noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
bool rotateEligible() const noexcept;
|
||||
|
||||
ox::Error moveSubSheet(TileSheet::SubSheetIdx src, TileSheet::SubSheetIdx dst) noexcept;
|
||||
|
||||
private:
|
||||
|
@ -22,7 +22,12 @@ ox::Error TileSheetGrid::buildShader() noexcept {
|
||||
}
|
||||
|
||||
void TileSheetGrid::draw(bool update, ox::Vec2 const&scroll) noexcept {
|
||||
glLineWidth(3 * m_pixelSizeMod * 0.5f);
|
||||
// the lines just show up bigger on Windows for some reason
|
||||
if constexpr(ox::defines::OS == ox::OS::Windows) {
|
||||
glLineWidth(3 * m_pixelSizeMod * 0.25f);
|
||||
} else {
|
||||
glLineWidth(3 * m_pixelSizeMod * 0.5f);
|
||||
}
|
||||
glUseProgram(m_shader);
|
||||
glBindVertexArray(m_bufferSet.vao);
|
||||
if (update) {
|
||||
|
@ -187,7 +187,11 @@ TileSheet::SubSheetIdx validateSubSheetIdx(TileSheet const&ts, TileSheet::SubShe
|
||||
return validateSubSheetIdx(std::move(idx), 0, ts.subsheet);
|
||||
}
|
||||
|
||||
TileSheet::SubSheet const&getSubSheet(
|
||||
#if defined(__GNUC__) && __GNUC__ >= 13
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdangling-reference"
|
||||
#endif
|
||||
static TileSheet::SubSheet const&getSubSheet(
|
||||
ox::SpanView<uint32_t> const &idx,
|
||||
std::size_t const idxIt,
|
||||
TileSheet::SubSheet const &pSubsheet) noexcept {
|
||||
@ -200,6 +204,9 @@ TileSheet::SubSheet const&getSubSheet(
|
||||
}
|
||||
return getSubSheet(idx, idxIt + 1, pSubsheet.subsheets[currentIdx]);
|
||||
}
|
||||
#if defined(__GNUC__) && __GNUC__ >= 13
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
TileSheet::SubSheet &getSubSheet(
|
||||
ox::SpanView<uint32_t> const &idx,
|
||||
@ -211,13 +218,20 @@ TileSheet::SubSheet &getSubSheet(
|
||||
return getSubSheet(idx, idxIt + 1, pSubsheet.subsheets[idx[idxIt]]);
|
||||
}
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__ >= 13
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdangling-reference"
|
||||
#endif
|
||||
TileSheet::SubSheet const&getSubSheet(TileSheet const &ts, ox::SpanView<uint32_t> const &idx) noexcept {
|
||||
return gfx::getSubSheet(idx, 0, ts.subsheet);
|
||||
}
|
||||
|
||||
TileSheet::SubSheet &getSubSheet(TileSheet &ts, ox::SpanView<uint32_t> const&idx) noexcept {
|
||||
TileSheet::SubSheet &getSubSheet(TileSheet &ts, ox::SpanView<uint32_t> const &idx) noexcept {
|
||||
return gfx::getSubSheet(idx, 0, ts.subsheet);
|
||||
}
|
||||
#if defined(__GNUC__) && __GNUC__ >= 13
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
ox::Error addSubSheet(TileSheet &ts, TileSheet::SubSheetIdx const&idx) noexcept {
|
||||
auto &parent = getSubSheet(ts, idx);
|
||||
|
@ -1,11 +1,11 @@
|
||||
add_executable(
|
||||
NostalgiaCoreTest
|
||||
NostalgiaGfxTest
|
||||
tests.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
NostalgiaCoreTest
|
||||
NostalgiaCore
|
||||
NostalgiaGfxTest
|
||||
NostalgiaGfx
|
||||
)
|
||||
|
||||
add_test("[NostalgiaCore] readWriteTileSheet" ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/NostalgiaCoreTest readWriteTileSheet)
|
||||
add_test("[NostalgiaGfx] readWriteTileSheet" ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/NostalgiaGfxTest readWriteTileSheet)
|
||||
|
@ -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,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,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,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;
|
||||
}
|
||||
|
||||
}
|
@ -1,13 +1,12 @@
|
||||
add_subdirectory(src)
|
||||
|
||||
target_include_directories(
|
||||
NostalgiaScene PUBLIC
|
||||
include
|
||||
)
|
||||
if(NOT BUILDCORE_TARGET STREQUAL "gba")
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
||||
install(
|
||||
DIRECTORY
|
||||
include/nostalgia
|
||||
DESTINATION
|
||||
include
|
||||
)
|
||||
)
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include <keel/module.hpp>
|
||||
|
||||
namespace nostalgia::scene {
|
||||
namespace nostalgia::sound {
|
||||
|
||||
const keel::Module *keelModule() noexcept;
|
||||
|
@ -0,0 +1,8 @@
|
||||
/*
|
||||
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace nostalgia::sound {
|
||||
}
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include <studio/studio.hpp>
|
||||
|
||||
namespace nostalgia::scene {
|
||||
namespace nostalgia::sound {
|
||||
|
||||
const studio::Module *studioModule() noexcept;
|
||||
|
@ -1,18 +1,16 @@
|
||||
|
||||
add_library(
|
||||
NostalgiaScene
|
||||
scene.cpp
|
||||
scenestatic.cpp
|
||||
NostalgiaSound
|
||||
sound.cpp
|
||||
)
|
||||
|
||||
target_include_directories(
|
||||
NostalgiaScene PUBLIC
|
||||
NostalgiaSound PUBLIC
|
||||
../include
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
NostalgiaScene PUBLIC
|
||||
NostalgiaCore
|
||||
NostalgiaSound PUBLIC
|
||||
Turbine
|
||||
)
|
||||
|
||||
add_subdirectory(keel)
|
||||
@ -22,7 +20,7 @@ endif()
|
||||
|
||||
install(
|
||||
TARGETS
|
||||
NostalgiaScene
|
||||
NostalgiaSound
|
||||
DESTINATION
|
||||
LIBRARY DESTINATION lib
|
||||
ARCHIVE DESTINATION lib
|
19
src/nostalgia/modules/sound/src/keel/CMakeLists.txt
Normal file
19
src/nostalgia/modules/sound/src/keel/CMakeLists.txt
Normal file
@ -0,0 +1,19 @@
|
||||
add_library(
|
||||
NostalgiaSound-Keel
|
||||
keelmodule.cpp
|
||||
typeconv.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
NostalgiaSound-Keel PUBLIC
|
||||
Keel
|
||||
NostalgiaSound
|
||||
)
|
||||
|
||||
install(
|
||||
TARGETS
|
||||
NostalgiaSound-Keel
|
||||
DESTINATION
|
||||
LIBRARY DESTINATION lib
|
||||
ARCHIVE DESTINATION lib
|
||||
)
|
46
src/nostalgia/modules/sound/src/keel/keelmodule.cpp
Normal file
46
src/nostalgia/modules/sound/src/keel/keelmodule.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#include <ox/model/model.hpp>
|
||||
|
||||
#include <keel/module.hpp>
|
||||
|
||||
#include "typeconv.hpp"
|
||||
|
||||
namespace nostalgia::sound {
|
||||
|
||||
static class: public keel::Module {
|
||||
private:
|
||||
|
||||
public:
|
||||
[[nodiscard]]
|
||||
ox::String id() const noexcept override {
|
||||
return ox::String{"net.drinkingtea.nostalgia.sound"};
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
ox::Vector<keel::TypeDescGenerator> types() const noexcept final {
|
||||
return {
|
||||
};
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
ox::Vector<keel::BaseConverter const*> converters() const noexcept final {
|
||||
return {
|
||||
};
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
ox::Vector<keel::PackTransform> packTransforms() const noexcept final {
|
||||
return {
|
||||
};
|
||||
}
|
||||
|
||||
} const mod;
|
||||
|
||||
keel::Module const*keelModule() noexcept {
|
||||
return &mod;
|
||||
}
|
||||
|
||||
}
|
@ -2,10 +2,8 @@
|
||||
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#include <nostalgia/scene/scenestatic.hpp>
|
||||
|
||||
namespace nostalgia::scene {
|
||||
|
||||
#include "typeconv.hpp"
|
||||
|
||||
namespace nostalgia::sound {
|
||||
|
||||
}
|
15
src/nostalgia/modules/sound/src/keel/typeconv.hpp
Normal file
15
src/nostalgia/modules/sound/src/keel/typeconv.hpp
Normal file
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ox/std/def.hpp>
|
||||
|
||||
#include <keel/typeconv.hpp>
|
||||
|
||||
namespace nostalgia::sound {
|
||||
|
||||
// Type converters
|
||||
|
||||
}
|
6
src/nostalgia/modules/sound/src/sound.cpp
Normal file
6
src/nostalgia/modules/sound/src/sound.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
/*
|
||||
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
namespace nostalgia::sound {
|
||||
}
|
17
src/nostalgia/modules/sound/src/studio/CMakeLists.txt
Normal file
17
src/nostalgia/modules/sound/src/studio/CMakeLists.txt
Normal file
@ -0,0 +1,17 @@
|
||||
add_library(
|
||||
NostalgiaSound-Studio-ImGui
|
||||
studiomodule.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
NostalgiaSound-Studio-ImGui PUBLIC
|
||||
NostalgiaSound
|
||||
Studio
|
||||
)
|
||||
|
||||
install(
|
||||
TARGETS
|
||||
NostalgiaSound-Studio-ImGui
|
||||
LIBRARY DESTINATION
|
||||
${NOSTALGIA_DIST_MODULE}
|
||||
)
|
27
src/nostalgia/modules/sound/src/studio/studiomodule.cpp
Normal file
27
src/nostalgia/modules/sound/src/studio/studiomodule.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#include <ox/std/memory.hpp>
|
||||
|
||||
#include <studio/studio.hpp>
|
||||
|
||||
namespace nostalgia::sound {
|
||||
|
||||
static class: public studio::Module {
|
||||
ox::Vector<studio::EditorMaker> editors(studio::StudioContext&) const noexcept final {
|
||||
return {
|
||||
};
|
||||
}
|
||||
|
||||
ox::Vector<ox::UPtr<studio::ItemMaker>> itemMakers(studio::StudioContext&) const noexcept final {
|
||||
ox::Vector<ox::UniquePtr<studio::ItemMaker>> out;
|
||||
return out;
|
||||
}
|
||||
} const mod;
|
||||
|
||||
const studio::Module *studioModule() noexcept {
|
||||
return &mod;
|
||||
}
|
||||
|
||||
}
|
10
src/nostalgia/modules/sound/test/CMakeLists.txt
Normal file
10
src/nostalgia/modules/sound/test/CMakeLists.txt
Normal file
@ -0,0 +1,10 @@
|
||||
add_executable(
|
||||
NostalgiaSoundTest
|
||||
tests.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
NostalgiaSoundTest
|
||||
NostalgiaSound
|
||||
)
|
||||
|
26
src/nostalgia/modules/sound/test/tests.cpp
Normal file
26
src/nostalgia/modules/sound/test/tests.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#undef NDEBUG
|
||||
|
||||
#include <map>
|
||||
#include <ox/std/error.hpp>
|
||||
#include <ox/mc/mc.hpp>
|
||||
|
||||
static std::map<ox::StringView, ox::Error(*)()> tests = {
|
||||
};
|
||||
|
||||
int main(int argc, const char **argv) {
|
||||
int retval = -1;
|
||||
if (argc > 0) {
|
||||
auto const args = ox::Span{argv, static_cast<size_t>(argc)};
|
||||
auto const testName = ox::StringView(args[1]);
|
||||
if (tests.find(testName) != tests.end()) {
|
||||
retval = static_cast<int>(tests[testName]());
|
||||
} else {
|
||||
retval = 1;
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
@ -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,44 +125,13 @@ 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) {
|
||||
constexpr ox::StringView SceneAddr{"/Scenes/Chester.nscn"};
|
||||
OX_REQUIRE_M(cctx, gfx::init(tctx));
|
||||
OX_REQUIRE(scn, keel::readObj<scene::SceneStatic>(keelCtx(tctx), SceneAddr));
|
||||
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.");
|
||||
return ox::Error{1, "Please provide path to project directory or OxFS file."};
|
||||
}
|
||||
auto const path = args[1];
|
||||
OX_REQUIRE_M(fs, keel::loadRomFs(path));
|
||||
|
@ -11,7 +11,7 @@ target_link_libraries(
|
||||
|
||||
target_compile_definitions(
|
||||
NostalgiaStudio PUBLIC
|
||||
OLYMPIC_APP_VERSION="dev build"
|
||||
OLYMPIC_APP_VERSION="d2025.02.0"
|
||||
)
|
||||
|
||||
install(
|
||||
@ -33,7 +33,7 @@ endif()
|
||||
|
||||
install(
|
||||
FILES
|
||||
ns.icns
|
||||
ns_logo.icns
|
||||
DESTINATION
|
||||
${NOSTALGIA_DIST_RESOURCES}/icons
|
||||
)
|
||||
|
@ -9,7 +9,7 @@
|
||||
<string>Nostalgia Studio</string>
|
||||
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>icons/ns.icns</string>
|
||||
<string>icons/ns_logo.icns</string>
|
||||
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>net.drinkingtea.nostalgia.studio</string>
|
||||
@ -18,7 +18,7 @@
|
||||
<string>APPL</string>
|
||||
|
||||
<key>CFBundleVersion</key>
|
||||
<string>0.0.0</string>
|
||||
<string>d2025.02.0</string>
|
||||
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>12.0.0</string>
|
||||
@ -30,6 +30,6 @@
|
||||
<string>True</string>
|
||||
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright (c) 2016-2023 Gary Talent <gary@drinkingtea.net></string>
|
||||
<string>Copyright (c) 2016-2025 Gary Talent <gary@drinkingtea.net></string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
BIN
src/nostalgia/studio/ns_logo.icns
Normal file
BIN
src/nostalgia/studio/ns_logo.icns
Normal file
Binary file not shown.
@ -64,12 +64,16 @@ ox::Result<ox::CStringView> uuidToPath(Context &ctx, ox::UUID const&uuid) noexce
|
||||
namespace detail {
|
||||
template<typename T>
|
||||
constexpr auto makeLoader(Context &ctx) {
|
||||
return [&ctx](ox::StringViewCR assetId) -> ox::Result<T> {
|
||||
auto const p = ctx.uuidToPath.at(assetId);
|
||||
if (p.error) {
|
||||
return ox::Error{1, "Asset ID not found"};
|
||||
return [&ctx](ox::StringView assetId) -> ox::Result<T> {
|
||||
if (!beginsWith(assetId, "/")) {
|
||||
auto const p = ctx.uuidToPath.at(assetId);
|
||||
if (p.error) {
|
||||
oxErrf("Could not find asset: {}", assetId);
|
||||
return ox::Error{1, "Asset ID not found"};
|
||||
}
|
||||
assetId = *p.value;
|
||||
}
|
||||
OX_REQUIRE(buff, ctx.rom->read(*p.value));
|
||||
OX_REQUIRE(buff, ctx.rom->read(assetId));
|
||||
auto [obj, err] = readAsset<T>(buff);
|
||||
if (err) {
|
||||
if (err != ox::Error_ClawTypeVersionMismatch && err != ox::Error_ClawTypeMismatch) {
|
||||
|
@ -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 {
|
||||
|
@ -13,6 +13,7 @@ ox::Error MakeCopyPopup::open(ox::StringViewCR path) noexcept {
|
||||
m_dirPath = substr(path, 0, idx + 1);
|
||||
m_title = sfmt("Copy {}", path);
|
||||
m_fileName = "";
|
||||
m_errMsg = "";
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -25,7 +26,7 @@ bool MakeCopyPopup::isOpen() const noexcept {
|
||||
return m_open;
|
||||
}
|
||||
|
||||
void MakeCopyPopup::draw(StudioContext const &ctx, ImVec2 const &sz) noexcept {
|
||||
void MakeCopyPopup::draw(StudioContext const &ctx) noexcept {
|
||||
switch (m_stage) {
|
||||
case Stage::Closed:
|
||||
break;
|
||||
@ -36,25 +37,26 @@ void MakeCopyPopup::draw(StudioContext const &ctx, ImVec2 const &sz) noexcept {
|
||||
[[fallthrough]];
|
||||
case Stage::Open:
|
||||
ig::centerNextWindow(ctx.tctx);
|
||||
ImGui::SetNextWindowSize(sz);
|
||||
constexpr auto modalFlags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize;
|
||||
ImGui::SetNextWindowSize({250, 0});
|
||||
constexpr auto modalFlags =
|
||||
ImGuiWindowFlags_NoCollapse |
|
||||
ImGuiWindowFlags_NoMove |
|
||||
ImGuiWindowFlags_NoResize;
|
||||
if (ImGui::BeginPopupModal(m_title.c_str(), &m_open, modalFlags)) {
|
||||
if (ImGui::IsWindowAppearing()) {
|
||||
ImGui::SetKeyboardFocusHere();
|
||||
}
|
||||
ig::InputText("Name", m_fileName);
|
||||
if (ImGui::IsItemFocused() && ImGui::IsKeyPressed(ImGuiKey_Enter)) {
|
||||
accept(ctx);
|
||||
}
|
||||
ImGui::Text("%s", m_errMsg.c_str());
|
||||
bool open = true;
|
||||
switch (ig::PopupControlsOkCancel(open)) {
|
||||
case ig::PopupResponse::None:
|
||||
break;
|
||||
case ig::PopupResponse::OK:
|
||||
{
|
||||
auto const p = sfmt("{}{}", m_dirPath, m_fileName);
|
||||
if (!ctx.project->exists(p)) {
|
||||
makeCopy.emit(m_srcPath, p);
|
||||
close();
|
||||
}
|
||||
}
|
||||
accept(ctx);
|
||||
break;
|
||||
case ig::PopupResponse::Cancel:
|
||||
close();
|
||||
@ -66,5 +68,14 @@ void MakeCopyPopup::draw(StudioContext const &ctx, ImVec2 const &sz) noexcept {
|
||||
}
|
||||
}
|
||||
|
||||
void MakeCopyPopup::accept(StudioContext const &ctx) noexcept {
|
||||
auto const p = sfmt("{}{}", m_dirPath, m_fileName);
|
||||
if (!ctx.project->exists(p)) {
|
||||
makeCopy.emit(m_srcPath, p);
|
||||
close();
|
||||
} else {
|
||||
m_errMsg = sfmt("{} already exists", p);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ class MakeCopyPopup {
|
||||
};
|
||||
Stage m_stage = Stage::Closed;
|
||||
bool m_open{};
|
||||
ox::String m_errMsg;
|
||||
ox::String m_title{"Copy File"};
|
||||
ox::String m_srcPath;
|
||||
ox::String m_dirPath;
|
||||
@ -35,8 +36,10 @@ class MakeCopyPopup {
|
||||
[[nodiscard]]
|
||||
bool isOpen() const noexcept;
|
||||
|
||||
void draw(StudioContext const &ctx, ImVec2 const &sz = {}) noexcept;
|
||||
void draw(StudioContext const &ctx) noexcept;
|
||||
|
||||
private:
|
||||
void accept(StudioContext const &ctx) noexcept;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -14,10 +14,14 @@
|
||||
#include <studio/configio.hpp>
|
||||
#include "clawviewer.hpp"
|
||||
#include "filedialogmanager.hpp"
|
||||
#include "studioapp.hpp"
|
||||
#include "studioui.hpp"
|
||||
|
||||
namespace studio {
|
||||
|
||||
void navigateTo(StudioContext &ctx, ox::StringParam filePath, ox::StringParam navArgs) noexcept {
|
||||
ctx.ui.navigateTo(std::move(filePath), std::move(navArgs));
|
||||
}
|
||||
|
||||
namespace ig {
|
||||
extern bool s_mainWinHasFocus;
|
||||
}
|
||||
@ -107,6 +111,10 @@ void StudioUI::handleKeyEvent(turbine::Key const key, bool const down) noexcept
|
||||
}
|
||||
}
|
||||
|
||||
void StudioUI::navigateTo(ox::StringParam path, ox::StringParam navArgs) noexcept {
|
||||
m_navAction.emplace(std::move(path), std::move(navArgs));
|
||||
}
|
||||
|
||||
void StudioUI::draw() noexcept {
|
||||
glutils::clearScreen();
|
||||
drawMenu();
|
||||
@ -137,7 +145,7 @@ void StudioUI::draw() noexcept {
|
||||
p->draw(m_sctx);
|
||||
}
|
||||
m_closeFileConfirm.draw(m_sctx);
|
||||
m_copyFilePopup.draw(m_sctx, {250, 0});
|
||||
m_copyFilePopup.draw(m_sctx);
|
||||
}
|
||||
ImGui::End();
|
||||
handleKeyInput();
|
||||
@ -148,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")) {
|
||||
@ -277,6 +285,11 @@ void StudioUI::drawTabs() noexcept {
|
||||
}
|
||||
m_closeActiveTab = false;
|
||||
}
|
||||
if (m_navAction) {
|
||||
oxLogError(openFile(m_navAction->path));
|
||||
m_activeEditor->navigateTo(m_navAction->args);
|
||||
m_navAction.reset();
|
||||
}
|
||||
}
|
||||
|
||||
void StudioUI::loadEditorMaker(EditorMaker const&editorMaker) noexcept {
|
@ -62,12 +62,19 @@ class StudioUI: public ox::SignalHandler {
|
||||
&m_renameFile,
|
||||
};
|
||||
bool m_showProjectExplorer = true;
|
||||
struct NavAction {
|
||||
ox::String path;
|
||||
ox::String args;
|
||||
};
|
||||
ox::Optional<NavAction> m_navAction;
|
||||
|
||||
public:
|
||||
explicit StudioUI(turbine::Context &ctx, ox::StringParam projectDataDir) noexcept;
|
||||
|
||||
void handleKeyEvent(turbine::Key, bool down) noexcept;
|
||||
|
||||
void navigateTo(ox::StringParam path, ox::StringParam navArgs) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr Project *project() noexcept {
|
||||
return m_project.get();
|
@ -27,4 +27,6 @@ inline keel::Context &keelCtx(StudioContext &ctx) noexcept {
|
||||
return keelCtx(ctx.tctx);
|
||||
}
|
||||
|
||||
void navigateTo(StudioContext &ctx, ox::StringParam filePath, ox::StringParam navArgs) noexcept;
|
||||
|
||||
}
|
||||
|
@ -99,6 +99,8 @@ class BaseEditor: public Widget {
|
||||
[[nodiscard]]
|
||||
virtual UndoStack *undoStack() noexcept;
|
||||
|
||||
virtual void navigateTo(ox::StringViewCR arg) noexcept;
|
||||
|
||||
void setRequiresConstantRefresh(bool value) noexcept;
|
||||
|
||||
// signals
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <studio/dragdrop.hpp>
|
||||
#include <studio/editor.hpp>
|
||||
#include <studio/filedialog.hpp>
|
||||
#include <studio/filepickerpopup.hpp>
|
||||
#include <studio/filetreemodel.hpp>
|
||||
#include <studio/imguiutil.hpp>
|
||||
#include <studio/module.hpp>
|
||||
|
@ -44,5 +44,5 @@ install(
|
||||
DIRECTORY
|
||||
../include/studio
|
||||
DESTINATION
|
||||
include/studio/
|
||||
include/studio
|
||||
)
|
||||
|
@ -106,6 +106,8 @@ UndoStack *BaseEditor::undoStack() noexcept {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void BaseEditor::navigateTo(ox::StringViewCR) noexcept {}
|
||||
|
||||
|
||||
Editor::Editor(StudioContext &ctx, ox::StringParam itemPath) noexcept:
|
||||
m_itemPath(std::move(itemPath)),
|
||||
|
@ -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"};
|
||||
|
@ -7,9 +7,7 @@
|
||||
namespace studio {
|
||||
|
||||
ox::Error UndoStack::push(ox::UPtr<UndoCommand> &&cmd) noexcept {
|
||||
for (auto const i = m_stackIdx; i < m_stack.size();) {
|
||||
std::ignore = m_stack.erase(i);
|
||||
}
|
||||
m_stack.resize(m_stackIdx);
|
||||
OX_RETURN_ERROR(cmd->redo());
|
||||
redoTriggered.emit(cmd.get());
|
||||
changeTriggered.emit(cmd.get());
|
||||
@ -25,22 +23,29 @@ ox::Error UndoStack::push(ox::UPtr<UndoCommand> &&cmd) noexcept {
|
||||
}
|
||||
|
||||
ox::Error UndoStack::redo() noexcept {
|
||||
if (m_stackIdx < m_stack.size()) {
|
||||
auto &c = m_stack[m_stackIdx];
|
||||
OX_RETURN_ERROR(c->redo());
|
||||
while (m_stackIdx < m_stack.size()) {
|
||||
auto const &c = m_stack[m_stackIdx];
|
||||
++m_stackIdx;
|
||||
redoTriggered.emit(c.get());
|
||||
changeTriggered.emit(c.get());
|
||||
if (!c->isObsolete()) {
|
||||
OX_RETURN_ERROR(c->redo());
|
||||
redoTriggered.emit(c.get());
|
||||
changeTriggered.emit(c.get());
|
||||
break;
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
ox::Error UndoStack::undo() noexcept {
|
||||
if (m_stackIdx) {
|
||||
auto &c = m_stack[--m_stackIdx];
|
||||
OX_RETURN_ERROR(c->undo());
|
||||
undoTriggered.emit(c.get());
|
||||
changeTriggered.emit(c.get());
|
||||
while (m_stackIdx) {
|
||||
--m_stackIdx;
|
||||
auto const &c = m_stack[m_stackIdx];
|
||||
if (!c->isObsolete()) {
|
||||
OX_RETURN_ERROR(c->undo());
|
||||
undoTriggered.emit(c.get());
|
||||
changeTriggered.emit(c.get());
|
||||
break;
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
Reference in New Issue
Block a user