This commit is contained in:
@ -19,10 +19,10 @@ using Color32 = uint32_t;
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr Color32 toColor32(Color16 nc) noexcept {
|
||||
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);
|
||||
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);
|
||||
return r | (g << 8) | (b << 16) | (a << 24);
|
||||
}
|
||||
|
||||
|
@ -12,15 +12,15 @@ namespace nostalgia::gfx {
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr std::size_t ptToIdx(int x, int y, int c, int scale = 1) noexcept {
|
||||
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);
|
||||
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);
|
||||
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 {
|
||||
const auto tileWidth = TileWidth * scale;
|
||||
const auto tileHeight = TileHeight * scale;
|
||||
const auto pixelsPerTile = tileWidth * tileHeight;
|
||||
auto const tileWidth = TileWidth * scale;
|
||||
auto const tileHeight = TileHeight * scale;
|
||||
auto const pixelsPerTile = tileWidth * tileHeight;
|
||||
// prevent divide by zeros
|
||||
if (!c) {
|
||||
++c;
|
||||
}
|
||||
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
|
||||
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
|
||||
return {
|
||||
itx + tc * tileWidth,
|
||||
ity + tr * tileHeight,
|
||||
|
@ -246,7 +246,11 @@ 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] =
|
||||
@ -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 {
|
||||
auto &bgCtl = regBgCtl(bgIdx);
|
||||
const auto &cbbData = ctx.cbbData[cbbIdx];
|
||||
auto const &cbbData = ctx.cbbData[cbbIdx];
|
||||
teagba::bgSetBpp(bgCtl, cbbData.bpp);
|
||||
teagba::bgSetCbb(bgCtl, cbbIdx);
|
||||
}
|
||||
@ -341,13 +345,13 @@ uint_t spriteCount(Context const &) noexcept {
|
||||
|
||||
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;
|
||||
// reset heap to make sure we have enough memory to allocate context data
|
||||
OX_ALLOW_UNSAFE_BUFFERS_BEGIN
|
||||
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);
|
||||
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);
|
||||
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) {
|
||||
const auto i = bgVertexRow(x, y);
|
||||
auto const 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);
|
||||
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);
|
||||
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);
|
||||
glUniform1f(uniformXScale, hf / wf);
|
||||
auto bgIdx = 0.f;
|
||||
for (const auto &bg : ctx.backgrounds) {
|
||||
for (auto const &bg : ctx.backgrounds) {
|
||||
if (bg.enabled) {
|
||||
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));
|
||||
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;
|
||||
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);
|
||||
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);
|
||||
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
|
||||
const auto tileRows = sb.tex.height / (TileHeight * Scale);
|
||||
auto const 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);
|
||||
const auto uniformPalette = static_cast<GLint>(glGetUniformLocation(shaderPgrm, "fPalette"));
|
||||
auto const 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");
|
||||
const auto spriteVboSz = ctx.blocksPerSprite * renderer::SpriteVertexVboLength;
|
||||
const auto spriteEboSz = ctx.blocksPerSprite * renderer::SpriteVertexEboLength;
|
||||
auto const spriteVboSz = ctx.blocksPerSprite * renderer::SpriteVertexVboLength;
|
||||
auto const spriteEboSz = ctx.blocksPerSprite * renderer::SpriteVertexEboLength;
|
||||
auto const vboBase = spriteVboSz * idx;
|
||||
auto const eboBase = spriteEboSz * idx;
|
||||
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 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);
|
||||
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);
|
||||
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);
|
||||
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;
|
||||
const auto tiles = ts.pixels.size() / bytesPerTile;
|
||||
auto const tiles = ts.pixels.size() / bytesPerTile;
|
||||
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;
|
||||
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);
|
||||
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 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);
|
||||
auto &cbb = ctx.cbbs[z];
|
||||
const auto vbo = ox::Span{cbb.vertices} + i * renderer::BgVertexVboLength;
|
||||
const auto ebo = ox::Span{cbb.elements} + i * renderer::BgVertexEboLength;
|
||||
auto const vbo = ox::Span{cbb.vertices} + i * renderer::BgVertexVboLength;
|
||||
auto const ebo = ox::Span{cbb.elements} + i * renderer::BgVertexEboLength;
|
||||
auto &bg = ctx.backgrounds[bgIdx];
|
||||
renderer::setTileBufferObject(
|
||||
static_cast<uint_t>(i * renderer::BgVertexVboRows),
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
#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;
|
||||
|
||||
const studio::Module *studioModule() noexcept {
|
||||
studio::Module const *studioModule() noexcept {
|
||||
return &mod;
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ CutPasteCommand::CutPasteCommand(
|
||||
|
||||
ox::Error CutPasteCommand::redo() noexcept {
|
||||
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);
|
||||
}
|
||||
return {};
|
||||
@ -56,7 +56,7 @@ ox::Error CutPasteCommand::redo() noexcept {
|
||||
|
||||
ox::Error CutPasteCommand::undo() noexcept {
|
||||
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);
|
||||
}
|
||||
return {};
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
void TileSheetEditorView::releaseMouseButton(TileSheetTool tool) noexcept {
|
||||
void TileSheetEditorView::releaseMouseButton(TileSheetTool const 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;
|
||||
const auto pixDrawSz = m_pixelsDrawer.pixelSize(paneSize);
|
||||
auto const pixDrawSz = m_pixelsDrawer.pixelSize(paneSize);
|
||||
x /= paneSize.x;
|
||||
y /= paneSize.y;
|
||||
x += -m_scrollOffset.x / 2;
|
||||
|
@ -73,7 +73,8 @@ 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 {
|
||||
const auto idx = ptToIdx(pt, columns);
|
||||
auto const idx = ptToIdx(pt, columns);
|
||||
pixels[idx] = palIdx;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -154,8 +154,8 @@ ox::Result<ox::StringView> getNameFor(TileSheet::SubSheet const&ss, SubSheetId c
|
||||
if (ss.id == pId) {
|
||||
return ox::StringView(ss.name);
|
||||
}
|
||||
for (const auto &sub : ss.subsheets) {
|
||||
const auto [name, err] = getNameFor(sub, pId);
|
||||
for (auto const &sub : ss.subsheets) {
|
||||
auto const [name, err] = getNameFor(sub, pId);
|
||||
if (!err) {
|
||||
return name;
|
||||
}
|
||||
@ -222,7 +222,7 @@ static TileSheet::SubSheet const&getSubSheet(
|
||||
if (idxIt == idx.size()) {
|
||||
return pSubsheet;
|
||||
}
|
||||
const auto currentIdx = idx[idxIt];
|
||||
auto const 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;
|
||||
const auto pixelCnt = dstWidth * dstHeight;
|
||||
auto const pixelCnt = dstWidth * dstHeight;
|
||||
dst.resize(static_cast<std::size_t>(pixelCnt));
|
||||
for (auto i = 0; i < pixelCnt; ++i) {
|
||||
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];
|
||||
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];
|
||||
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, const char **argv) {
|
||||
int main(int argc, char const **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, const char **argv) {
|
||||
int main(int argc, char const **argv) {
|
||||
int retval = -1;
|
||||
if (argc > 0) {
|
||||
auto const args = ox::Span{argv, static_cast<size_t>(argc)};
|
||||
|
@ -55,7 +55,7 @@ void registerStudioModules() noexcept;
|
||||
#if defined(_WIN32) && OLYMPIC_GUI_APP
|
||||
int WinMain() {
|
||||
auto const argc = __argc;
|
||||
auto const argv = const_cast<const char**>(__argv);
|
||||
auto const argv = const_cast<char const**>(__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;
|
||||
const auto err = readUuidHeader(buff).error;
|
||||
auto const 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 {
|
||||
const auto err = readUuidHeader(buff).error;
|
||||
const auto offset = err ? 0u : K1HdrSz;
|
||||
auto const err = readUuidHeader(buff).error;
|
||||
auto const 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;
|
||||
const auto err = readUuidHeader(buff).moveTo(out.value.uuid);
|
||||
const auto offset = err ? 0u : K1HdrSz;
|
||||
auto const err = readUuidHeader(buff).moveTo(out.value.uuid);
|
||||
auto const 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;
|
||||
}
|
||||
const auto [intermediate, chainErr] =
|
||||
auto const [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, const char **argv) {
|
||||
int main(int argc, char const **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<const char*>) {
|
||||
ox::SpanView<ox::CString>) {
|
||||
// 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 (const auto &c : obj) {
|
||||
for (auto const &c : obj) {
|
||||
ImGui::TableNextRow(0, 5);
|
||||
auto pathStr = ox::join<Str>("##", path).unwrap();
|
||||
auto lbl = ox::sfmt<Str>("{}##{}", c->name, pathStr);
|
||||
const auto rowSelected = false;
|
||||
const auto hasChildren = c->value.type() == ox::ModelValue::Type::Object
|
||||
auto const rowSelected = false;
|
||||
auto const hasChildren = c->value.type() == ox::ModelValue::Type::Object
|
||||
|| c->value.type() == ox::ModelValue::Type::Vector;
|
||||
const auto flags = ImGuiTreeNodeFlags_SpanFullWidth
|
||||
auto const 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) {
|
||||
const auto open = ImGui::TreeNodeEx(lbl.c_str(), flags);
|
||||
auto const open = ImGui::TreeNodeEx(lbl.c_str(), flags);
|
||||
ImGui::SameLine();
|
||||
drawRow(c->value);
|
||||
if (open) {
|
||||
|
@ -131,7 +131,7 @@ class ChildStackItem {
|
||||
class IDStackItem {
|
||||
public:
|
||||
explicit IDStackItem(int id) noexcept;
|
||||
explicit IDStackItem(const char *id) noexcept;
|
||||
explicit IDStackItem(ox::CString const 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 lbl,
|
||||
ox::CStringView const &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 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;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -18,11 +18,11 @@ ChildStackItem::~ChildStackItem() noexcept {
|
||||
ImGui::EndChild();
|
||||
}
|
||||
|
||||
IDStackItem::IDStackItem(int id) noexcept {
|
||||
IDStackItem::IDStackItem(int const id) noexcept {
|
||||
ImGui::PushID(id);
|
||||
}
|
||||
|
||||
IDStackItem::IDStackItem(const char *id) noexcept {
|
||||
IDStackItem::IDStackItem(ox::CString const id) noexcept {
|
||||
ImGui::PushID(id);
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@ bool PushButton(ox::CStringViewCR lbl, ImVec2 const &btnSz) noexcept {
|
||||
}
|
||||
|
||||
PopupResponse PopupControlsOkCancel(
|
||||
float popupWidth,
|
||||
float const 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 lbl,
|
||||
ox::SpanView<ox::CStringView> list,
|
||||
ox::CStringView const &lbl,
|
||||
ox::SpanView<ox::CStringView> const 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) {
|
||||
const auto selected = (selectedIdx == i);
|
||||
auto const 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 lbl,
|
||||
ox::Span<const ox::String> list,
|
||||
ox::CStringView const &lbl,
|
||||
ox::Span<ox::String const> const 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) {
|
||||
const auto selected = (selectedIdx == i);
|
||||
auto const 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 strCnt,
|
||||
size_t const 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) {
|
||||
const auto selected = (selectedIdx == i);
|
||||
auto const selected = (selectedIdx == i);
|
||||
if (ImGui::Selectable(f(i).c_str(), selected) && selectedIdx != i) {
|
||||
selectedIdx = i;
|
||||
out = true;
|
||||
|
Reference in New Issue
Block a user