2019-01-17 07:01:00 +00:00
|
|
|
// Copyright 2019 yuzu Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2019-01-20 04:03:26 +00:00
|
|
|
#include <chrono>
|
2019-01-17 07:01:00 +00:00
|
|
|
#include <memory>
|
2019-01-20 04:03:26 +00:00
|
|
|
#include <QString>
|
2019-01-17 07:01:00 +00:00
|
|
|
#include <QWidget>
|
|
|
|
|
2019-01-18 17:02:27 +00:00
|
|
|
#if !QT_CONFIG(movie)
|
|
|
|
#define YUZU_QT_MOVIE_MISSING 1
|
|
|
|
#endif
|
|
|
|
|
2019-01-17 07:01:00 +00:00
|
|
|
namespace Loader {
|
|
|
|
class AppLoader;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class LoadingScreen;
|
|
|
|
}
|
|
|
|
|
2019-01-20 04:03:26 +00:00
|
|
|
namespace VideoCore {
|
|
|
|
enum class LoadCallbackStage;
|
|
|
|
}
|
|
|
|
|
2019-01-17 07:01:00 +00:00
|
|
|
class QBuffer;
|
|
|
|
class QByteArray;
|
2019-01-21 16:20:16 +00:00
|
|
|
class QGraphicsOpacityEffect;
|
2019-01-17 07:01:00 +00:00
|
|
|
class QMovie;
|
2019-01-21 16:20:16 +00:00
|
|
|
class QPropertyAnimation;
|
2019-01-17 07:01:00 +00:00
|
|
|
|
|
|
|
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();
|
|
|
|
|
2019-01-21 16:20:16 +00:00
|
|
|
/// Slot used to update the status of the progress bar
|
2019-01-20 04:03:26 +00:00
|
|
|
void OnLoadProgress(VideoCore::LoadCallbackStage stage, std::size_t value, std::size_t total);
|
|
|
|
|
2019-01-21 16:20:16 +00:00
|
|
|
/// Hides the LoadingScreen with a fade out effect
|
|
|
|
void OnLoadComplete();
|
|
|
|
|
2019-01-17 07:01:00 +00:00
|
|
|
// 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;
|
|
|
|
|
2019-01-20 04:03:26 +00:00
|
|
|
signals:
|
|
|
|
void LoadProgress(VideoCore::LoadCallbackStage stage, std::size_t value, std::size_t total);
|
2019-01-21 16:20:16 +00:00
|
|
|
/// Signals that this widget is completely hidden now and should be replaced with the other
|
|
|
|
/// widget
|
|
|
|
void Hidden();
|
2019-01-17 07:01:00 +00:00
|
|
|
|
|
|
|
private:
|
2019-01-18 17:02:27 +00:00
|
|
|
#ifndef YUZU_QT_MOVIE_MISSING
|
2019-01-17 07:01:00 +00:00
|
|
|
std::unique_ptr<QMovie> animation;
|
|
|
|
std::unique_ptr<QBuffer> backing_buf;
|
|
|
|
std::unique_ptr<QByteArray> backing_mem;
|
2019-01-18 17:02:27 +00:00
|
|
|
#endif
|
2019-01-17 07:01:00 +00:00
|
|
|
std::unique_ptr<Ui::LoadingScreen> ui;
|
|
|
|
std::size_t previous_total = 0;
|
2019-01-20 04:03:26 +00:00
|
|
|
VideoCore::LoadCallbackStage previous_stage;
|
|
|
|
|
2019-01-21 16:20:16 +00:00
|
|
|
QGraphicsOpacityEffect* opacity_effect = nullptr;
|
2019-01-21 16:39:45 +00:00
|
|
|
std::unique_ptr<QPropertyAnimation> fadeout_animation;
|
2019-01-21 16:20:16 +00:00
|
|
|
|
2019-01-20 04:03:26 +00:00
|
|
|
// Definitions for the differences in text and styling for each stage
|
|
|
|
std::unordered_map<VideoCore::LoadCallbackStage, const char*> progressbar_style;
|
|
|
|
std::unordered_map<VideoCore::LoadCallbackStage, QString> stage_translations;
|
|
|
|
|
|
|
|
// newly generated shaders are added to the end of the file, so when loading and compiling
|
|
|
|
// shaders, it will start quickly but end slow if new shaders were added since previous launch.
|
|
|
|
// These variables are used to detect the change in speed so we can generate an ETA
|
|
|
|
bool slow_shader_compile_start = false;
|
2021-12-02 19:20:43 +00:00
|
|
|
std::chrono::steady_clock::time_point slow_shader_start;
|
|
|
|
std::chrono::steady_clock::time_point previous_time;
|
2019-01-20 04:03:26 +00:00
|
|
|
std::size_t slow_shader_first_value = 0;
|
2019-01-17 07:01:00 +00:00
|
|
|
};
|
2019-01-20 04:03:26 +00:00
|
|
|
|
|
|
|
Q_DECLARE_METATYPE(VideoCore::LoadCallbackStage);
|