diff --git a/BizHawk.MultiClient/tools/Watch/NewRamWatch.Designer.cs b/BizHawk.MultiClient/tools/Watch/NewRamWatch.Designer.cs index a4ec7d89a8..ef68829bae 100644 --- a/BizHawk.MultiClient/tools/Watch/NewRamWatch.Designer.cs +++ b/BizHawk.MultiClient/tools/Watch/NewRamWatch.Designer.cs @@ -204,12 +204,12 @@ // EditWatchToolStripButton1 // this.EditWatchToolStripButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.EditWatchToolStripButton1.Enabled = false; this.EditWatchToolStripButton1.Image = ((System.Drawing.Image)(resources.GetObject("EditWatchToolStripButton1.Image"))); this.EditWatchToolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta; this.EditWatchToolStripButton1.Name = "EditWatchToolStripButton1"; this.EditWatchToolStripButton1.Size = new System.Drawing.Size(23, 22); this.EditWatchToolStripButton1.Text = "Edit Watch"; + this.EditWatchToolStripButton1.Click += new System.EventHandler(this.editWatchToolStripMenuItem_Click); // // cutToolStripButton // @@ -454,12 +454,12 @@ // // editWatchToolStripMenuItem // - this.editWatchToolStripMenuItem.Enabled = false; this.editWatchToolStripMenuItem.Image = global::BizHawk.MultiClient.Properties.Resources.CutHS; this.editWatchToolStripMenuItem.Name = "editWatchToolStripMenuItem"; this.editWatchToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.E))); this.editWatchToolStripMenuItem.Size = new System.Drawing.Size(224, 22); this.editWatchToolStripMenuItem.Text = "&Edit Watch"; + this.editWatchToolStripMenuItem.Click += new System.EventHandler(this.editWatchToolStripMenuItem_Click); // // removeWatchToolStripMenuItem // diff --git a/BizHawk.MultiClient/tools/Watch/NewRamWatch.cs b/BizHawk.MultiClient/tools/Watch/NewRamWatch.cs index 610e9d37a1..dfb1910b1c 100644 --- a/BizHawk.MultiClient/tools/Watch/NewRamWatch.cs +++ b/BizHawk.MultiClient/tools/Watch/NewRamWatch.cs @@ -238,17 +238,25 @@ namespace BizHawk.MultiClient if (ask_result) { bool load_result = Watches.Load(file, details: true, append: false); - if (!load_result) + if (load_result) + { + Global.Config.RecentWatches.Add(file); + + } + else { DialogResult result = MessageBox.Show("Could not open " + file + "\nRemove from list?", "File not found", MessageBoxButtons.YesNo, MessageBoxIcon.Error); if (result == DialogResult.Yes) + { Global.Config.RecentWatches.Remove(file); + } } DisplayWatches(); UpdateWatchCount(); MessageLabel.Text = Path.GetFileName(Watches.CurrentFileName) + " *"; Watches.Changes = false; + } } @@ -390,6 +398,46 @@ namespace BizHawk.MultiClient } } + void EditWatch() + { + ListView.SelectedIndexCollection indexes = WatchListView.SelectedIndices; + + if (indexes.Count > 0) + { + WatchEditor we = new WatchEditor() + { + InitialLocation = GetPromptPoint(), + }; + + List watches = new List(); + foreach (int index in indexes) + { + if (!Watches[index].IsSeparator) + { + watches.Add(Watches[index]); + } + } + + if (!watches.Any()) + { + return; + } + + we.SetWatch(Watches.Domain, watches, WatchEditor.Mode.Edit); + Global.Sound.StopSound(); + var result = we.ShowDialog(); + if (result == DialogResult.OK) + { + Changes(); + } + + Global.Sound.StartSound(); + } + + UpdateValues(); + } + + #region Winform Events private void NewRamWatch_Load(object sender, EventArgs e) @@ -518,6 +566,11 @@ namespace BizHawk.MultiClient AddNewWatch(); } + private void editWatchToolStripMenuItem_Click(object sender, EventArgs e) + { + EditWatch(); + } + private void removeWatchToolStripMenuItem_Click(object sender, EventArgs e) { ListView.SelectedIndexCollection indexes = WatchListView.SelectedIndices; diff --git a/BizHawk.MultiClient/tools/Watch/Watch.cs b/BizHawk.MultiClient/tools/Watch/Watch.cs index 3cc9b846ca..7faaf1673a 100644 --- a/BizHawk.MultiClient/tools/Watch/Watch.cs +++ b/BizHawk.MultiClient/tools/Watch/Watch.cs @@ -49,7 +49,7 @@ namespace BizHawk.MultiClient public abstract string ValueString { get; } public abstract WatchSize Size { get; } - public virtual DisplayType Type { get { return _type; } set { _type = value; } } + public virtual DisplayType Type { get { return _type; } set { _type = value; } } public virtual bool BigEndian { get { return _bigEndian; } set { _bigEndian = value; } } public string DomainName diff --git a/BizHawk.MultiClient/tools/Watch/WatchEditor.Designer.cs b/BizHawk.MultiClient/tools/Watch/WatchEditor.Designer.cs index aa65a0e48f..99422c8ffe 100644 --- a/BizHawk.MultiClient/tools/Watch/WatchEditor.Designer.cs +++ b/BizHawk.MultiClient/tools/Watch/WatchEditor.Designer.cs @@ -111,12 +111,12 @@ this.label6.TabIndex = 15; this.label6.Text = "Memory Domain"; // - // DomainComboBox + // DomainDropDown // this.DomainDropDown.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.DomainDropDown.FormattingEnabled = true; this.DomainDropDown.Location = new System.Drawing.Point(12, 230); - this.DomainDropDown.Name = "DomainComboBox"; + this.DomainDropDown.Name = "DomainDropDown"; this.DomainDropDown.Size = new System.Drawing.Size(141, 21); this.DomainDropDown.TabIndex = 14; this.DomainDropDown.SelectedIndexChanged += new System.EventHandler(this.DomainComboBox_SelectedIndexChanged); @@ -165,6 +165,7 @@ this.DisplayTypeDropDown.Name = "DisplayTypeDropDown"; this.DisplayTypeDropDown.Size = new System.Drawing.Size(141, 21); this.DisplayTypeDropDown.TabIndex = 18; + this.DisplayTypeDropDown.SelectedIndexChanged += new System.EventHandler(this.DisplayTypeDropDown_SelectedIndexChanged); // // BigEndianCheckBox // diff --git a/BizHawk.MultiClient/tools/Watch/WatchEditor.cs b/BizHawk.MultiClient/tools/Watch/WatchEditor.cs index 0e51e68dfb..5313c660a3 100644 --- a/BizHawk.MultiClient/tools/Watch/WatchEditor.cs +++ b/BizHawk.MultiClient/tools/Watch/WatchEditor.cs @@ -15,6 +15,9 @@ namespace BizHawk.MultiClient private bool _loading = true; private string _addressFormatStr = "{0:X2}"; + private bool _changedSize = false; + private bool _changedDisplayType = false; + public Mode EditorMode { get { return _mode; } } public List Watches { get { return _watchList; } } public Point InitialLocation = new Point(0, 0); @@ -39,6 +42,46 @@ namespace BizHawk.MultiClient case Mode.New: SizeDropDown.SelectedItem = SizeDropDown.Items[0]; break; + case Mode.Edit: + switch (_watchList[0].Size) + { + case Watch.WatchSize.Byte: + SizeDropDown.SelectedItem = SizeDropDown.Items[0]; + break; + case Watch.WatchSize.Word: + SizeDropDown.SelectedItem = SizeDropDown.Items[1]; + break; + case Watch.WatchSize.DWord: + SizeDropDown.SelectedItem = SizeDropDown.Items[2]; + break; + } + int x = DisplayTypeDropDown.Items.IndexOf(Watch.DisplayTypeToString(_watchList[0].Type)); + DisplayTypeDropDown.SelectedItem = DisplayTypeDropDown.Items[x]; + + if (_watchList.Count > 1) + { + NotesBox.Enabled = false; + NotesBox.Text = ""; + + AddressBox.Enabled = false; + AddressBox.Text = _watchList.Select(a => a.AddressString).Aggregate((addrStr, nextStr) => addrStr + ("," + nextStr)); + + BigEndianCheckBox.ThreeState = true; + + if (_watchList.Select(s => s.Size).Distinct().Count() > 1) + { + DisplayTypeDropDown.Enabled = false; + } + } + else + { + NotesBox.Text = (_watchList[0] as iWatchEntryDetails).Notes; + AddressBox.Text = _watchList[0].AddressString; + } + + SetBigEndianCheckBox(); + DomainDropDown.Enabled = false; + break; } } @@ -48,8 +91,9 @@ namespace BizHawk.MultiClient { _watchList.AddRange(watches); } - SetTitle(); + _mode = mode; DoMemoryDomainDropdown(domain ?? Global.Emulator.MainMemory); + SetTitle(); } private void SetTitle() @@ -83,11 +127,6 @@ namespace BizHawk.MultiClient } } } - - if (DomainDropDown.SelectedIndex == null) - { - DomainDropDown.SelectedItem = DomainDropDown.Items[0]; - } } private void SetAddressBoxProperties() @@ -135,6 +174,7 @@ namespace BizHawk.MultiClient if (hasBig && hasLittle) { + BigEndianCheckBox.Checked = true; BigEndianCheckBox.CheckState = CheckState.Indeterminate; } else if (hasBig) @@ -215,6 +255,18 @@ namespace BizHawk.MultiClient } break; case Mode.Edit: + if (_changedSize = true) + { + //uh oh + } + if (_changedDisplayType) + { + _watchList.ForEach(x => x.Type = Watch.StringToDisplayType(DisplayTypeDropDown.SelectedItem.ToString())); + } + if (!(BigEndianCheckBox.CheckState == CheckState.Indeterminate)) + { + _watchList.ForEach(x => x.BigEndian = BigEndianCheckBox.Checked); + } break; case Mode.Duplicate: break; @@ -227,16 +279,27 @@ namespace BizHawk.MultiClient { SetAddressBoxProperties(); SetBigEndianCheckBox(); + _changedSize = true; + _changedDisplayType = true; } private void SizeDropDown_SelectedIndexChanged(object sender, EventArgs e) { SetDisplayTypes(); - + _changedSize = true; + + if (!DisplayTypeDropDown.Enabled) + { + DisplayTypeDropDown.Enabled = true; + _changedDisplayType = true; + } + } + + private void DisplayTypeDropDown_SelectedIndexChanged(object sender, EventArgs e) + { + _changedDisplayType = true; } #endregion - - } }