| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
#pragma once |
| 5 |
|
| 6 |
#include <map> |
| 7 |
#include <memory> |
| 8 |
#include <span> |
| 9 |
#include <vector> |
| 10 |
|
| 11 |
#include <QDialog> |
| 12 |
|
| 13 |
#include "Common/CommonTypes.h" |
| 14 |
#include "Common/EnumMap.h" |
| 15 |
#include "Core/HW/EXI/EXI.h" |
| 16 |
|
| 17 |
namespace Memcard |
| 18 |
{ |
| 19 |
class GCMemcard; |
| 20 |
class GCMemcardErrorCode; |
| 21 |
struct Savefile; |
| 22 |
enum class ReadSavefileErrorCode; |
| 23 |
enum class SavefileFormat; |
| 24 |
} |
| 25 |
|
| 26 |
class QAction; |
| 27 |
class QDialogButtonBox; |
| 28 |
class QGroupBox; |
| 29 |
class QLabel; |
| 30 |
class QLineEdit; |
| 31 |
class QMenu; |
| 32 |
class QPixmap; |
| 33 |
class QPushButton; |
| 34 |
class QString; |
| 35 |
class QTableWidget; |
| 36 |
class QTimer; |
| 37 |
class QToolButton; |
| 38 |
|
| 39 |
class GCMemcardManager : public QDialog |
| 40 |
{ |
| 41 |
Q_OBJECT |
| 42 |
public: |
| 43 |
explicit GCMemcardManager(QWidget* parent = nullptr); |
| 44 |
~GCMemcardManager() override; |
| 45 |
|
| 46 |
static QString GetErrorMessagesForErrorCode(const Memcard::GCMemcardErrorCode& code); |
| 47 |
static QString GetErrorMessageForErrorCode(Memcard::ReadSavefileErrorCode code); |
| 48 |
|
| 49 |
private: |
| 50 |
struct IconAnimationData; |
| 51 |
|
| 52 |
void CreateWidgets(); |
| 53 |
void ConnectWidgets(); |
| 54 |
void LoadDefaultMemcards(); |
| 55 |
|
| 56 |
void UpdateActions(); |
| 57 |
void UpdateSlotTable(ExpansionInterface::Slot slot); |
| 58 |
void SetSlotFile(ExpansionInterface::Slot slot, const QString& path); |
| 59 |
void SetSlotFileInteractive(ExpansionInterface::Slot slot); |
| 60 |
void SetActiveSlot(ExpansionInterface::Slot slot); |
| 61 |
|
| 62 |
std::vector<u8> GetSelectedFileIndices(); |
| 63 |
|
| 64 |
void ImportFiles(ExpansionInterface::Slot slot, std::span<const Memcard::Savefile> savefiles); |
| 65 |
|
| 66 |
void CopyFiles(); |
| 67 |
void ImportFile(); |
| 68 |
void DeleteFiles(); |
| 69 |
void ExportFiles(Memcard::SavefileFormat format); |
| 70 |
void FixChecksums(); |
| 71 |
void CreateNewCard(ExpansionInterface::Slot slot); |
| 72 |
void DrawIcons(); |
| 73 |
|
| 74 |
QPixmap GetBannerFromSaveFile(int file_index, ExpansionInterface::Slot slot); |
| 75 |
|
| 76 |
IconAnimationData GetIconFromSaveFile(int file_index, ExpansionInterface::Slot slot); |
| 77 |
|
| 78 |
|
| 79 |
QPushButton* m_select_button; |
| 80 |
QPushButton* m_copy_button; |
| 81 |
QToolButton* m_export_button; |
| 82 |
QMenu* m_export_menu; |
| 83 |
QAction* m_export_gci_action; |
| 84 |
QAction* m_export_gcs_action; |
| 85 |
QAction* m_export_sav_action; |
| 86 |
QPushButton* m_import_button; |
| 87 |
QPushButton* m_delete_button; |
| 88 |
QPushButton* m_fix_checksums_button; |
| 89 |
|
| 90 |
|
| 91 |
template <typename T> |
| 92 |
using SlotEnumMap = Common::EnumMap<T, ExpansionInterface::MAX_MEMCARD_SLOT>; |
| 93 |
|
| 94 |
SlotEnumMap<std::map<u8, IconAnimationData>> m_slot_active_icons; |
| 95 |
SlotEnumMap<std::unique_ptr<Memcard::GCMemcard>> m_slot_memcard; |
| 96 |
SlotEnumMap<QGroupBox*> m_slot_group; |
| 97 |
SlotEnumMap<QLineEdit*> m_slot_file_edit; |
| 98 |
SlotEnumMap<QPushButton*> m_slot_open_button; |
| 99 |
SlotEnumMap<QPushButton*> m_slot_create_button; |
| 100 |
SlotEnumMap<QTableWidget*> m_slot_table; |
| 101 |
SlotEnumMap<QLabel*> m_slot_stat_label; |
| 102 |
|
| 103 |
ExpansionInterface::Slot m_active_slot; |
| 104 |
u64 m_current_frame = 0; |
| 105 |
|
| 106 |
QDialogButtonBox* m_button_box; |
| 107 |
QTimer* m_timer; |
| 108 |
}; |