FullscreenUI: Add BackgroundProgressCallback

arm-build
Stenzek 2 months ago
parent 498e7aac56
commit 0733e173b2
No known key found for this signature in database

@ -8525,6 +8525,75 @@ void FullscreenUI::OpenLeaderboardsWindow()
});
}
FullscreenUI::BackgroundProgressCallback::BackgroundProgressCallback(std::string name)
: ProgressCallback(), m_name(std::move(name))
{
ImGuiFullscreen::OpenBackgroundProgressDialog(m_name.c_str(), "", 0, 100, 0);
}
FullscreenUI::BackgroundProgressCallback::~BackgroundProgressCallback()
{
ImGuiFullscreen::CloseBackgroundProgressDialog(m_name.c_str());
}
void FullscreenUI::BackgroundProgressCallback::SetStatusText(const std::string_view text)
{
ProgressCallback::SetStatusText(text);
Redraw(true);
}
void FullscreenUI::BackgroundProgressCallback::SetProgressRange(u32 range)
{
const u32 last_range = m_progress_range;
ProgressCallback::SetProgressRange(range);
if (m_progress_range != last_range)
Redraw(false);
}
void FullscreenUI::BackgroundProgressCallback::SetProgressValue(u32 value)
{
const u32 last_value = m_progress_value;
ProgressCallback::SetProgressValue(value);
if (m_progress_value != last_value)
Redraw(false);
}
void FullscreenUI::BackgroundProgressCallback::Redraw(bool force)
{
const int percent =
static_cast<int>((static_cast<float>(m_progress_value) / static_cast<float>(m_progress_range)) * 100.0f);
if (percent == m_last_progress_percent && !force)
return;
m_last_progress_percent = percent;
ImGuiFullscreen::UpdateBackgroundProgressDialog(m_name.c_str(), m_status_text, 0, 100, percent);
}
void FullscreenUI::BackgroundProgressCallback::ModalError(const std::string_view message)
{
Host::ReportErrorAsync("Error", message);
}
bool FullscreenUI::BackgroundProgressCallback::ModalConfirmation(const std::string_view message)
{
return Host::ConfirmMessage("Confirm", message);
}
void FullscreenUI::BackgroundProgressCallback::ModalInformation(const std::string_view message)
{
Host::ReportErrorAsync("Information", message);
}
void FullscreenUI::BackgroundProgressCallback::SetCancelled()
{
if (m_cancellable)
m_cancelled = true;
}
#endif // __ANDROID__
LoadingScreenProgressCallback::LoadingScreenProgressCallback()

@ -26,7 +26,21 @@ void OnSystemResumed();
void OnSystemDestroyed();
void OnRunningGameChanged(const std::string& path, const std::string& serial, const std::string& title, GameHash hash);
void Shutdown(bool clear_state);
void Render();
void InvalidateCoverCache();
void TimeToPrintableString(SmallStringBase* str, time_t t);
float GetBackgroundAlpha();
void OpenLoadingScreen(std::string_view image, std::string_view message, s32 progress_min = -1, s32 progress_max = -1,
s32 progress_value = -1);
void UpdateLoadingScreen(std::string_view image, std::string_view message, s32 progress_min = -1, s32 progress_max = -1,
s32 progress_value = -1);
void CloseLoadingScreen();
#ifndef __ANDROID__
void OpenPauseMenu();
void OpenCheatsMenu();
void OpenDiscChangeMenu();
@ -36,20 +50,31 @@ void ReturnToMainWindow();
void ReturnToPreviousWindow();
void SetStandardSelectionFooterText(bool back_instead_of_cancel);
void UpdateRunIdleState();
#endif
void Shutdown(bool clear_state);
void Render();
void InvalidateCoverCache();
void TimeToPrintableString(SmallStringBase* str, time_t t);
class BackgroundProgressCallback final : public ProgressCallback
{
public:
BackgroundProgressCallback(std::string name);
~BackgroundProgressCallback() override;
float GetBackgroundAlpha();
void SetStatusText(const std::string_view text) override;
void SetProgressRange(u32 range) override;
void SetProgressValue(u32 value) override;
void OpenLoadingScreen(std::string_view image, std::string_view message, s32 progress_min = -1, s32 progress_max = -1,
s32 progress_value = -1);
void UpdateLoadingScreen(std::string_view image, std::string_view message, s32 progress_min = -1, s32 progress_max = -1,
s32 progress_value = -1);
void CloseLoadingScreen();
void ModalError(const std::string_view message) override;
bool ModalConfirmation(const std::string_view message) override;
void ModalInformation(const std::string_view message) override;
void SetCancelled();
private:
void Redraw(bool force);
std::string m_name;
int m_last_progress_percent = -1;
};
#endif // __ANDROID__
} // namespace FullscreenUI

Loading…
Cancel
Save