Compare commits
47 Commits
release-d2
...
b8d7658626
| Author | SHA1 | Date | |
|---|---|---|---|
| b8d7658626 | |||
| 2503bb3b2c | |||
| e5dd448fe7 | |||
| 4770bb6a93 | |||
| c0bac696dc | |||
| 95f7c33419 | |||
| 535d8876d3 | |||
| 845e433221 | |||
| 5169a607cf | |||
| 8f03af99a7 | |||
| ee63a4a1e4 | |||
| 89ae226b1d | |||
| 477834ac04 | |||
| 97b707b61c | |||
| e86180e842 | |||
| 035ba8810f | |||
| f1c2113dd3 | |||
| 56b79f414d | |||
| 844656d557 | |||
| 849aceb86d | |||
| c84b85102c | |||
| 3fe62464c3 | |||
| db55fc722f | |||
| 2094450898 | |||
| 889bec04b1 | |||
| ac1e34d4cd | |||
| 55ed75f44d | |||
| 2751872c59 | |||
| 2a3cd35cc4 | |||
| b66f459f75 | |||
| 3910f4e77c | |||
| c0e96216ae | |||
| f9512d72e8 | |||
| b7f2c169ec | |||
| 1e5057d6e6 | |||
| c6255e3224 | |||
| 02230ef619 | |||
| 9b6b60e4d1 | |||
| b9a26ab61e | |||
| a521887ddd | |||
| 5ca7e2f226 | |||
| 125a235dd1 | |||
| 91a7129f8f | |||
| df48a232ec | |||
| ab11b885e6 | |||
| 36fc25fb7e | |||
| 4803cca334 |
11
Makefile
@@ -15,7 +15,12 @@ PROJECT_PLAYER=./build/${BC_VAR_CURRENT_BUILD}/bin/${BC_VAR_PROJECT_NAME_CAP}
|
||||
|
||||
.PHONY: pkg-gba
|
||||
pkg-gba: build
|
||||
${BC_CMD_ENVRUN} ${BC_PY3} ./util/scripts/pkg-gba.py sample_project ${BC_VAR_PROJECT_NAME}
|
||||
${BC_CMD_ENVRUN} ${BC_PY3} ./util/scripts/pkg-gba.py sample_project ${BC_VAR_PROJECT_NAME_CAP}
|
||||
|
||||
.PHONY: generate-studio-rsrc
|
||||
generate-studio-rsrc:
|
||||
${BC_CMD_ENVRUN} ${BC_PY3} ./util/scripts/file-to-cpp.py --rsrc src/olympic/studio/applib/src/rsrc.json
|
||||
${BC_CMD_ENVRUN} ${BC_PY3} ./util/scripts/file-to-cpp.py --rsrc src/nostalgia/studio/rsrc.json
|
||||
|
||||
.PHONY: build-player
|
||||
build-player:
|
||||
@@ -28,10 +33,10 @@ run-studio: build
|
||||
${PROJECT_STUDIO}
|
||||
.PHONY: gba-run
|
||||
gba-run: pkg-gba
|
||||
${MGBA} ${BC_VAR_PROJECT_NAME}.gba
|
||||
${MGBA} ${BC_VAR_PROJECT_NAME_CAP}.gba
|
||||
.PHONY: debug
|
||||
debug: build
|
||||
${BC_CMD_HOST_DEBUGGER} ./build/${BC_VAR_CURRENT_BUILD}/bin/${BC_VAR_PROJECT_NAME} sample_project
|
||||
${BC_CMD_HOST_DEBUGGER} ${PROJECT_PLAYER} sample_project
|
||||
.PHONY: debug-studio
|
||||
debug-studio: build
|
||||
${BC_CMD_HOST_DEBUGGER} ${PROJECT_STUDIO}
|
||||
|
||||
@@ -433,14 +433,14 @@ Error FileStoreTemplate<size_t>::resize() {
|
||||
template<typename size_t>
|
||||
Error FileStoreTemplate<size_t>::resize(std::size_t size, void *newBuff) {
|
||||
if (m_buffer->size() > size) {
|
||||
return ox::Error(1);
|
||||
return ox::Error{1, "new buffer is too small for existing data"};
|
||||
}
|
||||
m_buffSize = static_cast<size_t>(size);
|
||||
if (newBuff) {
|
||||
m_buffer = reinterpret_cast<Buffer*>(newBuff);
|
||||
m_buffer = static_cast<Buffer*>(newBuff);
|
||||
OX_RETURN_ERROR(m_buffer->setSize(static_cast<size_t>(size)));
|
||||
}
|
||||
return ox::Error(0);
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename size_t>
|
||||
|
||||
27
deps/ox/src/ox/fs/filesystem/filesystem.hpp
vendored
@@ -20,7 +20,7 @@
|
||||
namespace ox {
|
||||
|
||||
namespace detail {
|
||||
static inline void fsBuffFree(char *buff) noexcept {
|
||||
inline void fsBuffFree(char *buff) noexcept {
|
||||
safeDelete(buff);
|
||||
}
|
||||
}
|
||||
@@ -49,11 +49,11 @@ class FileSystem {
|
||||
|
||||
Result<Buffer> read(StringViewCR path) noexcept;
|
||||
|
||||
inline Error read(StringViewCR path, void *buffer, std::size_t buffSize) noexcept {
|
||||
Error read(StringViewCR path, void *buffer, std::size_t buffSize) noexcept {
|
||||
return readFilePath(path, buffer, buffSize);
|
||||
}
|
||||
|
||||
inline Error read(uint64_t inode, void *buffer, std::size_t buffSize) noexcept {
|
||||
Error read(uint64_t inode, void *buffer, std::size_t buffSize) noexcept {
|
||||
return readFileInode(inode, buffer, buffSize);
|
||||
}
|
||||
|
||||
@@ -69,8 +69,7 @@ class FileSystem {
|
||||
* @param path
|
||||
* @param readStart
|
||||
* @param readSize
|
||||
* @param buffer
|
||||
* @param size
|
||||
* @param buff
|
||||
* @return error or number of bytes read
|
||||
*/
|
||||
Result<size_t> read(
|
||||
@@ -102,36 +101,36 @@ class FileSystem {
|
||||
|
||||
Error write(const FileAddress &addr, const void *buffer, uint64_t size, FileType fileType = FileType::NormalFile) noexcept;
|
||||
|
||||
inline Error write(StringViewCR path, const void *buffer, uint64_t size, FileType fileType) noexcept {
|
||||
Error write(StringViewCR path, const void *buffer, uint64_t size, FileType fileType) noexcept {
|
||||
return writeFilePath(path, buffer, size, fileType);
|
||||
}
|
||||
|
||||
inline Error write(uint64_t inode, const void *buffer, uint64_t size, FileType fileType) noexcept {
|
||||
Error write(uint64_t inode, const void *buffer, uint64_t size, FileType fileType) noexcept {
|
||||
return writeFileInode(inode, buffer, size, fileType);
|
||||
}
|
||||
|
||||
inline Result<FileStat> stat(uint64_t inode) const noexcept {
|
||||
Result<FileStat> stat(uint64_t inode) const noexcept {
|
||||
return statInode(inode);
|
||||
}
|
||||
|
||||
inline Result<FileStat> stat(StringViewCR path) const noexcept {
|
||||
Result<FileStat> stat(StringViewCR path) const noexcept {
|
||||
return statPath(path);
|
||||
}
|
||||
|
||||
Result<FileStat> stat(const FileAddress &addr) const noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
inline bool exists(uint64_t inode) const noexcept {
|
||||
bool exists(uint64_t inode) const noexcept {
|
||||
return statInode(inode).ok();
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
inline bool exists(ox::StringView path) const noexcept {
|
||||
bool exists(ox::StringView path) const noexcept {
|
||||
return statPath(path).ok();
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
inline bool exists(FileAddress const&addr) const noexcept {
|
||||
bool exists(FileAddress const&addr) const noexcept {
|
||||
return stat(addr).ok();
|
||||
}
|
||||
|
||||
@@ -178,11 +177,11 @@ class MemFS: public FileSystem {
|
||||
public:
|
||||
Result<const char*> directAccess(const FileAddress &addr) const noexcept;
|
||||
|
||||
inline Result<const char*> directAccess(StringViewCR path) const noexcept {
|
||||
Result<const char*> directAccess(StringViewCR path) const noexcept {
|
||||
return directAccessPath(path);
|
||||
}
|
||||
|
||||
inline Result<const char*> directAccess(uint64_t inode) const noexcept {
|
||||
Result<const char*> directAccess(uint64_t inode) const noexcept {
|
||||
return directAccessInode(inode);
|
||||
}
|
||||
|
||||
|
||||
5
project/.nostalgia/type_descriptors/B.int32;0
Normal file
@@ -0,0 +1,5 @@
|
||||
O1;net.drinkingtea.ox.TypeDescriptor;1;{
|
||||
"length" : 4,
|
||||
"primitiveType" : 1,
|
||||
"typeName" : "B.int32"
|
||||
}
|
||||
5
project/.nostalgia/type_descriptors/B.int8;0
Normal file
@@ -0,0 +1,5 @@
|
||||
O1;net.drinkingtea.ox.TypeDescriptor;1;{
|
||||
"length" : 1,
|
||||
"primitiveType" : 1,
|
||||
"typeName" : "B.int8"
|
||||
}
|
||||
4
project/.nostalgia/type_descriptors/B.string;0
Normal file
@@ -0,0 +1,4 @@
|
||||
O1;net.drinkingtea.ox.TypeDescriptor;1;{
|
||||
"primitiveType" : 4,
|
||||
"typeName" : "B.string"
|
||||
}
|
||||
4
project/.nostalgia/type_descriptors/B.uint16;0
Normal file
@@ -0,0 +1,4 @@
|
||||
O1;net.drinkingtea.ox.TypeDescriptor;1;{
|
||||
"length" : 2,
|
||||
"typeName" : "B.uint16"
|
||||
}
|
||||
4
project/.nostalgia/type_descriptors/B.uint64;0
Normal file
@@ -0,0 +1,4 @@
|
||||
O1;net.drinkingtea.ox.TypeDescriptor;1;{
|
||||
"length" : 8,
|
||||
"typeName" : "B.uint64"
|
||||
}
|
||||
4
project/.nostalgia/type_descriptors/B.uint8;0
Normal file
@@ -0,0 +1,4 @@
|
||||
O1;net.drinkingtea.ox.TypeDescriptor;1;{
|
||||
"length" : 1,
|
||||
"typeName" : "B.uint8"
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
O1;net.drinkingtea.ox.TypeDescriptor;1;{
|
||||
"fieldList" :
|
||||
[
|
||||
{
|
||||
"fieldName" : "bpp",
|
||||
"typeId" : "B.int8;0"
|
||||
},
|
||||
{
|
||||
"fieldName" : "rows",
|
||||
"typeId" : "B.int32;0"
|
||||
},
|
||||
{
|
||||
"fieldName" : "columns",
|
||||
"typeId" : "B.int32;0"
|
||||
},
|
||||
{
|
||||
"fieldName" : "defaultPalette",
|
||||
"typeId" : "net.drinkingtea.ox.FileAddress;1"
|
||||
},
|
||||
{
|
||||
"fieldName" : "pal",
|
||||
"typeId" : "net.drinkingtea.nostalgia.core.Palette;1"
|
||||
},
|
||||
{
|
||||
"fieldName" : "pixels",
|
||||
"subscriptLevels" : 1,
|
||||
"subscriptStack" :
|
||||
[
|
||||
{
|
||||
"subscriptType" : 4
|
||||
}
|
||||
],
|
||||
"typeId" : "B.uint8;0"
|
||||
}
|
||||
],
|
||||
"primitiveType" : 5,
|
||||
"typeName" : "net.drinkingtea.nostalgia.core.NostalgiaGraphic",
|
||||
"typeVersion" : 1
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
O1;net.drinkingtea.ox.TypeDescriptor;1;{
|
||||
"fieldList" :
|
||||
[
|
||||
{
|
||||
"fieldName" : "name",
|
||||
"typeId" : "net.drinkingtea.ox.BasicString#8#;1"
|
||||
}
|
||||
],
|
||||
"primitiveType" : 5,
|
||||
"typeName" : "net.drinkingtea.nostalgia.core.Palette.ColorInfo",
|
||||
"typeVersion" : 3
|
||||
}
|
||||
@@ -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.core.PaletteColor;1"
|
||||
}
|
||||
],
|
||||
"primitiveType" : 5,
|
||||
"typeName" : "net.drinkingtea.nostalgia.core.Palette.PalettePage",
|
||||
"typeVersion" : 1
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
O1;net.drinkingtea.ox.TypeDescriptor;1;{
|
||||
"fieldList" :
|
||||
[
|
||||
{
|
||||
"fieldName" : "colors",
|
||||
"subscriptLevels" : 1,
|
||||
"subscriptStack" :
|
||||
[
|
||||
{
|
||||
"subscriptType" : 4
|
||||
}
|
||||
],
|
||||
"typeId" : "B.uint16;0"
|
||||
}
|
||||
],
|
||||
"primitiveType" : 5,
|
||||
"typeName" : "net.drinkingtea.nostalgia.core.Palette",
|
||||
"typeVersion" : 1
|
||||
}
|
||||
@@ -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.core.Palette",
|
||||
"typeVersion" : 2
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
O1;net.drinkingtea.ox.TypeDescriptor;1;{
|
||||
"fieldList" :
|
||||
[
|
||||
{
|
||||
"fieldName" : "colorInfo",
|
||||
"subscriptLevels" : 1,
|
||||
"subscriptStack" :
|
||||
[
|
||||
{
|
||||
"subscriptType" : 4
|
||||
}
|
||||
],
|
||||
"typeId" : "net.drinkingtea.nostalgia.core.Palette.ColorInfo;3"
|
||||
},
|
||||
{
|
||||
"fieldName" : "pages",
|
||||
"subscriptLevels" : 2,
|
||||
"subscriptStack" :
|
||||
[
|
||||
{
|
||||
"subscriptType" : 4
|
||||
},
|
||||
{
|
||||
"subscriptType" : 4
|
||||
}
|
||||
],
|
||||
"typeId" : "B.uint16;0"
|
||||
}
|
||||
],
|
||||
"preloadable" : true,
|
||||
"primitiveType" : 5,
|
||||
"typeName" : "net.drinkingtea.nostalgia.core.Palette",
|
||||
"typeVersion" : 3
|
||||
}
|
||||
@@ -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.core.Palette.PalettePage;1"
|
||||
}
|
||||
],
|
||||
"preloadable" : true,
|
||||
"primitiveType" : 5,
|
||||
"typeName" : "net.drinkingtea.nostalgia.core.Palette",
|
||||
"typeVersion" : 4
|
||||
}
|
||||
@@ -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.core.PaletteColor",
|
||||
"typeVersion" : 1
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
O1;net.drinkingtea.ox.TypeDescriptor;1;{
|
||||
"fieldList" :
|
||||
[
|
||||
{
|
||||
"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.core.TileSheet.SubSheet;1"
|
||||
},
|
||||
{
|
||||
"fieldName" : "pixels",
|
||||
"subscriptLevels" : 1,
|
||||
"subscriptStack" :
|
||||
[
|
||||
{
|
||||
"subscriptType" : 4
|
||||
}
|
||||
],
|
||||
"typeId" : "B.uint8;0"
|
||||
}
|
||||
],
|
||||
"primitiveType" : 5,
|
||||
"typeName" : "net.drinkingtea.nostalgia.core.TileSheet.SubSheet",
|
||||
"typeVersion" : 1
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
O1;net.drinkingtea.ox.TypeDescriptor;1;{
|
||||
"fieldList" :
|
||||
[
|
||||
{
|
||||
"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.core.TileSheet.SubSheet;3"
|
||||
},
|
||||
{
|
||||
"fieldName" : "pixels",
|
||||
"subscriptLevels" : 1,
|
||||
"subscriptStack" :
|
||||
[
|
||||
{
|
||||
"subscriptType" : 4
|
||||
}
|
||||
],
|
||||
"typeId" : "B.uint8;0"
|
||||
}
|
||||
],
|
||||
"primitiveType" : 5,
|
||||
"typeName" : "net.drinkingtea.nostalgia.core.TileSheet.SubSheet",
|
||||
"typeVersion" : 3
|
||||
}
|
||||
@@ -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.core.TileSheet.SubSheet;4"
|
||||
},
|
||||
{
|
||||
"fieldName" : "pixels",
|
||||
"subscriptLevels" : 1,
|
||||
"subscriptStack" :
|
||||
[
|
||||
{
|
||||
"subscriptType" : 4
|
||||
}
|
||||
],
|
||||
"typeId" : "B.uint8;0"
|
||||
}
|
||||
],
|
||||
"primitiveType" : 5,
|
||||
"typeName" : "net.drinkingtea.nostalgia.core.TileSheet.SubSheet",
|
||||
"typeVersion" : 4
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
O1;net.drinkingtea.ox.TypeDescriptor;1;{
|
||||
"fieldList" :
|
||||
[
|
||||
{
|
||||
"fieldName" : "bpp",
|
||||
"typeId" : "B.int8;0"
|
||||
},
|
||||
{
|
||||
"fieldName" : "defaultPalette",
|
||||
"typeId" : "net.drinkingtea.ox.FileAddress;1"
|
||||
},
|
||||
{
|
||||
"fieldName" : "subsheet",
|
||||
"typeId" : "net.drinkingtea.nostalgia.core.TileSheet.SubSheet;1"
|
||||
}
|
||||
],
|
||||
"primitiveType" : 5,
|
||||
"typeName" : "net.drinkingtea.nostalgia.core.TileSheet",
|
||||
"typeVersion" : 2
|
||||
}
|
||||
@@ -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.FileAddress;1"
|
||||
},
|
||||
{
|
||||
"fieldName" : "subsheet",
|
||||
"typeId" : "net.drinkingtea.nostalgia.core.TileSheet.SubSheet;3"
|
||||
}
|
||||
],
|
||||
"primitiveType" : 5,
|
||||
"typeName" : "net.drinkingtea.nostalgia.core.TileSheet",
|
||||
"typeVersion" : 3
|
||||
}
|
||||
@@ -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.FileAddress;1"
|
||||
},
|
||||
{
|
||||
"fieldName" : "subsheet",
|
||||
"typeId" : "net.drinkingtea.nostalgia.core.TileSheet.SubSheet;4"
|
||||
}
|
||||
],
|
||||
"primitiveType" : 5,
|
||||
"typeName" : "net.drinkingtea.nostalgia.core.TileSheet",
|
||||
"typeVersion" : 4
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
O1;net.drinkingtea.ox.TypeDescriptor;1;{
|
||||
"fieldList" :
|
||||
[
|
||||
{
|
||||
"fieldName" : "tilesheet",
|
||||
"typeId" : "net.drinkingtea.ox.BasicString#8#;1"
|
||||
},
|
||||
{
|
||||
"fieldName" : "palettes",
|
||||
"subscriptLevels" : 1,
|
||||
"subscriptStack" :
|
||||
[
|
||||
{
|
||||
"subscriptType" : 4
|
||||
}
|
||||
],
|
||||
"typeId" : "net.drinkingtea.ox.BasicString#8#;1"
|
||||
},
|
||||
{
|
||||
"fieldName" : "tiles",
|
||||
"subscriptLevels" : 3,
|
||||
"subscriptStack" :
|
||||
[
|
||||
{
|
||||
"subscriptType" : 4
|
||||
},
|
||||
{
|
||||
"subscriptType" : 4
|
||||
},
|
||||
{
|
||||
"subscriptType" : 4
|
||||
}
|
||||
],
|
||||
"typeId" : "net.drinkingtea.nostalgia.scene.TileDoc;1"
|
||||
}
|
||||
],
|
||||
"preloadable" : true,
|
||||
"primitiveType" : 5,
|
||||
"typeName" : "net.drinkingtea.nostalgia.scene.SceneDoc",
|
||||
"typeVersion" : 1
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
O1;net.drinkingtea.ox.TypeDescriptor;1;{
|
||||
"fieldList" :
|
||||
[
|
||||
{
|
||||
"fieldName" : "tilesheet",
|
||||
"typeId" : "net.drinkingtea.ox.FileAddress;1"
|
||||
},
|
||||
{
|
||||
"fieldName" : "palettes",
|
||||
"subscriptLevels" : 1,
|
||||
"subscriptStack" :
|
||||
[
|
||||
{
|
||||
"subscriptType" : 4
|
||||
}
|
||||
],
|
||||
"typeId" : "net.drinkingtea.ox.FileAddress;1"
|
||||
},
|
||||
{
|
||||
"fieldName" : "columns",
|
||||
"subscriptLevels" : 1,
|
||||
"subscriptStack" :
|
||||
[
|
||||
{
|
||||
"subscriptType" : 4
|
||||
}
|
||||
],
|
||||
"typeId" : "B.uint16;0"
|
||||
},
|
||||
{
|
||||
"fieldName" : "rows",
|
||||
"subscriptLevels" : 1,
|
||||
"subscriptStack" :
|
||||
[
|
||||
{
|
||||
"subscriptType" : 4
|
||||
}
|
||||
],
|
||||
"typeId" : "B.uint16;0"
|
||||
},
|
||||
{
|
||||
"fieldName" : "tileMapIdx",
|
||||
"subscriptLevels" : 2,
|
||||
"subscriptStack" :
|
||||
[
|
||||
{
|
||||
"subscriptType" : 4
|
||||
},
|
||||
{
|
||||
"subscriptType" : 4
|
||||
}
|
||||
],
|
||||
"typeId" : "B.uint16;0"
|
||||
},
|
||||
{
|
||||
"fieldName" : "tileType",
|
||||
"subscriptLevels" : 2,
|
||||
"subscriptStack" :
|
||||
[
|
||||
{
|
||||
"subscriptType" : 4
|
||||
},
|
||||
{
|
||||
"subscriptType" : 4
|
||||
}
|
||||
],
|
||||
"typeId" : "B.uint8;0"
|
||||
},
|
||||
{
|
||||
"fieldName" : "layerAttachments",
|
||||
"subscriptLevels" : 2,
|
||||
"subscriptStack" :
|
||||
[
|
||||
{
|
||||
"subscriptType" : 4
|
||||
},
|
||||
{
|
||||
"subscriptType" : 4
|
||||
}
|
||||
],
|
||||
"typeId" : "B.uint8;0"
|
||||
}
|
||||
],
|
||||
"preloadable" : true,
|
||||
"primitiveType" : 5,
|
||||
"typeName" : "net.drinkingtea.nostalgia.scene.SceneStatic",
|
||||
"typeVersion" : 1
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
O1;net.drinkingtea.ox.TypeDescriptor;1;{
|
||||
"fieldList" :
|
||||
[
|
||||
{
|
||||
"fieldName" : "subsheet_id",
|
||||
"typeId" : "B.int32;0"
|
||||
},
|
||||
{
|
||||
"fieldName" : "subsheet_path",
|
||||
"typeId" : "net.drinkingtea.ox.BasicString#8#;1"
|
||||
},
|
||||
{
|
||||
"fieldName" : "type",
|
||||
"typeId" : "B.uint8;0"
|
||||
},
|
||||
{
|
||||
"fieldName" : "layer_attachments",
|
||||
"subscriptLevels" : 1,
|
||||
"subscriptStack" :
|
||||
[
|
||||
{
|
||||
"length" : 4,
|
||||
"subscriptType" : 3
|
||||
}
|
||||
],
|
||||
"typeId" : "B.uint8;0"
|
||||
}
|
||||
],
|
||||
"preloadable" : true,
|
||||
"primitiveType" : 5,
|
||||
"typeName" : "net.drinkingtea.nostalgia.scene.TileDoc",
|
||||
"typeVersion" : 1
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
O1;net.drinkingtea.ox.TypeDescriptor;1;{
|
||||
"primitiveType" : 4,
|
||||
"typeName" : "net.drinkingtea.ox.BasicString",
|
||||
"typeParams" :
|
||||
[
|
||||
"8"
|
||||
],
|
||||
"typeVersion" : 1
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
O1;net.drinkingtea.ox.TypeDescriptor;1;{
|
||||
"fieldList" :
|
||||
[
|
||||
{
|
||||
"fieldName" : "path",
|
||||
"typeId" : "B.string"
|
||||
},
|
||||
{
|
||||
"fieldName" : "constPath",
|
||||
"typeId" : "B.string"
|
||||
},
|
||||
{
|
||||
"fieldName" : "inode",
|
||||
"typeId" : "B.uint64;0"
|
||||
}
|
||||
],
|
||||
"primitiveType" : 6,
|
||||
"typeName" : "net.drinkingtea.ox.FileAddress.Data",
|
||||
"typeVersion" : 1
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
O1;net.drinkingtea.ox.TypeDescriptor;1;{
|
||||
"fieldList" :
|
||||
[
|
||||
{
|
||||
"fieldName" : "type",
|
||||
"typeId" : "B.int8;0"
|
||||
},
|
||||
{
|
||||
"fieldName" : "data",
|
||||
"typeId" : "net.drinkingtea.ox.FileAddress.Data"
|
||||
}
|
||||
],
|
||||
"primitiveType" : 5,
|
||||
"typeName" : "net.drinkingtea.ox.FileAddress",
|
||||
"typeVersion" : 1
|
||||
}
|
||||
@@ -1,4 +1,16 @@
|
||||
# d2025.02
|
||||
# d2025.04.0
|
||||
|
||||
* Add app icon for both window and file
|
||||
* Fix selection clearing in TileSheet editor to work when clicking outside
|
||||
image.
|
||||
* Fix color number key range in PalettEditor. Previously, pressing A caused the
|
||||
editor to jump to the last color.
|
||||
|
||||
# d2025.02.1
|
||||
|
||||
* Fix closing tab with unsaved changes (a44c5acc4b)
|
||||
|
||||
# d2025.02.0
|
||||
|
||||
* Rename core namespace to gfx.
|
||||
* Add PaletteV5 to accommodate namespace change.
|
||||
|
||||
269
sample_project/TileSheets/NS_Logo16.nts
Normal file
@@ -0,0 +1,269 @@
|
||||
K1;e7ae945e-d6c5-4444-5738-be95b4e5937a;O1;net.drinkingtea.nostalgia.gfx.TileSheet;5;{
|
||||
"bpp" : 4,
|
||||
"defaultPalette" : "uuid://c79f21e2-f74f-4ad9-90ed-32b0ef7da6ed",
|
||||
"subsheet" :
|
||||
{
|
||||
"columns" : 2,
|
||||
"name" : "Root",
|
||||
"pixels" :
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
3,
|
||||
3,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
2,
|
||||
3,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
3,
|
||||
2,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
3,
|
||||
3,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"rows" : 2
|
||||
}
|
||||
}
|
||||
1039
sample_project/TileSheets/NS_Logo32.nts
Normal file
@@ -14,19 +14,6 @@
|
||||
namespace nostalgia::gfx {
|
||||
|
||||
static class: public keel::Module {
|
||||
private:
|
||||
NostalgiaPaletteToPaletteV1Converter m_nostalgiaPaletteToPaletteV1Converter;
|
||||
PaletteV1ToPaletteV2Converter m_paletteV1ToPaletteV2Converter;
|
||||
PaletteV2ToPaletteV3Converter m_paletteV2ToPaletteV3Converter;
|
||||
PaletteV3ToPaletteV4Converter m_paletteV3ToPaletteV4Converter;
|
||||
PaletteV4ToPaletteV5Converter m_paletteV4ToPaletteV5Converter;
|
||||
PaletteToCompactPaletteConverter m_paletteToCompactPaletteConverter;
|
||||
TileSheetV1ToTileSheetV2Converter m_tileSheetV1ToTileSheetV2Converter;
|
||||
TileSheetV2ToTileSheetV3Converter m_tileSheetV2ToTileSheetV3Converter;
|
||||
TileSheetV3ToTileSheetV4Converter m_tileSheetV3ToTileSheetV4Converter;
|
||||
TileSheetV4ToTileSheetV5Converter m_tileSheetV4ToTileSheetV5Converter;
|
||||
TileSheetToCompactTileSheetConverter m_tileSheetToCompactTileSheetConverter;
|
||||
|
||||
public:
|
||||
[[nodiscard]]
|
||||
ox::String id() const noexcept override {
|
||||
@@ -52,19 +39,19 @@ static class: public keel::Module {
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
ox::Vector<keel::BaseConverter const*> converters() const noexcept final {
|
||||
ox::Vector<keel::Converter> converters() const noexcept final {
|
||||
return {
|
||||
&m_nostalgiaPaletteToPaletteV1Converter,
|
||||
&m_paletteV1ToPaletteV2Converter,
|
||||
&m_paletteV2ToPaletteV3Converter,
|
||||
&m_paletteV3ToPaletteV4Converter,
|
||||
&m_paletteV4ToPaletteV5Converter,
|
||||
&m_paletteToCompactPaletteConverter,
|
||||
&m_tileSheetV1ToTileSheetV2Converter,
|
||||
&m_tileSheetV2ToTileSheetV3Converter,
|
||||
&m_tileSheetV3ToTileSheetV4Converter,
|
||||
&m_tileSheetV4ToTileSheetV5Converter,
|
||||
&m_tileSheetToCompactTileSheetConverter,
|
||||
keel::Converter::make<convertNostalgiaPaletteToPaletteV1>(),
|
||||
keel::Converter::make<convertPaletteV1ToPaletteV2>(),
|
||||
keel::Converter::make<convertPaletteV2ToPaletteV3>(),
|
||||
keel::Converter::make<convertPaletteV3ToPaletteV4>(),
|
||||
keel::Converter::make<convertPaletteV4ToPaletteV5>(),
|
||||
keel::Converter::make<convertPaletteToCompactPalette>(),
|
||||
keel::Converter::make<convertTileSheetV1ToTileSheetV2>(),
|
||||
keel::Converter::make<convertTileSheetV2ToTileSheetV3>(),
|
||||
keel::Converter::make<convertTileSheetV3ToTileSheetV4>(),
|
||||
keel::Converter::make<convertTileSheetV4ToTileSheetV5>(),
|
||||
keel::Converter::make<convertTileSheetToCompactTileSheet>(),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -6,26 +6,26 @@
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
|
||||
ox::Error NostalgiaPaletteToPaletteV1Converter::convert(
|
||||
ox::Error convertNostalgiaPaletteToPaletteV1(
|
||||
keel::Context&,
|
||||
NostalgiaPalette &src,
|
||||
PaletteV1 &dst) const noexcept {
|
||||
PaletteV1 &dst) noexcept {
|
||||
dst.colors = std::move(src.colors);
|
||||
return {};
|
||||
}
|
||||
|
||||
ox::Error PaletteV1ToPaletteV2Converter::convert(
|
||||
ox::Error convertPaletteV1ToPaletteV2(
|
||||
keel::Context&,
|
||||
PaletteV1 &src,
|
||||
PaletteV2 &dst) const noexcept {
|
||||
PaletteV2 &dst) noexcept {
|
||||
dst.pages.emplace_back(std::move(src.colors));
|
||||
return {};
|
||||
}
|
||||
|
||||
ox::Error PaletteV2ToPaletteV3Converter::convert(
|
||||
ox::Error convertPaletteV2ToPaletteV3(
|
||||
keel::Context&,
|
||||
PaletteV2 &src,
|
||||
PaletteV3 &dst) const noexcept {
|
||||
PaletteV3 &dst) noexcept {
|
||||
dst.pages = std::move(src.pages);
|
||||
if (!dst.pages.empty()) {
|
||||
dst.colorInfo.reserve(dst.pages[0].size());
|
||||
@@ -36,10 +36,10 @@ ox::Error PaletteV2ToPaletteV3Converter::convert(
|
||||
return {};
|
||||
}
|
||||
|
||||
ox::Error PaletteV3ToPaletteV4Converter::convert(
|
||||
ox::Error convertPaletteV3ToPaletteV4(
|
||||
keel::Context&,
|
||||
PaletteV3 &src,
|
||||
PaletteV4 &dst) const noexcept {
|
||||
PaletteV4 &dst) noexcept {
|
||||
dst.pages.reserve(src.pages.size());
|
||||
for (auto i = 1; auto &page : src.pages) {
|
||||
dst.pages.emplace_back(ox::sfmt("Page {}", i), std::move(page));
|
||||
@@ -52,10 +52,10 @@ ox::Error PaletteV3ToPaletteV4Converter::convert(
|
||||
return {};
|
||||
}
|
||||
|
||||
ox::Error PaletteV4ToPaletteV5Converter::convert(
|
||||
ox::Error convertPaletteV4ToPaletteV5(
|
||||
keel::Context&,
|
||||
PaletteV4 &src,
|
||||
PaletteV5 &dst) const noexcept {
|
||||
PaletteV5 &dst) noexcept {
|
||||
dst.colorNames = std::move(src.colorNames);
|
||||
dst.pages.reserve(src.pages.size());
|
||||
for (auto &s : src.pages) {
|
||||
@@ -72,10 +72,10 @@ ox::Error PaletteV4ToPaletteV5Converter::convert(
|
||||
return {};
|
||||
}
|
||||
|
||||
ox::Error PaletteToCompactPaletteConverter::convert(
|
||||
ox::Error convertPaletteToCompactPalette(
|
||||
keel::Context&,
|
||||
Palette &src,
|
||||
CompactPalette &dst) const noexcept {
|
||||
CompactPalette &dst) noexcept {
|
||||
dst.pages.reserve(src.pages.size());
|
||||
for (auto &page : src.pages) {
|
||||
auto &p = dst.pages.emplace_back();
|
||||
@@ -86,10 +86,10 @@ ox::Error PaletteToCompactPaletteConverter::convert(
|
||||
return {};
|
||||
}
|
||||
|
||||
ox::Error TileSheetV1ToTileSheetV2Converter::convert(
|
||||
ox::Error convertTileSheetV1ToTileSheetV2(
|
||||
keel::Context&,
|
||||
TileSheetV1 &src,
|
||||
TileSheetV2 &dst) const noexcept {
|
||||
TileSheetV2 &dst) noexcept {
|
||||
dst.bpp = src.bpp;
|
||||
dst.defaultPalette = std::move(src.defaultPalette);
|
||||
dst.subsheet.name = "Root";
|
||||
@@ -99,7 +99,7 @@ ox::Error TileSheetV1ToTileSheetV2Converter::convert(
|
||||
return {};
|
||||
}
|
||||
|
||||
void TileSheetV2ToTileSheetV3Converter::convertSubsheet(
|
||||
static void convertSubsheet(
|
||||
TileSheetV2::SubSheet &src,
|
||||
TileSheetV3::SubSheet &dst,
|
||||
SubSheetId &idIt) noexcept {
|
||||
@@ -115,10 +115,10 @@ void TileSheetV2ToTileSheetV3Converter::convertSubsheet(
|
||||
}
|
||||
}
|
||||
|
||||
ox::Error TileSheetV2ToTileSheetV3Converter::convert(
|
||||
ox::Error convertTileSheetV2ToTileSheetV3(
|
||||
keel::Context&,
|
||||
TileSheetV2 &src,
|
||||
TileSheetV3 &dst) const noexcept {
|
||||
TileSheetV3 &dst) noexcept {
|
||||
dst.bpp = src.bpp;
|
||||
dst.defaultPalette = std::move(src.defaultPalette);
|
||||
convertSubsheet(src.subsheet, dst.subsheet, dst.idIt);
|
||||
@@ -126,7 +126,7 @@ ox::Error TileSheetV2ToTileSheetV3Converter::convert(
|
||||
}
|
||||
|
||||
|
||||
void TileSheetV3ToTileSheetV4Converter::convertSubsheet(
|
||||
static void convertSubsheet(
|
||||
TileSheetV3::SubSheet &src,
|
||||
TileSheetV4::SubSheet &dst,
|
||||
SubSheetId &idIt) noexcept {
|
||||
@@ -142,10 +142,10 @@ void TileSheetV3ToTileSheetV4Converter::convertSubsheet(
|
||||
}
|
||||
}
|
||||
|
||||
ox::Error TileSheetV3ToTileSheetV4Converter::convert(
|
||||
ox::Error convertTileSheetV3ToTileSheetV4(
|
||||
keel::Context&,
|
||||
TileSheetV3 &src,
|
||||
TileSheetV4 &dst) const noexcept {
|
||||
TileSheetV4 &dst) noexcept {
|
||||
dst.bpp = src.bpp;
|
||||
dst.idIt = src.idIt;
|
||||
dst.defaultPalette = std::move(src.defaultPalette);
|
||||
@@ -154,7 +154,7 @@ ox::Error TileSheetV3ToTileSheetV4Converter::convert(
|
||||
}
|
||||
|
||||
|
||||
void TileSheetV4ToTileSheetV5Converter::convertSubsheet(
|
||||
static void convertSubsheet(
|
||||
int const bpp,
|
||||
TileSheetV4::SubSheet &src,
|
||||
TileSheetV5::SubSheet &dst) noexcept {
|
||||
@@ -179,22 +179,22 @@ void TileSheetV4ToTileSheetV5Converter::convertSubsheet(
|
||||
}
|
||||
}
|
||||
|
||||
ox::Error TileSheetV4ToTileSheetV5Converter::convert(
|
||||
ox::Error convertTileSheetV4ToTileSheetV5(
|
||||
keel::Context&,
|
||||
TileSheetV4 &src,
|
||||
TileSheetV5 &dst) const noexcept {
|
||||
dst.bpp = src.bpp;
|
||||
dst.idIt = src.idIt;
|
||||
TileSheetV5 &dst) noexcept {
|
||||
dst.bpp = src.bpp;
|
||||
dst.idIt = src.idIt;
|
||||
OX_RETURN_ERROR(src.defaultPalette.getPath().moveTo(dst.defaultPalette));
|
||||
convertSubsheet(dst.bpp, src.subsheet, dst.subsheet);
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
ox::Error TileSheetToCompactTileSheetConverter::convert(
|
||||
ox::Error convertTileSheetToCompactTileSheet(
|
||||
keel::Context&,
|
||||
TileSheet &src,
|
||||
CompactTileSheet &dst) const noexcept {
|
||||
CompactTileSheet &dst) noexcept {
|
||||
dst.bpp = src.bpp;
|
||||
dst.defaultPalette = ox::FileAddress{src.defaultPalette};
|
||||
dst.pixels = pixels(src);
|
||||
|
||||
@@ -16,60 +16,26 @@ namespace nostalgia::gfx {
|
||||
|
||||
// Type converters
|
||||
|
||||
class NostalgiaPaletteToPaletteV1Converter: public keel::Converter<NostalgiaPalette, PaletteV1> {
|
||||
ox::Error convert(keel::Context&, NostalgiaPalette &src, PaletteV1 &dst) const noexcept final;
|
||||
};
|
||||
ox::Error convertNostalgiaPaletteToPaletteV1(keel::Context&, NostalgiaPalette &src, PaletteV1 &dst) noexcept;
|
||||
|
||||
class PaletteV1ToPaletteV2Converter: public keel::Converter<PaletteV1, PaletteV2> {
|
||||
ox::Error convert(keel::Context&, PaletteV1 &src, PaletteV2 &dst) const noexcept final;
|
||||
};
|
||||
ox::Error convertPaletteV1ToPaletteV2(keel::Context&, PaletteV1 &src, PaletteV2 &dst) noexcept;
|
||||
|
||||
class PaletteV2ToPaletteV3Converter: public keel::Converter<PaletteV2, PaletteV3> {
|
||||
ox::Error convert(keel::Context&, PaletteV2 &src, PaletteV3 &dst) const noexcept final;
|
||||
};
|
||||
ox::Error convertPaletteV2ToPaletteV3(keel::Context&, PaletteV2 &src, PaletteV3 &dst) noexcept;
|
||||
|
||||
class PaletteV3ToPaletteV4Converter: public keel::Converter<PaletteV3, PaletteV4> {
|
||||
ox::Error convert(keel::Context&, PaletteV3 &src, PaletteV4 &dst) const noexcept final;
|
||||
};
|
||||
ox::Error convertPaletteV3ToPaletteV4(keel::Context&, PaletteV3 &src, PaletteV4 &dst) noexcept;
|
||||
|
||||
class PaletteV4ToPaletteV5Converter: public keel::Converter<PaletteV4, PaletteV5> {
|
||||
ox::Error convert(keel::Context&, PaletteV4 &src, PaletteV5 &dst) const noexcept final;
|
||||
};
|
||||
ox::Error convertPaletteV4ToPaletteV5(keel::Context&, PaletteV4 &src, PaletteV5 &dst) noexcept;
|
||||
|
||||
class PaletteToCompactPaletteConverter: public keel::Converter<Palette, CompactPalette> {
|
||||
ox::Error convert(keel::Context&, Palette &src, CompactPalette &dst) const noexcept final;
|
||||
};
|
||||
ox::Error convertPaletteToCompactPalette(keel::Context&, Palette &src, CompactPalette &dst) noexcept;
|
||||
|
||||
class TileSheetV1ToTileSheetV2Converter: public keel::Converter<TileSheetV1, TileSheetV2> {
|
||||
ox::Error convert(keel::Context&, TileSheetV1 &src, TileSheetV2 &dst) const noexcept final;
|
||||
};
|
||||
ox::Error convertTileSheetV1ToTileSheetV2(keel::Context&, TileSheetV1 &src, TileSheetV2 &dst) noexcept;
|
||||
|
||||
class TileSheetV2ToTileSheetV3Converter: public keel::Converter<TileSheetV2, TileSheetV3> {
|
||||
static void convertSubsheet(
|
||||
TileSheetV2::SubSheet &src,
|
||||
TileSheetV3::SubSheet &dst,
|
||||
SubSheetId &idIt) noexcept;
|
||||
ox::Error convert(keel::Context&, TileSheetV2 &src, TileSheetV3 &dst) const noexcept final;
|
||||
};
|
||||
ox::Error convertTileSheetV2ToTileSheetV3(keel::Context&, TileSheetV2 &src, TileSheetV3 &dst) noexcept;
|
||||
|
||||
class TileSheetV3ToTileSheetV4Converter: public keel::Converter<TileSheetV3, TileSheetV4> {
|
||||
static void convertSubsheet(
|
||||
TileSheetV3::SubSheet &src,
|
||||
TileSheetV4::SubSheet &dst,
|
||||
SubSheetId &idIt) noexcept;
|
||||
ox::Error convert(keel::Context&, TileSheetV3 &src, TileSheetV4 &dst) const noexcept final;
|
||||
};
|
||||
ox::Error convertTileSheetV3ToTileSheetV4(keel::Context&, TileSheetV3 &src, TileSheetV4 &dst) noexcept;
|
||||
|
||||
class TileSheetV4ToTileSheetV5Converter final: public keel::Converter<TileSheetV4, TileSheetV5> {
|
||||
static void convertSubsheet(
|
||||
int bpp,
|
||||
TileSheetV4::SubSheet &src,
|
||||
TileSheetV5::SubSheet &dst) noexcept;
|
||||
ox::Error convert(keel::Context&, TileSheetV4 &src, TileSheetV5 &dst) const noexcept override;
|
||||
};
|
||||
ox::Error convertTileSheetV4ToTileSheetV5(keel::Context&, TileSheetV4 &src, TileSheetV5 &dst) noexcept;
|
||||
|
||||
class TileSheetToCompactTileSheetConverter: public keel::Converter<TileSheet, CompactTileSheet> {
|
||||
ox::Error convert(keel::Context&, TileSheet &src, CompactTileSheet &dst) const noexcept final;
|
||||
};
|
||||
ox::Error convertTileSheetToCompactTileSheet(keel::Context&, TileSheet &src, CompactTileSheet &dst) noexcept;
|
||||
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ void PaletteEditorImGui::numShortcuts(size_t &val, size_t const sizeRange) noexc
|
||||
auto const lastElem = sizeRange - 1;
|
||||
if (ImGui::IsKeyPressed(ImGuiKey_0)) {
|
||||
val = ox::min<size_t>(9, lastElem);
|
||||
} else for (auto i = 9u; i < 10; --i) {
|
||||
} else for (auto i = 8u; i < 9; --i) {
|
||||
auto const key = static_cast<ImGuiKey>(ImGuiKey_1 + i);
|
||||
if (ImGui::IsKeyPressed(key)) {
|
||||
val = ox::min<size_t>(i, lastElem);
|
||||
|
||||
@@ -96,7 +96,7 @@ TileSheetEditorImGui::TileSheetEditorImGui(studio::StudioContext &sctx, ox::Stri
|
||||
m_model{m_view.model()} {
|
||||
// connect signal/slots
|
||||
m_subsheetEditor.inputSubmitted.connect(this, &TileSheetEditorImGui::updateActiveSubsheet);
|
||||
m_exportMenu.inputSubmitted.connect(this, &TileSheetEditorImGui::exportSubhseetToPng);
|
||||
m_exportMenu.inputSubmitted.connect(this, &TileSheetEditorImGui::exportSubsheetToPng);
|
||||
// load config
|
||||
auto const&config = studio::readConfig<TileSheetEditorConfig>(
|
||||
keelCtx(m_sctx), itemPath());
|
||||
@@ -397,7 +397,7 @@ void TileSheetEditorImGui::showSubsheetEditor() noexcept {
|
||||
}
|
||||
}
|
||||
|
||||
ox::Error TileSheetEditorImGui::exportSubhseetToPng(int const scale) const noexcept {
|
||||
ox::Error TileSheetEditorImGui::exportSubsheetToPng(int const scale) const noexcept {
|
||||
OX_REQUIRE(path, studio::saveFile({{"PNG", "png"}}));
|
||||
// subsheet to png
|
||||
auto const&s = m_model.activeSubSheet();
|
||||
@@ -414,7 +414,7 @@ ox::Error TileSheetEditorImGui::exportSubhseetToPng(int const scale) const noexc
|
||||
static_cast<unsigned>(width * scale),
|
||||
static_cast<unsigned>(height * scale));
|
||||
if (err) {
|
||||
oxErrorf("Tilesheet export failed: {}", toStr(err));
|
||||
oxErrorf("TileSheet export failed: {}", toStr(err));
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <studio/editor.hpp>
|
||||
#include <studio/filepickerpopup.hpp>
|
||||
|
||||
#include "tilesheetpixelgrid.hpp"
|
||||
#include "tilesheetpixels.hpp"
|
||||
#include "tilesheeteditorview.hpp"
|
||||
|
||||
@@ -91,7 +90,7 @@ class TileSheetEditorImGui: public studio::Editor {
|
||||
private:
|
||||
void showSubsheetEditor() noexcept;
|
||||
|
||||
ox::Error exportSubhseetToPng(int scale) const noexcept;
|
||||
ox::Error exportSubsheetToPng(int scale) const noexcept;
|
||||
|
||||
void drawTileSheet(ox::Vec2 const&fbSize) noexcept;
|
||||
|
||||
@@ -99,8 +98,6 @@ class TileSheetEditorImGui: public studio::Editor {
|
||||
|
||||
ox::Error updateActiveSubsheet(ox::StringView const&name, int cols, int rows) noexcept;
|
||||
|
||||
// slots
|
||||
private:
|
||||
void setActiveSubsheet(TileSheet::SubSheetIdx path) noexcept;
|
||||
|
||||
};
|
||||
|
||||
@@ -120,7 +120,7 @@ bool TileSheetEditorModel::acceptsClipboardPayload() const noexcept {
|
||||
return cb.ok();
|
||||
}
|
||||
|
||||
ox::StringView TileSheetEditorModel::palPath() const noexcept {
|
||||
ox::String const &TileSheetEditorModel::palPath() const & noexcept {
|
||||
return m_palPath;
|
||||
}
|
||||
|
||||
@@ -263,7 +263,13 @@ ox::Error TileSheetEditorModel::rotateRight() noexcept {
|
||||
}
|
||||
|
||||
void TileSheetEditorModel::setSelection(studio::Selection const&sel) noexcept {
|
||||
m_selection.emplace(sel);
|
||||
auto const &ss = activeSubSheet();
|
||||
if (sel.a.x < ss.columns * TileWidth && sel.a.y < ss.rows * TileHeight) {
|
||||
m_selection.emplace(sel);
|
||||
} else {
|
||||
m_selTracker.finishSelection();
|
||||
m_selection.reset();
|
||||
}
|
||||
m_updated = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ class TileSheetEditorModel: public ox::SignalHandler {
|
||||
constexpr Palette const&pal() const noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
ox::StringView palPath() const noexcept;
|
||||
ox::String const &palPath() const & noexcept;
|
||||
|
||||
ox::Error setPalette(ox::StringViewCR path) noexcept;
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ static class: public keel::Module {
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
ox::Vector<keel::BaseConverter const*> converters() const noexcept final {
|
||||
ox::Vector<keel::Converter> converters() const noexcept final {
|
||||
return {
|
||||
};
|
||||
}
|
||||
|
||||
@@ -64,13 +64,10 @@ static void testKeyEventHandler(turbine::Context &tctx, turbine::Key key, bool d
|
||||
|
||||
[[maybe_unused]]
|
||||
static ox::Error runTest(turbine::Context &tctx) {
|
||||
constexpr ox::StringView TileSheetAddr{"/TileSheets/Charset.nts"};
|
||||
constexpr ox::StringView PaletteAddr{"/Palettes/Chester.npal"};
|
||||
OX_REQUIRE_M(cctx, gfx::init(tctx));
|
||||
turbine::setApplicationData(tctx, cctx.get());
|
||||
OX_REQUIRE(tsStat, turbine::rom(tctx)->stat(PaletteAddr));
|
||||
OX_RETURN_ERROR(gfx::loadSpriteTileSheet(*cctx, TileSheetAddr));
|
||||
OX_RETURN_ERROR(gfx::loadSpritePalette(*cctx, PaletteAddr));
|
||||
OX_RETURN_ERROR(gfx::loadSpriteTileSheet(*cctx, "/TileSheets/Charset.nts"));
|
||||
OX_RETURN_ERROR(gfx::loadSpritePalette(*cctx, "/Palettes/Chester.npal"));
|
||||
OX_RETURN_ERROR(gfx::initConsole(*cctx));
|
||||
gfx::puts(*cctx, 10, 9, "DOPENESS!!!");
|
||||
turbine::setUpdateHandler(tctx, testUpdateHandler);
|
||||
@@ -86,7 +83,6 @@ static ox::Error runTileSheetSetTest(turbine::Context &tctx) {
|
||||
constexpr ox::StringView PaletteAddr{"/Palettes/Charset.npal"};
|
||||
OX_REQUIRE_M(cctx, gfx::init(tctx));
|
||||
turbine::setApplicationData(tctx, cctx.get());
|
||||
OX_REQUIRE(tsStat, turbine::rom(tctx)->stat(PaletteAddr));
|
||||
gfx::TileSheetSet const set{
|
||||
.bpp = 4,
|
||||
.entries = {
|
||||
@@ -134,7 +130,6 @@ ox::Error run(
|
||||
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));
|
||||
OX_REQUIRE_M(tctx, turbine::init(std::move(fs), project));
|
||||
OX_REQUIRE_M(tctx, turbine::init(path, project));
|
||||
return runTileSheetSetTest(*tctx);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
add_executable(NostalgiaStudio WIN32 MACOSX_BUNDLE)
|
||||
add_executable(
|
||||
NostalgiaStudio WIN32 MACOSX_BUNDLE
|
||||
ns.rc
|
||||
icondata.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
NostalgiaStudio
|
||||
|
||||
1495
src/nostalgia/studio/icondata.cpp
Normal file
1
src/nostalgia/studio/ns.rc
Normal file
@@ -0,0 +1 @@
|
||||
IDI_ICON1 ICON DISCARDABLE "ns_logo.ico"
|
||||
BIN
src/nostalgia/studio/ns_logo.ico
Normal file
|
After Width: | Height: | Size: 162 KiB |
BIN
src/nostalgia/studio/ns_logo1080.png
Normal file
|
After Width: | Height: | Size: 851 B |
BIN
src/nostalgia/studio/ns_logo16.png
Normal file
|
After Width: | Height: | Size: 134 B |
BIN
src/nostalgia/studio/ns_logo24.png
Normal file
|
After Width: | Height: | Size: 149 B |
BIN
src/nostalgia/studio/ns_logo264.png
Normal file
|
After Width: | Height: | Size: 275 B |
BIN
src/nostalgia/studio/ns_logo32.png
Normal file
|
After Width: | Height: | Size: 4.1 KiB |
BIN
src/nostalgia/studio/ns_logo40.png
Normal file
|
After Width: | Height: | Size: 334 B |
BIN
src/nostalgia/studio/ns_logo48.png
Normal file
|
After Width: | Height: | Size: 163 B |
39
src/nostalgia/studio/rsrc.json
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"cpp": "icondata.cpp",
|
||||
"namespace": "studio",
|
||||
"all_files": "WindowIcons",
|
||||
"files": [
|
||||
{
|
||||
"path": "ns_logo16.png",
|
||||
"cpp_name": "WindowIcon16"
|
||||
},
|
||||
{
|
||||
"path": "ns_logo24.png",
|
||||
"cpp_name": "WindowIcon24"
|
||||
},
|
||||
{
|
||||
"path": "ns_logo32.png",
|
||||
"cpp_name": "WindowIcon32"
|
||||
},
|
||||
{
|
||||
"path": "ns_logo40.png",
|
||||
"cpp_name": "WindowIcon40"
|
||||
},
|
||||
{
|
||||
"path": "ns_logo48.png",
|
||||
"cpp_name": "WindowIcon48"
|
||||
},
|
||||
{
|
||||
"path": "ns_logo128.png",
|
||||
"cpp_name": "WindowIcon128"
|
||||
},
|
||||
{
|
||||
"path": "ns_logo264.png",
|
||||
"cpp_name": "WindowIcon264"
|
||||
},
|
||||
{
|
||||
"path": "ns_logo1080.png",
|
||||
"cpp_name": "WindowIcon1080"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ox/claw/claw.hpp>
|
||||
#include <ox/claw/read.hpp>
|
||||
#include <ox/fs/fs.hpp>
|
||||
|
||||
#include "validation.hpp"
|
||||
|
||||
@@ -8,11 +8,11 @@
|
||||
#include <ox/std/memory.hpp>
|
||||
|
||||
#include "assetmanager.hpp"
|
||||
#include "typeconv.hpp"
|
||||
|
||||
namespace keel {
|
||||
|
||||
class Context;
|
||||
using PackTransform = ox::Result<bool>(*)(Context&, ox::Buffer &clawData, ox::StringViewCR);
|
||||
|
||||
class Context {
|
||||
public:
|
||||
@@ -22,7 +22,7 @@ class Context {
|
||||
AssetManager assetManager;
|
||||
ox::HashMap<ox::String, ox::UUID> pathToUuid;
|
||||
ox::HashMap<ox::UUIDStr, ox::String> uuidToPath;
|
||||
ox::Vector<class BaseConverter const*> converters;
|
||||
ox::Vector<Converter> converters;
|
||||
ox::Vector<PackTransform> packTransforms;
|
||||
#else
|
||||
std::size_t preloadSectionOffset = 0;
|
||||
@@ -45,7 +45,7 @@ constexpr ox::SpanView<PackTransform> packTransforms(
|
||||
#endif
|
||||
}
|
||||
|
||||
constexpr ox::SpanView<class BaseConverter const*> converters(
|
||||
constexpr ox::SpanView<Converter> converters(
|
||||
[[maybe_unused]] Context const&ctx) noexcept {
|
||||
#ifndef OX_BARE_METAL
|
||||
return ctx.converters;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -32,7 +32,7 @@ class Module {
|
||||
[[nodiscard]]
|
||||
virtual ox::Vector<TypeDescGenerator> types() const noexcept;
|
||||
[[nodiscard]]
|
||||
virtual ox::Vector<const keel::BaseConverter*> converters() const noexcept;
|
||||
virtual ox::Vector<Converter> converters() const noexcept;
|
||||
[[nodiscard]]
|
||||
virtual ox::Vector<PackTransform> packTransforms() const noexcept;
|
||||
};
|
||||
|
||||
@@ -4,15 +4,17 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ox/claw/write.hpp>
|
||||
#include <ox/std/def.hpp>
|
||||
#include <ox/std/error.hpp>
|
||||
#include <ox/std/string.hpp>
|
||||
|
||||
#include "asset.hpp"
|
||||
#include "context.hpp"
|
||||
|
||||
namespace keel {
|
||||
|
||||
class Context;
|
||||
|
||||
class Wrap {
|
||||
public:
|
||||
virtual ~Wrap() = default;
|
||||
@@ -30,6 +32,7 @@ class WrapT: public Wrap {
|
||||
[[nodiscard]]
|
||||
virtual constexpr T &obj() noexcept = 0;
|
||||
|
||||
[[nodiscard]]
|
||||
ox::UAnyPtr moveToCopy() noexcept final {
|
||||
return new T{std::move(obj())};
|
||||
}
|
||||
@@ -44,14 +47,17 @@ class WrapRef final: public WrapT<T> {
|
||||
public:
|
||||
constexpr explicit WrapRef(T &obj): m_obj{obj} {}
|
||||
|
||||
[[nodiscard]]
|
||||
ox::CStringView typeName() const noexcept override {
|
||||
return ox::ModelTypeName_v<T>;
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
int typeVersion() const noexcept override {
|
||||
return ox::ModelTypeVersion_v<T>;
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr T &obj() noexcept override {
|
||||
return m_obj;
|
||||
}
|
||||
@@ -70,14 +76,17 @@ class WrapInline final: public WrapT<T> {
|
||||
constexpr explicit WrapInline(Args &&...args): m_obj(ox::forward<Args>(args)...) {
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
ox::CStringView typeName() const noexcept override {
|
||||
return ox::ModelTypeName_v<T>;
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
int typeVersion() const noexcept override {
|
||||
return ox::ModelTypeVersion_v<T>;
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr T &obj() noexcept override {
|
||||
return m_obj;
|
||||
}
|
||||
@@ -113,7 +122,7 @@ class BaseConverter {
|
||||
virtual ox::Result<ox::UPtr<Wrap>> convertPtrToPtr(keel::Context &ctx, Wrap &src) const noexcept = 0;
|
||||
|
||||
virtual ox::Result<ox::UPtr<Wrap>> convertBuffToPtr(
|
||||
keel::Context &ctx, ox::BufferView const&srcBuff) const noexcept = 0;
|
||||
Context &ctx, ox::BufferView const&srcBuff) const noexcept = 0;
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr bool matches(
|
||||
@@ -125,21 +134,37 @@ class BaseConverter {
|
||||
|
||||
};
|
||||
|
||||
template<typename SrcType, typename DstType>
|
||||
class Converter: public BaseConverter {
|
||||
|
||||
template<auto Func>
|
||||
class ConverterFunc final: public BaseConverter {
|
||||
private:
|
||||
template<typename SrcType, typename DstType>
|
||||
struct ParamPack {
|
||||
using Src = SrcType;
|
||||
using Dst = DstType;
|
||||
};
|
||||
|
||||
template<typename Src, typename Dst>
|
||||
static ParamPack<Src, Dst> extractParams(ox::Error (*)(Context&, Src&, Dst&)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
public:
|
||||
using SrcType = typename decltype(extractParams(Func))::Src;
|
||||
using DstType = typename decltype(extractParams(Func))::Dst;
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr ox::StringView srcTypeName() const noexcept final {
|
||||
constexpr ox::StringView srcTypeName() const noexcept override {
|
||||
return ox::ModelTypeName_v<SrcType>;
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr int srcTypeVersion() const noexcept final {
|
||||
constexpr int srcTypeVersion() const noexcept override {
|
||||
return ox::ModelTypeVersion_v<SrcType>;
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr bool srcMatches(ox::StringViewCR pSrcTypeName, int pSrcTypeVersion) const noexcept final {
|
||||
constexpr bool srcMatches(ox::StringViewCR pSrcTypeName, int pSrcTypeVersion) const noexcept override {
|
||||
constexpr auto SrcTypeName = ox::requireModelTypeName<SrcType>();
|
||||
constexpr auto SrcTypeVersion = ox::requireModelTypeVersion<SrcType>();
|
||||
return pSrcTypeName == SrcTypeName
|
||||
@@ -147,7 +172,7 @@ class Converter: public BaseConverter {
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr bool dstMatches(ox::StringViewCR dstTypeName, int dstTypeVersion) const noexcept final {
|
||||
constexpr bool dstMatches(ox::StringViewCR dstTypeName, int dstTypeVersion) const noexcept override {
|
||||
constexpr auto DstTypeName = ox::StringView{ox::requireModelTypeName<DstType>()};
|
||||
constexpr auto DstTypeVersion = ox::requireModelTypeVersion<DstType>();
|
||||
return dstTypeName == DstTypeName
|
||||
@@ -155,14 +180,14 @@ class Converter: public BaseConverter {
|
||||
}
|
||||
|
||||
ox::Result<ox::UPtr<Wrap>> convertPtrToPtr(
|
||||
keel::Context &ctx, Wrap &src) const noexcept final {
|
||||
Context &ctx, Wrap &src) const noexcept override {
|
||||
ox::Result<ox::UPtr<Wrap>> dst{makeWrap<DstType>()};
|
||||
OX_RETURN_ERROR(convert(ctx, wrapCast<SrcType>(src), wrapCast<DstType>(*dst.value)));
|
||||
return dst;
|
||||
}
|
||||
|
||||
ox::Result<ox::UPtr<Wrap>> convertBuffToPtr(
|
||||
keel::Context &ctx, ox::BufferView const&srcBuff) const noexcept final {
|
||||
Context &ctx, ox::BufferView const&srcBuff) const noexcept override {
|
||||
OX_REQUIRE_M(src, readAsset<SrcType>(srcBuff));
|
||||
ox::Result<ox::UPtr<Wrap>> dst{makeWrap<DstType>()};
|
||||
OX_RETURN_ERROR(convert(ctx, src, wrapCast<DstType>(*dst.value)));
|
||||
@@ -170,24 +195,43 @@ class Converter: public BaseConverter {
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual ox::Error convert(keel::Context &ctx, SrcType&, DstType&) const noexcept = 0;
|
||||
static ox::Error convert(Context &ctx, SrcType &src, DstType &dst) noexcept {
|
||||
return Func(ctx, src, dst);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class Converter {
|
||||
private:
|
||||
ox::AllocAlias<BaseConverter> m_buff{};
|
||||
public:
|
||||
template<auto Func>
|
||||
static Converter make() noexcept {
|
||||
Converter out;
|
||||
static_assert(sizeof(ConverterFunc<Func>) <= sizeof(out.m_buff));
|
||||
new (out.m_buff.data()) ConverterFunc<Func>{};
|
||||
return out;
|
||||
}
|
||||
[[nodiscard]]
|
||||
BaseConverter const &converter() const noexcept {
|
||||
return *m_buff.data();
|
||||
}
|
||||
};
|
||||
|
||||
ox::Result<ox::UPtr<Wrap>> convert(
|
||||
keel::Context &ctx,
|
||||
Context &ctx,
|
||||
ox::BufferView const&srcBuffer,
|
||||
ox::StringViewCR dstTypeName,
|
||||
int dstTypeVersion) noexcept;
|
||||
|
||||
ox::Result<ox::UPtr<Wrap>> convert(
|
||||
keel::Context &ctx,
|
||||
Context &ctx,
|
||||
Wrap &src,
|
||||
ox::StringViewCR dstTypeName,
|
||||
int dstTypeVersion) noexcept;
|
||||
|
||||
ox::Result<ox::UPtr<Wrap>> convert(
|
||||
keel::Context &ctx,
|
||||
Context &ctx,
|
||||
auto &src,
|
||||
ox::StringViewCR dstTypeName,
|
||||
int const dstTypeVersion) noexcept {
|
||||
@@ -196,7 +240,7 @@ ox::Result<ox::UPtr<Wrap>> convert(
|
||||
}
|
||||
|
||||
ox::Result<ox::UPtr<Wrap>> convert(
|
||||
keel::Context &ctx,
|
||||
Context &ctx,
|
||||
auto const&src,
|
||||
ox::StringViewCR dstTypeName,
|
||||
int const dstTypeVersion) noexcept {
|
||||
@@ -207,27 +251,27 @@ ox::Result<ox::UPtr<Wrap>> convert(
|
||||
|
||||
template<typename DstType>
|
||||
ox::Result<DstType> convertObjToObj(
|
||||
keel::Context &ctx,
|
||||
Context &ctx,
|
||||
auto &src) noexcept {
|
||||
OX_REQUIRE_M(out, convert(ctx, WrapRef{src}, ox::ModelTypeName_v<DstType>, ox::ModelTypeVersion_v<DstType>));
|
||||
return std::move(wrapCast(*out));
|
||||
}
|
||||
|
||||
template<typename DstType>
|
||||
ox::Result<DstType> convert(keel::Context &ctx, ox::BufferView const&src) noexcept {
|
||||
ox::Result<DstType> convert(Context &ctx, ox::BufferView const&src) noexcept {
|
||||
OX_REQUIRE(out, convert(ctx, src, ox::ModelTypeName_v<DstType>, ox::ModelTypeVersion_v<DstType>));
|
||||
return std::move(wrapCast<DstType>(out));
|
||||
}
|
||||
|
||||
template<typename DstType>
|
||||
ox::Error convert(keel::Context &ctx, ox::BufferView const&buff, DstType &outObj) noexcept {
|
||||
ox::Error convert(Context &ctx, ox::BufferView const&buff, DstType &outObj) noexcept {
|
||||
OX_REQUIRE(out, convert(ctx, buff, ox::ModelTypeName_v<DstType>, ox::ModelTypeVersion_v<DstType>));
|
||||
outObj = std::move(wrapCast<DstType>(*out));
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename DstType>
|
||||
ox::Error convertObjToObj(keel::Context &ctx, auto &src, DstType &outObj) noexcept {
|
||||
ox::Error convertObjToObj(Context &ctx, auto &src, DstType &outObj) noexcept {
|
||||
OX_REQUIRE(outPtr, convert(ctx, src, ox::ModelTypeName_v<DstType>, ox::ModelTypeVersion_v<DstType>));
|
||||
outObj = std::move(wrapCast<DstType>(*outPtr));
|
||||
return {};
|
||||
@@ -235,13 +279,13 @@ ox::Error convertObjToObj(keel::Context &ctx, auto &src, DstType &outObj) noexce
|
||||
|
||||
template<typename DstType>
|
||||
ox::Result<ox::Buffer> convertBuffToBuff(
|
||||
keel::Context &ctx, ox::BufferView const&src, ox::ClawFormat const fmt) noexcept {
|
||||
Context &ctx, ox::BufferView const&src, ox::ClawFormat const fmt) noexcept {
|
||||
OX_REQUIRE(out, convert(ctx, src, ox::ModelTypeName_v<DstType>, ox::ModelTypeVersion_v<DstType>));
|
||||
return ox::writeClaw<DstType>(wrapCast<DstType>(*out), fmt);
|
||||
}
|
||||
|
||||
template<typename From, typename To, ox::ClawFormat fmt = ox::ClawFormat::Metal>
|
||||
ox::Result<bool> transformRule(keel::Context &ctx, ox::Buffer &buff, ox::StringViewCR typeId) noexcept {
|
||||
ox::Result<bool> transformRule(Context &ctx, ox::Buffer &buff, ox::StringViewCR typeId) noexcept {
|
||||
if (typeId == ox::ModelTypeId_v<From>) {
|
||||
OX_RETURN_ERROR(keel::convertBuffToBuff<To>(ctx, buff, fmt).moveTo(buff));
|
||||
return true;
|
||||
@@ -249,4 +293,6 @@ ox::Result<bool> transformRule(keel::Context &ctx, ox::Buffer &buff, ox::StringV
|
||||
return false;
|
||||
};
|
||||
|
||||
using PackTransform = ox::Result<bool>(*)(Context&, ox::Buffer &clawData, ox::StringViewCR);
|
||||
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ ox::Result<ox::ModelObject> readAsset(ox::TypeStore &ts, ox::BufferView buff) no
|
||||
return ox::readClaw(ts, buff);
|
||||
}
|
||||
|
||||
ox::Result<ox::StringView> readAssetTypeId(ox::BufferView buff) noexcept {
|
||||
ox::Result<ox::StringView> readAssetTypeId(ox::BufferView const buff) noexcept {
|
||||
const auto err = readUuidHeader(buff).error;
|
||||
const auto offset = err ? 0u : K1HdrSz;
|
||||
if (offset >= buff.size()) [[unlikely]] {
|
||||
|
||||
@@ -24,7 +24,7 @@ ox::Vector<TypeDescGenerator> Module::types() const noexcept {
|
||||
return {};
|
||||
}
|
||||
|
||||
ox::Vector<keel::BaseConverter const*> Module::converters() const noexcept {
|
||||
ox::Vector<Converter> Module::converters() const noexcept {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
@@ -6,13 +6,11 @@
|
||||
|
||||
#include <ox/clargs/clargs.hpp>
|
||||
#include <ox/fs/fs.hpp>
|
||||
#include <ox/logconn/def.hpp>
|
||||
#include <ox/logconn/logconn.hpp>
|
||||
#include <ox/oc/write.hpp>
|
||||
|
||||
#include <keel/keel.hpp>
|
||||
|
||||
static ox::Error writeFileBuff(ox::StringView path, ox::BufferView const buff) noexcept {
|
||||
static ox::Error writeFileBuff(ox::StringViewCR path, ox::BufferView const &buff) noexcept {
|
||||
try {
|
||||
std::ofstream f(std::string(toStdStringView(path)), std::ios::binary);
|
||||
f.write(buff.data(), static_cast<intptr_t>(buff.size()));
|
||||
@@ -22,7 +20,7 @@ static ox::Error writeFileBuff(ox::StringView path, ox::BufferView const buff) n
|
||||
return {};
|
||||
}
|
||||
|
||||
static ox::Result<ox::Buffer> readFileBuff(ox::StringView path) noexcept {
|
||||
static ox::Result<ox::Buffer> readFileBuff(ox::StringViewCR path) noexcept {
|
||||
std::ifstream file(std::string(toStdStringView(path)), std::ios::binary | std::ios::ate);
|
||||
if (!file.good()) {
|
||||
oxErrorf("Could not find OxFS file: {}", path);
|
||||
@@ -42,7 +40,7 @@ static ox::Result<ox::Buffer> readFileBuff(ox::StringView path) noexcept {
|
||||
|
||||
static ox::Error generateTypes(ox::TypeStore &ts) noexcept {
|
||||
for (auto const mod : keel::modules()) {
|
||||
for (auto gen : mod->types()) {
|
||||
for (auto const gen : mod->types()) {
|
||||
OX_RETURN_ERROR(gen(ts));
|
||||
}
|
||||
}
|
||||
@@ -50,10 +48,10 @@ static ox::Error generateTypes(ox::TypeStore &ts) noexcept {
|
||||
}
|
||||
|
||||
static ox::Error pack(
|
||||
ox::StringView argSrc,
|
||||
ox::StringView argRomBin,
|
||||
ox::StringView argManifest,
|
||||
ox::StringView projectDataDir) noexcept {
|
||||
ox::StringViewCR argSrc,
|
||||
ox::StringViewCR argRomBin,
|
||||
ox::StringViewCR argManifest,
|
||||
ox::StringViewCR projectDataDir) noexcept {
|
||||
ox::Buffer dstBuff(32 * ox::units::MB);
|
||||
OX_RETURN_ERROR(ox::FileSystem32::format(dstBuff.data(), dstBuff.size()));
|
||||
ox::FileSystem32 dst(dstBuff);
|
||||
@@ -82,10 +80,10 @@ static ox::Error pack(
|
||||
}
|
||||
|
||||
ox::Error run(
|
||||
[[maybe_unused]] ox::StringView project,
|
||||
[[maybe_unused]] ox::StringView appName,
|
||||
ox::StringView projectDataDir,
|
||||
ox::SpanView<ox::CString> argv) noexcept {
|
||||
[[maybe_unused]] ox::StringView const project,
|
||||
[[maybe_unused]] ox::StringView const appName,
|
||||
ox::StringView const projectDataDir,
|
||||
ox::SpanView<ox::CString> const argv) noexcept {
|
||||
ox::ClArgs const args(argv);
|
||||
auto const argSrc = args.getString("src", "");
|
||||
auto const argRomBin = args.getString("rom-bin", "");
|
||||
|
||||
@@ -11,13 +11,12 @@
|
||||
namespace keel {
|
||||
|
||||
static ox::Error pathToInode(
|
||||
keel::Context &ctx,
|
||||
ox::FileSystem &dest,
|
||||
Context &ctx,
|
||||
ox::FileSystem const &dest,
|
||||
ox::ModelObject &obj) noexcept {
|
||||
auto &o = obj;
|
||||
OX_REQUIRE(typeVal, o.at("type"));
|
||||
OX_REQUIRE(typeVal, obj.at("type"));
|
||||
auto const type = static_cast<ox::FileAddressType>(typeVal->get<int8_t>());
|
||||
OX_REQUIRE(dataVal, o.at("data"));
|
||||
OX_REQUIRE(dataVal, obj.at("data"));
|
||||
auto &data = dataVal->get<ox::ModelUnion>();
|
||||
ox::String path;
|
||||
switch (type) {
|
||||
@@ -47,13 +46,17 @@ static ox::Error pathToInode(
|
||||
}
|
||||
|
||||
static ox::Error transformFileAddressesObj(
|
||||
keel::Context &ctx, ox::FileSystem &dest, ox::ModelObject &obj) noexcept;
|
||||
Context &ctx,
|
||||
ox::FileSystem const &dest,
|
||||
ox::ModelObject &obj) noexcept;
|
||||
static ox::Error transformFileAddressesVec(
|
||||
keel::Context &ctx, ox::FileSystem &dest, ox::ModelValueVector &v) noexcept;
|
||||
Context &ctx,
|
||||
ox::FileSystem const &dest,
|
||||
ox::ModelValueVector &v) noexcept;
|
||||
|
||||
static ox::Error transformFileAddresses(
|
||||
keel::Context &ctx,
|
||||
ox::FileSystem &dest,
|
||||
Context &ctx,
|
||||
ox::FileSystem const &dest,
|
||||
ox::ModelValue &v) noexcept {
|
||||
if (v.type() == ox::ModelValue::Type::Object) {
|
||||
auto &obj = v.get<ox::ModelObject>();
|
||||
@@ -66,8 +69,8 @@ static ox::Error transformFileAddresses(
|
||||
}
|
||||
|
||||
static ox::Error transformFileAddressesVec(
|
||||
keel::Context &ctx,
|
||||
ox::FileSystem &dest,
|
||||
Context &ctx,
|
||||
ox::FileSystem const &dest,
|
||||
ox::ModelValueVector &v) noexcept {
|
||||
for (auto &f : v) {
|
||||
OX_RETURN_ERROR(transformFileAddresses(ctx, dest, f));
|
||||
@@ -80,13 +83,13 @@ static ox::Error transformFileAddressesVec(
|
||||
* @return error
|
||||
*/
|
||||
static ox::Error transformFileAddressesObj(
|
||||
keel::Context &ctx,
|
||||
ox::FileSystem &dest,
|
||||
Context &ctx,
|
||||
ox::FileSystem const &dest,
|
||||
ox::ModelObject &obj) noexcept {
|
||||
if (obj.typeName() == "net.drinkingtea.ox.FileAddress" && obj.typeVersion() == 1) {
|
||||
return pathToInode(ctx, dest, obj);
|
||||
}
|
||||
for (auto &f : obj) {
|
||||
for (auto const &f : obj) {
|
||||
auto &v = f->value;
|
||||
OX_RETURN_ERROR(transformFileAddresses(ctx, dest, v));
|
||||
}
|
||||
@@ -111,7 +114,7 @@ static ox::Error performPackTransforms(
|
||||
|
||||
static ox::Error doTransformations(
|
||||
Manifest &manifest,
|
||||
keel::Context &ctx,
|
||||
Context &ctx,
|
||||
ox::TypeStore &ts,
|
||||
ox::FileSystem &dest,
|
||||
ox::StringViewCR filePath) noexcept {
|
||||
@@ -134,7 +137,7 @@ static ox::Error doTransformations(
|
||||
// transformations need to be done after the copy to the new FS is complete
|
||||
static ox::Error transformClaw(
|
||||
Manifest &manifest,
|
||||
keel::Context &ctx,
|
||||
Context &ctx,
|
||||
ox::TypeStore &ts,
|
||||
ox::FileSystem &dest,
|
||||
ox::StringViewCR path) noexcept {
|
||||
@@ -200,7 +203,7 @@ static ox::Error copy(
|
||||
|
||||
ox::Error pack(
|
||||
Manifest &manifest,
|
||||
keel::Context &ctx,
|
||||
Context &ctx,
|
||||
ox::TypeStore &ts,
|
||||
ox::FileSystem &dest) noexcept {
|
||||
OX_RETURN_ERROR(copy(manifest, *ctx.rom, dest, "/"));
|
||||
|
||||
@@ -2,20 +2,21 @@
|
||||
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#include <keel/context.hpp>
|
||||
#include <keel/media.hpp>
|
||||
#include <keel/typeconv.hpp>
|
||||
|
||||
namespace keel {
|
||||
|
||||
static ox::Result<BaseConverter const*> findConverter(
|
||||
ox::SpanView<BaseConverter const*> const&converters,
|
||||
ox::SpanView<Converter> const&converters,
|
||||
ox::StringViewCR srcTypeName,
|
||||
int const srcTypeVersion,
|
||||
ox::StringViewCR dstTypeName,
|
||||
int const dstTypeVersion) noexcept {
|
||||
for (auto const&c : converters) {
|
||||
if (c->matches(srcTypeName, srcTypeVersion, dstTypeName, dstTypeVersion)) {
|
||||
return c;
|
||||
if (c.converter().matches(srcTypeName, srcTypeVersion, dstTypeName, dstTypeVersion)) {
|
||||
return &c.converter();
|
||||
}
|
||||
}
|
||||
return ox::Error{1, "Could not find converter"};
|
||||
@@ -31,7 +32,7 @@ static ox::Result<ox::UPtr<Wrap>> convert(BaseConverter const&c, Context &ctx, W
|
||||
|
||||
static ox::Result<ox::UPtr<Wrap>> convert(
|
||||
Context &ctx,
|
||||
ox::SpanView<BaseConverter const*> const&converters,
|
||||
ox::SpanView<Converter> const&converters,
|
||||
auto &src,
|
||||
ox::StringViewCR srcTypeName,
|
||||
int const srcTypeVersion,
|
||||
@@ -45,14 +46,14 @@ static ox::Result<ox::UPtr<Wrap>> convert(
|
||||
}
|
||||
// try to chain multiple converters
|
||||
for (auto const&subConverter : converters) {
|
||||
if (!subConverter->dstMatches(dstTypeName, dstTypeVersion)) {
|
||||
if (!subConverter.converter().dstMatches(dstTypeName, dstTypeVersion)) {
|
||||
continue;
|
||||
}
|
||||
const auto [intermediate, chainErr] =
|
||||
convert(ctx, converters, src, srcTypeName, srcTypeVersion,
|
||||
subConverter->srcTypeName(), subConverter->srcTypeVersion());
|
||||
subConverter.converter().srcTypeName(), subConverter.converter().srcTypeVersion());
|
||||
if (!chainErr) {
|
||||
return subConverter->convertPtrToPtr(ctx, *intermediate);
|
||||
return subConverter.converter().convertPtrToPtr(ctx, *intermediate);
|
||||
}
|
||||
}
|
||||
return ox::Error{1, "Could not convert between types"};
|
||||
|
||||
@@ -5,6 +5,7 @@ add_library(
|
||||
clawviewer.cpp
|
||||
deleteconfirmation.cpp
|
||||
filedialogmanager.cpp
|
||||
font.cpp
|
||||
makecopypopup.cpp
|
||||
newdir.cpp
|
||||
newmenu.cpp
|
||||
|
||||
BIN
src/olympic/studio/applib/src/Roboto-Medium.ttf
Normal file
@@ -32,11 +32,15 @@ static void keyEventHandler(turbine::Context &ctx, turbine::Key key, bool down)
|
||||
sctx->ui.handleKeyEvent(key, down);
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
ox::Vector<ox::SpanView<uint8_t>> WindowIcons() noexcept;
|
||||
|
||||
static ox::Error runApp(
|
||||
ox::StringViewCR appName,
|
||||
ox::StringViewCR projectDataDir,
|
||||
ox::UPtr<ox::FileSystem> &&fs) noexcept {
|
||||
OX_REQUIRE_M(ctx, turbine::init(std::move(fs), appName));
|
||||
oxLogError(turbine::setWindowIcon(*ctx, WindowIcons()));
|
||||
turbine::setWindowTitle(*ctx, keelCtx(*ctx).appName);
|
||||
turbine::setKeyEventHandler(*ctx, keyEventHandler);
|
||||
turbine::setRefreshWithin(*ctx, 0);
|
||||
|
||||
16272
src/olympic/studio/applib/src/font.cpp
Normal file
10
src/olympic/studio/applib/src/font.hpp
Normal file
@@ -0,0 +1,10 @@
|
||||
// Generated
|
||||
|
||||
#include <ox/std/span.hpp>
|
||||
|
||||
namespace studio::files {
|
||||
|
||||
[[nodiscard]]
|
||||
ox::SpanView<uint8_t> RobotoMedium_ttf() noexcept;
|
||||
|
||||
}
|
||||
11
src/olympic/studio/applib/src/rsrc.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"cpp": "font.cpp",
|
||||
"hpp": "font.hpp",
|
||||
"namespace": "studio::files",
|
||||
"files": [
|
||||
{
|
||||
"path": "Roboto-Medium.ttf",
|
||||
"cpp_name": "RobotoMedium_ttf"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -14,10 +14,16 @@
|
||||
#include <studio/configio.hpp>
|
||||
#include "clawviewer.hpp"
|
||||
#include "filedialogmanager.hpp"
|
||||
#include "font.hpp"
|
||||
#include "studioui.hpp"
|
||||
|
||||
namespace studio {
|
||||
|
||||
static bool shutdownHandler(turbine::Context &ctx) {
|
||||
auto sctx = turbine::applicationData<StudioContext>(ctx);
|
||||
return sctx->ui.handleShutdown();
|
||||
}
|
||||
|
||||
void navigateTo(StudioContext &ctx, ox::StringParam filePath, ox::StringParam navArgs) noexcept {
|
||||
ctx.ui.navigateTo(std::move(filePath), std::move(navArgs));
|
||||
}
|
||||
@@ -57,7 +63,21 @@ StudioUI::StudioUI(turbine::Context &ctx, ox::StringParam projectDataDir) noexce
|
||||
m_projectExplorer{keelCtx(m_tctx)},
|
||||
m_newProject{m_projectDataDir},
|
||||
m_aboutPopup{m_tctx} {
|
||||
{
|
||||
ImFontConfig fontCfg;
|
||||
fontCfg.FontDataOwnedByAtlas = false;
|
||||
auto const &io = ImGui::GetIO();
|
||||
auto const font = files::RobotoMedium_ttf();
|
||||
// const_cast is needed because this data is definitely const,
|
||||
// but AddFontFromMemoryTTF requires a mutable buffer.
|
||||
// However, setting fontCfg.FontDataOwnedByAtlas ensures
|
||||
// that it will still be treated as const.
|
||||
// ImGui documentation recognize that this is a bad design,
|
||||
// and hopefully it will change at some point.
|
||||
io.Fonts->AddFontFromMemoryTTF(const_cast<uint8_t*>(font.data()), static_cast<int>(font.size()), 13, &fontCfg);
|
||||
}
|
||||
turbine::setApplicationData(m_tctx, &m_sctx);
|
||||
turbine::setShutdownHandler(m_tctx, shutdownHandler);
|
||||
m_projectExplorer.fileChosen.connect(this, &StudioUI::openFile);
|
||||
m_projectExplorer.addDir.connect(this, &StudioUI::addDir);
|
||||
m_projectExplorer.addItem.connect(this, &StudioUI::addFile);
|
||||
@@ -69,6 +89,7 @@ StudioUI::StudioUI(turbine::Context &ctx, ox::StringParam projectDataDir) noexce
|
||||
m_renameFile.moveFile.connect(this, &StudioUI::queueFileMove);
|
||||
m_newProject.finished.connect(this, &StudioUI::createOpenProject);
|
||||
m_newMenu.finished.connect(this, &StudioUI::openFile);
|
||||
m_closeAppConfirm.response.connect(this, &StudioUI::handleCloseAppResponse);
|
||||
m_closeFileConfirm.response.connect(this, &StudioUI::handleCloseFileResponse);
|
||||
loadModules();
|
||||
// open project and files
|
||||
@@ -144,6 +165,7 @@ void StudioUI::draw() noexcept {
|
||||
for (auto const p : m_popups) {
|
||||
p->draw(m_sctx);
|
||||
}
|
||||
m_closeAppConfirm.draw(m_sctx);
|
||||
m_closeFileConfirm.draw(m_sctx);
|
||||
m_copyFilePopup.draw(m_sctx);
|
||||
}
|
||||
@@ -153,6 +175,16 @@ void StudioUI::draw() noexcept {
|
||||
procFileMoves();
|
||||
}
|
||||
|
||||
bool StudioUI::handleShutdown() noexcept {
|
||||
auto const out = ox::all_of(m_editors.begin(), m_editors.end(), [](ox::UPtr<BaseEditor> const &e) {
|
||||
return !e->unsavedChanges();
|
||||
});
|
||||
if (!out) {
|
||||
m_closeAppConfirm.open();
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
void StudioUI::drawMenu() noexcept {
|
||||
if (ImGui::BeginMainMenuBar()) {
|
||||
if (ImGui::BeginMenu("File")) {
|
||||
@@ -253,7 +285,9 @@ void StudioUI::drawTabs() noexcept {
|
||||
}
|
||||
if (!open) {
|
||||
if (e->unsavedChanges()) {
|
||||
m_closeAppConfirm.open();
|
||||
m_closeFileConfirm.open();
|
||||
++it;
|
||||
} else {
|
||||
e->close();
|
||||
if (m_activeEditor == (*it).get()) {
|
||||
@@ -369,6 +403,7 @@ void StudioUI::handleKeyInput() noexcept {
|
||||
} else if (ImGui::IsKeyPressed(ImGuiKey_W)) {
|
||||
if (m_activeEditor) {
|
||||
if (m_activeEditor->unsavedChanges()) {
|
||||
m_closeAppConfirm.open();
|
||||
m_closeFileConfirm.open();
|
||||
} else {
|
||||
oxLogError(closeCurrentFile());
|
||||
@@ -533,6 +568,13 @@ ox::Error StudioUI::makeCopyDlg(ox::StringViewCR path) noexcept {
|
||||
return m_copyFilePopup.open(path);
|
||||
}
|
||||
|
||||
ox::Error StudioUI::handleCloseAppResponse(ig::PopupResponse const response) noexcept {
|
||||
if (response == ig::PopupResponse::OK && m_activeEditor) {
|
||||
turbine::requestShutdown(m_tctx);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
ox::Error StudioUI::handleCloseFileResponse(ig::PopupResponse const response) noexcept {
|
||||
if (response == ig::PopupResponse::OK && m_activeEditor) {
|
||||
return closeCurrentFile();
|
||||
|
||||
@@ -49,6 +49,10 @@ class StudioUI: public ox::SignalHandler {
|
||||
DeleteConfirmation m_deleteConfirmation;
|
||||
NewDir m_newDirDialog;
|
||||
ig::QuestionPopup m_closeFileConfirm{"Close File?", "This file has unsaved changes. Close?"};
|
||||
ig::QuestionPopup m_closeAppConfirm{
|
||||
"Close Application?",
|
||||
"There are files with unsaved changes. Close?"
|
||||
};
|
||||
MakeCopyPopup m_copyFilePopup;
|
||||
RenameFile m_renameFile;
|
||||
NewProject m_newProject;
|
||||
@@ -80,6 +84,8 @@ class StudioUI: public ox::SignalHandler {
|
||||
return m_project.get();
|
||||
}
|
||||
|
||||
bool handleShutdown() noexcept;
|
||||
|
||||
protected:
|
||||
void draw() noexcept;
|
||||
|
||||
@@ -128,6 +134,8 @@ class StudioUI: public ox::SignalHandler {
|
||||
|
||||
ox::Error makeCopyDlg(ox::StringViewCR path) noexcept;
|
||||
|
||||
ox::Error handleCloseAppResponse(ig::PopupResponse response) noexcept;
|
||||
|
||||
ox::Error handleCloseFileResponse(ig::PopupResponse response) noexcept;
|
||||
|
||||
ox::Error closeCurrentFile() noexcept;
|
||||
|
||||
@@ -71,12 +71,6 @@ class SelectionTracker {
|
||||
return m_selectionOngoing;
|
||||
}
|
||||
|
||||
constexpr void startSelection(ox::Point cursor) noexcept {
|
||||
m_pointA = cursor;
|
||||
m_pointB = cursor;
|
||||
m_selectionOngoing = true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param cursor
|
||||
|
||||
@@ -19,8 +19,6 @@ class Context;
|
||||
|
||||
void safeDelete(Context *p);
|
||||
|
||||
void shutdown(Context &ctx) noexcept;
|
||||
|
||||
keel::Context const&keelCtx(Context const&ctx) noexcept;
|
||||
|
||||
keel::Context &keelCtx(Context &ctx) noexcept;
|
||||
|
||||
@@ -26,20 +26,22 @@ void removeDrawer(Context &ctx, Drawer *cd) noexcept;
|
||||
|
||||
ox::Error initGfx(Context &ctx) noexcept;
|
||||
|
||||
ox::Error setWindowIcon(Context &ctx, ox::SpanView<ox::SpanView<uint8_t>> const &iconPngs) noexcept;
|
||||
|
||||
void setWindowTitle(Context &ctx, ox::StringViewCR title) noexcept;
|
||||
|
||||
void focusWindow(Context &ctx) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
int getScreenWidth(Context &ctx) noexcept;
|
||||
int getScreenWidth(Context const &ctx) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
int getScreenHeight(Context &ctx) noexcept;
|
||||
int getScreenHeight(Context const &ctx) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
ox::Size getScreenSize(Context &ctx) noexcept;
|
||||
ox::Size getScreenSize(Context const &ctx) noexcept;
|
||||
|
||||
ox::Bounds getWindowBounds(Context &ctx) noexcept;
|
||||
ox::Bounds getWindowBounds(Context const &ctx) noexcept;
|
||||
|
||||
ox::Error setWindowBounds(Context &ctx, ox::Bounds const&bnds) noexcept;
|
||||
|
||||
|
||||
@@ -29,4 +29,8 @@ TimeMs ticksMs(Context const&ctx) noexcept;
|
||||
|
||||
void requestShutdown(Context &ctx) noexcept;
|
||||
|
||||
using ShutdownHandler = bool (*)(Context&);
|
||||
|
||||
void setShutdownHandler(Context &ctx, ShutdownHandler handler) noexcept;
|
||||
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
namespace turbine {
|
||||
|
||||
class Context {
|
||||
class Context final {
|
||||
public:
|
||||
UpdateHandler updateHandler = [](Context&) -> int {return 0;};
|
||||
keel::Context keelCtx;
|
||||
@@ -27,10 +27,6 @@ class Context {
|
||||
Context(Context const&other) noexcept = delete;
|
||||
Context(Context const&&other) noexcept = delete;
|
||||
|
||||
virtual inline ~Context() noexcept {
|
||||
shutdown(*this);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -27,19 +27,19 @@ ox::Error initGfx(Context&) noexcept {
|
||||
void setWindowTitle(Context&, ox::StringViewCR) noexcept {
|
||||
}
|
||||
|
||||
int getScreenWidth(Context&) noexcept {
|
||||
int getScreenWidth(Context const&) noexcept {
|
||||
return 240;
|
||||
}
|
||||
|
||||
int getScreenHeight(Context&) noexcept {
|
||||
int getScreenHeight(Context const&) noexcept {
|
||||
return 160;
|
||||
}
|
||||
|
||||
ox::Size getScreenSize(Context&) noexcept {
|
||||
ox::Size getScreenSize(Context const&) noexcept {
|
||||
return {240, 160};
|
||||
}
|
||||
|
||||
ox::Bounds getWindowBounds(Context&) noexcept {
|
||||
ox::Bounds getWindowBounds(Context const&) noexcept {
|
||||
return {0, 0, 240, 160};
|
||||
}
|
||||
|
||||
|
||||
@@ -86,4 +86,7 @@ void requestShutdown(Context &ctx) noexcept {
|
||||
ctx.running = false;
|
||||
}
|
||||
|
||||
void setShutdownHandler(Context&, ShutdownHandler) noexcept {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,4 +21,5 @@ target_link_libraries(
|
||||
glad
|
||||
glfw
|
||||
imgui
|
||||
lodepng
|
||||
)
|
||||
|
||||
@@ -30,6 +30,8 @@ class Context {
|
||||
uint64_t keysDown = 0;
|
||||
uint64_t prevFpsCheckTime = 0;
|
||||
uint64_t draws = 0;
|
||||
bool running{};
|
||||
ShutdownHandler shutdownHandler{};
|
||||
|
||||
Context() noexcept = default;
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <glad/glad.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <lodepng.h>
|
||||
#if TURBINE_USE_IMGUI
|
||||
#include <imgui_impl_glfw.h>
|
||||
#include <imgui_impl_opengl3.h>
|
||||
@@ -228,6 +229,42 @@ ox::Error initGfx(Context &ctx) noexcept {
|
||||
return {};
|
||||
}
|
||||
|
||||
struct IconData {
|
||||
std::vector<uint8_t> pixels;
|
||||
int w{}, h{};
|
||||
};
|
||||
|
||||
[[nodiscard]]
|
||||
[[maybe_unused]]
|
||||
static ox::Result<IconData> toGlfwImgPixels(ox::SpanView<uint8_t> const &iconPng) noexcept {
|
||||
ox::Result<IconData> out;
|
||||
unsigned w{}, h{};
|
||||
if (lodepng::decode(out.value.pixels, w, h, iconPng.data(), iconPng.size())) {
|
||||
return ox::Error{1, "unable to decode window icon PNG data"};
|
||||
}
|
||||
out.value.w = static_cast<int>(w);
|
||||
out.value.h = static_cast<int>(h);
|
||||
return out;
|
||||
}
|
||||
|
||||
ox::Error setWindowIcon(Context &ctx, ox::SpanView<ox::SpanView<uint8_t>> const &iconPngs) noexcept {
|
||||
if constexpr(ox::defines::OS != ox::OS::Darwin) {
|
||||
ox::Vector<IconData, 8> src;
|
||||
ox::Vector<GLFWimage, 8> imgs;
|
||||
for (auto const &iconPng : iconPngs) {
|
||||
OX_RETURN_ERROR(toGlfwImgPixels(iconPng).moveTo(src.emplace_back()));
|
||||
auto &icon = *src.back().unwrap();
|
||||
imgs.emplace_back(GLFWimage{
|
||||
.width = icon.w,
|
||||
.height = icon.h,
|
||||
.pixels = icon.pixels.data(),
|
||||
});
|
||||
}
|
||||
glfwSetWindowIcon(ctx.window, static_cast<int>(imgs.size()), imgs.data());
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
void setWindowTitle(Context &ctx, ox::StringViewCR title) noexcept {
|
||||
auto cstr = ox_malloca(title.bytes() + 1, char);
|
||||
ox::strncpy(cstr.get(), title.data(), title.bytes());
|
||||
@@ -238,25 +275,25 @@ void focusWindow(Context &ctx) noexcept {
|
||||
glfwFocusWindow(ctx.window);
|
||||
}
|
||||
|
||||
int getScreenWidth(Context &ctx) noexcept {
|
||||
int getScreenWidth(Context const &ctx) noexcept {
|
||||
int w = 0, h = 0;
|
||||
glfwGetFramebufferSize(ctx.window, &w, &h);
|
||||
return w;
|
||||
}
|
||||
|
||||
int getScreenHeight(Context &ctx) noexcept {
|
||||
int getScreenHeight(Context const &ctx) noexcept {
|
||||
int w = 0, h = 0;
|
||||
glfwGetFramebufferSize(ctx.window, &w, &h);
|
||||
return h;
|
||||
}
|
||||
|
||||
ox::Size getScreenSize(Context &ctx) noexcept {
|
||||
ox::Size getScreenSize(Context const &ctx) noexcept {
|
||||
int w = 0, h = 0;
|
||||
glfwGetFramebufferSize(ctx.window, &w, &h);
|
||||
return {w, h};
|
||||
}
|
||||
|
||||
ox::Bounds getWindowBounds(Context &ctx) noexcept {
|
||||
ox::Bounds getWindowBounds(Context const &ctx) noexcept {
|
||||
ox::Bounds bnds;
|
||||
glfwGetWindowPos(ctx.window, &bnds.x, &bnds.y);
|
||||
glfwGetWindowSize(ctx.window, &bnds.width, &bnds.height);
|
||||
|
||||
@@ -68,9 +68,21 @@ static void tickFps(Context &ctx, uint64_t const nowMs) noexcept {
|
||||
}
|
||||
}
|
||||
|
||||
static void shutdown(Context &ctx) noexcept {
|
||||
if (ctx.window) {
|
||||
#if TURBINE_USE_IMGUI
|
||||
ImGui_ImplOpenGL3_Shutdown();
|
||||
ImGui_ImplGlfw_Shutdown();
|
||||
#endif
|
||||
glfwDestroyWindow(ctx.window);
|
||||
ctx.window = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
ox::Error run(Context &ctx) noexcept {
|
||||
uint64_t sleepTime = 0;
|
||||
while (!glfwWindowShouldClose(ctx.window)) {
|
||||
ctx.running = true;
|
||||
while (ctx.running) {
|
||||
ctx.refreshWithinMs = 10 * 1000; // refresh within 10 seconds
|
||||
glfwPollEvents();
|
||||
auto const ticks = ticksMs(ctx);
|
||||
@@ -92,22 +104,17 @@ ox::Error run(Context &ctx) noexcept {
|
||||
if (realSleepTime && ctx.mandatoryRefreshPeriodEnd <= ticks) {
|
||||
glfwWaitEventsTimeout(static_cast<double>(realSleepTime) / 1000);
|
||||
}
|
||||
if (glfwWindowShouldClose(ctx.window)) {
|
||||
if (ctx.shutdownHandler(ctx)) {
|
||||
break;
|
||||
}
|
||||
glfwSetWindowShouldClose(ctx.window, false);
|
||||
}
|
||||
}
|
||||
shutdown(ctx);
|
||||
return {};
|
||||
}
|
||||
|
||||
void shutdown(Context &ctx) noexcept {
|
||||
if (ctx.window) {
|
||||
#if TURBINE_USE_IMGUI
|
||||
ImGui_ImplOpenGL3_Shutdown();
|
||||
ImGui_ImplGlfw_Shutdown();
|
||||
#endif
|
||||
glfwDestroyWindow(ctx.window);
|
||||
ctx.window = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
TimeMs ticksMs(Context const&ctx) noexcept {
|
||||
using namespace std::chrono;
|
||||
auto const now = duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();
|
||||
@@ -119,7 +126,11 @@ bool buttonDown(Context const&ctx, Key const key) noexcept {
|
||||
}
|
||||
|
||||
void requestShutdown(Context &ctx) noexcept {
|
||||
glfwSetWindowShouldClose(ctx.window, true);
|
||||
ctx.running = false;
|
||||
}
|
||||
|
||||
void setShutdownHandler(Context &ctx, ShutdownHandler const handler) noexcept {
|
||||
ctx.shutdownHandler = handler;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
106
util/scripts/file-to-cpp.py
Executable file
@@ -0,0 +1,106 @@
|
||||
#! /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 os
|
||||
import json
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
|
||||
def write_txt_file(path: str, txt: str):
|
||||
with open(path, "w") as f:
|
||||
f.write(txt)
|
||||
print(f'Wrote {path}')
|
||||
|
||||
|
||||
def file_to_hex(path: str, line_prefix: str) -> tuple[str, int]:
|
||||
with open(path, 'rb') as f:
|
||||
out = line_prefix
|
||||
data = f.read()
|
||||
i = 1
|
||||
for b in data:
|
||||
out += f"{b:#0{4}x},"
|
||||
out += '\n\t' if i % 10 == 0 else ' '
|
||||
i += 1
|
||||
return out[:-1], len(data)
|
||||
|
||||
|
||||
def file_to_cpp(path: str, cpp_name: str) -> tuple[str, str]:
|
||||
cpp = ''
|
||||
hpp = ''
|
||||
data, data_len = file_to_hex(path, "\t")
|
||||
cpp += f'\nstatic const ox::Array<uint8_t, {data_len}> {cpp_name}Data {{\n{data}\n}};\n'
|
||||
cpp += f'\nox::SpanView<uint8_t> {cpp_name}() noexcept {{ return {cpp_name}Data; }}\n'
|
||||
hpp += f'\n[[nodiscard]]\nox::SpanView<uint8_t> {cpp_name}() noexcept;\n'
|
||||
return cpp, hpp
|
||||
|
||||
|
||||
def proc_rsrc_file(rsrc_path: str):# Open and read the JSON file
|
||||
with open(rsrc_path, 'r') as file:
|
||||
data = json.load(file)
|
||||
base_path = pathlib.Path(rsrc_path).parent.absolute()
|
||||
all_files = data['all_files'] if 'all_files' in data else None
|
||||
namespace = data['namespace'] if 'namespace' in data else ''
|
||||
if len(namespace) > 0:
|
||||
push_ns = f'namespace {namespace} {{\n'
|
||||
pop_ns = '\n}\n'
|
||||
else:
|
||||
push_ns = ''
|
||||
pop_ns = ''
|
||||
cpp = '// Generated\n\n#include <ox/std/array.hpp>\n'
|
||||
cpp += '#include <ox/std/span.hpp>\n\n'
|
||||
hpp = '// Generated\n\n#include <ox/std/span.hpp>\n\n'
|
||||
cpp += push_ns
|
||||
hpp += push_ns
|
||||
all_files_func_decl = ''
|
||||
all_files_func = ''
|
||||
if all_files is not None:
|
||||
all_files_func_decl += f'\n[[nodiscard]]\nox::Vector<ox::SpanView<uint8_t>> {all_files}() noexcept;\n'
|
||||
all_files_func += f'\nox::Vector<ox::SpanView<uint8_t>> {all_files}() noexcept {{\n\treturn {{\n'
|
||||
for f in data['files']:
|
||||
if 'path' not in f:
|
||||
print('src file path missing', file=sys.stderr)
|
||||
sys.exit(1)
|
||||
path = f['path']
|
||||
if 'cpp_name' not in f:
|
||||
print('var name missing', file=sys.stderr)
|
||||
sys.exit(1)
|
||||
cpp_name = f['cpp_name']
|
||||
c, h = file_to_cpp(os.path.join(base_path, path), cpp_name)
|
||||
cpp += c
|
||||
if len(h) > 0:
|
||||
hpp += h
|
||||
if all_files is not None:
|
||||
all_files_func += f'\t\t{cpp_name}(),\n'
|
||||
if all_files is not None:
|
||||
cpp += all_files_func + '\t};\n}\n'
|
||||
hpp += all_files_func_decl
|
||||
cpp += pop_ns
|
||||
hpp += pop_ns
|
||||
write_txt_file(os.path.join(base_path, data['cpp']), cpp)
|
||||
if 'hpp' in data:
|
||||
write_txt_file(os.path.join(base_path, data['hpp']), hpp)
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--rsrc', help='path to file', required=True)
|
||||
args = parser.parse_args()
|
||||
proc_rsrc_file(args.rsrc)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
err = main()
|
||||
sys.exit(err)
|
||||
except KeyboardInterrupt:
|
||||
sys.exit(1)
|
||||