convert ToolHelper methods for freezing/unfreezing a collection of watch items into extensions
This commit is contained in:
parent
ce4ce0bacc
commit
3bbe3990ed
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
using BizHawk.Client.Common;
|
using BizHawk.Client.Common;
|
||||||
|
|
||||||
|
@ -55,5 +56,18 @@ namespace BizHawk.Client.EmuHawk.ToolExtensions
|
||||||
|
|
||||||
GlobalWin.Sound.StartSound();
|
GlobalWin.Sound.StartSound();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void FreezeAll(this IEnumerable<Watch> watches)
|
||||||
|
{
|
||||||
|
Global.CheatList.AddRange(
|
||||||
|
watches
|
||||||
|
.Where(w => !w.IsSeparator)
|
||||||
|
.Select(w => new Cheat(w, w.Value ?? 0)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void UnfreezeAll(this IEnumerable<Watch> watches)
|
||||||
|
{
|
||||||
|
Global.CheatList.RemoveRange(watches.Where(watch => !watch.IsSeparator));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -252,19 +252,6 @@ namespace BizHawk.Client.EmuHawk
|
||||||
GlobalWin.MainForm.UpdateCheatStatus();
|
GlobalWin.MainForm.UpdateCheatStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void FreezeAddress(IEnumerable<Watch> watches)
|
|
||||||
{
|
|
||||||
Global.CheatList.AddRange(
|
|
||||||
watches
|
|
||||||
.Where(w => !w.IsSeparator)
|
|
||||||
.Select(w => new Cheat(w, w.Value ?? 0)));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void UnfreezeAddress(IEnumerable<Watch> watches)
|
|
||||||
{
|
|
||||||
Global.CheatList.RemoveRange(watches.Where(watch => !watch.IsSeparator));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void ViewInHexEditor(MemoryDomain domain, IEnumerable<int> addresses, Watch.WatchSize size)
|
public static void ViewInHexEditor(MemoryDomain domain, IEnumerable<int> addresses, Watch.WatchSize size)
|
||||||
{
|
{
|
||||||
GlobalWin.Tools.Load<HexEditor>();
|
GlobalWin.Tools.Load<HexEditor>();
|
||||||
|
|
|
@ -1243,11 +1243,11 @@ namespace BizHawk.Client.EmuHawk
|
||||||
var allCheats = SelectedWatches.All(x => Global.CheatList.IsActive(x.Domain, x.Address ?? 0));
|
var allCheats = SelectedWatches.All(x => Global.CheatList.IsActive(x.Domain, x.Address ?? 0));
|
||||||
if (allCheats)
|
if (allCheats)
|
||||||
{
|
{
|
||||||
ToolHelpers.UnfreezeAddress(SelectedWatches);
|
SelectedWatches.UnfreezeAll();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ToolHelpers.FreezeAddress(SelectedWatches);
|
SelectedWatches.FreezeAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -784,11 +784,11 @@ namespace BizHawk.Client.EmuHawk
|
||||||
var allCheats = SelectedWatches.All(x => Global.CheatList.IsActive(x.Domain, x.Address ?? 0));
|
var allCheats = SelectedWatches.All(x => Global.CheatList.IsActive(x.Domain, x.Address ?? 0));
|
||||||
if (allCheats)
|
if (allCheats)
|
||||||
{
|
{
|
||||||
ToolHelpers.UnfreezeAddress(SelectedWatches);
|
SelectedWatches.UnfreezeAll();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ToolHelpers.FreezeAddress(SelectedWatches);
|
SelectedWatches.FreezeAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue