Patches: Try to load patch files matching the rom's full file name (including its extension)

This commit is contained in:
Sour 2019-11-13 19:56:36 -05:00
parent df6b003a36
commit 8364c186d4

View file

@ -217,6 +217,25 @@ namespace Mesen.GUI.Forms
}
}
private ResourcePath? GetIpsFile(ResourcePath romFile)
{
string[] extensions = new string[3] { ".ips", ".ups", ".bps" };
foreach(string ext in extensions) {
//Check if [romname].ips exists
string file = Path.Combine(romFile.Folder, Path.GetFileNameWithoutExtension(romFile.FileName)) + ext;
if(File.Exists(file)) {
return file;
} else {
//Check if [romname].[romext].ips exists
file = Path.Combine(romFile.Folder, Path.GetFileName(romFile.FileName)) + ext;
if(File.Exists(file)) {
return file;
}
}
}
return null;
}
private void LoadROM(ResourcePath romFile, bool autoLoadPatches = false, ResourcePath? patchFileToApply = null)
{
if(romFile.Exists) {
@ -231,14 +250,7 @@ namespace Mesen.GUI.Forms
ResourcePath? patchFile = patchFileToApply;
if(patchFile == null && autoLoadPatches) {
string[] extensions = new string[3] { ".ips", ".ups", ".bps" };
foreach(string ext in extensions) {
string file = Path.Combine(romFile.Folder, Path.GetFileNameWithoutExtension(romFile.FileName)) + ext;
if(File.Exists(file)) {
patchFile = file;
break;
}
}
patchFile = GetIpsFile(romFile);
}
Task loadRomTask = new Task(() => {