Cheats - fix bug where when editing a cheat, changing the address or domain was causing it to insert not update
This commit is contained in:
parent
377ab3b4ea
commit
f9a847728c
|
@ -1,11 +1,4 @@
|
||||||
using System;
|
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;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
using BizHawk.Client.Common;
|
using BizHawk.Client.Common;
|
||||||
|
@ -24,13 +17,14 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
#region Privates
|
#region Privates
|
||||||
|
|
||||||
private Cheat _cheat;
|
|
||||||
private const string HexInd = "0x";
|
private const string HexInd = "0x";
|
||||||
private bool _loading = false;
|
|
||||||
private bool _editmode = false;
|
|
||||||
|
|
||||||
private Action _addCallback = null;
|
private Cheat _cheat;
|
||||||
private Action _editCallback = null;
|
private bool _loading;
|
||||||
|
private bool _editmode;
|
||||||
|
|
||||||
|
private Action _addCallback;
|
||||||
|
private Action _editCallback;
|
||||||
|
|
||||||
private void CheatEdit_Load(object sender, EventArgs e)
|
private void CheatEdit_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
@ -38,6 +32,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
ToolHelpers.PopulateMemoryDomainDropdown(ref DomainDropDown, Global.Emulator.MemoryDomains.MainMemory);
|
ToolHelpers.PopulateMemoryDomainDropdown(ref DomainDropDown, Global.Emulator.MemoryDomains.MainMemory);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetFormToDefault();
|
SetFormToDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,6 +70,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
CompareBox.Text = String.Empty; // Necessary hack until WatchValueBox.ToRawInt() becomes nullable
|
CompareBox.Text = String.Empty; // Necessary hack until WatchValueBox.ToRawInt() becomes nullable
|
||||||
}
|
}
|
||||||
|
|
||||||
_loading = false;
|
_loading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,21 +159,22 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case 0:
|
case 0:
|
||||||
DisplayTypeDropDown.Items.AddRange(ByteWatch.ValidTypes.ConvertAll<string>(e => Watch.DisplayTypeToString(e)).ToArray());
|
DisplayTypeDropDown.Items.AddRange(ByteWatch.ValidTypes.ConvertAll(e => Watch.DisplayTypeToString(e)).ToArray());
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
DisplayTypeDropDown.Items.AddRange(WordWatch.ValidTypes.ConvertAll<string>(e => Watch.DisplayTypeToString(e)).ToArray());
|
DisplayTypeDropDown.Items.AddRange(WordWatch.ValidTypes.ConvertAll(e => Watch.DisplayTypeToString(e)).ToArray());
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
DisplayTypeDropDown.Items.AddRange(DWordWatch.ValidTypes.ConvertAll<string>(e => Watch.DisplayTypeToString(e)).ToArray());
|
DisplayTypeDropDown.Items.AddRange(DWordWatch.ValidTypes.ConvertAll(e => Watch.DisplayTypeToString(e)).ToArray());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
DisplayTypeDropDown.SelectedItem = DisplayTypeDropDown.Items[0];
|
DisplayTypeDropDown.SelectedItem = DisplayTypeDropDown.Items[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CheckFormState()
|
private void CheckFormState()
|
||||||
{
|
{
|
||||||
bool valid = (!String.IsNullOrWhiteSpace(AddressBox.Text) && !String.IsNullOrWhiteSpace(ValueBox.Text));
|
var valid = !String.IsNullOrWhiteSpace(AddressBox.Text) && !String.IsNullOrWhiteSpace(ValueBox.Text);
|
||||||
AddButton.Enabled = valid;
|
AddButton.Enabled = valid;
|
||||||
EditButton.Enabled = _editmode && valid;
|
EditButton.Enabled = _editmode && valid;
|
||||||
}
|
}
|
||||||
|
@ -191,7 +188,6 @@ namespace BizHawk.Client.EmuHawk
|
||||||
ValueBox.ByteSize =
|
ValueBox.ByteSize =
|
||||||
CompareBox.ByteSize =
|
CompareBox.ByteSize =
|
||||||
GetCurrentSize();
|
GetCurrentSize();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,7 +248,6 @@ namespace BizHawk.Client.EmuHawk
|
||||||
if (cheat.IsSeparator)
|
if (cheat.IsSeparator)
|
||||||
{
|
{
|
||||||
SetFormToDefault();
|
SetFormToDefault();
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -267,11 +262,16 @@ namespace BizHawk.Client.EmuHawk
|
||||||
SetFormToDefault();
|
SetFormToDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Cheat OriginalCheat
|
||||||
|
{
|
||||||
|
get { return _cheat; }
|
||||||
|
}
|
||||||
|
|
||||||
public Cheat Cheat
|
public Cheat Cheat
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
Watch watch = Watch.GenerateWatch(
|
var watch = Watch.GenerateWatch(
|
||||||
Global.Emulator.MemoryDomains[DomainDropDown.SelectedItem.ToString()],
|
Global.Emulator.MemoryDomains[DomainDropDown.SelectedItem.ToString()],
|
||||||
AddressBox.ToRawInt().Value,
|
AddressBox.ToRawInt().Value,
|
||||||
GetCurrentSize(),
|
GetCurrentSize(),
|
||||||
|
@ -287,14 +287,14 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetAddEvent(Action AddCallback)
|
public void SetAddEvent(Action addCallback)
|
||||||
{
|
{
|
||||||
_addCallback = AddCallback;
|
_addCallback = addCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetEditEvent(Action EditCallback)
|
public void SetEditEvent(Action editCallback)
|
||||||
{
|
{
|
||||||
_editCallback = EditCallback;
|
_editCallback = editCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -172,7 +172,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
LoadConfigSettings();
|
LoadConfigSettings();
|
||||||
ToggleGameGenieButton();
|
ToggleGameGenieButton();
|
||||||
CheatEditor.SetAddEvent(AddCheat);
|
CheatEditor.SetAddEvent(AddCheat);
|
||||||
CheatEditor.SetEditEvent(AddCheat); // CheatList.Add is already an upsert, so there is nothing different to handle here
|
CheatEditor.SetEditEvent(EditCheat);
|
||||||
UpdateDialog();
|
UpdateDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,6 +194,12 @@ namespace BizHawk.Client.EmuHawk
|
||||||
UpdateMessageLabel();
|
UpdateMessageLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void EditCheat()
|
||||||
|
{
|
||||||
|
Global.CheatList.Remove(CheatEditor.OriginalCheat);
|
||||||
|
AddCheat();
|
||||||
|
}
|
||||||
|
|
||||||
public void SaveConfigSettings()
|
public void SaveConfigSettings()
|
||||||
{
|
{
|
||||||
SaveColumnInfo();
|
SaveColumnInfo();
|
||||||
|
|
Loading…
Reference in New Issue