FullscreenUI: Prefetch two rows of covers in grid view

Less change of loading/placeholder images.
pull/3718/head
Stenzek 5 months ago
parent eb52ba3634
commit c9a7bf7420
No known key found for this signature in database

@ -2164,8 +2164,6 @@ void FullscreenUI::DrawAchievement(const rc_client_achievement_t* cheevo, const
(is_measured ? (spacing + LayoutScale(progress_height_unscaled)) : 0.0f) +
LayoutScale(LAYOUT_MENU_ITEM_EXTRA_HEIGHT);
const float pos_y = ImGui::GetCursorPosY();
SmallString text;
text.format("chv_{}", cheevo->id);
@ -2174,6 +2172,7 @@ void FullscreenUI::DrawAchievement(const rc_client_achievement_t* cheevo, const
const bool clicked = MenuButtonFrame(text, content_height, true, &bb, &visible, &hovered);
if (!visible)
{
const float pos_y = ImGui::GetCursorPosY();
if (pos_y >= prefetch_range.x && pos_y <= prefetch_range.y)
{
if (const std::string_view badge_url = Achievements::GetAchievementBadgeURL(cheevo, !is_unlocked);

@ -775,6 +775,10 @@ void FullscreenUI::DrawGameGrid(const ImVec2& heading_size)
if (!s_game_list_locals.game_list_sorted_entries.empty())
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + x_padding);
// Prefetch two rows worth of covers.
const ImVec2 prefetch_range =
ImVec2(window->Pos.y + window->Scroll.y, window->Pos.y + window->Scroll.y + (window->ClipRect.GetHeight() * 2.0f));
for (size_t entry_index = 0; entry_index < s_game_list_locals.game_list_sorted_entries.size(); entry_index++)
{
if (window->SkipItems)
@ -861,6 +865,11 @@ void FullscreenUI::DrawGameGrid(const ImVec2& heading_size)
HandleGameListOptions(entry);
}
}
else
{
if (pos.y >= prefetch_range.x && pos.y <= prefetch_range.y)
GetGameListCover(entry, false, false, false);
}
if (entry == s_game_list_locals.game_list_sorted_entries.front())
ImGui::SetItemDefaultFocus();

Loading…
Cancel
Save