Move MemoryCard{File,Folder} out of GUI

This commit is contained in:
Connor McLaughlin 2021-09-17 18:42:39 +10:00 committed by Kojin
parent 307feefa87
commit 640e955c38
18 changed files with 146 additions and 136 deletions

View File

@ -130,6 +130,8 @@ set(pcsx2Sources
IPC.cpp IPC.cpp
Mdec.cpp Mdec.cpp
Memory.cpp Memory.cpp
MemoryCardFile.cpp
MemoryCardFolder.cpp
MMI.cpp MMI.cpp
MTGS.cpp MTGS.cpp
MTVU.cpp MTVU.cpp
@ -204,6 +206,8 @@ set(pcsx2Headers
Mdec.h Mdec.h
MTVU.h MTVU.h
Memory.h Memory.h
MemoryCardFile.h
MemoryCardFolder.h
MemoryTypes.h MemoryTypes.h
Patch.h Patch.h
PathDefs.h PathDefs.h
@ -1010,8 +1014,6 @@ set(pcsx2GuiSources
gui/IsoDropTarget.cpp gui/IsoDropTarget.cpp
gui/MainFrame.cpp gui/MainFrame.cpp
gui/MainMenuClicks.cpp gui/MainMenuClicks.cpp
gui/MemoryCardFile.cpp
gui/MemoryCardFolder.cpp
gui/MessageBoxes.cpp gui/MessageBoxes.cpp
gui/MSWstuff.cpp gui/MSWstuff.cpp
gui/Panels/BaseApplicableConfigPanel.cpp gui/Panels/BaseApplicableConfigPanel.cpp
@ -1068,8 +1070,6 @@ set(pcsx2GuiHeaders
gui/i18n.h gui/i18n.h
gui/IsoDropTarget.h gui/IsoDropTarget.h
gui/MainFrame.h gui/MainFrame.h
gui/MemoryCardFile.h
gui/MemoryCardFolder.h
gui/MSWstuff.h gui/MSWstuff.h
gui/Panels/ConfigurationPanels.h gui/Panels/ConfigurationPanels.h
gui/Panels/LogOptionsPanels.h gui/Panels/LogOptionsPanels.h

View File

@ -528,6 +528,16 @@ struct Pcsx2Config
} }
}; };
// ------------------------------------------------------------------------
// Options struct for each memory card.
//
struct McdOptions
{
wxFileName Filename; // user-configured location of this memory card
bool Enabled; // memory card enabled (if false, memcard will not show up in-game)
MemoryCardType Type; // the memory card implementation that should be used
};
BITFIELD32() BITFIELD32()
bool bool
CdvdVerboseReads :1, // enables cdvd read activity verbosely dumped to the console CdvdVerboseReads :1, // enables cdvd read activity verbosely dumped to the console
@ -552,6 +562,11 @@ struct Pcsx2Config
ConsoleToStdio :1, ConsoleToStdio :1,
HostFs :1; HostFs :1;
// uses automatic ntfs compression when creating new memory cards (Win32 only)
#ifdef __WXMSW__
bool McdCompressNTFS;
#endif
BITFIELD_END BITFIELD_END
CpuOptions Cpu; CpuOptions Cpu;
@ -566,7 +581,10 @@ struct Pcsx2Config
FolderOptions Folders; FolderOptions Folders;
FilenameOptions BaseFilenames; FilenameOptions BaseFilenames;
// Memorycard options - first 2 are default slots, last 6 are multitap 1 and 2
// slots (3 each)
McdOptions Mcd[8];
wxString GzipIsoIndexTemplate; // for quick-access index with gzipped ISO wxString GzipIsoIndexTemplate; // for quick-access index with gzipped ISO
// Set at runtime, not loaded from config. // Set at runtime, not loaded from config.
@ -582,6 +600,7 @@ struct Pcsx2Config
Pcsx2Config(); Pcsx2Config();
void LoadSave( IniInterface& ini ); void LoadSave( IniInterface& ini );
void LoadSaveMemcards( IniInterface& ini );
void Load( const wxString& srcfile ); void Load( const wxString& srcfile );
void Load( const wxInputStream& srcstream ); void Load( const wxInputStream& srcstream );
@ -589,6 +608,7 @@ struct Pcsx2Config
void Save( const wxOutputStream& deststream ); void Save( const wxOutputStream& deststream );
wxString FullpathToBios() const; wxString FullpathToBios() const;
wxString FullpathToMcd(uint slot) const;
bool MultitapEnabled( uint port ) const; bool MultitapEnabled( uint port ) const;

View File

@ -27,11 +27,11 @@ struct Component_FileMcd;
#include "MemoryCardFolder.h" #include "MemoryCardFolder.h"
#include "System.h" #include "System.h"
#include "AppConfig.h" #include "Config.h"
#include "svnrev.h" #include "svnrev.h"
#include "ConsoleLogger.h" #include "gui/ConsoleLogger.h"
#include <wx/ffile.h> #include <wx/ffile.h>
#include <map> #include <map>
@ -280,7 +280,7 @@ void FileMemoryCard::Open()
continue; continue;
} }
wxFileName fname(g_Conf->FullpathToMcd(slot)); wxFileName fname(EmuConfig.FullpathToMcd(slot));
wxString str(fname.GetFullPath()); wxString str(fname.GetFullPath());
bool cont = false; bool cont = false;
@ -290,13 +290,13 @@ void FileMemoryCard::Open()
cont = true; cont = true;
} }
if (!g_Conf->Mcd[slot].Enabled) if (!EmuConfig.Mcd[slot].Enabled)
{ {
str = L"[disabled]"; str = L"[disabled]";
cont = true; cont = true;
} }
if (g_Conf->Mcd[slot].Type != MemoryCardType::MemoryCard_File) if (EmuConfig.Mcd[slot].Type != MemoryCardType::MemoryCard_File)
{ {
str = L"[is not memcard file]"; str = L"[is not memcard file]";
cont = true; cont = true;
@ -325,7 +325,7 @@ void FileMemoryCard::Open()
// (8MB, 256Mb, formatted, unformatted, etc ...) // (8MB, 256Mb, formatted, unformatted, etc ...)
#ifdef __WXMSW__ #ifdef __WXMSW__
NTFS_CompressFile(str, g_Conf->McdCompressNTFS); NTFS_CompressFile(str, EmuConfig.McdCompressNTFS);
#endif #endif
if (str.EndsWith(".bin")) if (str.EndsWith(".bin"))
@ -604,11 +604,11 @@ void FileMcd_EmuOpen()
// detect inserted memory card types // detect inserted memory card types
for (uint slot = 0; slot < 8; ++slot) for (uint slot = 0; slot < 8; ++slot)
{ {
if (g_Conf->Mcd[slot].Enabled) if (EmuConfig.Mcd[slot].Enabled)
{ {
MemoryCardType type = MemoryCardType::MemoryCard_File; // default to file if we can't find anything at the path so it gets auto-generated MemoryCardType type = MemoryCardType::MemoryCard_File; // default to file if we can't find anything at the path so it gets auto-generated
const wxString path = g_Conf->FullpathToMcd(slot); const wxString path = EmuConfig.FullpathToMcd(slot);
if (wxFileExists(path)) if (wxFileExists(path))
{ {
type = MemoryCardType::MemoryCard_File; type = MemoryCardType::MemoryCard_File;
@ -618,12 +618,12 @@ void FileMcd_EmuOpen()
type = MemoryCardType::MemoryCard_Folder; type = MemoryCardType::MemoryCard_Folder;
} }
g_Conf->Mcd[slot].Type = type; EmuConfig.Mcd[slot].Type = type;
} }
} }
Mcd::impl.Open(); Mcd::impl.Open();
Mcd::implFolder.SetFiltering(g_Conf->EmuOptions.McdFolderAutoManage); Mcd::implFolder.SetFiltering(EmuConfig.McdFolderAutoManage);
Mcd::implFolder.Open(); Mcd::implFolder.Open();
} }
@ -639,7 +639,7 @@ void FileMcd_EmuClose()
s32 FileMcd_IsPresent(uint port, uint slot) s32 FileMcd_IsPresent(uint port, uint slot)
{ {
const uint combinedSlot = FileMcd_ConvertToSlot(port, slot); const uint combinedSlot = FileMcd_ConvertToSlot(port, slot);
switch (g_Conf->Mcd[combinedSlot].Type) switch (EmuConfig.Mcd[combinedSlot].Type)
{ {
case MemoryCardType::MemoryCard_File: case MemoryCardType::MemoryCard_File:
return Mcd::impl.IsPresent(combinedSlot); return Mcd::impl.IsPresent(combinedSlot);
@ -653,7 +653,7 @@ s32 FileMcd_IsPresent(uint port, uint slot)
void FileMcd_GetSizeInfo(uint port, uint slot, McdSizeInfo* outways) void FileMcd_GetSizeInfo(uint port, uint slot, McdSizeInfo* outways)
{ {
const uint combinedSlot = FileMcd_ConvertToSlot(port, slot); const uint combinedSlot = FileMcd_ConvertToSlot(port, slot);
switch (g_Conf->Mcd[combinedSlot].Type) switch (EmuConfig.Mcd[combinedSlot].Type)
{ {
case MemoryCardType::MemoryCard_File: case MemoryCardType::MemoryCard_File:
Mcd::impl.GetSizeInfo(combinedSlot, *outways); Mcd::impl.GetSizeInfo(combinedSlot, *outways);
@ -669,7 +669,7 @@ void FileMcd_GetSizeInfo(uint port, uint slot, McdSizeInfo* outways)
bool FileMcd_IsPSX(uint port, uint slot) bool FileMcd_IsPSX(uint port, uint slot)
{ {
const uint combinedSlot = FileMcd_ConvertToSlot(port, slot); const uint combinedSlot = FileMcd_ConvertToSlot(port, slot);
switch (g_Conf->Mcd[combinedSlot].Type) switch (EmuConfig.Mcd[combinedSlot].Type)
{ {
case MemoryCardType::MemoryCard_File: case MemoryCardType::MemoryCard_File:
return Mcd::impl.IsPSX(combinedSlot); return Mcd::impl.IsPSX(combinedSlot);
@ -683,7 +683,7 @@ bool FileMcd_IsPSX(uint port, uint slot)
s32 FileMcd_Read(uint port, uint slot, u8* dest, u32 adr, int size) s32 FileMcd_Read(uint port, uint slot, u8* dest, u32 adr, int size)
{ {
const uint combinedSlot = FileMcd_ConvertToSlot(port, slot); const uint combinedSlot = FileMcd_ConvertToSlot(port, slot);
switch (g_Conf->Mcd[combinedSlot].Type) switch (EmuConfig.Mcd[combinedSlot].Type)
{ {
case MemoryCardType::MemoryCard_File: case MemoryCardType::MemoryCard_File:
return Mcd::impl.Read(combinedSlot, dest, adr, size); return Mcd::impl.Read(combinedSlot, dest, adr, size);
@ -697,7 +697,7 @@ s32 FileMcd_Read(uint port, uint slot, u8* dest, u32 adr, int size)
s32 FileMcd_Save(uint port, uint slot, const u8* src, u32 adr, int size) s32 FileMcd_Save(uint port, uint slot, const u8* src, u32 adr, int size)
{ {
const uint combinedSlot = FileMcd_ConvertToSlot(port, slot); const uint combinedSlot = FileMcd_ConvertToSlot(port, slot);
switch (g_Conf->Mcd[combinedSlot].Type) switch (EmuConfig.Mcd[combinedSlot].Type)
{ {
case MemoryCardType::MemoryCard_File: case MemoryCardType::MemoryCard_File:
return Mcd::impl.Save(combinedSlot, src, adr, size); return Mcd::impl.Save(combinedSlot, src, adr, size);
@ -711,7 +711,7 @@ s32 FileMcd_Save(uint port, uint slot, const u8* src, u32 adr, int size)
s32 FileMcd_EraseBlock(uint port, uint slot, u32 adr) s32 FileMcd_EraseBlock(uint port, uint slot, u32 adr)
{ {
const uint combinedSlot = FileMcd_ConvertToSlot(port, slot); const uint combinedSlot = FileMcd_ConvertToSlot(port, slot);
switch (g_Conf->Mcd[combinedSlot].Type) switch (EmuConfig.Mcd[combinedSlot].Type)
{ {
case MemoryCardType::MemoryCard_File: case MemoryCardType::MemoryCard_File:
return Mcd::impl.EraseBlock(combinedSlot, adr); return Mcd::impl.EraseBlock(combinedSlot, adr);
@ -725,7 +725,7 @@ s32 FileMcd_EraseBlock(uint port, uint slot, u32 adr)
u64 FileMcd_GetCRC(uint port, uint slot) u64 FileMcd_GetCRC(uint port, uint slot)
{ {
const uint combinedSlot = FileMcd_ConvertToSlot(port, slot); const uint combinedSlot = FileMcd_ConvertToSlot(port, slot);
switch (g_Conf->Mcd[combinedSlot].Type) switch (EmuConfig.Mcd[combinedSlot].Type)
{ {
case MemoryCardType::MemoryCard_File: case MemoryCardType::MemoryCard_File:
return Mcd::impl.GetCRC(combinedSlot); return Mcd::impl.GetCRC(combinedSlot);
@ -739,7 +739,7 @@ u64 FileMcd_GetCRC(uint port, uint slot)
void FileMcd_NextFrame(uint port, uint slot) void FileMcd_NextFrame(uint port, uint slot)
{ {
const uint combinedSlot = FileMcd_ConvertToSlot(port, slot); const uint combinedSlot = FileMcd_ConvertToSlot(port, slot);
switch (g_Conf->Mcd[combinedSlot].Type) switch (EmuConfig.Mcd[combinedSlot].Type)
{ {
//case MemoryCardType::MemoryCard_File: //case MemoryCardType::MemoryCard_File:
// Mcd::impl.NextFrame( combinedSlot ); // Mcd::impl.NextFrame( combinedSlot );
@ -755,13 +755,13 @@ void FileMcd_NextFrame(uint port, uint slot)
bool FileMcd_ReIndex(uint port, uint slot, const wxString& filter) bool FileMcd_ReIndex(uint port, uint slot, const wxString& filter)
{ {
const uint combinedSlot = FileMcd_ConvertToSlot(port, slot); const uint combinedSlot = FileMcd_ConvertToSlot(port, slot);
switch (g_Conf->Mcd[combinedSlot].Type) switch (EmuConfig.Mcd[combinedSlot].Type)
{ {
//case MemoryCardType::MemoryCard_File: //case MemoryCardType::MemoryCard_File:
// return Mcd::impl.ReIndex( combinedSlot, filter ); // return Mcd::impl.ReIndex( combinedSlot, filter );
// break; // break;
case MemoryCardType::MemoryCard_Folder: case MemoryCardType::MemoryCard_Folder:
return Mcd::implFolder.ReIndex(combinedSlot, g_Conf->EmuOptions.McdFolderAutoManage, filter); return Mcd::implFolder.ReIndex(combinedSlot, EmuConfig.McdFolderAutoManage, filter);
break; break;
default: default:
return false; return false;

View File

@ -20,7 +20,7 @@
#include "MemoryCardFolder.h" #include "MemoryCardFolder.h"
#include "System.h" #include "System.h"
#include "AppConfig.h" #include "Config.h"
#include "yaml-cpp/yaml.h" #include "yaml-cpp/yaml.h"
@ -91,10 +91,10 @@ bool FolderMemoryCard::IsFormatted() const
void FolderMemoryCard::Open(const bool enableFiltering, const wxString& filter) void FolderMemoryCard::Open(const bool enableFiltering, const wxString& filter)
{ {
Open(g_Conf->FullpathToMcd(m_slot), g_Conf->Mcd[m_slot], 0, enableFiltering, filter, false); Open(EmuConfig.FullpathToMcd(m_slot), EmuConfig.Mcd[m_slot], 0, enableFiltering, filter, false);
} }
void FolderMemoryCard::Open(const wxString& fullPath, const AppConfig::McdOptions& mcdOptions, const u32 sizeInClusters, const bool enableFiltering, const wxString& filter, bool simulateFileWrites) void FolderMemoryCard::Open(const wxString& fullPath, const Pcsx2Config::McdOptions& mcdOptions, const u32 sizeInClusters, const bool enableFiltering, const wxString& filter, bool simulateFileWrites)
{ {
InitializeInternalData(); InitializeInternalData();
m_performFileWrites = !simulateFileWrites; m_performFileWrites = !simulateFileWrites;

View File

@ -21,7 +21,7 @@
#include <map> #include <map>
#include <vector> #include <vector>
#include "AppConfig.h" #include "Config.h"
//#define DEBUG_WRITE_FOLDER_CARD_IN_MEMORY_TO_FILE_ON_CHANGE //#define DEBUG_WRITE_FOLDER_CARD_IN_MEMORY_TO_FILE_ON_CHANGE
@ -379,7 +379,7 @@ public:
// Initialize & Load Memory Card with values configured in the Memory Card Manager // Initialize & Load Memory Card with values configured in the Memory Card Manager
void Open(const bool enableFiltering, const wxString& filter); void Open(const bool enableFiltering, const wxString& filter);
// Initialize & Load Memory Card with provided custom values // Initialize & Load Memory Card with provided custom values
void Open(const wxString& fullPath, const AppConfig::McdOptions& mcdOptions, const u32 sizeInClusters, const bool enableFiltering, const wxString& filter, bool simulateFileWrites = false); void Open(const wxString& fullPath, const Pcsx2Config::McdOptions& mcdOptions, const u32 sizeInClusters, const bool enableFiltering, const wxString& filter, bool simulateFileWrites = false);
// Close the memory card and flush changes to the file system. Set flush to false to not store changes. // Close the memory card and flush changes to the file system. Set flush to false to not store changes.
void Close(bool flush = true); void Close(bool flush = true);

View File

@ -21,6 +21,7 @@
#include "Config.h" #include "Config.h"
#include "GS.h" #include "GS.h"
#include "CDVD/CDVDaccess.h" #include "CDVD/CDVDaccess.h"
#include "MemoryCardFile.h"
#ifndef PCSX2_CORE #ifndef PCSX2_CORE
#include "gui/AppConfig.h" #include "gui/AppConfig.h"
@ -493,6 +494,20 @@ Pcsx2Config::Pcsx2Config()
EnablePatches = true; EnablePatches = true;
BackupSavestate = true; BackupSavestate = true;
#ifdef __WXMSW__
McdCompressNTFS = true;
#endif
// To be moved to FileMemoryCard pluign (someday)
for (uint slot = 0; slot < 8; ++slot)
{
Mcd[slot].Enabled = !FileMcd_IsMultitapSlot(slot); // enables main 2 slots
Mcd[slot].Filename = FileMcd_GetDefaultName(slot);
// Folder memory card is autodetected later.
Mcd[slot].Type = MemoryCardType::MemoryCard_File;
}
GzipIsoIndexTemplate = L"$(f).pindex.tmp"; GzipIsoIndexTemplate = L"$(f).pindex.tmp";
CdvdSource = CDVD_SourceType::Iso; CdvdSource = CDVD_SourceType::Iso;
@ -538,6 +553,13 @@ void Pcsx2Config::LoadSave( IniInterface& ini )
#ifdef PCSX2_CORE #ifdef PCSX2_CORE
BaseFilenames.LoadSave(ini); BaseFilenames.LoadSave(ini);
Framerate.LoadSave(ini); Framerate.LoadSave(ini);
LoadSaveMemcards(ini);
IniEntry(GzipIsoIndexTemplate);
#ifdef __WXMSW__
IniEntry(McdCompressNTFS);
#endif
#endif #endif
if (ini.IsLoading()) if (ini.IsLoading())
@ -548,6 +570,30 @@ void Pcsx2Config::LoadSave( IniInterface& ini )
ini.Flush(); ini.Flush();
} }
void Pcsx2Config::LoadSaveMemcards( IniInterface& ini )
{
ScopedIniGroup path( ini, L"MemoryCards" );
for( uint slot=0; slot<2; ++slot )
{
ini.Entry( pxsFmt( L"Slot%u_Enable", slot+1 ),
Mcd[slot].Enabled, Mcd[slot].Enabled );
ini.Entry( pxsFmt( L"Slot%u_Filename", slot+1 ),
Mcd[slot].Filename, Mcd[slot].Filename );
}
for( uint slot=2; slot<8; ++slot )
{
int mtport = FileMcd_GetMtapPort(slot)+1;
int mtslot = FileMcd_GetMtapSlot(slot)+1;
ini.Entry( pxsFmt( L"Multitap%u_Slot%u_Enable", mtport, mtslot ),
Mcd[slot].Enabled, Mcd[slot].Enabled );
ini.Entry( pxsFmt( L"Multitap%u_Slot%u_Filename", mtport, mtslot ),
Mcd[slot].Filename, Mcd[slot].Filename );
}
}
bool Pcsx2Config::MultitapEnabled( uint port ) const bool Pcsx2Config::MultitapEnabled( uint port ) const
{ {
pxAssert( port < 2 ); pxAssert( port < 2 );
@ -577,6 +623,11 @@ wxString Pcsx2Config::FullpathToBios() const
return Path::Combine(Folders.Bios, BaseFilenames.Bios); return Path::Combine(Folders.Bios, BaseFilenames.Bios);
} }
wxString Pcsx2Config::FullpathToMcd(uint slot) const
{
return Path::Combine(Folders.MemoryCards, Mcd[slot].Filename);
}
void Pcsx2Config::CopyConfig(const Pcsx2Config& cfg) void Pcsx2Config::CopyConfig(const Pcsx2Config& cfg)
{ {
Cpu = cfg.Cpu; Cpu = cfg.Cpu;
@ -588,6 +639,8 @@ void Pcsx2Config::CopyConfig(const Pcsx2Config& cfg)
Trace = cfg.Trace; Trace = cfg.Trace;
BaseFilenames = cfg.BaseFilenames; BaseFilenames = cfg.BaseFilenames;
Framerate = cfg.Framerate; Framerate = cfg.Framerate;
for (u32 i = 0; i < sizeof(Mcd) / sizeof(Mcd[0]); i++)
Mcd[i] = cfg.Mcd[i];
GzipIsoIndexTemplate = cfg.GzipIsoIndexTemplate; GzipIsoIndexTemplate = cfg.GzipIsoIndexTemplate;
@ -609,4 +662,7 @@ void Pcsx2Config::CopyConfig(const Pcsx2Config& cfg)
MultitapPort1_Enabled = cfg.MultitapPort1_Enabled; MultitapPort1_Enabled = cfg.MultitapPort1_Enabled;
ConsoleToStdio = cfg.ConsoleToStdio; ConsoleToStdio = cfg.ConsoleToStdio;
HostFs = cfg.HostFs; HostFs = cfg.HostFs;
#ifdef __WXMSW__
McdCompressNTFS = cfg.McdCompressNTFS;
#endif
} }

View File

@ -15,7 +15,7 @@
#pragma once #pragma once
#include "gui/MemoryCardFile.h" #include "MemoryCardFile.h"
struct _mcd struct _mcd
{ {

View File

@ -30,7 +30,7 @@
#include "SPU2/spu2.h" #include "SPU2/spu2.h"
#include "DEV9/DEV9.h" #include "DEV9/DEV9.h"
#include "USB/USB.h" #include "USB/USB.h"
#include "gui/MemoryCardFile.h" #include "MemoryCardFile.h"
#ifdef _WIN32 #ifdef _WIN32
#include "PAD/Windows/PAD.h" #include "PAD/Windows/PAD.h"
#else #else

View File

@ -17,8 +17,6 @@
#include "App.h" #include "App.h"
#include "MainFrame.h" #include "MainFrame.h"
#include "MemoryCardFile.h"
#include "common/IniInterface.h" #include "common/IniInterface.h"
#include <wx/stdpaths.h> #include <wx/stdpaths.h>
@ -436,11 +434,6 @@ wxString GetUiKeysFilename()
return GetSettingsFolder().Combine( fname ).GetFullPath(); return GetSettingsFolder().Combine( fname ).GetFullPath();
} }
wxString AppConfig::FullpathToMcd( uint slot ) const
{
return Path::Combine( Folders.MemoryCards, Mcd[slot].Filename );
}
bool IsPortable() bool IsPortable()
{ {
return InstallationMode==InstallMode_Portable; return InstallationMode==InstallMode_Portable;
@ -460,25 +453,12 @@ AppConfig::AppConfig()
Toolbar_ImageSize = 24; Toolbar_ImageSize = 24;
Toolbar_ShowLabels = true; Toolbar_ShowLabels = true;
#ifdef __WXMSW__
McdCompressNTFS = true;
#endif
EnableSpeedHacks = true; EnableSpeedHacks = true;
EnableGameFixes = false; EnableGameFixes = false;
EnableFastBoot = true; EnableFastBoot = true;
EnablePresets = true; EnablePresets = true;
PresetIndex = 1; PresetIndex = 1;
// To be moved to FileMemoryCard pluign (someday)
for( uint slot=0; slot<8; ++slot )
{
Mcd[slot].Enabled = !FileMcd_IsMultitapSlot(slot); // enables main 2 slots
Mcd[slot].Filename = FileMcd_GetDefaultName( slot );
// Folder memory card is autodetected later.
Mcd[slot].Type = MemoryCardType::MemoryCard_File;
}
} }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
@ -529,30 +509,6 @@ void App_SaveInstallSettings( wxConfigBase* ini )
} }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
void AppConfig::LoadSaveMemcards( IniInterface& ini )
{
ScopedIniGroup path( ini, L"MemoryCards" );
for( uint slot=0; slot<2; ++slot )
{
ini.Entry( pxsFmt( L"Slot%u_Enable", slot+1 ),
Mcd[slot].Enabled, Mcd[slot].Enabled );
ini.Entry( pxsFmt( L"Slot%u_Filename", slot+1 ),
Mcd[slot].Filename, Mcd[slot].Filename );
}
for( uint slot=2; slot<8; ++slot )
{
int mtport = FileMcd_GetMtapPort(slot)+1;
int mtslot = FileMcd_GetMtapSlot(slot)+1;
ini.Entry( pxsFmt( L"Multitap%u_Slot%u_Enable", mtport, mtslot ),
Mcd[slot].Enabled, Mcd[slot].Enabled );
ini.Entry( pxsFmt( L"Multitap%u_Slot%u_Filename", mtport, mtslot ),
Mcd[slot].Filename, Mcd[slot].Filename );
}
}
void AppConfig::LoadSaveRootItems( IniInterface& ini ) void AppConfig::LoadSaveRootItems( IniInterface& ini )
{ {
IniEntry( MainGuiPosition ); IniEntry( MainGuiPosition );
@ -588,7 +544,7 @@ void AppConfig::LoadSaveRootItems( IniInterface& ini )
IniEntry( AskOnBoot ); IniEntry( AskOnBoot );
#ifdef __WXMSW__ #ifdef __WXMSW__
IniEntry( McdCompressNTFS ); ini.Entry(wxT("McdCompressNTFS"), EmuOptions.McdCompressNTFS, EmuOptions.McdCompressNTFS);
#endif #endif
} }
@ -596,7 +552,7 @@ void AppConfig::LoadSaveRootItems( IniInterface& ini )
void AppConfig::LoadSave( IniInterface& ini ) void AppConfig::LoadSave( IniInterface& ini )
{ {
LoadSaveRootItems( ini ); LoadSaveRootItems( ini );
LoadSaveMemcards( ini ); EmuOptions.LoadSaveMemcards( ini );
// Process various sub-components: // Process various sub-components:
ProgLogBox .LoadSave( ini, L"ProgramLog" ); ProgLogBox .LoadSave( ini, L"ProgramLog" );

View File

@ -153,16 +153,6 @@ public:
bool IsDefault( FoldersEnum_t folderidx ) const; bool IsDefault( FoldersEnum_t folderidx ) const;
}; };
// ------------------------------------------------------------------------
// Options struct for each memory card.
//
struct McdOptions
{
wxFileName Filename; // user-configured location of this memory card
bool Enabled; // memory card enabled (if false, memcard will not show up in-game)
MemoryCardType Type; // the memory card implementation that should be used
};
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
// The GS window receives much love from the land of Options and Settings. // The GS window receives much love from the land of Options and Settings.
// //
@ -260,11 +250,6 @@ public:
// Enables display of toolbar text labels. // Enables display of toolbar text labels.
bool Toolbar_ShowLabels; bool Toolbar_ShowLabels;
// uses automatic ntfs compression when creating new memory cards (Win32 only)
#ifdef __WXMSW__
bool McdCompressNTFS;
#endif
// Master toggle for enabling or disabling all speedhacks in one fail-free swoop. // Master toggle for enabling or disabling all speedhacks in one fail-free swoop.
// (the toggle is applied when a new EmuConfig is sent through AppCoreThread::ApplySettings) // (the toggle is applied when a new EmuConfig is sent through AppCoreThread::ApplySettings)
bool EnableSpeedHacks; bool EnableSpeedHacks;
@ -283,10 +268,6 @@ public:
bool AskOnBoot; bool AskOnBoot;
// Memorycard options - first 2 are default slots, last 6 are multitap 1 and 2
// slots (3 each)
McdOptions Mcd[8];
ConsoleLogOptions ProgLogBox; ConsoleLogOptions ProgLogBox;
FolderOptions Folders; FolderOptions Folders;
GSWindowOptions GSWindow; GSWindowOptions GSWindow;
@ -305,11 +286,8 @@ public:
public: public:
AppConfig(); AppConfig();
wxString FullpathToMcd( uint slot ) const;
void LoadSave( IniInterface& ini ); void LoadSave( IniInterface& ini );
void LoadSaveRootItems( IniInterface& ini ); void LoadSaveRootItems( IniInterface& ini );
void LoadSaveMemcards( IniInterface& ini );
static int GetMaxPresetIndex(); static int GetMaxPresetIndex();
static bool isOkGetPresetTextAndColor(int n, wxString& label, wxColor& c); static bool isOkGetPresetTextAndColor(int n, wxString& label, wxColor& c);

View File

@ -745,7 +745,7 @@ void AppApplySettings( const AppConfig* oldconf )
// Memcards generally compress very well via NTFS compression. // Memcards generally compress very well via NTFS compression.
#ifdef __WXMSW__ #ifdef __WXMSW__
NTFS_CompressFile( g_Conf->Folders.MemoryCards.ToString(), g_Conf->McdCompressNTFS ); NTFS_CompressFile( g_Conf->Folders.MemoryCards.ToString(), g_Conf->EmuOptions.McdCompressNTFS );
#endif #endif
sApp.DispatchEvent( AppStatus_SettingsApplied ); sApp.DispatchEvent( AppStatus_SettingsApplied );

View File

@ -196,7 +196,7 @@ namespace Dialogs
public: public:
virtual ~ConvertMemoryCardDialog() = default; virtual ~ConvertMemoryCardDialog() = default;
ConvertMemoryCardDialog( wxWindow* parent, const wxDirName& mcdPath, const AppConfig::McdOptions& mcdSourceConfig ); ConvertMemoryCardDialog( wxWindow* parent, const wxDirName& mcdPath, const Pcsx2Config::McdOptions& mcdSourceConfig );
protected: protected:
void CreateControls( const MemoryCardType sourceType ); void CreateControls( const MemoryCardType sourceType );

View File

@ -19,8 +19,8 @@
#include "gui/MSWstuff.h" #include "gui/MSWstuff.h"
#include "gui/MemoryCardFile.h" #include "MemoryCardFile.h"
#include "gui/MemoryCardFolder.h" #include "MemoryCardFolder.h"
#include <wx/ffile.h> #include <wx/ffile.h>
enum MemoryCardConversionType { enum MemoryCardConversionType {
@ -32,7 +32,7 @@ enum MemoryCardConversionType {
MemoryCardConversion_MaxCount MemoryCardConversion_MaxCount
}; };
Dialogs::ConvertMemoryCardDialog::ConvertMemoryCardDialog( wxWindow* parent, const wxDirName& mcdPath, const AppConfig::McdOptions& mcdSourceConfig ) Dialogs::ConvertMemoryCardDialog::ConvertMemoryCardDialog( wxWindow* parent, const wxDirName& mcdPath, const Pcsx2Config::McdOptions& mcdSourceConfig )
: wxDialogWithHelpers( parent, _( "Convert a memory card to a different format" ) ) : wxDialogWithHelpers( parent, _( "Convert a memory card to a different format" ) )
, m_mcdPath( mcdPath ) , m_mcdPath( mcdPath )
, m_mcdSourceFilename( mcdSourceConfig.Filename.GetFullName() ) , m_mcdSourceFilename( mcdSourceConfig.Filename.GetFullName() )
@ -175,7 +175,7 @@ bool Dialogs::ConvertMemoryCardDialog::ConvertToFile( const wxFileName& sourcePa
} }
FolderMemoryCard sourceFolderMemoryCard; FolderMemoryCard sourceFolderMemoryCard;
AppConfig::McdOptions config; Pcsx2Config::McdOptions config;
config.Enabled = true; config.Enabled = true;
config.Type = MemoryCardType::MemoryCard_Folder; config.Type = MemoryCardType::MemoryCard_Folder;
sourceFolderMemoryCard.Open( sourcePath.GetFullPath(), config, ( sizeInMB * 1024 * 1024 ) / FolderMemoryCard::ClusterSize, false, L"" ); sourceFolderMemoryCard.Open( sourcePath.GetFullPath(), config, ( sizeInMB * 1024 * 1024 ) / FolderMemoryCard::ClusterSize, false, L"" );
@ -204,7 +204,7 @@ bool Dialogs::ConvertMemoryCardDialog::ConvertToFolder( const wxFileName& source
u8 buffer[FolderMemoryCard::PageSizeRaw]; u8 buffer[FolderMemoryCard::PageSizeRaw];
FolderMemoryCard targetFolderMemoryCard; FolderMemoryCard targetFolderMemoryCard;
AppConfig::McdOptions config; Pcsx2Config::McdOptions config;
config.Enabled = true; config.Enabled = true;
config.Type = MemoryCardType::MemoryCard_Folder; config.Type = MemoryCardType::MemoryCard_Folder;
u32 adr = 0; u32 adr = 0;

View File

@ -18,7 +18,7 @@
#include "System.h" #include "System.h"
#include "gui/MSWstuff.h" #include "gui/MSWstuff.h"
#include "gui/MemoryCardFile.h" #include "MemoryCardFile.h"
//#include <wx/filepicker.h> //#include <wx/filepicker.h>
#include <wx/ffile.h> #include <wx/ffile.h>
@ -158,7 +158,7 @@ void Dialogs::CreateMemoryCardDialog::OnOk_Click( wxCommandEvent& evt )
// [TODO] Remove g_Conf->McdCompressNTFS, and have this dialog load/save directly from the ini. // [TODO] Remove g_Conf->McdCompressNTFS, and have this dialog load/save directly from the ini.
#ifdef __WXMSW__ #ifdef __WXMSW__
g_Conf->McdCompressNTFS = m_check_CompressNTFS->GetValue(); g_Conf->EmuOptions.McdCompressNTFS = m_check_CompressNTFS->GetValue();
#endif #endif
result_createdMcdFilename=L"_INVALID_FILE_NAME_"; result_createdMcdFilename=L"_INVALID_FILE_NAME_";
@ -220,7 +220,7 @@ void Dialogs::CreateMemoryCardDialog::CreateControls()
// Initial value of the checkbox is saved between calls to the dialog box. If the user checks // Initial value of the checkbox is saved between calls to the dialog box. If the user checks
// the option, it remains checked for future dialog. If the user unchecks it, ditto. // the option, it remains checked for future dialog. If the user unchecks it, ditto.
m_check_CompressNTFS->SetValue( g_Conf->McdCompressNTFS ); m_check_CompressNTFS->SetValue( g_Conf->EmuOptions.McdCompressNTFS );
#endif #endif
m_text_filenameInput = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER); m_text_filenameInput = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER);

View File

@ -16,7 +16,7 @@
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
#include "gui/AppCoreThread.h" #include "gui/AppCoreThread.h"
#include "System.h" #include "System.h"
#include "gui/MemoryCardFile.h" #include "MemoryCardFile.h"
#include "ConfigurationPanels.h" #include "ConfigurationPanels.h"
#include "MemoryCardPanels.h" #include "MemoryCardPanels.h"
@ -546,17 +546,17 @@ void Panels::MemoryCardListPanel_Simple::Apply()
Console.WriteLn(L"Apply memory cards:"); Console.WriteLn(L"Apply memory cards:");
for (uint slot = 0; slot < 8; ++slot) for (uint slot = 0; slot < 8; ++slot)
{ {
g_Conf->Mcd[slot].Type = m_Cards[slot].Type; g_Conf->EmuOptions.Mcd[slot].Type = m_Cards[slot].Type;
g_Conf->Mcd[slot].Enabled = m_Cards[slot].IsEnabled && m_Cards[slot].IsPresent; g_Conf->EmuOptions.Mcd[slot].Enabled = m_Cards[slot].IsEnabled && m_Cards[slot].IsPresent;
if (m_Cards[slot].IsPresent) if (m_Cards[slot].IsPresent)
g_Conf->Mcd[slot].Filename = m_Cards[slot].Filename; g_Conf->EmuOptions.Mcd[slot].Filename = m_Cards[slot].Filename;
else else
g_Conf->Mcd[slot].Filename = L""; g_Conf->EmuOptions.Mcd[slot].Filename = L"";
if (g_Conf->Mcd[slot].Enabled) if (g_Conf->EmuOptions.Mcd[slot].Enabled)
{ {
used++; used++;
Console.WriteLn(L"slot[%d]='%s'", slot, WX_STR(g_Conf->Mcd[slot].Filename.GetFullName())); Console.WriteLn(L"slot[%d]='%s'", slot, WX_STR(g_Conf->EmuOptions.Mcd[slot].Filename.GetFullName()));
} }
} }
if (!used) if (!used)
@ -569,8 +569,8 @@ void Panels::MemoryCardListPanel_Simple::AppStatusEvent_OnSettingsApplied()
{ {
for (uint slot = 0; slot < 8; ++slot) for (uint slot = 0; slot < 8; ++slot)
{ {
m_Cards[slot].IsEnabled = g_Conf->Mcd[slot].Enabled; m_Cards[slot].IsEnabled = g_Conf->EmuOptions.Mcd[slot].Enabled;
m_Cards[slot].Filename = g_Conf->Mcd[slot].Filename; m_Cards[slot].Filename = g_Conf->EmuOptions.Mcd[slot].Filename;
// Automatically create the enabled but non-existing file such that it can be managed (else will get created anyway on boot) // Automatically create the enabled but non-existing file such that it can be managed (else will get created anyway on boot)
wxString targetFile = (GetMcdPath() + m_Cards[slot].Filename.GetFullName()).GetFullPath(); wxString targetFile = (GetMcdPath() + m_Cards[slot].Filename.GetFullName()).GetFullPath();
@ -697,7 +697,7 @@ void Panels::MemoryCardListPanel_Simple::UiConvertCard(McdSlotItem& card)
return; return;
} }
AppConfig::McdOptions config; Pcsx2Config::McdOptions config;
config.Filename = card.Filename.GetFullName(); config.Filename = card.Filename.GetFullName();
config.Enabled = card.IsEnabled; config.Enabled = card.IsEnabled;
config.Type = card.Type; config.Type = card.Type;

View File

@ -323,6 +323,8 @@
<ClCompile Include="IopGte.cpp" /> <ClCompile Include="IopGte.cpp" />
<ClCompile Include="IPC.cpp" /> <ClCompile Include="IPC.cpp" />
<ClCompile Include="FW.cpp" /> <ClCompile Include="FW.cpp" />
<ClCompile Include="MemoryCardFile.cpp" />
<ClCompile Include="MemoryCardFolder.cpp" />
<ClCompile Include="PAD\Windows\PADConfig.cpp" /> <ClCompile Include="PAD\Windows\PADConfig.cpp" />
<ClCompile Include="PAD\Windows\DeviceEnumerator.cpp" /> <ClCompile Include="PAD\Windows\DeviceEnumerator.cpp" />
<ClCompile Include="PAD\Windows\Diagnostics.cpp" /> <ClCompile Include="PAD\Windows\Diagnostics.cpp" />
@ -660,8 +662,6 @@
<ClCompile Include="gui\IsoDropTarget.cpp" /> <ClCompile Include="gui\IsoDropTarget.cpp" />
<ClCompile Include="gui\MainFrame.cpp" /> <ClCompile Include="gui\MainFrame.cpp" />
<ClCompile Include="gui\MainMenuClicks.cpp" /> <ClCompile Include="gui\MainMenuClicks.cpp" />
<ClCompile Include="gui\MemoryCardFile.cpp" />
<ClCompile Include="gui\MemoryCardFolder.cpp" />
<ClCompile Include="gui\MessageBoxes.cpp" /> <ClCompile Include="gui\MessageBoxes.cpp" />
<ClCompile Include="gui\MSWstuff.cpp" /> <ClCompile Include="gui\MSWstuff.cpp" />
<ClCompile Include="gui\RecentIsoList.cpp" /> <ClCompile Include="gui\RecentIsoList.cpp" />
@ -772,6 +772,8 @@
<ClInclude Include="IopGte.h" /> <ClInclude Include="IopGte.h" />
<ClInclude Include="IPC.h" /> <ClInclude Include="IPC.h" />
<ClInclude Include="FW.h" /> <ClInclude Include="FW.h" />
<ClInclude Include="MemoryCardFile.h" />
<ClInclude Include="MemoryCardFolder.h" />
<ClInclude Include="PAD\Windows\PAD.h" /> <ClInclude Include="PAD\Windows\PAD.h" />
<ClInclude Include="PAD\Windows\PADConfig.h" /> <ClInclude Include="PAD\Windows\PADConfig.h" />
<ClInclude Include="PAD\Windows\DeviceEnumerator.h" /> <ClInclude Include="PAD\Windows\DeviceEnumerator.h" />
@ -1082,8 +1084,6 @@
<ClInclude Include="gui\GSFrame.h" /> <ClInclude Include="gui\GSFrame.h" />
<ClInclude Include="gui\IsoDropTarget.h" /> <ClInclude Include="gui\IsoDropTarget.h" />
<ClInclude Include="gui\MainFrame.h" /> <ClInclude Include="gui\MainFrame.h" />
<ClInclude Include="gui\MemoryCardFile.h" />
<ClInclude Include="gui\MemoryCardFolder.h" />
<ClInclude Include="gui\pxEventThread.h" /> <ClInclude Include="gui\pxEventThread.h" />
<ClInclude Include="gui\RecentIsoList.h" /> <ClInclude Include="gui\RecentIsoList.h" />
<ClInclude Include="PathDefs.h" /> <ClInclude Include="PathDefs.h" />

View File

@ -761,12 +761,6 @@
<ClCompile Include="gui\MainMenuClicks.cpp"> <ClCompile Include="gui\MainMenuClicks.cpp">
<Filter>AppHost</Filter> <Filter>AppHost</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="gui\MemoryCardFile.cpp">
<Filter>AppHost</Filter>
</ClCompile>
<ClCompile Include="gui\MemoryCardFolder.cpp">
<Filter>AppHost</Filter>
</ClCompile>
<ClCompile Include="gui\MessageBoxes.cpp"> <ClCompile Include="gui\MessageBoxes.cpp">
<Filter>AppHost</Filter> <Filter>AppHost</Filter>
</ClCompile> </ClCompile>
@ -1667,6 +1661,12 @@
<ClCompile Include="gui\pxRadioPanel.cpp"> <ClCompile Include="gui\pxRadioPanel.cpp">
<Filter>AppHost</Filter> <Filter>AppHost</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="MemoryCardFile.cpp">
<Filter>System\Ps2\Iop</Filter>
</ClCompile>
<ClCompile Include="MemoryCardFolder.cpp">
<Filter>System\Ps2\Iop</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="Patch.h"> <ClInclude Include="Patch.h">
@ -1993,12 +1993,6 @@
<ClInclude Include="gui\MainFrame.h"> <ClInclude Include="gui\MainFrame.h">
<Filter>AppHost\Include</Filter> <Filter>AppHost\Include</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="gui\MemoryCardFile.h">
<Filter>AppHost\Include</Filter>
</ClInclude>
<ClInclude Include="gui\MemoryCardFolder.h">
<Filter>AppHost\Include</Filter>
</ClInclude>
<ClInclude Include="gui\RecentIsoList.h"> <ClInclude Include="gui\RecentIsoList.h">
<Filter>AppHost\Include</Filter> <Filter>AppHost\Include</Filter>
</ClInclude> </ClInclude>
@ -2767,6 +2761,12 @@
<ClInclude Include="gui\pxEvents.h"> <ClInclude Include="gui\pxEvents.h">
<Filter>AppHost</Filter> <Filter>AppHost</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="MemoryCardFolder.h">
<Filter>System\Ps2\Iop</Filter>
</ClInclude>
<ClInclude Include="MemoryCardFile.h">
<Filter>System\Ps2\Iop</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="windows\wxResources.rc"> <ResourceCompile Include="windows\wxResources.rc">