Ram Watch - Save as implemented
This commit is contained in:
parent
3b3c755d81
commit
cd46a96530
|
@ -55,6 +55,35 @@ namespace BizHawk.MultiClient
|
||||||
watchList.Clear();
|
watchList.Clear();
|
||||||
DisplayWatchList();
|
DisplayWatchList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool SaveWatchFile(string path)
|
||||||
|
{
|
||||||
|
var file = new FileInfo(path);
|
||||||
|
//if (file.Exists == true) //TODO: prompt to overwrite
|
||||||
|
|
||||||
|
using (StreamWriter sw = new StreamWriter(path))
|
||||||
|
{
|
||||||
|
string str = "";
|
||||||
|
|
||||||
|
for (int x = 0; x < watchList.Count; x++)
|
||||||
|
{
|
||||||
|
str += watchList[x].address.ToString() + "\t"; //TODO: Make hex
|
||||||
|
str += watchList[x].GetTypeByChar().ToString() + "\t";
|
||||||
|
str += watchList[x].GetSignedByChar().ToString() + "\t";
|
||||||
|
|
||||||
|
if (watchList[x].bigendian == true)
|
||||||
|
str += "1\t";
|
||||||
|
else
|
||||||
|
str += "0\t";
|
||||||
|
|
||||||
|
str += watchList[x].notes + "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
sw.WriteLine(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool LoadWatchFile(string path, bool append)
|
bool LoadWatchFile(string path, bool append)
|
||||||
{
|
{
|
||||||
|
@ -188,9 +217,28 @@ namespace BizHawk.MultiClient
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private FileInfo GetSaveFileFromUser()
|
||||||
|
{
|
||||||
|
var sfd = new SaveFileDialog();
|
||||||
|
sfd.InitialDirectory = Global.Config.LastRomPath;
|
||||||
|
sfd.Filter = "Watch Files (*.wch)|*.wch|All Files|*.*";
|
||||||
|
sfd.RestoreDirectory = true;
|
||||||
|
Global.Sound.StopSound();
|
||||||
|
var result = sfd.ShowDialog();
|
||||||
|
Global.Sound.StartSound();
|
||||||
|
if (result != DialogResult.OK)
|
||||||
|
return null;
|
||||||
|
var file = new FileInfo(sfd.FileName);
|
||||||
|
Global.Config.LastRomPath = file.DirectoryName;
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
|
private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
var file = GetSaveFileFromUser();
|
||||||
|
if (file != null)
|
||||||
|
SaveWatchFile(file.FullName);
|
||||||
|
//TODO: inform the user (with using an annoying message box)
|
||||||
}
|
}
|
||||||
|
|
||||||
private void appendFileToolStripMenuItem_Click(object sender, EventArgs e)
|
private void appendFileToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
|
|
@ -53,6 +53,21 @@ namespace BizHawk.MultiClient
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public char GetTypeByChar()
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case atype.BYTE:
|
||||||
|
return 'b';
|
||||||
|
case atype.WORD:
|
||||||
|
return 'w';
|
||||||
|
case atype.DWORD:
|
||||||
|
return 'd';
|
||||||
|
default:
|
||||||
|
return 'b'; //Just in case
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public bool SetSignedByChar(char c) //s = signed, u = unsigned, h = hex
|
public bool SetSignedByChar(char c) //s = signed, u = unsigned, h = hex
|
||||||
{
|
{
|
||||||
switch (c)
|
switch (c)
|
||||||
|
@ -70,5 +85,20 @@ namespace BizHawk.MultiClient
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public char GetSignedByChar()
|
||||||
|
{
|
||||||
|
switch (signed)
|
||||||
|
{
|
||||||
|
case asigned.SIGNED:
|
||||||
|
return 's';
|
||||||
|
case asigned.UNSIGNED:
|
||||||
|
return 'u';
|
||||||
|
case asigned.HEX:
|
||||||
|
return 'h';
|
||||||
|
default:
|
||||||
|
return 's'; //Just in case
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue