MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / DrawGameList

Method DrawGameList

pcsx2/ImGui/FullscreenUI.cpp:2689–2896  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2687}
2688
2689void FullscreenUI::DrawGameList(const ImVec2& heading_size)
2690{
2691 ImGui::PushStyleColor(ImGuiCol_WindowBg, UIBackgroundColor);
2692
2693 if (!BeginFullscreenColumns(nullptr, heading_size.y, true, true))
2694 {
2695 EndFullscreenColumns();
2696 ImGui::PopStyleColor();
2697 return;
2698 }
2699
2700 if (!AreAnyDialogsOpen() && WantsToCloseMenu())
2701 SwitchToLanding();
2702
2703 const GameList::Entry* selected_entry = nullptr;
2704
2705 if (BeginFullscreenColumnWindow(0.0f, -530.0f, "game_list_entries"))
2706 {
2707 const ImVec2 image_size(LayoutScale(LAYOUT_MENU_BUTTON_HEIGHT * 0.68f, LAYOUT_MENU_BUTTON_HEIGHT));
2708
2709 ResetFocusHere();
2710
2711 BeginMenuButtons();
2712
2713 // TODO: replace with something not heap allocating
2714 std::string summary;
2715
2716 for (const GameList::Entry* entry : s_game_list_sorted_entries)
2717 {
2718 ImRect bb;
2719 bool visible, hovered;
2720 bool pressed = MenuButtonFrame(entry->path.c_str(), true, LAYOUT_MENU_BUTTON_HEIGHT, &visible, &hovered, &bb.Min, &bb.Max);
2721 if (!visible)
2722 continue;
2723
2724 summary.clear();
2725 if (entry->serial.empty())
2726 fmt::format_to(std::back_inserter(summary), "{} - ", GameList::RegionToString(entry->region, true));
2727 else
2728 fmt::format_to(std::back_inserter(summary), "{} - {} - ", entry->serial, GameList::RegionToString(entry->region, true));
2729
2730 const std::string_view filename(Path::GetFileName(entry->path));
2731 summary.append(filename);
2732
2733 DrawGameCover(entry, ImGui::GetWindowDrawList(), bb.Min, bb.Min + image_size);
2734
2735 const float midpoint = bb.Min.y + GetLineHeight(g_large_font) + LayoutScale(4.0f);
2736 const float text_start_x = bb.Min.x + image_size.x + LayoutScale(15.0f);
2737 const ImRect title_bb(ImVec2(text_start_x, bb.Min.y), ImVec2(bb.Max.x, midpoint));
2738 const ImRect summary_bb(ImVec2(text_start_x, midpoint), bb.Max);
2739 const std::string& title = entry->GetTitle(s_prefer_english_titles);
2740
2741 ImGui::PushFont(g_large_font.first, g_large_font.second);
2742 ImGui::RenderTextClipped(title_bb.Min, title_bb.Max, title.c_str(), title.c_str() + title.size(), nullptr,
2743 ImVec2(0.0f, 0.0f), &title_bb);
2744 ImGui::PopFont();
2745
2746 if (!summary.empty())

Callers

nothing calls this directly

Calls 15

LayoutScaleFunction · 0.85
GetLineHeightFunction · 0.85
PushFontFunction · 0.85
GetCurrentWindowFunction · 0.85
GetTitleMethod · 0.80
ImVec2Class · 0.70
format_toFunction · 0.50
maxFunction · 0.50
minFunction · 0.50
formatFunction · 0.50
c_strMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected