2013-04-17 21:43:35 -06:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2014-02-22 15:36:30 -07:00
|
|
|
#include <cstring>
|
|
|
|
#include <string>
|
|
|
|
#include <wx/bitmap.h>
|
|
|
|
#include <wx/button.h>
|
|
|
|
#include <wx/dialog.h>
|
|
|
|
#include <wx/filedlg.h>
|
|
|
|
#include <wx/filepicker.h>
|
|
|
|
#include <wx/image.h>
|
|
|
|
#include <wx/imaglist.h>
|
|
|
|
#include <wx/listbase.h>
|
|
|
|
#include <wx/menu.h>
|
2014-07-24 19:46:46 -06:00
|
|
|
#include <wx/msgdlg.h>
|
2014-02-17 03:18:15 -07:00
|
|
|
#include <wx/mstream.h>
|
2014-02-22 15:36:30 -07:00
|
|
|
#include <wx/sizer.h>
|
|
|
|
#include <wx/stattext.h>
|
2013-02-27 21:37:38 -07:00
|
|
|
|
2014-09-07 19:06:58 -06:00
|
|
|
#include "Common/CommonTypes.h"
|
2014-02-22 15:36:30 -07:00
|
|
|
#include "Common/FileUtil.h"
|
|
|
|
#include "Common/IniFile.h"
|
|
|
|
#include "Common/StringUtil.h"
|
|
|
|
#include "Core/HW/GCMemcard.h"
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "DolphinWX/MemcardManager.h"
|
|
|
|
#include "DolphinWX/WxUtils.h"
|
2009-03-01 00:15:10 -07:00
|
|
|
|
2014-05-17 11:17:28 -06:00
|
|
|
#define ARROWS slot ? "" : ARROW[slot], slot ? ARROW[slot] : ""
|
2009-02-21 20:23:48 -07:00
|
|
|
|
2008-12-07 22:30:24 -07:00
|
|
|
const u8 hdr[] = {
|
2015-02-15 12:43:31 -07:00
|
|
|
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
|
2008-12-07 22:30:24 -07:00
|
|
|
};
|
|
|
|
|
2014-07-08 06:29:26 -06:00
|
|
|
static wxBitmap wxBitmapFromMemoryRGBA(const unsigned char* data, u32 width, u32 height)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2013-01-13 21:42:18 -07:00
|
|
|
u32 stride = (4*width);
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2013-01-13 21:42:18 -07:00
|
|
|
u32 bytes = (stride*height) + sizeof(hdr);
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2015-02-15 12:43:31 -07:00
|
|
|
bytes = (bytes + 3)&(~3);
|
2008-12-07 22:30:24 -07:00
|
|
|
|
|
|
|
u8 *pdata = new u8[bytes];
|
|
|
|
|
2015-02-15 12:43:31 -07:00
|
|
|
memcpy(pdata, hdr, sizeof(hdr));
|
|
|
|
memset(pdata + sizeof(hdr), 0, bytes - sizeof(hdr));
|
2008-12-07 22:30:24 -07:00
|
|
|
|
|
|
|
u8 *pixelData = pdata + sizeof(hdr);
|
|
|
|
|
2015-02-15 12:43:31 -07:00
|
|
|
for (u32 y = 0; y < height; y++)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2015-02-15 12:43:31 -07:00
|
|
|
memcpy(pixelData + y*stride, data + (height - y - 1)*stride, stride);
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
2015-02-15 12:43:31 -07:00
|
|
|
*(u32*)(pdata + 18) = width;
|
|
|
|
*(u32*)(pdata + 22) = height;
|
|
|
|
*(u32*)(pdata + 34) = bytes - sizeof(hdr);
|
2008-12-07 22:30:24 -07:00
|
|
|
|
|
|
|
wxMemoryInputStream is(pdata, bytes);
|
|
|
|
wxBitmap map(wxImage(is, wxBITMAP_TYPE_BMP, -1), -1);
|
|
|
|
|
2015-02-15 12:43:31 -07:00
|
|
|
delete[] pdata;
|
2008-12-07 22:30:24 -07:00
|
|
|
|
|
|
|
return map;
|
|
|
|
}
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE(CMemcardManager, wxDialog)
|
2008-12-13 04:30:00 -07:00
|
|
|
EVT_BUTTON(ID_COPYFROM_A,CMemcardManager::CopyDeleteClick)
|
|
|
|
EVT_BUTTON(ID_COPYFROM_B,CMemcardManager::CopyDeleteClick)
|
2008-12-09 19:41:55 -07:00
|
|
|
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-07 22:30:24 -07:00
|
|
|
EVT_BUTTON(ID_CONVERTTOGCI,CMemcardManager::CopyDeleteClick)
|
2008-12-09 19:41:55 -07: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 00:14:37 -07:00
|
|
|
|
2008-12-20 11:43:52 -07:00
|
|
|
EVT_MENU_RANGE(ID_MEMCARDPATH_A, ID_USEPAGES, CMemcardManager::OnMenuChange)
|
2008-12-13 04:30:00 -07:00
|
|
|
EVT_MENU_RANGE(ID_COPYFROM_A, ID_CONVERTTOGCI, CMemcardManager::CopyDeleteClick)
|
2008-12-12 00:14:37 -07:00
|
|
|
EVT_MENU_RANGE(ID_NEXTPAGE_A, ID_PREVPAGE_B, CMemcardManager::OnPageChange)
|
|
|
|
EVT_MENU_RANGE(COLUMN_BANNER, NUMBER_OF_COLUMN, CMemcardManager::OnMenuChange)
|
2008-12-09 19:41:55 -07:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
2008-12-07 22:30:24 -07:00
|
|
|
CMemcardManager::CMemcardManager(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& position, const wxSize& size, long style)
|
|
|
|
: wxDialog(parent, id, title, position, size, style)
|
|
|
|
{
|
2015-02-15 12:43:31 -07:00
|
|
|
memoryCard[SLOT_A] = nullptr;
|
|
|
|
memoryCard[SLOT_B] = nullptr;
|
2010-12-10 00:11:05 -07:00
|
|
|
|
2011-12-09 15:58:58 -07:00
|
|
|
mcmSettings.twoCardsLoaded = false;
|
2010-12-10 00:11:05 -07:00
|
|
|
if (!LoadSettings())
|
2008-12-09 19:41:55 -07:00
|
|
|
{
|
2010-12-10 00:11:05 -07:00
|
|
|
itemsPerPage = 16;
|
|
|
|
mcmSettings.usePages = true;
|
2011-02-05 18:56:45 -07:00
|
|
|
for (int i = COLUMN_BANNER; i < NUMBER_OF_COLUMN; i++)
|
2010-12-10 00:11:05 -07:00
|
|
|
{
|
2015-02-15 12:43:31 -07:00
|
|
|
mcmSettings.column[i] = (i <= COLUMN_FIRSTBLOCK) ? true : false;
|
2010-12-10 00:11:05 -07:00
|
|
|
}
|
2008-12-09 19:41:55 -07:00
|
|
|
}
|
|
|
|
maxPages = (128 / itemsPerPage) - 1;
|
2008-12-07 22:30:24 -07:00
|
|
|
CreateGUIControls();
|
|
|
|
}
|
|
|
|
|
|
|
|
CMemcardManager::~CMemcardManager()
|
|
|
|
{
|
2008-12-09 19:41:55 -07:00
|
|
|
if (memoryCard[SLOT_A])
|
|
|
|
{
|
|
|
|
delete memoryCard[SLOT_A];
|
2014-03-09 14:14:26 -06:00
|
|
|
memoryCard[SLOT_A] = nullptr;
|
2008-12-09 19:41:55 -07:00
|
|
|
}
|
|
|
|
if (memoryCard[SLOT_B])
|
|
|
|
{
|
|
|
|
delete memoryCard[SLOT_B];
|
2014-03-09 14:14:26 -06:00
|
|
|
memoryCard[SLOT_B] = nullptr;
|
2008-12-09 19:41:55 -07:00
|
|
|
}
|
2010-12-10 00:11:05 -07:00
|
|
|
SaveSettings();
|
2008-12-09 19:41:55 -07:00
|
|
|
}
|
|
|
|
|
2010-12-10 00:11:05 -07:00
|
|
|
bool CMemcardManager::LoadSettings()
|
2008-12-09 19:41:55 -07:00
|
|
|
{
|
2010-02-02 14:56:29 -07:00
|
|
|
if (MemcardManagerIni.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX)))
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2010-12-10 00:11:05 -07:00
|
|
|
iniMemcardSection = MemcardManagerIni.GetOrCreateSection("MemcardManager");
|
|
|
|
iniMemcardSection->Get("Items per page", &itemsPerPage, 16);
|
|
|
|
iniMemcardSection->Get("DefaultMemcardA", &(DefaultMemcard[SLOT_A]), "");
|
|
|
|
iniMemcardSection->Get("DefaultMemcardB", &(DefaultMemcard[SLOT_B]), "");
|
|
|
|
iniMemcardSection->Get("DefaultIOFolder", &DefaultIOPath, "/Users/GC");
|
|
|
|
|
|
|
|
iniMemcardSection->Get("Use Pages", &mcmSettings.usePages, true);
|
|
|
|
iniMemcardSection->Get("cBanner", &mcmSettings.column[COLUMN_BANNER], true);
|
|
|
|
iniMemcardSection->Get("cTitle", &mcmSettings.column[COLUMN_TITLE], true);
|
|
|
|
iniMemcardSection->Get("cComment", &mcmSettings.column[COLUMN_COMMENT], true);
|
|
|
|
iniMemcardSection->Get("cIcon", &mcmSettings.column[COLUMN_ICON], true);
|
|
|
|
iniMemcardSection->Get("cBlocks", &mcmSettings.column[COLUMN_BLOCKS], true);
|
|
|
|
iniMemcardSection->Get("cFirst Block", &mcmSettings.column[COLUMN_FIRSTBLOCK], true);
|
|
|
|
|
|
|
|
mcmSettings.column[NUMBER_OF_COLUMN] = false;
|
|
|
|
|
2014-03-10 05:30:55 -06:00
|
|
|
for (int i = COLUMN_GAMECODE; i < NUMBER_OF_COLUMN; i++)
|
2009-01-14 23:06:30 -07:00
|
|
|
{
|
2010-12-10 00:11:05 -07:00
|
|
|
mcmSettings.column[i] = mcmSettings.column[NUMBER_OF_COLUMN];
|
2009-01-14 23:06:30 -07:00
|
|
|
}
|
2010-12-10 00:11:05 -07:00
|
|
|
return true;
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
2010-12-10 00:11:05 -07:00
|
|
|
return false;
|
2008-12-09 19:41:55 -07:00
|
|
|
}
|
|
|
|
|
2010-12-10 00:11:05 -07:00
|
|
|
bool CMemcardManager::SaveSettings()
|
2008-12-09 19:41:55 -07:00
|
|
|
{
|
2010-02-02 14:56:29 -07:00
|
|
|
MemcardManagerIni.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX));
|
2010-12-10 00:11:05 -07:00
|
|
|
iniMemcardSection = MemcardManagerIni.GetOrCreateSection("MemcardManager");
|
|
|
|
iniMemcardSection->Set("Items per page", itemsPerPage, 16);
|
|
|
|
iniMemcardSection->Set("DefaultMemcardA", DefaultMemcard[SLOT_A], "");
|
|
|
|
iniMemcardSection->Set("DefaultMemcardB", DefaultMemcard[SLOT_B], "");
|
|
|
|
|
|
|
|
iniMemcardSection->Set("Use Pages", mcmSettings.usePages, true);
|
|
|
|
iniMemcardSection->Set("cBanner", mcmSettings.column[COLUMN_BANNER], true);
|
|
|
|
iniMemcardSection->Set("cTitle", mcmSettings.column[COLUMN_TITLE], true);
|
|
|
|
iniMemcardSection->Set("cComment", mcmSettings.column[COLUMN_COMMENT], true);
|
2014-02-16 21:51:41 -07:00
|
|
|
iniMemcardSection->Set("cIcon", mcmSettings.column[COLUMN_ICON], true);
|
2010-12-10 00:11:05 -07:00
|
|
|
iniMemcardSection->Set("cBlocks", mcmSettings.column[COLUMN_BLOCKS], true);
|
|
|
|
iniMemcardSection->Set("cFirst Block", mcmSettings.column[COLUMN_FIRSTBLOCK], true);
|
|
|
|
|
|
|
|
return MemcardManagerIni.Save(File::GetUserPath(F_DOLPHINCONFIG_IDX));
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMemcardManager::CreateGUIControls()
|
|
|
|
{
|
2008-12-09 19:41:55 -07:00
|
|
|
// Create the controls for both memcards
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2014-05-17 11:17:28 -06:00
|
|
|
const char* ARROW[2] = { "<-", "->" };
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2011-01-04 21:35:46 -07:00
|
|
|
m_ConvertToGci = new wxButton(this, ID_CONVERTTOGCI, _("Convert to GCI"));
|
2011-03-16 22:26:01 -06:00
|
|
|
|
|
|
|
wxStaticBoxSizer *sMemcard[2];
|
2013-10-28 23:23:17 -06:00
|
|
|
|
2011-02-05 18:56:45 -07:00
|
|
|
for (int slot = SLOT_A; slot <= SLOT_B; slot++)
|
2009-02-21 20:23:48 -07:00
|
|
|
{
|
2014-02-16 21:51:41 -07:00
|
|
|
m_CopyFrom[slot] = new wxButton(this, ID_COPYFROM_A + slot,
|
2011-01-05 10:56:08 -07:00
|
|
|
wxString::Format(_("%1$sCopy%1$s"), ARROW[slot ? 0 : 1]));
|
2014-02-16 21:51:41 -07:00
|
|
|
m_SaveImport[slot] = new wxButton(this, ID_SAVEIMPORT_A + slot,
|
2011-01-05 10:56:08 -07:00
|
|
|
wxString::Format(_("%sImport GCI%s"), ARROWS));
|
2014-02-16 21:51:41 -07:00
|
|
|
m_SaveExport[slot] = new wxButton(this, ID_SAVEEXPORT_A + slot,
|
2011-01-05 10:56:08 -07:00
|
|
|
wxString::Format(_("%sExport GCI%s"), ARROWS));
|
2014-02-16 21:51:41 -07:00
|
|
|
m_Delete[slot] = new wxButton(this, ID_DELETE_A + slot,
|
2011-01-05 10:56:08 -07:00
|
|
|
wxString::Format(_("%sDelete%s"), ARROWS));
|
2009-02-21 20:23:48 -07:00
|
|
|
|
|
|
|
|
2011-01-04 21:35:46 -07:00
|
|
|
m_PrevPage[slot] = new wxButton(this, ID_PREVPAGE_A + slot, _("Prev Page"));
|
|
|
|
m_NextPage[slot] = new wxButton(this, ID_NEXTPAGE_A + slot, _("Next Page"));
|
2009-02-21 20:23:48 -07:00
|
|
|
|
2015-02-15 12:43:31 -07:00
|
|
|
t_Status[slot] = new wxStaticText(this, 0, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString);
|
2009-02-21 20:23:48 -07:00
|
|
|
|
2011-03-16 22:26:01 -06:00
|
|
|
wxBoxSizer * const sPages = new wxBoxSizer(wxHORIZONTAL);
|
2015-02-15 12:43:31 -07:00
|
|
|
sPages->Add(m_PrevPage[slot], 0, wxEXPAND | wxALL, 1);
|
|
|
|
sPages->Add(t_Status[slot], 0, wxEXPAND | wxALL, 5);
|
2011-03-16 22:26:01 -06:00
|
|
|
sPages->Add(0, 0, 1, wxEXPAND|wxALL, 0);
|
2015-02-15 12:43:31 -07:00
|
|
|
sPages->Add(m_NextPage[slot], 0, wxEXPAND | wxALL, 1);
|
2009-02-21 20:23:48 -07:00
|
|
|
|
2010-02-02 14:56:29 -07:00
|
|
|
m_MemcardPath[slot] = new wxFilePickerCtrl(this, ID_MEMCARDPATH_A + slot,
|
2013-03-02 19:34:53 -07:00
|
|
|
StrToWxStr(File::GetUserPath(D_GCUSER_IDX)), _("Choose a memory card:"),
|
2015-02-15 12:43:31 -07:00
|
|
|
_("GameCube Memory Cards (*.raw,*.gcp)") + wxString("|*.raw;*.gcp"), wxDefaultPosition, wxDefaultSize, wxFLP_USE_TEXTCTRL | wxFLP_OPEN);
|
2013-10-28 23:23:17 -06:00
|
|
|
|
2015-02-15 12:43:31 -07:00
|
|
|
m_MemcardList[slot] = new CMemcardListCtrl(this, ID_MEMCARDLIST_A + slot, wxDefaultPosition, wxSize(350, 400),
|
2010-12-10 00:11:05 -07:00
|
|
|
wxLC_REPORT | wxSUNKEN_BORDER | wxLC_ALIGN_LEFT | wxLC_SINGLE_SEL, mcmSettings);
|
2013-10-28 23:23:17 -06:00
|
|
|
|
2015-02-15 12:43:31 -07:00
|
|
|
m_MemcardList[slot]->AssignImageList(new wxImageList(96, 32), wxIMAGE_LIST_SMALL);
|
2009-02-21 20:23:48 -07:00
|
|
|
|
2014-05-17 11:17:28 -06:00
|
|
|
sMemcard[slot] = new wxStaticBoxSizer(wxVERTICAL, this, _("Memory Card") + wxString::Format(" %c", 'A' + slot));
|
2015-02-15 12:43:31 -07: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, 0, wxEXPAND | wxALL, 1);
|
2009-02-21 20:23:48 -07:00
|
|
|
}
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2011-03-16 22:26:01 -06:00
|
|
|
wxBoxSizer * const sButtons = new wxBoxSizer(wxVERTICAL);
|
2008-12-07 22:30:24 -07:00
|
|
|
sButtons->AddStretchSpacer(2);
|
2015-02-15 12:43:31 -07:00
|
|
|
sButtons->Add(m_CopyFrom[SLOT_B], 0, wxEXPAND, 5);
|
|
|
|
sButtons->Add(m_CopyFrom[SLOT_A], 0, wxEXPAND, 5);
|
2008-12-07 22:30:24 -07:00
|
|
|
sButtons->AddStretchSpacer(1);
|
2008-12-20 01:07:04 -07:00
|
|
|
sButtons->Add(m_SaveImport[SLOT_A], 0, wxEXPAND, 5);
|
|
|
|
sButtons->Add(m_SaveExport[SLOT_A], 0, wxEXPAND, 5);
|
2008-12-07 22:30:24 -07:00
|
|
|
sButtons->AddStretchSpacer(1);
|
2015-02-15 12:43:31 -07:00
|
|
|
sButtons->Add(m_ConvertToGci, 0, wxEXPAND, 5);
|
2008-12-07 22:30:24 -07:00
|
|
|
sButtons->AddStretchSpacer(1);
|
2008-12-20 01:07:04 -07:00
|
|
|
sButtons->Add(m_SaveImport[SLOT_B], 0, wxEXPAND, 5);
|
|
|
|
sButtons->Add(m_SaveExport[SLOT_B], 0, wxEXPAND, 5);
|
2008-12-07 22:30:24 -07:00
|
|
|
sButtons->AddStretchSpacer(1);
|
2015-02-15 12:43:31 -07:00
|
|
|
sButtons->Add(m_Delete[SLOT_A], 0, wxEXPAND, 5);
|
|
|
|
sButtons->Add(m_Delete[SLOT_B], 0, wxEXPAND, 5);
|
2011-03-16 22:26:01 -06:00
|
|
|
sButtons->AddStretchSpacer();
|
|
|
|
sButtons->Add(new wxButton(this, wxID_OK, _("Close")), 0, wxEXPAND, 5);
|
|
|
|
sButtons->AddStretchSpacer();
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2011-03-16 22:26:01 -06:00
|
|
|
wxBoxSizer * const sMain = new wxBoxSizer(wxHORIZONTAL);
|
2015-02-15 12:43:31 -07:00
|
|
|
sMain->Add(sMemcard[SLOT_A], 1, wxEXPAND | wxALL, 5);
|
2008-12-07 22:30:24 -07:00
|
|
|
sMain->Add(sButtons, 0, wxEXPAND, 0);
|
2015-02-15 12:43:31 -07:00
|
|
|
sMain->Add(sMemcard[SLOT_B], 1, wxEXPAND | wxALL, 5);
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2011-03-16 22:26:01 -06:00
|
|
|
SetSizerAndFit(sMain);
|
2010-02-24 23:12:35 -07:00
|
|
|
Center();
|
2009-02-21 20:23:48 -07:00
|
|
|
|
2011-02-05 18:56:45 -07:00
|
|
|
for (int i = SLOT_A; i <= SLOT_B; i++)
|
2008-12-20 01:47:38 -07:00
|
|
|
{
|
|
|
|
m_PrevPage[i]->Disable();
|
|
|
|
m_NextPage[i]->Disable();
|
|
|
|
m_CopyFrom[i]->Disable();
|
|
|
|
m_SaveImport[i]->Disable();
|
|
|
|
m_SaveExport[i]->Disable();
|
|
|
|
m_Delete[i]->Disable();
|
2010-12-10 00:11:05 -07:00
|
|
|
if (DefaultMemcard[i].length())
|
2008-12-20 01:47:38 -07:00
|
|
|
{
|
2013-03-02 19:34:53 -07:00
|
|
|
m_MemcardPath[i]->SetPath(StrToWxStr(DefaultMemcard[i]));
|
2010-12-10 00:11:05 -07:00
|
|
|
ChangePath(i);
|
2008-12-20 01:47:38 -07:00
|
|
|
}
|
|
|
|
}
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMemcardManager::OnPathChange(wxFileDirPickerEvent& event)
|
2008-12-20 01:47:38 -07:00
|
|
|
{
|
2010-12-10 00:11:05 -07:00
|
|
|
ChangePath(event.GetId() - ID_MEMCARDPATH_A);
|
2008-12-20 01:47:38 -07:00
|
|
|
}
|
|
|
|
|
2010-12-10 00:11:05 -07:00
|
|
|
void CMemcardManager::ChangePath(int slot)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2010-12-10 00:11:05 -07:00
|
|
|
int slot2 = (slot == SLOT_A) ? SLOT_B : SLOT_A;
|
|
|
|
page[slot] = FIRSTPAGE;
|
|
|
|
if (mcmSettings.usePages && m_PrevPage[slot]->IsEnabled())
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2010-12-10 00:11:05 -07:00
|
|
|
m_PrevPage[slot]->Disable();
|
|
|
|
m_MemcardList[slot]->prevPage = false;
|
|
|
|
}
|
2011-12-09 15:58:58 -07:00
|
|
|
if (!m_MemcardPath[SLOT_A]->GetPath().CmpNoCase(m_MemcardPath[SLOT_B]->GetPath()))
|
2010-12-10 00:11:05 -07:00
|
|
|
{
|
2014-03-10 05:30:55 -06:00
|
|
|
if (m_MemcardPath[slot]->GetPath().length())
|
2014-07-24 19:46:46 -06:00
|
|
|
wxMessageBox(_("Memcard already opened"));
|
2010-12-10 00:11:05 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-03-12 13:33:41 -06:00
|
|
|
if (m_MemcardPath[slot]->GetPath().length() && ReloadMemcard(WxStrToStr(m_MemcardPath[slot]->GetPath()), slot))
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2011-12-09 15:58:58 -07:00
|
|
|
if (memoryCard[slot2])
|
|
|
|
{
|
|
|
|
mcmSettings.twoCardsLoaded = true;
|
|
|
|
}
|
2008-12-20 01:07:04 -07:00
|
|
|
m_SaveImport[slot]->Enable();
|
|
|
|
m_SaveExport[slot]->Enable();
|
|
|
|
m_Delete[slot]->Enable();
|
2008-12-13 04:30:00 -07:00
|
|
|
}
|
2010-12-10 00:11:05 -07:00
|
|
|
else
|
2008-12-09 19:41:55 -07:00
|
|
|
{
|
2010-12-10 00:11:05 -07:00
|
|
|
if (memoryCard[slot])
|
|
|
|
{
|
|
|
|
delete memoryCard[slot];
|
2014-03-09 14:14:26 -06:00
|
|
|
memoryCard[slot] = nullptr;
|
2010-12-10 00:11:05 -07:00
|
|
|
}
|
|
|
|
mcmSettings.twoCardsLoaded = false;
|
|
|
|
m_MemcardPath[slot]->SetPath(wxEmptyString);
|
|
|
|
m_MemcardList[slot]->ClearAll();
|
|
|
|
t_Status[slot]->SetLabel(wxEmptyString);
|
|
|
|
m_SaveImport[slot]->Disable();
|
|
|
|
m_SaveExport[slot]->Disable();
|
|
|
|
m_Delete[slot]->Disable();
|
|
|
|
if (mcmSettings.usePages)
|
|
|
|
{
|
|
|
|
m_PrevPage[slot]->Disable();
|
|
|
|
m_NextPage[slot]->Disable();
|
|
|
|
}
|
2008-12-09 19:41:55 -07:00
|
|
|
}
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
2011-12-09 15:58:58 -07:00
|
|
|
|
|
|
|
m_CopyFrom[SLOT_A]->Enable(mcmSettings.twoCardsLoaded);
|
|
|
|
m_CopyFrom[SLOT_B]->Enable(mcmSettings.twoCardsLoaded);
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMemcardManager::OnPageChange(wxCommandEvent& event)
|
|
|
|
{
|
2008-12-20 01:07:04 -07:00
|
|
|
int slot = SLOT_B;
|
2008-12-07 22:30:24 -07:00
|
|
|
switch (event.GetId())
|
|
|
|
{
|
2008-12-09 19:41:55 -07:00
|
|
|
case ID_NEXTPAGE_A:
|
2008-12-20 01:07:04 -07:00
|
|
|
slot = SLOT_A;
|
2008-12-09 19:41:55 -07:00
|
|
|
case ID_NEXTPAGE_B:
|
2008-12-20 01:07:04 -07:00
|
|
|
if (!m_PrevPage[slot]->IsEnabled())
|
2008-12-09 19:41:55 -07:00
|
|
|
{
|
2008-12-20 01:07:04 -07:00
|
|
|
m_PrevPage[slot]->Enable();
|
|
|
|
m_MemcardList[slot]->prevPage = true;
|
2008-12-09 19:41:55 -07:00
|
|
|
}
|
2008-12-20 01:07:04 -07:00
|
|
|
page[slot]++;
|
|
|
|
if (page[slot] == maxPages)
|
2008-12-09 19:41:55 -07:00
|
|
|
{
|
2008-12-20 01:07:04 -07:00
|
|
|
m_NextPage[slot]->Disable();
|
|
|
|
m_MemcardList[slot]->nextPage = false;
|
2008-12-09 19:41:55 -07:00
|
|
|
}
|
2014-03-12 13:33:41 -06:00
|
|
|
ReloadMemcard(WxStrToStr(m_MemcardPath[slot]->GetPath()), slot);
|
2008-12-07 22:30:24 -07:00
|
|
|
break;
|
2008-12-09 19:41:55 -07:00
|
|
|
case ID_PREVPAGE_A:
|
2008-12-20 01:07:04 -07:00
|
|
|
slot = SLOT_A;
|
2008-12-09 19:41:55 -07:00
|
|
|
case ID_PREVPAGE_B:
|
2008-12-20 01:07:04 -07:00
|
|
|
if (!m_NextPage[slot]->IsEnabled())
|
2008-12-09 19:41:55 -07:00
|
|
|
{
|
2008-12-20 01:07:04 -07:00
|
|
|
m_NextPage[slot]->Enable();
|
|
|
|
m_MemcardList[slot]->nextPage = true;
|
2008-12-09 19:41:55 -07:00
|
|
|
}
|
2008-12-20 01:07:04 -07:00
|
|
|
page[slot]--;
|
|
|
|
if (!page[slot])
|
2008-12-09 19:41:55 -07:00
|
|
|
{
|
2008-12-20 01:07:04 -07:00
|
|
|
m_PrevPage[slot]->Disable();
|
|
|
|
m_MemcardList[slot]->prevPage = false;
|
2008-12-09 19:41:55 -07:00
|
|
|
}
|
2014-03-12 13:33:41 -06:00
|
|
|
ReloadMemcard(WxStrToStr(m_MemcardPath[slot]->GetPath()), slot);
|
2008-12-07 22:30:24 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-09 19:41:55 -07:00
|
|
|
void CMemcardManager::OnMenuChange(wxCommandEvent& event)
|
|
|
|
{
|
2010-12-10 00:11:05 -07:00
|
|
|
int _id = event.GetId();
|
2014-03-10 05:30:55 -06:00
|
|
|
switch (_id)
|
2008-12-09 19:41:55 -07:00
|
|
|
{
|
2010-12-10 00:11:05 -07:00
|
|
|
case ID_MEMCARDPATH_A:
|
|
|
|
case ID_MEMCARDPATH_B:
|
2013-02-27 21:37:38 -07:00
|
|
|
DefaultMemcard[_id - ID_MEMCARDPATH_A] = WxStrToStr(m_MemcardPath[_id - ID_MEMCARDPATH_A]->GetPath());
|
2010-12-10 00:11:05 -07:00
|
|
|
return;
|
2008-12-20 11:43:52 -07:00
|
|
|
case ID_USEPAGES:
|
2010-12-10 00:11:05 -07:00
|
|
|
mcmSettings.usePages = !mcmSettings.usePages;
|
|
|
|
if (!mcmSettings.usePages)
|
2008-12-09 19:41:55 -07:00
|
|
|
{
|
2008-12-20 01:07:04 -07:00
|
|
|
m_PrevPage[SLOT_A]->Disable();
|
|
|
|
m_PrevPage[SLOT_B]->Disable();
|
|
|
|
m_NextPage[SLOT_A]->Disable();
|
|
|
|
m_NextPage[SLOT_B]->Disable();
|
2010-12-10 00:11:05 -07:00
|
|
|
m_MemcardList[SLOT_A]->prevPage =
|
|
|
|
m_MemcardList[SLOT_B]->prevPage = false;
|
|
|
|
page[SLOT_A] =
|
|
|
|
page[SLOT_B] = FIRSTPAGE;
|
2008-12-09 19:41:55 -07:00
|
|
|
}
|
2008-12-20 11:43:52 -07:00
|
|
|
break;
|
2009-01-14 23:06:30 -07:00
|
|
|
case NUMBER_OF_COLUMN:
|
2010-12-10 00:11:05 -07:00
|
|
|
for (int i = COLUMN_GAMECODE; i <= NUMBER_OF_COLUMN; i++)
|
2009-01-14 23:06:30 -07:00
|
|
|
{
|
2010-12-10 00:11:05 -07:00
|
|
|
mcmSettings.column[i] = !mcmSettings.column[i];
|
2009-01-14 23:06:30 -07:00
|
|
|
}
|
2010-12-10 00:11:05 -07:00
|
|
|
break;
|
2008-12-20 11:43:52 -07:00
|
|
|
default:
|
2010-12-10 00:11:05 -07:00
|
|
|
mcmSettings.column[_id] = !mcmSettings.column[_id];
|
2008-12-20 11:43:52 -07:00
|
|
|
break;
|
2008-12-09 19:41:55 -07:00
|
|
|
}
|
2010-12-10 00:11:05 -07:00
|
|
|
|
2014-03-12 13:33:41 -06:00
|
|
|
if (memoryCard[SLOT_A]) ReloadMemcard(WxStrToStr(m_MemcardPath[SLOT_A]->GetPath()), SLOT_A);
|
|
|
|
if (memoryCard[SLOT_B]) ReloadMemcard(WxStrToStr(m_MemcardPath[SLOT_B]->GetPath()), SLOT_B);
|
2008-12-09 19:41:55 -07:00
|
|
|
}
|
2008-12-13 04:30:00 -07:00
|
|
|
bool CMemcardManager::CopyDeleteSwitch(u32 error, int slot)
|
|
|
|
{
|
|
|
|
switch (error)
|
|
|
|
{
|
|
|
|
case GCS:
|
2014-07-24 19:46:46 -06:00
|
|
|
wxMessageBox(_("File converted to .gci"));
|
2008-12-13 04:30:00 -07:00
|
|
|
break;
|
|
|
|
case SUCCESS:
|
|
|
|
if (slot != -1)
|
|
|
|
{
|
|
|
|
memoryCard[slot]->FixChecksums();
|
2014-05-17 11:17:28 -06:00
|
|
|
if (!memoryCard[slot]->Save()) PanicAlertT(E_SAVEFAILED);
|
2008-12-20 01:07:04 -07:00
|
|
|
page[slot] = FIRSTPAGE;
|
2014-03-12 13:33:41 -06:00
|
|
|
ReloadMemcard(WxStrToStr(m_MemcardPath[slot]->GetPath()), slot);
|
2008-12-13 04:30:00 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NOMEMCARD:
|
2014-07-24 19:46:46 -06:00
|
|
|
WxUtils::ShowErrorDialog(_("File is not recognized as a memcard"));
|
2008-12-13 04:30:00 -07:00
|
|
|
break;
|
|
|
|
case OPENFAIL:
|
2014-07-24 19:46:46 -06:00
|
|
|
WxUtils::ShowErrorDialog(_("File could not be opened\nor does not have a valid extension"));
|
2008-12-13 04:30:00 -07:00
|
|
|
break;
|
|
|
|
case OUTOFBLOCKS:
|
|
|
|
if (slot == -1)
|
|
|
|
{
|
2014-07-24 19:46:46 -06:00
|
|
|
WxUtils::ShowErrorDialog(_(E_UNK));
|
2008-12-13 04:30:00 -07:00
|
|
|
break;
|
|
|
|
}
|
2014-07-24 19:46:46 -06:00
|
|
|
wxMessageBox(wxString::Format(_("Only %d blocks available"), memoryCard[slot]->GetFreeBlocks()));
|
2008-12-13 04:30:00 -07:00
|
|
|
break;
|
|
|
|
case OUTOFDIRENTRIES:
|
2014-07-24 19:46:46 -06:00
|
|
|
WxUtils::ShowErrorDialog(_("No free directory index entries."));
|
2008-12-13 04:30:00 -07:00
|
|
|
break;
|
|
|
|
case LENGTHFAIL:
|
2014-07-24 19:46:46 -06:00
|
|
|
WxUtils::ShowErrorDialog(_("Imported file has invalid length."));
|
2008-12-13 04:30:00 -07:00
|
|
|
break;
|
|
|
|
case INVALIDFILESIZE:
|
2014-07-24 19:46:46 -06:00
|
|
|
WxUtils::ShowErrorDialog(_("The save you are trying to copy has an invalid file size."));
|
2008-12-13 04:30:00 -07:00
|
|
|
break;
|
|
|
|
case TITLEPRESENT:
|
2014-07-24 19:46:46 -06:00
|
|
|
WxUtils::ShowErrorDialog(_("Memcard already has a save for this title."));
|
2008-12-13 04:30:00 -07:00
|
|
|
break;
|
|
|
|
case SAVFAIL:
|
2014-07-24 19:46:46 -06:00
|
|
|
WxUtils::ShowErrorDialog(_("Imported file has sav extension\nbut does not have a correct header."));
|
2008-12-13 04:30:00 -07:00
|
|
|
break;
|
|
|
|
case GCSFAIL:
|
2014-07-24 19:46:46 -06:00
|
|
|
WxUtils::ShowErrorDialog(_("Imported file has gsc extension\nbut does not have a correct header."));
|
2008-12-13 04:30:00 -07:00
|
|
|
break;
|
|
|
|
case FAIL:
|
2009-01-14 23:06:30 -07:00
|
|
|
if (slot == -1)
|
|
|
|
{
|
2014-07-24 19:46:46 -06:00
|
|
|
WxUtils::ShowErrorDialog(_("Export failed"));
|
2009-01-14 23:06:30 -07:00
|
|
|
return false;
|
|
|
|
}
|
2014-07-24 19:46:46 -06:00
|
|
|
WxUtils::ShowErrorDialog(_("Invalid bat.map or dir entry."));
|
2008-12-13 04:30:00 -07:00
|
|
|
break;
|
|
|
|
case WRITEFAIL:
|
2014-07-24 19:46:46 -06:00
|
|
|
WxUtils::ShowErrorDialog(_(E_SAVEFAILED));
|
2008-12-13 04:30:00 -07:00
|
|
|
break;
|
2009-07-18 01:59:31 -06:00
|
|
|
case DELETE_FAIL:
|
2014-07-24 19:46:46 -06:00
|
|
|
WxUtils::ShowErrorDialog(_("Order of files in the File Directory do not match the block order\n"
|
|
|
|
"Right click and export all of the saves,\nand import the saves to a new memcard\n"));
|
2009-07-18 01:59:31 -06:00
|
|
|
break;
|
2008-12-13 04:30:00 -07:00
|
|
|
default:
|
2014-07-24 19:46:46 -06:00
|
|
|
WxUtils::ShowErrorDialog(_(E_UNK));
|
2008-12-13 04:30:00 -07:00
|
|
|
break;
|
|
|
|
}
|
2013-01-12 18:46:49 -07:00
|
|
|
SetFocus();
|
2008-12-13 04:30:00 -07:00
|
|
|
return true;
|
|
|
|
}
|
2008-12-09 19:41:55 -07:00
|
|
|
|
2008-12-07 22:30:24 -07:00
|
|
|
void CMemcardManager::CopyDeleteClick(wxCommandEvent& event)
|
|
|
|
{
|
2008-12-09 19:41:55 -07: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 04:30:00 -07:00
|
|
|
int slot2 = SLOT_A;
|
2008-12-07 22:30:24 -07:00
|
|
|
std::string fileName2("");
|
|
|
|
|
2008-12-20 01:07:04 -07: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-07 22:30:24 -07:00
|
|
|
|
2012-08-19 21:44:09 -06:00
|
|
|
int index = index_B;
|
2008-12-07 22:30:24 -07:00
|
|
|
switch (event.GetId())
|
|
|
|
{
|
2008-12-13 04:30:00 -07:00
|
|
|
case ID_COPYFROM_B:
|
|
|
|
slot = SLOT_A;
|
|
|
|
slot2 = SLOT_B;
|
|
|
|
case ID_COPYFROM_A:
|
|
|
|
index = slot2 ? index_B : index_A;
|
2011-12-09 16:02:05 -07:00
|
|
|
index = memoryCard[slot2]->GetFileIndex(index);
|
2008-12-13 04:30:00 -07:00
|
|
|
if ((index != wxNOT_FOUND))
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2008-12-13 04:30:00 -07:00
|
|
|
CopyDeleteSwitch(memoryCard[slot]->CopyFrom(*memoryCard[slot2], index), slot);
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
break;
|
2008-12-09 19:41:55 -07:00
|
|
|
case ID_FIXCHECKSUM_A:
|
|
|
|
slot = SLOT_A;
|
|
|
|
case ID_FIXCHECKSUM_B:
|
2008-12-13 04:30:00 -07:00
|
|
|
if (memoryCard[slot]->FixChecksums() && memoryCard[slot]->Save())
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2014-07-24 19:46:46 -06:00
|
|
|
wxMessageBox(_("The checksum was successfully fixed."));
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
2013-04-07 23:16:50 -06:00
|
|
|
else
|
|
|
|
{
|
2014-07-24 19:46:46 -06:00
|
|
|
WxUtils::ShowErrorDialog(_(E_SAVEFAILED));
|
2013-04-07 23:16:50 -06:00
|
|
|
}
|
2013-10-28 23:23:17 -06:00
|
|
|
break;
|
2008-12-07 22:30:24 -07:00
|
|
|
case ID_CONVERTTOGCI:
|
|
|
|
fileName2 = "convert";
|
2008-12-09 19:41:55 -07:00
|
|
|
case ID_SAVEIMPORT_A:
|
|
|
|
slot = SLOT_A;
|
|
|
|
case ID_SAVEIMPORT_B:
|
2008-12-13 04:30:00 -07:00
|
|
|
{
|
2010-07-23 17:50:09 -06:00
|
|
|
wxString fileName = wxFileSelector(
|
2011-01-04 21:35:46 -07:00
|
|
|
_("Select a save file to import"),
|
2010-07-23 17:50:09 -06:00
|
|
|
(strcmp(DefaultIOPath.c_str(), "/Users/GC") == 0)
|
2013-02-27 21:37:38 -07:00
|
|
|
? StrToWxStr("")
|
2013-03-02 19:34:53 -07:00
|
|
|
: StrToWxStr(DefaultIOPath),
|
2010-07-23 17:50:09 -06:00
|
|
|
wxEmptyString, wxEmptyString,
|
2014-05-17 11:17:28 -06:00
|
|
|
_("GameCube Savegame files(*.gci;*.gcs;*.sav)") + wxString("|*.gci;*.gcs;*.sav|") +
|
|
|
|
_("Native GCI files(*.gci)") + wxString("|*.gci|") +
|
|
|
|
_("MadCatz Gameshark files(*.gcs)") + wxString("|*.gcs|") +
|
|
|
|
_("Datel MaxDrive/Pro files(*.sav)") + wxString("|*.sav"),
|
2013-01-12 19:18:42 -07:00
|
|
|
wxFD_OPEN | wxFD_FILE_MUST_EXIST, this);
|
2009-08-07 02:52:04 -06:00
|
|
|
if (!fileName.empty() && !fileName2.empty())
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2011-01-06 06:57:46 -07:00
|
|
|
wxString temp2 = wxFileSelector(_("Save GCI as..."),
|
2014-05-17 11:17:28 -06:00
|
|
|
wxEmptyString, wxEmptyString, ".gci",
|
|
|
|
_("GCI File(*.gci)") + wxString("|*.gci"),
|
2015-02-15 12:43:31 -07:00
|
|
|
wxFD_OVERWRITE_PROMPT | wxFD_SAVE, this);
|
2013-04-07 23:16:50 -06:00
|
|
|
|
|
|
|
if (temp2.empty())
|
|
|
|
break;
|
|
|
|
|
2013-02-27 21:37:38 -07:00
|
|
|
fileName2 = WxStrToStr(temp2);
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
2009-08-07 02:52:04 -06:00
|
|
|
if (fileName.length() > 0)
|
2008-12-13 04:30:00 -07:00
|
|
|
{
|
2014-03-12 13:33:41 -06:00
|
|
|
CopyDeleteSwitch(memoryCard[slot]->ImportGci(WxStrToStr(fileName), fileName2), slot);
|
2008-12-13 04:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2008-12-09 19:41:55 -07:00
|
|
|
case ID_SAVEEXPORT_A:
|
2015-02-15 12:43:31 -07:00
|
|
|
slot = SLOT_A;
|
2008-12-09 19:41:55 -07:00
|
|
|
index = index_A;
|
|
|
|
case ID_SAVEEXPORT_B:
|
2011-12-09 16:02:05 -07:00
|
|
|
index = memoryCard[slot]->GetFileIndex(index);
|
2008-12-09 19:41:55 -07:00
|
|
|
if (index != wxNOT_FOUND)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2011-12-10 16:44:08 -07:00
|
|
|
std::string gciFilename;
|
|
|
|
if (!memoryCard[slot]->GCI_FileName(index, gciFilename))
|
|
|
|
{
|
2014-07-24 19:46:46 -06:00
|
|
|
wxMessageBox(_("Invalid index"), _("Error"));
|
2011-12-10 16:44:08 -07:00
|
|
|
return;
|
|
|
|
}
|
2010-07-23 17:50:09 -06:00
|
|
|
wxString fileName = wxFileSelector(
|
2011-01-06 06:57:46 -07:00
|
|
|
_("Export save as..."),
|
2013-03-02 19:34:53 -07:00
|
|
|
StrToWxStr(DefaultIOPath),
|
2014-05-17 11:17:28 -06:00
|
|
|
StrToWxStr(gciFilename), ".gci",
|
|
|
|
_("Native GCI files(*.gci)") + wxString("|*.gci|") +
|
|
|
|
_("MadCatz Gameshark files(*.gcs)") + wxString("|*.gcs|") +
|
|
|
|
_("Datel MaxDrive/Pro files(*.sav)") + wxString("|*.sav"),
|
2015-02-15 12:43:31 -07:00
|
|
|
wxFD_OVERWRITE_PROMPT | wxFD_SAVE, this);
|
2009-02-21 20:23:48 -07:00
|
|
|
|
2009-08-16 02:26:57 -06:00
|
|
|
if (fileName.length() > 0)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2014-03-12 13:33:41 -06:00
|
|
|
if (!CopyDeleteSwitch(memoryCard[slot]->ExportGci(index, WxStrToStr(fileName), ""), -1))
|
2009-02-21 20:23:48 -07:00
|
|
|
{
|
2013-02-27 21:37:38 -07:00
|
|
|
File::Delete(WxStrToStr(fileName));
|
2009-02-21 20:23:48 -07:00
|
|
|
}
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2009-02-21 20:23:48 -07:00
|
|
|
case ID_EXPORTALL_A:
|
2015-02-15 12:43:31 -07:00
|
|
|
slot = SLOT_A;
|
2009-02-21 20:23:48 -07:00
|
|
|
case ID_EXPORTALL_B:
|
|
|
|
{
|
2009-02-22 14:37:36 -07:00
|
|
|
std::string path1, path2, mpath;
|
2013-02-27 21:37:38 -07:00
|
|
|
mpath = WxStrToStr(m_MemcardPath[slot]->GetPath());
|
2014-03-09 14:14:26 -06:00
|
|
|
SplitPath(mpath, &path1, &path2, nullptr);
|
2009-02-21 20:23:48 -07:00
|
|
|
path1 += path2;
|
2011-02-28 20:06:14 -07:00
|
|
|
File::CreateDir(path1);
|
2014-07-24 19:46:46 -06:00
|
|
|
|
|
|
|
int answer = wxMessageBox(wxString::Format(_("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()), _("Warning"), wxYES_NO);
|
|
|
|
if (answer == wxYES)
|
2009-02-21 20:23:48 -07:00
|
|
|
{
|
2014-07-24 19:46:46 -06:00
|
|
|
for (int i = 0; i < DIRLEN; i++)
|
|
|
|
{
|
|
|
|
CopyDeleteSwitch(memoryCard[slot]->ExportGci(i, "", path1), -1);
|
|
|
|
}
|
2009-02-21 20:23:48 -07:00
|
|
|
}
|
2014-07-24 19:46:46 -06:00
|
|
|
|
2009-02-21 20:23:48 -07:00
|
|
|
break;
|
|
|
|
}
|
2008-12-09 19:41:55 -07:00
|
|
|
case ID_DELETE_A:
|
2008-12-23 00:20:22 -07:00
|
|
|
slot = SLOT_A;
|
2008-12-09 19:41:55 -07:00
|
|
|
index = index_A;
|
|
|
|
case ID_DELETE_B:
|
2011-12-09 16:02:05 -07:00
|
|
|
index = memoryCard[slot]->GetFileIndex(index);
|
2008-12-09 19:41:55 -07:00
|
|
|
if (index != wxNOT_FOUND)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2008-12-13 04:30:00 -07:00
|
|
|
CopyDeleteSwitch(memoryCard[slot]->RemoveFile(index), slot);
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-12 13:33:41 -06:00
|
|
|
bool CMemcardManager::ReloadMemcard(const std::string& fileName, int card)
|
2009-08-07 02:52:04 -06:00
|
|
|
{
|
2008-12-07 22:30:24 -07:00
|
|
|
if (memoryCard[card]) delete memoryCard[card];
|
|
|
|
|
|
|
|
// TODO: add error checking and animate icons
|
|
|
|
memoryCard[card] = new GCMemcard(fileName);
|
|
|
|
|
2013-04-07 23:16:50 -06:00
|
|
|
if (!memoryCard[card]->IsValid())
|
|
|
|
return false;
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2009-08-07 02:52:04 -06:00
|
|
|
int j;
|
|
|
|
|
|
|
|
wxString wxTitle,
|
|
|
|
wxComment,
|
|
|
|
wxBlock,
|
|
|
|
wxFirstBlock,
|
2011-12-10 16:44:08 -07:00
|
|
|
wxLabel;
|
2009-08-07 02:52:04 -06:00
|
|
|
|
|
|
|
|
2008-12-07 22:30:24 -07:00
|
|
|
m_MemcardList[card]->Hide();
|
|
|
|
m_MemcardList[card]->ClearAll();
|
2008-12-09 19:41:55 -07:00
|
|
|
|
2011-01-04 21:35:46 -07:00
|
|
|
m_MemcardList[card]->InsertColumn(COLUMN_BANNER, _("Banner"));
|
|
|
|
m_MemcardList[card]->InsertColumn(COLUMN_TITLE, _("Title"));
|
|
|
|
m_MemcardList[card]->InsertColumn(COLUMN_COMMENT, _("Comment"));
|
|
|
|
m_MemcardList[card]->InsertColumn(COLUMN_ICON, _("Icon"));
|
|
|
|
m_MemcardList[card]->InsertColumn(COLUMN_BLOCKS, _("Blocks"));
|
|
|
|
m_MemcardList[card]->InsertColumn(COLUMN_FIRSTBLOCK, _("First Block"));
|
2008-12-07 22:30:24 -07:00
|
|
|
|
|
|
|
wxImageList *list = m_MemcardList[card]->GetImageList(wxIMAGE_LIST_SMALL);
|
|
|
|
list->RemoveAll();
|
|
|
|
|
2011-12-09 16:02:05 -07:00
|
|
|
u8 nFiles = memoryCard[card]->GetNumFiles();
|
2015-02-15 12:43:31 -07:00
|
|
|
int *images = new int[nFiles * 2];
|
2008-12-09 19:41:55 -07:00
|
|
|
|
2015-02-15 12:43:31 -07:00
|
|
|
for (u8 i = 0; i < nFiles; i++)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
|
|
|
static u32 pxdata[96*32];
|
|
|
|
static u8 animDelay[8];
|
|
|
|
static u32 animData[32*32*8];
|
|
|
|
|
2011-12-09 16:02:05 -07:00
|
|
|
u8 fileIndex = memoryCard[card]->GetFileIndex(i);
|
|
|
|
int numFrames = memoryCard[card]->ReadAnimRGBA8(fileIndex, animData, animDelay);
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2011-12-09 16:02:05 -07:00
|
|
|
if (!memoryCard[card]->ReadBannerRGBA8(fileIndex, pxdata))
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2015-02-15 12:43:31 -07:00
|
|
|
memset(pxdata, 0, 96*32*4);
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2015-02-15 12:43:31 -07:00
|
|
|
if (numFrames > 0) // Just use the first one
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
|
|
|
u32 *icdata = animData;
|
|
|
|
|
2015-02-15 12:43:31 -07:00
|
|
|
for (int y = 0; y < 32; y++)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2015-02-15 12:43:31 -07:00
|
|
|
for (int x = 0; x < 32; x++)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2015-02-15 12:43:31 -07:00
|
|
|
pxdata[y*96 + x + 32] = icdata[y*32 + x];// | 0xFF000000
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-15 12:43:31 -07:00
|
|
|
wxBitmap map = wxBitmapFromMemoryRGBA((u8*)pxdata, 96, 32);
|
2008-12-07 22:30:24 -07:00
|
|
|
images[i*2] = list->Add(map);
|
|
|
|
|
2015-02-15 12:43:31 -07:00
|
|
|
if (numFrames > 0)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2015-02-15 12:43:31 -07:00
|
|
|
memset(pxdata, 0, 96*32*4);
|
|
|
|
int frames = 3;
|
2013-04-07 23:16:50 -06:00
|
|
|
|
2015-02-15 12:43:31 -07:00
|
|
|
if (numFrames < frames)
|
|
|
|
frames = numFrames;
|
2013-04-07 23:16:50 -06:00
|
|
|
|
2015-02-15 12:43:31 -07:00
|
|
|
for (int f = 0; f < frames; f++)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2015-02-15 12:43:31 -07:00
|
|
|
for (int y = 0; y < 32; y++)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2015-02-15 12:43:31 -07:00
|
|
|
for (int x = 0; x < 32; x++)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
|
|
|
pxdata[y*96 + x + 32*f] = animData[f*32*32 + y*32 + x];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-02-15 12:43:31 -07:00
|
|
|
wxBitmap icon = wxBitmapFromMemoryRGBA((u8*)pxdata, 96, 32);
|
|
|
|
images[i*2 + 1] = list->Add(icon);
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
}
|
2010-12-10 00:11:05 -07:00
|
|
|
|
2014-02-16 21:51:41 -07:00
|
|
|
int pagesMax = (mcmSettings.usePages) ?
|
2010-12-10 00:11:05 -07:00
|
|
|
(page[card] + 1) * itemsPerPage : 128;
|
|
|
|
|
|
|
|
for (j = page[card] * itemsPerPage; (j < nFiles) && (j < pagesMax); j++)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
|
|
|
u16 blocks;
|
|
|
|
u16 firstblock;
|
2011-12-09 16:02:05 -07:00
|
|
|
u8 fileIndex = memoryCard[card]->GetFileIndex(j);
|
|
|
|
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2008-12-09 19:41:55 -07:00
|
|
|
int index = m_MemcardList[card]->InsertItem(j, wxEmptyString);
|
|
|
|
|
2008-12-07 22:30:24 -07:00
|
|
|
m_MemcardList[card]->SetItem(index, COLUMN_BANNER, wxEmptyString);
|
2009-08-07 02:52:04 -06:00
|
|
|
|
2011-12-10 16:44:08 -07:00
|
|
|
std::string title = memoryCard[card]->GetSaveComment1(fileIndex);
|
|
|
|
std::string comment = memoryCard[card]->GetSaveComment2(fileIndex);
|
2009-08-07 02:52:04 -06:00
|
|
|
|
2013-03-03 01:30:45 -07:00
|
|
|
auto const string_decoder = memoryCard[card]->IsAsciiEncoding() ?
|
|
|
|
CP1252ToUTF8 : SHIFTJISToUTF8;
|
2013-10-28 23:23:17 -06:00
|
|
|
|
2013-03-03 01:30:45 -07:00
|
|
|
wxTitle = StrToWxStr(string_decoder(title));
|
|
|
|
wxComment = StrToWxStr(string_decoder(comment));
|
2010-01-12 23:34:34 -07:00
|
|
|
|
2009-08-07 02:52:04 -06:00
|
|
|
m_MemcardList[card]->SetItem(index, COLUMN_TITLE, wxTitle);
|
|
|
|
m_MemcardList[card]->SetItem(index, COLUMN_COMMENT, wxComment);
|
|
|
|
|
2011-12-09 16:02:05 -07:00
|
|
|
blocks = memoryCard[card]->DEntry_BlockCount(fileIndex);
|
2013-10-28 23:23:17 -06:00
|
|
|
|
2013-04-07 23:16:50 -06:00
|
|
|
if (blocks == 0xFFFF)
|
|
|
|
blocks = 0;
|
2013-10-28 23:23:17 -06:00
|
|
|
|
2014-05-17 11:17:28 -06:00
|
|
|
wxBlock.Printf("%10d", blocks);
|
2015-02-15 12:43:31 -07:00
|
|
|
m_MemcardList[card]->SetItem(index, COLUMN_BLOCKS, wxBlock);
|
2011-12-09 16:02:05 -07:00
|
|
|
firstblock = memoryCard[card]->DEntry_FirstBlock(fileIndex);
|
2014-02-16 21:51:41 -07:00
|
|
|
//if (firstblock == 0xFFFF) firstblock = 3; // to make firstblock -1
|
2014-05-17 11:17:28 -06:00
|
|
|
wxFirstBlock.Printf("%15d", firstblock);
|
2011-12-09 16:02:05 -07:00
|
|
|
m_MemcardList[card]->SetItem(index, COLUMN_FIRSTBLOCK, wxFirstBlock);
|
2008-12-07 22:30:24 -07:00
|
|
|
m_MemcardList[card]->SetItem(index, COLUMN_ICON, wxEmptyString);
|
|
|
|
|
|
|
|
if (images[j] >= 0)
|
|
|
|
{
|
|
|
|
m_MemcardList[card]->SetItemImage(index, images[j*2]);
|
2015-02-15 12:43:31 -07:00
|
|
|
m_MemcardList[card]->SetItemColumnImage(index, COLUMN_ICON, images[j*2 + 1]);
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-10 00:11:05 -07:00
|
|
|
if (mcmSettings.usePages)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2009-07-17 00:03:53 -06:00
|
|
|
if (nFiles <= itemsPerPage)
|
|
|
|
{
|
|
|
|
m_PrevPage[card]->Disable();
|
|
|
|
m_MemcardList[card]->prevPage = false;
|
|
|
|
}
|
|
|
|
if (j == nFiles)
|
2008-12-09 19:41:55 -07:00
|
|
|
{
|
2008-12-20 01:07:04 -07:00
|
|
|
m_NextPage[card]->Disable();
|
|
|
|
m_MemcardList[card]->nextPage = false;
|
2008-12-09 19:41:55 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-12-20 01:07:04 -07:00
|
|
|
m_NextPage[card]->Enable();
|
|
|
|
m_MemcardList[card]->nextPage = true;
|
2008-12-09 19:41:55 -07:00
|
|
|
}
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
delete[] images;
|
|
|
|
// Automatic column width and then show the list
|
2011-02-05 18:56:45 -07:00
|
|
|
for (int i = COLUMN_BANNER; i <= COLUMN_FIRSTBLOCK; i++)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2010-12-10 00:11:05 -07:00
|
|
|
if (mcmSettings.column[i])
|
2008-12-09 19:41:55 -07:00
|
|
|
m_MemcardList[card]->SetColumnWidth(i, wxLIST_AUTOSIZE);
|
|
|
|
else
|
|
|
|
m_MemcardList[card]->SetColumnWidth(i, 0);
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
2008-12-09 19:41:55 -07:00
|
|
|
|
2008-12-07 22:30:24 -07:00
|
|
|
m_MemcardList[card]->Show();
|
2011-02-05 18:56:45 -07:00
|
|
|
wxLabel.Printf(_("%u Free Blocks; %u Free Dir Entries"),
|
2009-02-21 20:23:48 -07:00
|
|
|
memoryCard[card]->GetFreeBlocks(), DIRLEN - nFiles);
|
2008-12-20 01:07:04 -07:00
|
|
|
t_Status[card]->SetLabel(wxLabel);
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2013-01-13 20:28:36 -07:00
|
|
|
// Done so text doesn't overlap the UI.
|
|
|
|
this->Fit();
|
|
|
|
|
2008-12-07 22:30:24 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-12-09 19:41:55 -07:00
|
|
|
void CMemcardManager::CMemcardListCtrl::OnRightClick(wxMouseEvent& event)
|
|
|
|
{
|
|
|
|
int flags;
|
|
|
|
long item = HitTest(event.GetPosition(), flags);
|
2014-11-11 07:50:11 -07:00
|
|
|
wxMenu popupMenu;
|
2008-12-09 19:41:55 -07:00
|
|
|
|
2013-10-28 23:23:17 -06:00
|
|
|
if (item != wxNOT_FOUND)
|
2008-12-09 19:41:55 -07:00
|
|
|
{
|
|
|
|
if (GetItemState(item, wxLIST_STATE_SELECTED) != wxLIST_STATE_SELECTED)
|
|
|
|
{
|
2015-02-15 12:43:31 -07:00
|
|
|
SetItemState(item, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
|
2008-12-09 19:41:55 -07:00
|
|
|
}
|
|
|
|
SetItemState(item, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED);
|
|
|
|
|
2010-12-10 00:11:05 -07:00
|
|
|
int slot = GetId() - ID_MEMCARDLIST_A;
|
2014-11-11 07:50:11 -07:00
|
|
|
popupMenu.Append(ID_COPYFROM_A + slot, wxString::Format(_("Copy to Memcard %c"), 'B' - slot));
|
|
|
|
popupMenu.Append(ID_DELETE_A + slot, _("Delete Save"));
|
|
|
|
popupMenu.Append(ID_SAVEIMPORT_A + slot, _("Import Save"));
|
|
|
|
popupMenu.Append(ID_SAVEEXPORT_A + slot, _("Export Save"));
|
|
|
|
popupMenu.Append(ID_EXPORTALL_A + slot, _("Export all saves"));
|
2013-10-28 23:23:17 -06:00
|
|
|
|
2014-11-11 07:50:11 -07:00
|
|
|
popupMenu.FindItem(ID_COPYFROM_A + slot)->Enable(__mcmSettings.twoCardsLoaded);
|
2009-02-21 20:23:48 -07:00
|
|
|
|
2014-11-11 07:50:11 -07:00
|
|
|
popupMenu.AppendSeparator();
|
2009-02-21 20:23:48 -07:00
|
|
|
|
2014-11-11 07:50:11 -07:00
|
|
|
popupMenu.Append(ID_FIXCHECKSUM_A + slot, _("Fix Checksums"));
|
|
|
|
popupMenu.Append(ID_PREVPAGE_A + slot, _("Previous Page"));
|
|
|
|
popupMenu.Append(ID_NEXTPAGE_A + slot, _("Next Page"));
|
|
|
|
popupMenu.Append(ID_MEMCARDPATH_A + slot, wxString::Format(_("Set as default Memcard %c"), 'A' + slot));
|
|
|
|
popupMenu.AppendCheckItem(ID_USEPAGES, _("Enable pages"));
|
2013-04-07 23:16:50 -06:00
|
|
|
|
2014-11-11 07:50:11 -07:00
|
|
|
popupMenu.FindItem(ID_PREVPAGE_A + slot)->Enable(prevPage && __mcmSettings.usePages);
|
|
|
|
popupMenu.FindItem(ID_NEXTPAGE_A + slot)->Enable(nextPage && __mcmSettings.usePages);
|
|
|
|
popupMenu.FindItem(ID_USEPAGES)->Check(__mcmSettings.usePages);
|
2013-10-28 23:23:17 -06:00
|
|
|
|
2014-11-11 07:50:11 -07:00
|
|
|
popupMenu.AppendSeparator();
|
2009-02-21 20:23:48 -07:00
|
|
|
|
2014-02-16 21:51:41 -07:00
|
|
|
// popupMenu->AppendCheckItem(COLUMN_BANNER, _("Show save banner"));
|
2014-11-11 07:50:11 -07:00
|
|
|
popupMenu.AppendCheckItem(COLUMN_TITLE, _("Show save title"));
|
|
|
|
popupMenu.AppendCheckItem(COLUMN_COMMENT, _("Show save comment"));
|
|
|
|
popupMenu.AppendCheckItem(COLUMN_ICON, _("Show save icon"));
|
|
|
|
popupMenu.AppendCheckItem(COLUMN_BLOCKS, _("Show save blocks"));
|
|
|
|
popupMenu.AppendCheckItem(COLUMN_FIRSTBLOCK, _("Show first block"));
|
2009-02-21 20:23:48 -07:00
|
|
|
|
2014-02-16 21:51:41 -07:00
|
|
|
// for (int i = COLUMN_BANNER; i <= COLUMN_FIRSTBLOCK; i++)
|
2011-02-05 18:56:45 -07:00
|
|
|
for (int i = COLUMN_TITLE; i <= COLUMN_FIRSTBLOCK; i++)
|
2009-02-21 20:23:48 -07:00
|
|
|
{
|
2014-11-11 07:50:11 -07:00
|
|
|
popupMenu.FindItem(i)->Check(__mcmSettings.column[i]);
|
2009-02-21 20:23:48 -07:00
|
|
|
}
|
2008-12-09 19:41:55 -07:00
|
|
|
}
|
2014-11-11 07:50:11 -07:00
|
|
|
PopupMenu(&popupMenu);
|
2008-12-09 19:41:55 -07:00
|
|
|
}
|
2009-04-27 20:30:50 -06:00
|
|
|
|