2020-12-05 13:08:24 +01:00
|
|
|
#pragma once
|
2020-06-02 10:39:24 +02:00
|
|
|
|
|
|
|
|
#include <QDialog>
|
|
|
|
|
#include <QTreeWidgetItem>
|
2020-06-12 21:09:08 +02:00
|
|
|
#include <QDragMoveEvent>
|
|
|
|
|
#include <QMimeData>
|
2020-06-02 10:39:24 +02:00
|
|
|
|
|
|
|
|
#include "Utilities/bin_patch.h"
|
2020-12-22 16:04:08 +01:00
|
|
|
#include <unordered_map>
|
2020-06-02 10:39:24 +02:00
|
|
|
|
|
|
|
|
namespace Ui
|
|
|
|
|
{
|
|
|
|
|
class patch_manager_dialog;
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-06 11:47:45 +02:00
|
|
|
class downloader;
|
2020-06-25 18:26:47 +02:00
|
|
|
class gui_settings;
|
|
|
|
|
|
2020-06-02 10:39:24 +02:00
|
|
|
class patch_manager_dialog : public QDialog
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
2020-06-26 02:58:06 +02:00
|
|
|
struct gui_patch_info
|
|
|
|
|
{
|
|
|
|
|
QString hash;
|
|
|
|
|
QString title;
|
|
|
|
|
QString serial;
|
|
|
|
|
QString app_version;
|
|
|
|
|
QString author;
|
|
|
|
|
QString notes;
|
|
|
|
|
QString description;
|
|
|
|
|
QString patch_version;
|
|
|
|
|
};
|
|
|
|
|
|
2020-09-06 12:27:35 +02:00
|
|
|
const QString tr_all_titles = tr("All titles - Warning: These patches apply to all games!");
|
2020-06-27 10:32:00 +02:00
|
|
|
const QString tr_all_serials = tr("All serials");
|
|
|
|
|
const QString tr_all_versions = tr("All versions");
|
|
|
|
|
|
2020-06-02 10:39:24 +02:00
|
|
|
public:
|
2021-03-07 19:55:40 +01:00
|
|
|
explicit patch_manager_dialog(std::shared_ptr<gui_settings> gui_settings, std::unordered_map<std::string, std::set<std::string>> games, const std::string& title_id, const std::string& version, QWidget* parent = nullptr);
|
2020-06-02 10:39:24 +02:00
|
|
|
~patch_manager_dialog();
|
|
|
|
|
|
2020-06-25 18:26:47 +02:00
|
|
|
int exec() override;
|
|
|
|
|
|
2020-06-02 10:39:24 +02:00
|
|
|
private Q_SLOTS:
|
|
|
|
|
void filter_patches(const QString& term);
|
2020-08-02 17:36:22 +02:00
|
|
|
void handle_item_selected(QTreeWidgetItem *current, QTreeWidgetItem *previous);
|
|
|
|
|
void handle_item_changed(QTreeWidgetItem *item, int column);
|
|
|
|
|
void handle_custom_context_menu_requested(const QPoint& pos);
|
|
|
|
|
void handle_show_owned_games_only(int state);
|
2020-06-02 10:39:24 +02:00
|
|
|
|
|
|
|
|
private:
|
2020-06-25 18:26:47 +02:00
|
|
|
void refresh(bool restore_layout = false);
|
2020-06-30 21:35:15 +02:00
|
|
|
void load_patches(bool show_error);
|
2020-06-02 10:39:24 +02:00
|
|
|
void populate_tree();
|
2021-04-07 23:05:18 +02:00
|
|
|
void save_config() const;
|
|
|
|
|
void update_patch_info(const gui_patch_info& info) const;
|
|
|
|
|
static bool is_valid_file(const QMimeData& md, QStringList* drop_paths = nullptr);
|
2021-11-18 20:47:17 +01:00
|
|
|
void download_update(bool automatic, bool auto_accept);
|
2020-09-06 11:47:45 +02:00
|
|
|
bool handle_json(const QByteArray& data);
|
2020-06-02 10:39:24 +02:00
|
|
|
|
2020-06-25 18:26:47 +02:00
|
|
|
std::shared_ptr<gui_settings> m_gui_settings;
|
|
|
|
|
|
2021-03-07 19:55:40 +01:00
|
|
|
bool m_expand_current_match = false;
|
|
|
|
|
QString m_search_version;
|
|
|
|
|
|
2020-06-26 18:31:42 +02:00
|
|
|
std::unordered_map<std::string, std::set<std::string>> m_owned_games;
|
|
|
|
|
bool m_show_owned_games_only = false;
|
|
|
|
|
|
2020-06-02 10:39:24 +02:00
|
|
|
patch_engine::patch_map m_map;
|
|
|
|
|
|
2020-09-06 11:47:45 +02:00
|
|
|
downloader* m_downloader = nullptr;
|
2021-11-18 20:47:17 +01:00
|
|
|
bool m_download_automatic = false;
|
|
|
|
|
bool m_download_auto_accept = false;
|
2020-09-06 11:47:45 +02:00
|
|
|
|
2020-06-02 10:39:24 +02:00
|
|
|
Ui::patch_manager_dialog *ui;
|
2020-06-12 21:09:08 +02:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
void dropEvent(QDropEvent* event) override;
|
|
|
|
|
void dragEnterEvent(QDragEnterEvent* event) override;
|
|
|
|
|
void dragMoveEvent(QDragMoveEvent* event) override;
|
|
|
|
|
void dragLeaveEvent(QDragLeaveEvent* event) override;
|
2020-06-02 10:39:24 +02:00
|
|
|
};
|