MemcardManager.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. // Copyright 2008 Dolphin Emulator Project
  2. // Licensed under GPLv2+
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <string>
  6. #include <wx/dialog.h>
  7. #include <wx/listctrl.h>
  8. #include "Common/CommonTypes.h"
  9. #include "Common/IniFile.h"
  10. class GCMemcard;
  11. class wxButton;
  12. class wxFileDirPickerEvent;
  13. class wxFilePickerCtrl;
  14. class wxStaticText;
  15. #undef MEMCARD_MANAGER_STYLE
  16. #define MEMCARD_MANAGER_STYLE wxCAPTION | wxSYSTEM_MENU | wxDIALOG_NO_PARENT | wxCLOSE_BOX | wxRESIZE_BORDER | wxMAXIMIZE_BOX
  17. #define MEMCARDMAN_TITLE _trans("Memory Card Manager WARNING-Make backups before using, should be fixed but could mangle stuff!")
  18. #define FIRSTPAGE 0
  19. class CMemcardManager : public wxDialog
  20. {
  21. public:
  22. CMemcardManager(wxWindow *parent, wxWindowID id = wxID_ANY, const wxString& title = wxGetTranslation(MEMCARDMAN_TITLE),
  23. const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = MEMCARD_MANAGER_STYLE);
  24. virtual ~CMemcardManager();
  25. private:
  26. DECLARE_EVENT_TABLE();
  27. int page[2];
  28. int itemsPerPage;
  29. int maxPages;
  30. std::string DefaultMemcard[2];
  31. std::string DefaultIOPath;
  32. IniFile MemcardManagerIni;
  33. IniFile::Section* iniMemcardSection;
  34. wxButton* m_CopyFrom[2];
  35. wxButton* m_SaveImport[2];
  36. wxButton* m_SaveExport[2];
  37. wxButton* m_Delete[2];
  38. wxButton* m_NextPage[2];
  39. wxButton* m_PrevPage[2];
  40. wxButton* m_ConvertToGci;
  41. wxFilePickerCtrl *m_MemcardPath[2];
  42. wxStaticText *t_Status[2];
  43. enum
  44. {
  45. ID_COPYFROM_A = 1000, // Do not rearrange these items,
  46. ID_COPYFROM_B, // ID_..._B must be 1 more than ID_..._A
  47. ID_FIXCHECKSUM_A,
  48. ID_FIXCHECKSUM_B,
  49. ID_DELETE_A,
  50. ID_DELETE_B,
  51. ID_SAVEEXPORT_A,
  52. ID_SAVEEXPORT_B,
  53. ID_SAVEIMPORT_A,
  54. ID_SAVEIMPORT_B,
  55. ID_EXPORTALL_A,
  56. ID_EXPORTALL_B,
  57. ID_CONVERTTOGCI,
  58. ID_NEXTPAGE_A,
  59. ID_NEXTPAGE_B,
  60. ID_PREVPAGE_A,
  61. ID_PREVPAGE_B,
  62. ID_MEMCARDLIST_A,
  63. ID_MEMCARDLIST_B,
  64. ID_MEMCARDPATH_A,
  65. ID_MEMCARDPATH_B,
  66. ID_USEPAGES,
  67. ID_DUMMY_VALUE_ //don't remove this value unless you have other enum values
  68. };
  69. enum
  70. {
  71. COLUMN_BANNER = 0,
  72. COLUMN_TITLE,
  73. COLUMN_COMMENT,
  74. COLUMN_ICON,
  75. COLUMN_BLOCKS,
  76. COLUMN_FIRSTBLOCK,
  77. COLUMN_GAMECODE,
  78. COLUMN_MAKERCODE,
  79. COLUMN_FILENAME,
  80. COLUMN_BIFLAGS,
  81. COLUMN_MODTIME,
  82. COLUMN_IMAGEADD,
  83. COLUMN_ICONFMT,
  84. COLUMN_ANIMSPEED,
  85. COLUMN_PERMISSIONS,
  86. COLUMN_COPYCOUNTER,
  87. COLUMN_COMMENTSADDRESS,
  88. NUMBER_OF_COLUMN
  89. };
  90. GCMemcard *memoryCard[2];
  91. void CreateGUIControls();
  92. void CopyDeleteClick(wxCommandEvent& event);
  93. bool ReloadMemcard(const std::string& fileName, int card);
  94. void OnMenuChange(wxCommandEvent& event);
  95. void OnPageChange(wxCommandEvent& event);
  96. void OnPathChange(wxFileDirPickerEvent& event);
  97. void ChangePath(int id);
  98. bool CopyDeleteSwitch(u32 error, int slot);
  99. bool LoadSettings();
  100. bool SaveSettings();
  101. struct _mcmSettings
  102. {
  103. bool twoCardsLoaded;
  104. bool usePages;
  105. bool column[NUMBER_OF_COLUMN + 1];
  106. } mcmSettings;
  107. class CMemcardListCtrl : public wxListCtrl
  108. {
  109. //BEGIN_EVENT_TABLE(CMemcardManager::CMemcardListCtrl, wxListCtrl)
  110. // EVT_RIGHT_DOWN(CMemcardManager::CMemcardListCtrl::OnRightClick)
  111. //END_EVENT_TABLE()
  112. public:
  113. CMemcardListCtrl(wxWindow* parent, const wxWindowID id,
  114. const wxPoint& pos, const wxSize& size,
  115. long style, _mcmSettings& _mcmSetngs)
  116. : wxListCtrl(parent, id, pos, size, style)
  117. , __mcmSettings(_mcmSetngs)
  118. {
  119. Bind(wxEVT_RIGHT_DOWN, &CMemcardListCtrl::OnRightClick, this);
  120. }
  121. ~CMemcardListCtrl()
  122. {
  123. Unbind(wxEVT_RIGHT_DOWN, &CMemcardListCtrl::OnRightClick, this);
  124. }
  125. _mcmSettings & __mcmSettings;
  126. bool prevPage;
  127. bool nextPage;
  128. private:
  129. void OnRightClick(wxMouseEvent& event);
  130. };
  131. CMemcardListCtrl *m_MemcardList[2];
  132. };