Round 1 of Removing the old cheat system in factor of the new one, old dialog and cheats removed from most tools and the mainform. Lua and Game Genie dialogs still use the legacy cheat system and therefore are busted in this commit.
This commit is contained in:
parent
ab26bbecfc
commit
5a0c075270
|
@ -348,7 +348,7 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
if ((Global.Emulator.SystemId == "GB") || (Global.Game.System == "GG"))
|
||||
{
|
||||
Cheat c = new Cheat();
|
||||
LegacyCheat c = new LegacyCheat();
|
||||
if (cheatname.Text.Length > 0)
|
||||
c.Name = cheatname.Text;
|
||||
else
|
||||
|
@ -391,7 +391,7 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
c.Domain = Global.Emulator.MemoryDomains[x];
|
||||
c.Enable();
|
||||
Global.MainForm.Cheats1.AddCheat(c);
|
||||
Global.CheatList_Legacy.Add(c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -224,8 +224,8 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
if (Global.Emulator is Genesis)
|
||||
{
|
||||
Cheat c = new Cheat();
|
||||
Cheat d = new Cheat();
|
||||
LegacyCheat c = new LegacyCheat();
|
||||
LegacyCheat d = new LegacyCheat();
|
||||
if (cheatname.Text.Length > 0)
|
||||
{
|
||||
c.Name = cheatname.Text + " Part 1";
|
||||
|
@ -269,10 +269,10 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
c.Domain = Global.Emulator.MemoryDomains[x];
|
||||
c.Enable();
|
||||
Global.MainForm.Cheats1.AddCheat(c);
|
||||
Global.CheatList_Legacy.Add(c);
|
||||
d.Domain = Global.Emulator.MemoryDomains[x];
|
||||
d.Enable();
|
||||
Global.MainForm.Cheats1.AddCheat(d);
|
||||
Global.CheatList_Legacy.Add(d);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@ namespace BizHawk.MultiClient
|
|||
public static IEmulator Emulator;
|
||||
public static CoreComm CoreComm;
|
||||
public static GameInfo Game;
|
||||
public static LegacyCheatList CheatList_Legacy;
|
||||
public static CheatList CheatList;
|
||||
public static NewCheatList CheatList2;
|
||||
|
||||
public static Controller NullControls;
|
||||
public static AutofireController AutofireNullControls;
|
||||
|
|
|
@ -2984,7 +2984,6 @@
|
|||
this.newCheatsToolStripMenuItem.Name = "newCheatsToolStripMenuItem";
|
||||
this.newCheatsToolStripMenuItem.Size = new System.Drawing.Size(189, 22);
|
||||
this.newCheatsToolStripMenuItem.Text = "New Cheats";
|
||||
this.newCheatsToolStripMenuItem.Click += new System.EventHandler(this.newCheatsToolStripMenuItem_Click);
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
|
|
|
@ -1545,7 +1545,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
public void UpdateCheatStatus()
|
||||
{
|
||||
if (Global.CheatList.HasActiveCheats)
|
||||
if (Global.CheatList.ActiveCount > 0)
|
||||
{
|
||||
CheatStatus.ToolTipText = "Cheats are currently active";
|
||||
CheatStatus.Image = Properties.Resources.Freeze;
|
||||
|
@ -2181,9 +2181,8 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
else if (ext.ToUpper() == ".CHT")
|
||||
{
|
||||
Global.CheatList.Load(filePaths[0], false);
|
||||
LoadCheatsWindow();
|
||||
Cheats1.LoadCheatFile(filePaths[0], false);
|
||||
Cheats1.DisplayCheatsList();
|
||||
}
|
||||
else if (ext.ToUpper() == ".WCH")
|
||||
{
|
||||
|
|
|
@ -96,7 +96,7 @@ namespace BizHawk.MultiClient
|
|||
private GBtools.GBGPUView _gbgpuview = null;
|
||||
private GBAtools.GBAGPUView _gbagpuview = null;
|
||||
private PCEBGViewer _pcebgviewer = null;
|
||||
private Cheats _cheats = null;
|
||||
private NewCheatForm _cheats = null;
|
||||
private ToolBox _toolbox = null;
|
||||
private TI83KeyPad _ti83pad = null;
|
||||
private TAStudio _tastudio = null;
|
||||
|
@ -110,7 +110,6 @@ namespace BizHawk.MultiClient
|
|||
|
||||
//TODO: this is a lazy way to refactor things, but works for now. The point is to not have these objects created until needed, without refactoring a lot of code
|
||||
public RamSearch RamSearch1 { get { if (_ramsearch == null) _ramsearch = new RamSearch(); return _ramsearch; } set { _ramsearch = value; } }
|
||||
|
||||
public HexEditor HexEditor1 { get { if (_hexeditor == null) _hexeditor = new HexEditor(); return _hexeditor; } set { _hexeditor = value; } }
|
||||
public TraceLogger TraceLogger1 { get { if (_tracelogger == null) _tracelogger = new TraceLogger(); return _tracelogger; } set { _tracelogger = value; } }
|
||||
public SNESGraphicsDebugger SNESGraphicsDebugger1 { get { if (_snesgraphicsdebugger == null) _snesgraphicsdebugger = new SNESGraphicsDebugger(); return _snesgraphicsdebugger; } set { _snesgraphicsdebugger = value; } }
|
||||
|
@ -120,7 +119,6 @@ namespace BizHawk.MultiClient
|
|||
public GBtools.GBGPUView GBGPUView1 { get { if (_gbgpuview == null) _gbgpuview = new GBtools.GBGPUView(); return _gbgpuview; } set { _gbgpuview = value; } }
|
||||
public GBAtools.GBAGPUView GBAGPUView1 { get { if (_gbagpuview == null) _gbagpuview = new GBAtools.GBAGPUView(); return _gbagpuview; } set { _gbagpuview = value; } }
|
||||
public PCEBGViewer PCEBGViewer1 { get { if (_pcebgviewer == null) _pcebgviewer = new PCEBGViewer(); return _pcebgviewer; } set { _pcebgviewer = value; } }
|
||||
public Cheats Cheats1 { get { if (_cheats == null) _cheats = new Cheats(); return _cheats; } set { _cheats = value; } }
|
||||
public ToolBox ToolBox1 { get { if (_toolbox == null) _toolbox = new ToolBox(); return _toolbox; } set { _toolbox = value; } }
|
||||
public TI83KeyPad TI83KeyPad1 { get { if (_ti83pad == null) _ti83pad = new TI83KeyPad(); return _ti83pad; } set { _ti83pad = value; } }
|
||||
public TAStudio TAStudio1 { get { if (_tastudio == null) _tastudio = new TAStudio(); return _tastudio; } set { _tastudio = value; } }
|
||||
|
@ -135,6 +133,11 @@ namespace BizHawk.MultiClient
|
|||
|
||||
//TODO: eventually start doing this, rather than tools attempting to talk to tools
|
||||
public void Cheats_UpdateValues() { if (_cheats != null) { _cheats.UpdateValues(); } }
|
||||
public void Cheats_Restart()
|
||||
{
|
||||
if (_cheats != null) _cheats.Restart();
|
||||
else Global.CheatList.NewList();
|
||||
}
|
||||
|
||||
#if WINDOWS
|
||||
private LuaConsole _luaconsole = null;
|
||||
|
@ -171,8 +174,8 @@ namespace BizHawk.MultiClient
|
|||
|
||||
FFMpeg.FFMpegPath = PathManager.MakeProgramRelativePath(Global.Config.FFMpegPath);
|
||||
|
||||
Global.CheatList_Legacy = new LegacyCheatList();
|
||||
Global.CheatList = new CheatList();
|
||||
Global.CheatList2 = new NewCheatList();
|
||||
UpdateStatusSlots();
|
||||
UpdateKeyPriorityIcon();
|
||||
|
||||
|
@ -200,7 +203,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
Closing += (o, e) =>
|
||||
{
|
||||
Global.CheatList.SaveSettings();
|
||||
Global.CheatList.SaveOnClose();
|
||||
CloseGame();
|
||||
Global.MovieSession.Movie.Stop();
|
||||
CloseTools();
|
||||
|
@ -1592,13 +1595,13 @@ namespace BizHawk.MultiClient
|
|||
if (_ti83pad != null) TI83KeyPad1.Restart();
|
||||
if (_tastudio != null) TAStudio1.Restart();
|
||||
if (_vpad != null) VirtualPadForm1.Restart();
|
||||
if (_cheats != null) Cheats1.Restart();
|
||||
Cheats_Restart();
|
||||
if (_toolbox != null) ToolBox1.Restart();
|
||||
if (_tracelogger != null) TraceLogger1.Restart();
|
||||
|
||||
if (Global.Config.LoadCheatFileByGame)
|
||||
{
|
||||
if (Global.CheatList.AttemptLoadCheatFile())
|
||||
if (Global.CheatList.AttemptToLoadCheatFile())
|
||||
{
|
||||
Global.OSD.AddMessage("Cheats file loaded");
|
||||
}
|
||||
|
@ -2863,13 +2866,19 @@ namespace BizHawk.MultiClient
|
|||
|
||||
public void LoadCheatsWindow()
|
||||
{
|
||||
if (!Cheats1.IsHandleCreated || Cheats1.IsDisposed)
|
||||
if (_cheats == null)
|
||||
{
|
||||
Cheats1 = new Cheats();
|
||||
Cheats1.Show();
|
||||
_cheats = new NewCheatForm();
|
||||
}
|
||||
|
||||
if (!_cheats.IsHandleCreated || _cheats.IsDisposed)
|
||||
{
|
||||
_cheats.Show();
|
||||
}
|
||||
else
|
||||
Cheats1.Focus();
|
||||
{
|
||||
_cheats.Focus();
|
||||
}
|
||||
}
|
||||
|
||||
public VideoPluginSettings N64GenerateVideoSettings(GameInfo game, bool hasmovie)
|
||||
|
@ -3200,7 +3209,7 @@ namespace BizHawk.MultiClient
|
|||
GBAGPUView1.Restart();
|
||||
PCEBGViewer1.Restart();
|
||||
TI83KeyPad1.Restart();
|
||||
Cheats1.Restart();
|
||||
Cheats_Restart();
|
||||
ToolBox1.Restart();
|
||||
#if WINDOWS
|
||||
LuaConsole1.Restart();
|
||||
|
@ -3241,7 +3250,7 @@ namespace BizHawk.MultiClient
|
|||
CloseForm(GBGPUView1);
|
||||
CloseForm(GBAGPUView1);
|
||||
CloseForm(PCEBGViewer1);
|
||||
CloseForm(Cheats1);
|
||||
CloseForm(_cheats);
|
||||
CloseForm(TI83KeyPad1);
|
||||
CloseForm(TAStudio1);
|
||||
CloseForm(TraceLogger1);
|
||||
|
@ -3253,7 +3262,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
private void CloseForm(Form form)
|
||||
{
|
||||
if (form.IsHandleCreated) form.Close();
|
||||
if (form != null && form.IsHandleCreated) form.Close();
|
||||
}
|
||||
|
||||
private void PreviousSlot()
|
||||
|
@ -4177,10 +4186,5 @@ namespace BizHawk.MultiClient
|
|||
RamWatch1.Focus();
|
||||
}
|
||||
}
|
||||
|
||||
private void newCheatsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
new NewCheatForm().Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -334,7 +334,7 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
if (Global.Emulator is NES)
|
||||
{
|
||||
Cheat c = new Cheat { Name = GameGenieCode.Text };
|
||||
LegacyCheat c = new LegacyCheat { Name = GameGenieCode.Text };
|
||||
|
||||
if (String.IsNullOrWhiteSpace(AddressBox.Text))
|
||||
{
|
||||
|
@ -366,7 +366,7 @@ namespace BizHawk.MultiClient
|
|||
c.Domain = Global.Emulator.MemoryDomains[1]; //System Bus only
|
||||
c.Enable();
|
||||
|
||||
Global.MainForm.Cheats1.AddCheat(c);
|
||||
Global.CheatList_Legacy.Add(c);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -293,7 +293,7 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
if (Global.Emulator is LibsnesCore)
|
||||
{
|
||||
Cheat c = new Cheat();
|
||||
LegacyCheat c = new LegacyCheat();
|
||||
if (cheatname.Text.Length > 0)
|
||||
c.Name = cheatname.Text;
|
||||
else
|
||||
|
@ -324,7 +324,7 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
c.Domain = Global.Emulator.MemoryDomains[x];
|
||||
c.Enable();
|
||||
Global.MainForm.Cheats1.AddCheat(c);
|
||||
Global.CheatList_Legacy.Add(c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace BizHawk.MultiClient
|
||||
{
|
||||
public class Cheat
|
||||
public class LegacyCheat
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public int Address { get; set; }
|
||||
|
@ -12,7 +12,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
private bool enabled;
|
||||
|
||||
public Cheat()
|
||||
public LegacyCheat()
|
||||
{
|
||||
Name = "";
|
||||
Address = 0;
|
||||
|
@ -22,7 +22,7 @@ namespace BizHawk.MultiClient
|
|||
Domain = new MemoryDomain("NULL", 1, Endian.Little, addr => 0, (a, v) => { });
|
||||
}
|
||||
|
||||
public Cheat(Cheat c)
|
||||
public LegacyCheat(LegacyCheat c)
|
||||
{
|
||||
Name = c.Name;
|
||||
Address = c.Address;
|
||||
|
@ -40,7 +40,7 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
}
|
||||
|
||||
public Cheat(string cname, int addr, byte val, bool e, MemoryDomain d, byte? comp = null)
|
||||
public LegacyCheat(string cname, int addr, byte val, bool e, MemoryDomain d, byte? comp = null)
|
||||
{
|
||||
Name = cname;
|
||||
Address = addr;
|
||||
|
@ -108,7 +108,7 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
}
|
||||
|
||||
~Cheat()
|
||||
~LegacyCheat()
|
||||
{
|
||||
DisposeOfCheat();
|
||||
}
|
||||
|
|
|
@ -7,9 +7,9 @@ using System.Windows.Forms;
|
|||
|
||||
namespace BizHawk.MultiClient
|
||||
{
|
||||
public class CheatList : IEnumerable<Cheat>
|
||||
public class LegacyCheatList : IEnumerable<LegacyCheat>
|
||||
{
|
||||
private List<Cheat> cheatList = new List<Cheat>();
|
||||
private List<LegacyCheat> cheatList = new List<LegacyCheat>();
|
||||
public string CurrentCheatFile = "";
|
||||
public bool Changes = false;
|
||||
public int Count { get { return cheatList.Count; } }
|
||||
|
@ -35,7 +35,7 @@ namespace BizHawk.MultiClient
|
|||
try
|
||||
{
|
||||
if (s.Length < 6) continue;
|
||||
Cheat c = new Cheat();
|
||||
LegacyCheat c = new LegacyCheat();
|
||||
string temp = s.Substring(0, s.IndexOf('\t'));
|
||||
c.Address = int.Parse(temp, NumberStyles.HexNumber);
|
||||
|
||||
|
@ -103,7 +103,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
if (Global.Config.DisableCheatsOnLoad)
|
||||
{
|
||||
foreach (Cheat t in cheatList)
|
||||
foreach (LegacyCheat t in cheatList)
|
||||
{
|
||||
t.Disable();
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ namespace BizHawk.MultiClient
|
|||
return Global.Emulator.MemoryDomains[0];
|
||||
}
|
||||
|
||||
public IEnumerator<Cheat> GetEnumerator()
|
||||
public IEnumerator<LegacyCheat> GetEnumerator()
|
||||
{
|
||||
return cheatList.GetEnumerator();
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
public void DisableAll()
|
||||
{
|
||||
foreach (Cheat c in cheatList)
|
||||
foreach (LegacyCheat c in cheatList)
|
||||
{
|
||||
c.Disable();
|
||||
}
|
||||
|
@ -210,7 +210,7 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
string str = "";
|
||||
|
||||
foreach (Cheat t in cheatList)
|
||||
foreach (LegacyCheat t in cheatList)
|
||||
{
|
||||
str += FormatAddress(t.Address) + "\t";
|
||||
str += String.Format("{0:X2}", t.Value) + "\t";
|
||||
|
@ -259,7 +259,7 @@ namespace BizHawk.MultiClient
|
|||
if (CurrentCheatFile.Length == 0)
|
||||
CurrentCheatFile = DefaultFilename;
|
||||
|
||||
SaveCheatFile(Global.CheatList.CurrentCheatFile);
|
||||
SaveCheatFile(Global.CheatList_Legacy.CurrentCheatFile);
|
||||
}
|
||||
else if (cheatList.Count == 0 && CurrentCheatFile.Length > 0)
|
||||
{
|
||||
|
@ -273,7 +273,7 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
get
|
||||
{
|
||||
return Path.Combine(Global.CheatList.CheatsPath, PathManager.FilesystemSafeName(Global.Game) + ".cht");
|
||||
return Path.Combine(Global.CheatList_Legacy.CheatsPath, PathManager.FilesystemSafeName(Global.Game) + ".cht");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -315,7 +315,7 @@ namespace BizHawk.MultiClient
|
|||
Global.MainForm.UpdateCheatStatus();
|
||||
}
|
||||
|
||||
public void Remove(Cheat c)
|
||||
public void Remove(LegacyCheat c)
|
||||
{
|
||||
c.DisposeOfCheat();
|
||||
cheatList.Remove(c);
|
||||
|
@ -334,7 +334,7 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
}
|
||||
|
||||
public void Add(Cheat c)
|
||||
public void Add(LegacyCheat c)
|
||||
{
|
||||
if (c != null)
|
||||
{
|
||||
|
@ -343,7 +343,7 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
}
|
||||
|
||||
public Cheat this[int index]
|
||||
public LegacyCheat this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
|
@ -351,7 +351,7 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
}
|
||||
|
||||
public void Insert(int index, Cheat item)
|
||||
public void Insert(int index, LegacyCheat item)
|
||||
{
|
||||
cheatList.Insert(index, item);
|
||||
Global.MainForm.UpdateCheatStatus();
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace BizHawk.MultiClient
|
|||
public void UpdateValues()
|
||||
{
|
||||
if (!IsHandleCreated || IsDisposed) return;
|
||||
CheatListView.ItemCount = Global.CheatList.Count;
|
||||
CheatListView.ItemCount = Global.CheatList_Legacy.Count;
|
||||
DisplayCheatsList();
|
||||
CheatListView.Refresh();
|
||||
}
|
||||
|
@ -71,13 +71,13 @@ namespace BizHawk.MultiClient
|
|||
|
||||
private void CheatListView_QueryItemBkColor(int index, int column, ref Color color)
|
||||
{
|
||||
if (index < Global.CheatList.Count)
|
||||
if (index < Global.CheatList_Legacy.Count)
|
||||
{
|
||||
if (Global.CheatList[index].Address < 0)
|
||||
if (Global.CheatList_Legacy[index].Address < 0)
|
||||
{
|
||||
color = Color.DarkGray;
|
||||
}
|
||||
else if (Global.CheatList[index].IsEnabled)
|
||||
else if (Global.CheatList_Legacy[index].IsEnabled)
|
||||
{
|
||||
color = Color.LightCyan;
|
||||
}
|
||||
|
@ -91,47 +91,47 @@ namespace BizHawk.MultiClient
|
|||
private void CheatListView_QueryItemText(int index, int column, out string text)
|
||||
{
|
||||
text = "";
|
||||
if (Global.CheatList[index].IsSeparator)
|
||||
if (Global.CheatList_Legacy[index].IsSeparator)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (column == 0) //Name
|
||||
{
|
||||
text = Global.CheatList[index].Name;
|
||||
text = Global.CheatList_Legacy[index].Name;
|
||||
}
|
||||
else if (column == 1) //Address
|
||||
{
|
||||
text = Global.CheatList.FormatAddress(Global.CheatList[index].Address);
|
||||
text = Global.CheatList_Legacy.FormatAddress(Global.CheatList_Legacy[index].Address);
|
||||
}
|
||||
else if (column == 2) //Value
|
||||
{
|
||||
if (Global.Config.Cheats_ValuesAsHex)
|
||||
{
|
||||
text = String.Format("{0:X2}", Global.CheatList[index].Value);
|
||||
text = String.Format("{0:X2}", Global.CheatList_Legacy[index].Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
text = Global.CheatList[index].Value.ToString();
|
||||
text = Global.CheatList_Legacy[index].Value.ToString();
|
||||
}
|
||||
}
|
||||
else if (column == 3) //Compare
|
||||
{
|
||||
if (Global.Config.Cheats_ValuesAsHex)
|
||||
{
|
||||
text = String.Format("{0:X2}", Global.CheatList[index].Compare);
|
||||
text = String.Format("{0:X2}", Global.CheatList_Legacy[index].Compare);
|
||||
}
|
||||
else
|
||||
{
|
||||
text = Global.CheatList[index].Compare.ToString();
|
||||
text = Global.CheatList_Legacy[index].Compare.ToString();
|
||||
}
|
||||
}
|
||||
else if (column == 4) //Domain
|
||||
{
|
||||
text = Global.CheatList[index].Domain.Name;
|
||||
text = Global.CheatList_Legacy[index].Domain.Name;
|
||||
}
|
||||
else if (column == 5) //Enabled
|
||||
{
|
||||
if (Global.CheatList[index].IsEnabled)
|
||||
if (Global.CheatList_Legacy[index].IsEnabled)
|
||||
{
|
||||
text = "*";
|
||||
}
|
||||
|
@ -199,14 +199,14 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
}
|
||||
|
||||
public void AddCheat(Cheat c)
|
||||
public void AddCheat(LegacyCheat c)
|
||||
{
|
||||
if (c == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Changes();
|
||||
Global.CheatList.Add(c);
|
||||
Global.CheatList_Legacy.Add(c);
|
||||
Global.OSD.AddMessage("Cheat added.");
|
||||
if (!IsHandleCreated || IsDisposed) return;
|
||||
DisplayCheatsList();
|
||||
|
@ -215,11 +215,11 @@ namespace BizHawk.MultiClient
|
|||
UpdateOtherTools();
|
||||
}
|
||||
|
||||
public void RemoveCheat(Cheat c)
|
||||
public void RemoveCheat(LegacyCheat c)
|
||||
{
|
||||
Changes();
|
||||
|
||||
Global.CheatList.Remove(c.Domain, c.Address);
|
||||
Global.CheatList_Legacy.Remove(c.Domain, c.Address);
|
||||
|
||||
Global.OSD.AddMessage("Cheat removed.");
|
||||
if (!IsHandleCreated || IsDisposed) return;
|
||||
|
@ -239,7 +239,7 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
bool doload = true;
|
||||
|
||||
if (Global.CheatList.Changes)
|
||||
if (Global.CheatList_Legacy.Changes)
|
||||
{
|
||||
doload = AskSave();
|
||||
}
|
||||
|
@ -254,7 +254,7 @@ namespace BizHawk.MultiClient
|
|||
else
|
||||
{
|
||||
DisplayCheatsList();
|
||||
Global.CheatList.Changes = false;
|
||||
Global.CheatList_Legacy.Changes = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -333,7 +333,7 @@ namespace BizHawk.MultiClient
|
|||
public void DisplayCheatsList()
|
||||
{
|
||||
UpdateNumberOfCheats();
|
||||
CheatListView.ItemCount = Global.CheatList.Count;
|
||||
CheatListView.ItemCount = Global.CheatList_Legacy.Count;
|
||||
}
|
||||
|
||||
private void MoveUp()
|
||||
|
@ -344,9 +344,9 @@ namespace BizHawk.MultiClient
|
|||
if (indexes.Count == 0) return;
|
||||
foreach (int index in indexes)
|
||||
{
|
||||
Cheat temp = Global.CheatList[index];
|
||||
Global.CheatList.Remove(Global.CheatList[index]);
|
||||
Global.CheatList.Insert(index - 1, temp);
|
||||
LegacyCheat temp = Global.CheatList_Legacy[index];
|
||||
Global.CheatList_Legacy.Remove(Global.CheatList_Legacy[index]);
|
||||
Global.CheatList_Legacy.Insert(index - 1, temp);
|
||||
|
||||
//Note: here it will get flagged many times redundantly potentially,
|
||||
//but this avoids it being flagged falsely when the user did not select an index
|
||||
|
@ -373,12 +373,12 @@ namespace BizHawk.MultiClient
|
|||
if (indexes.Count == 0) return;
|
||||
foreach (int index in indexes)
|
||||
{
|
||||
Cheat temp = Global.CheatList[index];
|
||||
LegacyCheat temp = Global.CheatList_Legacy[index];
|
||||
|
||||
if (index < Global.CheatList.Count - 1)
|
||||
if (index < Global.CheatList_Legacy.Count - 1)
|
||||
{
|
||||
Global.CheatList.Remove(Global.CheatList[index]);
|
||||
Global.CheatList.Insert(index + 1, temp);
|
||||
Global.CheatList_Legacy.Remove(Global.CheatList_Legacy[index]);
|
||||
Global.CheatList_Legacy.Insert(index + 1, temp);
|
||||
}
|
||||
|
||||
//Note: here it will get flagged many times redundantly potnetially,
|
||||
|
@ -421,18 +421,18 @@ namespace BizHawk.MultiClient
|
|||
|
||||
void Changes()
|
||||
{
|
||||
Global.CheatList.Changes = true;
|
||||
MessageLabel.Text = Path.GetFileName(Global.CheatList.CurrentCheatFile) + " *";
|
||||
Global.CheatList_Legacy.Changes = true;
|
||||
MessageLabel.Text = Path.GetFileName(Global.CheatList_Legacy.CurrentCheatFile) + " *";
|
||||
}
|
||||
|
||||
private FileInfo GetSaveFileFromUser()
|
||||
{
|
||||
var sfd = new SaveFileDialog();
|
||||
if (Global.CheatList.CurrentCheatFile.Length > 0)
|
||||
sfd.FileName = Path.GetFileNameWithoutExtension(Global.CheatList.CurrentCheatFile);
|
||||
if (Global.CheatList_Legacy.CurrentCheatFile.Length > 0)
|
||||
sfd.FileName = Path.GetFileNameWithoutExtension(Global.CheatList_Legacy.CurrentCheatFile);
|
||||
else if (!(Global.Emulator is NullEmulator))
|
||||
sfd.FileName = PathManager.FilesystemSafeName(Global.Game);
|
||||
sfd.InitialDirectory = Global.CheatList.CheatsPath;
|
||||
sfd.InitialDirectory = Global.CheatList_Legacy.CheatsPath;
|
||||
sfd.Filter = "Cheat Files (*.cht)|*.cht|All Files|*.*";
|
||||
sfd.RestoreDirectory = true;
|
||||
Global.Sound.StopSound();
|
||||
|
@ -450,10 +450,10 @@ namespace BizHawk.MultiClient
|
|||
var file = GetSaveFileFromUser();
|
||||
if (file != null)
|
||||
{
|
||||
Global.CheatList.SaveCheatFile(file.FullName);
|
||||
Global.CheatList.CurrentCheatFile = file.FullName;
|
||||
MessageLabel.Text = Path.GetFileName(Global.CheatList.CurrentCheatFile) + " saved.";
|
||||
Global.Config.RecentCheats.Add(Global.CheatList.CurrentCheatFile);
|
||||
Global.CheatList_Legacy.SaveCheatFile(file.FullName);
|
||||
Global.CheatList_Legacy.CurrentCheatFile = file.FullName;
|
||||
MessageLabel.Text = Path.GetFileName(Global.CheatList_Legacy.CurrentCheatFile) + " saved.";
|
||||
Global.Config.RecentCheats.Add(Global.CheatList_Legacy.CurrentCheatFile);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -464,19 +464,19 @@ namespace BizHawk.MultiClient
|
|||
return true;
|
||||
}
|
||||
|
||||
if (Global.CheatList.Changes)
|
||||
if (Global.CheatList_Legacy.Changes)
|
||||
{
|
||||
DialogResult result = MessageBox.Show("Save Changes?", "Cheats", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3);
|
||||
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
//TOOD: Do quicksave if filename, else save as
|
||||
if (String.CompareOrdinal(Global.CheatList.CurrentCheatFile, "") == 0)
|
||||
if (String.CompareOrdinal(Global.CheatList_Legacy.CurrentCheatFile, "") == 0)
|
||||
{
|
||||
SaveAs();
|
||||
}
|
||||
else
|
||||
Global.CheatList.SaveCheatFile(Global.CheatList.CurrentCheatFile);
|
||||
Global.CheatList_Legacy.SaveCheatFile(Global.CheatList_Legacy.CurrentCheatFile);
|
||||
return true;
|
||||
}
|
||||
else if (result == DialogResult.No)
|
||||
|
@ -490,14 +490,14 @@ namespace BizHawk.MultiClient
|
|||
private void NewCheatList()
|
||||
{
|
||||
bool result = true;
|
||||
if (Global.CheatList.Changes) result = AskSave();
|
||||
if (Global.CheatList_Legacy.Changes) result = AskSave();
|
||||
|
||||
if (result)
|
||||
{
|
||||
Global.CheatList.Clear();
|
||||
Global.CheatList_Legacy.Clear();
|
||||
DisplayCheatsList();
|
||||
Global.CheatList.CurrentCheatFile = "";
|
||||
Global.CheatList.Changes = false;
|
||||
Global.CheatList_Legacy.CurrentCheatFile = "";
|
||||
Global.CheatList_Legacy.Changes = false;
|
||||
MessageLabel.Text = "";
|
||||
}
|
||||
}
|
||||
|
@ -519,13 +519,13 @@ namespace BizHawk.MultiClient
|
|||
|
||||
private void Save()
|
||||
{
|
||||
if (String.IsNullOrEmpty(Global.CheatList.CurrentCheatFile))
|
||||
if (String.IsNullOrEmpty(Global.CheatList_Legacy.CurrentCheatFile))
|
||||
{
|
||||
Global.CheatList.CurrentCheatFile = Global.CheatList.DefaultFilename;
|
||||
Global.CheatList_Legacy.CurrentCheatFile = Global.CheatList_Legacy.DefaultFilename;
|
||||
}
|
||||
|
||||
Global.CheatList.SaveCheatFile(Global.CheatList.CurrentCheatFile);
|
||||
MessageLabel.Text = Path.GetFileName(Global.CheatList.CurrentCheatFile) + " saved.";
|
||||
Global.CheatList_Legacy.SaveCheatFile(Global.CheatList_Legacy.CurrentCheatFile);
|
||||
MessageLabel.Text = Path.GetFileName(Global.CheatList_Legacy.CurrentCheatFile) + " saved.";
|
||||
}
|
||||
|
||||
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
|
@ -541,9 +541,9 @@ namespace BizHawk.MultiClient
|
|||
private FileInfo GetFileFromUser()
|
||||
{
|
||||
var ofd = new OpenFileDialog();
|
||||
if (Global.CheatList.CurrentCheatFile.Length > 0)
|
||||
ofd.FileName = Path.GetFileNameWithoutExtension(Global.CheatList.CurrentCheatFile);
|
||||
ofd.InitialDirectory = Global.CheatList.CheatsPath;
|
||||
if (Global.CheatList_Legacy.CurrentCheatFile.Length > 0)
|
||||
ofd.FileName = Path.GetFileNameWithoutExtension(Global.CheatList_Legacy.CurrentCheatFile);
|
||||
ofd.InitialDirectory = Global.CheatList_Legacy.CheatsPath;
|
||||
ofd.Filter = "Cheat Files (*.cht)|*.cht|All Files|*.*";
|
||||
ofd.RestoreDirectory = true;
|
||||
|
||||
|
@ -561,9 +561,9 @@ namespace BizHawk.MultiClient
|
|||
|
||||
public bool LoadCheatFile(string path, bool append)
|
||||
{
|
||||
Global.CheatList.LoadCheatFile(path, append);
|
||||
Global.CheatList_Legacy.LoadCheatFile(path, append);
|
||||
UpdateNumberOfCheats();
|
||||
MessageLabel.Text = Path.GetFileName(Global.CheatList.CurrentCheatFile);
|
||||
MessageLabel.Text = Path.GetFileName(Global.CheatList_Legacy.CurrentCheatFile);
|
||||
DisplayCheatsList();
|
||||
return true;
|
||||
}
|
||||
|
@ -576,7 +576,7 @@ namespace BizHawk.MultiClient
|
|||
if (file != null)
|
||||
{
|
||||
bool r = true;
|
||||
if (Global.CheatList.Changes) r = AskSave();
|
||||
if (Global.CheatList_Legacy.Changes) r = AskSave();
|
||||
if (r)
|
||||
{
|
||||
LoadCheatFile(file.FullName, false);
|
||||
|
@ -597,19 +597,19 @@ namespace BizHawk.MultiClient
|
|||
private void InsertSeparator()
|
||||
{
|
||||
Changes();
|
||||
Cheat c = new Cheat {Address = -1};
|
||||
LegacyCheat c = new LegacyCheat {Address = -1};
|
||||
|
||||
ListView.SelectedIndexCollection indexes = CheatListView.SelectedIndices;
|
||||
if (indexes.Count > 0)
|
||||
{
|
||||
if (indexes[0] > 0)
|
||||
{
|
||||
Global.CheatList.Insert(indexes[0], c);
|
||||
Global.CheatList_Legacy.Insert(indexes[0], c);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Global.CheatList.Add(c);
|
||||
Global.CheatList_Legacy.Add(c);
|
||||
}
|
||||
DisplayCheatsList();
|
||||
CheatListView.Refresh();
|
||||
|
@ -625,14 +625,14 @@ namespace BizHawk.MultiClient
|
|||
InsertSeparator();
|
||||
}
|
||||
|
||||
private Cheat MakeCheat()
|
||||
private LegacyCheat MakeCheat()
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(AddressBox.Text) || String.IsNullOrWhiteSpace(ValueBox.Text))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Cheat c = new Cheat {Name = NameBox.Text};
|
||||
LegacyCheat c = new LegacyCheat {Name = NameBox.Text};
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -668,14 +668,14 @@ namespace BizHawk.MultiClient
|
|||
|
||||
private void RemoveCheat()
|
||||
{
|
||||
if (Global.CheatList.Count == 0) return;
|
||||
if (Global.CheatList_Legacy.Count == 0) return;
|
||||
Changes();
|
||||
ListView.SelectedIndexCollection indexes = CheatListView.SelectedIndices;
|
||||
if (indexes.Count > 0)
|
||||
{
|
||||
foreach (int index in indexes)
|
||||
{
|
||||
Global.CheatList.Remove(Global.CheatList[indexes[0]]); //index[0] used since each iteration will make this the correct list index
|
||||
Global.CheatList_Legacy.Remove(Global.CheatList_Legacy[indexes[0]]); //index[0] used since each iteration will make this the correct list index
|
||||
}
|
||||
indexes.Clear();
|
||||
DisplayCheatsList();
|
||||
|
@ -695,9 +695,9 @@ namespace BizHawk.MultiClient
|
|||
private void UpdateNumberOfCheats()
|
||||
{
|
||||
string message = "";
|
||||
int active = Global.CheatList.ActiveCheatCount;
|
||||
int active = Global.CheatList_Legacy.ActiveCheatCount;
|
||||
|
||||
int c = Global.CheatList.Count;
|
||||
int c = Global.CheatList_Legacy.Count;
|
||||
if (c == 1)
|
||||
{
|
||||
message += c.ToString() + " cheat (" + active.ToString() + " active)";
|
||||
|
@ -734,13 +734,13 @@ namespace BizHawk.MultiClient
|
|||
ListView.SelectedIndexCollection indexes = CheatListView.SelectedIndices;
|
||||
if (indexes.Count > 0)
|
||||
{
|
||||
Cheat c = new Cheat();
|
||||
LegacyCheat c = new LegacyCheat();
|
||||
int x = indexes[0];
|
||||
c.Name = Global.CheatList[x].Name;
|
||||
c.Address = Global.CheatList[x].Address;
|
||||
c.Value = Global.CheatList[x].Value;
|
||||
c.Name = Global.CheatList_Legacy[x].Name;
|
||||
c.Address = Global.CheatList_Legacy[x].Address;
|
||||
c.Value = Global.CheatList_Legacy[x].Value;
|
||||
Changes();
|
||||
Global.CheatList.Add(c);
|
||||
Global.CheatList_Legacy.Add(c);
|
||||
DisplayCheatsList();
|
||||
}
|
||||
}
|
||||
|
@ -762,19 +762,19 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
for (int x = 0; x < indexes.Count; x++)
|
||||
{
|
||||
if (Global.CheatList[indexes[x]].IsEnabled)
|
||||
if (Global.CheatList_Legacy[indexes[x]].IsEnabled)
|
||||
{
|
||||
Global.CheatList[indexes[x]].Disable();
|
||||
Global.CheatList_Legacy[indexes[x]].Disable();
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
Global.CheatList[indexes[x]].Enable();
|
||||
Global.CheatList_Legacy[indexes[x]].Enable();
|
||||
}
|
||||
catch
|
||||
{
|
||||
Global.CheatList.NotSupportedError();
|
||||
Global.CheatList_Legacy.NotSupportedError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -813,12 +813,12 @@ namespace BizHawk.MultiClient
|
|||
ListView.SelectedIndexCollection indexes = CheatListView.SelectedIndices;
|
||||
if (indexes.Count > 0)
|
||||
{
|
||||
NameBox.Text = Global.CheatList[indexes[0]].Name;
|
||||
AddressBox.Text = Global.CheatList.FormatAddress(Global.CheatList[indexes[0]].Address);
|
||||
DoHexorInt(ValueBox, Global.CheatList[indexes[0]].Value);
|
||||
DoHexorInt(CompareBox, Global.CheatList[indexes[0]].Compare);
|
||||
NameBox.Text = Global.CheatList_Legacy[indexes[0]].Name;
|
||||
AddressBox.Text = Global.CheatList_Legacy.FormatAddress(Global.CheatList_Legacy[indexes[0]].Address);
|
||||
DoHexorInt(ValueBox, Global.CheatList_Legacy[indexes[0]].Value);
|
||||
DoHexorInt(CompareBox, Global.CheatList_Legacy[indexes[0]].Compare);
|
||||
|
||||
SetDomainSelection(Global.CheatList[indexes[0]].Domain.ToString());
|
||||
SetDomainSelection(Global.CheatList_Legacy[indexes[0]].Domain.ToString());
|
||||
CheatListView.Refresh();
|
||||
}
|
||||
}
|
||||
|
@ -830,8 +830,8 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
if (AddressBox.Text.Length > 0 && ValueBox.Text.Length > 0)
|
||||
{
|
||||
Global.CheatList.Remove(Global.CheatList[indexes[0]]);
|
||||
Global.CheatList.Add(MakeCheat());
|
||||
Global.CheatList_Legacy.Remove(Global.CheatList_Legacy[indexes[0]]);
|
||||
Global.CheatList_Legacy.Add(MakeCheat());
|
||||
Changes();
|
||||
}
|
||||
CheatListView.Refresh();
|
||||
|
@ -931,7 +931,7 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
|
||||
string Str = e.Label;
|
||||
Global.CheatList[e.Item].Name = Str;
|
||||
Global.CheatList_Legacy[e.Item].Name = Str;
|
||||
}
|
||||
|
||||
private void restoreWindowSizeToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
|
@ -973,7 +973,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
private void fileToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
if (!Global.CheatList.Changes)
|
||||
if (!Global.CheatList_Legacy.Changes)
|
||||
{
|
||||
saveToolStripMenuItem.Enabled = false;
|
||||
}
|
||||
|
@ -990,12 +990,12 @@ namespace BizHawk.MultiClient
|
|||
|
||||
public void DisableAllCheats()
|
||||
{
|
||||
if (Global.CheatList.Any())
|
||||
if (Global.CheatList_Legacy.Any())
|
||||
{
|
||||
Global.OSD.AddMessage("All cheats disabled.");
|
||||
}
|
||||
|
||||
Global.CheatList.DisableAll();
|
||||
Global.CheatList_Legacy.DisableAll();
|
||||
|
||||
MemoryPulse.Clear();
|
||||
CheatListView.Refresh();
|
||||
|
@ -1004,7 +1004,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
public void RemoveAllCheats()
|
||||
{
|
||||
Global.CheatList.Clear();
|
||||
Global.CheatList_Legacy.Clear();
|
||||
MemoryPulse.Clear();
|
||||
if (!IsHandleCreated || IsDisposed) return;
|
||||
CheatListView.Refresh();
|
||||
|
@ -1195,7 +1195,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
private void selectAllToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
for (int x = 0; x < Global.CheatList.Count; x++)
|
||||
for (int x = 0; x < Global.CheatList_Legacy.Count; x++)
|
||||
{
|
||||
CheatListView.SelectItem(x, true);
|
||||
}
|
||||
|
@ -1209,7 +1209,7 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
else if (e.KeyCode == Keys.A && e.Control && !e.Alt && !e.Shift) //Select All
|
||||
{
|
||||
for (int x = 0; x < Global.CheatList.Count; x++)
|
||||
for (int x = 0; x < Global.CheatList_Legacy.Count; x++)
|
||||
{
|
||||
CheatListView.SelectItem(x, true);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
#region Privates
|
||||
|
||||
private NewCheat _cheat;
|
||||
private Cheat _cheat;
|
||||
private const string HexInd = "0x";
|
||||
private bool _loading = false;
|
||||
private bool _editmode = false;
|
||||
|
@ -237,7 +237,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
#region API
|
||||
|
||||
public void SetCheat(NewCheat cheat)
|
||||
public void SetCheat(Cheat cheat)
|
||||
{
|
||||
_editmode = true;
|
||||
_cheat = cheat;
|
||||
|
@ -254,12 +254,12 @@ namespace BizHawk.MultiClient
|
|||
|
||||
public void ClearForm()
|
||||
{
|
||||
_cheat = NewCheat.Separator;
|
||||
_cheat = Cheat.Separator;
|
||||
_editmode = false;
|
||||
SetFormToDefault();
|
||||
}
|
||||
|
||||
public NewCheat Cheat
|
||||
public Cheat Cheat
|
||||
{
|
||||
get
|
||||
{
|
||||
|
@ -271,7 +271,7 @@ namespace BizHawk.MultiClient
|
|||
NameBox.Text,
|
||||
BigEndianCheckBox.Checked);
|
||||
|
||||
return new NewCheat(w, CompareBox.ToRawInt(), enabled: true);
|
||||
return new Cheat(w, CompareBox.ToRawInt(), enabled: true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,15 +8,15 @@ using System.Windows.Forms;
|
|||
|
||||
namespace BizHawk.MultiClient
|
||||
{
|
||||
public class NewCheatList : IEnumerable<NewCheat>
|
||||
public class CheatList : IEnumerable<Cheat>
|
||||
{
|
||||
private List<NewCheat> _cheatList = new List<NewCheat>();
|
||||
private List<Cheat> _cheatList = new List<Cheat>();
|
||||
private string _currentFileName = String.Empty;
|
||||
private bool _changes = false;
|
||||
|
||||
public NewCheatList() { }
|
||||
public CheatList() { }
|
||||
|
||||
public IEnumerator<NewCheat> GetEnumerator()
|
||||
public IEnumerator<Cheat> GetEnumerator()
|
||||
{
|
||||
return _cheatList.GetEnumerator();
|
||||
}
|
||||
|
@ -26,11 +26,29 @@ namespace BizHawk.MultiClient
|
|||
return GetEnumerator();
|
||||
}
|
||||
|
||||
public NewCheat this[int index]
|
||||
public Cheat this[int index]
|
||||
{
|
||||
get { return _cheatList[index]; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks for a .cht file that matches the ROM loaded based on the default filename for a given ROM
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool AttemptToLoadCheatFile()
|
||||
{
|
||||
var file = new FileInfo(GenerateDefaultFilename());
|
||||
|
||||
if (file.Exists)
|
||||
{
|
||||
return Load(file.FullName, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void FlagChanges()
|
||||
{
|
||||
_changes = true;
|
||||
|
@ -46,7 +64,7 @@ namespace BizHawk.MultiClient
|
|||
get { return _cheatList.Count(x => !x.IsSeparator); }
|
||||
}
|
||||
|
||||
public int ActiveCheatCount
|
||||
public int ActiveCount
|
||||
{
|
||||
get { return _cheatList.Count(x => x.Enabled); }
|
||||
}
|
||||
|
@ -56,6 +74,7 @@ namespace BizHawk.MultiClient
|
|||
_cheatList.Clear();
|
||||
_currentFileName = String.Empty;
|
||||
_changes = false;
|
||||
Global.MainForm.UpdateCheatStatus();
|
||||
}
|
||||
|
||||
public void Update()
|
||||
|
@ -63,22 +82,35 @@ namespace BizHawk.MultiClient
|
|||
_cheatList.ForEach(x => x.Pulse());
|
||||
}
|
||||
|
||||
public void Add(NewCheat c)
|
||||
public void Add(Cheat c)
|
||||
{
|
||||
_changes = true;
|
||||
_cheatList.Add(c);
|
||||
Global.MainForm.UpdateCheatStatus();
|
||||
}
|
||||
|
||||
public void Insert(int index, NewCheat c)
|
||||
public void Insert(int index, Cheat c)
|
||||
{
|
||||
_changes = true;
|
||||
_cheatList.Insert(index, c);
|
||||
Global.MainForm.UpdateCheatStatus();
|
||||
}
|
||||
|
||||
public void Remove(NewCheat c)
|
||||
public void Remove(Cheat c)
|
||||
{
|
||||
_changes = true;
|
||||
_cheatList.Remove(c);
|
||||
Global.MainForm.UpdateCheatStatus();
|
||||
}
|
||||
|
||||
public void RemoveRange(IEnumerable<Cheat> cheats)
|
||||
{
|
||||
_changes = true;
|
||||
foreach (var cheat in cheats)
|
||||
{
|
||||
_cheatList.Remove(cheat);
|
||||
}
|
||||
Global.MainForm.UpdateCheatStatus();
|
||||
}
|
||||
|
||||
public bool Changes
|
||||
|
@ -90,18 +122,21 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
_changes = true;
|
||||
_cheatList.Clear();
|
||||
Global.MainForm.UpdateCheatStatus();
|
||||
}
|
||||
|
||||
public void DisableAll()
|
||||
{
|
||||
_changes = true;
|
||||
_cheatList.ForEach(x => x.Disable());
|
||||
Global.MainForm.UpdateCheatStatus();
|
||||
}
|
||||
|
||||
public void EnableAll()
|
||||
{
|
||||
_changes = true;
|
||||
_cheatList.ForEach(x => x.Enable());
|
||||
Global.MainForm.UpdateCheatStatus();
|
||||
}
|
||||
|
||||
public bool IsActive(MemoryDomain domain, int address)
|
||||
|
@ -147,7 +182,28 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
|
||||
Watch w = Watch.GenerateWatch(domain, address, size, Watch.DisplayType.Unsigned, String.Empty, endian);
|
||||
_cheatList.Add(new NewCheat(w, compare: null, enabled: true));
|
||||
_cheatList.Add(new Cheat(w, compare: null, enabled: true));
|
||||
Global.MainForm.UpdateCheatStatus();
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveOnClose()
|
||||
{
|
||||
if (Global.Config.CheatsAutoSaveOnClose)
|
||||
{
|
||||
if (_changes && _cheatList.Any())
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(_currentFileName))
|
||||
{
|
||||
_currentFileName = GenerateDefaultFilename();
|
||||
}
|
||||
|
||||
SaveFile(_currentFileName);
|
||||
}
|
||||
else if (!_cheatList.Any() && !String.IsNullOrWhiteSpace(_currentFileName))
|
||||
{
|
||||
new FileInfo(_currentFileName).Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -206,7 +262,7 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
if (s == "----")
|
||||
{
|
||||
_cheatList.Add(NewCheat.Separator);
|
||||
_cheatList.Add(Cheat.Separator);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -255,7 +311,7 @@ namespace BizHawk.MultiClient
|
|||
BIGENDIAN
|
||||
);
|
||||
|
||||
NewCheat c = new NewCheat(w, COMPARE, Global.Config.DisableCheatsOnLoad ? false : ENABLED);
|
||||
Cheat c = new Cheat(w, COMPARE, Global.Config.DisableCheatsOnLoad ? false : ENABLED);
|
||||
_cheatList.Add(c);
|
||||
}
|
||||
}
|
||||
|
@ -266,6 +322,7 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
}
|
||||
|
||||
Global.MainForm.UpdateCheatStatus();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -542,7 +599,7 @@ namespace BizHawk.MultiClient
|
|||
var sfd = new SaveFileDialog();
|
||||
if (!String.IsNullOrWhiteSpace(_currentFileName))
|
||||
{
|
||||
sfd.FileName = Path.GetFileNameWithoutExtension(Global.CheatList.CurrentCheatFile);
|
||||
sfd.FileName = Path.GetFileNameWithoutExtension(Global.CheatList_Legacy.CurrentCheatFile);
|
||||
}
|
||||
else if (!(Global.Emulator is NullEmulator))
|
||||
{
|
||||
|
|
|
@ -5,11 +5,11 @@ using System.Text;
|
|||
|
||||
namespace BizHawk.MultiClient
|
||||
{
|
||||
public class NewCheat
|
||||
public class Cheat
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
public NewCheat(Watch watch, int? compare = null, bool enabled = true)
|
||||
public Cheat(Watch watch, int? compare = null, bool enabled = true)
|
||||
{
|
||||
_enabled = enabled;
|
||||
_watch = watch;
|
||||
|
@ -20,7 +20,7 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
}
|
||||
|
||||
public NewCheat(NewCheat cheat)
|
||||
public Cheat(Cheat cheat)
|
||||
{
|
||||
if (cheat.IsSeparator)
|
||||
{
|
||||
|
@ -42,9 +42,9 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
}
|
||||
|
||||
public static NewCheat Separator
|
||||
public static Cheat Separator
|
||||
{
|
||||
get { return new NewCheat(SeparatorWatch.Instance, null, false); }
|
||||
get { return new Cheat(SeparatorWatch.Instance, null, false); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -756,9 +756,9 @@
|
|||
this.Controls.Add(this.CheatsMenu);
|
||||
this.Controls.Add(this.CheatListView);
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.MinimumSize = new System.Drawing.Size(285, 311);
|
||||
this.MinimumSize = new System.Drawing.Size(285, 384);
|
||||
this.Name = "NewCheatForm";
|
||||
this.Text = "New Cheat form";
|
||||
this.Text = "Cheats";
|
||||
this.Load += new System.EventHandler(this.NewCheatForm_Load);
|
||||
this.DragDrop += new System.Windows.Forms.DragEventHandler(this.NewCheatForm_DragDrop);
|
||||
this.DragEnter += new System.Windows.Forms.DragEventHandler(this.NewCheatForm_DragEnter);
|
||||
|
|
|
@ -58,25 +58,50 @@ namespace BizHawk.MultiClient
|
|||
TopMost = Global.Config.CheatsAlwaysOnTop;
|
||||
}
|
||||
|
||||
public void UpdateValues()
|
||||
{
|
||||
if (!IsHandleCreated || IsDisposed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateListView();
|
||||
}
|
||||
}
|
||||
|
||||
public void Restart()
|
||||
{
|
||||
if (!IsHandleCreated || IsDisposed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
NewList();
|
||||
ToggleGameGenieButton();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateListView()
|
||||
{
|
||||
CheatListView.ItemCount = Global.CheatList2.Count;
|
||||
TotalLabel.Text = Global.CheatList2.CheatCount.ToString()
|
||||
+ (Global.CheatList2.CheatCount == 1 ? " cheat " : " cheats ")
|
||||
+ Global.CheatList2.ActiveCheatCount.ToString() + " active";
|
||||
CheatListView.ItemCount = Global.CheatList.Count;
|
||||
TotalLabel.Text = Global.CheatList.CheatCount.ToString()
|
||||
+ (Global.CheatList.CheatCount == 1 ? " cheat " : " cheats ")
|
||||
+ Global.CheatList.ActiveCount.ToString() + " active";
|
||||
}
|
||||
|
||||
public void LoadFileFromRecent(string path)
|
||||
{
|
||||
bool ask_result = true;
|
||||
if (Global.CheatList2.Changes)
|
||||
if (Global.CheatList.Changes)
|
||||
{
|
||||
ask_result = AskSave();
|
||||
}
|
||||
|
||||
if (ask_result)
|
||||
{
|
||||
bool load_result = Global.CheatList2.Load(path, append: false);
|
||||
bool load_result = Global.CheatList.Load(path, append: false);
|
||||
if (!load_result)
|
||||
{
|
||||
Global.Config.RecentWatches.HandleLoadError(path);
|
||||
|
@ -96,11 +121,11 @@ namespace BizHawk.MultiClient
|
|||
|
||||
if (saved)
|
||||
{
|
||||
message = Path.GetFileName(Global.CheatList2.CurrentFileName) + " saved.";
|
||||
message = Path.GetFileName(Global.CheatList.CurrentFileName) + " saved.";
|
||||
}
|
||||
else
|
||||
{
|
||||
message = Path.GetFileName(Global.CheatList2.CurrentFileName) + (Global.CheatList2.Changes ? " *" : String.Empty);
|
||||
message = Path.GetFileName(Global.CheatList.CurrentFileName) + (Global.CheatList.Changes ? " *" : String.Empty);
|
||||
}
|
||||
|
||||
MessageLabel.Text = message;
|
||||
|
@ -113,14 +138,14 @@ namespace BizHawk.MultiClient
|
|||
return true;
|
||||
}
|
||||
|
||||
if (Global.CheatList2.Changes)
|
||||
if (Global.CheatList.Changes)
|
||||
{
|
||||
Global.Sound.StopSound();
|
||||
DialogResult result = MessageBox.Show("Save Changes?", "Cheats", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3);
|
||||
Global.Sound.StartSound();
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
Global.CheatList2.Save();
|
||||
Global.CheatList.Save();
|
||||
}
|
||||
else if (result == DialogResult.No)
|
||||
{
|
||||
|
@ -140,17 +165,17 @@ namespace BizHawk.MultiClient
|
|||
if (file != null)
|
||||
{
|
||||
bool result = true;
|
||||
if (Global.CheatList2.Changes)
|
||||
if (Global.CheatList.Changes)
|
||||
{
|
||||
result = AskSave();
|
||||
}
|
||||
|
||||
if (result)
|
||||
{
|
||||
Global.CheatList2.Load(file.FullName, append);
|
||||
Global.CheatList.Load(file.FullName, append);
|
||||
UpdateListView();
|
||||
UpdateMessageLabel();
|
||||
Global.Config.RecentCheats.Add(Global.CheatList2.CurrentFileName);
|
||||
Global.Config.RecentCheats.Add(Global.CheatList.CurrentFileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -158,9 +183,23 @@ namespace BizHawk.MultiClient
|
|||
private void NewCheatForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadConfigSettings();
|
||||
ToggleGameGenieButton();
|
||||
CheatEditor.SetAddEvent(AddCheat);
|
||||
CheatEditor.SetEditEvent(EditCheat);
|
||||
}
|
||||
|
||||
if ((Global.Emulator is NES) || (Global.Emulator is Genesis) || (Global.Emulator.SystemId == "GB") || (Global.Game.System == "GG") || (Global.Emulator is LibsnesCore))
|
||||
protected override void OnClosing(CancelEventArgs e)
|
||||
{
|
||||
if (!Global.Config.CheatsAutoSaveOnClose)
|
||||
{
|
||||
if (!AskSave())
|
||||
e.Cancel = true;
|
||||
}
|
||||
base.OnClosing(e);
|
||||
}
|
||||
|
||||
private void ToggleGameGenieButton()
|
||||
{
|
||||
GameGenieToolbarSeparator.Visible =
|
||||
LoadGameGenieToolbarItem.Visible =
|
||||
((Global.Emulator is NES)
|
||||
|
@ -168,14 +207,11 @@ namespace BizHawk.MultiClient
|
|||
|| (Global.Emulator.SystemId == "GB")
|
||||
|| (Global.Game.System == "GG")
|
||||
|| (Global.Emulator is LibsnesCore));
|
||||
|
||||
CheatEditor.SetAddEvent(AddCheat);
|
||||
CheatEditor.SetEditEvent(EditCheat);
|
||||
}
|
||||
|
||||
private void AddCheat()
|
||||
{
|
||||
Global.CheatList2.Add(CheatEditor.Cheat);
|
||||
Global.CheatList.Add(CheatEditor.Cheat);
|
||||
UpdateListView();
|
||||
UpdateMessageLabel();
|
||||
}
|
||||
|
@ -241,7 +277,7 @@ namespace BizHawk.MultiClient
|
|||
private void CheatListView_QueryItemText(int index, int column, out string text)
|
||||
{
|
||||
text = "";
|
||||
if (index >= Global.CheatList2.Count || Global.CheatList2[index].IsSeparator)
|
||||
if (index >= Global.CheatList.Count || Global.CheatList[index].IsSeparator)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -251,44 +287,44 @@ namespace BizHawk.MultiClient
|
|||
switch (columnName)
|
||||
{
|
||||
case NAME:
|
||||
text = Global.CheatList2[index].Name;
|
||||
text = Global.CheatList[index].Name;
|
||||
break;
|
||||
case ADDRESS:
|
||||
text = Global.CheatList2[index].AddressStr;
|
||||
text = Global.CheatList[index].AddressStr;
|
||||
break;
|
||||
case VALUE:
|
||||
text = Global.CheatList2[index].ValueStr;
|
||||
text = Global.CheatList[index].ValueStr;
|
||||
break;
|
||||
case COMPARE:
|
||||
text = Global.CheatList2[index].CompareStr;
|
||||
text = Global.CheatList[index].CompareStr;
|
||||
break;
|
||||
case ON:
|
||||
text = Global.CheatList2[index].Enabled ? "*" : "";
|
||||
text = Global.CheatList[index].Enabled ? "*" : "";
|
||||
break;
|
||||
case DOMAIN:
|
||||
text = Global.CheatList2[index].Domain.Name;
|
||||
text = Global.CheatList[index].Domain.Name;
|
||||
break;
|
||||
case SIZE:
|
||||
text = Global.CheatList2[index].Size.ToString();
|
||||
text = Global.CheatList[index].Size.ToString();
|
||||
break;
|
||||
case ENDIAN:
|
||||
text = Global.CheatList2[index].BigEndian.Value ? "Big" : "Little";
|
||||
text = Global.CheatList[index].BigEndian.Value ? "Big" : "Little";
|
||||
break;
|
||||
case TYPE:
|
||||
text = Watch.DisplayTypeToString(Global.CheatList2[index].Type);
|
||||
text = Watch.DisplayTypeToString(Global.CheatList[index].Type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void CheatListView_QueryItemBkColor(int index, int column, ref Color color)
|
||||
{
|
||||
if (index < Global.CheatList2.Count)
|
||||
if (index < Global.CheatList.Count)
|
||||
{
|
||||
if (Global.CheatList2[index].IsSeparator)
|
||||
if (Global.CheatList[index].IsSeparator)
|
||||
{
|
||||
color = BackColor;
|
||||
}
|
||||
else if (Global.CheatList2[index].Enabled)
|
||||
else if (Global.CheatList[index].Enabled)
|
||||
{
|
||||
color = Color.LightCyan;
|
||||
}
|
||||
|
@ -309,18 +345,18 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
}
|
||||
|
||||
private List<NewCheat> SelectedItems
|
||||
private List<Cheat> SelectedItems
|
||||
{
|
||||
get
|
||||
{
|
||||
var selected = new List<NewCheat>();
|
||||
var selected = new List<Cheat>();
|
||||
if (SelectedIndices.Any())
|
||||
{
|
||||
foreach (int index in SelectedIndices)
|
||||
{
|
||||
if (!Global.CheatList2[index].IsSeparator)
|
||||
if (!Global.CheatList[index].IsSeparator)
|
||||
{
|
||||
selected.Add(Global.CheatList2[index]);
|
||||
selected.Add(Global.CheatList[index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -328,7 +364,7 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
}
|
||||
|
||||
private List<NewCheat> SelectedCheats
|
||||
private List<Cheat> SelectedCheats
|
||||
{
|
||||
get
|
||||
{
|
||||
|
@ -346,9 +382,9 @@ namespace BizHawk.MultiClient
|
|||
|
||||
foreach (int index in indices)
|
||||
{
|
||||
var cheat = Global.CheatList2[index];
|
||||
Global.CheatList2.Remove(Global.CheatList2[index]);
|
||||
Global.CheatList2.Insert(index - 1, cheat);
|
||||
var cheat = Global.CheatList[index];
|
||||
Global.CheatList.Remove(Global.CheatList[index]);
|
||||
Global.CheatList.Insert(index - 1, cheat);
|
||||
}
|
||||
|
||||
UpdateMessageLabel();
|
||||
|
@ -378,12 +414,12 @@ namespace BizHawk.MultiClient
|
|||
|
||||
foreach (int index in indices)
|
||||
{
|
||||
var cheat = Global.CheatList2[index];
|
||||
var cheat = Global.CheatList[index];
|
||||
|
||||
if (index < Global.CheatList2.Count - 1)
|
||||
if (index < Global.CheatList.Count - 1)
|
||||
{
|
||||
Global.CheatList2.Remove(Global.CheatList2[index]);
|
||||
Global.CheatList2.Insert(index + 1, cheat);
|
||||
Global.CheatList.Remove(Global.CheatList[index]);
|
||||
Global.CheatList.Insert(index + 1, cheat);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -410,7 +446,7 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
foreach (int index in SelectedIndices)
|
||||
{
|
||||
Global.CheatList2.Remove(Global.CheatList2[SelectedIndices[0]]); //SelectedIndices[0] used since each iteration will make this the correct list index
|
||||
Global.CheatList.Remove(Global.CheatList[SelectedIndices[0]]); //SelectedIndices[0] used since each iteration will make this the correct list index
|
||||
}
|
||||
CheatListView.SelectedIndices.Clear();
|
||||
}
|
||||
|
@ -421,7 +457,7 @@ namespace BizHawk.MultiClient
|
|||
private void Toggle()
|
||||
{
|
||||
SelectedCheats.ForEach(x => x.Toggle());
|
||||
Global.CheatList2.FlagChanges();
|
||||
Global.CheatList.FlagChanges();
|
||||
UpdateListView();
|
||||
}
|
||||
|
||||
|
@ -504,13 +540,29 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
}
|
||||
|
||||
private void NewList()
|
||||
{
|
||||
bool result = true;
|
||||
if (Global.CheatList.Changes)
|
||||
{
|
||||
result = AskSave();
|
||||
}
|
||||
|
||||
if (result)
|
||||
{
|
||||
Global.CheatList.NewList();
|
||||
UpdateListView();
|
||||
UpdateMessageLabel();
|
||||
}
|
||||
}
|
||||
|
||||
#region Events
|
||||
|
||||
#region File
|
||||
|
||||
private void FileSubMenu_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
SaveMenuItem.Enabled = Global.CheatList2.Changes;
|
||||
SaveMenuItem.Enabled = Global.CheatList.Changes;
|
||||
}
|
||||
|
||||
private void RecentSubMenu_DropDownOpened(object sender, EventArgs e)
|
||||
|
@ -521,31 +573,20 @@ namespace BizHawk.MultiClient
|
|||
|
||||
private void NewMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
bool result = true;
|
||||
if (Global.CheatList2.Changes)
|
||||
{
|
||||
result = AskSave();
|
||||
}
|
||||
|
||||
if (result)
|
||||
{
|
||||
Global.CheatList2.NewList();
|
||||
UpdateListView();
|
||||
UpdateMessageLabel();
|
||||
}
|
||||
NewList();
|
||||
}
|
||||
|
||||
private void OpenMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
bool append = sender == AppendMenuItem;
|
||||
LoadFile(NewCheatList.GetFileFromUser(Global.CheatList2.CurrentFileName), append);
|
||||
LoadFile(CheatList.GetFileFromUser(Global.CheatList.CurrentFileName), append);
|
||||
}
|
||||
|
||||
private void SaveMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Global.CheatList2.Changes)
|
||||
if (Global.CheatList.Changes)
|
||||
{
|
||||
if (Global.CheatList2.Save())
|
||||
if (Global.CheatList.Save())
|
||||
{
|
||||
UpdateMessageLabel(saved: true);
|
||||
}
|
||||
|
@ -558,7 +599,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
private void SaveAsMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Global.CheatList2.SaveAs())
|
||||
if (Global.CheatList.SaveAs())
|
||||
{
|
||||
UpdateMessageLabel(saved: true);
|
||||
}
|
||||
|
@ -582,7 +623,7 @@ namespace BizHawk.MultiClient
|
|||
ToggleMenuItem.Enabled =
|
||||
SelectedIndices.Any();
|
||||
|
||||
DisableAllCheatsMenuItem.Enabled = Global.CheatList2.ActiveCheatCount > 0;
|
||||
DisableAllCheatsMenuItem.Enabled = Global.CheatList.ActiveCount > 0;
|
||||
|
||||
GameGenieSeparator.Visible =
|
||||
OpenGameGenieEncoderDecoderMenuItem.Visible =
|
||||
|
@ -604,7 +645,7 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
foreach (int index in CheatListView.SelectedIndices)
|
||||
{
|
||||
Global.CheatList2.Add(new NewCheat(Global.CheatList2[index]));
|
||||
Global.CheatList.Add(new Cheat(Global.CheatList[index]));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -616,11 +657,11 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
if (SelectedIndices.Any())
|
||||
{
|
||||
Global.CheatList2.Insert(SelectedIndices.Max(), NewCheat.Separator);
|
||||
Global.CheatList.Insert(SelectedIndices.Max(), Cheat.Separator);
|
||||
}
|
||||
else
|
||||
{
|
||||
Global.CheatList2.Add(NewCheat.Separator);
|
||||
Global.CheatList.Add(Cheat.Separator);
|
||||
}
|
||||
|
||||
UpdateListView();
|
||||
|
@ -639,7 +680,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
private void SelectAllMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
for (int i = 0; i < Global.CheatList2.Count; i++)
|
||||
for (int i = 0; i < Global.CheatList.Count; i++)
|
||||
{
|
||||
CheatListView.SelectItem(i, true);
|
||||
}
|
||||
|
@ -652,7 +693,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
private void DisableAllCheatsMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Global.CheatList2.DisableAll();
|
||||
Global.CheatList.DisableAll();
|
||||
}
|
||||
|
||||
private void OpenGameGenieEncoderDecoderMenuItem_Click(object sender, EventArgs e)
|
||||
|
@ -867,7 +908,7 @@ namespace BizHawk.MultiClient
|
|||
_sortReverse = false;
|
||||
}
|
||||
|
||||
Global.CheatList2.Sort(column.Name, _sortReverse);
|
||||
Global.CheatList.Sort(column.Name, _sortReverse);
|
||||
|
||||
_sortedColumn = column.Name;
|
||||
_sortReverse ^= true;
|
||||
|
|
|
@ -826,7 +826,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
private bool IsFrozen(int address)
|
||||
{
|
||||
return Global.CheatList.IsActiveCheat(Domain, address);
|
||||
return Global.CheatList.IsActive(Domain, address);
|
||||
}
|
||||
|
||||
private void ToggleFreeze()
|
||||
|
@ -839,6 +839,7 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
FreezeAddress(HighlightedAddress.Value);
|
||||
}
|
||||
|
||||
foreach (int i in SecondaryHighlightedAddresses)
|
||||
{
|
||||
if (IsFrozen(i))
|
||||
|
@ -851,76 +852,62 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
}
|
||||
|
||||
UpdateRelatedDialogs();
|
||||
}
|
||||
|
||||
private void UnFreezeAddress(int address) //TODO: refactor to int?
|
||||
{
|
||||
if (address >= 0)
|
||||
{
|
||||
var cheats = Global.CheatList.Where(x => x.Contains(address)).ToList();
|
||||
Global.CheatList.RemoveRange(cheats);
|
||||
}
|
||||
MemoryViewerBox.Refresh();
|
||||
}
|
||||
|
||||
private Watch.WatchSize WatchSize
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (DataSize)
|
||||
{
|
||||
default:
|
||||
case 1:
|
||||
return Watch.WatchSize.Byte;
|
||||
case 2:
|
||||
return Watch.WatchSize.Word;
|
||||
case 4:
|
||||
return Watch.WatchSize.DWord;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateRelatedDialogs()
|
||||
{
|
||||
Global.MainForm.UpdateCheatStatus();
|
||||
Global.MainForm.RamSearch1.UpdateValues();
|
||||
Global.MainForm.RamWatch1.UpdateValues();
|
||||
Global.MainForm.Cheats_UpdateValues();
|
||||
UpdateValues();
|
||||
}
|
||||
|
||||
private void UnFreezeAddress(int address)
|
||||
private void FreezeAddress(int address) //TODO refactor to int?
|
||||
{
|
||||
if (address >= 0)
|
||||
{
|
||||
Cheat c = new Cheat {Address = address, Value = Domain.PeekByte(address), Domain = Domain};
|
||||
Global.MainForm.Cheats1.RemoveCheat(c);
|
||||
Watch watch = Watch.GenerateWatch(
|
||||
Domain,
|
||||
address,
|
||||
WatchSize,
|
||||
Watch.DisplayType.Hex,
|
||||
String.Empty,
|
||||
BigEndian);
|
||||
|
||||
Global.CheatList.Add(new Cheat(watch, compare: null, enabled: true));
|
||||
|
||||
switch (DataSize)
|
||||
{
|
||||
default:
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
Cheat c2 = new Cheat {Address = address + 1, Domain = Domain, Value = Domain.PeekByte(address + 1)};
|
||||
c2.Enable();
|
||||
Global.MainForm.Cheats1.RemoveCheat(c2);
|
||||
break;
|
||||
case 4:
|
||||
Cheat c42 = new Cheat {Address = address + 1, Domain = Domain, Value = Domain.PeekByte(address + 1)};
|
||||
c42.Enable();
|
||||
Global.MainForm.Cheats1.RemoveCheat(c42);
|
||||
Cheat c43 = new Cheat {Address = address + 2, Domain = Domain, Value = Domain.PeekByte(address + 2)};
|
||||
c43.Enable();
|
||||
Global.MainForm.Cheats1.RemoveCheat(c43);
|
||||
Cheat c44 = new Cheat {Address = address + 3, Domain = Domain, Value = Domain.PeekByte(address + 3)};
|
||||
c44.Enable();
|
||||
Global.MainForm.Cheats1.RemoveCheat(c44);
|
||||
break;
|
||||
}
|
||||
}
|
||||
MemoryViewerBox.Refresh();
|
||||
UpdateRelatedDialogs();
|
||||
}
|
||||
|
||||
private void FreezeAddress(int address)
|
||||
{
|
||||
if (address >= 0)
|
||||
{
|
||||
Cheat c = new Cheat {Address = address, Value = Domain.PeekByte(address), Domain = Domain};
|
||||
c.Enable();
|
||||
Global.MainForm.Cheats1.AddCheat(c);
|
||||
|
||||
switch (DataSize)
|
||||
{
|
||||
default:
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
Cheat c2 = new Cheat {Address = address + 1, Domain = Domain, Value = Domain.PeekByte(address + 1)};
|
||||
c2.Enable();
|
||||
Global.MainForm.Cheats1.AddCheat(c2);
|
||||
break;
|
||||
case 4:
|
||||
Cheat c42 = new Cheat {Address = address + 1, Domain = Domain, Value = Domain.PeekByte(address + 1)};
|
||||
c42.Enable();
|
||||
Global.MainForm.Cheats1.AddCheat(c42);
|
||||
Cheat c43 = new Cheat {Address = address + 2, Domain = Domain, Value = Domain.PeekByte(address + 2)};
|
||||
c43.Enable();
|
||||
Global.MainForm.Cheats1.AddCheat(c43);
|
||||
Cheat c44 = new Cheat {Address = address + 3, Domain = Domain, Value = Domain.PeekByte(address + 3)};
|
||||
c44.Enable();
|
||||
Global.MainForm.Cheats1.AddCheat(c44);
|
||||
break;
|
||||
}
|
||||
}
|
||||
MemoryViewerBox.Refresh();
|
||||
}
|
||||
|
||||
private void freezeAddressToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
|
@ -1209,19 +1196,20 @@ namespace BizHawk.MultiClient
|
|||
|
||||
private void MemoryViewerBox_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
|
||||
for (int x = 0; x < Global.CheatList.Count; x++)
|
||||
var activeCheats = Global.CheatList.Where(x => x.Enabled);
|
||||
foreach(var cheat in activeCheats)
|
||||
{
|
||||
if (IsVisible(Global.CheatList[x].Address))
|
||||
if (IsVisible(cheat.Address.Value))
|
||||
{
|
||||
if (Domain.ToString() == Global.CheatList[x].Domain.ToString())
|
||||
if (Domain.ToString() == cheat.Domain.Name)
|
||||
{
|
||||
Rectangle rect = new Rectangle(GetAddressCoordinates(Global.CheatList[x].Address), new Size(15 * DataSize, fontHeight));
|
||||
Rectangle rect = new Rectangle(GetAddressCoordinates(cheat.Address.Value), new Size(15 * DataSize, fontHeight));
|
||||
e.Graphics.DrawRectangle(new Pen(Brushes.Black), rect);
|
||||
e.Graphics.FillRectangle(new SolidBrush(Global.Config.HexFreezeColor), rect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (addressHighlighted >= 0 && IsVisible(addressHighlighted))
|
||||
{
|
||||
Point point = GetAddressCoordinates(addressHighlighted);
|
||||
|
@ -1233,7 +1221,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
Rectangle textrect = new Rectangle(textpoint, new Size((8 * DataSize), fontHeight));
|
||||
|
||||
if (Global.CheatList.IsActiveCheat(Domain, addressHighlighted))
|
||||
if (Global.CheatList.IsActive(Domain, addressHighlighted))
|
||||
{
|
||||
e.Graphics.FillRectangle(new SolidBrush(Global.Config.HexHighlightFreezeColor), rect);
|
||||
e.Graphics.FillRectangle(new SolidBrush(Global.Config.HexHighlightFreezeColor), textrect);
|
||||
|
@ -1255,7 +1243,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
Rectangle textrect = new Rectangle(textpoint, new Size(8, fontHeight));
|
||||
|
||||
if (Global.CheatList.IsActiveCheat(Domain, address))
|
||||
if (Global.CheatList.IsActive(Domain, address))
|
||||
{
|
||||
e.Graphics.FillRectangle(new SolidBrush(Global.Config.HexHighlightFreezeColor), rect);
|
||||
e.Graphics.FillRectangle(new SolidBrush(Global.Config.HexHighlightFreezeColor), textrect);
|
||||
|
@ -1459,7 +1447,7 @@ namespace BizHawk.MultiClient
|
|||
case Keys.Delete:
|
||||
if (e.Modifiers == Keys.Shift)
|
||||
{
|
||||
RemoveAllCheats();
|
||||
ToolHelpers.UnfreezeAll();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1661,24 +1649,14 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
}
|
||||
|
||||
private void RemoveAllCheats()
|
||||
{
|
||||
Global.MainForm.Cheats1.RemoveAllCheats();
|
||||
MemoryViewerBox.Refresh();
|
||||
|
||||
Global.MainForm.RamSearch1.UpdateValues();
|
||||
Global.MainForm.RamWatch1.UpdateValues();
|
||||
Global.MainForm.Cheats_UpdateValues();
|
||||
}
|
||||
|
||||
private void unfreezeAllToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
RemoveAllCheats();
|
||||
ToolHelpers.UnfreezeAll();
|
||||
}
|
||||
|
||||
private void unfreezeAllToolStripMenuItem1_Click(object sender, EventArgs e)
|
||||
{
|
||||
RemoveAllCheats();
|
||||
ToolHelpers.UnfreezeAll();
|
||||
}
|
||||
|
||||
private void HexEditor_MouseWheel(object sender, MouseEventArgs e)
|
||||
|
@ -1766,7 +1744,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
private void HexPokeAddress(int address, byte value)
|
||||
{
|
||||
if (Global.CheatList.IsActiveCheat(Domain, address))
|
||||
if (Global.CheatList.IsActive(Domain, address))
|
||||
{
|
||||
UnFreezeAddress(address);
|
||||
Domain.PokeByte(address, value);
|
||||
|
|
|
@ -3010,7 +3010,7 @@ namespace BizHawk.MultiClient
|
|||
gg.DecodeGameGenieCode(code);
|
||||
if (gg.Address > 0 && gg.Value > 0)
|
||||
{
|
||||
Cheat c = new Cheat
|
||||
LegacyCheat c = new LegacyCheat
|
||||
{
|
||||
Name = code,
|
||||
Domain = Global.Emulator.MemoryDomains[1],
|
||||
|
@ -3022,7 +3022,7 @@ namespace BizHawk.MultiClient
|
|||
c.Compare = (byte)gg.Compare;
|
||||
}
|
||||
c.Enable();
|
||||
Global.MainForm.Cheats1.AddCheat(c);
|
||||
Global.CheatList_Legacy.Add(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3035,7 +3035,7 @@ namespace BizHawk.MultiClient
|
|||
gg.DecodeGameGenieCode(code);
|
||||
if (gg.Address > 0 && gg.Value > 0)
|
||||
{
|
||||
Cheat c = new Cheat
|
||||
LegacyCheat c = new LegacyCheat
|
||||
{
|
||||
Name = code,
|
||||
Domain = Global.Emulator.MemoryDomains[1],
|
||||
|
@ -3046,7 +3046,7 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
c.Compare = (byte)gg.Compare;
|
||||
}
|
||||
Global.CheatList.Remove(Global.Emulator.MemoryDomains[1], c.Address);
|
||||
Global.CheatList_Legacy.Remove(Global.Emulator.MemoryDomains[1], c.Address);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,8 +59,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
public static void UnfreezeAll()
|
||||
{
|
||||
Global.MainForm.Cheats1.RemoveAllCheats();
|
||||
|
||||
Global.CheatList.DisableAll();
|
||||
Global.MainForm.RamWatch1.UpdateValues();
|
||||
Global.MainForm.HexEditor1.UpdateValues();
|
||||
Global.MainForm.Cheats_UpdateValues();
|
||||
|
@ -71,72 +70,11 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
foreach(var watch in watches)
|
||||
{
|
||||
switch (watch.Size)
|
||||
{
|
||||
case Watch.WatchSize.Byte:
|
||||
Cheat c = new Cheat("", watch.Address.Value, (byte)watch.Value.Value,
|
||||
true, watch.Domain);
|
||||
Global.MainForm.Cheats1.AddCheat(c);
|
||||
break;
|
||||
case Watch.WatchSize.Word:
|
||||
{
|
||||
byte low = (byte)(watch.Value.Value / 256);
|
||||
byte high = (byte)(watch.Value.Value);
|
||||
int a1 = watch.Address.Value;
|
||||
int a2 = watch.Address.Value + 1;
|
||||
if (watch.BigEndian)
|
||||
{
|
||||
Cheat c1 = new Cheat("", a1, low, true, watch.Domain);
|
||||
Cheat c2 = new Cheat("", a2, high, true, watch.Domain);
|
||||
Global.MainForm.Cheats1.AddCheat(c1);
|
||||
Global.MainForm.Cheats1.AddCheat(c2);
|
||||
}
|
||||
else
|
||||
{
|
||||
Cheat c1 = new Cheat("", a1, high, true, watch.Domain);
|
||||
Cheat c2 = new Cheat("", a2, low, true, watch.Domain);
|
||||
Global.MainForm.Cheats1.AddCheat(c1);
|
||||
Global.MainForm.Cheats1.AddCheat(c2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Watch.WatchSize.DWord:
|
||||
{
|
||||
byte HIWORDhigh = (byte)(watch.Value.Value >> 24);
|
||||
byte HIWORDlow = (byte)(watch.Value.Value >> 16);
|
||||
byte LOWORDhigh = (byte)(watch.Value.Value >> 8);
|
||||
byte LOWORDlow = (byte)(watch.Value.Value);
|
||||
int a1 = watch.Address.Value;
|
||||
int a2 = watch.Address.Value + 1;
|
||||
int a3 = watch.Address.Value + 2;
|
||||
int a4 = watch.Address.Value + 3;
|
||||
if (watch.BigEndian)
|
||||
{
|
||||
Cheat c1 = new Cheat("", a1, HIWORDhigh, true, watch.Domain);
|
||||
Cheat c2 = new Cheat("", a2, HIWORDlow, true, watch.Domain);
|
||||
Cheat c3 = new Cheat("", a3, LOWORDhigh, true, watch.Domain);
|
||||
Cheat c4 = new Cheat("", a4, LOWORDlow, true, watch.Domain);
|
||||
Global.MainForm.Cheats1.AddCheat(c1);
|
||||
Global.MainForm.Cheats1.AddCheat(c2);
|
||||
Global.MainForm.Cheats1.AddCheat(c3);
|
||||
Global.MainForm.Cheats1.AddCheat(c4);
|
||||
}
|
||||
else
|
||||
{
|
||||
Cheat c1 = new Cheat("", a1, LOWORDlow, true, watch.Domain);
|
||||
Cheat c2 = new Cheat("", a2, LOWORDhigh, true, watch.Domain);
|
||||
Cheat c3 = new Cheat("", a3, HIWORDlow, true, watch.Domain);
|
||||
Cheat c4 = new Cheat("", a4, HIWORDhigh, true, watch.Domain);
|
||||
Global.MainForm.Cheats1.AddCheat(c1);
|
||||
Global.MainForm.Cheats1.AddCheat(c2);
|
||||
Global.MainForm.Cheats1.AddCheat(c3);
|
||||
Global.MainForm.Cheats1.AddCheat(c4);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
Cheat cheat = new Cheat(watch, compare: null, enabled: true);
|
||||
}
|
||||
|
||||
Global.MainForm.UpdateCheatStatus();
|
||||
Global.MainForm.RamSearch1.UpdateValues();
|
||||
Global.MainForm.RamWatch1.UpdateValues();
|
||||
Global.MainForm.HexEditor1.UpdateValues();
|
||||
Global.MainForm.Cheats_UpdateValues();
|
||||
|
|
|
@ -94,7 +94,7 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
Color nextColor = Color.White;
|
||||
|
||||
bool isCheat = Global.CheatList.IsActiveCheat(Settings.Domain, Searches[index].Address.Value);
|
||||
bool isCheat = Global.CheatList.IsActive(Settings.Domain, Searches[index].Address.Value);
|
||||
bool isWeeded = Global.Config.RamSearchPreviewMode && Searches.Preview(Searches[index].Address.Value) && !forcePreviewClear;
|
||||
|
||||
if (isCheat)
|
||||
|
@ -1165,14 +1165,14 @@ namespace BizHawk.MultiClient
|
|||
ViewInHexEditorContextMenuItem.Visible =
|
||||
SelectedIndices.Count > 0;
|
||||
|
||||
UnfreezeAllContextMenuItem.Visible = Global.CheatList.Any();
|
||||
UnfreezeAllContextMenuItem.Visible = Global.CheatList.ActiveCount > 0;
|
||||
|
||||
ContextMenuSeparator3.Visible = (SelectedIndices.Count > 0) || (Global.CheatList.Any());
|
||||
ContextMenuSeparator3.Visible = (SelectedIndices.Count > 0) || (Global.CheatList.ActiveCount > 0);
|
||||
|
||||
bool allCheats = true;
|
||||
foreach (int index in SelectedIndices)
|
||||
{
|
||||
if (!Global.CheatList.IsActiveCheat(Settings.Domain, Searches[index].Address.Value))
|
||||
if (!Global.CheatList.IsActive(Settings.Domain, Searches[index].Address.Value))
|
||||
{
|
||||
allCheats = false;
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
for (int x = 0; x < Watches.Count; x++)
|
||||
{
|
||||
bool alert = Watches[x].IsSeparator ? false : Global.CheatList.IsActiveCheat(Watches[x].Domain, Watches[x].Address.Value);
|
||||
bool alert = Watches[x].IsSeparator ? false : Global.CheatList.IsActive(Watches[x].Domain, Watches[x].Address.Value);
|
||||
Global.OSD.AddGUIText(
|
||||
Watches[x].ToString(),
|
||||
Global.Config.DispRamWatchx,
|
||||
|
@ -269,7 +269,7 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
color = BackColor;
|
||||
}
|
||||
else if (Global.CheatList.IsActiveCheat(Watches.Domain, Watches[index].Address.Value))
|
||||
else if (Global.CheatList.IsActive(Watches.Domain, Watches[index].Address.Value))
|
||||
{
|
||||
color = Color.LightCyan;
|
||||
}
|
||||
|
@ -1085,7 +1085,7 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
if (!Watches[i].IsSeparator)
|
||||
{
|
||||
if (!Global.CheatList.IsActiveCheat(Watches[i].Domain, Watches[i].Address.Value))
|
||||
if (!Global.CheatList.IsActive(Watches[i].Domain, Watches[i].Address.Value))
|
||||
{
|
||||
allCheats = false;
|
||||
}
|
||||
|
@ -1108,18 +1108,14 @@ namespace BizHawk.MultiClient
|
|||
ShowDiffContextMenuItem.Text = Global.Config.RamWatchShowDiffColumn ? "Hide difference value" : "Show difference value";
|
||||
ShowDomainContextMenuItem.Text = Global.Config.RamWatchShowDomainColumn ? "Hide domain" : "Show domain";
|
||||
|
||||
UnfreezeAllContextMenuItem.Visible = Global.CheatList.HasActiveCheats;
|
||||
UnfreezeAllContextMenuItem.Visible = Global.CheatList.ActiveCount > 0;
|
||||
|
||||
ViewInHexEditorContextMenuItem.Visible = SelectedWatches.Count == 1;
|
||||
}
|
||||
|
||||
private void UnfreezeAllContextMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Global.MainForm.Cheats1.RemoveAllCheats();
|
||||
UpdateValues();
|
||||
Global.MainForm.RamSearch1.UpdateValues();
|
||||
Global.MainForm.HexEditor1.UpdateValues();
|
||||
Global.MainForm.Cheats_UpdateValues();
|
||||
ToolHelpers.UnfreezeAll();
|
||||
}
|
||||
|
||||
private void ViewInHexEditorContextMenuItem_Click(object sender, EventArgs e)
|
||||
|
|
Loading…
Reference in New Issue