New Watch Editor - Edit Mode done

This commit is contained in:
adelikat 2013-09-08 02:51:53 +00:00
parent 8b7798896a
commit 8704acdaf3
5 changed files with 132 additions and 15 deletions

View File

@ -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
//

View File

@ -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<Watch> watches = new List<Watch>();
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;

View File

@ -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

View File

@ -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
//

View File

@ -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<Watch> 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
}
}