| 2896 | } |
| 2897 | |
| 2898 | void FullscreenUI::DrawGameGrid(const ImVec2& heading_size) |
| 2899 | { |
| 2900 | ImGuiIO& io = ImGui::GetIO(); |
| 2901 | if (!BeginFullscreenWindow( |
| 2902 | ImVec2(0.0f, heading_size.y), |
| 2903 | ImVec2(io.DisplaySize.x, io.DisplaySize.y - heading_size.y - LayoutScale(LAYOUT_FOOTER_HEIGHT)), "game_grid", |
| 2904 | UIBackgroundColor)) |
| 2905 | { |
| 2906 | EndFullscreenWindow(); |
| 2907 | return; |
| 2908 | } |
| 2909 | |
| 2910 | if (!AreAnyDialogsOpen() && WantsToCloseMenu()) |
| 2911 | SwitchToLanding(); |
| 2912 | |
| 2913 | ResetFocusHere(); |
| 2914 | BeginMenuButtons(); |
| 2915 | |
| 2916 | const ImGuiStyle& style = ImGui::GetStyle(); |
| 2917 | |
| 2918 | const float title_spacing = LayoutScale(10.0f); |
| 2919 | const float item_spacing = LayoutScale(20.0f); |
| 2920 | const float item_width_with_spacing = std::floor(LayoutScale(LAYOUT_SCREEN_WIDTH / 5.0f)); |
| 2921 | const float item_width = item_width_with_spacing - item_spacing; |
| 2922 | const float image_width = item_width - (style.FramePadding.x * 2.0f); |
| 2923 | const float image_height = image_width * 1.33f; |
| 2924 | const ImVec2 image_size(image_width, image_height); |
| 2925 | const float item_height = (style.FramePadding.y * 2.0f) + image_height + title_spacing + g_medium_font.second; |
| 2926 | const ImVec2 item_size(item_width, item_height); |
| 2927 | const u32 grid_count_x = std::floor(ImGui::GetWindowWidth() / item_width_with_spacing); |
| 2928 | const float start_x = |
| 2929 | (static_cast<float>(ImGui::GetWindowWidth()) - (item_width_with_spacing * static_cast<float>(grid_count_x))) * 0.5f; |
| 2930 | |
| 2931 | SmallString draw_title; |
| 2932 | |
| 2933 | u32 grid_x = 0; |
| 2934 | for (const GameList::Entry* entry : s_game_list_sorted_entries) |
| 2935 | { |
| 2936 | ImGuiWindow* window = ImGui::GetCurrentWindow(); |
| 2937 | if (window->SkipItems) |
| 2938 | continue; |
| 2939 | |
| 2940 | if (grid_x == grid_count_x) |
| 2941 | { |
| 2942 | grid_x = 0; |
| 2943 | ImGui::SetCursorPosX(start_x); |
| 2944 | ImGui::SetCursorPosY(ImGui::GetCursorPosY() + item_spacing); |
| 2945 | } |
| 2946 | else |
| 2947 | { |
| 2948 | ImGui::SameLine(start_x + static_cast<float>(grid_x) * (item_width + item_spacing)); |
| 2949 | } |
| 2950 | |
| 2951 | const ImGuiID id = window->GetID(entry->path.c_str(), entry->path.c_str() + entry->path.length()); |
| 2952 | const ImVec2 pos(window->DC.CursorPos); |
| 2953 | ImRect bb(pos, pos + item_size); |
| 2954 | ImGui::ItemSize(item_size); |
| 2955 | if (ImGui::ItemAdd(bb, id)) |
nothing calls this directly
no test coverage detected