mirror of https://github.com/PCSX2/pcsx2.git
FolderMemoryCard: Allow multiple save names in the save file filtering.
Split multiple save names to be filtered with a "/", ie the filter "A/B" matches both save folders that contain "A" and save folders that contain "B".
This commit is contained in:
parent
880be6f602
commit
2ee1cb81dd
|
@ -264,6 +264,26 @@ MemoryCardFileEntry* FolderMemoryCard::AppendFileEntryToDir( MemoryCardFileEntry
|
||||||
return newFileEntry;
|
return newFileEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FilterMatches( const wxString& fileName, const wxString& filter ) {
|
||||||
|
size_t start = 0;
|
||||||
|
size_t len = filter.Len();
|
||||||
|
while ( start < len ) {
|
||||||
|
size_t end = filter.find( '/', start );
|
||||||
|
if ( end == wxString::npos ) {
|
||||||
|
end = len;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString singleFilter = filter.Mid( start, end - start );
|
||||||
|
if ( fileName.Contains( singleFilter ) ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
start = end + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool FolderMemoryCard::AddFolder( MemoryCardFileEntry* const dirEntry, const wxString& dirPath, const wxString& filter ) {
|
bool FolderMemoryCard::AddFolder( MemoryCardFileEntry* const dirEntry, const wxString& dirPath, const wxString& filter ) {
|
||||||
wxDir dir( dirPath );
|
wxDir dir( dirPath );
|
||||||
if ( dir.IsOpened() ) {
|
if ( dir.IsOpened() ) {
|
||||||
|
@ -274,6 +294,12 @@ bool FolderMemoryCard::AddFolder( MemoryCardFileEntry* const dirEntry, const wxS
|
||||||
wxString fileName;
|
wxString fileName;
|
||||||
bool hasNext;
|
bool hasNext;
|
||||||
|
|
||||||
|
wxString localFilter;
|
||||||
|
bool hasFilter = !filter.IsEmpty();
|
||||||
|
if ( hasFilter ) {
|
||||||
|
localFilter = L"DATA-SYSTEM/" + filter;
|
||||||
|
}
|
||||||
|
|
||||||
int entryNumber = 2; // include . and ..
|
int entryNumber = 2; // include . and ..
|
||||||
hasNext = dir.GetFirst( &fileName );
|
hasNext = dir.GetFirst( &fileName );
|
||||||
while ( hasNext ) {
|
while ( hasNext ) {
|
||||||
|
@ -293,7 +319,7 @@ bool FolderMemoryCard::AddFolder( MemoryCardFileEntry* const dirEntry, const wxS
|
||||||
// if possible filter added directories by game serial
|
// if possible filter added directories by game serial
|
||||||
// this has the effective result of only files relevant to the current game being loaded into the memory card
|
// this has the effective result of only files relevant to the current game being loaded into the memory card
|
||||||
// which means every game essentially sees the memory card as if no other files exist
|
// which means every game essentially sees the memory card as if no other files exist
|
||||||
if ( !filter.IsEmpty() && !fileName.Contains( filter ) ) {
|
if ( hasFilter && !FilterMatches( fileName, localFilter ) ) {
|
||||||
hasNext = dir.GetNext( &fileName );
|
hasNext = dir.GetNext( &fileName );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1043,6 +1069,7 @@ void FolderMemoryCardAggregator::NextFrame( uint slot ) {
|
||||||
|
|
||||||
void FolderMemoryCardAggregator::ReIndex( uint slot, const wxString& filter ) {
|
void FolderMemoryCardAggregator::ReIndex( uint slot, const wxString& filter ) {
|
||||||
m_cards[slot].Close();
|
m_cards[slot].Close();
|
||||||
|
Console.WriteLn( Color_Green, L"(FolderMcd) Re-Indexing slot %u with filter \"%s\"", slot, WX_STR( filter ) );
|
||||||
m_cards[slot].Open( filter );
|
m_cards[slot].Open( filter );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue