From e57f7d92c395095423a91bae0f03d50c91be5545 Mon Sep 17 00:00:00 2001 From: TheLastRar Date: Thu, 31 Oct 2024 12:29:43 +0000 Subject: [PATCH] FSUI: Don't move IMGUI cursor unnecessarily in DrawGameGrid() --- pcsx2/ImGui/FullscreenUI.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/pcsx2/ImGui/FullscreenUI.cpp b/pcsx2/ImGui/FullscreenUI.cpp index 743066c1dd..e0bd94481f 100644 --- a/pcsx2/ImGui/FullscreenUI.cpp +++ b/pcsx2/ImGui/FullscreenUI.cpp @@ -6224,13 +6224,23 @@ void FullscreenUI::DrawGameGrid(const ImVec2& heading_size) SmallString draw_title; u32 grid_x = 0; - ImGui::SetCursorPos(ImVec2(start_x, 0.0f)); for (const GameList::Entry* entry : s_game_list_sorted_entries) { ImGuiWindow* window = ImGui::GetCurrentWindow(); if (window->SkipItems) continue; + if (grid_x == grid_count_x) + { + grid_x = 0; + ImGui::SetCursorPosX(start_x); + ImGui::SetCursorPosY(ImGui::GetCursorPosY() + item_spacing); + } + else + { + ImGui::SameLine(start_x + static_cast(grid_x) * (item_width + item_spacing)); + } + const ImGuiID id = window->GetID(entry->path.c_str(), entry->path.c_str() + entry->path.length()); const ImVec2 pos(window->DC.CursorPos); ImRect bb(pos, pos + item_size); @@ -6283,16 +6293,6 @@ void FullscreenUI::DrawGameGrid(const ImVec2& heading_size) } grid_x++; - if (grid_x == grid_count_x) - { - grid_x = 0; - ImGui::SetCursorPosX(start_x); - ImGui::SetCursorPosY(ImGui::GetCursorPosY() + item_spacing); - } - else - { - ImGui::SameLine(start_x + static_cast(grid_x) * (item_width + item_spacing)); - } } EndMenuButtons();