2018-01-25 11:54:50 -07:00
|
|
|
// Copyright 2018 Dolphin Emulator Project
|
2021-07-04 19:22:19 -06:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2018-01-25 11:54:50 -07:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2020-08-10 12:47:50 -06:00
|
|
|
#include <map>
|
2018-01-25 11:54:50 -07:00
|
|
|
#include <memory>
|
2023-06-08 10:49:35 -06:00
|
|
|
#include <span>
|
2018-01-25 11:54:50 -07:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include <QDialog>
|
|
|
|
|
2019-08-08 08:28:30 -06:00
|
|
|
#include "Common/CommonTypes.h"
|
2022-01-11 14:02:50 -07:00
|
|
|
#include "Common/EnumMap.h"
|
|
|
|
#include "Core/HW/EXI/EXI.h"
|
2019-08-08 08:28:30 -06:00
|
|
|
|
2020-06-14 18:09:37 -06:00
|
|
|
namespace Memcard
|
|
|
|
{
|
2018-01-25 11:54:50 -07:00
|
|
|
class GCMemcard;
|
2019-08-14 20:08:20 -06:00
|
|
|
class GCMemcardErrorCode;
|
2020-07-31 12:56:52 -06:00
|
|
|
struct Savefile;
|
|
|
|
enum class ReadSavefileErrorCode;
|
2020-07-18 07:42:02 -06:00
|
|
|
enum class SavefileFormat;
|
2020-06-14 18:09:37 -06:00
|
|
|
} // namespace Memcard
|
2018-01-25 11:54:50 -07:00
|
|
|
|
2020-07-18 07:42:02 -06:00
|
|
|
class QAction;
|
2018-01-25 11:54:50 -07:00
|
|
|
class QDialogButtonBox;
|
|
|
|
class QGroupBox;
|
|
|
|
class QLabel;
|
|
|
|
class QLineEdit;
|
2020-07-18 07:42:02 -06:00
|
|
|
class QMenu;
|
2019-02-25 12:59:49 -07:00
|
|
|
class QPixmap;
|
2018-01-25 11:54:50 -07:00
|
|
|
class QPushButton;
|
2019-08-14 20:08:20 -06:00
|
|
|
class QString;
|
2018-01-25 11:54:50 -07:00
|
|
|
class QTableWidget;
|
|
|
|
class QTimer;
|
2020-07-18 07:42:02 -06:00
|
|
|
class QToolButton;
|
2018-01-25 11:54:50 -07:00
|
|
|
|
|
|
|
class GCMemcardManager : public QDialog
|
|
|
|
{
|
2018-05-13 14:16:20 -06:00
|
|
|
Q_OBJECT
|
2018-01-25 11:54:50 -07:00
|
|
|
public:
|
|
|
|
explicit GCMemcardManager(QWidget* parent = nullptr);
|
|
|
|
~GCMemcardManager();
|
|
|
|
|
2020-06-14 18:09:37 -06:00
|
|
|
static QString GetErrorMessagesForErrorCode(const Memcard::GCMemcardErrorCode& code);
|
2020-07-31 12:56:52 -06:00
|
|
|
static QString GetErrorMessageForErrorCode(Memcard::ReadSavefileErrorCode code);
|
2019-08-14 20:08:20 -06:00
|
|
|
|
2018-01-25 11:54:50 -07:00
|
|
|
private:
|
2019-08-08 08:28:30 -06:00
|
|
|
struct IconAnimationData;
|
|
|
|
|
2018-01-25 11:54:50 -07:00
|
|
|
void CreateWidgets();
|
|
|
|
void ConnectWidgets();
|
2019-06-15 21:26:28 -06:00
|
|
|
void LoadDefaultMemcards();
|
2018-01-25 11:54:50 -07:00
|
|
|
|
|
|
|
void UpdateActions();
|
2022-01-11 14:02:50 -07:00
|
|
|
void UpdateSlotTable(ExpansionInterface::Slot slot);
|
|
|
|
void SetSlotFile(ExpansionInterface::Slot slot, QString path);
|
|
|
|
void SetSlotFileInteractive(ExpansionInterface::Slot slot);
|
|
|
|
void SetActiveSlot(ExpansionInterface::Slot slot);
|
2018-01-25 11:54:50 -07:00
|
|
|
|
2020-07-18 07:42:02 -06:00
|
|
|
std::vector<u8> GetSelectedFileIndices();
|
|
|
|
|
2023-06-08 10:49:35 -06:00
|
|
|
void ImportFiles(ExpansionInterface::Slot slot, std::span<const Memcard::Savefile> savefiles);
|
2020-07-31 12:56:52 -06:00
|
|
|
|
2018-01-25 11:54:50 -07:00
|
|
|
void CopyFiles();
|
|
|
|
void ImportFile();
|
|
|
|
void DeleteFiles();
|
2020-07-18 07:42:02 -06:00
|
|
|
void ExportFiles(Memcard::SavefileFormat format);
|
2018-01-25 11:54:50 -07:00
|
|
|
void FixChecksums();
|
2022-01-11 14:02:50 -07:00
|
|
|
void CreateNewCard(ExpansionInterface::Slot slot);
|
2018-01-25 11:54:50 -07:00
|
|
|
void DrawIcons();
|
|
|
|
|
2022-01-11 14:02:50 -07:00
|
|
|
QPixmap GetBannerFromSaveFile(int file_index, ExpansionInterface::Slot slot);
|
2019-08-08 08:28:30 -06:00
|
|
|
|
2022-01-11 14:02:50 -07:00
|
|
|
IconAnimationData GetIconFromSaveFile(int file_index, ExpansionInterface::Slot slot);
|
2018-01-25 11:54:50 -07:00
|
|
|
|
|
|
|
// Actions
|
|
|
|
QPushButton* m_select_button;
|
|
|
|
QPushButton* m_copy_button;
|
2020-07-18 07:42:02 -06:00
|
|
|
QToolButton* m_export_button;
|
|
|
|
QMenu* m_export_menu;
|
|
|
|
QAction* m_export_gci_action;
|
|
|
|
QAction* m_export_gcs_action;
|
|
|
|
QAction* m_export_sav_action;
|
2018-01-25 11:54:50 -07:00
|
|
|
QPushButton* m_import_button;
|
|
|
|
QPushButton* m_delete_button;
|
|
|
|
QPushButton* m_fix_checksums_button;
|
|
|
|
|
|
|
|
// Slots
|
2023-06-08 11:05:10 -06:00
|
|
|
template <typename T>
|
|
|
|
using SlotEnumMap = Common::EnumMap<T, ExpansionInterface::MAX_MEMCARD_SLOT>;
|
|
|
|
|
|
|
|
SlotEnumMap<std::map<u8, IconAnimationData>> m_slot_active_icons;
|
|
|
|
SlotEnumMap<std::unique_ptr<Memcard::GCMemcard>> m_slot_memcard;
|
|
|
|
SlotEnumMap<QGroupBox*> m_slot_group;
|
|
|
|
SlotEnumMap<QLineEdit*> m_slot_file_edit;
|
|
|
|
SlotEnumMap<QPushButton*> m_slot_open_button;
|
|
|
|
SlotEnumMap<QPushButton*> m_slot_create_button;
|
|
|
|
SlotEnumMap<QTableWidget*> m_slot_table;
|
|
|
|
SlotEnumMap<QLabel*> m_slot_stat_label;
|
2022-01-11 14:02:50 -07:00
|
|
|
|
|
|
|
ExpansionInterface::Slot m_active_slot;
|
2019-08-08 08:28:30 -06:00
|
|
|
u64 m_current_frame = 0;
|
2018-01-25 11:54:50 -07:00
|
|
|
|
|
|
|
QDialogButtonBox* m_button_box;
|
|
|
|
QTimer* m_timer;
|
|
|
|
};
|