From aa19cdf535b48edc3417a4202308b40133944f45 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Wed, 7 Jun 2023 00:41:31 -0500 Subject: [PATCH] [keel,nostalgia,studio] Fix implicit conversions --- src/keel/media.cpp | 4 +- src/nostalgia/appmodules/CMakeLists.txt | 2 +- src/nostalgia/core/CMakeLists.txt | 1 + src/nostalgia/core/color.hpp | 17 ++- src/nostalgia/core/gba/gfx.cpp | 26 ++-- src/nostalgia/core/studio/CMakeLists.txt | 22 +++- .../core/studio/paletteeditor-imgui.cpp | 3 +- .../core/studio/tilesheeteditor-imgui.cpp | 6 +- .../core/studio/tilesheeteditormodel.cpp | 10 +- src/nostalgia/core/tilesheet.hpp | 17 +-- src/nostalgia/scene/scene.cpp | 9 +- src/nostalgia/scene/scenestatic.hpp | 16 ++- src/studio/applib/src/newmenu.cpp | 1 - src/studio/modlib/include/studio/popup.hpp | 13 +- src/studio/modlib/src/popup.cpp | 12 ++ src/studio/modlib/src/project.cpp | 2 +- src/turbine/gba/turbine.cpp | 5 +- src/turbine/glfw/gfx.cpp | 113 ++++++++++-------- 18 files changed, 162 insertions(+), 117 deletions(-) diff --git a/src/keel/media.cpp b/src/keel/media.cpp index ca56ec61..e5671bb7 100644 --- a/src/keel/media.cpp +++ b/src/keel/media.cpp @@ -116,7 +116,7 @@ ox::Result getPreloadAddr(keel::Context *ctx, ox::CRStringView path oxRequire(stat, ctx->rom->stat(path)); oxRequire(buff, static_cast(ctx->rom.get())->directAccess(path)); PreloadPtr p; - oxReturnError(ox::readMC(buff, stat.size, &p)); + oxReturnError(ox::readMC(buff, static_cast(stat.size), &p)); return static_cast(p.preloadAddr) + ctx->preloadSectionOffset; } @@ -124,7 +124,7 @@ ox::Result getPreloadAddr(keel::Context *ctx, const ox::FileAddress oxRequire(stat, ctx->rom->stat(file)); oxRequire(buff, static_cast(ctx->rom.get())->directAccess(file)); PreloadPtr p; - oxReturnError(ox::readMC(buff, stat.size, &p)); + oxReturnError(ox::readMC(buff, static_cast(stat.size), &p)); return static_cast(p.preloadAddr) + ctx->preloadSectionOffset; } diff --git a/src/nostalgia/appmodules/CMakeLists.txt b/src/nostalgia/appmodules/CMakeLists.txt index 0d3bb8db..9083583c 100644 --- a/src/nostalgia/appmodules/CMakeLists.txt +++ b/src/nostalgia/appmodules/CMakeLists.txt @@ -26,7 +26,7 @@ if(TURBINE_BUILD_TYPE STREQUAL "Native") target_link_libraries( NostalgiaStudioModules PUBLIC StudioAppLib - NostalgiaCore-Studio + NostalgiaCore-Studio-ImGui NostalgiaScene-Studio ) if(NOT MSVC) diff --git a/src/nostalgia/core/CMakeLists.txt b/src/nostalgia/core/CMakeLists.txt index 4a89e5f2..eb497e33 100644 --- a/src/nostalgia/core/CMakeLists.txt +++ b/src/nostalgia/core/CMakeLists.txt @@ -13,6 +13,7 @@ endif() if(NOT MSVC) target_compile_options(NostalgiaCore PUBLIC -Wsign-conversion) + target_compile_options(NostalgiaCore PRIVATE -Wconversion) endif() target_link_libraries( diff --git a/src/nostalgia/core/color.hpp b/src/nostalgia/core/color.hpp index d80e0bec..90efbed0 100644 --- a/src/nostalgia/core/color.hpp +++ b/src/nostalgia/core/color.hpp @@ -46,7 +46,7 @@ constexpr uint8_t blue16(Color16 c) noexcept { [[nodiscard]] constexpr uint8_t alpha16(Color16 c) noexcept { - return c >> 15; + return static_cast(c >> 15); } [[nodiscard]] @@ -66,7 +66,7 @@ constexpr uint8_t blue32(Color16 c) noexcept { [[nodiscard]] constexpr uint8_t alpha32(Color16 c) noexcept { - return (c >> 15) * 255; + return static_cast((c >> 15) * 255); } @@ -128,9 +128,20 @@ constexpr float bluef(Color32 c) noexcept { } +[[nodiscard]] +constexpr Color16 color16(int r, int g, int b, int a = 0) noexcept { + return static_cast(ox::min(static_cast(r), 31)) + | static_cast(ox::min(static_cast(g), 31) << 5) + | static_cast(ox::min(static_cast(b), 31) << 10) + | static_cast(a << 15); +} + [[nodiscard]] constexpr Color16 color16(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 0) noexcept { - return ox::min(r, 31) | (ox::min(g, 31) << 5) | (ox::min(b, 31) << 10) | (a << 15); + return static_cast(ox::min(r, 31)) + | static_cast(ox::min(g, 31) << 5) + | static_cast(ox::min(b, 31) << 10) + | static_cast(a << 15); } static_assert(color16(0, 31, 0) == 992); diff --git a/src/nostalgia/core/gba/gfx.cpp b/src/nostalgia/core/gba/gfx.cpp index c2dd12bc..fac4f9c8 100644 --- a/src/nostalgia/core/gba/gfx.cpp +++ b/src/nostalgia/core/gba/gfx.cpp @@ -138,12 +138,12 @@ ox::Error loadBgTileSheet(Context *ctx, target.pal.palette = MEM_BG_PALETTE; target.cbbData = &g_cbbData[cbb]; target.tileMap = MEM_BG_TILES[cbb].data(); - oxReturnError(ox::readMC(ts, tsStat.size, &target)); + oxReturnError(ox::readMC(ts, static_cast(tsStat.size), &target)); // load external palette if available if (paletteAddr) { oxRequire(palStat, gctx.rom().stat(paletteAddr)); oxRequire(pal, static_cast(gctx.rom()).directAccess(paletteAddr)); - oxReturnError(ox::readMC(pal, palStat.size, &target.pal)); + oxReturnError(ox::readMC(pal, static_cast(palStat.size), &target.pal)); } // update bpp of all bgs with the updated cbb const auto bpp = g_cbbData[cbb].bpp; @@ -164,12 +164,12 @@ ox::Error loadSpriteTileSheet(Context *ctx, GbaTileMapTarget target; target.pal.palette = MEM_SPRITE_PALETTE; target.tileMap = MEM_SPRITE_TILES; - oxReturnError(ox::readMC(ts, tsStat.size, &target)); + oxReturnError(ox::readMC(ts, static_cast(tsStat.size), &target)); // load external palette if available if (paletteAddr) { oxRequire(palStat, gctx.rom().stat(paletteAddr)); oxRequire(pal, static_cast(gctx.rom()).directAccess(paletteAddr)); - oxReturnError(ox::readMC(pal, palStat.size, &target.pal)); + oxReturnError(ox::readMC(pal, static_cast(palStat.size), &target.pal)); } return {}; } @@ -180,7 +180,7 @@ ox::Error loadBgPalette(Context *ctx, unsigned, const ox::FileAddress &paletteAd target.palette = MEM_BG_PALETTE; oxRequire(palStat, gctx.rom().stat(paletteAddr)); oxRequire(pal, static_cast(gctx.rom()).directAccess(paletteAddr)); - oxReturnError(ox::readMC(pal, palStat.size, &target)); + oxReturnError(ox::readMC(pal, static_cast(palStat.size), &target)); return {}; } @@ -190,7 +190,7 @@ ox::Error loadSpritePalette(Context *ctx, unsigned cbb, const ox::FileAddress &p target.palette = &MEM_SPRITE_PALETTE[cbb]; oxRequire(palStat, gctx.rom().stat(paletteAddr)); oxRequire(pal, static_cast(gctx.rom()).directAccess(paletteAddr)); - oxReturnError(ox::readMC(pal, palStat.size, &target)); + oxReturnError(ox::readMC(pal, static_cast(palStat.size), &target)); return {}; } @@ -217,7 +217,7 @@ void hideSprite(Context*, unsigned idx) noexcept { //oxAssert(g_spriteUpdates < config::GbaSpriteBufferLen, "Sprite update buffer overflow"); teagba::GbaSpriteAttrUpdate oa; oa.attr0 = 2 << 8; - oa.idx = idx; + oa.idx = static_cast(idx); teagba::addSpriteUpdate(oa); } @@ -231,14 +231,16 @@ void setSprite(Context*, unsigned flipX) noexcept { //oxAssert(g_spriteUpdates < config::GbaSpriteBufferLen, "Sprite update buffer overflow"); teagba::GbaSpriteAttrUpdate oa; - oa.attr0 = static_cast(y & ox::onMask(0b111'1111)) + oa.attr0 = static_cast( + static_cast(y & ox::onMask(0b111'1111)) | (static_cast(1) << 10) // enable alpha - | (static_cast(spriteShape) << 14); - oa.attr1 = (static_cast(x) & ox::onMask(8)) + | (static_cast(spriteShape) << 14)); + oa.attr1 = static_cast( + (static_cast(x) & ox::onMask(8)) | (static_cast(flipX) << 12) - | (static_cast(spriteSize) << 14); + | (static_cast(spriteSize) << 14)); oa.attr2 = static_cast(tileIdx & ox::onMask(8)); - oa.idx = idx; + oa.idx = static_cast(idx); teagba::addSpriteUpdate(oa); } diff --git a/src/nostalgia/core/studio/CMakeLists.txt b/src/nostalgia/core/studio/CMakeLists.txt index d7f6629e..aa010144 100644 --- a/src/nostalgia/core/studio/CMakeLists.txt +++ b/src/nostalgia/core/studio/CMakeLists.txt @@ -1,23 +1,34 @@ add_library( - NostalgiaCore-Studio OBJECT - studiomodule.cpp + NostalgiaCore-Studio paletteeditor.cpp - paletteeditor-imgui.cpp - tilesheeteditor-imgui.cpp tilesheeteditorview.cpp tilesheeteditormodel.cpp tilesheetpixelgrid.cpp tilesheetpixels.cpp ) +add_library( + NostalgiaCore-Studio-ImGui OBJECT + studiomodule.cpp + paletteeditor-imgui.cpp + tilesheeteditor-imgui.cpp +) + if(NOT MSVC) target_compile_options(NostalgiaCore-Studio PRIVATE -Wsign-conversion) + target_compile_options(NostalgiaCore-Studio-ImGui PRIVATE -Wsign-conversion) endif() target_link_libraries( NostalgiaCore-Studio PUBLIC - Studio NostalgiaCore + Studio +) + +target_link_libraries( + NostalgiaCore-Studio-ImGui PUBLIC + NostalgiaCore-Studio + Studio lodepng ) @@ -25,6 +36,7 @@ target_link_libraries( install( TARGETS + NostalgiaCore-Studio-ImGui NostalgiaCore-Studio LIBRARY DESTINATION ${NOSTALGIA_DIST_MODULE} diff --git a/src/nostalgia/core/studio/paletteeditor-imgui.cpp b/src/nostalgia/core/studio/paletteeditor-imgui.cpp index 8abbd57d..64177211 100644 --- a/src/nostalgia/core/studio/paletteeditor-imgui.cpp +++ b/src/nostalgia/core/studio/paletteeditor-imgui.cpp @@ -53,7 +53,8 @@ void PaletteEditorImGui::draw(turbine::Context*) noexcept { const auto sz = ImVec2(70, 24); if (ImGui::Button("Add", sz)) { const auto colorSz = static_cast(m_pal.colors.size()); - undoStack()->push(ox::make(&m_pal, 0, colorSz)); + constexpr Color16 c = 0; + undoStack()->push(ox::make(&m_pal, c, colorSz)); } ImGui::SameLine(); ImGui::BeginDisabled(m_selectedRow >= m_pal.colors.size()); diff --git a/src/nostalgia/core/studio/tilesheeteditor-imgui.cpp b/src/nostalgia/core/studio/tilesheeteditor-imgui.cpp index d0415a68..2207576c 100644 --- a/src/nostalgia/core/studio/tilesheeteditor-imgui.cpp +++ b/src/nostalgia/core/studio/tilesheeteditor-imgui.cpp @@ -35,7 +35,7 @@ ox::Error toPngFile(const ox::String &path, const TileSheet::SubSheet &s, const ++idx; } constexpr auto fmt = alpha ? LCT_RGBA : LCT_RGB; - return OxError(lodepng_encode_file(path.c_str(), outData.data(), width, height, fmt, 8)); + return OxError(static_cast(lodepng_encode_file(path.c_str(), outData.data(), width, height, fmt, 8))); } TileSheetEditorImGui::TileSheetEditorImGui(turbine::Context *ctx, ox::CRStringView path): m_tileSheetEditor(ctx, path) { @@ -361,8 +361,8 @@ void TileSheetEditorImGui::drawPaletteSelector() noexcept { } // header if (ImGui::BeginTable("PaletteTable", 3, ImGuiTableFlags_RowBg | ImGuiTableFlags_SizingStretchProp)) { - ImGui::TableSetupColumn("No.", 0, 0.45); - ImGui::TableSetupColumn("", 0, 0.22); + ImGui::TableSetupColumn("No.", 0, 0.45f); + ImGui::TableSetupColumn("", 0, 0.22f); ImGui::TableSetupColumn("Color16", 0, 3); ImGui::TableHeadersRow(); if (auto pal = m_tileSheetEditor.pal()) { diff --git a/src/nostalgia/core/studio/tilesheeteditormodel.cpp b/src/nostalgia/core/studio/tilesheeteditormodel.cpp index ae049886..1bd81f10 100644 --- a/src/nostalgia/core/studio/tilesheeteditormodel.cpp +++ b/src/nostalgia/core/studio/tilesheeteditormodel.cpp @@ -130,7 +130,7 @@ class DrawCommand: public TileSheetCommand { }); if (existing == m_changes.cend()) { m_changes.emplace_back(static_cast(idx), subsheet.getPixel(m_img->bpp, idx)); - subsheet.setPixel(m_img->bpp, idx, m_palIdx); + subsheet.setPixel(m_img->bpp, idx, static_cast(m_palIdx)); return true; } } @@ -148,14 +148,14 @@ class DrawCommand: public TileSheetCommand { void redo() noexcept final { auto &subsheet = m_img->getSubSheet(m_subSheetIdx); for (const auto &c : m_changes) { - subsheet.setPixel(m_img->bpp, c.idx, m_palIdx); + subsheet.setPixel(m_img->bpp, c.idx, static_cast(m_palIdx)); } } void undo() noexcept final { auto &subsheet = m_img->getSubSheet(m_subSheetIdx); for (const auto &c : m_changes) { - subsheet.setPixel(m_img->bpp, c.idx, c.oldPalIdx); + subsheet.setPixel(m_img->bpp, c.idx, static_cast(c.oldPalIdx)); } } @@ -205,14 +205,14 @@ class CutPasteCommand: public TileSheetCommand { void redo() noexcept final { auto &subsheet = m_img->getSubSheet(m_subSheetIdx); for (const auto &c : m_changes) { - subsheet.setPixel(m_img->bpp, c.idx, c.newPalIdx); + subsheet.setPixel(m_img->bpp, c.idx, static_cast(c.newPalIdx)); } } void undo() noexcept final { auto &subsheet = m_img->getSubSheet(m_subSheetIdx); for (const auto &c : m_changes) { - subsheet.setPixel(m_img->bpp, c.idx, c.oldPalIdx); + subsheet.setPixel(m_img->bpp, c.idx, static_cast(c.oldPalIdx)); } } diff --git a/src/nostalgia/core/tilesheet.hpp b/src/nostalgia/core/tilesheet.hpp index 39e4a864..f780f446 100644 --- a/src/nostalgia/core/tilesheet.hpp +++ b/src/nostalgia/core/tilesheet.hpp @@ -138,8 +138,8 @@ struct TileSheet { } else { if (pBpp == 4) { for (auto p: this->pixels) { - pPixels->emplace_back(p & 0b1111); - pPixels->emplace_back(p >> 4); + pPixels->emplace_back(static_cast(p & 0b1111)); + pPixels->emplace_back(static_cast(p >> 4)); } } else { for (auto p: this->pixels) { @@ -226,14 +226,15 @@ struct TileSheet { pixels.size()); //oxAssert(pixels.size() == pixelCnt, "Pixel count does not match rows and columns"); for (std::size_t i = 0; i < pixelCnt; ++i) { - const auto colorIdx1 = pixels[i] & 0xF; - const auto colorIdx2 = pixels[i] >> 4; + const auto colorIdx1 = static_cast(pixels[i] & 0xF); + const auto colorIdx2 = static_cast(pixels[i] >> 4); callback(i * 2 + 0, colorIdx1); callback(i * 2 + 1, colorIdx2); } } else { - const auto pixelCnt = ox::min(static_cast(columns * rows * PixelsPerTile), - pixels.size()); + const auto pixelCnt = ox::min( + static_cast(columns * rows * PixelsPerTile), + pixels.size()); for (std::size_t i = 0; i < pixelCnt; ++i) { const auto p = pixels[i]; callback(i, p); @@ -242,10 +243,10 @@ struct TileSheet { } constexpr void setPixel(int8_t pBpp, uint64_t idx, uint8_t palIdx) noexcept { - auto &pixel = this->pixels[idx / 2]; + auto &pixel = this->pixels[static_cast(idx / 2)]; if (pBpp == 4) { if (idx & 1) { - pixel = (pixel & 0b0000'1111) | (palIdx << 4); + pixel = static_cast((pixel & 0b0000'1111) | (palIdx << 4)); } else { pixel = (pixel & 0b1111'0000) | (palIdx); } diff --git a/src/nostalgia/scene/scene.cpp b/src/nostalgia/scene/scene.cpp index 14586039..4ac8ae21 100644 --- a/src/nostalgia/scene/scene.cpp +++ b/src/nostalgia/scene/scene.cpp @@ -28,10 +28,11 @@ ox::Error Scene::setupDisplay(core::Context *ctx) noexcept { auto y = 0; auto width = m_sceneStatic.rows[layerNo]; for (const auto &tile : layer) { - core::setTile(ctx, layerNo, x, y, tile); - core::setTile(ctx, layerNo, x + 1, y, tile + 1); - core::setTile(ctx, layerNo, x, y + 1, tile + 2); - core::setTile(ctx, layerNo, x + 1, y + 1, tile + 3); + auto tile8 = static_cast(tile); + core::setTile(ctx, layerNo, x, y, tile8); + core::setTile(ctx, layerNo, x + 1, y, tile8 + 1); + core::setTile(ctx, layerNo, x, y + 1, tile8 + 2); + core::setTile(ctx, layerNo, x + 1, y + 1, tile8 + 3); x += 2; if (x >= width * 2) { x = 0; diff --git a/src/nostalgia/scene/scenestatic.hpp b/src/nostalgia/scene/scenestatic.hpp index 06aa04d3..531ff510 100644 --- a/src/nostalgia/scene/scenestatic.hpp +++ b/src/nostalgia/scene/scenestatic.hpp @@ -102,16 +102,20 @@ oxModelEnd() constexpr void setTopEdge(uint8_t &layerAttachments, unsigned val) noexcept { - layerAttachments = (layerAttachments & 0b11111100) | val; + const auto val8 = static_cast(val); + layerAttachments = (layerAttachments & 0b11111100) | val8; } constexpr void setBottomEdge(uint8_t &layerAttachments, unsigned val) noexcept { - layerAttachments = (layerAttachments & 0b11110011) | (val << 2); + const auto val8 = static_cast(val); + layerAttachments = (layerAttachments & 0b11110011) | static_cast(val8 << 2); } constexpr void setLeftEdge(uint8_t &layerAttachments, unsigned val) noexcept { - layerAttachments = (layerAttachments & 0b11001111) | (val << 4); + const auto val8 = static_cast(val); + layerAttachments = (layerAttachments & 0b11001111) | static_cast(val8 << 4); } constexpr void setRightEdge(uint8_t &layerAttachments, unsigned val) noexcept { - layerAttachments = (layerAttachments & 0b00111111) | (val << 6); + const auto val8 = static_cast(val); + layerAttachments = (layerAttachments & 0b00111111) | static_cast(val8 << 6); } [[nodiscard]] @@ -171,8 +175,8 @@ struct SceneStatic { return {tileMapIdx[i], tileType[i], layerAttachments[i]}; } constexpr auto setDimensions(ox::Size dim) noexcept { - columns = dim.width; - rows = dim.height; + columns = static_cast(dim.width); + rows = static_cast(dim.height); const auto tileCnt = static_cast(columns * rows); tileMapIdx.resize(tileCnt); tileType.resize(tileCnt); diff --git a/src/studio/applib/src/newmenu.cpp b/src/studio/applib/src/newmenu.cpp index 711573b0..6de16c2f 100644 --- a/src/studio/applib/src/newmenu.cpp +++ b/src/studio/applib/src/newmenu.cpp @@ -62,7 +62,6 @@ void NewMenu::drawNewItemType(turbine::Context *ctx) noexcept { } ImGui::ListBox("Item Type", &m_selectedType, items.get(), static_cast(m_types.size())); drawFirstPageButtons(); - ImGui::EndPopup(); }); } diff --git a/src/studio/modlib/include/studio/popup.hpp b/src/studio/modlib/include/studio/popup.hpp index 9f7a2f8e..9b44c6fd 100644 --- a/src/studio/modlib/include/studio/popup.hpp +++ b/src/studio/modlib/include/studio/popup.hpp @@ -4,14 +4,14 @@ #pragma once +#include + #include #include #include #include -#include "imguiuitl.hpp" - namespace studio { @@ -47,14 +47,7 @@ class Popup { return m_title; } - void drawWindow(turbine::Context *ctx, bool *open, auto drawContents) { - studio::ig::centerNextWindow(ctx); - ImGui::SetNextWindowSize(static_cast(m_size)); - constexpr auto modalFlags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize; - if (ImGui::BeginPopupModal(m_title.c_str(), open, modalFlags)) { - drawContents(); - } - } + void drawWindow(turbine::Context *ctx, bool *open, const std::function &drawContents); }; diff --git a/src/studio/modlib/src/popup.cpp b/src/studio/modlib/src/popup.cpp index 357ca17a..d46b4b6a 100644 --- a/src/studio/modlib/src/popup.cpp +++ b/src/studio/modlib/src/popup.cpp @@ -2,6 +2,18 @@ * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. */ +#include +#include + namespace studio { +void Popup::drawWindow(turbine::Context *ctx, bool *open, const std::function &drawContents) { + studio::ig::centerNextWindow(ctx); + ImGui::SetNextWindowSize(static_cast(m_size)); + constexpr auto modalFlags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize; + if (ImGui::BeginPopupModal(m_title.c_str(), open, modalFlags)) { + drawContents(); + } +} + } \ No newline at end of file diff --git a/src/studio/modlib/src/project.cpp b/src/studio/modlib/src/project.cpp index 2f12e8f8..55955b83 100644 --- a/src/studio/modlib/src/project.cpp +++ b/src/studio/modlib/src/project.cpp @@ -35,7 +35,7 @@ Project::Project(keel::Context *ctx, ox::String path, ox::CRStringView projectDa ox::Error Project::create() noexcept { std::error_code ec; std::filesystem::create_directory(m_path.toStdString(), ec); - return OxError(ec.value(), "PassThroughFS: mkdir failed"); + return OxError(static_cast(ec.value()), "PassThroughFS: mkdir failed"); } ox::FileSystem *Project::romFs() noexcept { diff --git a/src/turbine/gba/turbine.cpp b/src/turbine/gba/turbine.cpp index cb3db5df..8e43a651 100644 --- a/src/turbine/gba/turbine.cpp +++ b/src/turbine/gba/turbine.cpp @@ -16,9 +16,10 @@ extern "C" void turbine_isr(); namespace turbine { // Timer Consts -constexpr int NanoSecond = 1000000000; +constexpr int NanoSecond = 1'000'000'000; constexpr int MilliSecond = 1000; -constexpr int TicksMs59ns = 65535 - (NanoSecond / MilliSecond) / 59.59; +constexpr int TicksMs59ns = + 65535 - static_cast(static_cast(NanoSecond / MilliSecond) / 59.59); extern volatile gba_timer_t g_timerMs; diff --git a/src/turbine/glfw/gfx.cpp b/src/turbine/glfw/gfx.cpp index d0ecf204..bc6135c6 100644 --- a/src/turbine/glfw/gfx.cpp +++ b/src/turbine/glfw/gfx.cpp @@ -141,60 +141,67 @@ static void themeImgui() noexcept { style.ButtonTextAlign = ImVec2(0.5, 0.5); style.SelectableTextAlign = ImVec2(0.0, 0.0); // colors - style.Colors[ImGuiCol_Text] = ImVec4(0.9490196108818054, 0.95686274766922, 0.9764705896377563, 1.0); - style.Colors[ImGuiCol_TextDisabled] = ImVec4(0.3568627536296844, 0.4196078479290009, 0.4666666686534882, 1.0); - style.Colors[ImGuiCol_WindowBg] = ImVec4(0.1098039224743843, 0.1490196138620377, 0.168627455830574, 1.0); - style.Colors[ImGuiCol_ChildBg] = ImVec4(0.1490196138620377, 0.1764705926179886, 0.2196078449487686, 1.0); - style.Colors[ImGuiCol_PopupBg] = ImVec4(0.0784313753247261, 0.0784313753247261, 0.0784313753247261, 0.9399999976158142); - style.Colors[ImGuiCol_Border] = ImVec4(0.0784313753247261, 0.09803921729326248, 0.1176470592617989, 1.0); - style.Colors[ImGuiCol_BorderShadow] = ImVec4(0.0, 0.0, 0.0, 0.0); - style.Colors[ImGuiCol_FrameBg] = ImVec4(0.2000000029802322, 0.2470588237047195, 0.2862745225429535, 1.0); - style.Colors[ImGuiCol_FrameBgHovered] = ImVec4(0.1176470592617989, 0.2000000029802322, 0.2784313857555389, 1.0); - style.Colors[ImGuiCol_FrameBgActive] = ImVec4(0.08627451211214066, 0.1176470592617989, 0.1372549086809158, 1.0); - style.Colors[ImGuiCol_TitleBg] = ImVec4(0.08627451211214066, 0.1176470592617989, 0.1372549086809158, 0.6499999761581421); - style.Colors[ImGuiCol_TitleBgActive] = ImVec4(0.0784313753247261, 0.09803921729326248, 0.1176470592617989, 1.0); - style.Colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.0, 0.0, 0.0, 0.5099999904632568); - style.Colors[ImGuiCol_MenuBarBg] = ImVec4(0.1490196138620377, 0.1764705926179886, 0.2196078449487686, 1.0); - style.Colors[ImGuiCol_ScrollbarBg] = ImVec4(0.01960784383118153, 0.01960784383118153, 0.01960784383118153, 0.3899999856948853); - style.Colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.2000000029802322, 0.2470588237047195, 0.2862745225429535, 1.0); - style.Colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.1764705926179886, 0.2196078449487686, 0.2470588237047195, 1.0); - style.Colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.08627451211214066, 0.2078431397676468, 0.3098039329051971, 1.0); - style.Colors[ImGuiCol_CheckMark] = ImVec4(0.2784313857555389, 0.5568627715110779, 1.0, 1.0); - style.Colors[ImGuiCol_SliderGrab] = ImVec4(0.2784313857555389, 0.5568627715110779, 1.0, 1.0); - style.Colors[ImGuiCol_SliderGrabActive] = ImVec4(0.3686274588108063, 0.6078431606292725, 1.0, 1.0); - style.Colors[ImGuiCol_Button] = ImVec4(0.2000000029802322, 0.2470588237047195, 0.2862745225429535, 1.0); - style.Colors[ImGuiCol_ButtonHovered] = ImVec4(0.2784313857555389, 0.5568627715110779, 1.0, 1.0); - style.Colors[ImGuiCol_ButtonActive] = ImVec4(0.05882352963089943, 0.529411792755127, 0.9764705896377563, 1.0); + constexpr auto imVec4 = [](double r, double g, double b, double a) { + return ImVec4( + static_cast(r), + static_cast(g), + static_cast(b), + static_cast(a)); + }; + style.Colors[ImGuiCol_Text] = imVec4(0.9490196108818054, 0.95686274766922, 0.9764705896377563, 1.0); + style.Colors[ImGuiCol_TextDisabled] = imVec4(0.3568627536296844, 0.4196078479290009, 0.4666666686534882, 1.0); + style.Colors[ImGuiCol_WindowBg] = imVec4(0.1098039224743843, 0.1490196138620377, 0.168627455830574, 1.0); + style.Colors[ImGuiCol_ChildBg] = imVec4(0.1490196138620377, 0.1764705926179886, 0.2196078449487686, 1.0); + style.Colors[ImGuiCol_PopupBg] = imVec4(0.0784313753247261, 0.0784313753247261, 0.0784313753247261, 0.9399999976158142); + style.Colors[ImGuiCol_Border] = imVec4(0.0784313753247261, 0.09803921729326248, 0.1176470592617989, 1.0); + style.Colors[ImGuiCol_BorderShadow] = imVec4(0.0, 0.0, 0.0, 0.0); + style.Colors[ImGuiCol_FrameBg] = imVec4(0.2000000029802322, 0.2470588237047195, 0.2862745225429535, 1.0); + style.Colors[ImGuiCol_FrameBgHovered] = imVec4(0.1176470592617989, 0.2000000029802322, 0.2784313857555389, 1.0); + style.Colors[ImGuiCol_FrameBgActive] = imVec4(0.08627451211214066, 0.1176470592617989, 0.1372549086809158, 1.0); + style.Colors[ImGuiCol_TitleBg] = imVec4(0.08627451211214066, 0.1176470592617989, 0.1372549086809158, 0.6499999761581421); + style.Colors[ImGuiCol_TitleBgActive] = imVec4(0.0784313753247261, 0.09803921729326248, 0.1176470592617989, 1.0); + style.Colors[ImGuiCol_TitleBgCollapsed] = imVec4(0.0, 0.0, 0.0, 0.5099999904632568); + style.Colors[ImGuiCol_MenuBarBg] = imVec4(0.1490196138620377, 0.1764705926179886, 0.2196078449487686, 1.0); + style.Colors[ImGuiCol_ScrollbarBg] = imVec4(0.01960784383118153, 0.01960784383118153, 0.01960784383118153, 0.3899999856948853); + style.Colors[ImGuiCol_ScrollbarGrab] = imVec4(0.2000000029802322, 0.2470588237047195, 0.2862745225429535, 1.0); + style.Colors[ImGuiCol_ScrollbarGrabHovered] = imVec4(0.1764705926179886, 0.2196078449487686, 0.2470588237047195, 1.0); + style.Colors[ImGuiCol_ScrollbarGrabActive] = imVec4(0.08627451211214066, 0.2078431397676468, 0.3098039329051971, 1.0); + style.Colors[ImGuiCol_CheckMark] = imVec4(0.2784313857555389, 0.5568627715110779, 1.0, 1.0); + style.Colors[ImGuiCol_SliderGrab] = imVec4(0.2784313857555389, 0.5568627715110779, 1.0, 1.0); + style.Colors[ImGuiCol_SliderGrabActive] = imVec4(0.3686274588108063, 0.6078431606292725, 1.0, 1.0); + style.Colors[ImGuiCol_Button] = imVec4(0.2000000029802322, 0.2470588237047195, 0.2862745225429535, 1.0); + style.Colors[ImGuiCol_ButtonHovered] = imVec4(0.2784313857555389, 0.5568627715110779, 1.0, 1.0); + style.Colors[ImGuiCol_ButtonActive] = imVec4(0.05882352963089943, 0.529411792755127, 0.9764705896377563, 1.0); // custom value - style.Colors[ImGuiCol_Header] = ImVec4(0.4000000029802322, 0.4470588237047195, 0.4862745225429535, 0.550000011920929); - style.Colors[ImGuiCol_HeaderHovered] = ImVec4(0.2588235437870026, 0.5882353186607361, 0.9764705896377563, 0.800000011920929); - style.Colors[ImGuiCol_HeaderActive] = ImVec4(0.2588235437870026, 0.5882353186607361, 0.9764705896377563, 1.0); - style.Colors[ImGuiCol_Separator] = ImVec4(0.2000000029802322, 0.2470588237047195, 0.2862745225429535, 1.0); - style.Colors[ImGuiCol_SeparatorHovered] = ImVec4(0.09803921729326248, 0.4000000059604645, 0.7490196228027344, 0.7799999713897705); - style.Colors[ImGuiCol_SeparatorActive] = ImVec4(0.09803921729326248, 0.4000000059604645, 0.7490196228027344, 1.0); - style.Colors[ImGuiCol_ResizeGrip] = ImVec4(0.2588235437870026, 0.5882353186607361, 0.9764705896377563, 0.25); - style.Colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.2588235437870026, 0.5882353186607361, 0.9764705896377563, 0.6700000166893005); - style.Colors[ImGuiCol_ResizeGripActive] = ImVec4(0.2588235437870026, 0.5882353186607361, 0.9764705896377563, 0.949999988079071); - style.Colors[ImGuiCol_Tab] = ImVec4(0.1098039224743843, 0.1490196138620377, 0.168627455830574, 1.0); - style.Colors[ImGuiCol_TabHovered] = ImVec4(0.2588235437870026, 0.5882353186607361, 0.9764705896377563, 0.800000011920929); - style.Colors[ImGuiCol_TabActive] = ImVec4(0.2000000029802322, 0.2470588237047195, 0.2862745225429535, 1.0); - style.Colors[ImGuiCol_TabUnfocused] = ImVec4(0.1098039224743843, 0.1490196138620377, 0.168627455830574, 1.0); - style.Colors[ImGuiCol_TabUnfocusedActive] = ImVec4(0.1098039224743843, 0.1490196138620377, 0.168627455830574, 1.0); - style.Colors[ImGuiCol_PlotLines] = ImVec4(0.6078431606292725, 0.6078431606292725, 0.6078431606292725, 1.0); - style.Colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.0, 0.4274509847164154, 0.3490196168422699, 1.0); - style.Colors[ImGuiCol_PlotHistogram] = ImVec4(0.8980392217636108, 0.6980392336845398, 0.0, 1.0); - style.Colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.0, 0.6000000238418579, 0.0, 1.0); - style.Colors[ImGuiCol_TableHeaderBg] = ImVec4(0.1882352977991104, 0.1882352977991104, 0.2000000029802322, 1.0); - style.Colors[ImGuiCol_TableBorderStrong] = ImVec4(0.3098039329051971, 0.3098039329051971, 0.3490196168422699, 1.0); - style.Colors[ImGuiCol_TableBorderLight] = ImVec4(0.2274509817361832, 0.2274509817361832, 0.2470588237047195, 1.0); - style.Colors[ImGuiCol_TableRowBg] = ImVec4(0.0, 0.0, 0.0, 0.0); - style.Colors[ImGuiCol_TableRowBgAlt] = ImVec4(1.0, 1.0, 1.0, 0.05999999865889549); - style.Colors[ImGuiCol_TextSelectedBg] = ImVec4(0.2588235437870026, 0.5882353186607361, 0.9764705896377563, 0.3499999940395355); - style.Colors[ImGuiCol_DragDropTarget] = ImVec4(1.0, 1.0, 0.0, 0.8999999761581421); - style.Colors[ImGuiCol_NavHighlight] = ImVec4(0.2588235437870026, 0.5882353186607361, 0.9764705896377563, 1.0); - style.Colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.0, 1.0, 1.0, 0.699999988079071); - style.Colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.800000011920929, 0.800000011920929, 0.800000011920929, 0.2000000029802322); - style.Colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.800000011920929, 0.800000011920929, 0.800000011920929, 0.3499999940395355); + style.Colors[ImGuiCol_Header] = imVec4(0.4000000029802322, 0.4470588237047195, 0.4862745225429535, 0.550000011920929); + style.Colors[ImGuiCol_HeaderHovered] = imVec4(0.2588235437870026, 0.5882353186607361, 0.9764705896377563, 0.800000011920929); + style.Colors[ImGuiCol_HeaderActive] = imVec4(0.2588235437870026, 0.5882353186607361, 0.9764705896377563, 1.0); + style.Colors[ImGuiCol_Separator] = imVec4(0.2000000029802322, 0.2470588237047195, 0.2862745225429535, 1.0); + style.Colors[ImGuiCol_SeparatorHovered] = imVec4(0.09803921729326248, 0.4000000059604645, 0.7490196228027344, 0.7799999713897705); + style.Colors[ImGuiCol_SeparatorActive] = imVec4(0.09803921729326248, 0.4000000059604645, 0.7490196228027344, 1.0); + style.Colors[ImGuiCol_ResizeGrip] = imVec4(0.2588235437870026, 0.5882353186607361, 0.9764705896377563, 0.25); + style.Colors[ImGuiCol_ResizeGripHovered] = imVec4(0.2588235437870026, 0.5882353186607361, 0.9764705896377563, 0.6700000166893005); + style.Colors[ImGuiCol_ResizeGripActive] = imVec4(0.2588235437870026, 0.5882353186607361, 0.9764705896377563, 0.949999988079071); + style.Colors[ImGuiCol_Tab] = imVec4(0.1098039224743843, 0.1490196138620377, 0.168627455830574, 1.0); + style.Colors[ImGuiCol_TabHovered] = imVec4(0.2588235437870026, 0.5882353186607361, 0.9764705896377563, 0.800000011920929); + style.Colors[ImGuiCol_TabActive] = imVec4(0.2000000029802322, 0.2470588237047195, 0.2862745225429535, 1.0); + style.Colors[ImGuiCol_TabUnfocused] = imVec4(0.1098039224743843, 0.1490196138620377, 0.168627455830574, 1.0); + style.Colors[ImGuiCol_TabUnfocusedActive] = imVec4(0.1098039224743843, 0.1490196138620377, 0.168627455830574, 1.0); + style.Colors[ImGuiCol_PlotLines] = imVec4(0.6078431606292725, 0.6078431606292725, 0.6078431606292725, 1.0); + style.Colors[ImGuiCol_PlotLinesHovered] = imVec4(1.0, 0.4274509847164154, 0.3490196168422699, 1.0); + style.Colors[ImGuiCol_PlotHistogram] = imVec4(0.8980392217636108, 0.6980392336845398, 0.0, 1.0); + style.Colors[ImGuiCol_PlotHistogramHovered] = imVec4(1.0, 0.6000000238418579, 0.0, 1.0); + style.Colors[ImGuiCol_TableHeaderBg] = imVec4(0.1882352977991104, 0.1882352977991104, 0.2000000029802322, 1.0); + style.Colors[ImGuiCol_TableBorderStrong] = imVec4(0.3098039329051971, 0.3098039329051971, 0.3490196168422699, 1.0); + style.Colors[ImGuiCol_TableBorderLight] = imVec4(0.2274509817361832, 0.2274509817361832, 0.2470588237047195, 1.0); + style.Colors[ImGuiCol_TableRowBg] = imVec4(0.0, 0.0, 0.0, 0.0); + style.Colors[ImGuiCol_TableRowBgAlt] = imVec4(1.0, 1.0, 1.0, 0.05999999865889549); + style.Colors[ImGuiCol_TextSelectedBg] = imVec4(0.2588235437870026, 0.5882353186607361, 0.9764705896377563, 0.3499999940395355); + style.Colors[ImGuiCol_DragDropTarget] = imVec4(1.0, 1.0, 0.0, 0.8999999761581421); + style.Colors[ImGuiCol_NavHighlight] = imVec4(0.2588235437870026, 0.5882353186607361, 0.9764705896377563, 1.0); + style.Colors[ImGuiCol_NavWindowingHighlight] = imVec4(1.0, 1.0, 1.0, 0.699999988079071); + style.Colors[ImGuiCol_NavWindowingDimBg] = imVec4(0.800000011920929, 0.800000011920929, 0.800000011920929, 0.2000000029802322); + style.Colors[ImGuiCol_ModalWindowDimBg] = imVec4(0.800000011920929, 0.800000011920929, 0.800000011920929, 0.3499999940395355); } ox::Error initGfx(Context &ctx) noexcept {