diff --git a/src/frontend-common/achievements.cpp b/src/frontend-common/achievements.cpp index ec843b76d..f67d5eb49 100644 --- a/src/frontend-common/achievements.cpp +++ b/src/frontend-common/achievements.cpp @@ -920,9 +920,7 @@ bool Achievements::LoginAsync(const char* username, const char* password) return false; if (FullscreenUI::IsInitialized()) - { - ImGuiFullscreen::OpenBackgroundProgressDialog("cheevos_async_login", "Logging in to RetroAchivements...", 0, 1, 0); - } + ImGuiFullscreen::OpenBackgroundProgressDialog("cheevos_async_login", "Logging in to RetroAchivements...", 0, 0, 0); SendLogin(username, password, s_http_downloader.get(), LoginASyncCallback); return true; diff --git a/src/frontend-common/imgui_fullscreen.cpp b/src/frontend-common/imgui_fullscreen.cpp index 5796e4a29..08fdafb14 100644 --- a/src/frontend-common/imgui_fullscreen.cpp +++ b/src/frontend-common/imgui_fullscreen.cpp @@ -264,9 +264,8 @@ std::optional ImGuiFullscreen::LoadTextureImage(const char* std::shared_ptr ImGuiFullscreen::UploadTexture(const char* path, const Common::RGBA8Image& image) { - std::unique_ptr texture = - g_host_display->CreateTexture(image.GetWidth(), image.GetHeight(), 1, 1, 1, GPUTexture::Format::RGBA8, - image.GetPixels(), image.GetPitch()); + std::unique_ptr texture = g_host_display->CreateTexture( + image.GetWidth(), image.GetHeight(), 1, 1, 1, GPUTexture::Format::RGBA8, image.GetPixels(), image.GetPitch()); if (!texture) { Log_ErrorPrintf("failed to create %ux%u texture for resource", image.GetWidth(), image.GetHeight()); @@ -2264,17 +2263,32 @@ void ImGuiFullscreen::DrawBackgroundProgressDialogs(ImVec2& position, float spac nullptr, 0.0f); pos.y += g_medium_font->FontSize + LayoutScale(10.0f); - ImVec2 bar_end(pos.x + window_width - LayoutScale(10.0f * 2.0f), pos.y + LayoutScale(25.0f)); - float fraction = static_cast(data.value - data.min) / static_cast(data.max - data.min); - dl->AddRectFilled(pos, bar_end, ImGui::GetColorU32(UIPrimaryDarkColor)); - dl->AddRectFilled(pos, ImVec2(pos.x + fraction * (bar_end.x - pos.x), bar_end.y), - ImGui::GetColorU32(UISecondaryColor)); + const ImVec2 box_end(pos.x + window_width - LayoutScale(10.0f * 2.0f), pos.y + LayoutScale(25.0f)); + dl->AddRectFilled(pos, box_end, ImGui::GetColorU32(UIPrimaryDarkColor)); - const std::string text(fmt::format("{}%", static_cast(std::round(fraction * 100.0f)))); - const ImVec2 text_size(ImGui::CalcTextSize(text.c_str())); - const ImVec2 text_pos(pos.x + ((bar_end.x - pos.x) / 2.0f) - (text_size.x / 2.0f), - pos.y + ((bar_end.y - pos.y) / 2.0f) - (text_size.y / 2.0f)); - dl->AddText(g_medium_font, g_medium_font->FontSize, text_pos, ImGui::GetColorU32(UIPrimaryTextColor), text.c_str()); + if (data.min != data.max) + { + const float fraction = static_cast(data.value - data.min) / static_cast(data.max - data.min); + dl->AddRectFilled(pos, ImVec2(pos.x + fraction * (box_end.x - pos.x), box_end.y), + ImGui::GetColorU32(UISecondaryColor)); + + const auto text = TinyString::FromFmt("{}%", static_cast(std::round(fraction * 100.0f))); + const ImVec2 text_size(ImGui::CalcTextSize(text)); + const ImVec2 text_pos(pos.x + ((box_end.x - pos.x) / 2.0f) - (text_size.x / 2.0f), + pos.y + ((box_end.y - pos.y) / 2.0f) - (text_size.y / 2.0f)); + dl->AddText(g_medium_font, g_medium_font->FontSize, text_pos, ImGui::GetColorU32(UIPrimaryTextColor), + text.GetCharArray(), text.GetCharArray() + text.GetLength()); + } + else + { + // indeterminate, so draw a scrolling bar + const float bar_width = LayoutScale(30.0f); + const float fraction = static_cast(std::fmod(ImGui::GetTime(), 2.0) * 0.5); + const ImVec2 bar_start(pos.x + ImLerp(0.0f, box_end.x, fraction) - bar_width, pos.y); + const ImVec2 bar_end(std::min(bar_start.x + bar_width, box_end.x), pos.y + LayoutScale(25.0f)); + dl->AddRectFilled(ImClamp(bar_start, pos, box_end), ImClamp(bar_end, pos, box_end), + ImGui::GetColorU32(UISecondaryColor)); + } position.y += s_notification_vertical_direction * (window_height + spacing); }