New Ram Watch - some low hanging fruit

This commit is contained in:
adelikat 2013-09-06 20:43:01 +00:00
parent 0815d20f93
commit 068665f85b
3 changed files with 66 additions and 20 deletions

View File

@ -150,32 +150,32 @@
// newToolStripButton // newToolStripButton
// //
this.newToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.newToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.newToolStripButton.Enabled = false;
this.newToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("newToolStripButton.Image"))); this.newToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("newToolStripButton.Image")));
this.newToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta; this.newToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta;
this.newToolStripButton.Name = "newToolStripButton"; this.newToolStripButton.Name = "newToolStripButton";
this.newToolStripButton.Size = new System.Drawing.Size(23, 22); this.newToolStripButton.Size = new System.Drawing.Size(23, 22);
this.newToolStripButton.Text = "&New"; this.newToolStripButton.Text = "&New";
this.newToolStripButton.Click += new System.EventHandler(this.newListToolStripMenuItem_Click);
// //
// openToolStripButton // openToolStripButton
// //
this.openToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.openToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.openToolStripButton.Enabled = false;
this.openToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("openToolStripButton.Image"))); this.openToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("openToolStripButton.Image")));
this.openToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta; this.openToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta;
this.openToolStripButton.Name = "openToolStripButton"; this.openToolStripButton.Name = "openToolStripButton";
this.openToolStripButton.Size = new System.Drawing.Size(23, 22); this.openToolStripButton.Size = new System.Drawing.Size(23, 22);
this.openToolStripButton.Text = "&Open"; this.openToolStripButton.Text = "&Open";
this.openToolStripButton.Click += new System.EventHandler(this.openToolStripMenuItem_Click);
// //
// saveToolStripButton // saveToolStripButton
// //
this.saveToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.saveToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.saveToolStripButton.Enabled = false;
this.saveToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("saveToolStripButton.Image"))); this.saveToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("saveToolStripButton.Image")));
this.saveToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta; this.saveToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta;
this.saveToolStripButton.Name = "saveToolStripButton"; this.saveToolStripButton.Name = "saveToolStripButton";
this.saveToolStripButton.Size = new System.Drawing.Size(23, 22); this.saveToolStripButton.Size = new System.Drawing.Size(23, 22);
this.saveToolStripButton.Text = "&Save"; this.saveToolStripButton.Text = "&Save";
this.saveToolStripButton.Click += new System.EventHandler(this.saveToolStripMenuItem_Click);
// //
// toolStripSeparator // toolStripSeparator
// //
@ -320,6 +320,7 @@
this.filesToolStripMenuItem.Name = "filesToolStripMenuItem"; this.filesToolStripMenuItem.Name = "filesToolStripMenuItem";
this.filesToolStripMenuItem.Size = new System.Drawing.Size(42, 20); this.filesToolStripMenuItem.Size = new System.Drawing.Size(42, 20);
this.filesToolStripMenuItem.Text = "&Files"; this.filesToolStripMenuItem.Text = "&Files";
this.filesToolStripMenuItem.DropDownOpened += new System.EventHandler(this.filesToolStripMenuItem_DropDownOpened);
// //
// newListToolStripMenuItem // newListToolStripMenuItem
// //
@ -341,28 +342,28 @@
// //
// saveToolStripMenuItem // saveToolStripMenuItem
// //
this.saveToolStripMenuItem.Enabled = false;
this.saveToolStripMenuItem.Image = global::BizHawk.MultiClient.Properties.Resources.SaveAs; this.saveToolStripMenuItem.Image = global::BizHawk.MultiClient.Properties.Resources.SaveAs;
this.saveToolStripMenuItem.Name = "saveToolStripMenuItem"; this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
this.saveToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S))); this.saveToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
this.saveToolStripMenuItem.Size = new System.Drawing.Size(195, 22); this.saveToolStripMenuItem.Size = new System.Drawing.Size(195, 22);
this.saveToolStripMenuItem.Text = "&Save"; this.saveToolStripMenuItem.Text = "&Save";
this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click);
// //
// saveAsToolStripMenuItem // saveAsToolStripMenuItem
// //
this.saveAsToolStripMenuItem.Enabled = false;
this.saveAsToolStripMenuItem.Name = "saveAsToolStripMenuItem"; this.saveAsToolStripMenuItem.Name = "saveAsToolStripMenuItem";
this.saveAsToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) this.saveAsToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
| System.Windows.Forms.Keys.S))); | System.Windows.Forms.Keys.S)));
this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(195, 22); this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(195, 22);
this.saveAsToolStripMenuItem.Text = "Save &As..."; this.saveAsToolStripMenuItem.Text = "Save &As...";
this.saveAsToolStripMenuItem.Click += new System.EventHandler(this.saveAsToolStripMenuItem_Click);
// //
// appendFileToolStripMenuItem // appendFileToolStripMenuItem
// //
this.appendFileToolStripMenuItem.Enabled = false;
this.appendFileToolStripMenuItem.Name = "appendFileToolStripMenuItem"; this.appendFileToolStripMenuItem.Name = "appendFileToolStripMenuItem";
this.appendFileToolStripMenuItem.Size = new System.Drawing.Size(195, 22); this.appendFileToolStripMenuItem.Size = new System.Drawing.Size(195, 22);
this.appendFileToolStripMenuItem.Text = "A&ppend File..."; this.appendFileToolStripMenuItem.Text = "A&ppend File...";
this.appendFileToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click);
// //
// recentToolStripMenuItem // recentToolStripMenuItem
// //
@ -600,6 +601,7 @@
this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem"; this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem";
this.optionsToolStripMenuItem.Size = new System.Drawing.Size(61, 20); this.optionsToolStripMenuItem.Size = new System.Drawing.Size(61, 20);
this.optionsToolStripMenuItem.Text = "&Options"; this.optionsToolStripMenuItem.Text = "&Options";
this.optionsToolStripMenuItem.DropDownOpened += new System.EventHandler(this.optionsToolStripMenuItem_DropDownOpened);
// //
// definePreviousValueAsToolStripMenuItem // definePreviousValueAsToolStripMenuItem
// //
@ -625,17 +627,17 @@
// //
// displayWatchesOnScreenToolStripMenuItem // displayWatchesOnScreenToolStripMenuItem
// //
this.displayWatchesOnScreenToolStripMenuItem.Enabled = false;
this.displayWatchesOnScreenToolStripMenuItem.Name = "displayWatchesOnScreenToolStripMenuItem"; this.displayWatchesOnScreenToolStripMenuItem.Name = "displayWatchesOnScreenToolStripMenuItem";
this.displayWatchesOnScreenToolStripMenuItem.Size = new System.Drawing.Size(217, 22); this.displayWatchesOnScreenToolStripMenuItem.Size = new System.Drawing.Size(217, 22);
this.displayWatchesOnScreenToolStripMenuItem.Text = "Display Watches On Screen"; this.displayWatchesOnScreenToolStripMenuItem.Text = "Display Watches On Screen";
this.displayWatchesOnScreenToolStripMenuItem.Click += new System.EventHandler(this.displayWatchesOnScreenToolStripMenuItem_Click);
// //
// saveWindowPositionToolStripMenuItem // saveWindowPositionToolStripMenuItem
// //
this.saveWindowPositionToolStripMenuItem.Enabled = false;
this.saveWindowPositionToolStripMenuItem.Name = "saveWindowPositionToolStripMenuItem"; this.saveWindowPositionToolStripMenuItem.Name = "saveWindowPositionToolStripMenuItem";
this.saveWindowPositionToolStripMenuItem.Size = new System.Drawing.Size(217, 22); this.saveWindowPositionToolStripMenuItem.Size = new System.Drawing.Size(217, 22);
this.saveWindowPositionToolStripMenuItem.Text = "Save Window Position"; this.saveWindowPositionToolStripMenuItem.Text = "Save Window Position";
this.saveWindowPositionToolStripMenuItem.Click += new System.EventHandler(this.saveWindowPositionToolStripMenuItem_Click);
// //
// toolStripSeparator7 // toolStripSeparator7
// //

View File

@ -220,6 +220,12 @@ namespace BizHawk.MultiClient
#region Winform Events #region Winform Events
/*************File***********************/
private void filesToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
{
saveToolStripMenuItem.Enabled = Watches.Changes;
}
private void NewRamWatch_Load(object sender, EventArgs e) private void NewRamWatch_Load(object sender, EventArgs e)
{ {
@ -232,7 +238,8 @@ namespace BizHawk.MultiClient
private void openToolStripMenuItem_Click(object sender, EventArgs e) private void openToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var file = WatchCommon.GetFileFromUser(Watches.CurrentFileName); bool append = sender == appendFileToolStripMenuItem;
var file = WatchCommon.GetFileFromUser(Watches.CurrentFileName);
if (file != null) if (file != null)
{ {
bool result = true; bool result = true;
@ -243,9 +250,9 @@ namespace BizHawk.MultiClient
if (result) if (result)
{ {
Watches.Load(file.FullName, details: true, append: false); Watches.Load(file.FullName, true, append);
DisplayWatches(); DisplayWatches();
MessageLabel.Text = Path.GetFileNameWithoutExtension(Watches.CurrentFileName); MessageLabel.Text = Path.GetFileNameWithoutExtension(Watches.CurrentFileName) + (Watches.Changes ? " *" : String.Empty);
UpdateWatchCount(); UpdateWatchCount();
Global.Config.RecentWatches.Add(Watches.CurrentFileName); Global.Config.RecentWatches.Add(Watches.CurrentFileName);
SetMemoryDomain(WatchCommon.GetDomainPos(Watches.Domain.ToString())); SetMemoryDomain(WatchCommon.GetDomainPos(Watches.Domain.ToString()));
@ -253,6 +260,16 @@ namespace BizHawk.MultiClient
} }
} }
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
{
Watches.Save();
}
private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
{
Watches.SaveAs();
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e) private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{ {
if (!AskSave()) if (!AskSave())
@ -265,6 +282,32 @@ namespace BizHawk.MultiClient
} }
} }
/*************Options***********************/
private void optionsToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
{
displayWatchesOnScreenToolStripMenuItem.Checked = Global.Config.DisplayRamWatch;
saveWindowPositionToolStripMenuItem.Checked = Global.Config.RamWatchSaveWindowPosition;
}
private void displayWatchesOnScreenToolStripMenuItem_Click(object sender, EventArgs e)
{
Global.Config.DisplayRamWatch ^= true;
if (!Global.Config.DisplayRamWatch)
{
Global.OSD.ClearGUIText();
}
else
{
UpdateValues();
}
}
private void saveWindowPositionToolStripMenuItem_Click(object sender, EventArgs e)
{
Global.Config.RamWatchSaveWindowPosition ^= true;
}
#endregion #endregion
} }
} }

View File

@ -1266,7 +1266,7 @@ namespace BizHawk.MultiClient
} }
else else
{ {
SaveFileAs(); SaveAs();
} }
} }
@ -1276,13 +1276,14 @@ namespace BizHawk.MultiClient
if (result) if (result)
{ {
if (!append) if (append)
{ {
CurrentFileName = path; Changes = true;
} }
else else
{ {
Changes = false; CurrentFileName = path;
Changes = false;
} }
} }
@ -1295,7 +1296,7 @@ namespace BizHawk.MultiClient
throw new NotImplementedException(); throw new NotImplementedException();
} }
private void SaveFileAs() public void SaveAs()
{ {
//TODO //TODO
throw new NotImplementedException(); throw new NotImplementedException();
@ -1312,10 +1313,10 @@ namespace BizHawk.MultiClient
{ {
string line; string line;
if (append == false) if (append == false)
{ {
Clear(); Clear();
} }
while ((line = sr.ReadLine()) != null) while ((line = sr.ReadLine()) != null)
{ {