Compare commits
17 Commits
84205879d4
...
d7f309750e
Author | SHA1 | Date | |
---|---|---|---|
d7f309750e | |||
eeb2a5a151 | |||
453f2750dd | |||
189ba4c545 | |||
057738088e | |||
272eabc732 | |||
a02566697a | |||
6808adc8a1 | |||
abc076d657 | |||
1b790a34c4 | |||
9220271630 | |||
7941a514ba | |||
0c09c5306e | |||
3ff91af86b | |||
79b42e1df7 | |||
5eec9085f8 | |||
af7c89564c |
@ -57,6 +57,7 @@ misc-*,
|
|||||||
readability-duplicate-include,
|
readability-duplicate-include,
|
||||||
-misc-non-private-member-variables-in-classes,
|
-misc-non-private-member-variables-in-classes,
|
||||||
-misc-no-recursion,
|
-misc-no-recursion,
|
||||||
|
-misc-include-cleaner,
|
||||||
bugprone-*,
|
bugprone-*,
|
||||||
clang-analyzer-*,
|
clang-analyzer-*,
|
||||||
modernize-*,
|
modernize-*,
|
||||||
|
15
deps/ox/src/ox/model/typenamecatcher.hpp
vendored
15
deps/ox/src/ox/model/typenamecatcher.hpp
vendored
@ -147,4 +147,19 @@ constexpr auto ModelTypeName_v = getModelTypeName<T, Str>();
|
|||||||
template<typename T, typename Str = const char*>
|
template<typename T, typename Str = const char*>
|
||||||
constexpr auto ModelTypeVersion_v = requireModelTypeVersion<T>();
|
constexpr auto ModelTypeVersion_v = requireModelTypeVersion<T>();
|
||||||
|
|
||||||
|
template<typename T, typename Str = const char*>
|
||||||
|
constexpr auto ModelTypeVersionStr_v = [] {
|
||||||
|
constexpr auto version = ModelTypeVersion_v<T>;
|
||||||
|
constexpr auto versionStr = ox::sfmt("{}", version);
|
||||||
|
return ox::BString<versionStr.len()>{versionStr};
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
constexpr auto ModelTypeId_v = [] {
|
||||||
|
constexpr auto name = ModelTypeName_v<T, ox::StringView>;
|
||||||
|
constexpr auto version = ModelTypeVersion_v<T>;
|
||||||
|
constexpr auto versionStr = ox::sfmt<ox::BString<19>>("{}", version);
|
||||||
|
return ox::sfmt<ox::BString<name.len() + versionStr.len() + 1>>("{};{}", name, versionStr);
|
||||||
|
}();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
1
deps/ox/src/ox/std/CMakeLists.txt
vendored
1
deps/ox/src/ox/std/CMakeLists.txt
vendored
@ -103,6 +103,7 @@ install(
|
|||||||
hardware.hpp
|
hardware.hpp
|
||||||
hashmap.hpp
|
hashmap.hpp
|
||||||
heapmgr.hpp
|
heapmgr.hpp
|
||||||
|
ignore.hpp
|
||||||
iterator.hpp
|
iterator.hpp
|
||||||
math.hpp
|
math.hpp
|
||||||
maybeview.hpp
|
maybeview.hpp
|
||||||
|
2
deps/ox/src/ox/std/fmt.hpp
vendored
2
deps/ox/src/ox/std/fmt.hpp
vendored
@ -77,7 +77,7 @@ class FmtArg {
|
|||||||
char dataStr[10] = {};
|
char dataStr[10] = {};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static StringView sv(const T &v, char *dataStr) noexcept {
|
constexpr StringView sv(const T &v, char *dataStr) noexcept {
|
||||||
if constexpr(is_bool_v<T>) {
|
if constexpr(is_bool_v<T>) {
|
||||||
return v ? "true" : "false";
|
return v ? "true" : "false";
|
||||||
} else if constexpr(is_integer_v<T>) {
|
} else if constexpr(is_integer_v<T>) {
|
||||||
|
20
deps/ox/src/ox/std/ignore.hpp
vendored
Normal file
20
deps/ox/src/ox/std/ignore.hpp
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 - 2024 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#if __has_include(<tuple>)
|
||||||
|
|
||||||
|
#include <tuple>
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
namespace std {
|
||||||
|
|
||||||
|
inline constexpr struct {
|
||||||
|
constexpr void operator=(auto&&) const noexcept {}
|
||||||
|
} ignore;
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
2
deps/ox/src/ox/std/realstd.hpp
vendored
2
deps/ox/src/ox/std/realstd.hpp
vendored
@ -11,5 +11,5 @@
|
|||||||
#if __has_include(<cassert>)
|
#if __has_include(<cassert>)
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#else
|
#else
|
||||||
#define assert(e) while (1);
|
#define assert(e) while (!(e));
|
||||||
#endif
|
#endif
|
1
deps/ox/src/ox/std/std.hpp
vendored
1
deps/ox/src/ox/std/std.hpp
vendored
@ -26,6 +26,7 @@
|
|||||||
#include "hardware.hpp"
|
#include "hardware.hpp"
|
||||||
#include "hashmap.hpp"
|
#include "hashmap.hpp"
|
||||||
#include "heapmgr.hpp"
|
#include "heapmgr.hpp"
|
||||||
|
#include "ignore.hpp"
|
||||||
#include "iterator.hpp"
|
#include "iterator.hpp"
|
||||||
#include "math.hpp"
|
#include "math.hpp"
|
||||||
#include "maybeview.hpp"
|
#include "maybeview.hpp"
|
||||||
|
4
deps/ox/src/ox/std/strops.hpp
vendored
4
deps/ox/src/ox/std/strops.hpp
vendored
@ -80,6 +80,7 @@ constexpr bool endsWith(CRStringView base, CRStringView ending) noexcept {
|
|||||||
return base.len() >= endingLen && ox::strcmp(base.data() + (base.len() - endingLen), ending) == 0;
|
return base.len() >= endingLen && ox::strcmp(base.data() + (base.len() - endingLen), ending) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]]
|
||||||
constexpr std::size_t find(CRStringView str, char search) noexcept {
|
constexpr std::size_t find(CRStringView str, char search) noexcept {
|
||||||
std::size_t i = 0;
|
std::size_t i = 0;
|
||||||
for (; i < str.len(); ++i) {
|
for (; i < str.len(); ++i) {
|
||||||
@ -90,6 +91,7 @@ constexpr std::size_t find(CRStringView str, char search) noexcept {
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]]
|
||||||
constexpr std::size_t find(CRStringView str, CRStringView search) noexcept {
|
constexpr std::size_t find(CRStringView str, CRStringView search) noexcept {
|
||||||
std::size_t i = 0;
|
std::size_t i = 0;
|
||||||
for (; i < str.len(); ++i) {
|
for (; i < str.len(); ++i) {
|
||||||
@ -101,6 +103,7 @@ constexpr std::size_t find(CRStringView str, CRStringView search) noexcept {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<std::size_t smallSz = 0>
|
template<std::size_t smallSz = 0>
|
||||||
|
[[nodiscard]]
|
||||||
constexpr ox::Vector<ox::StringView, smallSz> split(CRStringView str, char del) noexcept {
|
constexpr ox::Vector<ox::StringView, smallSz> split(CRStringView str, char del) noexcept {
|
||||||
ox::Vector<ox::StringView, smallSz> out;
|
ox::Vector<ox::StringView, smallSz> out;
|
||||||
constexpr auto nextSeg = [](CRStringView current, char del) {
|
constexpr auto nextSeg = [](CRStringView current, char del) {
|
||||||
@ -117,6 +120,7 @@ constexpr ox::Vector<ox::StringView, smallSz> split(CRStringView str, char del)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<std::size_t smallSz = 0>
|
template<std::size_t smallSz = 0>
|
||||||
|
[[nodiscard]]
|
||||||
constexpr ox::Vector<ox::StringView, smallSz> split(CRStringView str, CRStringView del) noexcept {
|
constexpr ox::Vector<ox::StringView, smallSz> split(CRStringView str, CRStringView del) noexcept {
|
||||||
ox::Vector<ox::StringView, smallSz> out;
|
ox::Vector<ox::StringView, smallSz> out;
|
||||||
constexpr auto nextSeg = [](CRStringView current, CRStringView del) {
|
constexpr auto nextSeg = [](CRStringView current, CRStringView del) {
|
||||||
|
10
deps/ox/src/ox/std/typetraits.hpp
vendored
10
deps/ox/src/ox/std/typetraits.hpp
vendored
@ -143,7 +143,7 @@ template<typename T>
|
|||||||
constexpr bool memberable(...) { return false; }
|
constexpr bool memberable(...) { return false; }
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct is_class: integral_constant<bool, !is_union<T>::value && memberable<T>(0)> {};
|
struct is_class: integral_constant<bool, !is_union_v<T> && memberable<T>(nullptr)> {};
|
||||||
|
|
||||||
namespace test {
|
namespace test {
|
||||||
struct TestClass {int i;};
|
struct TestClass {int i;};
|
||||||
@ -159,11 +159,11 @@ constexpr bool is_class_v = is_class<T>();
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
constexpr bool is_signed_v = integral_constant<bool, T(-1) < T(0)>::value;
|
constexpr bool is_signed_v = integral_constant<bool, T(-1) < T(0)>::value;
|
||||||
|
|
||||||
template<typename T, std::size_t bits>
|
template<typename T, std::size_t bits = sizeof(T) * 8>
|
||||||
concept Signed_c = is_signed_v<T> && sizeof(T) == 8 * bits;
|
concept Signed_c = is_signed_v<T> && sizeof(T) == bits / 8;
|
||||||
|
|
||||||
template<typename T, std::size_t bits>
|
template<typename T, std::size_t bits = sizeof(T) * 8>
|
||||||
concept Unsigned_c = !is_signed_v<T> && sizeof(T) == 8 * bits;
|
concept Unsigned_c = !is_signed_v<T> && sizeof(T) == bits / 8;
|
||||||
|
|
||||||
template<typename T, typename U>
|
template<typename T, typename U>
|
||||||
struct is_same: false_type {};
|
struct is_same: false_type {};
|
||||||
|
16
deps/ox/src/ox/std/vector.hpp
vendored
16
deps/ox/src/ox/std/vector.hpp
vendored
@ -52,15 +52,17 @@ struct VectorAllocator {
|
|||||||
const std::size_t cap) noexcept {
|
const std::size_t cap) noexcept {
|
||||||
// this totally idiotic redundant check (&& count <= Size) is required to address a bug in devkitARM,
|
// this totally idiotic redundant check (&& count <= Size) is required to address a bug in devkitARM,
|
||||||
// try removing it later
|
// try removing it later
|
||||||
|
if (!std::is_constant_evaluated()) {
|
||||||
if (cap <= m_data.size() && count <= m_data.size()) {
|
if (cap <= m_data.size() && count <= m_data.size()) {
|
||||||
for (auto i = 0u; i < count; ++i) {
|
for (auto i = 0u; i < count; ++i) {
|
||||||
const auto dstItem = reinterpret_cast<T*>(&m_data[i]);
|
const auto dstItem = reinterpret_cast<T *>(&m_data[i]);
|
||||||
const auto srcItem = reinterpret_cast<T*>(&src->m_data[i]);
|
const auto srcItem = reinterpret_cast<T *>(&src->m_data[i]);
|
||||||
std::construct_at<T>(dstItem, std::move(*srcItem));
|
std::construct_at<T>(dstItem, std::move(*srcItem));
|
||||||
}
|
}
|
||||||
*items = reinterpret_cast<T*>(m_data.data());
|
*items = reinterpret_cast<T*>(m_data.data());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
constexpr void moveItemsFrom(
|
constexpr void moveItemsFrom(
|
||||||
T **items,
|
T **items,
|
||||||
@ -69,22 +71,26 @@ struct VectorAllocator {
|
|||||||
const std::size_t cap) noexcept {
|
const std::size_t cap) noexcept {
|
||||||
// this totally idiotic redundant check (&& count <= Size) is required to address a bug in devkitARM,
|
// this totally idiotic redundant check (&& count <= Size) is required to address a bug in devkitARM,
|
||||||
// try removing it later
|
// try removing it later
|
||||||
|
if (!std::is_constant_evaluated()) {
|
||||||
if (cap <= m_data.size() && count <= m_data.size()) {
|
if (cap <= m_data.size() && count <= m_data.size()) {
|
||||||
for (std::size_t i = 0; i < count; ++i) {
|
for (std::size_t i = 0; i < count; ++i) {
|
||||||
const auto dstItem = reinterpret_cast<T*>(&m_data[i]);
|
const auto dstItem = reinterpret_cast<T *>(&m_data[i]);
|
||||||
const auto srcItem = reinterpret_cast<T*>(&src->m_data[i]);
|
const auto srcItem = reinterpret_cast<T *>(&src->m_data[i]);
|
||||||
*dstItem = std::move(*srcItem);
|
*dstItem = std::move(*srcItem);
|
||||||
}
|
}
|
||||||
*items = reinterpret_cast<T*>(m_data.data());
|
*items = reinterpret_cast<T*>(m_data.data());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
constexpr void deallocate(T *items, std::size_t cap) noexcept {
|
constexpr void deallocate(T *items, std::size_t cap) noexcept {
|
||||||
// small vector optimization cannot be done it constexpr, but it doesn't really matter in constexpr
|
// small vector optimization cannot be done it constexpr, but it doesn't really matter in constexpr
|
||||||
if (std::is_constant_evaluated() || (items && static_cast<void*>(items) != static_cast<void*>(m_data.data()))) {
|
if (std::is_constant_evaluated()) {
|
||||||
|
if (items && static_cast<void*>(items) != static_cast<void*>(m_data.data())) {
|
||||||
m_allocator.deallocate(items, cap);
|
m_allocator.deallocate(items, cap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
namespace nostalgia::core {
|
namespace nostalgia::core {
|
||||||
|
|
||||||
class KeelModule: public keel::Module {
|
static class: public keel::Module {
|
||||||
private:
|
private:
|
||||||
NostalgiaPaletteToPaletteV1Converter m_nostalgiaPaletteToPaletteV1Converter;
|
NostalgiaPaletteToPaletteV1Converter m_nostalgiaPaletteToPaletteV1Converter;
|
||||||
PaletteV1ToPaletteV2Converter m_paletteV1ToPaletteV2Converter;
|
PaletteV1ToPaletteV2Converter m_paletteV1ToPaletteV2Converter;
|
||||||
@ -62,11 +62,11 @@ class KeelModule: public keel::Module {
|
|||||||
oxRequire(hdr, keel::readAssetHeader(buff));
|
oxRequire(hdr, keel::readAssetHeader(buff));
|
||||||
auto const typeId = ox::buildTypeId(
|
auto const typeId = ox::buildTypeId(
|
||||||
hdr.clawHdr.typeName, hdr.clawHdr.typeVersion, hdr.clawHdr.typeParams);
|
hdr.clawHdr.typeName, hdr.clawHdr.typeVersion, hdr.clawHdr.typeParams);
|
||||||
if (typeId == ox::buildTypeId<TileSheetV1>() ||
|
if (typeId == ox::ModelTypeId_v<TileSheetV1> ||
|
||||||
typeId == ox::buildTypeId<TileSheetV2>() ||
|
typeId == ox::ModelTypeId_v<TileSheetV2> ||
|
||||||
typeId == ox::buildTypeId<TileSheetV3>() ||
|
typeId == ox::ModelTypeId_v<TileSheetV3> ||
|
||||||
typeId == ox::buildTypeId<TileSheetV4>()) {
|
typeId == ox::ModelTypeId_v<TileSheetV4>) {
|
||||||
oxReturnError(keel::convertBuffToBuff<core::CompactTileSheet>(
|
oxReturnError(keel::convertBuffToBuff<CompactTileSheet>(
|
||||||
ctx, buff, ox::ClawFormat::Metal).moveTo(buff));
|
ctx, buff, ox::ClawFormat::Metal).moveTo(buff));
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
@ -75,19 +75,18 @@ class KeelModule: public keel::Module {
|
|||||||
oxRequire(hdr, keel::readAssetHeader(buff));
|
oxRequire(hdr, keel::readAssetHeader(buff));
|
||||||
auto const typeId = ox::buildTypeId(
|
auto const typeId = ox::buildTypeId(
|
||||||
hdr.clawHdr.typeName, hdr.clawHdr.typeVersion, hdr.clawHdr.typeParams);
|
hdr.clawHdr.typeName, hdr.clawHdr.typeVersion, hdr.clawHdr.typeParams);
|
||||||
if (typeId == ox::buildTypeId<NostalgiaPalette>() ||
|
if (typeId == ox::ModelTypeId_v<NostalgiaPalette> ||
|
||||||
typeId == ox::buildTypeId<PaletteV1>()) {
|
typeId == ox::ModelTypeId_v<PaletteV1>) {
|
||||||
oxReturnError(keel::convertBuffToBuff<core::Palette>(
|
oxReturnError(keel::convertBuffToBuff<Palette>(
|
||||||
ctx, buff, ox::ClawFormat::Metal).moveTo(buff));
|
ctx, buff, ox::ClawFormat::Metal).moveTo(buff));
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
} mod;
|
||||||
|
|
||||||
static const KeelModule mod;
|
keel::Module const*keelModule() noexcept {
|
||||||
const keel::Module *keelModule() noexcept {
|
|
||||||
return &mod;
|
return &mod;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,6 +239,7 @@ static void initSpritesBufferset(Context &ctx) noexcept {
|
|||||||
glEnableVertexAttribArray(texCoordAttr);
|
glEnableVertexAttribArray(texCoordAttr);
|
||||||
glVertexAttribPointer(texCoordAttr, 2, GL_FLOAT, GL_FALSE, SpriteVertexVboRowLength * sizeof(float),
|
glVertexAttribPointer(texCoordAttr, 2, GL_FLOAT, GL_FALSE, SpriteVertexVboRowLength * sizeof(float),
|
||||||
std::bit_cast<void*>(uintptr_t{4 * sizeof(float)}));
|
std::bit_cast<void*>(uintptr_t{4 * sizeof(float)}));
|
||||||
|
glBindVertexArray(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void initBackgroundBufferset(
|
static void initBackgroundBufferset(
|
||||||
@ -272,6 +273,7 @@ static void initBackgroundBufferset(
|
|||||||
glVertexAttribPointer(
|
glVertexAttribPointer(
|
||||||
palBankAttr, 1, GL_FLOAT, GL_FALSE, BgVertexVboRowLength * sizeof(float),
|
palBankAttr, 1, GL_FLOAT, GL_FALSE, BgVertexVboRowLength * sizeof(float),
|
||||||
std::bit_cast<void*>(uintptr_t{6 * sizeof(float)}));
|
std::bit_cast<void*>(uintptr_t{6 * sizeof(float)}));
|
||||||
|
glBindVertexArray(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static glutils::GLTexture createTexture(
|
static glutils::GLTexture createTexture(
|
||||||
@ -301,6 +303,7 @@ static void drawBackground(CBB &cbb) noexcept {
|
|||||||
}
|
}
|
||||||
glBindTexture(GL_TEXTURE_2D, cbb.tex);
|
glBindTexture(GL_TEXTURE_2D, cbb.tex);
|
||||||
glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(cbb.elements.size()), GL_UNSIGNED_INT, nullptr);
|
glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(cbb.elements.size()), GL_UNSIGNED_INT, nullptr);
|
||||||
|
glBindVertexArray(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void drawBackgrounds(
|
static void drawBackgrounds(
|
||||||
@ -354,6 +357,7 @@ static void drawSprites(Context &ctx, ox::Size const&renderSz) noexcept {
|
|||||||
// draw
|
// draw
|
||||||
glBindTexture(GL_TEXTURE_2D, sb.tex);
|
glBindTexture(GL_TEXTURE_2D, sb.tex);
|
||||||
glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(sb.elements.size()), GL_UNSIGNED_INT, nullptr);
|
glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(sb.elements.size()), GL_UNSIGNED_INT, nullptr);
|
||||||
|
glBindVertexArray(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void loadPalette(
|
static void loadPalette(
|
||||||
|
@ -342,13 +342,14 @@ void TileSheetEditorImGui::drawTileSheet(ox::Vec2 const&fbSize) noexcept {
|
|||||||
} else if (m_view.updated()) {
|
} else if (m_view.updated()) {
|
||||||
m_view.ackUpdate();
|
m_view.ackUpdate();
|
||||||
}
|
}
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, m_framebuffer);
|
{
|
||||||
|
glutils::FrameBufferBind const frameBufferBind(m_framebuffer);
|
||||||
// clear screen and draw
|
// clear screen and draw
|
||||||
glViewport(0, 0, fbSizei.width, fbSizei.height);
|
glViewport(0, 0, fbSizei.width, fbSizei.height);
|
||||||
m_view.draw();
|
m_view.draw();
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
}
|
||||||
ImGui::Image(
|
ImGui::Image(
|
||||||
std::bit_cast<ImTextureID>(uintptr_t{m_framebuffer.color.id}),
|
ig::toImTextureID(m_framebuffer.color.id),
|
||||||
static_cast<ImVec2>(fbSize),
|
static_cast<ImVec2>(fbSize),
|
||||||
ImVec2(0, 1),
|
ImVec2(0, 1),
|
||||||
ImVec2(1, 0));
|
ImVec2(1, 0));
|
||||||
|
@ -14,6 +14,7 @@ namespace nostalgia::core {
|
|||||||
TileSheetEditorView::TileSheetEditorView(studio::StudioContext &sctx, ox::StringView path, studio::UndoStack &undoStack):
|
TileSheetEditorView::TileSheetEditorView(studio::StudioContext &sctx, ox::StringView path, studio::UndoStack &undoStack):
|
||||||
m_model(sctx, path, undoStack),
|
m_model(sctx, path, undoStack),
|
||||||
m_pixelsDrawer(m_model) {
|
m_pixelsDrawer(m_model) {
|
||||||
|
glBindVertexArray(0);
|
||||||
// build shaders
|
// build shaders
|
||||||
oxThrowError(m_pixelsDrawer.buildShader());
|
oxThrowError(m_pixelsDrawer.buildShader());
|
||||||
oxThrowError(m_pixelGridDrawer.buildShader());
|
oxThrowError(m_pixelGridDrawer.buildShader());
|
||||||
|
@ -160,7 +160,7 @@ auto transformRule(keel::Context &ctx, ox::Buffer &buff) noexcept -> ox::Error {
|
|||||||
oxRequire(hdr, readAssetHeader(buff));
|
oxRequire(hdr, readAssetHeader(buff));
|
||||||
const auto typeId = ox::buildTypeId(
|
const auto typeId = ox::buildTypeId(
|
||||||
hdr.clawHdr.typeName, hdr.clawHdr.typeVersion, hdr.clawHdr.typeParams);
|
hdr.clawHdr.typeName, hdr.clawHdr.typeVersion, hdr.clawHdr.typeParams);
|
||||||
if (typeId == ox::buildTypeId<From>()) {
|
if (typeId == ox::ModelTypeId_v<From>) {
|
||||||
oxReturnError(keel::convertBuffToBuff<To>(ctx, buff, fmt).moveTo(buff));
|
oxReturnError(keel::convertBuffToBuff<To>(ctx, buff, fmt).moveTo(buff));
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
|
@ -56,7 +56,7 @@ static ox::Error runApp(
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
ox::Error run(
|
static ox::Error run(
|
||||||
ox::CRStringView appName,
|
ox::CRStringView appName,
|
||||||
ox::CRStringView projectDataDir,
|
ox::CRStringView projectDataDir,
|
||||||
int,
|
int,
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
|
|
||||||
|
#include <ox/std/bit.hpp>
|
||||||
|
|
||||||
#include <turbine/context.hpp>
|
#include <turbine/context.hpp>
|
||||||
#include <studio/context.hpp>
|
#include <studio/context.hpp>
|
||||||
|
|
||||||
@ -15,6 +17,91 @@ namespace studio::ig {
|
|||||||
|
|
||||||
inline constexpr auto BtnSz = ImVec2{52, 22};
|
inline constexpr auto BtnSz = ImVec2{52, 22};
|
||||||
|
|
||||||
|
|
||||||
|
constexpr ImTextureID toImTextureID(ox::Unsigned_c auto id) noexcept
|
||||||
|
requires(sizeof(id) <= sizeof(ox::Uint<sizeof(ImTextureID)*8>)) {
|
||||||
|
return std::bit_cast<ImTextureID>(ox::Uint<sizeof(ImTextureID)*8>{id});
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
ox::Result<T> getDragDropPayload(ox::CStringView name) noexcept {
|
||||||
|
auto const payload = ImGui::AcceptDragDropPayload(name.c_str());
|
||||||
|
if (!payload) {
|
||||||
|
return OxError(1, "No drag/drop payload");
|
||||||
|
}
|
||||||
|
return ox::readClaw<T>(
|
||||||
|
reinterpret_cast<char const*>(payload->Data),
|
||||||
|
static_cast<size_t>(payload->DataSize));
|
||||||
|
}
|
||||||
|
|
||||||
|
ox::Error setDragDropPayload(ox::CStringView name, auto const &obj) noexcept {
|
||||||
|
oxRequire(buff, ox::writeClaw(obj, ox::ClawFormat::Metal));
|
||||||
|
ImGui::SetDragDropPayload(name.c_str(), buff.data(), buff.size());
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class DragDropSource {
|
||||||
|
private:
|
||||||
|
bool const m_active{};
|
||||||
|
public:
|
||||||
|
inline DragDropSource() noexcept:
|
||||||
|
m_active(ImGui::BeginDragDropSource()) {
|
||||||
|
}
|
||||||
|
inline ~DragDropSource() noexcept {
|
||||||
|
if (m_active) {
|
||||||
|
ImGui::EndDragDropSource();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
constexpr operator bool() const noexcept {
|
||||||
|
return m_active;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
inline auto dragDropSource(auto const&cb) noexcept {
|
||||||
|
if constexpr(ox::is_same_v<decltype(cb()), ox::Error>) {
|
||||||
|
if (ig::DragDropSource const tgt; tgt) [[unlikely]] {
|
||||||
|
return cb();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (ig::DragDropSource const tgt; tgt) [[unlikely]] {
|
||||||
|
cb();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class DragDropTarget {
|
||||||
|
private:
|
||||||
|
bool const m_active{};
|
||||||
|
public:
|
||||||
|
inline DragDropTarget() noexcept:
|
||||||
|
m_active(ImGui::BeginDragDropTarget()) {
|
||||||
|
}
|
||||||
|
inline ~DragDropTarget() noexcept {
|
||||||
|
if (m_active) {
|
||||||
|
ImGui::EndDragDropTarget();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
constexpr operator bool() const noexcept {
|
||||||
|
return m_active;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
inline auto dragDropTarget(auto const&cb) noexcept {
|
||||||
|
if constexpr(ox::is_same_v<decltype(cb()), ox::Error>) {
|
||||||
|
if (ig::DragDropTarget const tgt; tgt) [[unlikely]] {
|
||||||
|
return cb();
|
||||||
|
}
|
||||||
|
return ox::Error{};
|
||||||
|
} else {
|
||||||
|
if (ig::DragDropTarget const tgt; tgt) [[unlikely]] {
|
||||||
|
cb();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class ChildStackItem {
|
class ChildStackItem {
|
||||||
public:
|
public:
|
||||||
explicit ChildStackItem(ox::CStringView id, ImVec2 const&sz = {}) noexcept;
|
explicit ChildStackItem(ox::CStringView id, ImVec2 const&sz = {}) noexcept;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user