new Watch editor - adding new watch now works
This commit is contained in:
parent
3c8196f234
commit
8b7798896a
|
@ -30,6 +30,95 @@ namespace BizHawk.MultiClient
|
|||
sortReverse = false;
|
||||
}
|
||||
|
||||
public void UpdateValues()
|
||||
{
|
||||
if ((!IsHandleCreated || IsDisposed) && !Global.Config.DisplayRamWatch)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Watches.UpdateValues();
|
||||
|
||||
if (Global.Config.DisplayRamWatch)
|
||||
{
|
||||
/* TODO
|
||||
for (int x = 0; x < Watches.Count; x++)
|
||||
{
|
||||
bool alert = Global.CheatList.IsActiveCheat(Domain, Watches[x].Address);
|
||||
Global.OSD.AddGUIText(Watches[x].ToString(),
|
||||
Global.Config.DispRamWatchx, (Global.Config.DispRamWatchy + (x * 14)), alert, Color.Black, Color.White, 0);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
if (!IsHandleCreated || IsDisposed) return;
|
||||
|
||||
WatchListView.BlazingFast = true;
|
||||
WatchListView.Refresh();
|
||||
WatchListView.BlazingFast = false;
|
||||
}
|
||||
|
||||
public void Restart()
|
||||
{
|
||||
if ((!IsHandleCreated || IsDisposed) && !Global.Config.DisplayRamWatch)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!String.IsNullOrWhiteSpace(Watches.CurrentFileName))
|
||||
{
|
||||
Watches.Reload();
|
||||
}
|
||||
else
|
||||
{
|
||||
NewWatchList(true);
|
||||
}
|
||||
}
|
||||
|
||||
public bool AskSave()
|
||||
{
|
||||
if (Global.Config.SupressAskSave) //User has elected to not be nagged
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Watches.Changes)
|
||||
{
|
||||
Global.Sound.StopSound();
|
||||
DialogResult result = MessageBox.Show("Save Changes?", "Ram Watch", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3);
|
||||
Global.Sound.StartSound();
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
Watches.Save();
|
||||
}
|
||||
else if (result == DialogResult.No)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (result == DialogResult.Cancel)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void SaveConfigSettings()
|
||||
{
|
||||
Global.Config.RamWatchAddressWidth = WatchListView.Columns[Global.Config.RamWatchAddressIndex].Width;
|
||||
Global.Config.RamWatchValueWidth = WatchListView.Columns[Global.Config.RamWatchValueIndex].Width;
|
||||
Global.Config.RamWatchPrevWidth = WatchListView.Columns[Global.Config.RamWatchPrevIndex].Width;
|
||||
Global.Config.RamWatchChangeWidth = WatchListView.Columns[Global.Config.RamWatchChangeIndex].Width;
|
||||
Global.Config.RamWatchDiffWidth = WatchListView.Columns[Global.Config.RamWatchDiffIndex].Width;
|
||||
Global.Config.RamWatchDomainWidth = WatchListView.Columns[Global.Config.RamWatchDomainIndex].Width;
|
||||
Global.Config.RamWatchNotesWidth = WatchListView.Columns[Global.Config.RamWatchNotesIndex].Width;
|
||||
|
||||
Global.Config.RamWatchWndx = Location.X;
|
||||
Global.Config.RamWatchWndy = Location.Y;
|
||||
Global.Config.RamWatchWidth = Right - Left;
|
||||
Global.Config.RamWatchHeight = Bottom - Top;
|
||||
}
|
||||
|
||||
protected override void OnClosing(CancelEventArgs e)
|
||||
{
|
||||
if (!AskSave())
|
||||
|
@ -57,7 +146,7 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
}
|
||||
|
||||
void WatchListView_QueryItemText(int index, int column, out string text)
|
||||
private void WatchListView_QueryItemText(int index, int column, out string text)
|
||||
{
|
||||
text = "";
|
||||
|
||||
|
@ -104,62 +193,6 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
}
|
||||
|
||||
public void UpdateValues()
|
||||
{
|
||||
if ((!IsHandleCreated || IsDisposed) && !Global.Config.DisplayRamWatch)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Watches.UpdateValues();
|
||||
|
||||
if (Global.Config.DisplayRamWatch)
|
||||
{
|
||||
/* TODO
|
||||
for (int x = 0; x < Watches.Count; x++)
|
||||
{
|
||||
bool alert = Global.CheatList.IsActiveCheat(Domain, Watches[x].Address);
|
||||
Global.OSD.AddGUIText(Watches[x].ToString(),
|
||||
Global.Config.DispRamWatchx, (Global.Config.DispRamWatchy + (x * 14)), alert, Color.Black, Color.White, 0);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
if (!IsHandleCreated || IsDisposed) return;
|
||||
|
||||
WatchListView.BlazingFast = true;
|
||||
WatchListView.Refresh();
|
||||
WatchListView.BlazingFast = false;
|
||||
}
|
||||
|
||||
public bool AskSave()
|
||||
{
|
||||
if (Global.Config.SupressAskSave) //User has elected to not be nagged
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Watches.Changes)
|
||||
{
|
||||
Global.Sound.StopSound();
|
||||
DialogResult result = MessageBox.Show("Save Changes?", "Ram Watch", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3);
|
||||
Global.Sound.StartSound();
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
Watches.Save();
|
||||
}
|
||||
else if (result == DialogResult.No)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (result == DialogResult.Cancel)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void DisplayWatches()
|
||||
{
|
||||
WatchListView.ItemCount = Watches.ItemCount;
|
||||
|
@ -214,26 +247,11 @@ namespace BizHawk.MultiClient
|
|||
|
||||
DisplayWatches();
|
||||
UpdateWatchCount();
|
||||
MessageLabel.Text = Path.GetFileName(Watches.CurrentFileName) + " *";
|
||||
Watches.Changes = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveConfigSettings()
|
||||
{
|
||||
Global.Config.RamWatchAddressWidth = WatchListView.Columns[Global.Config.RamWatchAddressIndex].Width;
|
||||
Global.Config.RamWatchValueWidth = WatchListView.Columns[Global.Config.RamWatchValueIndex].Width;
|
||||
Global.Config.RamWatchPrevWidth = WatchListView.Columns[Global.Config.RamWatchPrevIndex].Width;
|
||||
Global.Config.RamWatchChangeWidth = WatchListView.Columns[Global.Config.RamWatchChangeIndex].Width;
|
||||
Global.Config.RamWatchDiffWidth = WatchListView.Columns[Global.Config.RamWatchDiffIndex].Width;
|
||||
Global.Config.RamWatchDomainWidth = WatchListView.Columns[Global.Config.RamWatchDomainIndex].Width;
|
||||
Global.Config.RamWatchNotesWidth = WatchListView.Columns[Global.Config.RamWatchNotesIndex].Width;
|
||||
|
||||
Global.Config.RamWatchWndx = Location.X;
|
||||
Global.Config.RamWatchWndy = Location.Y;
|
||||
Global.Config.RamWatchWidth = Right - Left;
|
||||
Global.Config.RamWatchHeight = Bottom - Top;
|
||||
}
|
||||
|
||||
private void SetMemoryDomain(int pos)
|
||||
{
|
||||
if (pos < Global.Emulator.MemoryDomains.Count) //Sanity check
|
||||
|
@ -251,13 +269,13 @@ namespace BizHawk.MultiClient
|
|||
WatchListView.SelectItem(i, true);
|
||||
}
|
||||
|
||||
void Changes()
|
||||
private void Changes()
|
||||
{
|
||||
Watches.Changes = true;
|
||||
MessageLabel.Text = Path.GetFileName(Watches.CurrentFileName) + " *";
|
||||
}
|
||||
|
||||
void MoveUp()
|
||||
private void MoveUp()
|
||||
{
|
||||
ListView.SelectedIndexCollection indexes = WatchListView.SelectedIndices;
|
||||
if (indexes.Count == 0 || indexes[0] == 0)
|
||||
|
@ -290,7 +308,7 @@ namespace BizHawk.MultiClient
|
|||
DisplayWatches();
|
||||
}
|
||||
|
||||
void MoveDown()
|
||||
private void MoveDown()
|
||||
{
|
||||
ListView.SelectedIndexCollection indexes = WatchListView.SelectedIndices;
|
||||
if (indexes.Count == 0)
|
||||
|
@ -366,6 +384,7 @@ namespace BizHawk.MultiClient
|
|||
if (we.DialogResult == DialogResult.OK)
|
||||
{
|
||||
Watches.Add(we.Watches[0]);
|
||||
Changes();
|
||||
UpdateWatchCount();
|
||||
DisplayWatches();
|
||||
}
|
||||
|
|
|
@ -14,6 +14,32 @@ namespace BizHawk.MultiClient
|
|||
public enum WatchSize { Byte = 1, Word = 2, DWord = 4, Separator = 0 };
|
||||
public enum DisplayType { Separator, Signed, Unsigned, Hex, Binary, FixedPoint_12_4, FixedPoint_20_12, Float };
|
||||
|
||||
public static string DisplayTypeToString(DisplayType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
default:
|
||||
return type.ToString();
|
||||
case DisplayType.FixedPoint_12_4:
|
||||
return "Fixed Point 12.4";
|
||||
case DisplayType.FixedPoint_20_12:
|
||||
return "Fixed Point 20.12";
|
||||
}
|
||||
}
|
||||
|
||||
public static DisplayType StringToDisplayType(string name)
|
||||
{
|
||||
switch(name)
|
||||
{
|
||||
default:
|
||||
return (DisplayType) Enum.Parse(typeof(DisplayType), name);
|
||||
case "Fixed Point 12.4":
|
||||
return DisplayType.FixedPoint_12_4;
|
||||
case "Fixed Point 20.12":
|
||||
return DisplayType.FixedPoint_20_12;
|
||||
}
|
||||
}
|
||||
|
||||
protected int _address;
|
||||
protected MemoryDomain _domain;
|
||||
protected DisplayType _type;
|
||||
|
@ -22,7 +48,6 @@ namespace BizHawk.MultiClient
|
|||
public abstract int? Value { get; }
|
||||
public abstract string ValueString { get; }
|
||||
public abstract WatchSize Size { get; }
|
||||
public abstract List<DisplayType> ValidTypes { get; }
|
||||
|
||||
public virtual DisplayType Type { get { return _type; } set { _type = value; } }
|
||||
public virtual bool BigEndian { get { return _bigEndian; } set { _bigEndian = value; } }
|
||||
|
@ -286,7 +311,7 @@ namespace BizHawk.MultiClient
|
|||
get { return WatchSize.Separator; }
|
||||
}
|
||||
|
||||
public override List<DisplayType> ValidTypes
|
||||
public static List<DisplayType> ValidTypes
|
||||
{
|
||||
get { return new List<DisplayType>() { DisplayType.Separator }; }
|
||||
}
|
||||
|
@ -339,13 +364,13 @@ namespace BizHawk.MultiClient
|
|||
get { return WatchSize.Byte; }
|
||||
}
|
||||
|
||||
public override List<DisplayType> ValidTypes
|
||||
public static List<DisplayType> ValidTypes
|
||||
{
|
||||
get
|
||||
{
|
||||
return new List<DisplayType>()
|
||||
{
|
||||
DisplayType.Signed, DisplayType.Unsigned, DisplayType.Hex, DisplayType.Binary
|
||||
DisplayType.Unsigned, DisplayType.Signed, DisplayType.Hex, DisplayType.Binary
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -422,13 +447,13 @@ namespace BizHawk.MultiClient
|
|||
get { return WatchSize.Word; }
|
||||
}
|
||||
|
||||
public override List<DisplayType> ValidTypes
|
||||
public static List<DisplayType> ValidTypes
|
||||
{
|
||||
get
|
||||
{
|
||||
return new List<DisplayType>()
|
||||
{
|
||||
DisplayType.Signed, DisplayType.Unsigned, DisplayType.Hex, DisplayType.FixedPoint_12_4, DisplayType.Binary
|
||||
DisplayType.Unsigned, DisplayType.Signed, DisplayType.Hex, DisplayType.FixedPoint_12_4, DisplayType.Binary
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -521,13 +546,13 @@ namespace BizHawk.MultiClient
|
|||
get { return WatchSize.DWord; }
|
||||
}
|
||||
|
||||
public override List<DisplayType> ValidTypes
|
||||
public static List<DisplayType> ValidTypes
|
||||
{
|
||||
get
|
||||
{
|
||||
return new List<DisplayType>()
|
||||
{
|
||||
DisplayType.Signed, DisplayType.Unsigned, DisplayType.Hex, DisplayType.FixedPoint_20_12, DisplayType.Float
|
||||
DisplayType.Unsigned, DisplayType.Signed, DisplayType.Hex, DisplayType.FixedPoint_20_12, DisplayType.Float
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -764,6 +789,15 @@ namespace BizHawk.MultiClient
|
|||
return result;
|
||||
}
|
||||
|
||||
public void Reload()
|
||||
{
|
||||
if (!String.IsNullOrWhiteSpace(CurrentFileName))
|
||||
{
|
||||
LoadFile(CurrentFileName, true, false);
|
||||
Changes = false;
|
||||
}
|
||||
}
|
||||
|
||||
private bool SaveFile()
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(CurrentFileName))
|
||||
|
|
|
@ -35,7 +35,12 @@
|
|||
this.OK = new System.Windows.Forms.Button();
|
||||
this.Cancel = new System.Windows.Forms.Button();
|
||||
this.label6 = new System.Windows.Forms.Label();
|
||||
this.DomainComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.DomainDropDown = new System.Windows.Forms.ComboBox();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.SizeDropDown = new System.Windows.Forms.ComboBox();
|
||||
this.DisplayTypeLael = new System.Windows.Forms.Label();
|
||||
this.DisplayTypeDropDown = new System.Windows.Forms.ComboBox();
|
||||
this.BigEndianCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
|
@ -108,13 +113,68 @@
|
|||
//
|
||||
// DomainComboBox
|
||||
//
|
||||
this.DomainComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.DomainComboBox.FormattingEnabled = true;
|
||||
this.DomainComboBox.Location = new System.Drawing.Point(12, 230);
|
||||
this.DomainComboBox.Name = "DomainComboBox";
|
||||
this.DomainComboBox.Size = new System.Drawing.Size(141, 21);
|
||||
this.DomainComboBox.TabIndex = 14;
|
||||
this.DomainComboBox.SelectedIndexChanged += new System.EventHandler(this.DomainComboBox_SelectedIndexChanged);
|
||||
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.Size = new System.Drawing.Size(141, 21);
|
||||
this.DomainDropDown.TabIndex = 14;
|
||||
this.DomainDropDown.SelectedIndexChanged += new System.EventHandler(this.DomainComboBox_SelectedIndexChanged);
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(9, 64);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(27, 13);
|
||||
this.label3.TabIndex = 17;
|
||||
this.label3.Text = "Size";
|
||||
//
|
||||
// SizeDropDown
|
||||
//
|
||||
this.SizeDropDown.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.SizeDropDown.FormattingEnabled = true;
|
||||
this.SizeDropDown.Items.AddRange(new object[] {
|
||||
"1 Byte",
|
||||
"2 Byte",
|
||||
"4 Byte"});
|
||||
this.SizeDropDown.Location = new System.Drawing.Point(10, 80);
|
||||
this.SizeDropDown.Name = "SizeDropDown";
|
||||
this.SizeDropDown.Size = new System.Drawing.Size(141, 21);
|
||||
this.SizeDropDown.TabIndex = 16;
|
||||
this.SizeDropDown.SelectedIndexChanged += new System.EventHandler(this.SizeDropDown_SelectedIndexChanged);
|
||||
//
|
||||
// DisplayTypeLael
|
||||
//
|
||||
this.DisplayTypeLael.AutoSize = true;
|
||||
this.DisplayTypeLael.Location = new System.Drawing.Point(11, 106);
|
||||
this.DisplayTypeLael.Name = "DisplayTypeLael";
|
||||
this.DisplayTypeLael.Size = new System.Drawing.Size(68, 13);
|
||||
this.DisplayTypeLael.TabIndex = 19;
|
||||
this.DisplayTypeLael.Text = "Display Type";
|
||||
//
|
||||
// DisplayTypeDropDown
|
||||
//
|
||||
this.DisplayTypeDropDown.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.DisplayTypeDropDown.FormattingEnabled = true;
|
||||
this.DisplayTypeDropDown.Items.AddRange(new object[] {
|
||||
"1 Byte",
|
||||
"2 Byte",
|
||||
"4 Byte"});
|
||||
this.DisplayTypeDropDown.Location = new System.Drawing.Point(12, 122);
|
||||
this.DisplayTypeDropDown.Name = "DisplayTypeDropDown";
|
||||
this.DisplayTypeDropDown.Size = new System.Drawing.Size(141, 21);
|
||||
this.DisplayTypeDropDown.TabIndex = 18;
|
||||
//
|
||||
// BigEndianCheckBox
|
||||
//
|
||||
this.BigEndianCheckBox.AutoSize = true;
|
||||
this.BigEndianCheckBox.Location = new System.Drawing.Point(14, 159);
|
||||
this.BigEndianCheckBox.Name = "BigEndianCheckBox";
|
||||
this.BigEndianCheckBox.Size = new System.Drawing.Size(77, 17);
|
||||
this.BigEndianCheckBox.TabIndex = 20;
|
||||
this.BigEndianCheckBox.Text = "Big Endian";
|
||||
this.BigEndianCheckBox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// WatchEditor
|
||||
//
|
||||
|
@ -123,8 +183,13 @@
|
|||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.Cancel;
|
||||
this.ClientSize = new System.Drawing.Size(213, 296);
|
||||
this.Controls.Add(this.BigEndianCheckBox);
|
||||
this.Controls.Add(this.DisplayTypeLael);
|
||||
this.Controls.Add(this.DisplayTypeDropDown);
|
||||
this.Controls.Add(this.label3);
|
||||
this.Controls.Add(this.SizeDropDown);
|
||||
this.Controls.Add(this.label6);
|
||||
this.Controls.Add(this.DomainComboBox);
|
||||
this.Controls.Add(this.DomainDropDown);
|
||||
this.Controls.Add(this.Cancel);
|
||||
this.Controls.Add(this.OK);
|
||||
this.Controls.Add(this.NotesBox);
|
||||
|
@ -151,6 +216,11 @@
|
|||
private System.Windows.Forms.Button OK;
|
||||
private System.Windows.Forms.Button Cancel;
|
||||
private System.Windows.Forms.Label label6;
|
||||
private System.Windows.Forms.ComboBox DomainComboBox;
|
||||
private System.Windows.Forms.ComboBox DomainDropDown;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.ComboBox SizeDropDown;
|
||||
private System.Windows.Forms.Label DisplayTypeLael;
|
||||
private System.Windows.Forms.ComboBox DisplayTypeDropDown;
|
||||
private System.Windows.Forms.CheckBox BigEndianCheckBox;
|
||||
}
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
|
@ -33,6 +32,14 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
_loading = false;
|
||||
SetAddressBoxProperties();
|
||||
|
||||
switch (_mode)
|
||||
{
|
||||
default:
|
||||
case Mode.New:
|
||||
SizeDropDown.SelectedItem = SizeDropDown.Items[0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetWatch(MemoryDomain domain = null, List<Watch> watches = null, Mode mode = Mode.New)
|
||||
|
@ -64,25 +71,30 @@ namespace BizHawk.MultiClient
|
|||
|
||||
private void DoMemoryDomainDropdown(MemoryDomain startDomain)
|
||||
{
|
||||
DomainComboBox.Items.Clear();
|
||||
DomainDropDown.Items.Clear();
|
||||
if (Global.Emulator.MemoryDomains.Count > 0)
|
||||
{
|
||||
foreach (MemoryDomain domain in Global.Emulator.MemoryDomains)
|
||||
{
|
||||
var result = DomainComboBox.Items.Add(domain.ToString());
|
||||
var result = DomainDropDown.Items.Add(domain.ToString());
|
||||
if (domain.Name == startDomain.Name)
|
||||
{
|
||||
DomainComboBox.SelectedIndex = result;
|
||||
DomainDropDown.SelectedIndex = result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (DomainDropDown.SelectedIndex == null)
|
||||
{
|
||||
DomainDropDown.SelectedItem = DomainDropDown.Items[0];
|
||||
}
|
||||
}
|
||||
|
||||
private void SetAddressBoxProperties()
|
||||
{
|
||||
if (!_loading)
|
||||
{
|
||||
var domain = Global.Emulator.MemoryDomains.FirstOrDefault(d => d.Name == DomainComboBox.SelectedItem.ToString());
|
||||
var domain = Global.Emulator.MemoryDomains.FirstOrDefault(d => d.Name == DomainDropDown.SelectedItem.ToString());
|
||||
if (domain != null)
|
||||
{
|
||||
AddressBox.MaxLength = IntHelpers.GetNumDigits(domain.Size - 1);
|
||||
|
@ -92,6 +104,64 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
}
|
||||
|
||||
private void SetDisplayTypes()
|
||||
{
|
||||
DisplayTypeDropDown.Items.Clear();
|
||||
switch (SizeDropDown.SelectedIndex)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
DisplayTypeDropDown.Items.AddRange(ByteWatch.ValidTypes.ConvertAll<string>(e => Watch.DisplayTypeToString(e)).ToArray());
|
||||
break;
|
||||
case 1:
|
||||
DisplayTypeDropDown.Items.AddRange(WordWatch.ValidTypes.ConvertAll<string>(e => Watch.DisplayTypeToString(e)).ToArray());
|
||||
break;
|
||||
case 2:
|
||||
DisplayTypeDropDown.Items.AddRange(DWordWatch.ValidTypes.ConvertAll<string>(e => Watch.DisplayTypeToString(e)).ToArray());
|
||||
break;
|
||||
}
|
||||
DisplayTypeDropDown.SelectedItem = DisplayTypeDropDown.Items[0];
|
||||
}
|
||||
|
||||
private void SetBigEndianCheckBox()
|
||||
{
|
||||
if (_watchList != null)
|
||||
{
|
||||
if (_watchList.Count > 1)
|
||||
{
|
||||
//Aggregate state
|
||||
var hasBig = _watchList.Any(x => x.BigEndian);
|
||||
var hasLittle = _watchList.Any(x => x.BigEndian == false);
|
||||
|
||||
if (hasBig && hasLittle)
|
||||
{
|
||||
BigEndianCheckBox.CheckState = CheckState.Indeterminate;
|
||||
}
|
||||
else if (hasBig)
|
||||
{
|
||||
BigEndianCheckBox.Checked = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
BigEndianCheckBox.Checked = false;
|
||||
}
|
||||
}
|
||||
else if (_watchList.Count == 1)
|
||||
{
|
||||
BigEndianCheckBox.Checked = _watchList[0].BigEndian;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var domain = Global.Emulator.MemoryDomains.FirstOrDefault(d => d.Name == DomainDropDown.SelectedItem.ToString());
|
||||
if (domain == null)
|
||||
{
|
||||
domain = Global.Emulator.MainMemory;
|
||||
}
|
||||
BigEndianCheckBox.Checked = domain.Endian == Endian.Big ? true : false;
|
||||
|
||||
}
|
||||
|
||||
#region Events
|
||||
|
||||
private void Cancel_Click(object sender, EventArgs e)
|
||||
|
@ -104,7 +174,51 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
DialogResult = DialogResult.OK;
|
||||
|
||||
//TODO
|
||||
switch (_mode)
|
||||
{
|
||||
default:
|
||||
case Mode.New:
|
||||
var domain = Global.Emulator.MemoryDomains.FirstOrDefault(d => d.Name == DomainDropDown.SelectedItem.ToString());
|
||||
var address = (AddressBox as HexTextBox).ToInt();
|
||||
var notes = NotesBox.Text;
|
||||
var type = Watch.StringToDisplayType(DisplayTypeDropDown.SelectedItem.ToString());
|
||||
var bigendian = BigEndianCheckBox.Checked;
|
||||
switch (SizeDropDown.SelectedIndex)
|
||||
{
|
||||
case 0:
|
||||
_watchList.Add(new DetailedByteWatch(domain, address)
|
||||
{
|
||||
Notes = notes,
|
||||
Type = type,
|
||||
BigEndian = bigendian,
|
||||
}
|
||||
);
|
||||
break;
|
||||
case 1:
|
||||
_watchList.Add(new DetailedWordWatch(domain, address)
|
||||
{
|
||||
Notes = notes,
|
||||
Type = type,
|
||||
BigEndian = bigendian,
|
||||
}
|
||||
);
|
||||
break;
|
||||
case 2:
|
||||
_watchList.Add(new DetailedDWordWatch(domain, address)
|
||||
{
|
||||
Notes = notes,
|
||||
Type = type,
|
||||
BigEndian = bigendian,
|
||||
}
|
||||
);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case Mode.Edit:
|
||||
break;
|
||||
case Mode.Duplicate:
|
||||
break;
|
||||
}
|
||||
|
||||
Close();
|
||||
}
|
||||
|
@ -112,8 +226,17 @@ namespace BizHawk.MultiClient
|
|||
private void DomainComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
SetAddressBoxProperties();
|
||||
SetBigEndianCheckBox();
|
||||
}
|
||||
|
||||
private void SizeDropDown_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
SetDisplayTypes();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Windows.Forms;
|
||||
using System.Globalization;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace BizHawk
|
||||
{
|
||||
|
@ -20,5 +21,10 @@ namespace BizHawk
|
|||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
public int ToInt()
|
||||
{
|
||||
return int.Parse(Text, NumberStyles.HexNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue