New Cheat List - fix bugs in file loading

This commit is contained in:
adelikat 2013-10-04 22:21:09 +00:00
parent 55cab352a1
commit a32578eb42
3 changed files with 46 additions and 9 deletions

View File

@ -274,6 +274,18 @@ namespace BizHawk.MultiClient
return Path.Combine(MakeAbsolutePath(pathEntry.Path, game.System), name);
}
public static string GetCheatsPath(GameInfo game)
{
PathEntry pathEntry = Global.Config.PathEntries[game.System, "Cheats"];
if (pathEntry == null)
{
pathEntry = Global.Config.PathEntries[game.System, "Base"];
}
return MakeAbsolutePath(pathEntry.Path, game.System);
}
public static string ScreenshotPrefix(GameInfo game)
{
string name = FilesystemSafeName(game);

View File

@ -166,9 +166,14 @@ namespace BizHawk.MultiClient
using (StreamReader sr = file.OpenText())
{
if (!append)
if (append)
{
_changes = true;
}
else
{
Clear();
_changes = false;
}
string s;
@ -176,7 +181,8 @@ namespace BizHawk.MultiClient
{
try
{
int ADDR, VALUE, COMPARE;
int ADDR, VALUE;
int? COMPARE;
MemoryDomain DOMAIN;
bool ENABLED;
string NAME;
@ -186,7 +192,15 @@ namespace BizHawk.MultiClient
string[] vals = s.Split('\t');
ADDR = Int32.Parse(vals[0], NumberStyles.HexNumber);
VALUE = Int32.Parse(vals[1], NumberStyles.HexNumber);
COMPARE = Int32.Parse(vals[2], NumberStyles.HexNumber);
if (vals[2] == "N")
{
COMPARE = null;
}
else
{
COMPARE = Int32.Parse(vals[2], NumberStyles.HexNumber);
}
DOMAIN = ToolHelpers.DomainByName(vals[3]);
ENABLED = vals[4] == "1";
NAME = vals[5];
@ -210,7 +224,7 @@ namespace BizHawk.MultiClient
}
}
throw new NotImplementedException();
return true;
}
public string CurrentFileName
@ -241,9 +255,7 @@ namespace BizHawk.MultiClient
{
ofd.FileName = Path.GetFileNameWithoutExtension(currentFile);
}
ofd.InitialDirectory = PathManager.MakeAbsolutePath(
Global.Config.PathEntries[Global.Emulator.SystemId, "Cheats"].Path,
Global.Emulator.SystemId);
ofd.InitialDirectory = PathManager.GetCheatsPath(Global.Game);
ofd.Filter = "Cheat Files (*.cht)|*.cht|All Files|*.*";
ofd.RestoreDirectory = true;

View File

@ -26,7 +26,7 @@ namespace BizHawk.MultiClient
{ ADDRESS, 60 },
{ VALUE, 59 },
{ COMPARE, 59 },
{ ON, 25 },
{ ON, 28 },
{ DOMAIN, 55 },
};
@ -75,11 +75,24 @@ namespace BizHawk.MultiClient
{
Global.Config.RecentWatches.Add(path);
UpdateListView();
MessageLabel.Text = Path.GetFileName(path) + " loaded";
ShowFileName(loaded: true);
}
}
}
private void ShowFileName(bool loaded)
{
MessageLabel.Text = Path.GetFileName(Global.CheatList2.CurrentFileName);
if (loaded)
{
MessageLabel.Text += " loaded";
}
else if (Global.CheatList2.Changes)
{
MessageLabel.Text += " *";
}
}
public bool AskSave()
{
if (Global.Config.SupressAskSave) //User has elected to not be nagged