Compare commits
5 Commits
671b8edaad
...
release-d2
Author | SHA1 | Date | |
---|---|---|---|
1057099fcf | |||
17577b6e8b | |||
db442e2775 | |||
23cd50d29e | |||
28088d1ed1 |
24
deps/glutils/include/glutils/glutils.hpp
vendored
24
deps/glutils/include/glutils/glutils.hpp
vendored
@@ -89,7 +89,7 @@ struct GLObject: public Base {
|
||||
return id;
|
||||
}
|
||||
|
||||
constexpr operator GLuint const&() const noexcept {
|
||||
constexpr operator const GLuint&() const noexcept {
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ struct FrameBuffer {
|
||||
return fbo.id;
|
||||
}
|
||||
|
||||
constexpr operator GLuint const&() const noexcept {
|
||||
constexpr operator const GLuint&() const noexcept {
|
||||
return fbo.id;
|
||||
}
|
||||
|
||||
@@ -158,14 +158,14 @@ struct FrameBuffer {
|
||||
|
||||
class FrameBufferBind {
|
||||
private:
|
||||
static FrameBuffer const *s_activeFb;
|
||||
FrameBuffer const *m_restoreFb = nullptr;
|
||||
static const FrameBuffer *s_activeFb;
|
||||
const FrameBuffer *m_restoreFb = nullptr;
|
||||
public:
|
||||
explicit FrameBufferBind(FrameBuffer const &fb) noexcept;
|
||||
explicit FrameBufferBind(const FrameBuffer &fb) noexcept;
|
||||
~FrameBufferBind() noexcept;
|
||||
};
|
||||
|
||||
void bind(FrameBuffer const &fb) noexcept;
|
||||
void bind(const FrameBuffer &fb) noexcept;
|
||||
|
||||
struct ShaderVarSet {
|
||||
GLsizei len{};
|
||||
@@ -201,9 +201,9 @@ void setupShaderParams(
|
||||
|
||||
void setupShaderParams(GLProgram const&shader, ox::Vector<ShaderVarSet> const&vars) noexcept;
|
||||
|
||||
GLVertexArray generateVertexArrayObject() noexcept;
|
||||
glutils::GLVertexArray generateVertexArrayObject() noexcept;
|
||||
|
||||
GLBuffer generateBuffer() noexcept;
|
||||
glutils::GLBuffer generateBuffer() noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
FrameBuffer generateFrameBuffer(int width, int height) noexcept;
|
||||
@@ -218,10 +218,10 @@ void resizeInitFrameBuffer(FrameBuffer &fb, int width, int height) noexcept;
|
||||
void resizeInitFrameBuffer(FrameBuffer &fb, ox::Size const&sz) noexcept;
|
||||
|
||||
struct BufferSet {
|
||||
GLVertexArray vao;
|
||||
GLBuffer vbo;
|
||||
GLBuffer ebo;
|
||||
GLTexture tex;
|
||||
glutils::GLVertexArray vao;
|
||||
glutils::GLBuffer vbo;
|
||||
glutils::GLBuffer ebo;
|
||||
glutils::GLTexture tex;
|
||||
ox::Vector<float> vertices;
|
||||
ox::Vector<GLuint> elements;
|
||||
};
|
||||
|
47
deps/glutils/src/glutils.cpp
vendored
47
deps/glutils/src/glutils.cpp
vendored
@@ -46,9 +46,9 @@ template struct GLObject<deleteVertexArray>;
|
||||
template struct GLObject<deleteProgram>;
|
||||
template struct GLObject<deleteShader>;
|
||||
|
||||
FrameBuffer const *FrameBufferBind::s_activeFb = nullptr;
|
||||
const FrameBuffer *FrameBufferBind::s_activeFb = nullptr;
|
||||
|
||||
FrameBufferBind::FrameBufferBind(FrameBuffer const &fb) noexcept: m_restoreFb(s_activeFb) {
|
||||
FrameBufferBind::FrameBufferBind(const FrameBuffer &fb) noexcept: m_restoreFb(s_activeFb) {
|
||||
s_activeFb = &fb;
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fb);
|
||||
glViewport(0, 0, fb.width, fb.height);
|
||||
@@ -64,15 +64,15 @@ FrameBufferBind::~FrameBufferBind() noexcept {
|
||||
}
|
||||
}
|
||||
|
||||
void bind(FrameBuffer const &fb) noexcept {
|
||||
void bind(const FrameBuffer &fb) noexcept {
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fb);
|
||||
glViewport(0, 0, fb.width, fb.height);
|
||||
}
|
||||
|
||||
|
||||
static ox::Result<GLShader> buildShader(
|
||||
GLuint const shaderType,
|
||||
GLchar const *src,
|
||||
GLuint shaderType,
|
||||
const GLchar *src,
|
||||
ox::StringViewCR shaderName) noexcept {
|
||||
GLShader shader(glCreateShader(shaderType));
|
||||
glShaderSource(shader, 1, &src, nullptr);
|
||||
@@ -162,30 +162,16 @@ FrameBuffer generateFrameBuffer(int width, int height) noexcept {
|
||||
// color texture
|
||||
glGenTextures(1, &fb.color.id);
|
||||
glBindTexture(GL_TEXTURE_2D, fb.color);
|
||||
glTexImage2D(
|
||||
GL_TEXTURE_2D,
|
||||
0,
|
||||
GL_RGB,
|
||||
width,
|
||||
height,
|
||||
0,
|
||||
GL_RGB,
|
||||
GL_UNSIGNED_BYTE,
|
||||
nullptr);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, nullptr);
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
glFramebufferTexture2D(
|
||||
GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, fb.color, 0);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, fb.color, 0);
|
||||
// depth texture
|
||||
glGenRenderbuffers(1, &fb.depth.id);
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, fb.depth);
|
||||
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height);
|
||||
glFramebufferRenderbuffer(
|
||||
GL_FRAMEBUFFER,
|
||||
GL_DEPTH_STENCIL_ATTACHMENT,
|
||||
GL_RENDERBUFFER,
|
||||
fb.depth);
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, fb.depth);
|
||||
// verify FBO
|
||||
oxAssert(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE, "Frame Buffer is incomplete");
|
||||
// restore primary FB
|
||||
@@ -203,16 +189,7 @@ void resizeFrameBuffer(FrameBuffer &fb, int width, int height) noexcept {
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fb);
|
||||
// color texture
|
||||
glBindTexture(GL_TEXTURE_2D, fb.color);
|
||||
glTexImage2D(
|
||||
GL_TEXTURE_2D,
|
||||
0,
|
||||
GL_RGB,
|
||||
width,
|
||||
height,
|
||||
0,
|
||||
GL_RGB,
|
||||
GL_UNSIGNED_BYTE,
|
||||
nullptr);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, nullptr);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
// depth texture
|
||||
@@ -224,7 +201,7 @@ void resizeFrameBuffer(FrameBuffer &fb, int width, int height) noexcept {
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, 0);
|
||||
}
|
||||
|
||||
void resizeInitFrameBuffer(FrameBuffer &fb, int const width, int const height) noexcept {
|
||||
void resizeInitFrameBuffer(FrameBuffer &fb, int width, int height) noexcept {
|
||||
if (!fb) {
|
||||
fb = generateFrameBuffer(width, height);
|
||||
return;
|
||||
@@ -237,13 +214,13 @@ void resizeInitFrameBuffer(FrameBuffer &fb, ox::Size const &sz) noexcept {
|
||||
}
|
||||
|
||||
void sendVbo(BufferSet const&bs) noexcept {
|
||||
auto const bufferSize = static_cast<GLsizeiptr>(sizeof(decltype(bs.vertices)::value_type) * bs.vertices.size());
|
||||
const auto bufferSize = static_cast<GLsizeiptr>(sizeof(decltype(bs.vertices)::value_type) * bs.vertices.size());
|
||||
glBindBuffer(GL_ARRAY_BUFFER, bs.vbo);
|
||||
glBufferData(GL_ARRAY_BUFFER, bufferSize, bs.vertices.data(), GL_DYNAMIC_DRAW);
|
||||
}
|
||||
|
||||
void sendEbo(BufferSet const&bs) noexcept {
|
||||
auto const bufferSize = static_cast<GLsizeiptr>(sizeof(decltype(bs.elements)::value_type) * bs.elements.size());
|
||||
const auto bufferSize = static_cast<GLsizeiptr>(sizeof(decltype(bs.elements)::value_type) * bs.elements.size());
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bs.ebo);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, bufferSize, bs.elements.data(), GL_STATIC_DRAW);
|
||||
}
|
||||
|
17
deps/ox/src/ox/std/stringliteral.hpp
vendored
17
deps/ox/src/ox/std/stringliteral.hpp
vendored
@@ -16,28 +16,35 @@ namespace ox {
|
||||
* StringLiteral is used for functions that want to ensure that they are taking
|
||||
* string literals, and not strings outside of the data section of the program
|
||||
* that might get deleted.
|
||||
* This type cannot force you to use it correctly, so don't give it something
|
||||
* that is not a literal.
|
||||
* If you do this:
|
||||
* StringLiteral(str.c_str())
|
||||
* the resulting segfault is on you.
|
||||
*/
|
||||
class StringLiteral: public detail::BaseStringView {
|
||||
public:
|
||||
consteval StringLiteral() noexcept = default;
|
||||
constexpr StringLiteral() noexcept = default;
|
||||
|
||||
constexpr StringLiteral(StringLiteral const&sv) noexcept = default;
|
||||
|
||||
consteval explicit StringLiteral(std::nullptr_t) noexcept {}
|
||||
constexpr explicit StringLiteral(std::nullptr_t) noexcept {}
|
||||
|
||||
consteval explicit StringLiteral(char const *str, std::size_t const len) noexcept: BaseStringView{str, len} {}
|
||||
constexpr explicit StringLiteral(const char *str, std::size_t len) noexcept: BaseStringView(str, len) {}
|
||||
|
||||
OX_ALLOW_UNSAFE_BUFFERS_BEGIN
|
||||
consteval explicit StringLiteral(char const *str) noexcept: StringLiteral{str, ox::strlen(str)} {}
|
||||
constexpr explicit StringLiteral(char const *str) noexcept: StringLiteral(str, ox::strlen(str)) {}
|
||||
OX_ALLOW_UNSAFE_BUFFERS_END
|
||||
|
||||
constexpr StringLiteral &operator=(StringLiteral const&other) noexcept {
|
||||
if (&other != this) {
|
||||
set(other.data(), other.len());
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr char const *c_str() const noexcept {
|
||||
constexpr const char *c_str() const noexcept {
|
||||
return data();
|
||||
}
|
||||
|
||||
|
2
deps/teagba/include/teagba/gfx.hpp
vendored
2
deps/teagba/include/teagba/gfx.hpp
vendored
@@ -37,7 +37,7 @@ struct OX_ALIGN8 GbaSpriteAttrUpdate {
|
||||
|
||||
GbaSpriteAttrUpdate &spriteAttr(size_t i) noexcept;
|
||||
|
||||
void addSpriteUpdate(GbaSpriteAttrUpdate const &upd) noexcept;
|
||||
void addSpriteUpdate(const GbaSpriteAttrUpdate &upd) noexcept;
|
||||
|
||||
void applySpriteUpdates() noexcept;
|
||||
|
||||
|
4
deps/teagba/src/cstartup.cpp
vendored
4
deps/teagba/src/cstartup.cpp
vendored
@@ -26,7 +26,7 @@ extern void (*__preinit_array_end[]) (void);
|
||||
extern void (*__init_array_start[]) (void);
|
||||
extern void (*__init_array_end[]) (void);
|
||||
|
||||
int main(int argc, char const **argv);
|
||||
int main(int argc, const char **argv);
|
||||
|
||||
extern "C" {
|
||||
|
||||
@@ -50,7 +50,7 @@ void __libc_init_array() {
|
||||
}
|
||||
|
||||
int c_start() {
|
||||
char const *args[2] = {"", "rom.oxfs"};
|
||||
const char *args[2] = {"", "rom.oxfs"};
|
||||
ox::heapmgr::initHeap(HEAP_BEGIN, HEAP_END);
|
||||
mgba::initConsole();
|
||||
#pragma GCC diagnostic push
|
||||
|
2
deps/teagba/src/gfx.cpp
vendored
2
deps/teagba/src/gfx.cpp
vendored
@@ -16,7 +16,7 @@ GbaSpriteAttrUpdate &spriteAttr(size_t i) noexcept {
|
||||
return g_spriteBuffer[i];
|
||||
}
|
||||
|
||||
void addSpriteUpdate(GbaSpriteAttrUpdate const &upd) noexcept {
|
||||
void addSpriteUpdate(const GbaSpriteAttrUpdate &upd) noexcept {
|
||||
const auto ie = REG_IE; // disable vblank interrupt handler
|
||||
REG_IE = REG_IE & static_cast<uint16_t>(~teagba::Int_vblank); // disable vblank interrupt handler
|
||||
g_spriteBuffer[upd.idx] = upd;
|
||||
|
@@ -19,10 +19,10 @@ using Color32 = uint32_t;
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr Color32 toColor32(Color16 nc) noexcept {
|
||||
auto const r = static_cast<Color32>(((nc & 0b0000000000011111) >> 0) * 8);
|
||||
auto const g = static_cast<Color32>(((nc & 0b0000001111100000) >> 5) * 8);
|
||||
auto const b = static_cast<Color32>(((nc & 0b0111110000000000) >> 10) * 8);
|
||||
auto const a = static_cast<Color32>(255);
|
||||
const auto r = static_cast<Color32>(((nc & 0b0000000000011111) >> 0) * 8);
|
||||
const auto g = static_cast<Color32>(((nc & 0b0000001111100000) >> 5) * 8);
|
||||
const auto b = static_cast<Color32>(((nc & 0b0111110000000000) >> 10) * 8);
|
||||
const auto a = static_cast<Color32>(255);
|
||||
return r | (g << 8) | (b << 16) | (a << 24);
|
||||
}
|
||||
|
||||
|
@@ -12,18 +12,8 @@ constexpr auto TileWidth = 8;
|
||||
constexpr auto TileHeight = 8;
|
||||
constexpr auto PixelsPerTile = TileWidth * TileHeight;
|
||||
|
||||
constexpr ox::StringLiteral FileExt_ng{"ng"};
|
||||
constexpr ox::StringLiteral FileExt_nts{"nts"};
|
||||
constexpr ox::StringLiteral FileExt_npal{"npal"};
|
||||
|
||||
constexpr ox::Array<ox::StringLiteral, 2> FileExts_TileSheet{
|
||||
FileExt_nts,
|
||||
FileExt_ng,
|
||||
};
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr bool isTileSheet(ox::StringViewCR path) noexcept {
|
||||
return endsWith(path, FileExt_nts) || endsWith(path, FileExt_ng);
|
||||
}
|
||||
constexpr ox::StringLiteral FileExt_ng("ng");
|
||||
constexpr ox::StringLiteral FileExt_nts("nts");
|
||||
constexpr ox::StringLiteral FileExt_npal("npal");
|
||||
|
||||
}
|
||||
|
@@ -114,10 +114,10 @@ struct InitParams {
|
||||
ox::Result<ox::UPtr<Context>> init(turbine::Context &tctx, InitParams const¶ms = {}) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
int tileColumns(Context const&) noexcept;
|
||||
int tileColumns(Context&) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
int tileRows(Context const&) noexcept;
|
||||
int tileRows(Context&) noexcept;
|
||||
|
||||
ox::Error loadBgPalette(
|
||||
Context &ctx,
|
||||
|
@@ -12,15 +12,15 @@ namespace nostalgia::gfx {
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr std::size_t ptToIdx(int x, int y, int c, int scale = 1) noexcept {
|
||||
auto const tileWidth = TileWidth * scale;
|
||||
auto const tileHeight = TileHeight * scale;
|
||||
auto const pixelsPerTile = tileWidth * tileHeight;
|
||||
auto const colLength = static_cast<std::size_t>(pixelsPerTile);
|
||||
auto const rowLength = static_cast<std::size_t>(static_cast<std::size_t>(c / tileWidth) * colLength);
|
||||
auto const colStart = static_cast<std::size_t>(colLength * static_cast<std::size_t>(x / tileWidth));
|
||||
auto const rowStart = static_cast<std::size_t>(rowLength * static_cast<std::size_t>(y / tileHeight));
|
||||
auto const colOffset = static_cast<std::size_t>(x % tileWidth);
|
||||
auto const rowOffset = static_cast<std::size_t>((y % tileHeight) * tileHeight);
|
||||
const auto tileWidth = TileWidth * scale;
|
||||
const auto tileHeight = TileHeight * scale;
|
||||
const auto pixelsPerTile = tileWidth * tileHeight;
|
||||
const auto colLength = static_cast<std::size_t>(pixelsPerTile);
|
||||
const auto rowLength = static_cast<std::size_t>(static_cast<std::size_t>(c / tileWidth) * colLength);
|
||||
const auto colStart = static_cast<std::size_t>(colLength * static_cast<std::size_t>(x / tileWidth));
|
||||
const auto rowStart = static_cast<std::size_t>(rowLength * static_cast<std::size_t>(y / tileHeight));
|
||||
const auto colOffset = static_cast<std::size_t>(x % tileWidth);
|
||||
const auto rowOffset = static_cast<std::size_t>((y % tileHeight) * tileHeight);
|
||||
return static_cast<std::size_t>(colStart + colOffset + rowStart + rowOffset);
|
||||
}
|
||||
|
||||
@@ -31,19 +31,19 @@ constexpr std::size_t ptToIdx(const ox::Point &pt, int c, int scale = 1) noexcep
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr ox::Point idxToPt(int i, int c, int scale = 1) noexcept {
|
||||
auto const tileWidth = TileWidth * scale;
|
||||
auto const tileHeight = TileHeight * scale;
|
||||
auto const pixelsPerTile = tileWidth * tileHeight;
|
||||
const auto tileWidth = TileWidth * scale;
|
||||
const auto tileHeight = TileHeight * scale;
|
||||
const auto pixelsPerTile = tileWidth * tileHeight;
|
||||
// prevent divide by zeros
|
||||
if (!c) {
|
||||
++c;
|
||||
}
|
||||
auto const t = i / pixelsPerTile; // tile number
|
||||
auto const iti = i % pixelsPerTile; // in tile index
|
||||
auto const tc = t % c; // tile column
|
||||
auto const tr = t / c; // tile row
|
||||
auto const itx = iti % tileWidth; // in tile x
|
||||
auto const ity = iti / tileHeight; // in tile y
|
||||
const auto t = i / pixelsPerTile; // tile number
|
||||
const auto iti = i % pixelsPerTile; // in tile index
|
||||
const auto tc = t % c; // tile column
|
||||
const auto tr = t / c; // tile row
|
||||
const auto itx = iti % tileWidth; // in tile x
|
||||
const auto ity = iti / tileHeight; // in tile y
|
||||
return {
|
||||
itx + tc * tileWidth,
|
||||
ity + tr * tileHeight,
|
||||
|
@@ -6,28 +6,6 @@
|
||||
|
||||
#include <studio/studio.hpp>
|
||||
|
||||
#include "tilesheet.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
|
||||
inline void navigateToTileSheet(
|
||||
studio::Context &ctx, ox::StringParam path, SubSheetId const subsheetId) noexcept {
|
||||
studio::navigateTo(ctx, std::move(path), ox::intToStr(subsheetId));
|
||||
}
|
||||
|
||||
inline void navigateToPalette(studio::Context &ctx, ox::StringParam path) noexcept {
|
||||
studio::navigateTo(ctx, std::move(path));
|
||||
}
|
||||
|
||||
inline void navigateToPalette(
|
||||
studio::Context &ctx,
|
||||
ox::StringParam path,
|
||||
size_t const colorIdx,
|
||||
size_t const palPage) noexcept {
|
||||
studio::navigateTo(
|
||||
ctx,
|
||||
std::move(path),
|
||||
ox::sfmt("{};{}", colorIdx, palPage));
|
||||
}
|
||||
namespace nostalgia::core {
|
||||
|
||||
}
|
||||
|
@@ -246,11 +246,7 @@ ox::Error loadSpriteTileSheet(
|
||||
}
|
||||
|
||||
void setBgTile(
|
||||
Context &ctx,
|
||||
uint_t const bgIdx,
|
||||
int const column,
|
||||
int const row,
|
||||
BgTile const &tile) noexcept {
|
||||
Context &ctx, uint_t const bgIdx, int const column, int const row, BgTile const&tile) noexcept {
|
||||
auto const tileIdx = static_cast<std::size_t>(row * tileColumns(ctx) + column);
|
||||
// see Tonc 9.3
|
||||
MEM_BG_MAP[bgIdx][tileIdx] =
|
||||
@@ -279,7 +275,7 @@ bool bgStatus(Context&, unsigned const bg) noexcept {
|
||||
|
||||
void setBgStatus(Context&, unsigned const bg, bool const status) noexcept {
|
||||
constexpr auto Bg0Status = 8;
|
||||
auto const mask = static_cast<uint32_t>(status) << (Bg0Status + bg);
|
||||
const auto mask = static_cast<uint32_t>(status) << (Bg0Status + bg);
|
||||
REG_DISPCTL = REG_DISPCTL | ((REG_DISPCTL & ~mask) | mask);
|
||||
}
|
||||
|
||||
@@ -290,7 +286,7 @@ void setBgBpp(Context&, unsigned const bgIdx, unsigned const bpp) noexcept {
|
||||
|
||||
void setBgCbb(Context &ctx, unsigned const bgIdx, unsigned const cbbIdx) noexcept {
|
||||
auto &bgCtl = regBgCtl(bgIdx);
|
||||
auto const &cbbData = ctx.cbbData[cbbIdx];
|
||||
const auto &cbbData = ctx.cbbData[cbbIdx];
|
||||
teagba::bgSetBpp(bgCtl, cbbData.bpp);
|
||||
teagba::bgSetCbb(bgCtl, cbbIdx);
|
||||
}
|
||||
@@ -345,13 +341,13 @@ uint_t spriteCount(Context const &) noexcept {
|
||||
|
||||
namespace ox {
|
||||
|
||||
void panic(char const *file, int line, char const *panicMsg, ox::Error const &err) noexcept {
|
||||
void panic(const char *file, int line, const char *panicMsg, ox::Error const&err) noexcept {
|
||||
using namespace nostalgia::gfx;
|
||||
// reset heap to make sure we have enough memory to allocate context data
|
||||
OX_ALLOW_UNSAFE_BUFFERS_BEGIN
|
||||
auto const heapBegin = reinterpret_cast<char*>(MEM_EWRAM_BEGIN);
|
||||
auto const heapSz = (MEM_EWRAM_END - MEM_EWRAM_BEGIN) / 2;
|
||||
auto const heapEnd = reinterpret_cast<char*>(MEM_EWRAM_BEGIN + heapSz);
|
||||
const auto heapBegin = reinterpret_cast<char*>(MEM_EWRAM_BEGIN);
|
||||
const auto heapSz = (MEM_EWRAM_END - MEM_EWRAM_BEGIN) / 2;
|
||||
const auto heapEnd = reinterpret_cast<char*>(MEM_EWRAM_BEGIN + heapSz);
|
||||
ox::heapmgr::initHeap(heapBegin, heapEnd);
|
||||
OX_ALLOW_UNSAFE_BUFFERS_END
|
||||
auto tctx = turbine::init(keel::loadRomFs("").unwrap(), "Nostalgia").unwrap();
|
||||
|
@@ -287,7 +287,7 @@ static void initSpriteBufferObjects(Context const &ctx, glutils::BufferSet &bs)
|
||||
static void initBackgroundBufferObjects(glutils::BufferSet &bs) noexcept {
|
||||
for (auto x = 0u; x < TileColumns; ++x) {
|
||||
for (auto y = 0u; y < TileRows; ++y) {
|
||||
auto const i = bgVertexRow(x, y);
|
||||
const auto i = bgVertexRow(x, y);
|
||||
auto const vbo = ox::Span{bs.vertices}
|
||||
+ i * static_cast<std::size_t>(BgVertexVboLength);
|
||||
auto const ebo = ox::Span{bs.elements}
|
||||
@@ -428,19 +428,19 @@ static void drawBackgrounds(
|
||||
ox::Size const&renderSz) noexcept {
|
||||
// load background shader and its uniforms
|
||||
glUseProgram(ctx.bgShader);
|
||||
auto const uniformSrcImgSz = glGetUniformLocation(ctx.bgShader, "fSrcImgSz");
|
||||
auto const uniformXScale = static_cast<GLint>(glGetUniformLocation(ctx.bgShader, "vXScale"));
|
||||
auto const uniformTileHeight = static_cast<GLint>(glGetUniformLocation(ctx.bgShader, "vTileHeight"));
|
||||
auto const uniformBgIdx = static_cast<GLint>(glGetUniformLocation(ctx.bgShader, "vBgIdx"));
|
||||
auto const [wi, hi] = renderSz;
|
||||
auto const wf = static_cast<float>(wi);
|
||||
auto const hf = static_cast<float>(hi);
|
||||
const auto uniformSrcImgSz = glGetUniformLocation(ctx.bgShader, "fSrcImgSz");
|
||||
const auto uniformXScale = static_cast<GLint>(glGetUniformLocation(ctx.bgShader, "vXScale"));
|
||||
const auto uniformTileHeight = static_cast<GLint>(glGetUniformLocation(ctx.bgShader, "vTileHeight"));
|
||||
const auto uniformBgIdx = static_cast<GLint>(glGetUniformLocation(ctx.bgShader, "vBgIdx"));
|
||||
const auto [wi, hi] = renderSz;
|
||||
const auto wf = static_cast<float>(wi);
|
||||
const auto hf = static_cast<float>(hi);
|
||||
glUniform1f(uniformXScale, hf / wf);
|
||||
auto bgIdx = 0.f;
|
||||
for (auto const &bg : ctx.backgrounds) {
|
||||
for (const auto &bg : ctx.backgrounds) {
|
||||
if (bg.enabled) {
|
||||
auto &cbb = ctx.cbbs[bg.cbbIdx];
|
||||
auto const tileRows = cbb.tex.height / (TileHeight * Scale);
|
||||
const auto tileRows = cbb.tex.height / (TileHeight * Scale);
|
||||
glUniform1f(uniformTileHeight, 1.0f / static_cast<float>(tileRows));
|
||||
glUniform2f(
|
||||
uniformSrcImgSz,
|
||||
@@ -456,11 +456,11 @@ static void drawBackgrounds(
|
||||
static void drawSprites(Context &ctx, ox::Size const&renderSz) noexcept {
|
||||
glUseProgram(ctx.spriteShader);
|
||||
auto &sb = ctx.spriteBlocks;
|
||||
auto const uniformXScale = glGetUniformLocation(ctx.bgShader, "vXScale");
|
||||
auto const uniformTileHeight = glGetUniformLocation(ctx.spriteShader, "vTileHeight");
|
||||
auto const [wi, hi] = renderSz;
|
||||
auto const wf = static_cast<float>(wi);
|
||||
auto const hf = static_cast<float>(hi);
|
||||
const auto uniformXScale = glGetUniformLocation(ctx.bgShader, "vXScale");
|
||||
const auto uniformTileHeight = glGetUniformLocation(ctx.spriteShader, "vTileHeight");
|
||||
const auto [wi, hi] = renderSz;
|
||||
const auto wf = static_cast<float>(wi);
|
||||
const auto hf = static_cast<float>(hi);
|
||||
glUniform1f(uniformXScale, hf / wf);
|
||||
// update vbo
|
||||
glBindVertexArray(sb.vao);
|
||||
@@ -469,7 +469,7 @@ static void drawSprites(Context &ctx, ox::Size const&renderSz) noexcept {
|
||||
glutils::sendVbo(sb);
|
||||
}
|
||||
// set vTileHeight uniform
|
||||
auto const tileRows = sb.tex.height / (TileHeight * Scale);
|
||||
const auto tileRows = sb.tex.height / (TileHeight * Scale);
|
||||
glUniform1f(uniformTileHeight, 1.0f / static_cast<float>(tileRows));
|
||||
// draw
|
||||
glBindTexture(GL_TEXTURE_2D, sb.tex);
|
||||
@@ -493,7 +493,7 @@ static void loadPalette(
|
||||
// make first color transparent
|
||||
palette[palOffset + 3] = 0;
|
||||
glUseProgram(shaderPgrm);
|
||||
auto const uniformPalette = static_cast<GLint>(glGetUniformLocation(shaderPgrm, "fPalette"));
|
||||
const auto uniformPalette = static_cast<GLint>(glGetUniformLocation(shaderPgrm, "fPalette"));
|
||||
glUniform4fv(uniformPalette, ColorCnt, palette.data());
|
||||
}
|
||||
|
||||
@@ -526,12 +526,12 @@ static void setSprite(
|
||||
auto const uY = static_cast<int>(s.y + 8) % 255 - 8;
|
||||
oxAssert(1 < ctx.spriteBlocks.vertices.size(), "vbo overflow");
|
||||
oxAssert(1 < ctx.spriteBlocks.elements.size(), "ebo overflow");
|
||||
auto const spriteVboSz = ctx.blocksPerSprite * renderer::SpriteVertexVboLength;
|
||||
auto const spriteEboSz = ctx.blocksPerSprite * renderer::SpriteVertexEboLength;
|
||||
const auto spriteVboSz = ctx.blocksPerSprite * renderer::SpriteVertexVboLength;
|
||||
const auto spriteEboSz = ctx.blocksPerSprite * renderer::SpriteVertexEboLength;
|
||||
auto const vboBase = spriteVboSz * idx;
|
||||
auto const eboBase = spriteEboSz * idx;
|
||||
auto i = 0u;
|
||||
auto const set = [&](int xIt, int yIt, bool enabled) {
|
||||
const auto set = [&](int xIt, int yIt, bool enabled) {
|
||||
auto const fX = static_cast<float>(uX + xIt * 8) / 8;
|
||||
auto const fY = static_cast<float>(uY + yIt * 8) / 8;
|
||||
auto const vboIdx = vboBase + renderer::SpriteVertexVboLength * i;
|
||||
@@ -576,10 +576,10 @@ static void setSprite(
|
||||
|
||||
ox::Result<ox::UPtr<Context>> init(turbine::Context &tctx, InitParams const¶ms) noexcept {
|
||||
auto ctx = ox::make_unique<Context>(tctx, params);
|
||||
auto const bgVshad = ox::sfmt(renderer::bgvshadTmpl, gl::GlslVersion);
|
||||
auto const bgFshad = ox::sfmt(renderer::bgfshadTmpl, gl::GlslVersion);
|
||||
auto const spriteVshad = ox::sfmt(renderer::spritevshadTmpl, gl::GlslVersion);
|
||||
auto const spriteFshad = ox::sfmt(renderer::spritefshadTmpl, gl::GlslVersion);
|
||||
const auto bgVshad = ox::sfmt(renderer::bgvshadTmpl, gl::GlslVersion);
|
||||
const auto bgFshad = ox::sfmt(renderer::bgfshadTmpl, gl::GlslVersion);
|
||||
const auto spriteVshad = ox::sfmt(renderer::spritevshadTmpl, gl::GlslVersion);
|
||||
const auto spriteFshad = ox::sfmt(renderer::spritefshadTmpl, gl::GlslVersion);
|
||||
OX_RETURN_ERROR(glutils::buildShaderProgram(bgVshad, bgFshad).moveTo(ctx->bgShader));
|
||||
OX_RETURN_ERROR(
|
||||
glutils::buildShaderProgram(spriteVshad, spriteFshad).moveTo(ctx->spriteShader));
|
||||
@@ -603,12 +603,12 @@ struct TileSheetData {
|
||||
}
|
||||
};
|
||||
|
||||
static ox::Result<TileSheetData> normalizeTileSheet
|
||||
(CompactTileSheet const&ts) noexcept {
|
||||
static ox::Result<TileSheetData> normalizeTileSheet(
|
||||
CompactTileSheet const&ts) noexcept {
|
||||
const uint_t bytesPerTile = ts.bpp == 8 ? PixelsPerTile : PixelsPerTile / 2;
|
||||
auto const tiles = ts.pixels.size() / bytesPerTile;
|
||||
const auto tiles = ts.pixels.size() / bytesPerTile;
|
||||
constexpr int width = 8;
|
||||
int const height = 8 * static_cast<int>(tiles);
|
||||
const int height = 8 * static_cast<int>(tiles);
|
||||
ox::Vector<uint32_t> pixels;
|
||||
if (bytesPerTile == 64) { // 8 BPP
|
||||
pixels.resize(ts.pixels.size());
|
||||
@@ -779,13 +779,13 @@ void setBgTile(
|
||||
"nostalgia.gfx.setBgTile",
|
||||
"bgIdx: {}, column: {}, row: {}, tile: {}, palBank: {}",
|
||||
bgIdx, column, row, tile.tileIdx, tile.palBank);
|
||||
auto const z = static_cast<uint_t>(bgIdx);
|
||||
auto const y = static_cast<uint_t>(row);
|
||||
auto const x = static_cast<uint_t>(column);
|
||||
auto const i = renderer::bgVertexRow(x, y);
|
||||
const auto z = static_cast<uint_t>(bgIdx);
|
||||
const auto y = static_cast<uint_t>(row);
|
||||
const auto x = static_cast<uint_t>(column);
|
||||
const auto i = renderer::bgVertexRow(x, y);
|
||||
auto &cbb = ctx.cbbs[z];
|
||||
auto const vbo = ox::Span{cbb.vertices} + i * renderer::BgVertexVboLength;
|
||||
auto const ebo = ox::Span{cbb.elements} + i * renderer::BgVertexEboLength;
|
||||
const auto vbo = ox::Span{cbb.vertices} + i * renderer::BgVertexVboLength;
|
||||
const auto ebo = ox::Span{cbb.elements} + i * renderer::BgVertexEboLength;
|
||||
auto &bg = ctx.backgrounds[bgIdx];
|
||||
renderer::setTileBufferObject(
|
||||
static_cast<uint_t>(i * renderer::BgVertexVboRows),
|
||||
|
@@ -10,11 +10,11 @@ namespace nostalgia::gfx {
|
||||
constexpr auto GbaTileColumns = 32;
|
||||
constexpr auto GbaTileRows = 32;
|
||||
|
||||
int tileColumns(Context const&) noexcept {
|
||||
int tileColumns(Context&) noexcept {
|
||||
return GbaTileColumns;
|
||||
}
|
||||
|
||||
int tileRows(Context const&) noexcept {
|
||||
int tileRows(Context&) noexcept {
|
||||
return GbaTileRows;
|
||||
}
|
||||
|
||||
|
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <keel/typeconv.hpp>
|
||||
|
||||
#include <nostalgia/gfx/context.hpp>
|
||||
#include <nostalgia/gfx/palette.hpp>
|
||||
#include <nostalgia/gfx/tilesheet.hpp>
|
||||
|
||||
|
@@ -30,7 +30,7 @@ static class: public studio::Module {
|
||||
}
|
||||
} const mod;
|
||||
|
||||
studio::Module const *studioModule() noexcept {
|
||||
const studio::Module *studioModule() noexcept {
|
||||
return &mod;
|
||||
}
|
||||
|
||||
|
@@ -48,7 +48,7 @@ CutPasteCommand::CutPasteCommand(
|
||||
|
||||
ox::Error CutPasteCommand::redo() noexcept {
|
||||
auto &subsheet = getSubSheet(m_img, m_subSheetIdx);
|
||||
for (auto const &c : m_changes) {
|
||||
for (const auto &c : m_changes) {
|
||||
subsheet.pixels[c.idx] = static_cast<uint8_t>(c.newPalIdx);
|
||||
}
|
||||
return {};
|
||||
@@ -56,7 +56,7 @@ ox::Error CutPasteCommand::redo() noexcept {
|
||||
|
||||
ox::Error CutPasteCommand::undo() noexcept {
|
||||
auto &subsheet = getSubSheet(m_img, m_subSheetIdx);
|
||||
for (auto const &c : m_changes) {
|
||||
for (const auto &c : m_changes) {
|
||||
subsheet.pixels[c.idx] = static_cast<uint8_t>(c.oldPalIdx);
|
||||
}
|
||||
return {};
|
||||
|
@@ -9,8 +9,6 @@
|
||||
#include <keel/media.hpp>
|
||||
#include <studio/studio.hpp>
|
||||
|
||||
#include <nostalgia/gfx/studio.hpp>
|
||||
|
||||
#include "tilesheeteditor-imgui.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
@@ -578,10 +576,10 @@ void TileSheetEditorImGui::drawPaletteMenu() noexcept {
|
||||
m_view.setPalIdx(i);
|
||||
}
|
||||
if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(0)) {
|
||||
navigateToPalette(
|
||||
studio::navigateTo(
|
||||
m_sctx,
|
||||
m_model.palPath(),
|
||||
i, m_model.palettePage());
|
||||
ox::sfmt("{};{}", i, m_model.palettePage()));
|
||||
}
|
||||
// Column: color RGB
|
||||
ImGui::TableNextColumn();
|
||||
|
@@ -92,7 +92,7 @@ void TileSheetEditorView::clickFill(ox::Vec2 const &paneSize, ox::Vec2 const &cl
|
||||
m_model.fill(pt, static_cast<uint8_t>(m_palIdx));
|
||||
}
|
||||
|
||||
void TileSheetEditorView::releaseMouseButton(TileSheetTool const tool) noexcept {
|
||||
void TileSheetEditorView::releaseMouseButton(TileSheetTool tool) noexcept {
|
||||
switch (tool) {
|
||||
case TileSheetTool::Draw:
|
||||
case TileSheetTool::Fill:
|
||||
@@ -135,7 +135,7 @@ void TileSheetEditorView::initView() noexcept {
|
||||
|
||||
ox::Point TileSheetEditorView::clickPoint(ox::Vec2 const&paneSize, ox::Vec2 const&clickPos) const noexcept {
|
||||
auto [x, y] = clickPos;
|
||||
auto const pixDrawSz = m_pixelsDrawer.pixelSize(paneSize);
|
||||
const auto pixDrawSz = m_pixelsDrawer.pixelSize(paneSize);
|
||||
x /= paneSize.x;
|
||||
y /= paneSize.y;
|
||||
x += -m_scrollOffset.x / 2;
|
||||
|
@@ -73,8 +73,7 @@ class TileSheetGrid {
|
||||
void update(ox::Vec2 const&paneSize, TileSheet::SubSheet const&subsheet) noexcept;
|
||||
|
||||
private:
|
||||
static void setBufferObject(
|
||||
ox::Point pt1, ox::Point pt2, Color32 c, ox::Span<float> vbo, ox::Vec2 const &pixSize) noexcept;
|
||||
static void setBufferObject(ox::Point pt1, ox::Point pt2, Color32 c, ox::Span<float> vbo, ox::Vec2 const&pixSize) noexcept;
|
||||
|
||||
void setBufferObjects(ox::Vec2 const&paneSize, TileSheet::SubSheet const&subsheet) noexcept;
|
||||
|
||||
|
@@ -86,12 +86,12 @@ static void setPixel(
|
||||
int const columns,
|
||||
ox::Point const&pt,
|
||||
uint8_t const palIdx) noexcept {
|
||||
auto const idx = ptToIdx(pt, columns);
|
||||
const auto idx = ptToIdx(pt, columns);
|
||||
pixels[idx] = palIdx;
|
||||
}
|
||||
|
||||
void setPixel(TileSheet::SubSheet &ss, ox::Point const&pt, uint8_t const palIdx) noexcept {
|
||||
auto const idx = ptToIdx(pt, ss.columns);
|
||||
const auto idx = ptToIdx(pt, ss.columns);
|
||||
ss.pixels[idx] = palIdx;
|
||||
}
|
||||
|
||||
@@ -154,8 +154,8 @@ ox::Result<ox::StringView> getNameFor(TileSheet::SubSheet const &ss, SubSheetId
|
||||
if (ss.id == pId) {
|
||||
return ox::StringView(ss.name);
|
||||
}
|
||||
for (auto const &sub : ss.subsheets) {
|
||||
auto const [name, err] = getNameFor(sub, pId);
|
||||
for (const auto &sub : ss.subsheets) {
|
||||
const auto [name, err] = getNameFor(sub, pId);
|
||||
if (!err) {
|
||||
return name;
|
||||
}
|
||||
@@ -222,7 +222,7 @@ static TileSheet::SubSheet const &getSubSheet(
|
||||
if (idxIt == idx.size()) {
|
||||
return pSubsheet;
|
||||
}
|
||||
auto const currentIdx = idx[idxIt];
|
||||
const auto currentIdx = idx[idxIt];
|
||||
if (pSubsheet.subsheets.size() < currentIdx) {
|
||||
return pSubsheet;
|
||||
}
|
||||
@@ -437,13 +437,13 @@ ox::Vector<uint32_t> resizeTileSheetData(
|
||||
ox::Vector<uint32_t> dst;
|
||||
auto dstWidth = srcSize.width * scale;
|
||||
auto dstHeight = srcSize.height * scale;
|
||||
auto const pixelCnt = dstWidth * dstHeight;
|
||||
const auto pixelCnt = dstWidth * dstHeight;
|
||||
dst.resize(static_cast<std::size_t>(pixelCnt));
|
||||
for (auto i = 0; i < pixelCnt; ++i) {
|
||||
auto const dstPt = idxToPt(i, 1, scale);
|
||||
auto const srcPt = dstPt / ox::Point{scale, scale};
|
||||
auto const srcIdx = ptToIdx(srcPt, 1);
|
||||
auto const srcPixel = srcPixels[srcIdx];
|
||||
const auto dstPt = idxToPt(i, 1, scale);
|
||||
const auto srcPt = dstPt / ox::Point{scale, scale};
|
||||
const auto srcIdx = ptToIdx(srcPt, 1);
|
||||
const auto srcPixel = srcPixels[srcIdx];
|
||||
dst[static_cast<std::size_t>(i)] = srcPixel;
|
||||
}
|
||||
return dst;
|
||||
|
@@ -24,7 +24,7 @@ static std::map<ox::StringView, ox::Error(*)()> tests = {
|
||||
},
|
||||
};
|
||||
|
||||
int main(int argc, char const **argv) {
|
||||
int main(int argc, const char **argv) {
|
||||
int retval = -1;
|
||||
if (argc > 0) {
|
||||
auto const args = ox::Span{argv, static_cast<size_t>(argc)};
|
||||
|
@@ -11,7 +11,7 @@
|
||||
static std::map<ox::StringView, ox::Error(*)()> tests = {
|
||||
};
|
||||
|
||||
int main(int argc, char const **argv) {
|
||||
int main(int argc, const char **argv) {
|
||||
int retval = -1;
|
||||
if (argc > 0) {
|
||||
auto const args = ox::Span{argv, static_cast<size_t>(argc)};
|
||||
|
@@ -15,7 +15,7 @@ target_link_libraries(
|
||||
|
||||
target_compile_definitions(
|
||||
NostalgiaStudio PUBLIC
|
||||
OLYMPIC_APP_VERSION="dev build"
|
||||
OLYMPIC_APP_VERSION="d2025.06.0"
|
||||
)
|
||||
|
||||
install(
|
||||
|
@@ -18,7 +18,7 @@
|
||||
<string>APPL</string>
|
||||
|
||||
<key>CFBundleVersion</key>
|
||||
<string>dev build</string>
|
||||
<string>d2025.06.0</string>
|
||||
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>12.0.0</string>
|
||||
|
@@ -55,7 +55,7 @@ void registerStudioModules() noexcept;
|
||||
#if defined(_WIN32) && OLYMPIC_GUI_APP
|
||||
int WinMain() {
|
||||
auto const argc = __argc;
|
||||
auto const argv = const_cast<char const**>(__argv);
|
||||
auto const argv = const_cast<const char**>(__argv);
|
||||
#else
|
||||
int main(int const argc, char const **argv) {
|
||||
#endif
|
||||
|
@@ -26,7 +26,7 @@ ox::Error writeUuidHeader(ox::Writer_c auto &writer, ox::UUID const&uuid) noexce
|
||||
template<typename T>
|
||||
ox::Result<T> readAsset(ox::BufferView buff) noexcept {
|
||||
std::size_t offset = 0;
|
||||
auto const err = readUuidHeader(buff).error;
|
||||
const auto err = readUuidHeader(buff).error;
|
||||
if (!err) {
|
||||
offset = K1HdrSz; // the size of K1 headers
|
||||
}
|
||||
|
@@ -37,8 +37,8 @@ ox::Result<ox::ModelObject> readAsset(ox::TypeStore &ts, ox::BufferView buff) no
|
||||
}
|
||||
|
||||
ox::Result<ox::StringView> readAssetTypeId(ox::BufferView const buff) noexcept {
|
||||
auto const err = readUuidHeader(buff).error;
|
||||
auto const offset = err ? 0u : K1HdrSz;
|
||||
const auto err = readUuidHeader(buff).error;
|
||||
const auto offset = err ? 0u : K1HdrSz;
|
||||
if (offset >= buff.size()) [[unlikely]] {
|
||||
return ox::Error(1, "Buffer too small for expected data");
|
||||
}
|
||||
@@ -47,8 +47,8 @@ ox::Result<ox::StringView> readAssetTypeId(ox::BufferView const buff) noexcept {
|
||||
|
||||
ox::Result<AssetHdr> readAssetHeader(ox::BufferView buff) noexcept {
|
||||
ox::Result<AssetHdr> out;
|
||||
auto const err = readUuidHeader(buff).moveTo(out.value.uuid);
|
||||
auto const offset = err ? 0u : K1HdrSz;
|
||||
const auto err = readUuidHeader(buff).moveTo(out.value.uuid);
|
||||
const auto offset = err ? 0u : K1HdrSz;
|
||||
if (offset >= buff.size()) [[unlikely]] {
|
||||
return ox::Error(1, "Buffer too small for expected data");
|
||||
}
|
||||
|
@@ -49,7 +49,7 @@ static ox::Result<ox::UPtr<Wrap>> convert(
|
||||
if (!subConverter.converter().dstMatches(dstTypeName, dstTypeVersion)) {
|
||||
continue;
|
||||
}
|
||||
auto const [intermediate, chainErr] =
|
||||
const auto [intermediate, chainErr] =
|
||||
convert(ctx, converters, src, srcTypeName, srcTypeVersion,
|
||||
subConverter.converter().srcTypeName(), subConverter.converter().srcTypeVersion());
|
||||
if (!chainErr) {
|
||||
|
@@ -25,7 +25,7 @@ static std::map<ox::StringView, ox::Error(*)()> tests = {
|
||||
},
|
||||
};
|
||||
|
||||
int main(int argc, char const **argv) {
|
||||
int main(int argc, const char **argv) {
|
||||
int retval = -1;
|
||||
if (argc > 0) {
|
||||
auto const args = ox::Span{argv, static_cast<size_t>(argc)};
|
||||
|
@@ -61,7 +61,7 @@ static ox::Error runApp(
|
||||
static ox::Error run(
|
||||
ox::StringViewCR appName,
|
||||
ox::StringViewCR projectDataDir,
|
||||
ox::SpanView<ox::CString>) {
|
||||
ox::SpanView<const char*>) {
|
||||
// seed UUID generator
|
||||
auto const time = std::time(nullptr);
|
||||
ox::UUID::seedGenerator({
|
||||
|
@@ -140,14 +140,14 @@ void ClawEditor::drawVar(ObjPath &path, ox::StringViewCR name, ox::ModelValue co
|
||||
|
||||
void ClawEditor::drawTree(ObjPath &path, ox::ModelObject const&obj) noexcept {
|
||||
using Str = ox::BasicString<100>;
|
||||
for (auto const &c : obj) {
|
||||
for (const auto &c : obj) {
|
||||
ImGui::TableNextRow(0, 5);
|
||||
auto pathStr = ox::join<Str>("##", path).unwrap();
|
||||
auto lbl = ox::sfmt<Str>("{}##{}", c->name, pathStr);
|
||||
auto const rowSelected = false;
|
||||
auto const hasChildren = c->value.type() == ox::ModelValue::Type::Object
|
||||
const auto rowSelected = false;
|
||||
const auto hasChildren = c->value.type() == ox::ModelValue::Type::Object
|
||||
|| c->value.type() == ox::ModelValue::Type::Vector;
|
||||
auto const flags = ImGuiTreeNodeFlags_SpanFullWidth
|
||||
const auto flags = ImGuiTreeNodeFlags_SpanFullWidth
|
||||
| ImGuiTreeNodeFlags_OpenOnArrow
|
||||
| (hasChildren ? 0 : ImGuiTreeNodeFlags_Leaf)
|
||||
| (rowSelected ? ImGuiTreeNodeFlags_Selected : 0);
|
||||
@@ -158,7 +158,7 @@ void ClawEditor::drawTree(ObjPath &path, ox::ModelObject const &obj) noexcept {
|
||||
//}
|
||||
path.push_back(c->name);
|
||||
if (c->value.type() == ox::ModelValue::Type::Object) {
|
||||
auto const open = ImGui::TreeNodeEx(lbl.c_str(), flags);
|
||||
const auto open = ImGui::TreeNodeEx(lbl.c_str(), flags);
|
||||
ImGui::SameLine();
|
||||
drawRow(c->value);
|
||||
if (open) {
|
||||
|
@@ -13,7 +13,7 @@
|
||||
|
||||
namespace studio {
|
||||
|
||||
class NewProject: public Popup {
|
||||
class NewProject: public studio::Popup {
|
||||
public:
|
||||
enum class Stage {
|
||||
Closed,
|
||||
|
@@ -635,7 +635,8 @@ ox::Error StudioUI::openProjectPath(ox::StringParam path) noexcept {
|
||||
keel::DuplicateSet ds;
|
||||
OX_RETURN_ERROR(keel::setRomFs(keelCtx(m_tctx), std::move(fs), ds));
|
||||
if (ds.size()) {
|
||||
ox::String msg{"Multiple files have the same UUID:\n"};
|
||||
ox::String msg;
|
||||
msg += "Multiple files have the same UUID:\n";
|
||||
for (auto const &k : ds.keys()) {
|
||||
msg += ox::sfmt("\n\t{}:\n", k.toString());
|
||||
for (auto const &v : ds[k]) {
|
||||
|
@@ -24,8 +24,6 @@ class FilePickerPopup {
|
||||
public:
|
||||
explicit FilePickerPopup(ox::StringParam name, keel::Context &kctx, ox::StringParam fileExt) noexcept;
|
||||
|
||||
explicit FilePickerPopup(ox::StringParam name, keel::Context &kctx, ox::SpanView<ox::StringLiteral> fileExts) noexcept;
|
||||
|
||||
explicit FilePickerPopup(ox::StringParam name, keel::Context &kctx, ox::Vector<ox::String> fileExts) noexcept;
|
||||
|
||||
void refresh() noexcept;
|
||||
|
@@ -131,7 +131,7 @@ class ChildStackItem {
|
||||
class IDStackItem {
|
||||
public:
|
||||
explicit IDStackItem(int id) noexcept;
|
||||
explicit IDStackItem(ox::CString const id) noexcept;
|
||||
explicit IDStackItem(const char *id) noexcept;
|
||||
explicit IDStackItem(ox::CStringViewCR id) noexcept;
|
||||
~IDStackItem() noexcept;
|
||||
};
|
||||
@@ -244,7 +244,7 @@ bool BeginPopup(turbine::Context &ctx, ox::CStringViewCR popupName, bool &show,
|
||||
* @return true if new value selected, false otherwise
|
||||
*/
|
||||
bool ComboBox(
|
||||
ox::CStringView const &lbl,
|
||||
ox::CStringView lbl,
|
||||
ox::SpanView<ox::CStringView> list,
|
||||
size_t &selectedIdx) noexcept;
|
||||
|
||||
@@ -255,7 +255,7 @@ bool ComboBox(
|
||||
* @param selectedIdx
|
||||
* @return true if new value selected, false otherwise
|
||||
*/
|
||||
bool ComboBox(ox::CStringView const &lbl, ox::Span<ox::String const> list, size_t &selectedIdx) noexcept;
|
||||
bool ComboBox(ox::CStringView lbl, ox::Span<const ox::String> list, size_t &selectedIdx) noexcept;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@@ -28,7 +28,7 @@ struct Selection {
|
||||
}
|
||||
};
|
||||
|
||||
constexpr auto iterateSelection(Selection const &sel, auto const &cb) {
|
||||
constexpr auto iterateSelection(studio::Selection const&sel, auto const&cb) {
|
||||
constexpr auto retErr = ox::is_same_v<decltype(cb(0, 0)), ox::Error>;
|
||||
for (auto x = sel.a.x; x <= sel.b.x; ++x) {
|
||||
for (auto y = sel.a.y; y <= sel.b.y; ++y) {
|
||||
@@ -44,7 +44,7 @@ constexpr auto iterateSelection(Selection const &sel, auto const &cb) {
|
||||
}
|
||||
};
|
||||
|
||||
constexpr auto iterateSelectionRows(Selection const &sel, auto const &cb) {
|
||||
constexpr auto iterateSelectionRows(studio::Selection const&sel, auto const&cb) {
|
||||
constexpr auto retErr = ox::is_same_v<decltype(cb(0, 0)), ox::Error>;
|
||||
for (auto y = sel.a.y; y <= sel.b.y; ++y) {
|
||||
for (auto x = sel.a.x; x <= sel.b.x; ++x) {
|
||||
|
@@ -12,7 +12,7 @@ namespace studio {
|
||||
|
||||
class NoChangesException: public ox::Exception {
|
||||
public:
|
||||
explicit NoChangesException(std::source_location sloc = std::source_location::current()):
|
||||
inline NoChangesException(std::source_location sloc = std::source_location::current()):
|
||||
ox::Exception(1, "Command makes no changes.", sloc) {}
|
||||
};
|
||||
|
||||
|
@@ -26,22 +26,6 @@ FilePickerPopup::FilePickerPopup(
|
||||
m_fileExts{std::move(fileExt)} {
|
||||
}
|
||||
|
||||
FilePickerPopup::FilePickerPopup(
|
||||
ox::StringParam name,
|
||||
keel::Context &kctx,
|
||||
ox::SpanView<ox::StringLiteral> fileExts) noexcept:
|
||||
m_name{std::move(name)},
|
||||
m_explorer{kctx},
|
||||
m_fileExts{[fileExts] {
|
||||
ox::Vector<ox::String> out;
|
||||
out.reserve(fileExts.size());
|
||||
for (auto &s : fileExts) {
|
||||
out.emplace_back(s);
|
||||
}
|
||||
return out;
|
||||
}()} {
|
||||
}
|
||||
|
||||
FilePickerPopup::FilePickerPopup(
|
||||
ox::StringParam name,
|
||||
keel::Context &kctx,
|
||||
|
@@ -18,11 +18,11 @@ ChildStackItem::~ChildStackItem() noexcept {
|
||||
ImGui::EndChild();
|
||||
}
|
||||
|
||||
IDStackItem::IDStackItem(int const id) noexcept {
|
||||
IDStackItem::IDStackItem(int id) noexcept {
|
||||
ImGui::PushID(id);
|
||||
}
|
||||
|
||||
IDStackItem::IDStackItem(ox::CString const id) noexcept {
|
||||
IDStackItem::IDStackItem(const char *id) noexcept {
|
||||
ImGui::PushID(id);
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ bool PushButton(ox::CStringViewCR lbl, ImVec2 const &btnSz) noexcept {
|
||||
}
|
||||
|
||||
PopupResponse PopupControlsOkCancel(
|
||||
float const popupWidth,
|
||||
float popupWidth,
|
||||
bool &popupOpen,
|
||||
ox::CStringViewCR ok,
|
||||
ox::CStringViewCR cancel) {
|
||||
@@ -110,14 +110,14 @@ bool BeginPopup(turbine::Context &ctx, ox::CStringViewCR popupName, bool &show,
|
||||
}
|
||||
|
||||
bool ComboBox(
|
||||
ox::CStringView const &lbl,
|
||||
ox::SpanView<ox::CStringView> const list,
|
||||
ox::CStringView lbl,
|
||||
ox::SpanView<ox::CStringView> list,
|
||||
size_t &selectedIdx) noexcept {
|
||||
bool out{};
|
||||
auto const first = selectedIdx < list.size() ? list[selectedIdx].c_str() : "";
|
||||
if (ImGui::BeginCombo(lbl.c_str(), first, 0)) {
|
||||
for (auto i = 0u; i < list.size(); ++i) {
|
||||
auto const selected = (selectedIdx == i);
|
||||
const auto selected = (selectedIdx == i);
|
||||
if (ImGui::Selectable(list[i].c_str(), selected) && selectedIdx != i) {
|
||||
selectedIdx = i;
|
||||
out = true;
|
||||
@@ -129,14 +129,14 @@ bool ComboBox(
|
||||
}
|
||||
|
||||
bool ComboBox(
|
||||
ox::CStringView const &lbl,
|
||||
ox::Span<ox::String const> const list,
|
||||
ox::CStringView lbl,
|
||||
ox::Span<const ox::String> list,
|
||||
size_t &selectedIdx) noexcept {
|
||||
bool out{};
|
||||
auto const first = selectedIdx < list.size() ? list[selectedIdx].c_str() : "";
|
||||
if (ImGui::BeginCombo(lbl.c_str(), first, 0)) {
|
||||
for (auto i = 0u; i < list.size(); ++i) {
|
||||
auto const selected = (selectedIdx == i);
|
||||
const auto selected = (selectedIdx == i);
|
||||
if (ImGui::Selectable(list[i].c_str(), selected) && selectedIdx != i) {
|
||||
selectedIdx = i;
|
||||
out = true;
|
||||
@@ -150,13 +150,13 @@ bool ComboBox(
|
||||
bool ComboBox(
|
||||
ox::CStringViewCR lbl,
|
||||
std::function<ox::CStringView(size_t)> const &f,
|
||||
size_t const strCnt,
|
||||
size_t strCnt,
|
||||
size_t &selectedIdx) noexcept {
|
||||
bool out{};
|
||||
auto const first = selectedIdx < strCnt ? f(selectedIdx).c_str() : "";
|
||||
if (ImGui::BeginCombo(lbl.c_str(), first, 0)) {
|
||||
for (auto i = 0u; i < strCnt; ++i) {
|
||||
auto const selected = (selectedIdx == i);
|
||||
const auto selected = (selectedIdx == i);
|
||||
if (ImGui::Selectable(f(i).c_str(), selected) && selectedIdx != i) {
|
||||
selectedIdx = i;
|
||||
out = true;
|
||||
|
@@ -8,7 +8,7 @@
|
||||
namespace studio {
|
||||
|
||||
void Popup::drawWindow(turbine::Context &ctx, bool &open, std::function<void()> const&drawContents) {
|
||||
ig::centerNextWindow(ctx);
|
||||
studio::ig::centerNextWindow(ctx);
|
||||
ImGui::SetNextWindowSize(static_cast<ImVec2>(m_size));
|
||||
constexpr auto modalFlags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize;
|
||||
if (ImGui::BeginPopupModal(m_title.c_str(), &open, modalFlags)) {
|
||||
|
@@ -28,7 +28,7 @@ class ClipboardObject: public BaseClipboardObject {
|
||||
}
|
||||
};
|
||||
|
||||
ox::String getClipboardText(Context const &ctx) noexcept;
|
||||
ox::String getClipboardText(Context &ctx) noexcept;
|
||||
|
||||
void setClipboardText(Context &ctx, ox::StringViewCR text) noexcept;
|
||||
|
||||
|
@@ -9,7 +9,7 @@
|
||||
|
||||
namespace turbine {
|
||||
|
||||
ox::String getClipboardText(Context const &) noexcept {
|
||||
ox::String getClipboardText(Context&) noexcept {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@@ -12,7 +12,7 @@
|
||||
|
||||
namespace turbine {
|
||||
|
||||
ox::String getClipboardText(Context const &ctx) noexcept {
|
||||
ox::String getClipboardText(Context &ctx) noexcept {
|
||||
return ox::String(glfwGetClipboardString(ctx.window));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user