1
0
mirror of https://git.suyu.dev/suyu/suyu synced 2025-01-18 05:40:11 -06:00
suyu-mirror/src/yuzu/loading_screen.h
James Rowe 08fcf41b0a 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.
2019-01-19 23:34:03 -07:00

51 lines
1.3 KiB
C++

// Copyright 2019 yuzu Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include <memory>
#include <QWidget>
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<QMovie> animation;
std::unique_ptr<QBuffer> backing_buf;
std::unique_ptr<QByteArray> backing_mem;
std::unique_ptr<Ui::LoadingScreen> ui;
std::size_t previous_total = 0;
};