Cheats - if cheats file is empty dont show "Cheats file loaded" message

This commit is contained in:
adelikat 2012-09-01 17:44:55 +00:00
parent e5a3764f69
commit c1d2272aec
2 changed files with 77 additions and 54 deletions

View File

@ -1397,8 +1397,10 @@ namespace BizHawk.MultiClient
if (Global.Config.LoadCheatFileByGame)
{
if (Global.CheatList.AttemptLoadCheatFile())
{
Global.OSD.AddMessage("Cheats file loaded");
}
}
CurrentlyOpenRom = file.CanonicalFullPath;
HandlePlatformMenus();

View File

@ -21,6 +21,7 @@ namespace BizHawk.MultiClient
var file = new FileInfo(path);
if (file.Exists == false) return false;
int cheatcount = 0;
using (StreamReader sr = file.OpenText())
{
if (!append) currentCheatFile = path;
@ -32,8 +33,9 @@ namespace BizHawk.MultiClient
{
Clear(); //Wipe existing list and read from file
}
while ((s = sr.ReadLine()) != null)
{
try
{
if (s.Length < 6) continue;
Cheat c = new Cheat();
@ -91,19 +93,35 @@ namespace BizHawk.MultiClient
s = s.Substring(y, s.Length - y); //Name
c.name = s;
cheatcount++;
cheatList.Add(c);
}
catch
{
continue;
}
Global.Config.RecentCheats.Add(file.FullName);
Changes = false;
}
}
if (Global.Config.DisableCheatsOnLoad)
{
for (int x = 0; x < cheatList.Count; x++)
{
cheatList[x].Disable();
}
return true; //TODO
}
if (cheatcount > 0)
{
Changes = false;
Global.Config.RecentCheats.Add(file.FullName);
return true;
}
else
{
return false;
}
}
public void NotSupportedError()
@ -299,9 +317,12 @@ namespace BizHawk.MultiClient
}
else
{
LoadCheatFile(CheatFile, false);
bool loaded = LoadCheatFile(CheatFile, false);
if (loaded)
{
Global.MainForm.UpdateCheatStatus();
return true;
}
return loaded;
}
}