Adds a right click menu options to memcard manager, whether to use pages\ how many saves per page, which columns to show/hide

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1476 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
LPFaint99 2008-12-10 02:41:55 +00:00
parent e80c190602
commit 4f40c79345
3 changed files with 547 additions and 271 deletions

View File

@ -47,7 +47,7 @@ SConfig::~SConfig()
void SConfig::SaveSettings()
{
IniFile ini;
// ini.Load(CONFIG_FILE); // yes we must load first to not kill unknown stuff
ini.Load(CONFIG_FILE); // yes we must load first to not kill unknown stuff
// misc
{

View File

@ -72,158 +72,234 @@ wxBitmap wxBitmapFromMemoryRGBA(const unsigned char* data, int width, int height
BEGIN_EVENT_TABLE(CMemcardManager, wxDialog)
EVT_CLOSE(CMemcardManager::OnClose)
EVT_BUTTON(ID_COPYTOLEFT,CMemcardManager::CopyDeleteClick)
EVT_BUTTON(ID_COPYTORIGHT,CMemcardManager::CopyDeleteClick)
EVT_BUTTON(ID_FIXCHECKSUMLEFT,CMemcardManager::CopyDeleteClick)
EVT_BUTTON(ID_FIXCHECKSUMRIGHT,CMemcardManager::CopyDeleteClick)
EVT_BUTTON(ID_DELETELEFT,CMemcardManager::CopyDeleteClick)
EVT_BUTTON(ID_DELETERIGHT,CMemcardManager::CopyDeleteClick)
EVT_BUTTON(ID_SAVEIMPORTRIGHT,CMemcardManager::CopyDeleteClick)
EVT_BUTTON(ID_SAVEEXPORTRIGHT,CMemcardManager::CopyDeleteClick)
EVT_BUTTON(ID_SAVEIMPORTLEFT,CMemcardManager::CopyDeleteClick)
EVT_BUTTON(ID_SAVEEXPORTLEFT,CMemcardManager::CopyDeleteClick)
EVT_BUTTON(ID_COPYTO_A,CMemcardManager::CopyDeleteClick)
EVT_BUTTON(ID_COPYTO_B,CMemcardManager::CopyDeleteClick)
EVT_BUTTON(ID_FIXCHECKSUM_A,CMemcardManager::CopyDeleteClick)
EVT_BUTTON(ID_FIXCHECKSUM_B,CMemcardManager::CopyDeleteClick)
EVT_BUTTON(ID_DELETE_A,CMemcardManager::CopyDeleteClick)
EVT_BUTTON(ID_DELETE_B,CMemcardManager::CopyDeleteClick)
EVT_BUTTON(ID_SAVEIMPORT_B,CMemcardManager::CopyDeleteClick)
EVT_BUTTON(ID_SAVEEXPORT_B,CMemcardManager::CopyDeleteClick)
EVT_BUTTON(ID_SAVEIMPORT_A,CMemcardManager::CopyDeleteClick)
EVT_BUTTON(ID_SAVEEXPORT_A,CMemcardManager::CopyDeleteClick)
EVT_BUTTON(ID_CONVERTTOGCI,CMemcardManager::CopyDeleteClick)
EVT_BUTTON(ID_MEMCARD1PREVPAGE, CMemcardManager::OnPageChange)
EVT_BUTTON(ID_MEMCARD1NEXTPAGE, CMemcardManager::OnPageChange)
EVT_BUTTON(ID_MEMCARD2PREVPAGE, CMemcardManager::OnPageChange)
EVT_BUTTON(ID_MEMCARD2NEXTPAGE, CMemcardManager::OnPageChange)
EVT_FILEPICKER_CHANGED(ID_MEMCARD1PATH,CMemcardManager::OnPathChange)
EVT_FILEPICKER_CHANGED(ID_MEMCARD2PATH,CMemcardManager::OnPathChange)
EVT_BUTTON(ID_PREVPAGE_A, CMemcardManager::OnPageChange)
EVT_BUTTON(ID_NEXTPAGE_A, CMemcardManager::OnPageChange)
EVT_BUTTON(ID_PREVPAGE_B, CMemcardManager::OnPageChange)
EVT_BUTTON(ID_NEXTPAGE_B, CMemcardManager::OnPageChange)
EVT_MENU(ID_COPYTO_A,CMemcardManager::CopyDeleteClick)
EVT_MENU(ID_COPYTO_B,CMemcardManager::CopyDeleteClick)
EVT_MENU(ID_FIXCHECKSUM_A,CMemcardManager::CopyDeleteClick)
EVT_MENU(ID_FIXCHECKSUM_B,CMemcardManager::CopyDeleteClick)
EVT_MENU(ID_DELETE_A,CMemcardManager::CopyDeleteClick)
EVT_MENU(ID_DELETE_B,CMemcardManager::CopyDeleteClick)
EVT_MENU(ID_SAVEIMPORT_B,CMemcardManager::CopyDeleteClick)
EVT_MENU(ID_SAVEEXPORT_B,CMemcardManager::CopyDeleteClick)
EVT_MENU(ID_SAVEIMPORT_A,CMemcardManager::CopyDeleteClick)
EVT_MENU(ID_SAVEEXPORT_A,CMemcardManager::CopyDeleteClick)
EVT_MENU(ID_CONVERTTOGCI,CMemcardManager::CopyDeleteClick)
EVT_MENU(ID_PREVPAGE_A, CMemcardManager::OnPageChange)
EVT_MENU(ID_NEXTPAGE_A, CMemcardManager::OnPageChange)
EVT_MENU(ID_PREVPAGE_B, CMemcardManager::OnPageChange)
EVT_MENU(ID_NEXTPAGE_B, CMemcardManager::OnPageChange)
EVT_MENU(COLUMN_BANNER, CMemcardManager::OnMenuChange)
EVT_MENU(COLUMN_TITLE, CMemcardManager::OnMenuChange)
EVT_MENU(COLUMN_COMMENT, CMemcardManager::OnMenuChange)
EVT_MENU(COLUMN_ICON, CMemcardManager::OnMenuChange)
EVT_MENU(COLUMN_BLOCKS, CMemcardManager::OnMenuChange)
EVT_MENU(COLUMN_FIRSTBLOCK, CMemcardManager::OnMenuChange)
EVT_MENU(ID_USEPAGES, CMemcardManager::OnMenuChange)
EVT_FILEPICKER_CHANGED(ID_MEMCARDPATH_A,CMemcardManager::OnPathChange)
EVT_FILEPICKER_CHANGED(ID_MEMCARDPATH_B,CMemcardManager::OnPathChange)
END_EVENT_TABLE()
BEGIN_EVENT_TABLE(CMemcardManager::CMemcardListCtrl, wxListCtrl)
EVT_RIGHT_DOWN(CMemcardManager::CMemcardListCtrl::OnRightClick)
END_EVENT_TABLE()
CMemcardManager::CMemcardManager(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& position, const wxSize& size, long style)
: wxDialog(parent, id, title, position, size, style)
{
memoryCard[0]=NULL;
memoryCard[1]=NULL;
memoryCard[SLOT_A]=NULL;
memoryCard[SLOT_B]=NULL;
if (MemcardManagerIni.Load(wxT(CONFIG_FILE)))
{
MemcardManagerIni.Get(wxT("MemcardManager"), wxT("Items per page"), &itemsPerPage, 16);
}
else itemsPerPage = 16;
maxPages = (128 / itemsPerPage) - 1;
CreateGUIControls();
}
CMemcardManager::~CMemcardManager()
{
if (memoryCard[0])
if (memoryCard[SLOT_A])
{
delete memoryCard[0];
memoryCard[0] = NULL;
delete memoryCard[SLOT_A];
memoryCard[SLOT_A] = NULL;
}
if (memoryCard[1])
if (memoryCard[SLOT_B])
{
delete memoryCard[1];
memoryCard[1] = NULL;
delete memoryCard[SLOT_B];
memoryCard[SLOT_B] = NULL;
}
MemcardManagerIni.Load(wxT(CONFIG_FILE));
MemcardManagerIni.Set(wxT("MemcardManager"), wxT("Items per page"), itemsPerPage);
MemcardManagerIni.Save(wxT(CONFIG_FILE));
}
CMemcardManager::CMemcardListCtrl::CMemcardListCtrl(wxWindow* parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
: wxListCtrl(parent, id, pos, size, style)
{
if (MemcardManagerIni.Load(wxT(CONFIG_FILE)))
{
MemcardManagerIni.Get(wxT("MemcardManager"), wxT("Use Pages"), &usePages, true);
MemcardManagerIni.Get(wxT("MemcardManager"), wxT("cBanner"), &column[COLUMN_BANNER], true);
MemcardManagerIni.Get(wxT("MemcardManager"), wxT("cTitle"), &column[COLUMN_TITLE], true);
MemcardManagerIni.Get(wxT("MemcardManager"), wxT("cComment"), &column[COLUMN_COMMENT], true);
MemcardManagerIni.Get(wxT("MemcardManager"), wxT("cBlocks"), &column[COLUMN_BLOCKS], true);
MemcardManagerIni.Get(wxT("MemcardManager"), wxT("cBanner"), &column[COLUMN_BANNER], true);
MemcardManagerIni.Get(wxT("MemcardManager"), wxT("cFirst Block"), &column[COLUMN_FIRSTBLOCK], true);
}
else
{
usePages = true;
for (int i = 0; i < NUMBER_OF_COLUMN; i++) column[i] = true;
}
twoCardsLoaded = false;
prevPage = false;
nextPage = false;
}
CMemcardManager::CMemcardListCtrl::~CMemcardListCtrl()
{
MemcardManagerIni.Load(wxT(CONFIG_FILE));
MemcardManagerIni.Set(wxT("MemcardManager"), wxT("Use Pages"), usePages);
MemcardManagerIni.Set(wxT("MemcardManager"), wxT("cBanner"), column[COLUMN_BANNER]);
MemcardManagerIni.Set(wxT("MemcardManager"), wxT("cTitle"), column[COLUMN_TITLE]);
MemcardManagerIni.Set(wxT("MemcardManager"), wxT("cComment"), column[COLUMN_COMMENT]);
MemcardManagerIni.Set(wxT("MemcardManager"), wxT("cBlocks"), column[COLUMN_BLOCKS]);
MemcardManagerIni.Set(wxT("MemcardManager"), wxT("cBanner"), column[COLUMN_BANNER]);
MemcardManagerIni.Set(wxT("MemcardManager"), wxT("cFirst Block"), column[COLUMN_FIRSTBLOCK]);
MemcardManagerIni.Save(wxT(CONFIG_FILE));
}
void CMemcardManager::CreateGUIControls()
{
t_StatusLeft = new wxStaticText(this, 0, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString);
t_StatusRight = new wxStaticText(this, 0, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString);
// Create the controls for both memcards
// Loading invalid .raw files should no longer crash the app
m_MemcardPath_A = new wxFilePickerCtrl(this, ID_MEMCARDPATH_A, wxEmptyString, wxT("Choose a memory card:"),
wxT("Raw memcards (*.raw)|*.raw"), wxDefaultPosition, wxDefaultSize, wxFLP_USE_TEXTCTRL|wxFLP_FILE_MUST_EXIST|wxFLP_OPEN);
m_MemcardPath_B = new wxFilePickerCtrl(this, ID_MEMCARDPATH_B, wxEmptyString, wxT("Choose a memory card:"),
wxT("Raw memcards (*.raw)|*.raw"), wxDefaultPosition, wxDefaultSize, wxFLP_USE_TEXTCTRL|wxFLP_FILE_MUST_EXIST|wxFLP_OPEN);
m_MemcardList[SLOT_A] = new CMemcardListCtrl(this, ID_MEMCARDLIST_A, wxDefaultPosition, wxSize(350,400),
wxLC_REPORT | wxSUNKEN_BORDER | wxLC_ALIGN_LEFT | wxLC_SINGLE_SEL);
m_MemcardList[SLOT_B] = new CMemcardListCtrl(this, ID_MEMCARDLIST_B, wxDefaultPosition, wxSize(350,400),
wxLC_REPORT | wxSUNKEN_BORDER | wxLC_ALIGN_LEFT | wxLC_SINGLE_SEL);
m_MemcardList[SLOT_A]->AssignImageList(new wxImageList(96,32),wxIMAGE_LIST_SMALL);
m_MemcardList[SLOT_B]->AssignImageList(new wxImageList(96,32),wxIMAGE_LIST_SMALL);
t_Status_A = new wxStaticText(this, 0, wxEmptyString, wxDefaultPosition,wxDefaultSize, 0, wxEmptyString);
t_Status_B = new wxStaticText(this, 0, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString);
// buttons
m_CopyToLeft = new wxButton(this, ID_COPYTOLEFT, wxT("<-Copy<-"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_CopyToRight = new wxButton(this, ID_COPYTORIGHT, wxT("->Copy->"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_CopyTo_A = new wxButton(this, ID_COPYTO_A, wxT("<-Copy<-"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_CopyTo_B = new wxButton(this, ID_COPYTO_B, wxT("->Copy->"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_FixChecksumLeft = new wxButton(this, ID_FIXCHECKSUMLEFT, wxT("<-Fix Checksum"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_FixChecksumRight = new wxButton(this, ID_FIXCHECKSUMRIGHT, wxT("Fix Checksum->"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_FixChecksum_A = new wxButton(this, ID_FIXCHECKSUM_A, wxT("<-Fix Checksum"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_FixChecksum_B = new wxButton(this, ID_FIXCHECKSUM_B, wxT("Fix Checksum->"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_SaveImportLeft = new wxButton(this, ID_SAVEIMPORTLEFT, wxT("<-Import GCI"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_SaveImportRight = new wxButton(this, ID_SAVEIMPORTRIGHT, wxT("Import GCI->"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_SaveImport_A = new wxButton(this, ID_SAVEIMPORT_A, wxT("<-Import GCI"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_SaveImport_B = new wxButton(this, ID_SAVEIMPORT_B, wxT("Import GCI->"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_SaveExportLeft = new wxButton(this, ID_SAVEEXPORTLEFT, wxT("<-Export GCI"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_SaveExportRight = new wxButton(this, ID_SAVEEXPORTRIGHT, wxT("Export GCI->"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_SaveExport_A = new wxButton(this, ID_SAVEEXPORT_A, wxT("<-Export GCI"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_SaveExport_B = new wxButton(this, ID_SAVEEXPORT_B, wxT("Export GCI->"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_ConvertToGci = new wxButton(this, ID_CONVERTTOGCI, wxT("Convert to GCI"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_DeleteLeft = new wxButton(this, ID_DELETELEFT, wxT("<-Delete"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_DeleteRight = new wxButton(this, ID_DELETERIGHT, wxT("Delete->"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_Delete_A = new wxButton(this, ID_DELETE_A, wxT("<-Delete"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_Delete_B = new wxButton(this, ID_DELETE_B, wxT("Delete->"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_Memcard1PrevPage = new wxButton(this, ID_MEMCARD1PREVPAGE, wxT("Prev Page"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_Memcard2PrevPage = new wxButton(this, ID_MEMCARD2PREVPAGE, wxT("Prev Page"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_PrevPage_A = new wxButton(this, ID_PREVPAGE_A, wxT("Prev Page"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_PrevPage_B = new wxButton(this, ID_PREVPAGE_B, wxT("Prev Page"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_Memcard1NextPage = new wxButton(this, ID_MEMCARD1NEXTPAGE, wxT("Next Page"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_Memcard2NextPage = new wxButton(this, ID_MEMCARD2NEXTPAGE, wxT("Next Page"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
// Sizers that double as wxStaticBoxes
sMemcard1 = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Memory Card 1"));
sMemcard2 = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Memory Card 2"));
// Create the controls for both memcards
// Loading invalid .raw files should no longer crash the app
m_Memcard1Path = new wxFilePickerCtrl(this, ID_MEMCARD1PATH, wxEmptyString, wxT("Choose a memory card:"),
wxT("Raw memcards (*.raw)|*.raw"), wxDefaultPosition, wxDefaultSize, wxFLP_USE_TEXTCTRL|wxFLP_FILE_MUST_EXIST|wxFLP_OPEN);
m_Memcard2Path = new wxFilePickerCtrl(this, ID_MEMCARD2PATH, wxEmptyString, wxT("Choose a memory card:"),
wxT("Raw memcards (*.raw)|*.raw"), wxDefaultPosition, wxDefaultSize, wxFLP_USE_TEXTCTRL|wxFLP_FILE_MUST_EXIST|wxFLP_OPEN);
m_MemcardList[0] = new wxListCtrl(this, ID_MEMCARD1LIST, wxDefaultPosition, wxSize(350,400),
wxLC_REPORT | wxSUNKEN_BORDER | wxLC_ALIGN_LEFT | wxLC_SINGLE_SEL);
m_MemcardList[1] = new wxListCtrl(this, ID_MEMCARD2LIST, wxDefaultPosition, wxSize(350,400),
wxLC_REPORT | wxSUNKEN_BORDER | wxLC_ALIGN_LEFT | wxLC_SINGLE_SEL);
m_NextPage_A = new wxButton(this, ID_NEXTPAGE_A, wxT("Next Page"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_NextPage_B = new wxButton(this, ID_NEXTPAGE_B, wxT("Next Page"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_MemcardList[0]->AssignImageList(new wxImageList(96,32),wxIMAGE_LIST_SMALL);
m_MemcardList[1]->AssignImageList(new wxImageList(96,32),wxIMAGE_LIST_SMALL);
// Sizers that double as wxStaticBoxes
sMemcard_A = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Memory Card A"));
sMemcard_B = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Memory Card B"));
// mmmm sizer goodness
wxBoxSizer* sButtons;
sButtons = new wxBoxSizer(wxVERTICAL);
sButtons->AddStretchSpacer(2);
sButtons->Add(m_CopyToLeft, 0, wxEXPAND, 5);
sButtons->Add(m_CopyToRight, 0, wxEXPAND, 5);
sButtons->Add(m_CopyTo_A, 0, wxEXPAND, 5);
sButtons->Add(m_CopyTo_B, 0, wxEXPAND, 5);
sButtons->AddStretchSpacer(1);
sButtons->Add(m_FixChecksumLeft, 0, wxEXPAND, 5);
sButtons->Add(m_FixChecksumRight, 0, wxEXPAND, 5);
sButtons->Add(m_FixChecksum_A, 0, wxEXPAND, 5);
sButtons->Add(m_FixChecksum_B, 0, wxEXPAND, 5);
sButtons->AddStretchSpacer(1);
sButtons->Add(m_SaveImportLeft, 0, wxEXPAND, 5);
sButtons->Add(m_SaveExportLeft, 0, wxEXPAND, 5);
sButtons->Add(m_SaveImport_A, 0, wxEXPAND, 5);
sButtons->Add(m_SaveExport_A, 0, wxEXPAND, 5);
sButtons->AddStretchSpacer(1);
sButtons->Add(m_ConvertToGci, 0, wxEXPAND, 5);
sButtons->AddStretchSpacer(1);
sButtons->Add(m_SaveImportRight, 0, wxEXPAND, 5);
sButtons->Add(m_SaveExportRight, 0, wxEXPAND, 5);
sButtons->Add(m_SaveImport_B, 0, wxEXPAND, 5);
sButtons->Add(m_SaveExport_B, 0, wxEXPAND, 5);
sButtons->AddStretchSpacer(1);
sButtons->Add(m_DeleteLeft, 0, wxEXPAND, 5);
sButtons->Add(m_DeleteRight, 0, wxEXPAND, 5);
sButtons->Add(m_Delete_A, 0, wxEXPAND, 5);
sButtons->Add(m_Delete_B, 0, wxEXPAND, 5);
sButtons->AddStretchSpacer(1);
sPagesLeft = new wxBoxSizer(wxHORIZONTAL);
sPagesRight = new wxBoxSizer(wxHORIZONTAL);
sPages_A = new wxBoxSizer(wxHORIZONTAL);
sPages_B = new wxBoxSizer(wxHORIZONTAL);
sPages_A->Add(m_PrevPage_A, 0, wxEXPAND|wxALL, 1);
sPages_A->Add(t_Status_A,0, wxEXPAND|wxALL, 5);
sPages_A->Add(0, 0, 1, wxEXPAND|wxALL, 0);
sPages_A->Add(m_NextPage_A, 0, wxEXPAND|wxALL, 1);
sPages_B->Add(m_PrevPage_B, 0, wxEXPAND|wxALL, 1);
sPages_B->Add(t_Status_B, 0, wxEXPAND|wxALL, 5);
sPages_B->Add(0, 0, 1, wxEXPAND|wxALL, 0);
sPages_B->Add(m_NextPage_B, 0, wxEXPAND|wxALL, 1);
sPagesLeft->Add(m_Memcard1PrevPage, 0, wxEXPAND|wxALL, 1);
sPagesLeft->Add(t_StatusLeft,0, wxEXPAND|wxALL, 5);
sPagesLeft->Add(0, 0, 1, wxEXPAND|wxALL, 0);
sPagesLeft->Add(m_Memcard1NextPage, 0, wxEXPAND|wxALL, 1);
sPagesRight->Add(m_Memcard2PrevPage, 0, wxEXPAND|wxALL, 1);
sPagesRight->Add(t_StatusRight, 0, wxEXPAND|wxALL, 5);
sPagesRight->Add(0, 0, 1, wxEXPAND|wxALL, 0);
sPagesRight->Add(m_Memcard2NextPage, 0, wxEXPAND|wxALL, 1);
sMemcard1->Add(m_Memcard1Path, 0, wxEXPAND|wxALL, 5);
sMemcard1->Add(m_MemcardList[0], 1, wxEXPAND|wxALL, 5);
sMemcard1->Add(sPagesLeft, 0, wxEXPAND|wxALL, 1);
sMemcard2->Add(m_Memcard2Path, 0, wxEXPAND|wxALL, 5);
sMemcard2->Add(m_MemcardList[1], 1, wxEXPAND|wxALL, 5);
sMemcard2->Add(sPagesRight, 0, wxEXPAND|wxALL, 1);
sMemcard_A->Add(m_MemcardPath_A, 0, wxEXPAND|wxALL, 5);
sMemcard_A->Add(m_MemcardList[SLOT_A], 1, wxEXPAND|wxALL, 5);
sMemcard_A->Add(sPages_A, 0, wxEXPAND|wxALL, 1);
sMemcard_B->Add(m_MemcardPath_B, 0, wxEXPAND|wxALL, 5);
sMemcard_B->Add(m_MemcardList[SLOT_B], 1, wxEXPAND|wxALL, 5);
sMemcard_B->Add(sPages_B, 0, wxEXPAND|wxALL, 1);
sMain = new wxBoxSizer(wxHORIZONTAL);
sMain->Add(sMemcard1, 1, wxEXPAND|wxALL, 5);
sMain->Add(sMemcard_A, 1, wxEXPAND|wxALL, 5);
sMain->Add(sButtons, 0, wxEXPAND, 0);
sMain->Add(sMemcard2, 1, wxEXPAND|wxALL, 5);
sMain->Add(sMemcard_B, 1, wxEXPAND|wxALL, 5);
this->SetSizer(sMain);
sMain->SetSizeHints(this);
Fit();
m_Memcard1PrevPage->Disable();
m_Memcard1NextPage->Disable();
m_Memcard2PrevPage->Disable();
m_Memcard2NextPage->Disable();
m_CopyToLeft->Disable();
m_CopyToRight->Disable();
m_FixChecksumLeft->Disable();
m_FixChecksumRight->Disable();
m_SaveImportLeft->Disable();
m_SaveExportLeft->Disable();
m_SaveImportRight->Disable();
m_SaveExportRight->Disable();
m_DeleteLeft->Disable();
m_DeleteRight->Disable();
m_PrevPage_A->Disable();
m_NextPage_A->Disable();
m_PrevPage_B->Disable();
m_NextPage_B->Disable();
m_CopyTo_A->Disable();
m_CopyTo_B->Disable();
m_FixChecksum_A->Disable();
m_FixChecksum_B->Disable();
m_SaveImport_A->Disable();
m_SaveExport_A->Disable();
m_SaveImport_B->Disable();
m_SaveExport_B->Disable();
m_Delete_A->Disable();
m_Delete_B->Disable();
}
void CMemcardManager::OnClose(wxCloseEvent& WXUNUSED (event))
@ -235,69 +311,84 @@ void CMemcardManager::OnPathChange(wxFileDirPickerEvent& event)
{
switch (event.GetId())
{
case ID_MEMCARD1PATH:
page0 = 0;
if (m_Memcard1PrevPage->IsEnabled()) m_Memcard1PrevPage->Disable();
if (!strcasecmp(m_Memcard1Path->GetPath().mb_str(),m_Memcard2Path->GetPath().mb_str()))
case ID_MEMCARDPATH_A:
pageA = FIRSTPAGE;
if (m_MemcardList[SLOT_A]->usePages && m_PrevPage_A->IsEnabled())
{
m_PrevPage_A->Disable();
m_MemcardList[SLOT_A]->prevPage = false;
}
if (!strcasecmp(m_MemcardPath_A->GetPath().mb_str(), m_MemcardPath_B->GetPath().mb_str()))
{
wxMessageBox(wxT("Memcard already opened"), wxT("Error"), wxOK|wxICON_ERROR);
m_Memcard1Path->SetPath(wxEmptyString);
m_MemcardList[0]->ClearAll();
t_StatusLeft->SetLabel(wxEmptyString);
}
else if (ReloadMemcard(event.GetPath().mb_str(), 0, page0))
else if (ReloadMemcard(event.GetPath().mb_str(), SLOT_A, pageA))
{
m_FixChecksumLeft->Enable();
m_SaveImportLeft->Enable();
m_SaveExportLeft->Enable();
m_DeleteLeft->Enable();
m_MemcardList[SLOT_B]->twoCardsLoaded = true;
m_FixChecksum_A->Enable();
m_SaveImport_A->Enable();
m_SaveExport_A->Enable();
m_Delete_A->Enable();
break;
}
m_Memcard1Path->SetPath(wxEmptyString);
m_MemcardList[0]->ClearAll();
t_StatusLeft->SetLabel(wxEmptyString);
m_FixChecksumLeft->Disable();
m_SaveImportLeft->Disable();
m_SaveExportLeft->Disable();
m_DeleteLeft->Disable();
m_Memcard1PrevPage->Disable();
m_Memcard1NextPage->Disable();
m_MemcardList[SLOT_B]->twoCardsLoaded = false;
m_MemcardPath_A->SetPath(wxEmptyString);
m_MemcardList[SLOT_A]->ClearAll();
t_Status_A->SetLabel(wxEmptyString);
m_FixChecksum_A->Disable();
m_SaveImport_A->Disable();
m_SaveExport_A->Disable();
m_Delete_A->Disable();
if (m_MemcardList[SLOT_A]->usePages)
{
m_PrevPage_A->Disable();
m_NextPage_A->Disable();
}
break;
case ID_MEMCARD2PATH:
page1 = 0;
if (m_Memcard2PrevPage->IsEnabled()) m_Memcard2PrevPage->Disable();
if (!strcasecmp(m_Memcard1Path->GetPath().mb_str(),m_Memcard2Path->GetPath().mb_str()))
case ID_MEMCARDPATH_B:
pageB = FIRSTPAGE;
if (m_MemcardList[SLOT_B]->usePages && m_PrevPage_B->IsEnabled())
{
m_PrevPage_B->Disable();
m_MemcardList[SLOT_B]->prevPage = false;
}
if (!strcasecmp(m_MemcardPath_A->GetPath().mb_str(), m_MemcardPath_B->GetPath().mb_str()))
{
wxMessageBox(wxT("Memcard already opened"), wxT("Error"), wxOK|wxICON_ERROR);
}
else if (ReloadMemcard(event.GetPath().mb_str(), 1, page1))
else if (ReloadMemcard(event.GetPath().mb_str(), SLOT_B, pageB))
{
m_FixChecksumRight->Enable();
m_SaveImportRight->Enable();
m_SaveExportRight->Enable();
m_DeleteRight->Enable();
m_MemcardList[SLOT_A]->twoCardsLoaded = true;
m_FixChecksum_B->Enable();
m_SaveImport_B->Enable();
m_SaveExport_B->Enable();
m_Delete_B->Enable();
break;
}
m_Memcard2Path->SetPath(wxEmptyString);
m_MemcardList[1]->ClearAll();
t_StatusRight->SetLabel(wxEmptyString);
m_FixChecksumRight->Disable();
m_SaveImportRight->Disable();
m_SaveExportRight->Disable();
m_DeleteRight->Disable();
m_Memcard2PrevPage->Disable();
m_Memcard2NextPage->Disable();
m_MemcardList[SLOT_A]->twoCardsLoaded = false;
m_MemcardPath_B->SetPath(wxEmptyString);
m_MemcardList[SLOT_B]->ClearAll();
t_Status_B->SetLabel(wxEmptyString);
m_FixChecksum_B->Disable();
m_SaveImport_B->Disable();
m_SaveExport_B->Disable();
m_Delete_B->Disable();
if (m_MemcardList[SLOT_B]->usePages)
{
m_PrevPage_B->Disable();
m_NextPage_B->Disable();
}
break;
}
if (m_DeleteRight->IsEnabled() && m_DeleteLeft->IsEnabled())
if (m_Delete_B->IsEnabled() && m_Delete_A->IsEnabled())
{
m_CopyToLeft->Enable();
m_CopyToRight->Enable();
m_CopyTo_A->Enable();
m_CopyTo_B->Enable();
}
else
{
m_CopyToLeft->Disable();
m_CopyToRight->Disable();
m_CopyTo_A->Disable();
m_CopyTo_B->Disable();
}
}
@ -305,53 +396,109 @@ void CMemcardManager::OnPageChange(wxCommandEvent& event)
{
switch (event.GetId())
{
case ID_MEMCARD1NEXTPAGE:
if (!m_Memcard1PrevPage->IsEnabled()) m_Memcard1PrevPage->Enable();
if (!m_Memcard1NextPage->IsEnabled()) m_Memcard1NextPage->Enable();
page0++;
if (page0 == MAXPAGES) m_Memcard1NextPage->Disable();
ReloadMemcard(m_Memcard1Path->GetPath().mb_str(), 0, page0);
case ID_NEXTPAGE_A:
if (!m_PrevPage_A->IsEnabled())
{
m_PrevPage_A->Enable();
m_MemcardList[SLOT_A]->prevPage = true;
}
pageA++;
if (pageA == maxPages)
{
m_NextPage_A->Disable();
m_MemcardList[SLOT_A]->nextPage = false;
}
ReloadMemcard(m_MemcardPath_A->GetPath().mb_str(), SLOT_A, pageA);
break;
case ID_MEMCARD2NEXTPAGE:
if (!m_Memcard2PrevPage->IsEnabled()) m_Memcard2PrevPage->Enable();
if (!m_Memcard2NextPage->IsEnabled()) m_Memcard2NextPage->Enable();
page1++;
if (page1 == MAXPAGES) m_Memcard2NextPage->Disable();
ReloadMemcard(m_Memcard2Path->GetPath().mb_str(), 1, page1);
case ID_NEXTPAGE_B:
if (!m_PrevPage_B->IsEnabled())
{
m_PrevPage_B->Enable();
m_MemcardList[SLOT_B]->prevPage = true;
}
pageB++;
if (pageB == maxPages)
{
m_NextPage_B->Disable();
m_MemcardList[SLOT_B]->nextPage = false;
}
ReloadMemcard(m_MemcardPath_B->GetPath().mb_str(), SLOT_B, pageB);
break;
case ID_MEMCARD1PREVPAGE:
if (!m_Memcard1NextPage->IsEnabled()) m_Memcard1NextPage->Enable();
page0--;
if (!page0) m_Memcard1PrevPage->Disable();
ReloadMemcard(m_Memcard1Path->GetPath().mb_str(), 0, page0);
case ID_PREVPAGE_A:
if (!m_NextPage_A->IsEnabled())
{
m_NextPage_A->Enable();
m_MemcardList[SLOT_A]->nextPage = true;
}
pageA--;
if (!pageA)
{
m_PrevPage_A->Disable();
m_MemcardList[SLOT_A]->prevPage = false;
}
ReloadMemcard(m_MemcardPath_A->GetPath().mb_str(), SLOT_A, pageA);
break;
case ID_MEMCARD2PREVPAGE:
if (!m_Memcard2NextPage->IsEnabled()) m_Memcard2NextPage->Enable();
page1--;
if (!page1) m_Memcard2PrevPage->Disable();
ReloadMemcard(m_Memcard2Path->GetPath().mb_str(), 1, page1);
case ID_PREVPAGE_B:
if (!m_NextPage_B->IsEnabled())
{
m_NextPage_B->Enable();
m_MemcardList[SLOT_B]->nextPage = true;
}
pageB--;
if (!pageB)
{
m_PrevPage_B->Disable();
m_MemcardList[SLOT_B]->prevPage = false;
}
ReloadMemcard(m_MemcardPath_B->GetPath().mb_str(), SLOT_B, pageB);
break;
}
}
void CMemcardManager::OnMenuChange(wxCommandEvent& event)
{
if (event.GetId() == ID_USEPAGES)
{
m_MemcardList[SLOT_A]->usePages = !m_MemcardList[SLOT_A]->usePages;
m_MemcardList[SLOT_B]->usePages = !m_MemcardList[SLOT_B]->usePages;
if (!m_MemcardList[SLOT_A]->usePages)
{
m_PrevPage_A->Disable();
m_PrevPage_B->Disable();
m_NextPage_A->Disable();
m_NextPage_B->Disable();
pageA = pageB = FIRSTPAGE;
}
}
else
{
m_MemcardList[SLOT_A]->column[event.GetId()] = !m_MemcardList[SLOT_A]->column[event.GetId()];
m_MemcardList[SLOT_B]->column[event.GetId()] = !m_MemcardList[SLOT_B]->column[event.GetId()];
}
if (memoryCard[SLOT_A]) ReloadMemcard(m_MemcardPath_A->GetPath().mb_str(), SLOT_A, pageA);
if (memoryCard[SLOT_B]) ReloadMemcard(m_MemcardPath_B->GetPath().mb_str(), SLOT_B, pageB);
}
void CMemcardManager::CopyDeleteClick(wxCommandEvent& event)
{
int index0 = m_MemcardList[0]->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
int index1 = m_MemcardList[1]->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
int slot = 1;
int index2 = index1;
int index_A = m_MemcardList[SLOT_A]->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
int index_B = m_MemcardList[SLOT_B]->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
int slot = SLOT_B;
int index = index_B;
std::string fileName2("");
wxString blocksOpen;
if (index0 != -1 && page0) index0 += ITEMSPERPAGE * page0;
if (index1 != -1 && page1) index1 += ITEMSPERPAGE * page1;
if (index_A != wxNOT_FOUND && pageA) index_A += itemsPerPage * pageA;
if (index_B != wxNOT_FOUND && pageB) index_B += itemsPerPage * pageB;
switch (event.GetId())
{
case ID_COPYTOLEFT:
if ((index1 != -1) && (memoryCard[0] != NULL))
case ID_COPYTO_A:
if ((index_B != wxNOT_FOUND) && (memoryCard[0] != NULL))
{
switch (memoryCard[0]->CopyFrom(*memoryCard[1], index1))
switch (memoryCard[SLOT_A]->CopyFrom(*memoryCard[SLOT_B], index_B))
{
case FAIL:
wxMessageBox(wxT("Invalid bat.map or dir entry"), wxT("Failure"), wxOK);
@ -360,8 +507,8 @@ void CMemcardManager::CopyDeleteClick(wxCommandEvent& event)
wxMessageBox(wxT("File is not recognized as a memcard"), wxT("Failure"), wxOK);
break;
case SUCCESS:
memoryCard[0]->Save();
ReloadMemcard(m_Memcard1Path->GetPath().mb_str(), 0, 0);
memoryCard[SLOT_A]->Save();
ReloadMemcard(m_MemcardPath_A->GetPath().mb_str(), SLOT_A, FIRSTPAGE);
break;
}
@ -371,10 +518,10 @@ void CMemcardManager::CopyDeleteClick(wxCommandEvent& event)
wxMessageBox(wxT("You have not selected a save to copy"), wxT("Error"), wxOK|wxICON_ERROR);
}
break;
case ID_COPYTORIGHT:
if ((index0 != -1) && (memoryCard[1] != NULL))
case ID_COPYTO_B:
if ((index_A != wxNOT_FOUND) && (memoryCard[SLOT_B] != NULL))
{
switch (memoryCard[1]->CopyFrom(*memoryCard[0], index0))
switch (memoryCard[SLOT_B]->CopyFrom(*memoryCard[SLOT_A], index_A))
{
case FAIL:
wxMessageBox(wxT("Invalid bat.map or dir entry"),
@ -385,8 +532,8 @@ void CMemcardManager::CopyDeleteClick(wxCommandEvent& event)
wxT("Error"), wxOK|wxICON_ERROR);
break;
case SUCCESS:
memoryCard[1]->Save();
ReloadMemcard(m_Memcard2Path->GetPath().mb_str(), 1, 0);
memoryCard[SLOT_B]->Save();
ReloadMemcard(m_MemcardPath_B->GetPath().mb_str(), SLOT_B, FIRSTPAGE);
break;
}
}
@ -395,9 +542,9 @@ void CMemcardManager::CopyDeleteClick(wxCommandEvent& event)
wxMessageBox(wxT("You have not selected a save to copy"), wxT("Error"), wxOK|wxICON_ERROR);
}
break;
case ID_FIXCHECKSUMLEFT:
slot = 0;
case ID_FIXCHECKSUMRIGHT:
case ID_FIXCHECKSUM_A:
slot = SLOT_A;
case ID_FIXCHECKSUM_B:
if (memoryCard[slot] != NULL)
{
// Fix checksums and save the changes
@ -413,9 +560,9 @@ void CMemcardManager::CopyDeleteClick(wxCommandEvent& event)
case ID_CONVERTTOGCI:
fileName2 = "convert";
case ID_SAVEIMPORTLEFT:
slot = 0;
case ID_SAVEIMPORTRIGHT:
case ID_SAVEIMPORT_A:
slot = SLOT_A;
case ID_SAVEIMPORT_B:
if (memoryCard[slot] != NULL || !fileName2.empty())
{
wxString temp = wxFileSelector(_T("Select a save file to import"),
@ -492,8 +639,8 @@ void CMemcardManager::CopyDeleteClick(wxCommandEvent& event)
break;
default:
memoryCard[slot]->Save();
slot == 1 ? ReloadMemcard(m_Memcard2Path->GetPath().mb_str(), 1, 0)
: ReloadMemcard(m_Memcard1Path->GetPath().mb_str(), 0, 0);
slot == SLOT_B ? ReloadMemcard(m_MemcardPath_B->GetPath().mb_str(), SLOT_B, FIRSTPAGE)
: ReloadMemcard(m_MemcardPath_A->GetPath().mb_str(), SLOT_A, FIRSTPAGE);
break;
}
}
@ -503,11 +650,11 @@ void CMemcardManager::CopyDeleteClick(wxCommandEvent& event)
wxMessageBox(wxT("Memory card is not loaded"), wxT("Error"), wxOK|wxICON_ERROR);
}
break;
case ID_SAVEEXPORTLEFT:
slot=0;
index2 = index0;
case ID_SAVEEXPORTRIGHT:
if (index2 != -1)
case ID_SAVEEXPORT_A:
slot=SLOT_A;
index = index_A;
case ID_SAVEEXPORT_B:
if (index != wxNOT_FOUND)
{
wxString temp = wxFileSelector(_T("Save GCI as.."),
wxEmptyString, wxEmptyString, _T(".gci"), wxString::Format
@ -521,7 +668,7 @@ void CMemcardManager::CopyDeleteClick(wxCommandEvent& event)
if (temp.length() > 0)
{
switch (memoryCard[slot]->ExportGci(index2, fileName))
switch (memoryCard[slot]->ExportGci(index, fileName))
{
case NOMEMCARD:
wxMessageBox(wxT("File is not recognized as a memcard"),
@ -546,13 +693,13 @@ void CMemcardManager::CopyDeleteClick(wxCommandEvent& event)
wxMessageBox(wxT("You have not selected a save to export"), wxT("Error"), wxOK|wxICON_ERROR);
}
break;
case ID_DELETELEFT:
slot=0;
index2 = index0;
case ID_DELETERIGHT:
if (index2 != -1)
case ID_DELETE_A:
slot=SLOT_A;
index = index_A;
case ID_DELETE_B:
if (index != wxNOT_FOUND)
{
switch (memoryCard[slot]->RemoveFile(index2))
switch (memoryCard[slot]->RemoveFile(index))
{
case NOMEMCARD:
wxMessageBox(wxT("File is not recognized as a memcard"),
@ -564,8 +711,8 @@ void CMemcardManager::CopyDeleteClick(wxCommandEvent& event)
break;
case SUCCESS:
memoryCard[slot]->Save();
slot == 1 ? ReloadMemcard(m_Memcard2Path->GetPath().mb_str(), 1, 0)
: ReloadMemcard(m_Memcard1Path->GetPath().mb_str(), 0, 0);
slot == SLOT_B ? ReloadMemcard(m_MemcardPath_B->GetPath().mb_str(), SLOT_B, FIRSTPAGE)
: ReloadMemcard(m_MemcardPath_A->GetPath().mb_str(), SLOT_A, FIRSTPAGE);
break;
}
}
@ -593,6 +740,7 @@ bool CMemcardManager::ReloadMemcard(const char *fileName, int card, int page)
m_MemcardList[card]->Hide();
m_MemcardList[card]->ClearAll();
m_MemcardList[card]->InsertColumn(COLUMN_BANNER, _T("Banner"));
m_MemcardList[card]->InsertColumn(COLUMN_TITLE, _T("Title"));
m_MemcardList[card]->InsertColumn(COLUMN_COMMENT, _T("Comment"));
@ -604,8 +752,8 @@ bool CMemcardManager::ReloadMemcard(const char *fileName, int card, int page)
list->RemoveAll();
int nFiles = memoryCard[card]->GetNumFiles();
int *images = new int[nFiles*2];
for (int i = 0;i < nFiles;i++)
{
static u32 pxdata[96*32];
@ -626,7 +774,7 @@ bool CMemcardManager::ReloadMemcard(const char *fileName, int card, int page)
{
for (int x=0;x<32;x++)
{
pxdata[y*96+x+32] = icdata[y*32+x] /* | 0xFF000000 */;
pxdata[y*96+x+32] = icdata[y*32+x];// | 0xFF000000
}
}
}
@ -654,26 +802,29 @@ bool CMemcardManager::ReloadMemcard(const char *fileName, int card, int page)
images[i*2+1] = list->Add(icon);
}
}
for (j = page * 16;(j < nFiles) && (j < (page + 1)* 16);j++)
int pagesMax = 128;
if (m_MemcardList[card]->usePages) pagesMax = (page + 1) * itemsPerPage;
for (j = page * itemsPerPage;(j < nFiles) && (j < pagesMax);j++)
{
char title[32];
char comment[32];
u16 blocks;
u16 firstblock;
if (!memoryCard[card]->GetComment1(j, title)) title[0]=0;
if (!memoryCard[card]->GetComment2(j, comment)) comment[0]=0;
int index = m_MemcardList[card]->InsertItem(j, wxT("row"));
int index = m_MemcardList[card]->InsertItem(j, wxEmptyString);
m_MemcardList[card]->SetItem(index, COLUMN_BANNER, wxEmptyString);
if (!memoryCard[card]->GetComment1(j, title)) title[0]=0;
m_MemcardList[card]->SetItem(index, COLUMN_TITLE, wxString::FromAscii(title));
if (!memoryCard[card]->GetComment2(j, comment)) comment[0]=0;
m_MemcardList[card]->SetItem(index, COLUMN_COMMENT, wxString::FromAscii(comment));
blocks = memoryCard[card]->GetFileSize(j);
if (blocks == 0xFFFF) blocks = 0;
wxBlock.Printf(wxT("%10d"), blocks);
m_MemcardList[card]->SetItem(index,COLUMN_BLOCKS, wxBlock);
firstblock = memoryCard[card]->GetFirstBlock(j);
if (firstblock == 0xFFFF) firstblock = 3; // to make firstblock -1
wxFirstBlock.Printf(wxT("%10d"), firstblock-4);
m_MemcardList[card]->SetItem(index,COLUMN_BLOCKS, wxBlock);
wxFirstBlock.Printf(wxT("%15d"), firstblock-4);
m_MemcardList[card]->SetItem(index,COLUMN_FIRSTBLOCK, wxFirstBlock);
m_MemcardList[card]->SetItem(index, COLUMN_ICON, wxEmptyString);
@ -684,25 +835,50 @@ bool CMemcardManager::ReloadMemcard(const char *fileName, int card, int page)
}
}
if (j == nFiles)
if (m_MemcardList[card]->usePages)
{
card ? m_Memcard2NextPage->Disable() : m_Memcard1NextPage->Disable();
}
else
{
card ? m_Memcard2NextPage->Enable() : m_Memcard1NextPage->Enable();
if ((j == nFiles))
{
if (card)
{
m_NextPage_B->Disable();
m_MemcardList[SLOT_B]->nextPage = false;
}
else
{
m_NextPage_A->Disable();
m_MemcardList[SLOT_A]->nextPage = false;
}
}
else
{
if (card)
{
m_NextPage_B->Enable();
m_MemcardList[SLOT_B]->nextPage = true;
}
else
{
m_NextPage_A->Enable();
m_MemcardList[SLOT_A]->nextPage = true;
}
}
}
delete[] images;
// Automatic column width and then show the list
for (int i = 0; i < m_MemcardList[card]->GetColumnCount(); i++)
for (int i = 0; i < NUMBER_OF_COLUMN; i++)
{
m_MemcardList[card]->SetColumnWidth(i, wxLIST_AUTOSIZE);
if (m_MemcardList[card]->column[i])
m_MemcardList[card]->SetColumnWidth(i, wxLIST_AUTOSIZE);
else
m_MemcardList[card]->SetColumnWidth(i, 0);
}
m_MemcardList[card]->Show();
wxLabel.Printf(wxT("%d Free Blocks; %d Free Dir Entries"),
memoryCard[card]->GetFreeBlocks(), 127 - nFiles);
card ? t_StatusRight->SetLabel(wxLabel) : t_StatusLeft->SetLabel(wxLabel);
card ? t_Status_B->SetLabel(wxLabel) : t_Status_A->SetLabel(wxLabel);
return true;
}
@ -740,3 +916,77 @@ bool CMemcardManager::ReadError(GCMemcard *memcard)
wxT("Error"), wxOK|wxICON_ERROR);
return true;
}
void CMemcardManager::CMemcardListCtrl::OnRightClick(wxMouseEvent& event)
{
int flags;
long item = HitTest(event.GetPosition(), flags);
if (item != wxNOT_FOUND)
{
if (GetItemState(item, wxLIST_STATE_SELECTED) != wxLIST_STATE_SELECTED)
{
SetItemState(item, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
}
SetItemState(item, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED);
wxMenu popupMenu;
if (event.GetId() == ID_MEMCARDLIST_A)
{
popupMenu.Append(ID_COPYTO_B, wxT("Copy to Memcard B"));
popupMenu.Append(ID_DELETE_A, wxT("Delete Save"));
popupMenu.Append(ID_SAVEIMPORT_A, wxT("Import Save"));
popupMenu.Append(ID_SAVEEXPORT_A, wxT("Export Save"));
if (!twoCardsLoaded)
popupMenu.FindItem(ID_COPYTO_B)->Enable(false);
popupMenu.AppendSeparator();
popupMenu.Append(ID_FIXCHECKSUM_A, wxT("Fix Checksum"));
popupMenu.Append(ID_PREVPAGE_A, wxT("Previous Page"));
popupMenu.Append(ID_NEXTPAGE_A, wxT("Next Page"));
if (!prevPage || !usePages)
popupMenu.FindItem(ID_PREVPAGE_A)->Enable(false);
if (!nextPage || !usePages)
popupMenu.FindItem(ID_NEXTPAGE_A)->Enable(false);
}
else if (event.GetId() == ID_MEMCARDLIST_B)
{
popupMenu.Append(ID_COPYTO_A, wxT("Copy to Memcard A"));
popupMenu.Append(ID_DELETE_B, wxT("Delete Save"));
popupMenu.Append(ID_SAVEIMPORT_B, wxT("Import Save"));
popupMenu.Append(ID_SAVEEXPORT_B, wxT("Export Save"));
if (!twoCardsLoaded)
popupMenu.FindItem(ID_COPYTO_A)->Enable(false);
popupMenu.AppendSeparator();
popupMenu.Append(ID_FIXCHECKSUM_B, wxT("Fix Checksum"));
popupMenu.Append(ID_PREVPAGE_B, wxT("Previous Page"));
popupMenu.Append(ID_NEXTPAGE_B, wxT("Next Page"));
if (!prevPage || !usePages)
popupMenu.FindItem(ID_PREVPAGE_B)->Enable(false);
if (!nextPage || !usePages)
popupMenu.FindItem(ID_NEXTPAGE_B)->Enable(false);
}
popupMenu.AppendCheckItem(COLUMN_BANNER, wxT("Show save banner"));
if(column[COLUMN_BANNER]) popupMenu.FindItem(COLUMN_BANNER)->Check();
popupMenu.AppendCheckItem(COLUMN_TITLE, wxT("Show save title"));
if(column[COLUMN_TITLE]) popupMenu.FindItem(COLUMN_TITLE)->Check();
popupMenu.AppendCheckItem(COLUMN_COMMENT, wxT("Show save comment"));
if(column[COLUMN_COMMENT]) popupMenu.FindItem(COLUMN_COMMENT)->Check();
popupMenu.AppendCheckItem(COLUMN_ICON, wxT("Show save icon"));
if(column[COLUMN_ICON]) popupMenu.FindItem(COLUMN_ICON)->Check();
popupMenu.AppendCheckItem(COLUMN_BLOCKS, wxT("Show save blocks"));
if(column[COLUMN_BLOCKS]) popupMenu.FindItem(COLUMN_BLOCKS)->Check();
popupMenu.AppendCheckItem(COLUMN_FIRSTBLOCK, wxT("Show save first block"));
if(column[COLUMN_FIRSTBLOCK]) popupMenu.FindItem(COLUMN_FIRSTBLOCK)->Check();
popupMenu.AppendCheckItem(ID_USEPAGES, wxT("Enable pages"));
if(usePages) popupMenu.FindItem(ID_USEPAGES)->Check();
PopupMenu(&popupMenu);
}
}

View File

@ -25,75 +25,81 @@
#include <wx/listctrl.h>
#include <wx/imaglist.h>
#include "IniFile.h"
#include "MemoryCards/GCMemcard.h"
#undef MEMCARD_MANAGER_STYLE
#define MEMCARD_MANAGER_STYLE wxCAPTION | wxSYSTEM_MENU | wxDIALOG_NO_PARENT | wxCLOSE_BOX | wxRESIZE_BORDER | wxMAXIMIZE_BOX
#define ITEMSPERPAGE 16
#define MAXPAGES (128 / ITEMSPERPAGE) - 1
#define MEMCARDMAN_TITLE "Memory Card Manager WARNING-Make backups before using, should be fixed but could mangle stuff!"
#define FIRSTPAGE 0
#define SLOT_A 0
#define SLOT_B 1
class CMemcardManager
: public wxDialog
{
public:
CMemcardManager(wxWindow *parent, wxWindowID id = 1, const wxString& title = wxT("Memory Card Manager WARNING-Make backups before using, should be fixed but could mangle stuff!"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = MEMCARD_MANAGER_STYLE);
CMemcardManager(wxWindow *parent, wxWindowID id = 1, const wxString& title = wxT(MEMCARDMAN_TITLE),
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = MEMCARD_MANAGER_STYLE);
virtual ~CMemcardManager();
private:
DECLARE_EVENT_TABLE();
int page0,
page1;
int pageA,
pageB,
itemsPerPage,
maxPages;
wxBoxSizer *sMain;
wxBoxSizer *sPagesLeft;
wxBoxSizer *sPagesRight;
wxStaticText *t_StatusLeft;
wxStaticText *t_StatusRight;
wxButton *m_CopyToLeft;
wxButton *m_CopyToRight;
wxButton *m_FixChecksumLeft;
wxButton *m_FixChecksumRight;
wxButton *m_SaveImportLeft;
wxButton *m_SaveExportLeft;
wxButton *m_SaveImportRight;
wxButton *m_SaveExportRight;
wxBoxSizer *sPages_A;
wxBoxSizer *sPages_B;
wxStaticText *t_Status_A;
wxStaticText *t_Status_B;
wxButton *m_CopyTo_A;
wxButton *m_CopyTo_B;
wxButton *m_FixChecksum_A;
wxButton *m_FixChecksum_B;
wxButton *m_SaveImport_A;
wxButton *m_SaveImport_B;
wxButton *m_SaveExport_A;
wxButton *m_SaveExport_B;
wxButton *m_ConvertToGci;
wxButton *m_DeleteLeft;
wxButton *m_DeleteRight;
wxButton *m_Memcard1PrevPage;
wxButton *m_Memcard1NextPage;
wxButton *m_Memcard2PrevPage;
wxButton *m_Memcard2NextPage;
wxStaticBoxSizer *sMemcard1;
wxStaticBoxSizer *sMemcard2;
wxFilePickerCtrl *m_Memcard1Path;
wxFilePickerCtrl *m_Memcard2Path;
wxListCtrl *m_MemcardList[2];
wxButton *m_Delete_A;
wxButton *m_Delete_B;
wxButton *m_PrevPage_A;
wxButton *m_NextPage_A;
wxButton *m_PrevPage_B;
wxButton *m_NextPage_B;
wxStaticBoxSizer *sMemcard_A;
wxStaticBoxSizer *sMemcard_B;
wxFilePickerCtrl *m_MemcardPath_A;
wxFilePickerCtrl *m_MemcardPath_B;
IniFile MemcardManagerIni;
enum
{
ID_COPYTORIGHT = 1000,
ID_COPYTOLEFT,
ID_FIXCHECKSUMRIGHT,
ID_FIXCHECKSUMLEFT,
ID_DELETERIGHT,
ID_DELETELEFT,
ID_MEMCARD1PATH,
ID_MEMCARD2PATH,
ID_MEMCARD1NEXTPAGE,
ID_MEMCARD1PREVPAGE,
ID_MEMCARD2NEXTPAGE,
ID_MEMCARD2PREVPAGE,
ID_SAVEEXPORTRIGHT,
ID_SAVEEXPORTLEFT,
ID_SAVEIMPORTRIGHT,
ID_SAVEIMPORTLEFT,
ID_COPYTO_B = 1000,
ID_COPYTO_A,
ID_FIXCHECKSUM_A,
ID_FIXCHECKSUM_B,
ID_DELETE_B,
ID_DELETE_A,
ID_MEMCARDPATH_A,
ID_MEMCARDPATH_B,
ID_NEXTPAGE_A,
ID_PREVPAGE_A,
ID_NEXTPAGE_B,
ID_PREVPAGE_B,
ID_SAVEEXPORT_A,
ID_SAVEEXPORT_B,
ID_SAVEIMPORT_A,
ID_SAVEIMPORT_B,
ID_CONVERTTOGCI,
ID_MEMCARD1LIST,
ID_MEMCARD2LIST,
ID_MEMCARDLIST_A,
ID_MEMCARDLIST_B,
ID_USEPAGES,
ID_DUMMY_VALUE_ //don't remove this value unless you have other enum values
};
@ -114,9 +120,29 @@ class CMemcardManager
void OnClose(wxCloseEvent& event);
void CopyDeleteClick(wxCommandEvent& event);
bool ReloadMemcard(const char *fileName, int card, int page);
void OnMenuChange(wxCommandEvent& event);
void OnPageChange(wxCommandEvent& event);
void OnPathChange(wxFileDirPickerEvent& event);
bool ReadError(GCMemcard *memcard);
class CMemcardListCtrl : public wxListCtrl
{
public:
IniFile MemcardManagerIni;
CMemcardListCtrl(wxWindow* parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, long style);
~CMemcardListCtrl();
bool twoCardsLoaded,
usePages,
prevPage,
nextPage,
column[NUMBER_OF_COLUMN];
private:
DECLARE_EVENT_TABLE()
void OnRightClick(wxMouseEvent& event);
};
CMemcardListCtrl *m_MemcardList[2];
};
#endif