From fb5d3545fe33f88185af74cd4468419cf5f05757 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Fri, 31 May 2024 23:58:40 -0500 Subject: [PATCH] [nostalgia/core/studio] Cleanup --- .../tilesheeteditor/tilesheeteditor-imgui.cpp | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditor-imgui.cpp b/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditor-imgui.cpp index c5d16c1f..da406f06 100644 --- a/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditor-imgui.cpp +++ b/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditor-imgui.cpp @@ -212,8 +212,8 @@ void TileSheetEditorImGui::draw(studio::StudioContext&) noexcept { } } auto const paneSize = ImGui::GetContentRegionAvail(); - auto const tileSheetParentSize = ImVec2(paneSize.x - m_palViewWidth, paneSize.y); - auto const fbSize = ox::Vec2(tileSheetParentSize.x - 16, tileSheetParentSize.y - 16); + auto const tileSheetParentSize = ImVec2{paneSize.x - m_palViewWidth, paneSize.y}; + auto const fbSize = ox::Vec2{tileSheetParentSize.x - 16, tileSheetParentSize.y - 16}; ImGui::BeginChild("TileSheetView", tileSheetParentSize, true); { drawTileSheet(fbSize); @@ -225,7 +225,7 @@ void TileSheetEditorImGui::draw(studio::StudioContext&) noexcept { auto const controlsSize = ImGui::GetContentRegionAvail(); ImGui::BeginChild("ToolBox", {m_palViewWidth - 24, 30}, true); { - auto const btnSz = ImVec2(45, 14); + auto const btnSz = ImVec2{45, 14}; if (ImGui::Selectable("Select", m_tool == TileSheetTool::Select, 0, btnSz)) { m_tool = TileSheetTool::Select; } @@ -388,7 +388,7 @@ ox::Error TileSheetEditorImGui::exportSubhseetToPng(int scale) noexcept { void TileSheetEditorImGui::drawTileSheet(ox::Vec2 const&fbSize) noexcept { auto const winPos = ImGui::GetWindowPos(); - auto const fbSizei = ox::Size(static_cast(fbSize.x), static_cast(fbSize.y)); + auto const fbSizei = ox::Size{static_cast(fbSize.x), static_cast(fbSize.y)}; if (m_framebuffer.width != fbSizei.width || m_framebuffer.height != fbSizei.height) { glutils::resizeInitFrameBuffer(m_framebuffer, fbSizei.width, fbSizei.height); m_view.resizeView(fbSize); @@ -404,11 +404,11 @@ void TileSheetEditorImGui::drawTileSheet(ox::Vec2 const&fbSize) noexcept { ImGui::Image( ig::toImTextureID(m_framebuffer.color.id), static_cast(fbSize), - ImVec2(0, 1), - ImVec2(1, 0)); + {0, 1}, + {1, 0}); // handle input, this must come after drawing auto const&io = ImGui::GetIO(); - auto const mousePos = ox::Vec2(ImGui::GetMousePos()); + auto const mousePos = ox::Vec2{ImGui::GetMousePos()}; if (ImGui::IsItemHovered()) { auto const wheel = io.MouseWheel; auto const wheelh = io.MouseWheelH; @@ -436,7 +436,7 @@ void TileSheetEditorImGui::drawTileSheet(ox::Vec2 const&fbSize) noexcept { } } if (ImGui::BeginPopupContextItem("TileMenu", ImGuiPopupFlags_MouseButtonRight)) { - auto const popupPos = ox::Vec2(ImGui::GetWindowPos()); + auto const popupPos = ox::Vec2{ImGui::GetWindowPos()}; if (ImGui::MenuItem("Insert Tile")) { m_view.insertTile(fbSize, clickPos(winPos, popupPos)); } @@ -504,8 +504,8 @@ void TileSheetEditorImGui::drawPaletteSelector() noexcept { auto ic = ImGui::GetColorU32(ImVec4(redf(c), greenf(c), bluef(c), 1)); ImGui::TableSetBgColor(ImGuiTableBgTarget_CellBg, ic); ImGui::TableNextColumn(); - auto const&name = pal.colorInfo[i].name; - ImGui::Text("%s", name.c_str()); + auto const&name = i < pal.colorInfo.size() ? pal.colorInfo[i].name.c_str() : ""; + ImGui::Text("%s", name); ImGui::TableNextColumn(); ImGui::Text("(%02d, %02d, %02d)", red16(c), green16(c), blue16(c)); ImGui::TableNextRow(); @@ -556,7 +556,7 @@ void TileSheetEditorImGui::SubSheetEditor::draw(turbine::Context &tctx) noexcept auto const modSize = m_cols > 0; auto constexpr popupWidth = 235.f; auto const popupHeight = modSize ? 130.f : 85.f; - auto const popupSz = ImVec2(popupWidth, popupHeight); + auto const popupSz = ImVec2{popupWidth, popupHeight}; if (ig::BeginPopup(tctx, popupName, m_show, popupSz)) { ImGui::InputText("Name", m_name.data(), m_name.cap()); if (modSize) { @@ -581,7 +581,7 @@ void TileSheetEditorImGui::ExportMenu::draw(turbine::Context &tctx) noexcept { } constexpr auto popupWidth = 235.f; constexpr auto popupHeight = 85.f; - constexpr auto popupSz = ImVec2(popupWidth, popupHeight); + constexpr auto popupSz = ImVec2{popupWidth, popupHeight}; if (ig::BeginPopup(tctx, popupName, m_show, popupSz)) { ImGui::InputInt("Scale", &m_scale); m_scale = ox::clamp(m_scale, 1, 50);