From 08fcf41b0a3d4e6066cb72f47c3e1d94bb7fc408 Mon Sep 17 00:00:00 2001 From: James Rowe Date: Thu, 17 Jan 2019 00:01:00 -0700 Subject: QT Frontend: Add a Loading screen with progressbar With shader caches on the horizon, one requirement is to provide visible feedback for the progress. The shader cache reportedly takes several minutes to load for large caches that were invalidated, and as such we should provide a loading screen with progress. Adds a loading screen widget that will be shown until the first frame of the game is swapped. This was chosen in case shader caches are not being used, several games still take more than a few seconds to launch and could benefit from a loading screen. --- src/yuzu/loading_screen.h | 50 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/yuzu/loading_screen.h (limited to 'src/yuzu/loading_screen.h') diff --git a/src/yuzu/loading_screen.h b/src/yuzu/loading_screen.h new file mode 100644 index 000000000..ffcaa260d --- /dev/null +++ b/src/yuzu/loading_screen.h @@ -0,0 +1,50 @@ +// Copyright 2019 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include +#include + +namespace Loader { +class AppLoader; +} + +namespace Ui { +class LoadingScreen; +} + +class QBuffer; +class QByteArray; +class QMovie; + +class LoadingScreen : public QWidget { + Q_OBJECT + +public: + explicit LoadingScreen(QWidget* parent = nullptr); + + ~LoadingScreen(); + + /// Call before showing the loading screen to load the widgets with the logo and banner for the + /// currently loaded application. + void Prepare(Loader::AppLoader& loader); + + /// After the loading screen is hidden, the owner of this class can call this to clean up any + /// used resources such as the logo and banner. + void Clear(); + + // In order to use a custom widget with a stylesheet, you need to override the paintEvent + // See https://wiki.qt.io/How_to_Change_the_Background_Color_of_QWidget + void paintEvent(QPaintEvent* event) override; + + void OnLoadProgress(std::size_t value, std::size_t total); + +private: + std::unique_ptr animation; + std::unique_ptr backing_buf; + std::unique_ptr backing_mem; + std::unique_ptr ui; + std::size_t previous_total = 0; +}; -- cgit v1.2.3