diff --git a/BizHawk.MultiClient/BizHawk.MultiClient.csproj b/BizHawk.MultiClient/BizHawk.MultiClient.csproj index 02f2b107dd..5ceea4e13a 100644 --- a/BizHawk.MultiClient/BizHawk.MultiClient.csproj +++ b/BizHawk.MultiClient/BizHawk.MultiClient.csproj @@ -484,6 +484,12 @@ N64VideoPluginconfig.cs + + UserControl + + + CheatEdit.cs + @@ -818,6 +824,9 @@ Resources.resx True + + CheatEdit.cs + NewCheatForm.cs diff --git a/BizHawk.MultiClient/BizHawk.MultiClient_v4.5.csproj b/BizHawk.MultiClient/BizHawk.MultiClient_v4.5.csproj index 280d5d6f4f..aec176233f 100644 --- a/BizHawk.MultiClient/BizHawk.MultiClient_v4.5.csproj +++ b/BizHawk.MultiClient/BizHawk.MultiClient_v4.5.csproj @@ -486,6 +486,12 @@ SNESOptions.cs + + UserControl + + + CheatEdit.cs + @@ -818,6 +824,9 @@ Resources.resx True + + CheatEdit.cs + NewCheatForm.cs diff --git a/BizHawk.MultiClient/tools/Cheats/CheatEdit.Designer.cs b/BizHawk.MultiClient/tools/Cheats/CheatEdit.Designer.cs new file mode 100644 index 0000000000..fbd64f9306 --- /dev/null +++ b/BizHawk.MultiClient/tools/Cheats/CheatEdit.Designer.cs @@ -0,0 +1,305 @@ +namespace BizHawk.MultiClient +{ + partial class CheatEdit + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.NameBox = new System.Windows.Forms.TextBox(); + this.NameLabel = new System.Windows.Forms.Label(); + this.AddressLabel = new System.Windows.Forms.Label(); + this.AddressHexIndLabel = new System.Windows.Forms.Label(); + this.AddressBox = new BizHawk.HexTextBox(); + this.ValueBox = new BizHawk.MultiClient.WatchValueBox(); + this.ValueHexIndLabel = new System.Windows.Forms.Label(); + this.ValueLabel = new System.Windows.Forms.Label(); + this.CompareBox = new BizHawk.MultiClient.WatchValueBox(); + this.CompareHexIndLabel = new System.Windows.Forms.Label(); + this.CompareLabel = new System.Windows.Forms.Label(); + this.DomainLabel = new System.Windows.Forms.Label(); + this.DomainDropDown = new System.Windows.Forms.ComboBox(); + this.SizeLabel = 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.AddButton = new System.Windows.Forms.Button(); + this.EditButton = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // NameBox + // + this.NameBox.Location = new System.Drawing.Point(70, 15); + this.NameBox.Name = "NameBox"; + this.NameBox.Size = new System.Drawing.Size(108, 20); + this.NameBox.TabIndex = 5; + // + // NameLabel + // + this.NameLabel.AutoSize = true; + this.NameLabel.Location = new System.Drawing.Point(12, 18); + this.NameLabel.Name = "NameLabel"; + this.NameLabel.Size = new System.Drawing.Size(35, 13); + this.NameLabel.TabIndex = 4; + this.NameLabel.Text = "Name"; + // + // AddressLabel + // + this.AddressLabel.AutoSize = true; + this.AddressLabel.Location = new System.Drawing.Point(38, 45); + this.AddressLabel.Name = "AddressLabel"; + this.AddressLabel.Size = new System.Drawing.Size(45, 13); + this.AddressLabel.TabIndex = 6; + this.AddressLabel.Text = "Address"; + // + // AddressHexIndLabel + // + this.AddressHexIndLabel.AutoSize = true; + this.AddressHexIndLabel.Location = new System.Drawing.Point(89, 45); + this.AddressHexIndLabel.Name = "AddressHexIndLabel"; + this.AddressHexIndLabel.Size = new System.Drawing.Size(18, 13); + this.AddressHexIndLabel.TabIndex = 8; + this.AddressHexIndLabel.Text = "0x"; + // + // AddressBox + // + this.AddressBox.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper; + this.AddressBox.Location = new System.Drawing.Point(113, 42); + this.AddressBox.MaxLength = 8; + this.AddressBox.Name = "AddressBox"; + this.AddressBox.Size = new System.Drawing.Size(65, 20); + this.AddressBox.TabIndex = 9; + // + // ValueBox + // + this.ValueBox.ByteSize = BizHawk.MultiClient.Watch.WatchSize.Byte; + this.ValueBox.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper; + this.ValueBox.Location = new System.Drawing.Point(113, 68); + this.ValueBox.MaxLength = 2; + this.ValueBox.Name = "ValueBox"; + this.ValueBox.Size = new System.Drawing.Size(65, 20); + this.ValueBox.TabIndex = 12; + this.ValueBox.Type = BizHawk.MultiClient.Watch.DisplayType.Hex; + // + // ValueHexIndLabel + // + this.ValueHexIndLabel.AutoSize = true; + this.ValueHexIndLabel.Location = new System.Drawing.Point(89, 71); + this.ValueHexIndLabel.Name = "ValueHexIndLabel"; + this.ValueHexIndLabel.Size = new System.Drawing.Size(18, 13); + this.ValueHexIndLabel.TabIndex = 11; + this.ValueHexIndLabel.Text = "0x"; + // + // ValueLabel + // + this.ValueLabel.AutoSize = true; + this.ValueLabel.Location = new System.Drawing.Point(38, 71); + this.ValueLabel.Name = "ValueLabel"; + this.ValueLabel.Size = new System.Drawing.Size(34, 13); + this.ValueLabel.TabIndex = 10; + this.ValueLabel.Text = "Value"; + // + // CompareBox + // + this.CompareBox.ByteSize = BizHawk.MultiClient.Watch.WatchSize.Byte; + this.CompareBox.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper; + this.CompareBox.Location = new System.Drawing.Point(113, 94); + this.CompareBox.MaxLength = 2; + this.CompareBox.Name = "CompareBox"; + this.CompareBox.Size = new System.Drawing.Size(65, 20); + this.CompareBox.TabIndex = 15; + this.CompareBox.Type = BizHawk.MultiClient.Watch.DisplayType.Hex; + // + // CompareHexIndLabel + // + this.CompareHexIndLabel.AutoSize = true; + this.CompareHexIndLabel.Location = new System.Drawing.Point(89, 97); + this.CompareHexIndLabel.Name = "CompareHexIndLabel"; + this.CompareHexIndLabel.Size = new System.Drawing.Size(18, 13); + this.CompareHexIndLabel.TabIndex = 14; + this.CompareHexIndLabel.Text = "0x"; + // + // CompareLabel + // + this.CompareLabel.AutoSize = true; + this.CompareLabel.Location = new System.Drawing.Point(38, 97); + this.CompareLabel.Name = "CompareLabel"; + this.CompareLabel.Size = new System.Drawing.Size(49, 13); + this.CompareLabel.TabIndex = 13; + this.CompareLabel.Text = "Compare"; + // + // DomainLabel + // + this.DomainLabel.AutoSize = true; + this.DomainLabel.Location = new System.Drawing.Point(12, 124); + this.DomainLabel.Name = "DomainLabel"; + this.DomainLabel.Size = new System.Drawing.Size(43, 13); + this.DomainLabel.TabIndex = 16; + this.DomainLabel.Text = "Domain"; + // + // DomainDropDown + // + this.DomainDropDown.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.DomainDropDown.FormattingEnabled = true; + this.DomainDropDown.Location = new System.Drawing.Point(78, 121); + this.DomainDropDown.Name = "DomainDropDown"; + this.DomainDropDown.Size = new System.Drawing.Size(100, 21); + this.DomainDropDown.TabIndex = 17; + this.DomainDropDown.SelectedIndexChanged += new System.EventHandler(this.DomainDropDown_SelectedIndexChanged); + // + // SizeLabel + // + this.SizeLabel.AutoSize = true; + this.SizeLabel.Location = new System.Drawing.Point(20, 150); + this.SizeLabel.Name = "SizeLabel"; + this.SizeLabel.Size = new System.Drawing.Size(27, 13); + this.SizeLabel.TabIndex = 18; + this.SizeLabel.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(78, 147); + this.SizeDropDown.Name = "SizeDropDown"; + this.SizeDropDown.Size = new System.Drawing.Size(100, 21); + this.SizeDropDown.TabIndex = 19; + this.SizeDropDown.SelectedIndexChanged += new System.EventHandler(this.SizeDropDown_SelectedIndexChanged); + // + // DisplayTypeLael + // + this.DisplayTypeLael.AutoSize = true; + this.DisplayTypeLael.Location = new System.Drawing.Point(4, 174); + this.DisplayTypeLael.Name = "DisplayTypeLael"; + this.DisplayTypeLael.Size = new System.Drawing.Size(68, 13); + this.DisplayTypeLael.TabIndex = 20; + 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(78, 171); + this.DisplayTypeDropDown.Name = "DisplayTypeDropDown"; + this.DisplayTypeDropDown.Size = new System.Drawing.Size(100, 21); + this.DisplayTypeDropDown.TabIndex = 21; + // + // BigEndianCheckBox + // + this.BigEndianCheckBox.AutoSize = true; + this.BigEndianCheckBox.Location = new System.Drawing.Point(101, 198); + this.BigEndianCheckBox.Name = "BigEndianCheckBox"; + this.BigEndianCheckBox.Size = new System.Drawing.Size(77, 17); + this.BigEndianCheckBox.TabIndex = 22; + this.BigEndianCheckBox.Text = "Big Endian"; + this.BigEndianCheckBox.UseVisualStyleBackColor = true; + // + // AddButton + // + this.AddButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.AddButton.Enabled = false; + this.AddButton.Location = new System.Drawing.Point(7, 226); + this.AddButton.Name = "AddButton"; + this.AddButton.Size = new System.Drawing.Size(65, 23); + this.AddButton.TabIndex = 23; + this.AddButton.Text = "&Add"; + this.AddButton.UseVisualStyleBackColor = true; + // + // EditButton + // + this.EditButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.EditButton.Enabled = false; + this.EditButton.Location = new System.Drawing.Point(113, 226); + this.EditButton.Name = "EditButton"; + this.EditButton.Size = new System.Drawing.Size(65, 23); + this.EditButton.TabIndex = 24; + this.EditButton.Text = "&Edit"; + this.EditButton.UseVisualStyleBackColor = true; + // + // CheatEdit + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.EditButton); + this.Controls.Add(this.AddButton); + this.Controls.Add(this.BigEndianCheckBox); + this.Controls.Add(this.DisplayTypeDropDown); + this.Controls.Add(this.DisplayTypeLael); + this.Controls.Add(this.SizeDropDown); + this.Controls.Add(this.SizeLabel); + this.Controls.Add(this.DomainDropDown); + this.Controls.Add(this.DomainLabel); + this.Controls.Add(this.CompareBox); + this.Controls.Add(this.CompareHexIndLabel); + this.Controls.Add(this.CompareLabel); + this.Controls.Add(this.ValueBox); + this.Controls.Add(this.ValueHexIndLabel); + this.Controls.Add(this.ValueLabel); + this.Controls.Add(this.AddressBox); + this.Controls.Add(this.AddressHexIndLabel); + this.Controls.Add(this.AddressLabel); + this.Controls.Add(this.NameBox); + this.Controls.Add(this.NameLabel); + this.Name = "CheatEdit"; + this.Size = new System.Drawing.Size(200, 266); + this.Load += new System.EventHandler(this.CheatEdit_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox NameBox; + private System.Windows.Forms.Label NameLabel; + private System.Windows.Forms.Label AddressLabel; + private System.Windows.Forms.Label AddressHexIndLabel; + private HexTextBox AddressBox; + private WatchValueBox ValueBox; + private System.Windows.Forms.Label ValueHexIndLabel; + private System.Windows.Forms.Label ValueLabel; + private WatchValueBox CompareBox; + private System.Windows.Forms.Label CompareHexIndLabel; + private System.Windows.Forms.Label CompareLabel; + private System.Windows.Forms.Label DomainLabel; + private System.Windows.Forms.ComboBox DomainDropDown; + private System.Windows.Forms.Label SizeLabel; + private System.Windows.Forms.ComboBox SizeDropDown; + private System.Windows.Forms.Label DisplayTypeLael; + private System.Windows.Forms.ComboBox DisplayTypeDropDown; + private System.Windows.Forms.CheckBox BigEndianCheckBox; + private System.Windows.Forms.Button AddButton; + private System.Windows.Forms.Button EditButton; + } +} diff --git a/BizHawk.MultiClient/tools/Cheats/CheatEdit.cs b/BizHawk.MultiClient/tools/Cheats/CheatEdit.cs new file mode 100644 index 0000000000..0890109ab9 --- /dev/null +++ b/BizHawk.MultiClient/tools/Cheats/CheatEdit.cs @@ -0,0 +1,221 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace BizHawk.MultiClient +{ + public partial class CheatEdit : UserControl + { + //TODO: + private NewCheat _cheat; + private const string HexInd = "0x"; + + private bool _loading = false; + + public CheatEdit() + { + InitializeComponent(); + } + + private void CheatEdit_Load(object sender, EventArgs e) + { + ToolHelpers.PopulateMemoryDomainDropdown(ref DomainDropDown, Global.Emulator.MainMemory); + SetFormToDefault(); + } + + private void SetFormToCheat() + { + _loading = true; + SetSizeSelected(_cheat.Size); + PopulateTypeDropdown(); + SetTypeSelected(_cheat.Type); + SetDomainSelected(_cheat.Domain); + + AddressBox.SetHexProperties(_cheat.Domain.Size); + + NameBox.Text = _cheat.Name; + AddressBox.Text = _cheat.AddressStr; + ValueBox.Text = _cheat.ValueStr; + CompareBox.Text = _cheat.Compare.HasValue ? _cheat.CompareStr : String.Empty; + + ValueBox.ByteSize = + CompareBox.ByteSize = + _cheat.Size; + + ValueBox.Type = + CompareBox.Type = + _cheat.Type; + + ValueHexIndLabel.Text = + CompareHexIndLabel.Text = + _cheat.Type == Watch.DisplayType.Hex ? HexInd : String.Empty; + + BigEndianCheckBox.Checked = _cheat.BigEndian.Value; + + CheckFormState(); + _loading = false; + } + + private void SetFormToDefault() + { + _loading = true; + SetSizeSelected(Watch.WatchSize.Byte); + PopulateTypeDropdown(); + + NameBox.Text = String.Empty; + AddressBox.SetHexProperties(Global.Emulator.MainMemory.Size); + + ValueBox.ByteSize = + CompareBox.ByteSize = + Watch.WatchSize.Byte; + + ValueBox.Type = + CompareBox.Type = + Watch.DisplayType.Hex; + + ValueBox.ResetText(); + CompareBox.ResetText(); + + ValueHexIndLabel.Text = + CompareHexIndLabel.Text = + HexInd; + + BigEndianCheckBox.Checked = false; + + CheckFormState(); + _loading = false; + } + + private void SetSizeSelected(Watch.WatchSize size) + { + switch (size) + { + default: + case Watch.WatchSize.Byte: + SizeDropDown.SelectedIndex = 0; + break; + case Watch.WatchSize.Word: + SizeDropDown.SelectedIndex = 1; + break; + case Watch.WatchSize.DWord: + SizeDropDown.SelectedIndex = 2; + break; + } + } + + private void SetTypeSelected(Watch.DisplayType type) + { + foreach (var item in DisplayTypeDropDown.Items) + { + if (item.ToString() == Watch.DisplayTypeToString(type)) + { + DisplayTypeDropDown.SelectedItem = item; + return; + } + } + } + + private void SetDomainSelected(MemoryDomain domain) + { + foreach (var item in DomainDropDown.Items) + { + if (item.ToString() == domain.Name) + { + DomainDropDown.SelectedItem = item; + return; + } + } + } + + private void PopulateTypeDropdown() + { + DisplayTypeDropDown.Items.Clear(); + switch (SizeDropDown.SelectedIndex) + { + default: + case 0: + DisplayTypeDropDown.Items.AddRange(ByteWatch.ValidTypes.ConvertAll(e => Watch.DisplayTypeToString(e)).ToArray()); + break; + case 1: + DisplayTypeDropDown.Items.AddRange(WordWatch.ValidTypes.ConvertAll(e => Watch.DisplayTypeToString(e)).ToArray()); + break; + case 2: + DisplayTypeDropDown.Items.AddRange(DWordWatch.ValidTypes.ConvertAll(e => Watch.DisplayTypeToString(e)).ToArray()); + break; + } + DisplayTypeDropDown.SelectedItem = DisplayTypeDropDown.Items[0]; + } + + private void CheckFormState() + { + AddButton.Enabled = + EditButton.Enabled = + (!String.IsNullOrWhiteSpace(AddressBox.Text) && !String.IsNullOrWhiteSpace(ValueBox.Text)); + } + + private void SizeDropDown_SelectedIndexChanged(object sender, EventArgs e) + { + if (!_loading) + { + PopulateTypeDropdown(); + + ValueBox.ByteSize = + CompareBox.ByteSize = + GetCurrentSize(); + + } + } + + private void DomainDropDown_SelectedIndexChanged(object sender, EventArgs e) + { + if (!_loading) + { + var domain = ToolHelpers.DomainByName(DomainDropDown.SelectedItem.ToString()); + AddressBox.SetHexProperties(domain.Size); + } + } + + private Watch.WatchSize GetCurrentSize() + { + switch (SizeDropDown.SelectedIndex) + { + default: + case 0: + return Watch.WatchSize.Byte; + case 1: + return Watch.WatchSize.Word; + case 2: + return Watch.WatchSize.DWord; + } + } + + #region API + + public void SetCheat(NewCheat cheat) + { + _cheat = cheat; + if (cheat.IsSeparator) + { + SetFormToDefault(); + + } + else + { + SetFormToCheat(); + } + } + + //Add Cheat Callback + //Edit Cheat Callback + + #endregion + + + } +} diff --git a/BizHawk.MultiClient/tools/Cheats/CheatEdit.resx b/BizHawk.MultiClient/tools/Cheats/CheatEdit.resx new file mode 100644 index 0000000000..29dcb1b3a3 --- /dev/null +++ b/BizHawk.MultiClient/tools/Cheats/CheatEdit.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/BizHawk.MultiClient/tools/Cheats/NewCheatForm.Designer.cs b/BizHawk.MultiClient/tools/Cheats/NewCheatForm.Designer.cs index 2c14afa6ff..25599da8b2 100644 --- a/BizHawk.MultiClient/tools/Cheats/NewCheatForm.Designer.cs +++ b/BizHawk.MultiClient/tools/Cheats/NewCheatForm.Designer.cs @@ -62,8 +62,8 @@ this.MoveDownMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.SelectAllMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator6 = new System.Windows.Forms.ToolStripSeparator(); - this.DisableAllCheatsMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.ToggleMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.DisableAllCheatsMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.GameGenieSeparator = new System.Windows.Forms.ToolStripSeparator(); this.OpenGameGenieEncoderDecoderMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.OptionsSubMenu = new System.Windows.Forms.ToolStripMenuItem(); @@ -100,17 +100,19 @@ this.LoadGameGenieToolbarItem = new System.Windows.Forms.ToolStripButton(); this.TotalLabel = new System.Windows.Forms.Label(); this.MessageLabel = new System.Windows.Forms.Label(); + this.CheatGroupBox = new System.Windows.Forms.GroupBox(); + this.CheatEditor = new BizHawk.MultiClient.CheatEdit(); this.contextMenuStrip1.SuspendLayout(); this.CheatsMenu.SuspendLayout(); this.toolStrip1.SuspendLayout(); + this.CheatGroupBox.SuspendLayout(); this.SuspendLayout(); // // CheatListView // this.CheatListView.AllowColumnReorder = true; - this.CheatListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.CheatListView.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); this.CheatListView.AutoArrange = false; this.CheatListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.CheatName, @@ -128,7 +130,7 @@ this.CheatListView.Location = new System.Drawing.Point(12, 72); this.CheatListView.Name = "CheatListView"; this.CheatListView.selectedItem = -1; - this.CheatListView.Size = new System.Drawing.Size(376, 236); + this.CheatListView.Size = new System.Drawing.Size(414, 278); this.CheatListView.TabIndex = 1; this.CheatListView.UseCompatibleStateImageBehavior = false; this.CheatListView.View = System.Windows.Forms.View.Details; @@ -177,7 +179,7 @@ this.toggleToolStripMenuItem.Image = global::BizHawk.MultiClient.Properties.Resources.Refresh1; this.toggleToolStripMenuItem.Name = "toggleToolStripMenuItem"; this.toggleToolStripMenuItem.ShortcutKeyDisplayString = "Enter"; - this.toggleToolStripMenuItem.Size = new System.Drawing.Size(204, 22); + this.toggleToolStripMenuItem.Size = new System.Drawing.Size(157, 22); this.toggleToolStripMenuItem.Text = "&Toggle"; this.toggleToolStripMenuItem.Click += new System.EventHandler(this.ToggleMenuItem_Click); // @@ -194,7 +196,7 @@ // this.disableAllCheatsToolStripMenuItem.Image = global::BizHawk.MultiClient.Properties.Resources.Stop; this.disableAllCheatsToolStripMenuItem.Name = "disableAllCheatsToolStripMenuItem"; - this.disableAllCheatsToolStripMenuItem.Size = new System.Drawing.Size(204, 22); + this.disableAllCheatsToolStripMenuItem.Size = new System.Drawing.Size(157, 22); this.disableAllCheatsToolStripMenuItem.Text = "&Disable All"; this.disableAllCheatsToolStripMenuItem.Click += new System.EventHandler(this.DisableAllCheatsMenuItem_Click); // @@ -208,7 +210,7 @@ this.ColumnsSubMenu}); this.CheatsMenu.Location = new System.Drawing.Point(0, 0); this.CheatsMenu.Name = "CheatsMenu"; - this.CheatsMenu.Size = new System.Drawing.Size(587, 24); + this.CheatsMenu.Size = new System.Drawing.Size(646, 24); this.CheatsMenu.TabIndex = 2; this.CheatsMenu.Text = "menuStrip1"; // @@ -390,14 +392,6 @@ this.toolStripSeparator6.Name = "toolStripSeparator6"; this.toolStripSeparator6.Size = new System.Drawing.Size(230, 6); // - // DisableAllCheatsMenuItem - // - this.DisableAllCheatsMenuItem.Image = global::BizHawk.MultiClient.Properties.Resources.Stop; - this.DisableAllCheatsMenuItem.Name = "DisableAllCheatsMenuItem"; - this.DisableAllCheatsMenuItem.Size = new System.Drawing.Size(233, 22); - this.DisableAllCheatsMenuItem.Text = "Disable all"; - this.DisableAllCheatsMenuItem.Click += new System.EventHandler(this.DisableAllCheatsMenuItem_Click); - // // ToggleMenuItem // this.ToggleMenuItem.Image = global::BizHawk.MultiClient.Properties.Resources.Refresh1; @@ -407,6 +401,14 @@ this.ToggleMenuItem.Text = "&Toggle"; this.ToggleMenuItem.Click += new System.EventHandler(this.ToggleMenuItem_Click); // + // DisableAllCheatsMenuItem + // + this.DisableAllCheatsMenuItem.Image = global::BizHawk.MultiClient.Properties.Resources.Stop; + this.DisableAllCheatsMenuItem.Name = "DisableAllCheatsMenuItem"; + this.DisableAllCheatsMenuItem.Size = new System.Drawing.Size(233, 22); + this.DisableAllCheatsMenuItem.Text = "Disable all"; + this.DisableAllCheatsMenuItem.Click += new System.EventHandler(this.DisableAllCheatsMenuItem_Click); + // // GameGenieSeparator // this.GameGenieSeparator.Name = "GameGenieSeparator"; @@ -587,7 +589,7 @@ this.LoadGameGenieToolbarItem}); this.toolStrip1.Location = new System.Drawing.Point(0, 24); this.toolStrip1.Name = "toolStrip1"; - this.toolStrip1.Size = new System.Drawing.Size(587, 25); + this.toolStrip1.Size = new System.Drawing.Size(646, 25); this.toolStrip1.TabIndex = 3; this.toolStrip1.Text = "toolStrip1"; // @@ -710,17 +712,39 @@ // this.MessageLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.MessageLabel.AutoSize = true; - this.MessageLabel.Location = new System.Drawing.Point(13, 312); + this.MessageLabel.Location = new System.Drawing.Point(13, 354); this.MessageLabel.Name = "MessageLabel"; this.MessageLabel.Size = new System.Drawing.Size(31, 13); this.MessageLabel.TabIndex = 7; this.MessageLabel.Text = " "; // + // CheatGroupBox + // + this.CheatGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.CheatGroupBox.Controls.Add(this.CheatEditor); + this.CheatGroupBox.Location = new System.Drawing.Point(432, 72); + this.CheatGroupBox.Name = "CheatGroupBox"; + this.CheatGroupBox.Size = new System.Drawing.Size(202, 278); + this.CheatGroupBox.TabIndex = 8; + this.CheatGroupBox.TabStop = false; + this.CheatGroupBox.Text = "Cheat"; + // + // CheatEditor + // + this.CheatEditor.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.CheatEditor.Location = new System.Drawing.Point(6, 14); + this.CheatEditor.Name = "CheatEditor"; + this.CheatEditor.Size = new System.Drawing.Size(190, 264); + this.CheatEditor.TabIndex = 0; + // // NewCheatForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(587, 328); + this.ClientSize = new System.Drawing.Size(646, 370); + this.Controls.Add(this.CheatGroupBox); this.Controls.Add(this.MessageLabel); this.Controls.Add(this.TotalLabel); this.Controls.Add(this.toolStrip1); @@ -736,6 +760,7 @@ this.CheatsMenu.PerformLayout(); this.toolStrip1.ResumeLayout(false); this.toolStrip1.PerformLayout(); + this.CheatGroupBox.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); @@ -813,5 +838,7 @@ private System.Windows.Forms.ToolStripMenuItem toggleToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem removeSelectedToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem disableAllCheatsToolStripMenuItem; + private System.Windows.Forms.GroupBox CheatGroupBox; + private CheatEdit CheatEditor; } } \ No newline at end of file diff --git a/BizHawk.MultiClient/tools/ToolHelpers.cs b/BizHawk.MultiClient/tools/ToolHelpers.cs index 845d0080fe..4ac4d2d397 100644 --- a/BizHawk.MultiClient/tools/ToolHelpers.cs +++ b/BizHawk.MultiClient/tools/ToolHelpers.cs @@ -41,6 +41,22 @@ namespace BizHawk.MultiClient return items.ToArray(); } + public static void PopulateMemoryDomainDropdown(ref ComboBox dropdown, MemoryDomain startDomain) + { + dropdown.Items.Clear(); + if (Global.Emulator.MemoryDomains.Count > 0) + { + foreach (var domain in Global.Emulator.MemoryDomains) + { + var result = dropdown.Items.Add(domain.ToString()); + if (domain.Name == startDomain.Name) + { + dropdown.SelectedIndex = result; + } + } + } + } + public static void UnfreezeAll() { Global.MainForm.Cheats1.RemoveAllCheats(); diff --git a/BizHawk.MultiClient/tools/Watch/WatchValueBox.cs b/BizHawk.MultiClient/tools/Watch/WatchValueBox.cs index 02a00ad9c4..c22ba5f9a4 100644 --- a/BizHawk.MultiClient/tools/Watch/WatchValueBox.cs +++ b/BizHawk.MultiClient/tools/Watch/WatchValueBox.cs @@ -13,6 +13,32 @@ namespace BizHawk.MultiClient CharacterCasing = CharacterCasing.Upper; } + public override void ResetText() + { + switch (Type) + { + default: + case Watch.DisplayType.Signed: + case Watch.DisplayType.Unsigned: + Text = "0"; + break; + case Watch.DisplayType.Hex: + string formatstr = "{0:X" + MaxLength.ToString() + "}"; + Text = String.Format(formatstr, 0); + break; + case Watch.DisplayType.FixedPoint_12_4: + case Watch.DisplayType.FixedPoint_20_12: + case Watch.DisplayType.Float: + Text = "0.0"; + break; + case Watch.DisplayType.Binary: + Text = "0".PadLeft(((int)_size) * 8); + break; + } + + + } + public Watch.WatchSize ByteSize { get { return _size; } @@ -322,7 +348,7 @@ namespace BizHawk.MultiClient } else { - hexVal++; + hexVal--; } string formatstr = "{0:X" + MaxLength.ToString() + "}"; Text = String.Format(formatstr, hexVal); diff --git a/BizHawk.Util/HexTextBox.cs b/BizHawk.Util/HexTextBox.cs index c769a4baf8..f725145816 100644 --- a/BizHawk.Util/HexTextBox.cs +++ b/BizHawk.Util/HexTextBox.cs @@ -11,6 +11,20 @@ namespace BizHawk public class HexTextBox : TextBox, INumberBox { + private string _addressFormatStr = "{0:X4}"; + + public void SetHexProperties(int domainSize) + { + MaxLength = IntHelpers.GetNumDigits(domainSize - 1); + _addressFormatStr = "{0:X" + MaxLength.ToString() + "}"; + ResetText(); + } + + public override void ResetText() + { + Text = String.Format(_addressFormatStr, 0); + } + public HexTextBox() { CharacterCasing = CharacterCasing.Upper; @@ -44,8 +58,8 @@ namespace BizHawk { val++; } - string formatstr = "{0:X" + MaxLength.ToString() + "}"; - Text = String.Format(formatstr, val); + + Text = String.Format(_addressFormatStr, val); } } else if (e.KeyCode == Keys.Down) @@ -62,8 +76,7 @@ namespace BizHawk val--; } - string formatstr = "{0:X" + MaxLength.ToString() + "}"; - Text = String.Format(formatstr, val); + Text = String.Format(_addressFormatStr, val); } } else @@ -76,7 +89,7 @@ namespace BizHawk { if (String.IsNullOrWhiteSpace(Text)) { - Text = "0"; + ResetText(); } } @@ -112,6 +125,11 @@ namespace BizHawk } } + public override void ResetText() + { + Text = "0"; + } + protected override void OnKeyDown(KeyEventArgs e) { if (e.KeyCode == Keys.Up) @@ -158,7 +176,7 @@ namespace BizHawk { if (String.IsNullOrWhiteSpace(Text)) { - Text = "0"; + ResetText(); } }