2008-12-08 05:30:24 +00:00
|
|
|
// Copyright (C) 2003-2008 Dolphin Project.
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, version 2.0.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official SVN repository and contact information can be found at
|
|
|
|
// http://code.google.com/p/dolphin-emu/
|
|
|
|
|
|
|
|
#include "Globals.h"
|
|
|
|
#include "MemcardManager.h"
|
2008-12-12 07:14:37 +00:00
|
|
|
#include "Common.h"
|
2008-12-08 05:30:24 +00:00
|
|
|
#include "wx/mstream.h"
|
2009-01-15 06:06:30 +00:00
|
|
|
//#define DEBUG_MCM true
|
2009-02-22 03:23:48 +00:00
|
|
|
#define DEFAULTS wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator
|
|
|
|
#define ARROWS slot ? "" : ARROW[slot], slot ? ARROW[slot] : ""
|
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
const u8 hdr[] = {
|
|
|
|
0x42,0x4D,
|
|
|
|
0x38,0x30,0x00,0x00,
|
|
|
|
0x00,0x00,0x00,0x00,
|
|
|
|
0x36,0x00,0x00,0x00,
|
|
|
|
0x28,0x00,0x00,0x00,
|
|
|
|
0x20,0x00,0x00,0x00, //W
|
|
|
|
0x20,0x00,0x00,0x00, //H
|
|
|
|
0x01,0x00,
|
|
|
|
0x20,0x00,
|
|
|
|
0x00,0x00,0x00,0x00,
|
|
|
|
0x02,0x30,0x00,0x00, //data size
|
|
|
|
0x12,0x0B,0x00,0x00,
|
|
|
|
0x12,0x0B,0x00,0x00,
|
|
|
|
0x00,0x00,0x00,0x00,
|
|
|
|
0x00,0x00,0x00,0x00
|
|
|
|
};
|
|
|
|
|
|
|
|
wxBitmap wxBitmapFromMemoryRGBA(const unsigned char* data, int width, int height)
|
|
|
|
{
|
|
|
|
int stride = (4*width);
|
|
|
|
|
|
|
|
int bytes = (stride*height) + sizeof(hdr);
|
|
|
|
|
|
|
|
bytes = (bytes+3)&(~3);
|
|
|
|
|
|
|
|
u8 *pdata = new u8[bytes];
|
|
|
|
|
|
|
|
memset(pdata,0,bytes);
|
|
|
|
memcpy(pdata,hdr,sizeof(hdr));
|
|
|
|
|
|
|
|
u8 *pixelData = pdata + sizeof(hdr);
|
|
|
|
|
|
|
|
for (int y=0;y<height;y++)
|
|
|
|
{
|
|
|
|
memcpy(pixelData+y*stride,data+(height-y-1)*stride,stride);
|
|
|
|
}
|
|
|
|
|
|
|
|
*(int*)(pdata+18) = width;
|
|
|
|
*(int*)(pdata+22) = height;
|
|
|
|
*(u32*)(pdata+34) = bytes-sizeof(hdr);
|
|
|
|
|
|
|
|
wxMemoryInputStream is(pdata, bytes);
|
|
|
|
wxBitmap map(wxImage(is, wxBITMAP_TYPE_BMP, -1), -1);
|
|
|
|
|
|
|
|
delete [] pdata;
|
|
|
|
|
|
|
|
return map;
|
|
|
|
}
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE(CMemcardManager, wxDialog)
|
|
|
|
EVT_CLOSE(CMemcardManager::OnClose)
|
2008-12-10 02:41:55 +00:00
|
|
|
|
2008-12-13 11:30:00 +00:00
|
|
|
EVT_BUTTON(ID_COPYFROM_A,CMemcardManager::CopyDeleteClick)
|
|
|
|
EVT_BUTTON(ID_COPYFROM_B,CMemcardManager::CopyDeleteClick)
|
2008-12-10 02:41:55 +00:00
|
|
|
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)
|
2008-12-08 05:30:24 +00:00
|
|
|
EVT_BUTTON(ID_CONVERTTOGCI,CMemcardManager::CopyDeleteClick)
|
2008-12-10 02:41:55 +00:00
|
|
|
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_FILEPICKER_CHANGED(ID_MEMCARDPATH_A,CMemcardManager::OnPathChange)
|
|
|
|
EVT_FILEPICKER_CHANGED(ID_MEMCARDPATH_B,CMemcardManager::OnPathChange)
|
2008-12-12 07:14:37 +00:00
|
|
|
|
2008-12-20 18:43:52 +00:00
|
|
|
EVT_MENU_RANGE(ID_MEMCARDPATH_A, ID_USEPAGES, CMemcardManager::OnMenuChange)
|
2008-12-13 11:30:00 +00:00
|
|
|
EVT_MENU_RANGE(ID_COPYFROM_A, ID_CONVERTTOGCI, CMemcardManager::CopyDeleteClick)
|
2008-12-12 07:14:37 +00:00
|
|
|
EVT_MENU_RANGE(ID_NEXTPAGE_A, ID_PREVPAGE_B, CMemcardManager::OnPageChange)
|
|
|
|
EVT_MENU_RANGE(COLUMN_BANNER, NUMBER_OF_COLUMN, CMemcardManager::OnMenuChange)
|
2008-12-10 02:41:55 +00:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE(CMemcardManager::CMemcardListCtrl, wxListCtrl)
|
|
|
|
EVT_RIGHT_DOWN(CMemcardManager::CMemcardListCtrl::OnRightClick)
|
2008-12-08 05:30:24 +00:00
|
|
|
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)
|
|
|
|
{
|
2008-12-10 02:41:55 +00:00
|
|
|
memoryCard[SLOT_A]=NULL;
|
|
|
|
memoryCard[SLOT_B]=NULL;
|
2008-12-10 09:57:15 +00:00
|
|
|
if (MemcardManagerIni.Load(CONFIG_FILE))
|
2008-12-10 02:41:55 +00:00
|
|
|
{
|
2008-12-10 09:57:15 +00:00
|
|
|
MemcardManagerIni.Get("MemcardManager", "Items per page", &itemsPerPage, 16);
|
2008-12-20 08:47:38 +00:00
|
|
|
MemcardManagerIni.Get("MemcardManager", "DefaultMemcardA", &(DefaultMemcard[SLOT_A]), ".");
|
|
|
|
MemcardManagerIni.Get("MemcardManager", "DefaultMemcardB", &(DefaultMemcard[SLOT_B]), ".");
|
2009-02-22 03:23:48 +00:00
|
|
|
MemcardManagerIni.Get("MemcardManager", "DefaultIOFolder", &DefaultIOPath, "/Users/GC");
|
2008-12-10 02:41:55 +00:00
|
|
|
}
|
|
|
|
else itemsPerPage = 16;
|
|
|
|
maxPages = (128 / itemsPerPage) - 1;
|
2008-12-08 05:30:24 +00:00
|
|
|
CreateGUIControls();
|
|
|
|
}
|
|
|
|
|
|
|
|
CMemcardManager::~CMemcardManager()
|
|
|
|
{
|
2008-12-10 02:41:55 +00:00
|
|
|
if (memoryCard[SLOT_A])
|
|
|
|
{
|
|
|
|
delete memoryCard[SLOT_A];
|
|
|
|
memoryCard[SLOT_A] = NULL;
|
|
|
|
}
|
|
|
|
if (memoryCard[SLOT_B])
|
|
|
|
{
|
|
|
|
delete memoryCard[SLOT_B];
|
|
|
|
memoryCard[SLOT_B] = NULL;
|
|
|
|
}
|
2008-12-10 09:57:15 +00:00
|
|
|
MemcardManagerIni.Load(CONFIG_FILE);
|
|
|
|
MemcardManagerIni.Set("MemcardManager", "Items per page", itemsPerPage);
|
2009-01-15 06:06:30 +00:00
|
|
|
|
|
|
|
if (!DefaultMemcard[SLOT_A].empty() && (strcmp(DefaultMemcard[SLOT_A].c_str(), ".")))
|
|
|
|
MemcardManagerIni.Set("MemcardManager", "DefaultMemcardA", DefaultMemcard[SLOT_A]);
|
|
|
|
else
|
|
|
|
MemcardManagerIni.DeleteKey("MemcardManager", "DefaultMemcardA");
|
|
|
|
if (!DefaultMemcard[SLOT_B].empty() && (strcmp(DefaultMemcard[SLOT_B].c_str(), ".")))
|
|
|
|
MemcardManagerIni.Set("MemcardManager", "DefaultMemcardB", DefaultMemcard[SLOT_B]);
|
|
|
|
else
|
|
|
|
MemcardManagerIni.DeleteKey("MemcardManager", "DefaultMemcardB");
|
2008-12-10 09:57:15 +00:00
|
|
|
MemcardManagerIni.Save(CONFIG_FILE);
|
2008-12-10 02:41:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CMemcardManager::CMemcardListCtrl::CMemcardListCtrl(wxWindow* parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
|
|
|
|
: wxListCtrl(parent, id, pos, size, style)
|
|
|
|
{
|
2008-12-10 09:57:15 +00:00
|
|
|
if (MemcardManagerIni.Load(CONFIG_FILE))
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2008-12-10 09:57:15 +00:00
|
|
|
MemcardManagerIni.Get("MemcardManager", "Use Pages", &usePages, true);
|
|
|
|
MemcardManagerIni.Get("MemcardManager", "cBanner", &column[COLUMN_BANNER], true);
|
|
|
|
MemcardManagerIni.Get("MemcardManager", "cTitle", &column[COLUMN_TITLE], true);
|
|
|
|
MemcardManagerIni.Get("MemcardManager", "cComment", &column[COLUMN_COMMENT], true);
|
2009-02-22 03:23:48 +00:00
|
|
|
MemcardManagerIni.Get("MemcardManager", "cIcon", &column[COLUMN_ICON], true);
|
2008-12-10 09:57:15 +00:00
|
|
|
MemcardManagerIni.Get("MemcardManager", "cBlocks", &column[COLUMN_BLOCKS], true);
|
|
|
|
MemcardManagerIni.Get("MemcardManager", "cFirst Block", &column[COLUMN_FIRSTBLOCK], true);
|
2009-01-15 06:06:30 +00:00
|
|
|
#ifdef DEBUG_MCM
|
2009-02-22 03:23:48 +00:00
|
|
|
MemcardManagerIni.Get("MemcardManager", "cDebug", &column[NUMBER_OF_COLUMN], false);
|
2009-01-15 06:06:30 +00:00
|
|
|
#else
|
|
|
|
column[NUMBER_OF_COLUMN] = false;
|
|
|
|
#endif
|
|
|
|
for(int i = COLUMN_GAMECODE; i < NUMBER_OF_COLUMN; i++)
|
|
|
|
{
|
|
|
|
column[i] = column[NUMBER_OF_COLUMN];
|
|
|
|
}
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
2008-12-10 02:41:55 +00:00
|
|
|
else
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2008-12-10 02:41:55 +00:00
|
|
|
usePages = true;
|
2009-01-15 06:06:30 +00:00
|
|
|
for (int i = 0; i < NUMBER_OF_COLUMN; i++)
|
|
|
|
{
|
|
|
|
if ( i > COLUMN_FIRSTBLOCK) column[i] = false;
|
|
|
|
else column[i] = true;
|
|
|
|
}
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
2008-12-10 02:41:55 +00:00
|
|
|
twoCardsLoaded = false;
|
|
|
|
prevPage = false;
|
|
|
|
nextPage = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
CMemcardManager::CMemcardListCtrl::~CMemcardListCtrl()
|
|
|
|
{
|
2008-12-10 09:57:15 +00:00
|
|
|
MemcardManagerIni.Load(CONFIG_FILE);
|
2009-02-22 03:23:48 +00:00
|
|
|
|
2008-12-10 09:57:15 +00:00
|
|
|
MemcardManagerIni.Set("MemcardManager", "Use Pages", usePages);
|
|
|
|
MemcardManagerIni.Set("MemcardManager", "cBanner", column[COLUMN_BANNER]);
|
|
|
|
MemcardManagerIni.Set("MemcardManager", "cTitle", column[COLUMN_TITLE]);
|
|
|
|
MemcardManagerIni.Set("MemcardManager", "cComment", column[COLUMN_COMMENT]);
|
2009-02-22 03:23:48 +00:00
|
|
|
MemcardManagerIni.Set("MemcardManager", "cIcon", column[COLUMN_ICON]);
|
2008-12-10 09:57:15 +00:00
|
|
|
MemcardManagerIni.Set("MemcardManager", "cBlocks", column[COLUMN_BLOCKS]);
|
|
|
|
MemcardManagerIni.Set("MemcardManager", "cFirst Block", column[COLUMN_FIRSTBLOCK]);
|
2009-01-15 06:06:30 +00:00
|
|
|
#ifdef DEBUG_MCM
|
|
|
|
MemcardManagerIni.Set("MemcardManager", "cDebug", column[NUMBER_OF_COLUMN]);
|
|
|
|
#endif
|
2008-12-10 09:57:15 +00:00
|
|
|
MemcardManagerIni.Save(CONFIG_FILE);
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMemcardManager::CreateGUIControls()
|
|
|
|
{
|
2008-12-10 02:41:55 +00:00
|
|
|
// Create the controls for both memcards
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2009-02-22 07:52:02 +00:00
|
|
|
char ARROW[2][3] = {{'<','-',0,}, {'-','>',0}};
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2009-02-22 03:23:48 +00:00
|
|
|
m_ConvertToGci = new wxButton(this, ID_CONVERTTOGCI, wxT("Convert to GCI"), DEFAULTS);
|
2008-12-13 11:30:00 +00:00
|
|
|
|
2009-02-22 03:23:48 +00:00
|
|
|
for (int slot = SLOT_A; slot < SLOT_B + 1; slot++)
|
|
|
|
{
|
|
|
|
m_CopyFrom[slot] = new wxButton(this, ID_COPYFROM_A + slot,
|
2009-02-22 07:52:02 +00:00
|
|
|
wxString::Format(wxT("%1$sCopy%1$s"), ARROW[slot ? 0 : 1]), DEFAULTS);
|
2009-02-22 03:23:48 +00:00
|
|
|
m_FixChecksum[slot] = new wxButton(this, ID_FIXCHECKSUM_A + slot,
|
2009-02-22 07:52:02 +00:00
|
|
|
wxString::Format(wxT("%sFix Checksum%s"), ARROWS), DEFAULTS);
|
2009-02-22 03:23:48 +00:00
|
|
|
m_SaveImport[slot] = new wxButton(this, ID_SAVEIMPORT_A + slot,
|
2009-02-22 07:52:02 +00:00
|
|
|
wxString::Format(wxT("%sImport GCI%s"), ARROWS), DEFAULTS);
|
2009-02-22 03:23:48 +00:00
|
|
|
m_SaveExport[slot] = new wxButton(this, ID_SAVEEXPORT_A + slot,
|
2009-02-22 07:52:02 +00:00
|
|
|
wxString::Format(wxT("%sExport GCI%s"), ARROWS), DEFAULTS);
|
2009-02-22 03:23:48 +00:00
|
|
|
m_Delete[slot] = new wxButton(this, ID_DELETE_A + slot,
|
2009-02-22 07:52:02 +00:00
|
|
|
wxString::Format(wxT("%sDelete%s"), ARROWS), DEFAULTS);
|
2009-02-22 03:23:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
m_PrevPage[slot] = new wxButton(this, ID_PREVPAGE_A + slot, wxT("Prev Page"), DEFAULTS);
|
|
|
|
m_NextPage[slot] = new wxButton(this, ID_NEXTPAGE_A + slot, wxT("Next Page"), DEFAULTS);
|
|
|
|
|
|
|
|
t_Status[slot] = new wxStaticText(this, 0, wxEmptyString, wxDefaultPosition,wxDefaultSize, 0, wxEmptyString);
|
|
|
|
|
|
|
|
sPages[slot] = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
sPages[slot]->Add(m_PrevPage[slot], 0, wxEXPAND|wxALL, 1);
|
|
|
|
sPages[slot]->Add(t_Status[slot],0, wxEXPAND|wxALL, 5);
|
|
|
|
sPages[slot]->Add(0, 0, 1, wxEXPAND|wxALL, 0);
|
|
|
|
sPages[slot]->Add(m_NextPage[slot], 0, wxEXPAND|wxALL, 1);
|
|
|
|
|
|
|
|
m_MemcardPath[slot] = new wxFilePickerCtrl(this, ID_MEMCARDPATH_A + slot, wxEmptyString, wxT("Choose a memory card:"),
|
|
|
|
wxT("Gamecube Memory Cards (*.raw,*.gcp)|*.raw;*.gcp"), wxDefaultPosition, wxDefaultSize, wxFLP_USE_TEXTCTRL|wxFLP_OPEN);
|
2008-12-10 02:41:55 +00:00
|
|
|
|
2009-02-22 03:23:48 +00:00
|
|
|
m_MemcardList[slot] = new CMemcardListCtrl(this, ID_MEMCARDLIST_A + slot, wxDefaultPosition, wxSize(350,400),
|
|
|
|
wxLC_REPORT | wxSUNKEN_BORDER | wxLC_ALIGN_LEFT | wxLC_SINGLE_SEL);
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2009-02-22 03:23:48 +00:00
|
|
|
m_MemcardList[slot]->AssignImageList(new wxImageList(96,32),wxIMAGE_LIST_SMALL);
|
|
|
|
|
2009-02-22 07:52:02 +00:00
|
|
|
sMemcard[slot] = new wxStaticBoxSizer(wxVERTICAL, this, wxString::Format(wxT("Memory Card %c"), 'A' + slot));
|
2009-02-22 03:23:48 +00:00
|
|
|
sMemcard[slot]->Add(m_MemcardPath[slot], 0, wxEXPAND|wxALL, 5);
|
|
|
|
sMemcard[slot]->Add(m_MemcardList[slot], 1, wxEXPAND|wxALL, 5);
|
|
|
|
sMemcard[slot]->Add(sPages[slot], 0, wxEXPAND|wxALL, 1);
|
|
|
|
}
|
2008-12-08 05:30:24 +00:00
|
|
|
|
|
|
|
sButtons = new wxBoxSizer(wxVERTICAL);
|
|
|
|
sButtons->AddStretchSpacer(2);
|
2008-12-20 08:07:04 +00:00
|
|
|
sButtons->Add(m_CopyFrom[SLOT_B], 0, wxEXPAND, 5);
|
|
|
|
sButtons->Add(m_CopyFrom[SLOT_A], 0, wxEXPAND, 5);
|
2008-12-08 05:30:24 +00:00
|
|
|
sButtons->AddStretchSpacer(1);
|
2008-12-20 08:07:04 +00:00
|
|
|
sButtons->Add(m_FixChecksum[SLOT_A], 0, wxEXPAND, 5);
|
|
|
|
sButtons->Add(m_FixChecksum[SLOT_B], 0, wxEXPAND, 5);
|
2008-12-08 05:30:24 +00:00
|
|
|
sButtons->AddStretchSpacer(1);
|
2008-12-20 08:07:04 +00:00
|
|
|
sButtons->Add(m_SaveImport[SLOT_A], 0, wxEXPAND, 5);
|
|
|
|
sButtons->Add(m_SaveExport[SLOT_A], 0, wxEXPAND, 5);
|
2008-12-08 05:30:24 +00:00
|
|
|
sButtons->AddStretchSpacer(1);
|
|
|
|
sButtons->Add(m_ConvertToGci, 0, wxEXPAND, 5);
|
|
|
|
sButtons->AddStretchSpacer(1);
|
2008-12-20 08:07:04 +00:00
|
|
|
sButtons->Add(m_SaveImport[SLOT_B], 0, wxEXPAND, 5);
|
|
|
|
sButtons->Add(m_SaveExport[SLOT_B], 0, wxEXPAND, 5);
|
2008-12-08 05:30:24 +00:00
|
|
|
sButtons->AddStretchSpacer(1);
|
2008-12-20 08:07:04 +00:00
|
|
|
sButtons->Add(m_Delete[SLOT_A], 0, wxEXPAND, 5);
|
|
|
|
sButtons->Add(m_Delete[SLOT_B], 0, wxEXPAND, 5);
|
2008-12-08 05:30:24 +00:00
|
|
|
sButtons->AddStretchSpacer(1);
|
|
|
|
|
|
|
|
sMain = new wxBoxSizer(wxHORIZONTAL);
|
2009-02-22 03:23:48 +00:00
|
|
|
sMain->Add(sMemcard[SLOT_A], 1, wxEXPAND|wxALL, 5);
|
2008-12-08 05:30:24 +00:00
|
|
|
sMain->Add(sButtons, 0, wxEXPAND, 0);
|
2009-02-22 03:23:48 +00:00
|
|
|
sMain->Add(sMemcard[SLOT_B], 1, wxEXPAND|wxALL, 5);
|
2008-12-08 05:30:24 +00:00
|
|
|
|
|
|
|
this->SetSizer(sMain);
|
|
|
|
sMain->SetSizeHints(this);
|
|
|
|
Fit();
|
2009-02-22 03:23:48 +00:00
|
|
|
|
|
|
|
for (int i = SLOT_A; i < SLOT_B + 1; i++)
|
2008-12-20 08:47:38 +00:00
|
|
|
{
|
|
|
|
m_PrevPage[i]->Disable();
|
|
|
|
m_NextPage[i]->Disable();
|
|
|
|
m_CopyFrom[i]->Disable();
|
|
|
|
m_FixChecksum[i]->Disable();
|
|
|
|
m_SaveImport[i]->Disable();
|
|
|
|
m_SaveExport[i]->Disable();
|
|
|
|
m_Delete[i]->Disable();
|
2009-01-15 06:06:30 +00:00
|
|
|
if (strcmp(DefaultMemcard[i].c_str(), "."))
|
2008-12-20 08:47:38 +00:00
|
|
|
{
|
2008-12-20 19:40:20 +00:00
|
|
|
m_MemcardPath[i]->SetPath(wxString::FromAscii(DefaultMemcard[i].c_str()));
|
2008-12-23 07:20:22 +00:00
|
|
|
ChangePath(ID_MEMCARDPATH_A + i);
|
2008-12-20 08:47:38 +00:00
|
|
|
}
|
|
|
|
}
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMemcardManager::OnClose(wxCloseEvent& WXUNUSED (event))
|
|
|
|
{
|
|
|
|
Destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMemcardManager::OnPathChange(wxFileDirPickerEvent& event)
|
2008-12-20 08:47:38 +00:00
|
|
|
{
|
|
|
|
ChangePath(event.GetId());
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMemcardManager::ChangePath(int id)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2008-12-20 08:07:04 +00:00
|
|
|
int slot = SLOT_B;
|
|
|
|
int slot2 = SLOT_A;
|
2008-12-20 08:47:38 +00:00
|
|
|
switch (id)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2008-12-10 02:41:55 +00:00
|
|
|
case ID_MEMCARDPATH_A:
|
2008-12-20 08:07:04 +00:00
|
|
|
slot = SLOT_A;
|
|
|
|
slot2 = SLOT_B;
|
2008-12-10 02:41:55 +00:00
|
|
|
case ID_MEMCARDPATH_B:
|
2008-12-20 08:07:04 +00:00
|
|
|
page[slot] = FIRSTPAGE;
|
|
|
|
if (m_MemcardList[slot]->usePages && m_PrevPage[slot]->IsEnabled())
|
2008-12-10 02:41:55 +00:00
|
|
|
{
|
2008-12-20 08:07:04 +00:00
|
|
|
m_PrevPage[slot]->Disable();
|
|
|
|
m_MemcardList[slot]->prevPage = false;
|
2008-12-10 02:41:55 +00:00
|
|
|
}
|
2008-12-20 08:07:04 +00:00
|
|
|
if (!strcasecmp(m_MemcardPath[slot2]->GetPath().mb_str(), m_MemcardPath[slot]->GetPath().mb_str()))
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2009-01-15 06:06:30 +00:00
|
|
|
if(!m_MemcardPath[slot]->GetPath().IsEmpty())
|
2008-12-12 07:14:37 +00:00
|
|
|
PanicAlert(E_ALREADYOPENED);
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
2008-12-20 08:47:38 +00:00
|
|
|
else if (ReloadMemcard(m_MemcardPath[slot]->GetPath().mb_str(), slot))
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2008-12-20 08:07:04 +00:00
|
|
|
m_MemcardList[slot2]->twoCardsLoaded = true;
|
|
|
|
m_FixChecksum[slot]->Enable();
|
|
|
|
m_SaveImport[slot]->Enable();
|
|
|
|
m_SaveExport[slot]->Enable();
|
|
|
|
m_Delete[slot]->Enable();
|
2008-12-08 05:30:24 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-12-20 08:07:04 +00:00
|
|
|
if (memoryCard[slot])
|
2008-12-13 11:30:00 +00:00
|
|
|
{
|
2008-12-20 08:07:04 +00:00
|
|
|
delete memoryCard[slot];
|
|
|
|
memoryCard[slot] = NULL;
|
2008-12-13 11:30:00 +00:00
|
|
|
}
|
2008-12-20 08:07:04 +00:00
|
|
|
m_MemcardList[slot2]->twoCardsLoaded = false;
|
|
|
|
m_MemcardPath[slot]->SetPath(wxEmptyString);
|
|
|
|
m_MemcardList[slot]->ClearAll();
|
|
|
|
t_Status[slot]->SetLabel(wxEmptyString);
|
|
|
|
m_FixChecksum[slot]->Disable();
|
|
|
|
m_SaveImport[slot]->Disable();
|
|
|
|
m_SaveExport[slot]->Disable();
|
|
|
|
m_Delete[slot]->Disable();
|
|
|
|
if (m_MemcardList[slot]->usePages)
|
2008-12-10 02:41:55 +00:00
|
|
|
{
|
2008-12-20 08:07:04 +00:00
|
|
|
m_PrevPage[slot]->Disable();
|
|
|
|
m_NextPage[slot]->Disable();
|
2008-12-10 02:41:55 +00:00
|
|
|
}
|
2008-12-08 05:30:24 +00:00
|
|
|
break;
|
|
|
|
}
|
2009-02-22 03:23:48 +00:00
|
|
|
if (m_Delete[SLOT_A]->IsEnabled() && m_Delete[SLOT_B]->IsEnabled())
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2008-12-20 08:07:04 +00:00
|
|
|
m_CopyFrom[SLOT_A]->Enable();
|
|
|
|
m_CopyFrom[SLOT_B]->Enable();
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-12-20 08:07:04 +00:00
|
|
|
m_CopyFrom[SLOT_A]->Disable();
|
|
|
|
m_CopyFrom[SLOT_B]->Disable();
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMemcardManager::OnPageChange(wxCommandEvent& event)
|
|
|
|
{
|
2008-12-20 08:07:04 +00:00
|
|
|
int slot = SLOT_B;
|
2008-12-08 05:30:24 +00:00
|
|
|
switch (event.GetId())
|
|
|
|
{
|
2008-12-10 02:41:55 +00:00
|
|
|
case ID_NEXTPAGE_A:
|
2008-12-20 08:07:04 +00:00
|
|
|
slot = SLOT_A;
|
2008-12-10 02:41:55 +00:00
|
|
|
case ID_NEXTPAGE_B:
|
2008-12-20 08:07:04 +00:00
|
|
|
if (!m_PrevPage[slot]->IsEnabled())
|
2008-12-10 02:41:55 +00:00
|
|
|
{
|
2008-12-20 08:07:04 +00:00
|
|
|
m_PrevPage[slot]->Enable();
|
|
|
|
m_MemcardList[slot]->prevPage = true;
|
2008-12-10 02:41:55 +00:00
|
|
|
}
|
2008-12-20 08:07:04 +00:00
|
|
|
page[slot]++;
|
|
|
|
if (page[slot] == maxPages)
|
2008-12-10 02:41:55 +00:00
|
|
|
{
|
2008-12-20 08:07:04 +00:00
|
|
|
m_NextPage[slot]->Disable();
|
|
|
|
m_MemcardList[slot]->nextPage = false;
|
2008-12-10 02:41:55 +00:00
|
|
|
}
|
2008-12-20 08:07:04 +00:00
|
|
|
ReloadMemcard(m_MemcardPath[slot]->GetPath().mb_str(), slot);
|
2008-12-08 05:30:24 +00:00
|
|
|
break;
|
2008-12-10 02:41:55 +00:00
|
|
|
case ID_PREVPAGE_A:
|
2008-12-20 08:07:04 +00:00
|
|
|
slot = SLOT_A;
|
2008-12-10 02:41:55 +00:00
|
|
|
case ID_PREVPAGE_B:
|
2008-12-20 08:07:04 +00:00
|
|
|
if (!m_NextPage[slot]->IsEnabled())
|
2008-12-10 02:41:55 +00:00
|
|
|
{
|
2008-12-20 08:07:04 +00:00
|
|
|
m_NextPage[slot]->Enable();
|
|
|
|
m_MemcardList[slot]->nextPage = true;
|
2008-12-10 02:41:55 +00:00
|
|
|
}
|
2008-12-20 08:07:04 +00:00
|
|
|
page[slot]--;
|
|
|
|
if (!page[slot])
|
2008-12-10 02:41:55 +00:00
|
|
|
{
|
2008-12-20 08:07:04 +00:00
|
|
|
m_PrevPage[slot]->Disable();
|
|
|
|
m_MemcardList[slot]->prevPage = false;
|
2008-12-10 02:41:55 +00:00
|
|
|
}
|
2008-12-20 08:07:04 +00:00
|
|
|
ReloadMemcard(m_MemcardPath[slot]->GetPath().mb_str(), slot);
|
2008-12-08 05:30:24 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-10 02:41:55 +00:00
|
|
|
void CMemcardManager::OnMenuChange(wxCommandEvent& event)
|
|
|
|
{
|
2008-12-20 18:43:52 +00:00
|
|
|
switch(event.GetId())
|
2008-12-10 02:41:55 +00:00
|
|
|
{
|
2008-12-20 18:43:52 +00:00
|
|
|
case ID_USEPAGES:
|
2008-12-10 02:41:55 +00:00
|
|
|
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)
|
|
|
|
{
|
2008-12-20 08:07:04 +00:00
|
|
|
m_PrevPage[SLOT_A]->Disable();
|
|
|
|
m_PrevPage[SLOT_B]->Disable();
|
|
|
|
m_NextPage[SLOT_A]->Disable();
|
|
|
|
m_NextPage[SLOT_B]->Disable();
|
|
|
|
page[SLOT_A] = page[SLOT_B] = FIRSTPAGE;
|
2008-12-10 02:41:55 +00:00
|
|
|
}
|
2008-12-20 18:43:52 +00:00
|
|
|
break;
|
|
|
|
case ID_MEMCARDPATH_A:
|
2008-12-20 19:40:20 +00:00
|
|
|
DefaultMemcard[SLOT_A] = m_MemcardPath[SLOT_A]->GetPath().mb_str();
|
2008-12-20 18:43:52 +00:00
|
|
|
break;
|
|
|
|
case ID_MEMCARDPATH_B:
|
2008-12-20 19:40:20 +00:00
|
|
|
DefaultMemcard[SLOT_B] = m_MemcardPath[SLOT_B]->GetPath().mb_str();
|
2008-12-20 18:43:52 +00:00
|
|
|
break;
|
2009-01-15 06:06:30 +00:00
|
|
|
case NUMBER_OF_COLUMN:
|
|
|
|
for( int i = COLUMN_GAMECODE; i < NUMBER_OF_COLUMN; i++)
|
|
|
|
{
|
|
|
|
m_MemcardList[SLOT_A]->column[i] = !m_MemcardList[SLOT_A]->column[i];
|
|
|
|
m_MemcardList[SLOT_B]->column[i] = !m_MemcardList[SLOT_B]->column[i];
|
|
|
|
}
|
2008-12-20 18:43:52 +00:00
|
|
|
default:
|
2008-12-10 02:41:55 +00:00
|
|
|
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()];
|
2008-12-20 18:43:52 +00:00
|
|
|
if (memoryCard[SLOT_A]) ReloadMemcard(m_MemcardPath[SLOT_A]->GetPath().mb_str(), SLOT_A);
|
|
|
|
if (memoryCard[SLOT_B]) ReloadMemcard(m_MemcardPath[SLOT_B]->GetPath().mb_str(), SLOT_B);
|
|
|
|
break;
|
2008-12-10 02:41:55 +00:00
|
|
|
}
|
|
|
|
}
|
2008-12-13 11:30:00 +00:00
|
|
|
bool CMemcardManager::CopyDeleteSwitch(u32 error, int slot)
|
|
|
|
{
|
|
|
|
switch (error)
|
|
|
|
{
|
|
|
|
case GCS:
|
|
|
|
SuccessAlert("File converted to .gci");
|
|
|
|
break;
|
|
|
|
case SUCCESS:
|
|
|
|
if (slot != -1)
|
|
|
|
{
|
|
|
|
memoryCard[slot]->FixChecksums();
|
|
|
|
if (!memoryCard[slot]->Save()) PanicAlert(E_SAVEFAILED);
|
2008-12-20 08:07:04 +00:00
|
|
|
page[slot] = FIRSTPAGE;
|
|
|
|
ReloadMemcard(m_MemcardPath[slot]->GetPath().mb_str(), slot);
|
2008-12-13 11:30:00 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NOMEMCARD:
|
|
|
|
PanicAlert(E_NOMEMCARD);
|
|
|
|
break;
|
|
|
|
case OPENFAIL:
|
|
|
|
PanicAlert(E_OPENFAIL);
|
|
|
|
break;
|
|
|
|
case OUTOFBLOCKS:
|
|
|
|
if (slot == -1)
|
|
|
|
{
|
|
|
|
PanicAlert(E_UNK);
|
|
|
|
break;
|
|
|
|
}
|
2008-12-20 19:40:20 +00:00
|
|
|
PanicAlert(E_OUTOFBLOCKS, memoryCard[slot]->GetFreeBlocks());
|
2008-12-13 11:30:00 +00:00
|
|
|
break;
|
|
|
|
case OUTOFDIRENTRIES:
|
|
|
|
PanicAlert(E_OUTOFDIRENTRIES);
|
|
|
|
break;
|
|
|
|
case LENGTHFAIL:
|
|
|
|
PanicAlert(E_LENGTHFAIL);
|
|
|
|
break;
|
|
|
|
case INVALIDFILESIZE:
|
|
|
|
PanicAlert(E_INVALIDFILESIZE);
|
|
|
|
break;
|
|
|
|
case TITLEPRESENT:
|
|
|
|
PanicAlert(E_TITLEPRESENT);
|
|
|
|
break;
|
|
|
|
case SAVFAIL:
|
|
|
|
PanicAlert(E_SAVFAIL);
|
|
|
|
break;
|
|
|
|
case GCSFAIL:
|
|
|
|
PanicAlert(E_GCSFAIL);
|
|
|
|
break;
|
|
|
|
case FAIL:
|
2009-01-15 06:06:30 +00:00
|
|
|
if (slot == -1)
|
|
|
|
{
|
|
|
|
PanicAlert("Export Failed");
|
|
|
|
return false;
|
|
|
|
}
|
2008-12-13 11:30:00 +00:00
|
|
|
PanicAlert(E_INVALID);
|
|
|
|
break;
|
|
|
|
case WRITEFAIL:
|
|
|
|
PanicAlert(E_SAVEFAILED);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
PanicAlert(E_UNK);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2008-12-10 02:41:55 +00:00
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
void CMemcardManager::CopyDeleteClick(wxCommandEvent& event)
|
|
|
|
{
|
2008-12-10 02:41:55 +00:00
|
|
|
|
|
|
|
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;
|
2008-12-13 11:30:00 +00:00
|
|
|
int slot2 = SLOT_A;
|
2008-12-10 02:41:55 +00:00
|
|
|
int index = index_B;
|
2008-12-08 05:30:24 +00:00
|
|
|
std::string fileName2("");
|
|
|
|
|
2008-12-20 08:07:04 +00:00
|
|
|
if (index_A != wxNOT_FOUND && page[SLOT_A]) index_A += itemsPerPage * page[SLOT_A];
|
|
|
|
if (index_B != wxNOT_FOUND && page[SLOT_B]) index_B += itemsPerPage * page[SLOT_B];
|
2008-12-08 05:30:24 +00:00
|
|
|
|
|
|
|
switch (event.GetId())
|
|
|
|
{
|
2008-12-13 11:30:00 +00:00
|
|
|
case ID_COPYFROM_B:
|
|
|
|
slot = SLOT_A;
|
|
|
|
slot2 = SLOT_B;
|
|
|
|
case ID_COPYFROM_A:
|
|
|
|
index = slot2 ? index_B : index_A;
|
|
|
|
if ((index != wxNOT_FOUND))
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2008-12-13 11:30:00 +00:00
|
|
|
CopyDeleteSwitch(memoryCard[slot]->CopyFrom(*memoryCard[slot2], index), slot);
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
break;
|
2008-12-10 02:41:55 +00:00
|
|
|
case ID_FIXCHECKSUM_A:
|
|
|
|
slot = SLOT_A;
|
|
|
|
case ID_FIXCHECKSUM_B:
|
2008-12-13 11:30:00 +00:00
|
|
|
if (memoryCard[slot]->FixChecksums() && memoryCard[slot]->Save())
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2008-12-13 11:30:00 +00:00
|
|
|
SuccessAlert("The checksum was successfully fixed");
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
2008-12-13 11:30:00 +00:00
|
|
|
else PanicAlert(E_SAVEFAILED);
|
2008-12-08 05:30:24 +00:00
|
|
|
break;
|
|
|
|
case ID_CONVERTTOGCI:
|
|
|
|
fileName2 = "convert";
|
2008-12-10 02:41:55 +00:00
|
|
|
case ID_SAVEIMPORT_A:
|
|
|
|
slot = SLOT_A;
|
|
|
|
case ID_SAVEIMPORT_B:
|
2008-12-13 11:30:00 +00:00
|
|
|
{
|
|
|
|
wxString temp = wxFileSelector(_T("Select a save file to import"),
|
2009-02-22 21:37:36 +00:00
|
|
|
(strcmp(DefaultIOPath.c_str(), "/Users/GC") == 0) ? wxString::FromAscii(""): wxString::FromAscii(DefaultIOPath.c_str()), wxEmptyString, wxEmptyString, wxString::Format
|
2008-12-13 11:30:00 +00:00
|
|
|
(
|
|
|
|
_T("Gamecube save files(*.gci,*.gcs,*.sav)|*.gci;*.gcs;*.sav|"
|
|
|
|
"Native GCI files (*.gci)|*.gci|"
|
|
|
|
"MadCatz Gameshark files(*.gcs)|*.gcs|"
|
|
|
|
"Datel MaxDrive/Pro files(*.sav)|*.sav"),
|
|
|
|
wxFileSelectorDefaultWildcardStr,
|
|
|
|
wxFileSelectorDefaultWildcardStr
|
|
|
|
),
|
|
|
|
wxFD_OPEN | wxFD_FILE_MUST_EXIST);
|
|
|
|
const char * fileName = temp.ToAscii();
|
|
|
|
if (!temp.empty() && !fileName2.empty())
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2008-12-13 11:30:00 +00:00
|
|
|
wxString temp2 = wxFileSelector(_T("Save GCI as.."),
|
|
|
|
wxEmptyString, wxEmptyString, _T(".gci"), wxString::Format
|
2008-12-08 05:30:24 +00:00
|
|
|
(
|
2008-12-13 11:30:00 +00:00
|
|
|
_T("GCI File(*.gci)|*.gci"),
|
2008-12-08 05:30:24 +00:00
|
|
|
wxFileSelectorDefaultWildcardStr,
|
|
|
|
wxFileSelectorDefaultWildcardStr
|
|
|
|
),
|
2008-12-13 11:30:00 +00:00
|
|
|
wxFD_OVERWRITE_PROMPT|wxFD_SAVE);
|
|
|
|
if (temp2.empty()) break;
|
|
|
|
fileName2 = temp2.mb_str();
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
2008-12-13 11:30:00 +00:00
|
|
|
if (temp.length() > 0)
|
|
|
|
{
|
|
|
|
CopyDeleteSwitch(memoryCard[slot]->ImportGci(fileName, fileName2), slot);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2008-12-10 02:41:55 +00:00
|
|
|
case ID_SAVEEXPORT_A:
|
|
|
|
slot=SLOT_A;
|
|
|
|
index = index_A;
|
|
|
|
case ID_SAVEEXPORT_B:
|
|
|
|
if (index != wxNOT_FOUND)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2009-02-22 03:23:48 +00:00
|
|
|
char tempC[36], tempC2[32];
|
|
|
|
memoryCard[slot]->DEntry_GameCode(index,tempC);
|
|
|
|
memoryCard[slot]->DEntry_FileName(index,tempC2);
|
|
|
|
sprintf(tempC, "%s_%s.gci", tempC, tempC2);
|
2009-02-22 21:37:36 +00:00
|
|
|
wxString temp = wxFileSelector(_T("Save GCI as.."), wxString::FromAscii(DefaultIOPath.c_str()),
|
2009-02-22 07:52:02 +00:00
|
|
|
wxString::FromAscii(tempC), _T(".gci"), wxString::Format
|
2009-02-22 03:23:48 +00:00
|
|
|
(
|
|
|
|
_T("GCI File(*.gci)|*.gci"),
|
|
|
|
wxFileSelectorDefaultWildcardStr,
|
|
|
|
wxFileSelectorDefaultWildcardStr
|
|
|
|
),
|
|
|
|
wxFD_OVERWRITE_PROMPT|wxFD_SAVE);
|
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
if (temp.length() > 0)
|
|
|
|
{
|
2009-02-22 03:23:48 +00:00
|
|
|
const char * fileName = temp.ToAscii();
|
|
|
|
if (!CopyDeleteSwitch(memoryCard[slot]->ExportGci(index, fileName, NULL), -1))
|
|
|
|
{
|
2008-12-13 19:49:19 +00:00
|
|
|
File::Delete(temp.ToAscii());
|
2009-02-22 03:23:48 +00:00
|
|
|
}
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2009-02-22 03:23:48 +00:00
|
|
|
case ID_EXPORTALL_A:
|
|
|
|
slot=SLOT_A;
|
|
|
|
case ID_EXPORTALL_B:
|
|
|
|
{
|
2009-02-22 21:37:36 +00:00
|
|
|
std::string path1, path2, mpath;
|
|
|
|
mpath = m_MemcardPath[slot]->GetPath().mb_str();
|
|
|
|
SplitPath(mpath, &path1, &path2, NULL);
|
2009-02-22 03:23:48 +00:00
|
|
|
path1 += path2;
|
|
|
|
File::CreateDir(path1.c_str());
|
|
|
|
if(PanicYesNo("Warning: This will overwrite any existing saves "
|
|
|
|
"that are in the folder:\n%s\nand have the same name"
|
|
|
|
" as a file on your memcard\nContinue?", path1.c_str()))
|
|
|
|
for (int i = 0; i < DIRLEN; i++)
|
|
|
|
{
|
2009-02-22 21:37:36 +00:00
|
|
|
CopyDeleteSwitch(memoryCard[slot]->ExportGci(i, ".", &path1), -1);
|
2009-02-22 03:23:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2008-12-10 02:41:55 +00:00
|
|
|
case ID_DELETE_A:
|
2008-12-23 07:20:22 +00:00
|
|
|
slot = SLOT_A;
|
2008-12-10 02:41:55 +00:00
|
|
|
index = index_A;
|
|
|
|
case ID_DELETE_B:
|
|
|
|
if (index != wxNOT_FOUND)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2008-12-13 11:30:00 +00:00
|
|
|
CopyDeleteSwitch(memoryCard[slot]->RemoveFile(index), slot);
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-20 08:07:04 +00:00
|
|
|
bool CMemcardManager::ReloadMemcard(const char *fileName, int card)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
|
|
|
wxString wxBlock;
|
|
|
|
wxString wxFirstBlock;
|
|
|
|
wxString wxLabel;
|
2009-01-15 06:06:30 +00:00
|
|
|
wxString tString;
|
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
int j;
|
|
|
|
|
|
|
|
if (memoryCard[card]) delete memoryCard[card];
|
|
|
|
|
|
|
|
// TODO: add error checking and animate icons
|
|
|
|
memoryCard[card] = new GCMemcard(fileName);
|
|
|
|
|
2008-12-20 08:07:04 +00:00
|
|
|
if (memoryCard[card]->fail) return false;
|
2008-12-08 05:30:24 +00:00
|
|
|
|
|
|
|
m_MemcardList[card]->Hide();
|
|
|
|
m_MemcardList[card]->ClearAll();
|
2008-12-10 02:41:55 +00:00
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
m_MemcardList[card]->InsertColumn(COLUMN_BANNER, _T("Banner"));
|
|
|
|
m_MemcardList[card]->InsertColumn(COLUMN_TITLE, _T("Title"));
|
|
|
|
m_MemcardList[card]->InsertColumn(COLUMN_COMMENT, _T("Comment"));
|
|
|
|
m_MemcardList[card]->InsertColumn(COLUMN_ICON, _T("Icon"));
|
|
|
|
m_MemcardList[card]->InsertColumn(COLUMN_BLOCKS, _T("Blocks"));
|
|
|
|
m_MemcardList[card]->InsertColumn(COLUMN_FIRSTBLOCK, _T("First Block"));
|
2009-01-15 06:06:30 +00:00
|
|
|
#ifdef DEBUG_MCM
|
|
|
|
m_MemcardList[card]->InsertColumn(COLUMN_GAMECODE, _T("GameCode"));
|
|
|
|
m_MemcardList[card]->InsertColumn(COLUMN_MAKERCODE, _T("MakerCode"));
|
|
|
|
m_MemcardList[card]->InsertColumn(COLUMN_BIFLAGS, _T("BIFLAGS"));
|
|
|
|
m_MemcardList[card]->InsertColumn(COLUMN_FILENAME, _T("FILENAME"));
|
|
|
|
m_MemcardList[card]->InsertColumn(COLUMN_MODTIME, _T("MODTIME"));
|
|
|
|
m_MemcardList[card]->InsertColumn(COLUMN_IMAGEADD, _T("IMAGEADD"));
|
|
|
|
m_MemcardList[card]->InsertColumn(COLUMN_ICONFMT, _T("ICONFMT"));
|
|
|
|
m_MemcardList[card]->InsertColumn(COLUMN_ANIMSPEED, _T("ANIMSPEED"));
|
|
|
|
m_MemcardList[card]->InsertColumn(COLUMN_PERMISSIONS, _T("PERMISSIONS"));
|
|
|
|
m_MemcardList[card]->InsertColumn(COLUMN_COPYCOUNTER, _T("COPYCOUNTER"));
|
|
|
|
m_MemcardList[card]->InsertColumn(COLUMN_COMMENTSADDRESS, _T("COMMENTSADDRESS"));
|
|
|
|
#endif
|
2008-12-08 05:30:24 +00:00
|
|
|
|
|
|
|
wxImageList *list = m_MemcardList[card]->GetImageList(wxIMAGE_LIST_SMALL);
|
|
|
|
list->RemoveAll();
|
|
|
|
|
|
|
|
int nFiles = memoryCard[card]->GetNumFiles();
|
|
|
|
int *images = new int[nFiles*2];
|
2008-12-10 02:41:55 +00:00
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
for (int i = 0;i < nFiles;i++)
|
|
|
|
{
|
|
|
|
static u32 pxdata[96*32];
|
|
|
|
static u8 animDelay[8];
|
|
|
|
static u32 animData[32*32*8];
|
|
|
|
|
|
|
|
int numFrames = memoryCard[card]->ReadAnimRGBA8(i,animData,animDelay);
|
|
|
|
|
|
|
|
if (!memoryCard[card]->ReadBannerRGBA8(i,pxdata))
|
|
|
|
{
|
|
|
|
memset(pxdata,0,96*32*4);
|
|
|
|
|
|
|
|
if (numFrames>0) // Just use the first one
|
|
|
|
{
|
|
|
|
u32 *icdata = animData;
|
|
|
|
|
|
|
|
for (int y=0;y<32;y++)
|
|
|
|
{
|
|
|
|
for (int x=0;x<32;x++)
|
|
|
|
{
|
2008-12-10 02:41:55 +00:00
|
|
|
pxdata[y*96+x+32] = icdata[y*32+x];// | 0xFF000000
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
wxBitmap map = wxBitmapFromMemoryRGBA((u8*)pxdata,96,32);
|
|
|
|
images[i*2] = list->Add(map);
|
|
|
|
|
|
|
|
if (numFrames>0)
|
|
|
|
{
|
|
|
|
memset(pxdata,0,96*32*4);
|
|
|
|
int frames=3;
|
|
|
|
if (numFrames<frames) frames=numFrames;
|
|
|
|
for (int f=0;f<frames;f++)
|
|
|
|
{
|
|
|
|
for (int y=0;y<32;y++)
|
|
|
|
{
|
|
|
|
for (int x=0;x<32;x++)
|
|
|
|
{
|
|
|
|
pxdata[y*96 + x + 32*f] = animData[f*32*32 + y*32 + x];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
wxBitmap icon = wxBitmapFromMemoryRGBA((u8*)pxdata,96,32);
|
|
|
|
images[i*2+1] = list->Add(icon);
|
|
|
|
}
|
|
|
|
}
|
2008-12-10 02:41:55 +00:00
|
|
|
int pagesMax = 128;
|
2008-12-20 08:07:04 +00:00
|
|
|
if (m_MemcardList[card]->usePages) pagesMax = (page[card] + 1) * itemsPerPage;
|
|
|
|
for (j = page[card] * itemsPerPage;(j < nFiles) && (j < pagesMax);j++)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
|
|
|
char title[32];
|
|
|
|
char comment[32];
|
|
|
|
u16 blocks;
|
|
|
|
u16 firstblock;
|
|
|
|
|
2008-12-10 02:41:55 +00:00
|
|
|
int index = m_MemcardList[card]->InsertItem(j, wxEmptyString);
|
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
m_MemcardList[card]->SetItem(index, COLUMN_BANNER, wxEmptyString);
|
2009-01-15 06:06:30 +00:00
|
|
|
if (!memoryCard[card]->DEntry_Comment1(j, title)) title[0]=0;
|
2008-12-08 05:30:24 +00:00
|
|
|
m_MemcardList[card]->SetItem(index, COLUMN_TITLE, wxString::FromAscii(title));
|
2009-01-15 06:06:30 +00:00
|
|
|
if (!memoryCard[card]->DEntry_Comment2(j, comment)) comment[0]=0;
|
2008-12-08 05:30:24 +00:00
|
|
|
m_MemcardList[card]->SetItem(index, COLUMN_COMMENT, wxString::FromAscii(comment));
|
2009-01-15 06:06:30 +00:00
|
|
|
blocks = memoryCard[card]->DEntry_BlockCount(j);
|
2008-12-08 05:30:24 +00:00
|
|
|
if (blocks == 0xFFFF) blocks = 0;
|
|
|
|
wxBlock.Printf(wxT("%10d"), blocks);
|
2008-12-10 02:41:55 +00:00
|
|
|
m_MemcardList[card]->SetItem(index,COLUMN_BLOCKS, wxBlock);
|
2009-01-15 06:06:30 +00:00
|
|
|
firstblock = memoryCard[card]->DEntry_FirstBlock(j);
|
2008-12-08 05:30:24 +00:00
|
|
|
if (firstblock == 0xFFFF) firstblock = 3; // to make firstblock -1
|
2008-12-10 02:41:55 +00:00
|
|
|
wxFirstBlock.Printf(wxT("%15d"), firstblock-4);
|
2008-12-08 05:30:24 +00:00
|
|
|
m_MemcardList[card]->SetItem(index,COLUMN_FIRSTBLOCK, wxFirstBlock);
|
|
|
|
m_MemcardList[card]->SetItem(index, COLUMN_ICON, wxEmptyString);
|
|
|
|
|
|
|
|
if (images[j] >= 0)
|
|
|
|
{
|
|
|
|
m_MemcardList[card]->SetItemImage(index, images[j*2]);
|
|
|
|
m_MemcardList[card]->SetItemColumnImage(index, COLUMN_ICON, images[j*2+1]);
|
|
|
|
}
|
2009-01-15 06:06:30 +00:00
|
|
|
#ifdef DEBUG_MCM
|
|
|
|
char gC[5];
|
|
|
|
if (!memoryCard[card]->DEntry_GameCode(j, gC)) gC[0]=0;
|
|
|
|
m_MemcardList[card]->SetItem(index, COLUMN_GAMECODE, wxString::FromAscii(gC));
|
|
|
|
|
|
|
|
char mC[3];
|
|
|
|
if (!memoryCard[card]->DEntry_Markercode(j, mC)) mC[0]=0;
|
|
|
|
m_MemcardList[card]->SetItem(index, COLUMN_MAKERCODE, wxString::FromAscii(mC));
|
|
|
|
|
|
|
|
char bI[9];
|
|
|
|
if (!memoryCard[card]->DEntry_BIFlags(j, bI)) bI[0]=0;
|
|
|
|
m_MemcardList[card]->SetItem(index, COLUMN_BIFLAGS, wxString::FromAscii(bI));
|
|
|
|
|
|
|
|
char fN[32];
|
|
|
|
if (!memoryCard[card]->DEntry_FileName(j, fN)) fN[0]=0;
|
|
|
|
m_MemcardList[card]->SetItem(index, COLUMN_FILENAME, wxString::FromAscii(fN));
|
|
|
|
|
|
|
|
tString.Printf(wxT("%04X"), memoryCard[card]->DEntry_ModTime(j));
|
|
|
|
m_MemcardList[card]->SetItem(index, COLUMN_MODTIME, tString);
|
|
|
|
|
|
|
|
tString.Printf(wxT("%04X"), memoryCard[card]->DEntry_ImageOffset(j));
|
|
|
|
m_MemcardList[card]->SetItem(index, COLUMN_IMAGEADD, tString);
|
|
|
|
|
2009-02-22 03:23:48 +00:00
|
|
|
char iF[17];
|
|
|
|
if (!memoryCard[card]->DEntry_IconFmt(j, iF)) iF[0]=0;
|
|
|
|
m_MemcardList[card]->SetItem(index, COLUMN_ICONFMT, wxString::FromAscii(iF));
|
2009-01-15 06:06:30 +00:00
|
|
|
|
|
|
|
tString.Printf(wxT("%02X"), memoryCard[card]->DEntry_AnimSpeed(j));
|
|
|
|
m_MemcardList[card]->SetItem(index, COLUMN_ANIMSPEED, tString);
|
|
|
|
|
|
|
|
char per[40];
|
|
|
|
if (!memoryCard[card]->DEntry_Permissions(j, per)) per[0]=0;
|
|
|
|
m_MemcardList[card]->SetItem(index, COLUMN_PERMISSIONS, wxString::FromAscii(per));
|
|
|
|
|
|
|
|
tString.Printf(wxT("%0X"), memoryCard[card]->DEntry_CopyCounter(j));
|
|
|
|
m_MemcardList[card]->SetItem(index, COLUMN_COPYCOUNTER, tString);
|
|
|
|
|
|
|
|
tString.Printf(wxT("%04X"), memoryCard[card]->DEntry_CommentsAddress(j));
|
|
|
|
m_MemcardList[card]->SetItem(index, COLUMN_COMMENTSADDRESS, tString);
|
|
|
|
#endif
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
2008-12-10 02:41:55 +00:00
|
|
|
if (m_MemcardList[card]->usePages)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2008-12-10 02:41:55 +00:00
|
|
|
if ((j == nFiles))
|
|
|
|
{
|
2008-12-20 08:07:04 +00:00
|
|
|
m_NextPage[card]->Disable();
|
|
|
|
m_MemcardList[card]->nextPage = false;
|
2008-12-10 02:41:55 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-12-20 08:07:04 +00:00
|
|
|
m_NextPage[card]->Enable();
|
|
|
|
m_MemcardList[card]->nextPage = true;
|
2008-12-10 02:41:55 +00:00
|
|
|
}
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
delete[] images;
|
|
|
|
// Automatic column width and then show the list
|
2008-12-10 02:41:55 +00:00
|
|
|
for (int i = 0; i < NUMBER_OF_COLUMN; i++)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2008-12-10 02:41:55 +00:00
|
|
|
if (m_MemcardList[card]->column[i])
|
|
|
|
m_MemcardList[card]->SetColumnWidth(i, wxLIST_AUTOSIZE);
|
|
|
|
else
|
|
|
|
m_MemcardList[card]->SetColumnWidth(i, 0);
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
2008-12-10 02:41:55 +00:00
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
m_MemcardList[card]->Show();
|
|
|
|
wxLabel.Printf(wxT("%d Free Blocks; %d Free Dir Entries"),
|
2009-02-22 03:23:48 +00:00
|
|
|
memoryCard[card]->GetFreeBlocks(), DIRLEN - nFiles);
|
2008-12-20 08:07:04 +00:00
|
|
|
t_Status[card]->SetLabel(wxLabel);
|
2008-12-08 05:30:24 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-12-10 02:41:55 +00:00
|
|
|
void CMemcardManager::CMemcardListCtrl::OnRightClick(wxMouseEvent& event)
|
|
|
|
{
|
|
|
|
|
|
|
|
int flags;
|
|
|
|
long item = HitTest(event.GetPosition(), flags);
|
2009-01-15 06:06:30 +00:00
|
|
|
wxMenu popupMenu;
|
2008-12-10 02:41:55 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2009-02-22 03:23:48 +00:00
|
|
|
int slot = event.GetId() - ID_MEMCARDLIST_A;
|
2009-02-22 21:37:36 +00:00
|
|
|
popupMenu.Append(ID_COPYFROM_A + slot, wxString::Format(wxT("Copy to Memcard %c"), 'B' - slot));
|
2009-02-22 03:23:48 +00:00
|
|
|
popupMenu.Append(ID_DELETE_A + slot, wxT("Delete Save"));
|
|
|
|
popupMenu.Append(ID_SAVEIMPORT_A + slot, wxT("Import Save"));
|
|
|
|
popupMenu.Append(ID_SAVEEXPORT_A + slot, wxT("Export Save"));
|
|
|
|
popupMenu.Append(ID_EXPORTALL_A + slot, wxT("Export all saves"));
|
|
|
|
|
|
|
|
if (!twoCardsLoaded)
|
|
|
|
popupMenu.FindItem(ID_COPYFROM_A + slot)->Enable(false);
|
|
|
|
|
|
|
|
popupMenu.AppendSeparator();
|
|
|
|
|
|
|
|
popupMenu.Append(ID_FIXCHECKSUM_A + slot, wxT("Fix Checksums"));
|
|
|
|
popupMenu.Append(ID_PREVPAGE_A + slot, wxT("Previous Page"));
|
|
|
|
popupMenu.Append(ID_NEXTPAGE_A + slot, wxT("Next Page"));
|
2009-02-22 21:37:36 +00:00
|
|
|
popupMenu.Append(ID_MEMCARDPATH_A + slot, wxString::Format(wxT("Set as default Memcard %c"), 'A' + slot));
|
2009-02-22 03:23:48 +00:00
|
|
|
popupMenu.AppendCheckItem(ID_USEPAGES, wxT("Enable pages"));
|
|
|
|
|
|
|
|
if (!prevPage || !usePages)
|
|
|
|
popupMenu.FindItem(ID_PREVPAGE_A + slot)->Enable(false);
|
|
|
|
if (!nextPage || !usePages)
|
|
|
|
popupMenu.FindItem(ID_NEXTPAGE_A + slot)->Enable(false);
|
|
|
|
if(usePages)
|
|
|
|
popupMenu.FindItem(ID_USEPAGES)->Check();
|
|
|
|
|
|
|
|
popupMenu.AppendSeparator();
|
|
|
|
|
2009-01-15 06:06:30 +00:00
|
|
|
popupMenu.AppendCheckItem(COLUMN_BANNER, wxT("Show save banner"));
|
|
|
|
popupMenu.AppendCheckItem(COLUMN_TITLE, wxT("Show save title"));
|
|
|
|
popupMenu.AppendCheckItem(COLUMN_COMMENT, wxT("Show save comment"));
|
|
|
|
popupMenu.AppendCheckItem(COLUMN_ICON, wxT("Show save icon"));
|
|
|
|
popupMenu.AppendCheckItem(COLUMN_BLOCKS, wxT("Show save blocks"));
|
2009-02-22 03:23:48 +00:00
|
|
|
|
|
|
|
for (int i = COLUMN_BANNER; i <= COLUMN_BLOCKS; i++)
|
|
|
|
{
|
|
|
|
if (column[i]) popupMenu.FindItem(i)->Check();
|
|
|
|
}
|
2009-01-15 06:06:30 +00:00
|
|
|
#ifdef DEBUG_MCM
|
|
|
|
popupMenu.AppendCheckItem(NUMBER_OF_COLUMN, wxT("Debug Memcard"));
|
|
|
|
if (column[NUMBER_OF_COLUMN]) popupMenu.FindItem(NUMBER_OF_COLUMN)->Check();
|
|
|
|
#endif
|
2008-12-10 02:41:55 +00:00
|
|
|
}
|
2009-01-15 06:06:30 +00:00
|
|
|
PopupMenu(&popupMenu);
|
2008-12-10 02:41:55 +00:00
|
|
|
}
|