Squashed 'deps/nostalgia/' changes from 37cfa927..f847289b

f847289b [glutils] Cleanup
94b0020d [nostalgia,olympic] Cleanup
c54c0bad [teagba] Cleanup
b9ffae02 [nostalgia/gfx] Cleanup
003f3e01 [nostalgia] Update release notes
9028e74a [nostalgia/gfx/studio/tilesheet] Disable paste when nothing is selected
f5ccab5f [studio] Cleanup

git-subtree-dir: deps/nostalgia
git-subtree-split: f847289bd493e3318eb6fc1d09ea216e140899aa
This commit is contained in:
2025-06-23 20:49:01 -05:00
parent 6bbcae10cc
commit 9b5f7886ca
60 changed files with 370 additions and 345 deletions

View File

@ -89,7 +89,7 @@ struct GLObject: public Base {
return id; return id;
} }
constexpr operator const GLuint&() const noexcept { constexpr operator GLuint const&() const noexcept {
return id; return id;
} }
@ -135,7 +135,7 @@ struct FrameBuffer {
return fbo.id; return fbo.id;
} }
constexpr operator const GLuint&() const noexcept { constexpr operator GLuint const&() const noexcept {
return fbo.id; return fbo.id;
} }
@ -158,14 +158,14 @@ struct FrameBuffer {
class FrameBufferBind { class FrameBufferBind {
private: private:
static const FrameBuffer *s_activeFb; static FrameBuffer const *s_activeFb;
const FrameBuffer *m_restoreFb = nullptr; FrameBuffer const *m_restoreFb = nullptr;
public: public:
explicit FrameBufferBind(const FrameBuffer &fb) noexcept; explicit FrameBufferBind(FrameBuffer const &fb) noexcept;
~FrameBufferBind() noexcept; ~FrameBufferBind() noexcept;
}; };
void bind(const FrameBuffer &fb) noexcept; void bind(FrameBuffer const &fb) noexcept;
struct ShaderVarSet { struct ShaderVarSet {
GLsizei len{}; GLsizei len{};
@ -201,9 +201,9 @@ void setupShaderParams(
void setupShaderParams(GLProgram const &shader, ox::Vector<ShaderVarSet> const &vars) noexcept; void setupShaderParams(GLProgram const &shader, ox::Vector<ShaderVarSet> const &vars) noexcept;
glutils::GLVertexArray generateVertexArrayObject() noexcept; GLVertexArray generateVertexArrayObject() noexcept;
glutils::GLBuffer generateBuffer() noexcept; GLBuffer generateBuffer() noexcept;
[[nodiscard]] [[nodiscard]]
FrameBuffer generateFrameBuffer(int width, int height) noexcept; 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; void resizeInitFrameBuffer(FrameBuffer &fb, ox::Size const &sz) noexcept;
struct BufferSet { struct BufferSet {
glutils::GLVertexArray vao; GLVertexArray vao;
glutils::GLBuffer vbo; GLBuffer vbo;
glutils::GLBuffer ebo; GLBuffer ebo;
glutils::GLTexture tex; GLTexture tex;
ox::Vector<float> vertices; ox::Vector<float> vertices;
ox::Vector<GLuint> elements; ox::Vector<GLuint> elements;
}; };

View File

@ -46,9 +46,9 @@ template struct GLObject<deleteVertexArray>;
template struct GLObject<deleteProgram>; template struct GLObject<deleteProgram>;
template struct GLObject<deleteShader>; template struct GLObject<deleteShader>;
const FrameBuffer *FrameBufferBind::s_activeFb = nullptr; FrameBuffer const *FrameBufferBind::s_activeFb = nullptr;
FrameBufferBind::FrameBufferBind(const FrameBuffer &fb) noexcept: m_restoreFb(s_activeFb) { FrameBufferBind::FrameBufferBind(FrameBuffer const &fb) noexcept: m_restoreFb(s_activeFb) {
s_activeFb = &fb; s_activeFb = &fb;
glBindFramebuffer(GL_FRAMEBUFFER, fb); glBindFramebuffer(GL_FRAMEBUFFER, fb);
glViewport(0, 0, fb.width, fb.height); glViewport(0, 0, fb.width, fb.height);
@ -64,15 +64,15 @@ FrameBufferBind::~FrameBufferBind() noexcept {
} }
} }
void bind(const FrameBuffer &fb) noexcept { void bind(FrameBuffer const &fb) noexcept {
glBindFramebuffer(GL_FRAMEBUFFER, fb); glBindFramebuffer(GL_FRAMEBUFFER, fb);
glViewport(0, 0, fb.width, fb.height); glViewport(0, 0, fb.width, fb.height);
} }
static ox::Result<GLShader> buildShader( static ox::Result<GLShader> buildShader(
GLuint shaderType, GLuint const shaderType,
const GLchar *src, GLchar const *src,
ox::StringViewCR shaderName) noexcept { ox::StringViewCR shaderName) noexcept {
GLShader shader(glCreateShader(shaderType)); GLShader shader(glCreateShader(shaderType));
glShaderSource(shader, 1, &src, nullptr); glShaderSource(shader, 1, &src, nullptr);
@ -162,16 +162,30 @@ FrameBuffer generateFrameBuffer(int width, int height) noexcept {
// color texture // color texture
glGenTextures(1, &fb.color.id); glGenTextures(1, &fb.color.id);
glBindTexture(GL_TEXTURE_2D, fb.color); 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); glGenerateMipmap(GL_TEXTURE_2D);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_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 // depth texture
glGenRenderbuffers(1, &fb.depth.id); glGenRenderbuffers(1, &fb.depth.id);
glBindRenderbuffer(GL_RENDERBUFFER, fb.depth); glBindRenderbuffer(GL_RENDERBUFFER, fb.depth);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height); 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 // verify FBO
oxAssert(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE, "Frame Buffer is incomplete"); oxAssert(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE, "Frame Buffer is incomplete");
// restore primary FB // restore primary FB
@ -189,7 +203,16 @@ void resizeFrameBuffer(FrameBuffer &fb, int width, int height) noexcept {
glBindFramebuffer(GL_FRAMEBUFFER, fb); glBindFramebuffer(GL_FRAMEBUFFER, fb);
// color texture // color texture
glBindTexture(GL_TEXTURE_2D, fb.color); 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_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// depth texture // depth texture
@ -201,7 +224,7 @@ void resizeFrameBuffer(FrameBuffer &fb, int width, int height) noexcept {
glBindRenderbuffer(GL_RENDERBUFFER, 0); glBindRenderbuffer(GL_RENDERBUFFER, 0);
} }
void resizeInitFrameBuffer(FrameBuffer &fb, int width, int height) noexcept { void resizeInitFrameBuffer(FrameBuffer &fb, int const width, int const height) noexcept {
if (!fb) { if (!fb) {
fb = generateFrameBuffer(width, height); fb = generateFrameBuffer(width, height);
return; return;
@ -214,13 +237,13 @@ void resizeInitFrameBuffer(FrameBuffer &fb, ox::Size const&sz) noexcept {
} }
void sendVbo(BufferSet const &bs) noexcept { void sendVbo(BufferSet const &bs) noexcept {
const auto bufferSize = static_cast<GLsizeiptr>(sizeof(decltype(bs.vertices)::value_type) * bs.vertices.size()); auto const bufferSize = static_cast<GLsizeiptr>(sizeof(decltype(bs.vertices)::value_type) * bs.vertices.size());
glBindBuffer(GL_ARRAY_BUFFER, bs.vbo); glBindBuffer(GL_ARRAY_BUFFER, bs.vbo);
glBufferData(GL_ARRAY_BUFFER, bufferSize, bs.vertices.data(), GL_DYNAMIC_DRAW); glBufferData(GL_ARRAY_BUFFER, bufferSize, bs.vertices.data(), GL_DYNAMIC_DRAW);
} }
void sendEbo(BufferSet const &bs) noexcept { void sendEbo(BufferSet const &bs) noexcept {
const auto bufferSize = static_cast<GLsizeiptr>(sizeof(decltype(bs.elements)::value_type) * bs.elements.size()); auto const bufferSize = static_cast<GLsizeiptr>(sizeof(decltype(bs.elements)::value_type) * bs.elements.size());
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bs.ebo); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bs.ebo);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, bufferSize, bs.elements.data(), GL_STATIC_DRAW); glBufferData(GL_ELEMENT_ARRAY_BUFFER, bufferSize, bs.elements.data(), GL_STATIC_DRAW);
} }

View File

@ -37,7 +37,7 @@ struct OX_ALIGN8 GbaSpriteAttrUpdate {
GbaSpriteAttrUpdate &spriteAttr(size_t i) noexcept; GbaSpriteAttrUpdate &spriteAttr(size_t i) noexcept;
void addSpriteUpdate(const GbaSpriteAttrUpdate &upd) noexcept; void addSpriteUpdate(GbaSpriteAttrUpdate const &upd) noexcept;
void applySpriteUpdates() noexcept; void applySpriteUpdates() noexcept;

View File

@ -26,7 +26,7 @@ extern void (*__preinit_array_end[]) (void);
extern void (*__init_array_start[]) (void); extern void (*__init_array_start[]) (void);
extern void (*__init_array_end[]) (void); extern void (*__init_array_end[]) (void);
int main(int argc, const char **argv); int main(int argc, char const **argv);
extern "C" { extern "C" {
@ -50,7 +50,7 @@ void __libc_init_array() {
} }
int c_start() { int c_start() {
const char *args[2] = {"", "rom.oxfs"}; char const *args[2] = {"", "rom.oxfs"};
ox::heapmgr::initHeap(HEAP_BEGIN, HEAP_END); ox::heapmgr::initHeap(HEAP_BEGIN, HEAP_END);
mgba::initConsole(); mgba::initConsole();
#pragma GCC diagnostic push #pragma GCC diagnostic push

View File

@ -16,7 +16,7 @@ GbaSpriteAttrUpdate &spriteAttr(size_t i) noexcept {
return g_spriteBuffer[i]; return g_spriteBuffer[i];
} }
void addSpriteUpdate(const GbaSpriteAttrUpdate &upd) noexcept { void addSpriteUpdate(GbaSpriteAttrUpdate const &upd) noexcept {
const auto ie = REG_IE; // disable vblank interrupt handler const auto ie = REG_IE; // disable vblank interrupt handler
REG_IE = REG_IE & static_cast<uint16_t>(~teagba::Int_vblank); // disable vblank interrupt handler REG_IE = REG_IE & static_cast<uint16_t>(~teagba::Int_vblank); // disable vblank interrupt handler
g_spriteBuffer[upd.idx] = upd; g_spriteBuffer[upd.idx] = upd;

View File

@ -14,8 +14,6 @@
subsheets subsheets
* PaletteEditor: Add RGB key shortcuts for focusing color channels * PaletteEditor: Add RGB key shortcuts for focusing color channels
* PaletteEditor: Add color preview to color editor * PaletteEditor: Add color preview to color editor
* PaletteEditor: Make RGB key shortcuts work when color channel inputs are
focused
# d2025.05.1 # d2025.05.1

View File

@ -19,10 +19,10 @@ using Color32 = uint32_t;
[[nodiscard]] [[nodiscard]]
constexpr Color32 toColor32(Color16 nc) noexcept { constexpr Color32 toColor32(Color16 nc) noexcept {
const auto r = static_cast<Color32>(((nc & 0b0000000000011111) >> 0) * 8); auto const r = static_cast<Color32>(((nc & 0b0000000000011111) >> 0) * 8);
const auto g = static_cast<Color32>(((nc & 0b0000001111100000) >> 5) * 8); auto const g = static_cast<Color32>(((nc & 0b0000001111100000) >> 5) * 8);
const auto b = static_cast<Color32>(((nc & 0b0111110000000000) >> 10) * 8); auto const b = static_cast<Color32>(((nc & 0b0111110000000000) >> 10) * 8);
const auto a = static_cast<Color32>(255); auto const a = static_cast<Color32>(255);
return r | (g << 8) | (b << 16) | (a << 24); return r | (g << 8) | (b << 16) | (a << 24);
} }

View File

@ -12,15 +12,15 @@ namespace nostalgia::gfx {
[[nodiscard]] [[nodiscard]]
constexpr std::size_t ptToIdx(int x, int y, int c, int scale = 1) noexcept { constexpr std::size_t ptToIdx(int x, int y, int c, int scale = 1) noexcept {
const auto tileWidth = TileWidth * scale; auto const tileWidth = TileWidth * scale;
const auto tileHeight = TileHeight * scale; auto const tileHeight = TileHeight * scale;
const auto pixelsPerTile = tileWidth * tileHeight; auto const pixelsPerTile = tileWidth * tileHeight;
const auto colLength = static_cast<std::size_t>(pixelsPerTile); auto const colLength = static_cast<std::size_t>(pixelsPerTile);
const auto rowLength = static_cast<std::size_t>(static_cast<std::size_t>(c / tileWidth) * colLength); auto const 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)); auto const 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)); auto const rowStart = static_cast<std::size_t>(rowLength * static_cast<std::size_t>(y / tileHeight));
const auto colOffset = static_cast<std::size_t>(x % tileWidth); auto const colOffset = static_cast<std::size_t>(x % tileWidth);
const auto rowOffset = static_cast<std::size_t>((y % tileHeight) * tileHeight); auto const rowOffset = static_cast<std::size_t>((y % tileHeight) * tileHeight);
return static_cast<std::size_t>(colStart + colOffset + rowStart + rowOffset); 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]] [[nodiscard]]
constexpr ox::Point idxToPt(int i, int c, int scale = 1) noexcept { constexpr ox::Point idxToPt(int i, int c, int scale = 1) noexcept {
const auto tileWidth = TileWidth * scale; auto const tileWidth = TileWidth * scale;
const auto tileHeight = TileHeight * scale; auto const tileHeight = TileHeight * scale;
const auto pixelsPerTile = tileWidth * tileHeight; auto const pixelsPerTile = tileWidth * tileHeight;
// prevent divide by zeros // prevent divide by zeros
if (!c) { if (!c) {
++c; ++c;
} }
const auto t = i / pixelsPerTile; // tile number auto const t = i / pixelsPerTile; // tile number
const auto iti = i % pixelsPerTile; // in tile index auto const iti = i % pixelsPerTile; // in tile index
const auto tc = t % c; // tile column auto const tc = t % c; // tile column
const auto tr = t / c; // tile row auto const tr = t / c; // tile row
const auto itx = iti % tileWidth; // in tile x auto const itx = iti % tileWidth; // in tile x
const auto ity = iti / tileHeight; // in tile y auto const ity = iti / tileHeight; // in tile y
return { return {
itx + tc * tileWidth, itx + tc * tileWidth,
ity + tr * tileHeight, ity + tr * tileHeight,

View File

@ -246,7 +246,11 @@ ox::Error loadSpriteTileSheet(
} }
void setBgTile( 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); auto const tileIdx = static_cast<std::size_t>(row * tileColumns(ctx) + column);
// see Tonc 9.3 // see Tonc 9.3
MEM_BG_MAP[bgIdx][tileIdx] = MEM_BG_MAP[bgIdx][tileIdx] =
@ -275,7 +279,7 @@ bool bgStatus(Context&, unsigned const bg) noexcept {
void setBgStatus(Context&, unsigned const bg, bool const status) noexcept { void setBgStatus(Context&, unsigned const bg, bool const status) noexcept {
constexpr auto Bg0Status = 8; constexpr auto Bg0Status = 8;
const auto mask = static_cast<uint32_t>(status) << (Bg0Status + bg); auto const mask = static_cast<uint32_t>(status) << (Bg0Status + bg);
REG_DISPCTL = REG_DISPCTL | ((REG_DISPCTL & ~mask) | mask); REG_DISPCTL = REG_DISPCTL | ((REG_DISPCTL & ~mask) | mask);
} }
@ -286,7 +290,7 @@ void setBgBpp(Context&, unsigned const bgIdx, unsigned const bpp) noexcept {
void setBgCbb(Context &ctx, unsigned const bgIdx, unsigned const cbbIdx) noexcept { void setBgCbb(Context &ctx, unsigned const bgIdx, unsigned const cbbIdx) noexcept {
auto &bgCtl = regBgCtl(bgIdx); auto &bgCtl = regBgCtl(bgIdx);
const auto &cbbData = ctx.cbbData[cbbIdx]; auto const &cbbData = ctx.cbbData[cbbIdx];
teagba::bgSetBpp(bgCtl, cbbData.bpp); teagba::bgSetBpp(bgCtl, cbbData.bpp);
teagba::bgSetCbb(bgCtl, cbbIdx); teagba::bgSetCbb(bgCtl, cbbIdx);
} }
@ -341,13 +345,13 @@ uint_t spriteCount(Context const&) noexcept {
namespace ox { namespace ox {
void panic(const char *file, int line, const char *panicMsg, ox::Error const&err) noexcept { void panic(char const *file, int line, char const *panicMsg, ox::Error const &err) noexcept {
using namespace nostalgia::gfx; using namespace nostalgia::gfx;
// reset heap to make sure we have enough memory to allocate context data // reset heap to make sure we have enough memory to allocate context data
OX_ALLOW_UNSAFE_BUFFERS_BEGIN OX_ALLOW_UNSAFE_BUFFERS_BEGIN
const auto heapBegin = reinterpret_cast<char*>(MEM_EWRAM_BEGIN); auto const heapBegin = reinterpret_cast<char*>(MEM_EWRAM_BEGIN);
const auto heapSz = (MEM_EWRAM_END - MEM_EWRAM_BEGIN) / 2; auto const heapSz = (MEM_EWRAM_END - MEM_EWRAM_BEGIN) / 2;
const auto heapEnd = reinterpret_cast<char*>(MEM_EWRAM_BEGIN + heapSz); auto const heapEnd = reinterpret_cast<char*>(MEM_EWRAM_BEGIN + heapSz);
ox::heapmgr::initHeap(heapBegin, heapEnd); ox::heapmgr::initHeap(heapBegin, heapEnd);
OX_ALLOW_UNSAFE_BUFFERS_END OX_ALLOW_UNSAFE_BUFFERS_END
auto tctx = turbine::init(keel::loadRomFs("").unwrap(), "Nostalgia").unwrap(); auto tctx = turbine::init(keel::loadRomFs("").unwrap(), "Nostalgia").unwrap();

View File

@ -287,7 +287,7 @@ static void initSpriteBufferObjects(Context const &ctx, glutils::BufferSet &bs)
static void initBackgroundBufferObjects(glutils::BufferSet &bs) noexcept { static void initBackgroundBufferObjects(glutils::BufferSet &bs) noexcept {
for (auto x = 0u; x < TileColumns; ++x) { for (auto x = 0u; x < TileColumns; ++x) {
for (auto y = 0u; y < TileRows; ++y) { for (auto y = 0u; y < TileRows; ++y) {
const auto i = bgVertexRow(x, y); auto const i = bgVertexRow(x, y);
auto const vbo = ox::Span{bs.vertices} auto const vbo = ox::Span{bs.vertices}
+ i * static_cast<std::size_t>(BgVertexVboLength); + i * static_cast<std::size_t>(BgVertexVboLength);
auto const ebo = ox::Span{bs.elements} auto const ebo = ox::Span{bs.elements}
@ -428,19 +428,19 @@ static void drawBackgrounds(
ox::Size const &renderSz) noexcept { ox::Size const &renderSz) noexcept {
// load background shader and its uniforms // load background shader and its uniforms
glUseProgram(ctx.bgShader); glUseProgram(ctx.bgShader);
const auto uniformSrcImgSz = glGetUniformLocation(ctx.bgShader, "fSrcImgSz"); auto const uniformSrcImgSz = glGetUniformLocation(ctx.bgShader, "fSrcImgSz");
const auto uniformXScale = static_cast<GLint>(glGetUniformLocation(ctx.bgShader, "vXScale")); auto const uniformXScale = static_cast<GLint>(glGetUniformLocation(ctx.bgShader, "vXScale"));
const auto uniformTileHeight = static_cast<GLint>(glGetUniformLocation(ctx.bgShader, "vTileHeight")); auto const uniformTileHeight = static_cast<GLint>(glGetUniformLocation(ctx.bgShader, "vTileHeight"));
const auto uniformBgIdx = static_cast<GLint>(glGetUniformLocation(ctx.bgShader, "vBgIdx")); auto const uniformBgIdx = static_cast<GLint>(glGetUniformLocation(ctx.bgShader, "vBgIdx"));
const auto [wi, hi] = renderSz; auto const [wi, hi] = renderSz;
const auto wf = static_cast<float>(wi); auto const wf = static_cast<float>(wi);
const auto hf = static_cast<float>(hi); auto const hf = static_cast<float>(hi);
glUniform1f(uniformXScale, hf / wf); glUniform1f(uniformXScale, hf / wf);
auto bgIdx = 0.f; auto bgIdx = 0.f;
for (const auto &bg : ctx.backgrounds) { for (auto const &bg : ctx.backgrounds) {
if (bg.enabled) { if (bg.enabled) {
auto &cbb = ctx.cbbs[bg.cbbIdx]; auto &cbb = ctx.cbbs[bg.cbbIdx];
const auto tileRows = cbb.tex.height / (TileHeight * Scale); auto const tileRows = cbb.tex.height / (TileHeight * Scale);
glUniform1f(uniformTileHeight, 1.0f / static_cast<float>(tileRows)); glUniform1f(uniformTileHeight, 1.0f / static_cast<float>(tileRows));
glUniform2f( glUniform2f(
uniformSrcImgSz, uniformSrcImgSz,
@ -456,11 +456,11 @@ static void drawBackgrounds(
static void drawSprites(Context &ctx, ox::Size const&renderSz) noexcept { static void drawSprites(Context &ctx, ox::Size const&renderSz) noexcept {
glUseProgram(ctx.spriteShader); glUseProgram(ctx.spriteShader);
auto &sb = ctx.spriteBlocks; auto &sb = ctx.spriteBlocks;
const auto uniformXScale = glGetUniformLocation(ctx.bgShader, "vXScale"); auto const uniformXScale = glGetUniformLocation(ctx.bgShader, "vXScale");
const auto uniformTileHeight = glGetUniformLocation(ctx.spriteShader, "vTileHeight"); auto const uniformTileHeight = glGetUniformLocation(ctx.spriteShader, "vTileHeight");
const auto [wi, hi] = renderSz; auto const [wi, hi] = renderSz;
const auto wf = static_cast<float>(wi); auto const wf = static_cast<float>(wi);
const auto hf = static_cast<float>(hi); auto const hf = static_cast<float>(hi);
glUniform1f(uniformXScale, hf / wf); glUniform1f(uniformXScale, hf / wf);
// update vbo // update vbo
glBindVertexArray(sb.vao); glBindVertexArray(sb.vao);
@ -469,7 +469,7 @@ static void drawSprites(Context &ctx, ox::Size const&renderSz) noexcept {
glutils::sendVbo(sb); glutils::sendVbo(sb);
} }
// set vTileHeight uniform // set vTileHeight uniform
const auto tileRows = sb.tex.height / (TileHeight * Scale); auto const tileRows = sb.tex.height / (TileHeight * Scale);
glUniform1f(uniformTileHeight, 1.0f / static_cast<float>(tileRows)); glUniform1f(uniformTileHeight, 1.0f / static_cast<float>(tileRows));
// draw // draw
glBindTexture(GL_TEXTURE_2D, sb.tex); glBindTexture(GL_TEXTURE_2D, sb.tex);
@ -493,7 +493,7 @@ static void loadPalette(
// make first color transparent // make first color transparent
palette[palOffset + 3] = 0; palette[palOffset + 3] = 0;
glUseProgram(shaderPgrm); glUseProgram(shaderPgrm);
const auto uniformPalette = static_cast<GLint>(glGetUniformLocation(shaderPgrm, "fPalette")); auto const uniformPalette = static_cast<GLint>(glGetUniformLocation(shaderPgrm, "fPalette"));
glUniform4fv(uniformPalette, ColorCnt, palette.data()); glUniform4fv(uniformPalette, ColorCnt, palette.data());
} }
@ -526,12 +526,12 @@ static void setSprite(
auto const uY = static_cast<int>(s.y + 8) % 255 - 8; auto const uY = static_cast<int>(s.y + 8) % 255 - 8;
oxAssert(1 < ctx.spriteBlocks.vertices.size(), "vbo overflow"); oxAssert(1 < ctx.spriteBlocks.vertices.size(), "vbo overflow");
oxAssert(1 < ctx.spriteBlocks.elements.size(), "ebo overflow"); oxAssert(1 < ctx.spriteBlocks.elements.size(), "ebo overflow");
const auto spriteVboSz = ctx.blocksPerSprite * renderer::SpriteVertexVboLength; auto const spriteVboSz = ctx.blocksPerSprite * renderer::SpriteVertexVboLength;
const auto spriteEboSz = ctx.blocksPerSprite * renderer::SpriteVertexEboLength; auto const spriteEboSz = ctx.blocksPerSprite * renderer::SpriteVertexEboLength;
auto const vboBase = spriteVboSz * idx; auto const vboBase = spriteVboSz * idx;
auto const eboBase = spriteEboSz * idx; auto const eboBase = spriteEboSz * idx;
auto i = 0u; auto i = 0u;
const auto set = [&](int xIt, int yIt, bool enabled) { auto const set = [&](int xIt, int yIt, bool enabled) {
auto const fX = static_cast<float>(uX + xIt * 8) / 8; auto const fX = static_cast<float>(uX + xIt * 8) / 8;
auto const fY = static_cast<float>(uY + yIt * 8) / 8; auto const fY = static_cast<float>(uY + yIt * 8) / 8;
auto const vboIdx = vboBase + renderer::SpriteVertexVboLength * i; 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&params) noexcept { ox::Result<ox::UPtr<Context>> init(turbine::Context &tctx, InitParams const&params) noexcept {
auto ctx = ox::make_unique<Context>(tctx, params); auto ctx = ox::make_unique<Context>(tctx, params);
const auto bgVshad = ox::sfmt(renderer::bgvshadTmpl, gl::GlslVersion); auto const bgVshad = ox::sfmt(renderer::bgvshadTmpl, gl::GlslVersion);
const auto bgFshad = ox::sfmt(renderer::bgfshadTmpl, gl::GlslVersion); auto const bgFshad = ox::sfmt(renderer::bgfshadTmpl, gl::GlslVersion);
const auto spriteVshad = ox::sfmt(renderer::spritevshadTmpl, gl::GlslVersion); auto const spriteVshad = ox::sfmt(renderer::spritevshadTmpl, gl::GlslVersion);
const auto spriteFshad = ox::sfmt(renderer::spritefshadTmpl, gl::GlslVersion); auto const spriteFshad = ox::sfmt(renderer::spritefshadTmpl, gl::GlslVersion);
OX_RETURN_ERROR(glutils::buildShaderProgram(bgVshad, bgFshad).moveTo(ctx->bgShader)); OX_RETURN_ERROR(glutils::buildShaderProgram(bgVshad, bgFshad).moveTo(ctx->bgShader));
OX_RETURN_ERROR( OX_RETURN_ERROR(
glutils::buildShaderProgram(spriteVshad, spriteFshad).moveTo(ctx->spriteShader)); glutils::buildShaderProgram(spriteVshad, spriteFshad).moveTo(ctx->spriteShader));
@ -603,12 +603,12 @@ struct TileSheetData {
} }
}; };
static ox::Result<TileSheetData> normalizeTileSheet( static ox::Result<TileSheetData> normalizeTileSheet
CompactTileSheet const&ts) noexcept { (CompactTileSheet const&ts) noexcept {
const uint_t bytesPerTile = ts.bpp == 8 ? PixelsPerTile : PixelsPerTile / 2; const uint_t bytesPerTile = ts.bpp == 8 ? PixelsPerTile : PixelsPerTile / 2;
const auto tiles = ts.pixels.size() / bytesPerTile; auto const tiles = ts.pixels.size() / bytesPerTile;
constexpr int width = 8; constexpr int width = 8;
const int height = 8 * static_cast<int>(tiles); int const height = 8 * static_cast<int>(tiles);
ox::Vector<uint32_t> pixels; ox::Vector<uint32_t> pixels;
if (bytesPerTile == 64) { // 8 BPP if (bytesPerTile == 64) { // 8 BPP
pixels.resize(ts.pixels.size()); pixels.resize(ts.pixels.size());
@ -779,13 +779,13 @@ void setBgTile(
"nostalgia.gfx.setBgTile", "nostalgia.gfx.setBgTile",
"bgIdx: {}, column: {}, row: {}, tile: {}, palBank: {}", "bgIdx: {}, column: {}, row: {}, tile: {}, palBank: {}",
bgIdx, column, row, tile.tileIdx, tile.palBank); bgIdx, column, row, tile.tileIdx, tile.palBank);
const auto z = static_cast<uint_t>(bgIdx); auto const z = static_cast<uint_t>(bgIdx);
const auto y = static_cast<uint_t>(row); auto const y = static_cast<uint_t>(row);
const auto x = static_cast<uint_t>(column); auto const x = static_cast<uint_t>(column);
const auto i = renderer::bgVertexRow(x, y); auto const i = renderer::bgVertexRow(x, y);
auto &cbb = ctx.cbbs[z]; auto &cbb = ctx.cbbs[z];
const auto vbo = ox::Span{cbb.vertices} + i * renderer::BgVertexVboLength; auto const vbo = ox::Span{cbb.vertices} + i * renderer::BgVertexVboLength;
const auto ebo = ox::Span{cbb.elements} + i * renderer::BgVertexEboLength; auto const ebo = ox::Span{cbb.elements} + i * renderer::BgVertexEboLength;
auto &bg = ctx.backgrounds[bgIdx]; auto &bg = ctx.backgrounds[bgIdx];
renderer::setTileBufferObject( renderer::setTileBufferObject(
static_cast<uint_t>(i * renderer::BgVertexVboRows), static_cast<uint_t>(i * renderer::BgVertexVboRows),

View File

@ -8,7 +8,6 @@
#include <keel/typeconv.hpp> #include <keel/typeconv.hpp>
#include <nostalgia/gfx/context.hpp>
#include <nostalgia/gfx/palette.hpp> #include <nostalgia/gfx/palette.hpp>
#include <nostalgia/gfx/tilesheet.hpp> #include <nostalgia/gfx/tilesheet.hpp>

View File

@ -30,7 +30,7 @@ static class: public studio::Module {
} }
} const mod; } const mod;
const studio::Module *studioModule() noexcept { studio::Module const *studioModule() noexcept {
return &mod; return &mod;
} }

View File

@ -48,7 +48,7 @@ CutPasteCommand::CutPasteCommand(
ox::Error CutPasteCommand::redo() noexcept { ox::Error CutPasteCommand::redo() noexcept {
auto &subsheet = getSubSheet(m_img, m_subSheetIdx); auto &subsheet = getSubSheet(m_img, m_subSheetIdx);
for (const auto &c : m_changes) { for (auto const &c : m_changes) {
subsheet.pixels[c.idx] = static_cast<uint8_t>(c.newPalIdx); subsheet.pixels[c.idx] = static_cast<uint8_t>(c.newPalIdx);
} }
return {}; return {};
@ -56,7 +56,7 @@ ox::Error CutPasteCommand::redo() noexcept {
ox::Error CutPasteCommand::undo() noexcept { ox::Error CutPasteCommand::undo() noexcept {
auto &subsheet = getSubSheet(m_img, m_subSheetIdx); auto &subsheet = getSubSheet(m_img, m_subSheetIdx);
for (const auto &c : m_changes) { for (auto const &c : m_changes) {
subsheet.pixels[c.idx] = static_cast<uint8_t>(c.oldPalIdx); subsheet.pixels[c.idx] = static_cast<uint8_t>(c.oldPalIdx);
} }
return {}; return {};

View File

@ -194,6 +194,7 @@ void TileSheetEditorImGui::keyStateChanged(turbine::Key const key, bool const do
void TileSheetEditorImGui::draw(studio::Context&) noexcept { void TileSheetEditorImGui::draw(studio::Context&) noexcept {
setCopyEnabled(m_model.hasSelection()); setCopyEnabled(m_model.hasSelection());
setCutEnabled(m_model.hasSelection()); setCutEnabled(m_model.hasSelection());
setPasteEnabled(m_model.hasSelection());
if (ig::mainWinHasFocus() && m_tool == TileSheetTool::Select) { if (ig::mainWinHasFocus() && m_tool == TileSheetTool::Select) {
if (ImGui::IsKeyDown(ImGuiKey_ModCtrl) && !m_palPathFocused) { if (ImGui::IsKeyDown(ImGuiKey_ModCtrl) && !m_palPathFocused) {
if (ImGui::IsKeyPressed(ImGuiKey_A)) { if (ImGui::IsKeyPressed(ImGuiKey_A)) {

View File

@ -92,7 +92,7 @@ void TileSheetEditorView::clickFill(ox::Vec2 const&paneSize, ox::Vec2 const&clic
m_model.fill(pt, static_cast<uint8_t>(m_palIdx)); m_model.fill(pt, static_cast<uint8_t>(m_palIdx));
} }
void TileSheetEditorView::releaseMouseButton(TileSheetTool tool) noexcept { void TileSheetEditorView::releaseMouseButton(TileSheetTool const tool) noexcept {
switch (tool) { switch (tool) {
case TileSheetTool::Draw: case TileSheetTool::Draw:
case TileSheetTool::Fill: 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 { ox::Point TileSheetEditorView::clickPoint(ox::Vec2 const &paneSize, ox::Vec2 const &clickPos) const noexcept {
auto [x, y] = clickPos; auto [x, y] = clickPos;
const auto pixDrawSz = m_pixelsDrawer.pixelSize(paneSize); auto const pixDrawSz = m_pixelsDrawer.pixelSize(paneSize);
x /= paneSize.x; x /= paneSize.x;
y /= paneSize.y; y /= paneSize.y;
x += -m_scrollOffset.x / 2; x += -m_scrollOffset.x / 2;

View File

@ -73,7 +73,8 @@ class TileSheetGrid {
void update(ox::Vec2 const &paneSize, TileSheet::SubSheet const &subsheet) noexcept; void update(ox::Vec2 const &paneSize, TileSheet::SubSheet const &subsheet) noexcept;
private: 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; void setBufferObjects(ox::Vec2 const &paneSize, TileSheet::SubSheet const &subsheet) noexcept;

View File

@ -86,12 +86,12 @@ static void setPixel(
int const columns, int const columns,
ox::Point const &pt, ox::Point const &pt,
uint8_t const palIdx) noexcept { uint8_t const palIdx) noexcept {
const auto idx = ptToIdx(pt, columns); auto const idx = ptToIdx(pt, columns);
pixels[idx] = palIdx; pixels[idx] = palIdx;
} }
void setPixel(TileSheet::SubSheet &ss, ox::Point const &pt, uint8_t const palIdx) noexcept { void setPixel(TileSheet::SubSheet &ss, ox::Point const &pt, uint8_t const palIdx) noexcept {
const auto idx = ptToIdx(pt, ss.columns); auto const idx = ptToIdx(pt, ss.columns);
ss.pixels[idx] = palIdx; ss.pixels[idx] = palIdx;
} }
@ -154,8 +154,8 @@ ox::Result<ox::StringView> getNameFor(TileSheet::SubSheet const&ss, SubSheetId c
if (ss.id == pId) { if (ss.id == pId) {
return ox::StringView(ss.name); return ox::StringView(ss.name);
} }
for (const auto &sub : ss.subsheets) { for (auto const &sub : ss.subsheets) {
const auto [name, err] = getNameFor(sub, pId); auto const [name, err] = getNameFor(sub, pId);
if (!err) { if (!err) {
return name; return name;
} }
@ -222,7 +222,7 @@ static TileSheet::SubSheet const&getSubSheet(
if (idxIt == idx.size()) { if (idxIt == idx.size()) {
return pSubsheet; return pSubsheet;
} }
const auto currentIdx = idx[idxIt]; auto const currentIdx = idx[idxIt];
if (pSubsheet.subsheets.size() < currentIdx) { if (pSubsheet.subsheets.size() < currentIdx) {
return pSubsheet; return pSubsheet;
} }
@ -437,13 +437,13 @@ ox::Vector<uint32_t> resizeTileSheetData(
ox::Vector<uint32_t> dst; ox::Vector<uint32_t> dst;
auto dstWidth = srcSize.width * scale; auto dstWidth = srcSize.width * scale;
auto dstHeight = srcSize.height * scale; auto dstHeight = srcSize.height * scale;
const auto pixelCnt = dstWidth * dstHeight; auto const pixelCnt = dstWidth * dstHeight;
dst.resize(static_cast<std::size_t>(pixelCnt)); dst.resize(static_cast<std::size_t>(pixelCnt));
for (auto i = 0; i < pixelCnt; ++i) { for (auto i = 0; i < pixelCnt; ++i) {
const auto dstPt = idxToPt(i, 1, scale); auto const dstPt = idxToPt(i, 1, scale);
const auto srcPt = dstPt / ox::Point{scale, scale}; auto const srcPt = dstPt / ox::Point{scale, scale};
const auto srcIdx = ptToIdx(srcPt, 1); auto const srcIdx = ptToIdx(srcPt, 1);
const auto srcPixel = srcPixels[srcIdx]; auto const srcPixel = srcPixels[srcIdx];
dst[static_cast<std::size_t>(i)] = srcPixel; dst[static_cast<std::size_t>(i)] = srcPixel;
} }
return dst; return dst;

View File

@ -24,7 +24,7 @@ static std::map<ox::StringView, ox::Error(*)()> tests = {
}, },
}; };
int main(int argc, const char **argv) { int main(int argc, char const **argv) {
int retval = -1; int retval = -1;
if (argc > 0) { if (argc > 0) {
auto const args = ox::Span{argv, static_cast<size_t>(argc)}; auto const args = ox::Span{argv, static_cast<size_t>(argc)};

View File

@ -11,7 +11,7 @@
static std::map<ox::StringView, ox::Error(*)()> tests = { static std::map<ox::StringView, ox::Error(*)()> tests = {
}; };
int main(int argc, const char **argv) { int main(int argc, char const **argv) {
int retval = -1; int retval = -1;
if (argc > 0) { if (argc > 0) {
auto const args = ox::Span{argv, static_cast<size_t>(argc)}; auto const args = ox::Span{argv, static_cast<size_t>(argc)};

View File

@ -55,7 +55,7 @@ void registerStudioModules() noexcept;
#if defined(_WIN32) && OLYMPIC_GUI_APP #if defined(_WIN32) && OLYMPIC_GUI_APP
int WinMain() { int WinMain() {
auto const argc = __argc; auto const argc = __argc;
auto const argv = const_cast<const char**>(__argv); auto const argv = const_cast<char const**>(__argv);
#else #else
int main(int const argc, char const **argv) { int main(int const argc, char const **argv) {
#endif #endif

View File

@ -26,7 +26,7 @@ ox::Error writeUuidHeader(ox::Writer_c auto &writer, ox::UUID const&uuid) noexce
template<typename T> template<typename T>
ox::Result<T> readAsset(ox::BufferView buff) noexcept { ox::Result<T> readAsset(ox::BufferView buff) noexcept {
std::size_t offset = 0; std::size_t offset = 0;
const auto err = readUuidHeader(buff).error; auto const err = readUuidHeader(buff).error;
if (!err) { if (!err) {
offset = K1HdrSz; // the size of K1 headers offset = K1HdrSz; // the size of K1 headers
} }

View File

@ -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 { ox::Result<ox::StringView> readAssetTypeId(ox::BufferView const buff) noexcept {
const auto err = readUuidHeader(buff).error; auto const err = readUuidHeader(buff).error;
const auto offset = err ? 0u : K1HdrSz; auto const offset = err ? 0u : K1HdrSz;
if (offset >= buff.size()) [[unlikely]] { if (offset >= buff.size()) [[unlikely]] {
return ox::Error(1, "Buffer too small for expected data"); 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> readAssetHeader(ox::BufferView buff) noexcept {
ox::Result<AssetHdr> out; ox::Result<AssetHdr> out;
const auto err = readUuidHeader(buff).moveTo(out.value.uuid); auto const err = readUuidHeader(buff).moveTo(out.value.uuid);
const auto offset = err ? 0u : K1HdrSz; auto const offset = err ? 0u : K1HdrSz;
if (offset >= buff.size()) [[unlikely]] { if (offset >= buff.size()) [[unlikely]] {
return ox::Error(1, "Buffer too small for expected data"); return ox::Error(1, "Buffer too small for expected data");
} }

View File

@ -49,7 +49,7 @@ static ox::Result<ox::UPtr<Wrap>> convert(
if (!subConverter.converter().dstMatches(dstTypeName, dstTypeVersion)) { if (!subConverter.converter().dstMatches(dstTypeName, dstTypeVersion)) {
continue; continue;
} }
const auto [intermediate, chainErr] = auto const [intermediate, chainErr] =
convert(ctx, converters, src, srcTypeName, srcTypeVersion, convert(ctx, converters, src, srcTypeName, srcTypeVersion,
subConverter.converter().srcTypeName(), subConverter.converter().srcTypeVersion()); subConverter.converter().srcTypeName(), subConverter.converter().srcTypeVersion());
if (!chainErr) { if (!chainErr) {

View File

@ -25,7 +25,7 @@ static std::map<ox::StringView, ox::Error(*)()> tests = {
}, },
}; };
int main(int argc, const char **argv) { int main(int argc, char const **argv) {
int retval = -1; int retval = -1;
if (argc > 0) { if (argc > 0) {
auto const args = ox::Span{argv, static_cast<size_t>(argc)}; auto const args = ox::Span{argv, static_cast<size_t>(argc)};

View File

@ -61,7 +61,7 @@ static ox::Error runApp(
static ox::Error run( static ox::Error run(
ox::StringViewCR appName, ox::StringViewCR appName,
ox::StringViewCR projectDataDir, ox::StringViewCR projectDataDir,
ox::SpanView<const char*>) { ox::SpanView<ox::CString>) {
// seed UUID generator // seed UUID generator
auto const time = std::time(nullptr); auto const time = std::time(nullptr);
ox::UUID::seedGenerator({ ox::UUID::seedGenerator({

View File

@ -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 { void ClawEditor::drawTree(ObjPath &path, ox::ModelObject const&obj) noexcept {
using Str = ox::BasicString<100>; using Str = ox::BasicString<100>;
for (const auto &c : obj) { for (auto const &c : obj) {
ImGui::TableNextRow(0, 5); ImGui::TableNextRow(0, 5);
auto pathStr = ox::join<Str>("##", path).unwrap(); auto pathStr = ox::join<Str>("##", path).unwrap();
auto lbl = ox::sfmt<Str>("{}##{}", c->name, pathStr); auto lbl = ox::sfmt<Str>("{}##{}", c->name, pathStr);
const auto rowSelected = false; auto const rowSelected = false;
const auto hasChildren = c->value.type() == ox::ModelValue::Type::Object auto const hasChildren = c->value.type() == ox::ModelValue::Type::Object
|| c->value.type() == ox::ModelValue::Type::Vector; || c->value.type() == ox::ModelValue::Type::Vector;
const auto flags = ImGuiTreeNodeFlags_SpanFullWidth auto const flags = ImGuiTreeNodeFlags_SpanFullWidth
| ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnArrow
| (hasChildren ? 0 : ImGuiTreeNodeFlags_Leaf) | (hasChildren ? 0 : ImGuiTreeNodeFlags_Leaf)
| (rowSelected ? ImGuiTreeNodeFlags_Selected : 0); | (rowSelected ? ImGuiTreeNodeFlags_Selected : 0);
@ -158,7 +158,7 @@ void ClawEditor::drawTree(ObjPath &path, ox::ModelObject const&obj) noexcept {
//} //}
path.push_back(c->name); path.push_back(c->name);
if (c->value.type() == ox::ModelValue::Type::Object) { if (c->value.type() == ox::ModelValue::Type::Object) {
const auto open = ImGui::TreeNodeEx(lbl.c_str(), flags); auto const open = ImGui::TreeNodeEx(lbl.c_str(), flags);
ImGui::SameLine(); ImGui::SameLine();
drawRow(c->value); drawRow(c->value);
if (open) { if (open) {

View File

@ -635,8 +635,7 @@ ox::Error StudioUI::openProjectPath(ox::StringParam path) noexcept {
keel::DuplicateSet ds; keel::DuplicateSet ds;
OX_RETURN_ERROR(keel::setRomFs(keelCtx(m_tctx), std::move(fs), ds)); OX_RETURN_ERROR(keel::setRomFs(keelCtx(m_tctx), std::move(fs), ds));
if (ds.size()) { if (ds.size()) {
ox::String msg; ox::String msg{"Multiple files have the same UUID:\n"};
msg += "Multiple files have the same UUID:\n";
for (auto const &k : ds.keys()) { for (auto const &k : ds.keys()) {
msg += ox::sfmt("\n\t{}:\n", k.toString()); msg += ox::sfmt("\n\t{}:\n", k.toString());
for (auto const &v : ds[k]) { for (auto const &v : ds[k]) {

View File

@ -131,7 +131,7 @@ class ChildStackItem {
class IDStackItem { class IDStackItem {
public: public:
explicit IDStackItem(int id) noexcept; explicit IDStackItem(int id) noexcept;
explicit IDStackItem(const char *id) noexcept; explicit IDStackItem(ox::CString const id) noexcept;
explicit IDStackItem(ox::CStringViewCR id) noexcept; explicit IDStackItem(ox::CStringViewCR id) noexcept;
~IDStackItem() 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 * @return true if new value selected, false otherwise
*/ */
bool ComboBox( bool ComboBox(
ox::CStringView lbl, ox::CStringView const &lbl,
ox::SpanView<ox::CStringView> list, ox::SpanView<ox::CStringView> list,
size_t &selectedIdx) noexcept; size_t &selectedIdx) noexcept;
@ -255,7 +255,7 @@ bool ComboBox(
* @param selectedIdx * @param selectedIdx
* @return true if new value selected, false otherwise * @return true if new value selected, false otherwise
*/ */
bool ComboBox(ox::CStringView lbl, ox::Span<const ox::String> list, size_t &selectedIdx) noexcept; bool ComboBox(ox::CStringView const &lbl, ox::Span<ox::String const> list, size_t &selectedIdx) noexcept;
/** /**
* *

View File

@ -18,11 +18,11 @@ ChildStackItem::~ChildStackItem() noexcept {
ImGui::EndChild(); ImGui::EndChild();
} }
IDStackItem::IDStackItem(int id) noexcept { IDStackItem::IDStackItem(int const id) noexcept {
ImGui::PushID(id); ImGui::PushID(id);
} }
IDStackItem::IDStackItem(const char *id) noexcept { IDStackItem::IDStackItem(ox::CString const id) noexcept {
ImGui::PushID(id); ImGui::PushID(id);
} }
@ -55,7 +55,7 @@ bool PushButton(ox::CStringViewCR lbl, ImVec2 const &btnSz) noexcept {
} }
PopupResponse PopupControlsOkCancel( PopupResponse PopupControlsOkCancel(
float popupWidth, float const popupWidth,
bool &popupOpen, bool &popupOpen,
ox::CStringViewCR ok, ox::CStringViewCR ok,
ox::CStringViewCR cancel) { ox::CStringViewCR cancel) {
@ -110,14 +110,14 @@ bool BeginPopup(turbine::Context &ctx, ox::CStringViewCR popupName, bool &show,
} }
bool ComboBox( bool ComboBox(
ox::CStringView lbl, ox::CStringView const &lbl,
ox::SpanView<ox::CStringView> list, ox::SpanView<ox::CStringView> const list,
size_t &selectedIdx) noexcept { size_t &selectedIdx) noexcept {
bool out{}; bool out{};
auto const first = selectedIdx < list.size() ? list[selectedIdx].c_str() : ""; auto const first = selectedIdx < list.size() ? list[selectedIdx].c_str() : "";
if (ImGui::BeginCombo(lbl.c_str(), first, 0)) { if (ImGui::BeginCombo(lbl.c_str(), first, 0)) {
for (auto i = 0u; i < list.size(); ++i) { for (auto i = 0u; i < list.size(); ++i) {
const auto selected = (selectedIdx == i); auto const selected = (selectedIdx == i);
if (ImGui::Selectable(list[i].c_str(), selected) && selectedIdx != i) { if (ImGui::Selectable(list[i].c_str(), selected) && selectedIdx != i) {
selectedIdx = i; selectedIdx = i;
out = true; out = true;
@ -129,14 +129,14 @@ bool ComboBox(
} }
bool ComboBox( bool ComboBox(
ox::CStringView lbl, ox::CStringView const &lbl,
ox::Span<const ox::String> list, ox::Span<ox::String const> const list,
size_t &selectedIdx) noexcept { size_t &selectedIdx) noexcept {
bool out{}; bool out{};
auto const first = selectedIdx < list.size() ? list[selectedIdx].c_str() : ""; auto const first = selectedIdx < list.size() ? list[selectedIdx].c_str() : "";
if (ImGui::BeginCombo(lbl.c_str(), first, 0)) { if (ImGui::BeginCombo(lbl.c_str(), first, 0)) {
for (auto i = 0u; i < list.size(); ++i) { for (auto i = 0u; i < list.size(); ++i) {
const auto selected = (selectedIdx == i); auto const selected = (selectedIdx == i);
if (ImGui::Selectable(list[i].c_str(), selected) && selectedIdx != i) { if (ImGui::Selectable(list[i].c_str(), selected) && selectedIdx != i) {
selectedIdx = i; selectedIdx = i;
out = true; out = true;
@ -150,13 +150,13 @@ bool ComboBox(
bool ComboBox( bool ComboBox(
ox::CStringViewCR lbl, ox::CStringViewCR lbl,
std::function<ox::CStringView(size_t)> const &f, std::function<ox::CStringView(size_t)> const &f,
size_t strCnt, size_t const strCnt,
size_t &selectedIdx) noexcept { size_t &selectedIdx) noexcept {
bool out{}; bool out{};
auto const first = selectedIdx < strCnt ? f(selectedIdx).c_str() : ""; auto const first = selectedIdx < strCnt ? f(selectedIdx).c_str() : "";
if (ImGui::BeginCombo(lbl.c_str(), first, 0)) { if (ImGui::BeginCombo(lbl.c_str(), first, 0)) {
for (auto i = 0u; i < strCnt; ++i) { for (auto i = 0u; i < strCnt; ++i) {
const auto selected = (selectedIdx == i); auto const selected = (selectedIdx == i);
if (ImGui::Selectable(f(i).c_str(), selected) && selectedIdx != i) { if (ImGui::Selectable(f(i).c_str(), selected) && selectedIdx != i) {
selectedIdx = i; selectedIdx = i;
out = true; out = true;