mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
Fixes/Cleanup for the MemcardManager.
Notable Changes: Fixes right click menu in linux. Fixes Issue 2412. sram.raw file is no longer required to format a memcard Update to use new ini sections, automatically remove default settings from ini file enable pages setting no longer requires memcard manager to be reopened to take effect it is no longer possible to switch to a negative page number git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6546 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -76,4 +76,5 @@ union SRAM
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
extern SRAM sram_dump;
|
||||||
#endif
|
#endif
|
||||||
|
@ -18,9 +18,7 @@
|
|||||||
#include "MemcardManager.h"
|
#include "MemcardManager.h"
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "wx/mstream.h"
|
#include "wx/mstream.h"
|
||||||
#include "WxUtils.h"
|
|
||||||
|
|
||||||
#define DEFAULTS wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator
|
|
||||||
#define ARROWS slot ? _T("") : ARROW[slot], slot ? ARROW[slot] : _T("")
|
#define ARROWS slot ? _T("") : ARROW[slot], slot ? ARROW[slot] : _T("")
|
||||||
|
|
||||||
const u8 hdr[] = {
|
const u8 hdr[] = {
|
||||||
@ -108,18 +106,17 @@ CMemcardManager::CMemcardManager(wxWindow* parent, wxWindowID id, const wxString
|
|||||||
{
|
{
|
||||||
memoryCard[SLOT_A]=NULL;
|
memoryCard[SLOT_A]=NULL;
|
||||||
memoryCard[SLOT_B]=NULL;
|
memoryCard[SLOT_B]=NULL;
|
||||||
if (MemcardManagerIni.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX)))
|
|
||||||
|
if (!LoadSettings())
|
||||||
{
|
{
|
||||||
MemcardManagerIni.Get("MemcardManager", "Items per page", &itemsPerPage, 16);
|
itemsPerPage = 16;
|
||||||
MemcardManagerIni.Get("MemcardManager", "DefaultMemcardA", &(DefaultMemcard[SLOT_A]), ".");
|
mcmSettings.usePages = true;
|
||||||
MemcardManagerIni.Get("MemcardManager", "DefaultMemcardB", &(DefaultMemcard[SLOT_B]), ".");
|
for (int i = 0; i < NUMBER_OF_COLUMN; i++)
|
||||||
MemcardManagerIni.Get("MemcardManager", "DefaultIOFolder", &DefaultIOPath, "/Users/GC");
|
{
|
||||||
|
mcmSettings.column[i] = (i <= COLUMN_FIRSTBLOCK)? true:false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else itemsPerPage = 16;
|
|
||||||
maxPages = (128 / itemsPerPage) - 1;
|
maxPages = (128 / itemsPerPage) - 1;
|
||||||
#ifdef MCM_DEBUG_FRAME
|
|
||||||
MemcardManagerDebug = NULL;
|
|
||||||
#endif
|
|
||||||
CreateGUIControls();
|
CreateGUIControls();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,80 +132,55 @@ CMemcardManager::~CMemcardManager()
|
|||||||
delete memoryCard[SLOT_B];
|
delete memoryCard[SLOT_B];
|
||||||
memoryCard[SLOT_B] = NULL;
|
memoryCard[SLOT_B] = NULL;
|
||||||
}
|
}
|
||||||
#ifdef MCM_DEBUG_FRAME
|
SaveSettings();
|
||||||
if (MemcardManagerDebug)
|
|
||||||
{
|
|
||||||
MemcardManagerDebug->Destroy();
|
|
||||||
delete MemcardManagerDebug;
|
|
||||||
MemcardManagerDebug = NULL;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
MemcardManagerIni.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX));
|
|
||||||
MemcardManagerIni.Set("MemcardManager", "Items per page", itemsPerPage);
|
|
||||||
|
|
||||||
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");
|
|
||||||
MemcardManagerIni.Save(File::GetUserPath(F_DOLPHINCONFIG_IDX));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CMemcardManager::CMemcardListCtrl::CMemcardListCtrl(wxWindow* parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
|
bool CMemcardManager::LoadSettings()
|
||||||
: wxListCtrl(parent, id, pos, size, style)
|
|
||||||
{
|
{
|
||||||
if (MemcardManagerIni.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX)))
|
if (MemcardManagerIni.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX)))
|
||||||
{
|
{
|
||||||
MemcardManagerIni.Get("MemcardManager", "Use Pages", &usePages, true);
|
iniMemcardSection = MemcardManagerIni.GetOrCreateSection("MemcardManager");
|
||||||
MemcardManagerIni.Get("MemcardManager", "cBanner", &column[COLUMN_BANNER], true);
|
iniMemcardSection->Get("Items per page", &itemsPerPage, 16);
|
||||||
MemcardManagerIni.Get("MemcardManager", "cTitle", &column[COLUMN_TITLE], true);
|
iniMemcardSection->Get("DefaultMemcardA", &(DefaultMemcard[SLOT_A]), "");
|
||||||
MemcardManagerIni.Get("MemcardManager", "cComment", &column[COLUMN_COMMENT], true);
|
iniMemcardSection->Get("DefaultMemcardB", &(DefaultMemcard[SLOT_B]), "");
|
||||||
MemcardManagerIni.Get("MemcardManager", "cIcon", &column[COLUMN_ICON], true);
|
iniMemcardSection->Get("DefaultIOFolder", &DefaultIOPath, "/Users/GC");
|
||||||
MemcardManagerIni.Get("MemcardManager", "cBlocks", &column[COLUMN_BLOCKS], true);
|
|
||||||
MemcardManagerIni.Get("MemcardManager", "cFirst Block", &column[COLUMN_FIRSTBLOCK], true);
|
iniMemcardSection->Get("Use Pages", &mcmSettings.usePages, true);
|
||||||
#ifdef DEBUG_MCM
|
iniMemcardSection->Get("cBanner", &mcmSettings.column[COLUMN_BANNER], true);
|
||||||
MemcardManagerIni.Get("MemcardManager", "cDebug", &column[NUMBER_OF_COLUMN], false);
|
iniMemcardSection->Get("cTitle", &mcmSettings.column[COLUMN_TITLE], true);
|
||||||
#else
|
iniMemcardSection->Get("cComment", &mcmSettings.column[COLUMN_COMMENT], true);
|
||||||
column[NUMBER_OF_COLUMN] = false;
|
iniMemcardSection->Get("cIcon", &mcmSettings.column[COLUMN_ICON], true);
|
||||||
#endif
|
iniMemcardSection->Get("cBlocks", &mcmSettings.column[COLUMN_BLOCKS], true);
|
||||||
|
iniMemcardSection->Get("cFirst Block", &mcmSettings.column[COLUMN_FIRSTBLOCK], true);
|
||||||
|
|
||||||
|
mcmSettings.column[NUMBER_OF_COLUMN] = false;
|
||||||
|
|
||||||
for(int i = COLUMN_GAMECODE; i < NUMBER_OF_COLUMN; i++)
|
for(int i = COLUMN_GAMECODE; i < NUMBER_OF_COLUMN; i++)
|
||||||
{
|
{
|
||||||
column[i] = column[NUMBER_OF_COLUMN];
|
mcmSettings.column[i] = mcmSettings.column[NUMBER_OF_COLUMN];
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else
|
return false;
|
||||||
{
|
|
||||||
usePages = true;
|
|
||||||
for (int i = 0; i < NUMBER_OF_COLUMN; i++)
|
|
||||||
{
|
|
||||||
if ( i > COLUMN_FIRSTBLOCK) column[i] = false;
|
|
||||||
else column[i] = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
twoCardsLoaded = false;
|
|
||||||
prevPage = false;
|
|
||||||
nextPage = false;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CMemcardManager::CMemcardListCtrl::~CMemcardListCtrl()
|
bool CMemcardManager::SaveSettings()
|
||||||
{
|
{
|
||||||
MemcardManagerIni.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX));
|
MemcardManagerIni.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX));
|
||||||
|
iniMemcardSection = MemcardManagerIni.GetOrCreateSection("MemcardManager");
|
||||||
|
iniMemcardSection->Set("Items per page", itemsPerPage, 16);
|
||||||
|
iniMemcardSection->Set("DefaultMemcardA", DefaultMemcard[SLOT_A], "");
|
||||||
|
iniMemcardSection->Set("DefaultMemcardB", DefaultMemcard[SLOT_B], "");
|
||||||
|
|
||||||
MemcardManagerIni.Set("MemcardManager", "Use Pages", usePages);
|
iniMemcardSection->Set("Use Pages", mcmSettings.usePages, true);
|
||||||
MemcardManagerIni.Set("MemcardManager", "cBanner", column[COLUMN_BANNER]);
|
iniMemcardSection->Set("cBanner", mcmSettings.column[COLUMN_BANNER], true);
|
||||||
MemcardManagerIni.Set("MemcardManager", "cTitle", column[COLUMN_TITLE]);
|
iniMemcardSection->Set("cTitle", mcmSettings.column[COLUMN_TITLE], true);
|
||||||
MemcardManagerIni.Set("MemcardManager", "cComment", column[COLUMN_COMMENT]);
|
iniMemcardSection->Set("cComment", mcmSettings.column[COLUMN_COMMENT], true);
|
||||||
MemcardManagerIni.Set("MemcardManager", "cIcon", column[COLUMN_ICON]);
|
iniMemcardSection->Set("cIcon", mcmSettings.column[COLUMN_ICON], true);
|
||||||
MemcardManagerIni.Set("MemcardManager", "cBlocks", column[COLUMN_BLOCKS]);
|
iniMemcardSection->Set("cBlocks", mcmSettings.column[COLUMN_BLOCKS], true);
|
||||||
MemcardManagerIni.Set("MemcardManager", "cFirst Block", column[COLUMN_FIRSTBLOCK]);
|
iniMemcardSection->Set("cFirst Block", mcmSettings.column[COLUMN_FIRSTBLOCK], true);
|
||||||
#ifdef DEBUG_MCM
|
|
||||||
MemcardManagerIni.Set("MemcardManager", "cDebug", column[NUMBER_OF_COLUMN]);
|
return MemcardManagerIni.Save(File::GetUserPath(F_DOLPHINCONFIG_IDX));
|
||||||
#endif
|
|
||||||
MemcardManagerIni.Save(File::GetUserPath(F_DOLPHINCONFIG_IDX));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMemcardManager::CreateGUIControls()
|
void CMemcardManager::CreateGUIControls()
|
||||||
@ -217,22 +189,22 @@ void CMemcardManager::CreateGUIControls()
|
|||||||
|
|
||||||
const wxChar* ARROW[2] = {_T("<-"), _T("->")};
|
const wxChar* ARROW[2] = {_T("<-"), _T("->")};
|
||||||
|
|
||||||
m_ConvertToGci = new wxButton(this, ID_CONVERTTOGCI, wxT("Convert to GCI"), DEFAULTS);
|
m_ConvertToGci = new wxButton(this, ID_CONVERTTOGCI, wxT("Convert to GCI"));
|
||||||
|
|
||||||
for (int slot = SLOT_A; slot < SLOT_B + 1; slot++)
|
for (int slot = SLOT_A; slot < SLOT_B + 1; slot++)
|
||||||
{
|
{
|
||||||
m_CopyFrom[slot] = new wxButton(this, ID_COPYFROM_A + slot,
|
m_CopyFrom[slot] = new wxButton(this, ID_COPYFROM_A + slot,
|
||||||
wxString::Format(wxT("%1$sCopy%1$s"), ARROW[slot ? 0 : 1]), DEFAULTS);
|
wxString::Format(wxT("%1$sCopy%1$s"), ARROW[slot ? 0 : 1]));
|
||||||
m_SaveImport[slot] = new wxButton(this, ID_SAVEIMPORT_A + slot,
|
m_SaveImport[slot] = new wxButton(this, ID_SAVEIMPORT_A + slot,
|
||||||
wxString::Format(wxT("%sImport GCI%s"), ARROWS), DEFAULTS);
|
wxString::Format(wxT("%sImport GCI%s"), ARROWS));
|
||||||
m_SaveExport[slot] = new wxButton(this, ID_SAVEEXPORT_A + slot,
|
m_SaveExport[slot] = new wxButton(this, ID_SAVEEXPORT_A + slot,
|
||||||
wxString::Format(wxT("%sExport GCI%s"), ARROWS), DEFAULTS);
|
wxString::Format(wxT("%sExport GCI%s"), ARROWS));
|
||||||
m_Delete[slot] = new wxButton(this, ID_DELETE_A + slot,
|
m_Delete[slot] = new wxButton(this, ID_DELETE_A + slot,
|
||||||
wxString::Format(wxT("%sDelete%s"), ARROWS), DEFAULTS);
|
wxString::Format(wxT("%sDelete%s"), ARROWS));
|
||||||
|
|
||||||
|
|
||||||
m_PrevPage[slot] = new wxButton(this, ID_PREVPAGE_A + slot, wxT("Prev Page"), DEFAULTS);
|
m_PrevPage[slot] = new wxButton(this, ID_PREVPAGE_A + slot, wxT("Prev Page"));
|
||||||
m_NextPage[slot] = new wxButton(this, ID_NEXTPAGE_A + slot, wxT("Next Page"), DEFAULTS);
|
m_NextPage[slot] = new wxButton(this, ID_NEXTPAGE_A + slot, wxT("Next Page"));
|
||||||
|
|
||||||
t_Status[slot] = new wxStaticText(this, 0, wxEmptyString, wxDefaultPosition,wxDefaultSize, 0, wxEmptyString);
|
t_Status[slot] = new wxStaticText(this, 0, wxEmptyString, wxDefaultPosition,wxDefaultSize, 0, wxEmptyString);
|
||||||
|
|
||||||
@ -247,7 +219,7 @@ void CMemcardManager::CreateGUIControls()
|
|||||||
wxT("Gamecube Memory Cards (*.raw,*.gcp)|*.raw;*.gcp"), wxDefaultPosition, wxDefaultSize, wxFLP_USE_TEXTCTRL|wxFLP_OPEN);
|
wxT("Gamecube Memory Cards (*.raw,*.gcp)|*.raw;*.gcp"), wxDefaultPosition, wxDefaultSize, wxFLP_USE_TEXTCTRL|wxFLP_OPEN);
|
||||||
|
|
||||||
m_MemcardList[slot] = new CMemcardListCtrl(this, ID_MEMCARDLIST_A + slot, wxDefaultPosition, wxSize(350,400),
|
m_MemcardList[slot] = new CMemcardListCtrl(this, ID_MEMCARDLIST_A + slot, wxDefaultPosition, wxSize(350,400),
|
||||||
wxLC_REPORT | wxSUNKEN_BORDER | wxLC_ALIGN_LEFT | wxLC_SINGLE_SEL);
|
wxLC_REPORT | wxSUNKEN_BORDER | wxLC_ALIGN_LEFT | wxLC_SINGLE_SEL, mcmSettings);
|
||||||
|
|
||||||
m_MemcardList[slot]->AssignImageList(new wxImageList(96,32),wxIMAGE_LIST_SMALL);
|
m_MemcardList[slot]->AssignImageList(new wxImageList(96,32),wxIMAGE_LIST_SMALL);
|
||||||
|
|
||||||
@ -292,10 +264,10 @@ void CMemcardManager::CreateGUIControls()
|
|||||||
m_SaveImport[i]->Disable();
|
m_SaveImport[i]->Disable();
|
||||||
m_SaveExport[i]->Disable();
|
m_SaveExport[i]->Disable();
|
||||||
m_Delete[i]->Disable();
|
m_Delete[i]->Disable();
|
||||||
if (strcmp(DefaultMemcard[i].c_str(), "."))
|
if (DefaultMemcard[i].length())
|
||||||
{
|
{
|
||||||
m_MemcardPath[i]->SetPath(wxString::From8BitData(DefaultMemcard[i].c_str()));
|
m_MemcardPath[i]->SetPath(wxString::From8BitData(DefaultMemcard[i].c_str()));
|
||||||
ChangePath(ID_MEMCARDPATH_A + i);
|
ChangePath(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -307,56 +279,52 @@ void CMemcardManager::OnClose(wxCloseEvent& WXUNUSED (event))
|
|||||||
|
|
||||||
void CMemcardManager::OnPathChange(wxFileDirPickerEvent& event)
|
void CMemcardManager::OnPathChange(wxFileDirPickerEvent& event)
|
||||||
{
|
{
|
||||||
ChangePath(event.GetId());
|
ChangePath(event.GetId() - ID_MEMCARDPATH_A);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMemcardManager::ChangePath(int id)
|
void CMemcardManager::ChangePath(int slot)
|
||||||
{
|
{
|
||||||
int slot = SLOT_B;
|
int slot2 = (slot == SLOT_A) ? SLOT_B : SLOT_A;
|
||||||
int slot2 = SLOT_A;
|
page[slot] = FIRSTPAGE;
|
||||||
switch (id)
|
if (mcmSettings.usePages && m_PrevPage[slot]->IsEnabled())
|
||||||
{
|
{
|
||||||
case ID_MEMCARDPATH_A:
|
m_PrevPage[slot]->Disable();
|
||||||
slot = SLOT_A;
|
m_MemcardList[slot]->prevPage = false;
|
||||||
slot2 = SLOT_B;
|
}
|
||||||
case ID_MEMCARDPATH_B:
|
if (!strcasecmp(m_MemcardPath[slot2]->GetPath().mb_str(), m_MemcardPath[slot]->GetPath().mb_str()))
|
||||||
page[slot] = FIRSTPAGE;
|
{
|
||||||
if (m_MemcardList[slot]->usePages && m_PrevPage[slot]->IsEnabled())
|
if(m_MemcardPath[slot]->GetPath().length())
|
||||||
{
|
|
||||||
m_PrevPage[slot]->Disable();
|
|
||||||
m_MemcardList[slot]->prevPage = false;
|
|
||||||
}
|
|
||||||
if (!strcasecmp(m_MemcardPath[slot2]->GetPath().mb_str(), m_MemcardPath[slot]->GetPath().mb_str()))
|
|
||||||
{
|
|
||||||
if(!m_MemcardPath[slot]->GetPath().IsEmpty())
|
|
||||||
PanicAlert("Memcard already opened");
|
PanicAlert("Memcard already opened");
|
||||||
}
|
}
|
||||||
else if (ReloadMemcard(m_MemcardPath[slot]->GetPath().mb_str(), slot))
|
else
|
||||||
|
{
|
||||||
|
if (m_MemcardPath[slot]->GetPath().length() && ReloadMemcard(m_MemcardPath[slot]->GetPath().mb_str(), slot))
|
||||||
{
|
{
|
||||||
m_MemcardList[slot2]->twoCardsLoaded = true;
|
mcmSettings.twoCardsLoaded = true;
|
||||||
m_SaveImport[slot]->Enable();
|
m_SaveImport[slot]->Enable();
|
||||||
m_SaveExport[slot]->Enable();
|
m_SaveExport[slot]->Enable();
|
||||||
m_Delete[slot]->Enable();
|
m_Delete[slot]->Enable();
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if (memoryCard[slot])
|
else
|
||||||
{
|
{
|
||||||
delete memoryCard[slot];
|
if (memoryCard[slot])
|
||||||
memoryCard[slot] = NULL;
|
{
|
||||||
|
delete memoryCard[slot];
|
||||||
|
memoryCard[slot] = NULL;
|
||||||
|
}
|
||||||
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
m_MemcardList[slot2]->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 (m_MemcardList[slot]->usePages)
|
|
||||||
{
|
|
||||||
m_PrevPage[slot]->Disable();
|
|
||||||
m_NextPage[slot]->Disable();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if (m_Delete[SLOT_A]->IsEnabled() && m_Delete[SLOT_B]->IsEnabled())
|
if (m_Delete[SLOT_A]->IsEnabled() && m_Delete[SLOT_B]->IsEnabled())
|
||||||
{
|
{
|
||||||
@ -412,39 +380,40 @@ void CMemcardManager::OnPageChange(wxCommandEvent& event)
|
|||||||
|
|
||||||
void CMemcardManager::OnMenuChange(wxCommandEvent& event)
|
void CMemcardManager::OnMenuChange(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
switch(event.GetId())
|
int _id = event.GetId();
|
||||||
|
switch(_id)
|
||||||
{
|
{
|
||||||
|
case ID_MEMCARDPATH_A:
|
||||||
|
case ID_MEMCARDPATH_B:
|
||||||
|
DefaultMemcard[_id - ID_MEMCARDPATH_A] = m_MemcardPath[_id - ID_MEMCARDPATH_A]->GetPath().mb_str();
|
||||||
|
return;
|
||||||
case ID_USEPAGES:
|
case ID_USEPAGES:
|
||||||
m_MemcardList[SLOT_A]->usePages = !m_MemcardList[SLOT_A]->usePages;
|
mcmSettings.usePages = !mcmSettings.usePages;
|
||||||
m_MemcardList[SLOT_B]->usePages = !m_MemcardList[SLOT_B]->usePages;
|
if (!mcmSettings.usePages)
|
||||||
if (!m_MemcardList[SLOT_A]->usePages)
|
|
||||||
{
|
{
|
||||||
m_PrevPage[SLOT_A]->Disable();
|
m_PrevPage[SLOT_A]->Disable();
|
||||||
m_PrevPage[SLOT_B]->Disable();
|
m_PrevPage[SLOT_B]->Disable();
|
||||||
m_NextPage[SLOT_A]->Disable();
|
m_NextPage[SLOT_A]->Disable();
|
||||||
m_NextPage[SLOT_B]->Disable();
|
m_NextPage[SLOT_B]->Disable();
|
||||||
page[SLOT_A] = page[SLOT_B] = FIRSTPAGE;
|
m_MemcardList[SLOT_A]->prevPage =
|
||||||
|
m_MemcardList[SLOT_B]->prevPage = false;
|
||||||
|
page[SLOT_A] =
|
||||||
|
page[SLOT_B] = FIRSTPAGE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ID_MEMCARDPATH_A:
|
|
||||||
DefaultMemcard[SLOT_A] = m_MemcardPath[SLOT_A]->GetPath().mb_str();
|
|
||||||
break;
|
|
||||||
case ID_MEMCARDPATH_B:
|
|
||||||
DefaultMemcard[SLOT_B] = m_MemcardPath[SLOT_B]->GetPath().mb_str();
|
|
||||||
break;
|
|
||||||
case NUMBER_OF_COLUMN:
|
case NUMBER_OF_COLUMN:
|
||||||
for( int i = COLUMN_GAMECODE; i < NUMBER_OF_COLUMN; i++)
|
for (int i = COLUMN_GAMECODE; i <= NUMBER_OF_COLUMN; i++)
|
||||||
{
|
{
|
||||||
m_MemcardList[SLOT_A]->column[i] = !m_MemcardList[SLOT_A]->column[i];
|
mcmSettings.column[i] = !mcmSettings.column[i];
|
||||||
m_MemcardList[SLOT_B]->column[i] = !m_MemcardList[SLOT_B]->column[i];
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
m_MemcardList[SLOT_A]->column[event.GetId()] = !m_MemcardList[SLOT_A]->column[event.GetId()];
|
mcmSettings.column[_id] = !mcmSettings.column[_id];
|
||||||
m_MemcardList[SLOT_B]->column[event.GetId()] = !m_MemcardList[SLOT_B]->column[event.GetId()];
|
|
||||||
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
bool CMemcardManager::CopyDeleteSwitch(u32 error, int slot)
|
bool CMemcardManager::CopyDeleteSwitch(u32 error, int slot)
|
||||||
{
|
{
|
||||||
@ -668,19 +637,6 @@ bool CMemcardManager::ReloadMemcard(const char *fileName, int card)
|
|||||||
m_MemcardList[card]->InsertColumn(COLUMN_ICON, _T("Icon"));
|
m_MemcardList[card]->InsertColumn(COLUMN_ICON, _T("Icon"));
|
||||||
m_MemcardList[card]->InsertColumn(COLUMN_BLOCKS, _T("Blocks"));
|
m_MemcardList[card]->InsertColumn(COLUMN_BLOCKS, _T("Blocks"));
|
||||||
m_MemcardList[card]->InsertColumn(COLUMN_FIRSTBLOCK, _T("First Block"));
|
m_MemcardList[card]->InsertColumn(COLUMN_FIRSTBLOCK, _T("First Block"));
|
||||||
#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
|
|
||||||
|
|
||||||
wxImageList *list = m_MemcardList[card]->GetImageList(wxIMAGE_LIST_SMALL);
|
wxImageList *list = m_MemcardList[card]->GetImageList(wxIMAGE_LIST_SMALL);
|
||||||
list->RemoveAll();
|
list->RemoveAll();
|
||||||
@ -736,9 +692,11 @@ bool CMemcardManager::ReloadMemcard(const char *fileName, int card)
|
|||||||
images[i*2+1] = list->Add(icon);
|
images[i*2+1] = list->Add(icon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int pagesMax = 128;
|
|
||||||
if (m_MemcardList[card]->usePages) pagesMax = (page[card] + 1) * itemsPerPage;
|
int pagesMax = (mcmSettings.usePages) ?
|
||||||
for (j = page[card] * itemsPerPage;(j < nFiles) && (j < pagesMax); j++)
|
(page[card] + 1) * itemsPerPage : 128;
|
||||||
|
|
||||||
|
for (j = page[card] * itemsPerPage; (j < nFiles) && (j < pagesMax); j++)
|
||||||
{
|
{
|
||||||
char title[DENTRY_STRLEN];
|
char title[DENTRY_STRLEN];
|
||||||
char comment[DENTRY_STRLEN];
|
char comment[DENTRY_STRLEN];
|
||||||
@ -779,49 +737,9 @@ bool CMemcardManager::ReloadMemcard(const char *fileName, int card)
|
|||||||
m_MemcardList[card]->SetItemImage(index, images[j*2]);
|
m_MemcardList[card]->SetItemImage(index, images[j*2]);
|
||||||
m_MemcardList[card]->SetItemColumnImage(index, COLUMN_ICON, images[j*2+1]);
|
m_MemcardList[card]->SetItemColumnImage(index, COLUMN_ICON, images[j*2+1]);
|
||||||
}
|
}
|
||||||
#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);
|
|
||||||
|
|
||||||
char iF[17];
|
|
||||||
if (!memoryCard[card]->DEntry_IconFmt(j, iF)) iF[0]=0;
|
|
||||||
m_MemcardList[card]->SetItem(index, COLUMN_ICONFMT, wxString::FromAscii(iF));
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_MemcardList[card]->usePages)
|
if (mcmSettings.usePages)
|
||||||
{
|
{
|
||||||
if (nFiles <= itemsPerPage)
|
if (nFiles <= itemsPerPage)
|
||||||
{
|
{
|
||||||
@ -844,7 +762,7 @@ bool CMemcardManager::ReloadMemcard(const char *fileName, int card)
|
|||||||
// Automatic column width and then show the list
|
// Automatic column width and then show the list
|
||||||
for (int i = 0; i < NUMBER_OF_COLUMN; i++)
|
for (int i = 0; i < NUMBER_OF_COLUMN; i++)
|
||||||
{
|
{
|
||||||
if (m_MemcardList[card]->column[i])
|
if (mcmSettings.column[i])
|
||||||
m_MemcardList[card]->SetColumnWidth(i, wxLIST_AUTOSIZE);
|
m_MemcardList[card]->SetColumnWidth(i, wxLIST_AUTOSIZE);
|
||||||
else
|
else
|
||||||
m_MemcardList[card]->SetColumnWidth(i, 0);
|
m_MemcardList[card]->SetColumnWidth(i, 0);
|
||||||
@ -855,19 +773,6 @@ bool CMemcardManager::ReloadMemcard(const char *fileName, int card)
|
|||||||
memoryCard[card]->GetFreeBlocks(), DIRLEN - nFiles);
|
memoryCard[card]->GetFreeBlocks(), DIRLEN - nFiles);
|
||||||
t_Status[card]->SetLabel(wxLabel);
|
t_Status[card]->SetLabel(wxLabel);
|
||||||
|
|
||||||
|
|
||||||
#ifdef MCM_DEBUG_FRAME
|
|
||||||
if(MemcardManagerDebug == NULL)
|
|
||||||
{
|
|
||||||
MemcardManagerDebug = new CMemcardManagerDebug((wxFrame *)NULL, wxDefaultPosition, wxSize(950, 400));
|
|
||||||
|
|
||||||
}
|
|
||||||
if (MemcardManagerDebug != NULL)
|
|
||||||
{
|
|
||||||
MemcardManagerDebug->Show();
|
|
||||||
MemcardManagerDebug->updatePanels(memoryCard, card);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -886,15 +791,14 @@ void CMemcardManager::CMemcardListCtrl::OnRightClick(wxMouseEvent& event)
|
|||||||
}
|
}
|
||||||
SetItemState(item, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED);
|
SetItemState(item, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED);
|
||||||
|
|
||||||
int slot = event.GetId() - ID_MEMCARDLIST_A;
|
int slot = GetId() - ID_MEMCARDLIST_A;
|
||||||
popupMenu->Append(ID_COPYFROM_A + slot, wxString::Format(wxT("Copy to Memcard %c"), 'B' - slot));
|
popupMenu->Append(ID_COPYFROM_A + slot, wxString::Format(wxT("Copy to Memcard %c"), 'B' - slot));
|
||||||
popupMenu->Append(ID_DELETE_A + slot, wxT("Delete Save"));
|
popupMenu->Append(ID_DELETE_A + slot, wxT("Delete Save"));
|
||||||
popupMenu->Append(ID_SAVEIMPORT_A + slot, wxT("Import Save"));
|
popupMenu->Append(ID_SAVEIMPORT_A + slot, wxT("Import Save"));
|
||||||
popupMenu->Append(ID_SAVEEXPORT_A + slot, wxT("Export Save"));
|
popupMenu->Append(ID_SAVEEXPORT_A + slot, wxT("Export Save"));
|
||||||
popupMenu->Append(ID_EXPORTALL_A + slot, wxT("Export all saves"));
|
popupMenu->Append(ID_EXPORTALL_A + slot, wxT("Export all saves"));
|
||||||
|
|
||||||
if (!twoCardsLoaded)
|
popupMenu->FindItem(ID_COPYFROM_A + slot)->Enable(__mcmSettings.twoCardsLoaded);
|
||||||
popupMenu->FindItem(ID_COPYFROM_A + slot)->Enable(false);
|
|
||||||
|
|
||||||
popupMenu->AppendSeparator();
|
popupMenu->AppendSeparator();
|
||||||
|
|
||||||
@ -904,12 +808,9 @@ void CMemcardManager::CMemcardListCtrl::OnRightClick(wxMouseEvent& event)
|
|||||||
popupMenu->Append(ID_MEMCARDPATH_A + slot, wxString::Format(wxT("Set as default Memcard %c"), 'A' + slot));
|
popupMenu->Append(ID_MEMCARDPATH_A + slot, wxString::Format(wxT("Set as default Memcard %c"), 'A' + slot));
|
||||||
popupMenu->AppendCheckItem(ID_USEPAGES, wxT("Enable pages"));
|
popupMenu->AppendCheckItem(ID_USEPAGES, wxT("Enable pages"));
|
||||||
|
|
||||||
if (!prevPage || !usePages)
|
popupMenu->FindItem(ID_PREVPAGE_A + slot)->Enable(prevPage && __mcmSettings.usePages);
|
||||||
popupMenu->FindItem(ID_PREVPAGE_A + slot)->Enable(false);
|
popupMenu->FindItem(ID_NEXTPAGE_A + slot)->Enable(nextPage && __mcmSettings.usePages);
|
||||||
if (!nextPage || !usePages)
|
popupMenu->FindItem(ID_USEPAGES)->Check(__mcmSettings.usePages);
|
||||||
popupMenu->FindItem(ID_NEXTPAGE_A + slot)->Enable(false);
|
|
||||||
if(usePages)
|
|
||||||
popupMenu->FindItem(ID_USEPAGES)->Check();
|
|
||||||
|
|
||||||
popupMenu->AppendSeparator();
|
popupMenu->AppendSeparator();
|
||||||
|
|
||||||
@ -921,12 +822,8 @@ void CMemcardManager::CMemcardListCtrl::OnRightClick(wxMouseEvent& event)
|
|||||||
|
|
||||||
for (int i = COLUMN_BANNER; i <= COLUMN_BLOCKS; i++)
|
for (int i = COLUMN_BANNER; i <= COLUMN_BLOCKS; i++)
|
||||||
{
|
{
|
||||||
if (column[i]) popupMenu->FindItem(i)->Check();
|
popupMenu->FindItem(i)->Check(__mcmSettings.column[i]);
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_MCM
|
|
||||||
popupMenu->AppendCheckItem(NUMBER_OF_COLUMN, wxT("Debug Memcard"));
|
|
||||||
if (column[NUMBER_OF_COLUMN]) popupMenu->FindItem(NUMBER_OF_COLUMN)->Check();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
PopupMenu(popupMenu);
|
PopupMenu(popupMenu);
|
||||||
}
|
}
|
||||||
|
@ -39,15 +39,6 @@
|
|||||||
#define E_UNK "Unknown error"
|
#define E_UNK "Unknown error"
|
||||||
#define FIRSTPAGE 0
|
#define FIRSTPAGE 0
|
||||||
|
|
||||||
#ifdef MEMCMAN
|
|
||||||
#undef CONFIG_FILE
|
|
||||||
#define CONFIG_FILE "./MemcardManager.ini"
|
|
||||||
#define DEBUG_MCM
|
|
||||||
#define MCM_DEBUG_FRAME
|
|
||||||
#include "MCMdebug.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
class CMemcardManager : public wxDialog
|
class CMemcardManager : public wxDialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -65,9 +56,7 @@ class CMemcardManager : public wxDialog
|
|||||||
std::string DefaultMemcard[2],
|
std::string DefaultMemcard[2],
|
||||||
DefaultIOPath;
|
DefaultIOPath;
|
||||||
IniFile MemcardManagerIni;
|
IniFile MemcardManagerIni;
|
||||||
#ifdef MCM_DEBUG_FRAME
|
IniFile::Section* iniMemcardSection;
|
||||||
CMemcardManagerDebug * MemcardManagerDebug;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
wxBoxSizer *sMain,
|
wxBoxSizer *sMain,
|
||||||
*sButtons,
|
*sButtons,
|
||||||
@ -143,19 +132,25 @@ class CMemcardManager : public wxDialog
|
|||||||
void OnPathChange(wxFileDirPickerEvent& event);
|
void OnPathChange(wxFileDirPickerEvent& event);
|
||||||
void ChangePath(int id);
|
void ChangePath(int id);
|
||||||
bool CopyDeleteSwitch(u32 error, int slot);
|
bool CopyDeleteSwitch(u32 error, int slot);
|
||||||
|
bool LoadSettings();
|
||||||
|
bool SaveSettings();
|
||||||
|
|
||||||
|
struct _mcmSettings
|
||||||
|
{
|
||||||
|
bool twoCardsLoaded,
|
||||||
|
usePages,
|
||||||
|
column[NUMBER_OF_COLUMN+1];
|
||||||
|
}mcmSettings;
|
||||||
|
|
||||||
class CMemcardListCtrl : public wxListCtrl
|
class CMemcardListCtrl : public wxListCtrl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
IniFile MemcardManagerIni;
|
CMemcardListCtrl(wxWindow* parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, long style, _mcmSettings& _mcmSetngs)
|
||||||
|
: wxListCtrl(parent, id, pos, size, style), __mcmSettings(_mcmSetngs){;}
|
||||||
CMemcardListCtrl(wxWindow* parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, long style);
|
~CMemcardListCtrl(){;}
|
||||||
~CMemcardListCtrl();
|
_mcmSettings & __mcmSettings;
|
||||||
bool twoCardsLoaded,
|
bool prevPage,
|
||||||
usePages,
|
nextPage;
|
||||||
prevPage,
|
|
||||||
nextPage,
|
|
||||||
column[NUMBER_OF_COLUMN+1];
|
|
||||||
private:
|
private:
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
void OnRightClick(wxMouseEvent& event);
|
void OnRightClick(wxMouseEvent& event);
|
||||||
|
@ -1156,14 +1156,15 @@ bool GCMemcard::Format(bool sjis, bool New, int slot, u16 SizeMb, bool hdrOnly)
|
|||||||
if ((SizeMb != MemCard2043Mb) || (data_size != mc_data_size)) return false;
|
if ((SizeMb != MemCard2043Mb) || (data_size != mc_data_size)) return false;
|
||||||
|
|
||||||
pStream = fopen(File::GetUserPath(F_GCSRAM_IDX), "rb");
|
pStream = fopen(File::GetUserPath(F_GCSRAM_IDX), "rb");
|
||||||
if (pStream == NULL)
|
if (pStream)
|
||||||
{
|
{
|
||||||
PanicAlert("Could not open SRAM file");
|
fread(&m_SRAM, 1, 64, pStream);
|
||||||
return false;
|
fclose(pStream);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_SRAM = sram_dump;
|
||||||
}
|
}
|
||||||
fread(&m_SRAM, 1, 64, pStream);
|
|
||||||
fclose(pStream);
|
|
||||||
|
|
||||||
time = CEXIIPL::GetGCTime();
|
time = CEXIIPL::GetGCTime();
|
||||||
rand = Common::swap64(time);
|
rand = Common::swap64(time);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user