rpcsx/rpcs3/rpcs3qt/trophy_manager_dialog.h

136 lines
3.4 KiB
C
Raw Normal View History

2020-12-05 13:08:24 +01:00
#pragma once
2017-10-26 11:09:44 -05:00
#include "Loader/TROPUSR.h"
2017-10-26 11:09:44 -05:00
#include <QWidget>
2018-05-17 22:36:31 +02:00
#include <QComboBox>
2021-10-30 20:44:25 +02:00
#include <QFutureWatcher>
2018-05-17 22:36:31 +02:00
#include <QLabel>
2017-10-26 11:09:44 -05:00
#include <QPixmap>
2018-05-17 22:36:31 +02:00
#include <QTableWidget>
#include <QSlider>
2018-05-17 22:36:31 +02:00
#include <QSplitter>
2020-02-22 20:42:49 +01:00
2021-04-07 23:05:18 +02:00
#include <memory>
#include <mutex>
#include <unordered_map>
2021-04-07 23:05:18 +02:00
class game_list;
2020-02-22 20:42:49 +01:00
class gui_settings;
class TROPUSRLoader;
2017-10-26 11:09:44 -05:00
struct GameTrophiesData
{
std::unique_ptr<TROPUSRLoader> trop_usr;
trophy_xml_document trop_config; // I'd like to use unique but the protocol inside of the function passes around shared pointers..
std::unordered_map<int, QPixmap> trophy_images; // Cache trophy images to avoid loading from disk as much as possible.
std::unordered_map<int, QString> trophy_image_paths;
2017-10-26 11:09:44 -05:00
std::string game_name;
std::string path;
};
enum TrophyColumns
{
Icon = 0,
Name = 1,
Description = 2,
Type = 3,
IsUnlocked = 4,
Id = 5,
PlatinumLink = 6,
2018-05-17 22:36:31 +02:00
Count
2018-05-17 22:36:31 +02:00
};
enum GameColumns
{
GameIcon = 0,
GameName = 1,
GameProgress = 2,
2018-05-17 22:36:31 +02:00
GameColumnsCount
2017-10-26 11:09:44 -05:00
};
2021-10-30 20:44:25 +02:00
enum GameUserRole
{
GameIndex = Qt::UserRole,
GamePixmapLoaded,
GamePixmap
};
2017-10-26 11:09:44 -05:00
class trophy_manager_dialog : public QWidget
{
2018-10-31 20:38:48 +02:00
Q_OBJECT
2017-10-26 11:09:44 -05:00
public:
explicit trophy_manager_dialog(std::shared_ptr<gui_settings> gui_settings);
2018-10-31 20:38:48 +02:00
~trophy_manager_dialog() override;
void RepaintUI(bool restore_layout = true);
public Q_SLOTS:
2018-07-08 11:48:38 +02:00
void HandleRepaintUiRequest();
2017-10-26 11:09:44 -05:00
private Q_SLOTS:
2021-04-07 23:05:18 +02:00
QPixmap GetResizedGameIcon(int index) const;
void ResizeGameIcons();
void ResizeTrophyIcons();
2017-10-26 11:09:44 -05:00
void ApplyFilter();
void ShowContextMenu(const QPoint& pos);
2017-10-26 11:09:44 -05:00
private:
/** Loads a trophy folder.
Returns true if successful. Does not attempt to install if failure occurs, like sceNpTrophy.
*/
bool LoadTrophyFolderToDB(const std::string& trop_name);
2017-10-26 11:09:44 -05:00
2019-07-27 16:30:34 +02:00
/** Populate the trophy database (multithreaded). */
void StartTrophyLoadThreads();
/** Fills game table with information.
Takes results from LoadTrophyFolderToDB and puts it into the UI.
*/
void PopulateGameTable();
/** Fills trophy table with information.
2017-10-26 11:09:44 -05:00
Takes results from LoadTrophyFolderToDB and puts it into the UI.
*/
void PopulateTrophyTable();
2017-10-26 11:09:44 -05:00
2021-04-07 23:05:18 +02:00
void ReadjustGameTable() const;
void ReadjustTrophyTable() const;
2018-05-17 22:36:31 +02:00
void closeEvent(QCloseEvent *event) override;
bool eventFilter(QObject *object, QEvent *event) override;
std::shared_ptr<gui_settings> m_gui_settings;
2017-10-26 11:09:44 -05:00
std::vector<std::unique_ptr<GameTrophiesData>> m_trophies_db; //! Holds all the trophy information.
std::mutex m_trophies_db_mtx;
2018-05-17 22:36:31 +02:00
QComboBox* m_game_combo; //! Lets you choose a game
QLabel* m_game_progress; //! Shows you the current game's progress
QSplitter* m_splitter; //! Contains the game and trophy tables
game_list* m_trophy_table; //! UI element to display trophy stuff.
2018-05-17 22:36:31 +02:00
QTableWidget* m_game_table; //! UI element to display games.
2021-10-30 20:44:25 +02:00
QFutureWatcher<QPixmap> m_game_repaint_watcher;
QFutureWatcher<QPixmap> m_trophy_repaint_watcher;
2017-10-26 11:09:44 -05:00
bool m_show_hidden_trophies = false;
bool m_show_unlocked_trophies = true;
bool m_show_locked_trophies = true;
bool m_show_bronze_trophies = true;
bool m_show_silver_trophies = true;
bool m_show_gold_trophies = true;
bool m_show_platinum_trophies = true;
std::string m_trophy_dir;
int m_icon_height = 75;
bool m_save_icon_height = false;
QSlider* m_icon_slider = nullptr;
int m_game_icon_size_index = 25;
QSize m_game_icon_size = QSize(m_game_icon_size_index, m_game_icon_size_index);
bool m_save_game_icon_size = false;
QSlider* m_game_icon_slider = nullptr;
QColor m_game_icon_color;
2017-10-26 11:09:44 -05:00
};