GCMemcardManager.h 2.8 KB

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