Convert Tools to use NewUpdate and remove legacy methods (#1976)

* ToolForm - add General type, remove UpdateValues from IToolForm and start refactoring to NewUpdate, a lot of things are broken

* remove boilerplate Update methods from tool dialogs that do not need them

* convert more tools

* update more tools to use NewUpdate

* update more tools

* update more tools

* convert more tools to use ToolFormBase, remove UpdateBefore property

* set up fast update in some tools

* more fixes to fast update

* Ram Watch/Search - fix fast update

* rename stuff

* rename NewUpdate() to UpdateValues()

* ToolManager - remove unused Cheats convenience property

* cleanup
This commit is contained in:
adelikat 2020-05-03 12:22:02 -05:00 committed by GitHub
parent da5ddf3217
commit ea634daa7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
38 changed files with 196 additions and 587 deletions

View File

@ -2,41 +2,30 @@
{ {
public enum ToolFormUpdateType public enum ToolFormUpdateType
{ {
// reserved /// <summary>
Legacy, LegacyFast, /// Called by other tools and other events outside of a frame loop
/// </summary>
// reserved concept: we can run other events through here (should probably rename then) General,
Reset,
/// <summary> /// <summary>
/// Called before a frame emulates /// Called before a frame emulates
/// </summary> /// </summary>
PreFrame, PreFrame,
FastPreFrame,
/// <summary> /// <summary>
/// Called after a frame emulates /// Called after a frame emulates
/// </summary> /// </summary>
PostFrame PostFrame,
FastPostFrame
} }
public interface IToolForm public interface IToolForm
{ {
/// <summary> /// <summary>
/// Will be called by the client anytime an Update needs to occur, such as after an emulated frame, a loadstate, or a related dialog has made a relevant change /// Directs the tool to update, with an indicator of the type of update
/// </summary> /// </summary>
void UpdateValues(); void UpdateValues(ToolFormUpdateType type);
/// <summary>
/// A new extensible update method
/// </summary>
void NewUpdate(ToolFormUpdateType type);
/// <summary>
/// Will be called by the client when performance is critical,
/// The tool should only do the minimum to still function,
/// Drawing should not occur if possible, during a fast update
/// </summary>
void FastUpdate();
/// <summary> /// <summary>
/// Will be called anytime the dialog needs to be restarted, such as when a new ROM is loaded /// Will be called anytime the dialog needs to be restarted, such as when a new ROM is loaded
@ -51,14 +40,6 @@
/// </summary> /// </summary>
bool AskSaveChanges(); bool AskSaveChanges();
/// <summary>
/// Indicates whether the tool should be updated before a frame loop or after.
/// In general, tools that draw graphics from the core should update before the loop,
/// Information tools such as those that display core ram values should be after.
/// AWESOME! no separate preupdate and postupdate hooks. seriously?
/// </summary>
bool UpdateBefore { get; }
// Necessary winform calls // Necessary winform calls
bool Focus(); bool Focus();
bool ContainsFocus { get; } bool ContainsFocus { get; }

View File

@ -10,7 +10,7 @@ using BizHawk.Emulation.Common;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
public partial class CoreFeatureAnalysis : Form, IToolFormAutoConfig public partial class CoreFeatureAnalysis : ToolFormBase, IToolFormAutoConfig
{ {
#region ConfigPersist #region ConfigPersist
@ -118,8 +118,6 @@ namespace BizHawk.Client.EmuHawk
KnownCores = new Dictionary<string, CoreInfo>(); KnownCores = new Dictionary<string, CoreInfo>();
} }
public void NewUpdate(ToolFormUpdateType type) { }
private TreeNode CreateCoreTree(CoreInfo ci) private TreeNode CreateCoreTree(CoreInfo ci)
{ {
var ret = new TreeNode var ret = new TreeNode
@ -255,16 +253,6 @@ namespace BizHawk.Client.EmuHawk
CoreTree.EndUpdate(); CoreTree.EndUpdate();
} }
#region IToolForm
public void UpdateValues()
{
}
public void FastUpdate()
{
}
public void Restart() public void Restart()
{ {
var ci = new CoreInfo(Emulator); var ci = new CoreInfo(Emulator);
@ -273,11 +261,5 @@ namespace BizHawk.Client.EmuHawk
DoCurrentCoreTree(ci); DoCurrentCoreTree(ci);
DoAllCoresTree(ci); DoAllCoresTree(ci);
} }
public bool AskSaveChanges() => true;
public bool UpdateBefore => false;
#endregion
} }
} }

View File

@ -34,16 +34,8 @@ namespace BizHawk.Client.EmuHawk
Attach(); Attach();
} }
public void UpdateValues() { } // TODO
public void NewUpdate(ToolFormUpdateType type) { }
public void FastUpdate() { }
public void Restart() { } public void Restart() { }
public bool UpdateBefore => true;
private void Attach() private void Attach()
{ {
_logStream = new LogStream(); _logStream = new LogStream();

View File

@ -7,7 +7,7 @@ using BizHawk.Emulation.Common;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
public partial class NESSoundConfig : Form, IToolForm public partial class NESSoundConfig : ToolFormBase, IToolForm
{ {
[RequiredService] [RequiredService]
private NES NES { get; set; } private NES NES { get; set; }
@ -15,19 +15,6 @@ namespace BizHawk.Client.EmuHawk
private NES.NESSettings _oldSettings; private NES.NESSettings _oldSettings;
private NES.NESSettings _settings; private NES.NESSettings _settings;
public bool AskSaveChanges() { return true; }
public bool UpdateBefore => false;
public void UpdateValues()
{
}
public void NewUpdate(ToolFormUpdateType type) { }
public void FastUpdate()
{
}
public void Restart() public void Restart()
{ {
NESSoundConfig_Load(null, null); NESSoundConfig_Load(null, null);

View File

@ -253,26 +253,13 @@ namespace BizHawk.Client.EmuHawk
#endregion #endregion
#region IToolForm Implementation protected override void UpdateBefore() => Update(fast: false);
protected override void FastUpdateBefore() => Update(fast: true);
public bool UpdateBefore => true;
public void NewUpdate(ToolFormUpdateType type) { }
public void UpdateValues()
{
Update(fast: false);
}
public void FastUpdate()
{
Update(fast: true);
}
public void Restart() public void Restart()
{ {
if (_currentDomain == null || if (_currentDomain == null
MemoryDomains.Contains(_currentDomain)) || MemoryDomains.Contains(_currentDomain))
{ {
_currentDomain = MemoryDomains.MainMemory; _currentDomain = MemoryDomains.MainMemory;
_bigEndian = _currentDomain.EndianType == MemoryDomain.Endian.Big; _bigEndian = _currentDomain.EndianType == MemoryDomain.Endian.Big;
@ -296,8 +283,6 @@ namespace BizHawk.Client.EmuHawk
} }
} }
#endregion
#region Control Events #region Control Events
#region FileMenu #region FileMenu

View File

@ -82,17 +82,7 @@ namespace BizHawk.Client.EmuHawk
}); });
} }
public void NewUpdate(ToolFormUpdateType type) { } protected override void UpdateAfter() => UpdateDisplay(false);
public void UpdateValues()
{
UpdateDisplay(false);
}
public void FastUpdate()
{
// Do nothing
}
public void Restart() public void Restart()
{ {
@ -236,8 +226,6 @@ namespace BizHawk.Client.EmuHawk
return true; return true;
} }
public bool UpdateBefore => false;
private bool _autoloading; private bool _autoloading;
public void LoadFile(string path) public void LoadFile(string path)
{ {

View File

@ -53,20 +53,6 @@ namespace BizHawk.Client.EmuHawk
[ConfigPersist] [ConfigPersist]
public CheatsSettings Settings { get; set; } public CheatsSettings Settings { get; set; }
public bool UpdateBefore => false;
public void NewUpdate(ToolFormUpdateType type) { }
public void UpdateValues()
{
// Do nothing
}
public void FastUpdate()
{
// Do nothing
}
public void Restart() public void Restart()
{ {
CheatEditor.MemoryDomains = Core; CheatEditor.MemoryDomains = Core;
@ -76,7 +62,7 @@ namespace BizHawk.Client.EmuHawk
/// <summary> /// <summary>
/// Tools that want to refresh the cheats list should call this, not UpdateValues /// Tools that want to refresh the cheats list should call this, not UpdateValues
/// </summary> /// </summary>
public void UpdateDialog() protected override void GeneralUpdate()
{ {
CheatListView.RowCount = Global.CheatList.Count; CheatListView.RowCount = Global.CheatList.Count;
TotalLabel.Text = $"{Global.CheatList.CheatCount} {(Global.CheatList.CheatCount == 1 ? "cheat" : "cheats")} {Global.CheatList.ActiveCount} active"; TotalLabel.Text = $"{Global.CheatList.CheatCount} {(Global.CheatList.CheatCount == 1 ? "cheat" : "cheats")} {Global.CheatList.ActiveCount} active";
@ -95,7 +81,7 @@ namespace BizHawk.Client.EmuHawk
else else
{ {
Config.RecentCheats.Add(path); Config.RecentCheats.Add(path);
UpdateDialog(); GeneralUpdate();
UpdateMessageLabel(); UpdateMessageLabel();
} }
} }
@ -123,7 +109,7 @@ namespace BizHawk.Client.EmuHawk
if (result) if (result)
{ {
Global.CheatList.Load(file.FullName, append); Global.CheatList.Load(file.FullName, append);
UpdateDialog(); GeneralUpdate();
UpdateMessageLabel(); UpdateMessageLabel();
Config.RecentCheats.Add(Global.CheatList.CurrentFileName); Config.RecentCheats.Add(Global.CheatList.CurrentFileName);
} }
@ -156,7 +142,7 @@ namespace BizHawk.Client.EmuHawk
ToggleGameGenieButton(); ToggleGameGenieButton();
CheatEditor.SetAddEvent(AddCheat); CheatEditor.SetAddEvent(AddCheat);
CheatEditor.SetEditEvent(EditCheat); CheatEditor.SetEditEvent(EditCheat);
UpdateDialog(); GeneralUpdate();
} }
private void SetColumns() private void SetColumns()
@ -185,7 +171,7 @@ namespace BizHawk.Client.EmuHawk
private void AddCheat() private void AddCheat()
{ {
Global.CheatList.Add(CheatEditor.GetCheat()); Global.CheatList.Add(CheatEditor.GetCheat());
UpdateDialog(); GeneralUpdate();
UpdateMessageLabel(); UpdateMessageLabel();
} }
@ -196,7 +182,7 @@ namespace BizHawk.Client.EmuHawk
if (!newCheat.IsSeparator) // If a separator comes from the cheat editor something must have been invalid if (!newCheat.IsSeparator) // If a separator comes from the cheat editor something must have been invalid
{ {
Global.CheatList.Exchange(CheatEditor.OriginalCheat, newCheat); Global.CheatList.Exchange(CheatEditor.OriginalCheat, newCheat);
UpdateDialog(); GeneralUpdate();
UpdateMessageLabel(); UpdateMessageLabel();
} }
} }
@ -331,7 +317,7 @@ namespace BizHawk.Client.EmuHawk
if (result) if (result)
{ {
Global.CheatList.NewList(Tools.GenerateDefaultCheatFilename()); Global.CheatList.NewList(Tools.GenerateDefaultCheatFilename());
UpdateDialog(); GeneralUpdate();
UpdateMessageLabel(); UpdateMessageLabel();
ToggleGameGenieButton(); ToggleGameGenieButton();
} }
@ -436,7 +422,7 @@ namespace BizHawk.Client.EmuHawk
} }
CheatListView.DeselectAll(); CheatListView.DeselectAll();
UpdateDialog(); GeneralUpdate();
} }
} }
@ -451,7 +437,7 @@ namespace BizHawk.Client.EmuHawk
Global.CheatList.Add(Cheat.Separator); Global.CheatList.Add(Cheat.Separator);
} }
UpdateDialog(); GeneralUpdate();
UpdateMessageLabel(); UpdateMessageLabel();
} }
@ -479,7 +465,7 @@ namespace BizHawk.Client.EmuHawk
} }
UpdateMessageLabel(); UpdateMessageLabel();
UpdateDialog(); GeneralUpdate();
} }
private void MoveDownMenuItem_Click(object sender, EventArgs e) private void MoveDownMenuItem_Click(object sender, EventArgs e)
@ -507,7 +493,7 @@ namespace BizHawk.Client.EmuHawk
CheatListView.SelectRow(index, true); CheatListView.SelectRow(index, true);
} }
UpdateDialog(); GeneralUpdate();
} }
private void SelectAllMenuItem_Click(object sender, EventArgs e) private void SelectAllMenuItem_Click(object sender, EventArgs e)
@ -644,7 +630,7 @@ namespace BizHawk.Client.EmuHawk
_sortedColumn = column.Name; _sortedColumn = column.Name;
_sortReverse ^= true; _sortReverse ^= true;
UpdateDialog(); GeneralUpdate();
} }
private void NewCheatForm_DragDrop(object sender, DragEventArgs e) private void NewCheatForm_DragDrop(object sender, DragEventArgs e)
@ -653,7 +639,7 @@ namespace BizHawk.Client.EmuHawk
if (Path.GetExtension(filePaths[0]) == ".cht") if (Path.GetExtension(filePaths[0]) == ".cht")
{ {
LoadFile(new FileInfo(filePaths[0]), append: false); LoadFile(new FileInfo(filePaths[0]), append: false);
UpdateDialog(); GeneralUpdate();
UpdateMessageLabel(); UpdateMessageLabel();
} }
} }

View File

@ -130,13 +130,6 @@ namespace BizHawk.Client.EmuHawk
#endregion #endregion
public void NewUpdate(ToolFormUpdateType type) { }
public void UpdateValues()
{
// Nothing to do
}
private void FullUpdate() private void FullUpdate()
{ {
RegisterPanel.UpdateValues(); RegisterPanel.UpdateValues();
@ -145,17 +138,10 @@ namespace BizHawk.Client.EmuHawk
BreakPointControl1.UpdateValues(); BreakPointControl1.UpdateValues();
} }
public void FastUpdate()
{
// Nothing to do
}
public void Restart() public void Restart()
{ {
DisengageDebugger(); DisengageDebugger();
EngageDebugger(); EngageDebugger();
} }
public bool UpdateBefore => false;
} }
} }

View File

@ -54,8 +54,6 @@ namespace BizHawk.Client.EmuHawk
} }
} }
public bool UpdateBefore => true;
public GbGpuView() public GbGpuView()
{ {
InitializeComponent(); InitializeComponent();
@ -536,12 +534,7 @@ namespace BizHawk.Client.EmuHawk
// what was last passed to the emu core // what was last passed to the emu core
private int _cbScanlineEmu = -4; // force refresh private int _cbScanlineEmu = -4; // force refresh
public void NewUpdate(ToolFormUpdateType type) { } protected override void UpdateBefore()
/// <summary>
/// put me in ToolsBefore
/// </summary>
public void UpdateValues()
{ {
if (!IsHandleCreated || IsDisposed) if (!IsHandleCreated || IsDisposed)
{ {
@ -572,11 +565,6 @@ namespace BizHawk.Client.EmuHawk
} }
} }
public void FastUpdate()
{
// Do nothing
}
#endregion #endregion
#region mouseovers #region mouseovers

View File

@ -52,16 +52,6 @@ namespace BizHawk.Client.EmuHawk
Gb?.SetPrinterCallback(null); Gb?.SetPrinterCallback(null);
} }
public bool UpdateBefore => false;
public void FastUpdate()
{
}
public void NewUpdate(ToolFormUpdateType type)
{
}
public void Restart() public void Restart()
{ {
// Really, there's not necessarily a reason to clear it at all, // Really, there's not necessarily a reason to clear it at all,
@ -71,7 +61,7 @@ namespace BizHawk.Client.EmuHawk
_connected = false; _connected = false;
} }
public void UpdateValues() protected override void UpdateAfter()
{ {
// Automatically connect once the game is running // Automatically connect once the game is running
if (!_connected) if (!_connected)

View File

@ -29,8 +29,6 @@ namespace BizHawk.Client.EmuHawk
// MobileDetailView memory; // MobileDetailView memory;
public bool UpdateBefore => true;
public GbaGpuView() public GbaGpuView()
{ {
InitializeComponent(); InitializeComponent();
@ -699,7 +697,6 @@ namespace BizHawk.Client.EmuHawk
} }
} }
public void Restart() public void Restart()
{ {
var mem = GBA.GetMemoryAreas(); var mem = GBA.GetMemoryAreas();
@ -709,13 +706,10 @@ namespace BizHawk.Client.EmuHawk
_mmio = mem.mmio; _mmio = mem.mmio;
_cbScanlineEmu = 500; // force an update _cbScanlineEmu = 500; // force an update
UpdateValues(); GeneralUpdate();
} }
public void NewUpdate(ToolFormUpdateType type) { } protected override void UpdateBefore()
/// <summary>belongs in ToolsBefore</summary>
public void UpdateValues()
{ {
if (!IsHandleCreated || IsDisposed) if (!IsHandleCreated || IsDisposed)
{ {
@ -736,11 +730,6 @@ namespace BizHawk.Client.EmuHawk
} }
} }
public void FastUpdate()
{
// Do nothing
}
private void ShowSelectedWidget() private void ShowSelectedWidget()
{ {
if (listBoxWidgets.SelectedItem != null) if (listBoxWidgets.SelectedItem != null)

View File

@ -27,28 +27,10 @@ namespace BizHawk.Client.EmuHawk
InitializeComponent(); InitializeComponent();
} }
#region IToolForm
public bool UpdateBefore => true;
public void FastUpdate()
{
}
public void Restart() public void Restart()
{ {
} }
public void NewUpdate(ToolFormUpdateType type)
{
}
public void UpdateValues()
{
}
#endregion
private void Go_Click(object sender, EventArgs e) private void Go_Click(object sender, EventArgs e)
{ {
foreach (var l in txtCheat.Lines) foreach (var l in txtCheat.Lines)

View File

@ -117,9 +117,7 @@ namespace BizHawk.Client.EmuHawk
bmpViewTiles.Refresh(); bmpViewTiles.Refresh();
} }
public void NewUpdate(ToolFormUpdateType type) { } protected override unsafe void UpdateBefore()
public unsafe void UpdateValues()
{ {
if (Emu == null) if (Emu == null)
{ {
@ -140,24 +138,17 @@ namespace BizHawk.Client.EmuHawk
} }
} }
public void FastUpdate()
{
// Do nothing
}
public void Restart() public void Restart()
{ {
UpdateValues(); GeneralUpdate();
} }
public bool UpdateBefore => true;
private void bmpViewPal_MouseClick(object sender, MouseEventArgs e) private void bmpViewPal_MouseClick(object sender, MouseEventArgs e)
{ {
int idx = e.Y / 16; int idx = e.Y / 16;
idx = Math.Min(3, Math.Max(idx, 0)); idx = Math.Min(3, Math.Max(idx, 0));
_palIndex = idx; _palIndex = idx;
UpdateValues(); GeneralUpdate();
} }
private void VDPViewer_KeyDown(object sender, KeyEventArgs e) private void VDPViewer_KeyDown(object sender, KeyEventArgs e)

View File

@ -149,31 +149,22 @@ namespace BizHawk.Client.EmuHawk
LoadFileFromRecent(RecentTables[0]); LoadFileFromRecent(RecentTables[0]);
} }
FullUpdate(); GeneralUpdate();
} }
#region API #region API
public bool UpdateBefore => false; protected override void UpdateAfter()
public void NewUpdate(ToolFormUpdateType type) { }
public void UpdateValues()
{ {
AddressesLabel.Text = GenerateMemoryViewString(true); AddressesLabel.Text = GenerateMemoryViewString(true);
} }
public void FullUpdate() protected override void GeneralUpdate()
{ {
AddressesLabel.Text = GenerateMemoryViewString(true); AddressesLabel.Text = GenerateMemoryViewString(true);
AddressLabel.Text = GenerateAddressString(); AddressLabel.Text = GenerateAddressString();
} }
public void FastUpdate()
{
// Do nothing
}
public void Restart() public void Restart()
{ {
if (!(MainForm.CurrentlyOpenRomArgs.OpenAdvanced is OpenAdvanced_MAME)) if (!(MainForm.CurrentlyOpenRomArgs.OpenAdvanced is OpenAdvanced_MAME))
@ -210,7 +201,7 @@ namespace BizHawk.Client.EmuHawk
SetDataSize(DataSize); SetDataSize(DataSize);
SetHeader(); SetHeader();
FullUpdate(); GeneralUpdate();
} }
public void SetToAddresses(IEnumerable<long> addresses, MemoryDomain domain, WatchSize size) public void SetToAddresses(IEnumerable<long> addresses, MemoryDomain domain, WatchSize size)
@ -225,7 +216,7 @@ namespace BizHawk.Client.EmuHawk
_secondaryHighlightedAddresses.Clear(); _secondaryHighlightedAddresses.Clear();
_secondaryHighlightedAddresses.AddRange(addrList.Where(addr => addr != addrList[0])); _secondaryHighlightedAddresses.AddRange(addrList.Where(addr => addr != addrList[0]));
ClearNibbles(); ClearNibbles();
FullUpdate(); GeneralUpdate();
MemoryViewerBox.Refresh(); MemoryViewerBox.Refresh();
} }
} }
@ -691,7 +682,7 @@ namespace BizHawk.Client.EmuHawk
UpdateGroupBoxTitle(); UpdateGroupBoxTitle();
SetHeader(); SetHeader();
FullUpdate(); GeneralUpdate();
LastDomain = _domain.Name; LastDomain = _domain.Name;
} }
@ -727,7 +718,7 @@ namespace BizHawk.Client.EmuHawk
SetHighlighted(address); SetHighlighted(address);
ClearNibbles(); ClearNibbles();
FullUpdate(); GeneralUpdate();
MemoryViewerBox.Refresh(); MemoryViewerBox.Refresh();
} }
@ -802,7 +793,7 @@ namespace BizHawk.Client.EmuHawk
_digitFormatString = $"{{0:X{DataSize * 2}}} "; _digitFormatString = $"{{0:X{DataSize * 2}}} ";
SetHeader(); SetHeader();
UpdateGroupBoxTitle(); UpdateGroupBoxTitle();
FullUpdate(); GeneralUpdate();
_secondaryHighlightedAddresses.Clear(); _secondaryHighlightedAddresses.Clear();
} }
} }
@ -1369,7 +1360,7 @@ namespace BizHawk.Client.EmuHawk
{ {
LoadTable(ofd.FileName); LoadTable(ofd.FileName);
RecentTables.Add(ofd.FileName); RecentTables.Add(ofd.FileName);
FullUpdate(); GeneralUpdate();
} }
} }
@ -1389,7 +1380,7 @@ namespace BizHawk.Client.EmuHawk
else else
{ {
RecentTables.Add(path); RecentTables.Add(path);
FullUpdate(); GeneralUpdate();
} }
} }
@ -1519,7 +1510,7 @@ namespace BizHawk.Client.EmuHawk
} }
} }
FullUpdate(); GeneralUpdate();
} }
private bool _lastSearchWasText; private bool _lastSearchWasText;
@ -1631,7 +1622,7 @@ namespace BizHawk.Client.EmuHawk
private void BigEndianMenuItem_Click(object sender, EventArgs e) private void BigEndianMenuItem_Click(object sender, EventArgs e)
{ {
BigEndian ^= true; BigEndian ^= true;
FullUpdate(); GeneralUpdate();
} }
private void GoToAddressMenuItem_Click(object sender, EventArgs e) private void GoToAddressMenuItem_Click(object sender, EventArgs e)
@ -1734,7 +1725,7 @@ namespace BizHawk.Client.EmuHawk
poke.SetWatch(watches); poke.SetWatch(watches);
poke.ShowHawkDialog(); poke.ShowHawkDialog();
FullUpdate(); GeneralUpdate();
} }
} }
@ -1765,7 +1756,7 @@ namespace BizHawk.Client.EmuHawk
private void HexEditor_Resize(object sender, EventArgs e) private void HexEditor_Resize(object sender, EventArgs e)
{ {
SetUpScrollBar(); SetUpScrollBar();
FullUpdate(); GeneralUpdate();
} }
private void HexEditor_ResizeEnd(object sender, EventArgs e) private void HexEditor_ResizeEnd(object sender, EventArgs e)
@ -2014,12 +2005,12 @@ namespace BizHawk.Client.EmuHawk
ClearNibbles(); ClearNibbles();
SetHighlighted(currentAddress + DataSize); SetHighlighted(currentAddress + DataSize);
FullUpdate(); GeneralUpdate();
Refresh(); Refresh();
} }
UpdateGroupBoxTitle(); UpdateGroupBoxTitle();
FullUpdate(); GeneralUpdate();
} }
private void ViewerContextMenuStrip_Opening(object sender, CancelEventArgs e) private void ViewerContextMenuStrip_Opening(object sender, CancelEventArgs e)
@ -2075,7 +2066,7 @@ namespace BizHawk.Client.EmuHawk
_secondaryHighlightedAddresses.ForEach(IncrementAddress); _secondaryHighlightedAddresses.ForEach(IncrementAddress);
FullUpdate(); GeneralUpdate();
} }
private void DecrementContextItem_Click(object sender, EventArgs e) private void DecrementContextItem_Click(object sender, EventArgs e)
@ -2092,7 +2083,7 @@ namespace BizHawk.Client.EmuHawk
_secondaryHighlightedAddresses.ForEach(DecrementAddress); _secondaryHighlightedAddresses.ForEach(DecrementAddress);
FullUpdate(); GeneralUpdate();
} }
#endregion #endregion
@ -2289,7 +2280,7 @@ namespace BizHawk.Client.EmuHawk
_programmaticallyChangingValue = false; _programmaticallyChangingValue = false;
} }
FullUpdate(); GeneralUpdate();
} }
} }

View File

@ -437,7 +437,7 @@ namespace BizHawk.Client.EmuHawk
if (marker != null) if (marker != null)
{ {
Tastudio.CurrentTasMovie.Markers.Remove(marker); Tastudio.CurrentTasMovie.Markers.Remove(marker);
Tastudio.UpdateValues(); Tastudio.RefreshDialog();
} }
} }
} }
@ -456,7 +456,7 @@ namespace BizHawk.Client.EmuHawk
else else
{ {
Tastudio.CurrentTasMovie.Markers.Add(frame, message); Tastudio.CurrentTasMovie.Markers.Add(frame, message);
Tastudio.UpdateValues(); Tastudio.RefreshDialog();
} }
} }
} }

View File

@ -113,24 +113,10 @@ namespace BizHawk.Client.EmuHawk
public LuaLibraries LuaImp { get; private set; } public LuaLibraries LuaImp { get; private set; }
public bool UpdateBefore => true;
private IEnumerable<LuaFile> SelectedItems => LuaListView.SelectedRows.Select(index => LuaImp.ScriptList[index]); private IEnumerable<LuaFile> SelectedItems => LuaListView.SelectedRows.Select(index => LuaImp.ScriptList[index]);
private IEnumerable<LuaFile> SelectedFiles => SelectedItems.Where(x => !x.IsSeparator); private IEnumerable<LuaFile> SelectedFiles => SelectedItems.Where(x => !x.IsSeparator);
public void NewUpdate(ToolFormUpdateType type) { }
public void UpdateValues()
{
// Do nothing
}
public void FastUpdate()
{
// Do nothing
}
private void LuaConsole_Load(object sender, EventArgs e) private void LuaConsole_Load(object sender, EventArgs e)
{ {
// Hack for previous config settings // Hack for previous config settings

View File

@ -87,21 +87,6 @@ namespace BizHawk.Client.EmuHawk
MacroInputTool_Load(null, null); MacroInputTool_Load(null, null);
} }
public void NewUpdate(ToolFormUpdateType type) { }
// These do absolutely nothing.
public void UpdateValues()
{
}
public void FastUpdate()
{
}
public bool UpdateBefore => true;
public override bool AskSaveChanges() public override bool AskSaveChanges()
{ {
if (_unsavedZones.Count == 0 || IsDisposed) if (_unsavedZones.Count == 0 || IsDisposed)

View File

@ -187,7 +187,7 @@ namespace BizHawk.Client.EmuHawk
} }
else if (_tools.IsLoaded<TAStudio>()) else if (_tools.IsLoaded<TAStudio>())
{ {
_tools.TAStudio.UpdateValues(); _tools.UpdateValues<TAStudio>();
} }
} }

View File

@ -61,26 +61,10 @@ namespace BizHawk.Client.EmuHawk
} }
} }
#region IToolForm
public void NewUpdate(ToolFormUpdateType type) { }
public void UpdateValues()
{
}
public void FastUpdate()
{
}
public void Restart() public void Restart()
{ {
} }
public bool UpdateBefore => true;
#endregion
private void CancelBtn_Click(object sender, EventArgs e) private void CancelBtn_Click(object sender, EventArgs e)
{ {
DialogResult = DialogResult.Cancel; DialogResult = DialogResult.Cancel;

View File

@ -7,7 +7,7 @@ using BizHawk.Emulation.Common;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
public partial class BarcodeEntry : Form, IToolForm public partial class BarcodeEntry : ToolFormBase, IToolForm
{ {
[RequiredService] [RequiredService]
private DatachBarcode Reader { get; set; } private DatachBarcode Reader { get; set; }
@ -17,32 +17,11 @@ namespace BizHawk.Client.EmuHawk
InitializeComponent(); InitializeComponent();
} }
#region IToolForm
public void NewUpdate(ToolFormUpdateType type) { }
public void UpdateValues()
{
}
public void FastUpdate()
{
}
public void Restart() public void Restart()
{ {
textBox1_TextChanged(null, null); textBox1_TextChanged(null, null);
} }
public bool AskSaveChanges()
{
return true;
}
public bool UpdateBefore => false;
#endregion
private void textBox1_TextChanged(object sender, EventArgs e) private void textBox1_TextChanged(object sender, EventArgs e)
{ {
if (!DatachBarcode.ValidString(textBox1.Text, out var why)) if (!DatachBarcode.ValidString(textBox1.Text, out var why))

View File

@ -26,23 +26,10 @@ namespace BizHawk.Client.EmuHawk
SyncContents(); SyncContents();
} }
public bool UpdateBefore => true;
public void Restart() public void Restart()
{ {
} }
public void NewUpdate(ToolFormUpdateType type) { }
public void UpdateValues()
{
}
public void FastUpdate()
{
// Do nothing
}
private bool _isRunning; private bool _isRunning;
// http://www.phy.mtu.edu/~suits/notefreqs.html // http://www.phy.mtu.edu/~suits/notefreqs.html

View File

@ -37,29 +37,16 @@ namespace BizHawk.Client.EmuHawk
Generate(true); Generate(true);
} }
#region Public API
public bool UpdateBefore => true;
public void Restart() public void Restart()
{ {
Generate(true); Generate(true);
} }
public void NewUpdate(ToolFormUpdateType type) { } protected override void UpdateBefore()
public void UpdateValues()
{ {
_ppu.InstallCallback1(() => Generate(), _scanline); _ppu.InstallCallback1(() => Generate(), _scanline);
} }
public void FastUpdate()
{
// Do nothing
}
#endregion
private unsafe void DrawTile(int* dst, int pitch, byte* pal, byte* tile, int* finalPal) private unsafe void DrawTile(int* dst, int pitch, byte* pal, byte* tile, int* finalPal)
{ {
dst += 7; dst += 7;
@ -213,7 +200,7 @@ namespace BizHawk.Client.EmuHawk
private void RefreshImageContextMenuItem_Click(object sender, EventArgs e) private void RefreshImageContextMenuItem_Click(object sender, EventArgs e)
{ {
UpdateValues(); GeneralUpdate();
NameTableView.Refresh(); NameTableView.Refresh();
} }

View File

@ -57,29 +57,17 @@ namespace BizHawk.Client.EmuHawk
ChrRomViewReload(); ChrRomViewReload();
} }
#region Public API protected override void UpdateBefore()
public bool UpdateBefore => true;
public void NewUpdate(ToolFormUpdateType type) { }
public void UpdateValues()
{ {
_ppu.InstallCallback2(() => Generate(), _scanline); _ppu.InstallCallback2(() => Generate(), _scanline);
} }
public void FastUpdate()
{
// Do nothing
}
public void Restart() public void Restart()
{ {
Generate(true); Generate(true);
ChrRomViewReload(); ChrRomViewReload();
} }
#endregion
private byte GetBit(byte[] ppuBus, int address, int bit) private byte GetBit(byte[] ppuBus, int address, int bit)
{ {
return (byte)((ppuBus[address] >> (7 - bit)) & 1); return (byte)((ppuBus[address] >> (7 - bit)) & 1);

View File

@ -30,10 +30,6 @@ namespace BizHawk.Client.EmuHawk
Activated += (o, e) => Generate(); Activated += (o, e) => Generate();
} }
#region Public API
public bool UpdateBefore => true;
public unsafe void Generate() public unsafe void Generate()
{ {
if (PCE.Frame % RefreshRate.Value != 0) if (PCE.Frame % RefreshRate.Value != 0)
@ -85,19 +81,7 @@ namespace BizHawk.Client.EmuHawk
// Nothing to do // Nothing to do
} }
public void NewUpdate(ToolFormUpdateType type) { } protected override void UpdateBefore() => Generate();
public void UpdateValues()
{
Generate();
}
public void FastUpdate()
{
// Do nothing
}
#endregion
#region Events #region Events

View File

@ -38,9 +38,7 @@ namespace BizHawk.Client.EmuHawk
base.OnShown(e); base.OnShown(e);
} }
public void NewUpdate(ToolFormUpdateType type) { } protected override void UpdateAfter()
public void UpdateValues()
{ {
foreach (var entry in _psgEntries) foreach (var entry in _psgEntries)
{ {
@ -147,11 +145,6 @@ namespace BizHawk.Client.EmuHawk
lvChannels.EndUpdate(); lvChannels.EndUpdate();
} }
public void FastUpdate()
{
// Todo
}
private class PsgEntry private class PsgEntry
{ {
public int Index { get; set; } public int Index { get; set; }
@ -170,8 +163,6 @@ namespace BizHawk.Client.EmuHawk
{ {
} }
public bool UpdateBefore => false;
// 32*16 samples, 16bit, mono, 8khz (but we'll change the sample rate) // 32*16 samples, 16bit, mono, 8khz (but we'll change the sample rate)
private static readonly byte[] EmptyWav = { private static readonly byte[] EmptyWav = {
0x52, 0x49, 0x46, 0x46, 0x24, 0x04, 0x00, 0x00, 0x57, 0x41, 0x56, 0x45, 0x66, 0x6D, 0x74, 0x20, 0x52, 0x49, 0x46, 0x46, 0x24, 0x04, 0x00, 0x00, 0x57, 0x41, 0x56, 0x45, 0x66, 0x6D, 0x74, 0x20,

View File

@ -30,11 +30,7 @@ namespace BizHawk.Client.EmuHawk
bmpViewSPPal.ChangeBitmapSize(256, 256); bmpViewSPPal.ChangeBitmapSize(256, 256);
} }
#region IToolForm protected override void UpdateBefore()
public void NewUpdate(ToolFormUpdateType type) { }
public void UpdateValues()
{ {
DrawBacks(); DrawBacks();
DrawSprites(); DrawSprites();
@ -45,11 +41,6 @@ namespace BizHawk.Client.EmuHawk
bmpViewSPPal.Refresh(); bmpViewSPPal.Refresh();
} }
public void FastUpdate()
{
// Do nothing
}
static unsafe void Draw16x16(byte* src, int* dest, int pitch, int* pal) static unsafe void Draw16x16(byte* src, int* dest, int pitch, int* pal)
{ {
int inc = pitch - 16; int inc = pitch - 16;
@ -164,14 +155,10 @@ namespace BizHawk.Client.EmuHawk
CheckBoxVDC2_CheckedChanged(null, null); CheckBoxVDC2_CheckedChanged(null, null);
} }
public bool UpdateBefore => true;
#endregion
private void CheckBoxVDC2_CheckedChanged(object sender, EventArgs e) private void CheckBoxVDC2_CheckedChanged(object sender, EventArgs e)
{ {
_vdc = checkBoxVDC2.Checked ? Emu.VDC2 : Emu.VDC1; _vdc = checkBoxVDC2.Checked ? Emu.VDC2 : Emu.VDC1;
UpdateValues(); GeneralUpdate();
} }
private void BmpViewBGPal_MouseClick(object sender, MouseEventArgs e) private void BmpViewBGPal_MouseClick(object sender, MouseEventArgs e)

View File

@ -135,9 +135,7 @@ namespace BizHawk.Client.EmuHawk
bmpViewPalette.Refresh(); bmpViewPalette.Refresh();
} }
public void NewUpdate(ToolFormUpdateType type) { } protected override void UpdateBefore()
public void UpdateValues()
{ {
unsafe unsafe
{ {
@ -150,18 +148,11 @@ namespace BizHawk.Client.EmuHawk
} }
} }
public void FastUpdate()
{
// Do nothing
}
public void Restart() public void Restart()
{ {
UpdateValues(); GeneralUpdate();
} }
public bool UpdateBefore => true;
private void bmpViewPalette_MouseClick(object sender, MouseEventArgs e) private void bmpViewPalette_MouseClick(object sender, MouseEventArgs e)
{ {
int p = Math.Min(Math.Max(e.Y / 16, 0), 1); int p = Math.Min(Math.Max(e.Y / 16, 0), 1);

View File

@ -40,8 +40,6 @@ namespace BizHawk.Client.EmuHawk
{ {
readonly List<DisplayTypeItem> displayTypeItems = new List<DisplayTypeItem>(); readonly List<DisplayTypeItem> displayTypeItems = new List<DisplayTypeItem>();
public bool UpdateBefore => false;
[RequiredService] [RequiredService]
private LibsnesCore Emulator { get; set; } private LibsnesCore Emulator { get; set; }
@ -130,9 +128,7 @@ namespace BizHawk.Client.EmuHawk
: $"@{address:X4} ({address / 1024}K)"; : $"@{address:X4} ({address / 1024}K)";
} }
public void NewUpdate(ToolFormUpdateType type) { } protected override void UpdateAfter()
public void UpdateValues()
{ {
SyncCore(); SyncCore();
if (Visible && !checkScanlineControl.Checked) if (Visible && !checkScanlineControl.Checked)
@ -142,11 +138,6 @@ namespace BizHawk.Client.EmuHawk
} }
} }
public void FastUpdate()
{
// To do
}
public void UpdateToolsLoadstate() public void UpdateToolsLoadstate()
{ {
SyncCore(); SyncCore();

View File

@ -22,13 +22,14 @@ namespace BizHawk.Client.EmuHawk
private bool _hackyDontUpdate; private bool _hackyDontUpdate;
private bool _initializing; // If true, will bypass restart logic, this is necessary since loading projects causes a movie to load which causes a rom to reload causing dialogs to restart private bool _initializing; // If true, will bypass restart logic, this is necessary since loading projects causes a movie to load which causes a rom to reload causing dialogs to restart
public bool UpdateBefore => false;
public void NewUpdate(ToolFormUpdateType type) { }
private int _lastRefresh; private int _lastRefresh;
public void UpdateValues() protected override void GeneralUpdate()
{
RefreshDialog();
}
protected override void UpdateAfter()
{ {
if (!IsHandleCreated || IsDisposed || CurrentTasMovie == null) if (!IsHandleCreated || IsDisposed || CurrentTasMovie == null)
{ {
@ -62,11 +63,6 @@ namespace BizHawk.Client.EmuHawk
RefreshDialog(refreshNeeded, refreshBranches: false); RefreshDialog(refreshNeeded, refreshBranches: false);
} }
public void FastUpdate()
{
// Do nothing
}
public void Restart() public void Restart()
{ {
if (!IsHandleCreated || IsDisposed) if (!IsHandleCreated || IsDisposed)

View File

@ -33,29 +33,11 @@ namespace BizHawk.Client.EmuHawk
Global.InputManager.ClickyVirtualPadController.Click(name); Global.InputManager.ClickyVirtualPadController.Click(name);
} }
#region Public API
public bool UpdateBefore => false;
public void NewUpdate(ToolFormUpdateType type) { }
public void UpdateValues()
{
// Do nothing
}
public void FastUpdate()
{
// Do nothing
}
public void Restart() public void Restart()
{ {
// Do nothing // Do nothing
} }
#endregion
private void SetToolTips() private void SetToolTips()
{ {
// Set button hotkey mapping into tooltips // Set button hotkey mapping into tooltips

View File

@ -28,16 +28,6 @@ namespace BizHawk.Client.EmuHawk
); );
} }
public void NewUpdate(ToolFormUpdateType type) { }
public bool UpdateBefore => false;
public void UpdateValues() { }
public void FastUpdate()
{
// Do nothing
}
public void Restart() public void Restart()
{ {
SetTools(); SetTools();

View File

@ -18,6 +18,34 @@ namespace BizHawk.Client.EmuHawk
public virtual bool AskSaveChanges() => true; public virtual bool AskSaveChanges() => true;
public virtual void UpdateValues(ToolFormUpdateType type)
{
switch (type)
{
case ToolFormUpdateType.PreFrame:
UpdateBefore();
break;
case ToolFormUpdateType.PostFrame:
UpdateAfter();
break;
case ToolFormUpdateType.General:
GeneralUpdate();
break;
case ToolFormUpdateType.FastPreFrame:
FastUpdateBefore();
break;
case ToolFormUpdateType.FastPostFrame:
FastUpdateAfter();
break;
}
}
protected virtual void UpdateBefore() { }
protected virtual void UpdateAfter() { }
protected virtual void GeneralUpdate() { }
protected virtual void FastUpdateBefore() { }
protected virtual void FastUpdateAfter() { }
public static FileInfo OpenFileDialog(string currentFile, string path, string fileType, string fileExt) public static FileInfo OpenFileDialog(string currentFile, string path, string fileType, string fileExt)
{ {
if (!Directory.Exists(path)) if (!Directory.Exists(path))

View File

@ -464,42 +464,24 @@ namespace BizHawk.Client.EmuHawk
private void UpdateBefore() private void UpdateBefore()
{ {
var beforeList = _tools.Where(t => t.UpdateBefore); foreach (var tool in _tools)
foreach (var tool in beforeList)
{ {
if (!tool.IsDisposed if (!tool.IsDisposed
|| (tool is RamWatch && _config.DisplayRamWatch)) // RAM Watch hack, on screen display should run even if RAM Watch is closed || (tool is RamWatch && _config.DisplayRamWatch)) // RAM Watch hack, on screen display should run even if RAM Watch is closed
{ {
tool.UpdateValues(); tool.UpdateValues(ToolFormUpdateType.PreFrame);
}
}
foreach (var tool in _tools)
{
if (!tool.IsDisposed)
{
tool.NewUpdate(ToolFormUpdateType.PreFrame);
} }
} }
} }
private void UpdateAfter() private void UpdateAfter()
{ {
var afterList = _tools.Where(t => !t.UpdateBefore); foreach (var tool in _tools)
foreach (var tool in afterList)
{ {
if (!tool.IsDisposed if (!tool.IsDisposed
|| (tool is RamWatch && _config.DisplayRamWatch)) // RAM Watch hack, on screen display should run even if RAM Watch is closed || (tool is RamWatch && _config.DisplayRamWatch)) // RAM Watch hack, on screen display should run even if RAM Watch is closed
{ {
tool.UpdateValues(); tool.UpdateValues(ToolFormUpdateType.PostFrame);
}
}
foreach (var tool in _tools)
{
if (!tool.IsDisposed)
{
tool.NewUpdate(ToolFormUpdateType.PostFrame);
} }
} }
} }
@ -516,7 +498,7 @@ namespace BizHawk.Client.EmuHawk
if (!tool.IsDisposed || if (!tool.IsDisposed ||
(tool is RamWatch && _config.DisplayRamWatch)) // RAM Watch hack, on screen display should run even if RAM Watch is closed (tool is RamWatch && _config.DisplayRamWatch)) // RAM Watch hack, on screen display should run even if RAM Watch is closed
{ {
tool.UpdateValues(); tool.UpdateValues(ToolFormUpdateType.General);
} }
} }
} }
@ -585,22 +567,6 @@ namespace BizHawk.Client.EmuHawk
.All(result => result); .All(result => result);
} }
/// <summary>
/// Calls AskSave() on an instance of T, if it exists, else returns true
/// The caller should interpret false as cancel and will back out of the action that invokes this call
/// </summary>
/// <typeparam name="T">Type of tool</typeparam>
public bool AskSave<T>() where T : IToolForm
{
if (_config.SuppressAskSave) // User has elected to not be nagged
{
return true;
}
var tool = _tools.FirstOrDefault(t => t is T);
return tool != null && tool.AskSaveChanges();
}
/// <summary> /// <summary>
/// If T exists, this call will close the tool, and remove it from memory /// If T exists, this call will close the tool, and remove it from memory
/// </summary> /// </summary>
@ -732,13 +698,12 @@ namespace BizHawk.Client.EmuHawk
public void FastUpdateBefore() public void FastUpdateBefore()
{ {
var beforeList = _tools.Where(t => t.UpdateBefore); foreach (var tool in _tools)
foreach (var tool in beforeList)
{ {
if (!tool.IsDisposed if (!tool.IsDisposed
|| (tool is RamWatch && _config.DisplayRamWatch)) // RAM Watch hack, on screen display should run even if RAM Watch is closed || (tool is RamWatch && _config.DisplayRamWatch)) // RAM Watch hack, on screen display should run even if RAM Watch is closed
{ {
tool.FastUpdate(); tool.UpdateValues(ToolFormUpdateType.FastPreFrame);
} }
} }
} }
@ -750,13 +715,12 @@ namespace BizHawk.Client.EmuHawk
LuaConsole.ResumeScripts(true); LuaConsole.ResumeScripts(true);
} }
var afterList = _tools.Where(t => !t.UpdateBefore); foreach (var tool in _tools)
foreach (var tool in afterList)
{ {
if (!tool.IsDisposed if (!tool.IsDisposed
|| (tool is RamWatch && _config.DisplayRamWatch)) // RAM Watch hack, on screen display should run even if RAM Watch is closed || (tool is RamWatch && _config.DisplayRamWatch)) // RAM Watch hack, on screen display should run even if RAM Watch is closed
{ {
tool.FastUpdate(); tool.UpdateValues(ToolFormUpdateType.FastPostFrame);
} }
} }
@ -817,8 +781,6 @@ namespace BizHawk.Client.EmuHawk
public RamSearch RamSearch => GetTool<RamSearch>(); public RamSearch RamSearch => GetTool<RamSearch>();
public Cheats Cheats => GetTool<Cheats>();
public HexEditor HexEditor => GetTool<HexEditor>(); public HexEditor HexEditor => GetTool<HexEditor>();
public VirtualpadTool VirtualPad => GetTool<VirtualpadTool>(); public VirtualpadTool VirtualPad => GetTool<VirtualpadTool>();
@ -889,11 +851,7 @@ namespace BizHawk.Client.EmuHawk
UpdateValues<RamWatch>(); UpdateValues<RamWatch>();
UpdateValues<RamSearch>(); UpdateValues<RamSearch>();
UpdateValues<HexEditor>(); UpdateValues<HexEditor>();
UpdateValues<Cheats>();
if (Has<Cheats>())
{
Cheats.UpdateDialog();
}
_owner.UpdateCheatStatus(); _owner.UpdateCheatStatus();
} }

View File

@ -93,8 +93,6 @@ namespace BizHawk.Client.EmuHawk
}); });
} }
public bool UpdateBefore => false;
private void SaveConfigSettings() private void SaveConfigSettings()
{ {
//Tracer.Enabled = LoggingEnabled.Checked; //Tracer.Enabled = LoggingEnabled.Checked;
@ -133,9 +131,7 @@ namespace BizHawk.Client.EmuHawk
public Action<TraceInfo> Putter { get; set; } public Action<TraceInfo> Putter { get; set; }
} }
public void UpdateValues() { } public override void UpdateValues(ToolFormUpdateType type)
public void NewUpdate(ToolFormUpdateType type)
{ {
if (type == ToolFormUpdateType.PostFrame) if (type == ToolFormUpdateType.PostFrame)
{ {
@ -192,10 +188,6 @@ namespace BizHawk.Client.EmuHawk
} }
} }
public void FastUpdate()
{
}
public void Restart() public void Restart()
{ {
CloseFile(); CloseFile();

View File

@ -127,10 +127,6 @@ namespace BizHawk.Client.EmuHawk
} }
} }
#region IToolForm Implementation
public bool UpdateBefore => false;
public void Restart() public void Restart()
{ {
if (!IsHandleCreated || IsDisposed) if (!IsHandleCreated || IsDisposed)
@ -141,9 +137,7 @@ namespace BizHawk.Client.EmuHawk
CreatePads(); CreatePads();
} }
public void NewUpdate(ToolFormUpdateType type) { } protected override void UpdateAfter()
public void UpdateValues()
{ {
if (!IsHandleCreated || IsDisposed) if (!IsHandleCreated || IsDisposed)
{ {
@ -178,7 +172,7 @@ namespace BizHawk.Client.EmuHawk
Pads.ForEach(pad => pad.UpdateValues()); Pads.ForEach(pad => pad.UpdateValues());
} }
public void FastUpdate() protected override void FastUpdateAfter()
{ {
// TODO: SetPrevious logic should go here too or that will get out of whack // TODO: SetPrevious logic should go here too or that will get out of whack
@ -188,8 +182,6 @@ namespace BizHawk.Client.EmuHawk
} }
} }
#endregion
#region Menu #region Menu
private void PadsSubMenu_DropDownOpened(object sender, EventArgs e) private void PadsSubMenu_DropDownOpened(object sender, EventArgs e)

View File

@ -93,7 +93,7 @@ namespace BizHawk.Client.EmuHawk
{ {
var success = _watchList.All(watch => watch.Poke(ValueBox.Text)); var success = _watchList.All(watch => watch.Poke(ValueBox.Text));
ParentTool?.UpdateValues(); ParentTool?.UpdateValues(ToolFormUpdateType.General);
if (success) if (success)
{ {

View File

@ -71,8 +71,6 @@ namespace BizHawk.Client.EmuHawk
[ConfigPersist] [ConfigPersist]
public RamSearchSettings Settings { get; set; } public RamSearchSettings Settings { get; set; }
public bool UpdateBefore => false;
private void HardSetDisplayTypeDropDown(Common.DisplayType type) private void HardSetDisplayTypeDropDown(Common.DisplayType type)
{ {
foreach (var item in DisplayTypeDropdown.Items) foreach (var item in DisplayTypeDropdown.Items)
@ -248,14 +246,21 @@ namespace BizHawk.Client.EmuHawk
SetTotal(); SetTotal();
} }
public void NewUpdate(ToolFormUpdateType type) public override void UpdateValues(ToolFormUpdateType type)
{ {
switch (type)
{
case ToolFormUpdateType.PostFrame:
case ToolFormUpdateType.General:
FrameUpdate();
break;
case ToolFormUpdateType.FastPostFrame:
MinimalUpdate();
break;
}
} }
/// <summary> private void FrameUpdate()
/// This should only be called when the values of the list need an update such as after a poke or emulation occurred
/// </summary>
public void UpdateValues()
{ {
if (_searches.Count > 0) if (_searches.Count > 0)
{ {
@ -278,7 +283,7 @@ namespace BizHawk.Client.EmuHawk
} }
} }
public void FastUpdate() private void MinimalUpdate()
{ {
if (_searches.Count > 0) if (_searches.Count > 0)
{ {

View File

@ -99,15 +99,13 @@ namespace BizHawk.Client.EmuHawk
public IEnumerable<Watch> Watches => _watches.Where(x => !x.IsSeparator); public IEnumerable<Watch> Watches => _watches.Where(x => !x.IsSeparator);
public bool UpdateBefore => false;
#region API #region API
public void AddWatch(Watch watch) public void AddWatch(Watch watch)
{ {
_watches.Add(watch); _watches.Add(watch);
WatchListView.RowCount = _watches.Count; WatchListView.RowCount = _watches.Count;
UpdateValues(); GeneralUpdate();
UpdateWatchCount(); UpdateWatchCount();
Changes(); Changes();
} }
@ -165,7 +163,7 @@ namespace BizHawk.Client.EmuHawk
Config.RecentWatches.Add(path); Config.RecentWatches.Add(path);
WatchListView.RowCount = _watches.Count; WatchListView.RowCount = _watches.Count;
UpdateWatchCount(); UpdateWatchCount();
UpdateValues(); GeneralUpdate();
UpdateStatusBar(); UpdateStatusBar();
_watches.Changes = false; _watches.Changes = false;
} }
@ -189,7 +187,7 @@ namespace BizHawk.Client.EmuHawk
UpdateWatchCount(); UpdateWatchCount();
Config.RecentWatches.Add(_watches.CurrentFileName); Config.RecentWatches.Add(_watches.CurrentFileName);
UpdateStatusBar(); UpdateStatusBar();
UpdateValues(); GeneralUpdate();
PokeAddressToolBarItem.Enabled = PokeAddressToolBarItem.Enabled =
FreezeAddressToolBarItem.Enabled = FreezeAddressToolBarItem.Enabled =
SelectedIndices.Any() SelectedIndices.Any()
@ -212,7 +210,7 @@ namespace BizHawk.Client.EmuHawk
{ {
_watches.RefreshDomains(MemoryDomains); _watches.RefreshDomains(MemoryDomains);
_watches.Reload(); _watches.Reload();
UpdateValues(); GeneralUpdate();
UpdateStatusBar(); UpdateStatusBar();
} }
else else
@ -222,8 +220,58 @@ namespace BizHawk.Client.EmuHawk
} }
} }
public void NewUpdate(ToolFormUpdateType type) public override void UpdateValues(ToolFormUpdateType type)
{ {
switch (type)
{
case ToolFormUpdateType.PostFrame:
case ToolFormUpdateType.General:
FrameUpdate();
break;
case ToolFormUpdateType.FastPostFrame:
MinimalUpdate();
break;
}
}
#endregion
#region Private Methods
private void MinimalUpdate()
{
if ((!IsHandleCreated || IsDisposed) && !Config.DisplayRamWatch)
{
return;
}
if (_watches.Any())
{
_watches.UpdateValues();
DisplayOnScreenWatches();
}
}
private void FrameUpdate()
{
if ((!IsHandleCreated || IsDisposed) && !Config.DisplayRamWatch)
{
return;
}
GlobalWin.OSD.ClearRamWatches();
if (_watches.Any())
{
_watches.UpdateValues();
DisplayOnScreenWatches();
if (!IsHandleCreated || IsDisposed)
{
return;
}
WatchListView.RowCount = _watches.Count;
}
} }
private void DisplayOnScreenWatches() private void DisplayOnScreenWatches()
@ -247,46 +295,6 @@ namespace BizHawk.Client.EmuHawk
} }
} }
public void UpdateValues()
{
if ((!IsHandleCreated || IsDisposed) && !Config.DisplayRamWatch)
{
return;
}
GlobalWin.OSD.ClearRamWatches();
if (_watches.Any())
{
_watches.UpdateValues();
DisplayOnScreenWatches();
if (!IsHandleCreated || IsDisposed)
{
return;
}
WatchListView.RowCount = _watches.Count;
}
}
public void FastUpdate()
{
if ((!IsHandleCreated || IsDisposed) && !Config.DisplayRamWatch)
{
return;
}
if (_watches.Any())
{
_watches.UpdateValues();
DisplayOnScreenWatches();
}
}
#endregion
#region Private Methods
private void Changes() private void Changes()
{ {
_watches.Changes = true; _watches.Changes = true;
@ -336,7 +344,7 @@ namespace BizHawk.Client.EmuHawk
WatchListView.RowCount = _watches.Count; WatchListView.RowCount = _watches.Count;
UpdateWatchCount(); UpdateWatchCount();
UpdateStatusBar(); UpdateStatusBar();
UpdateValues(); GeneralUpdate();
} }
private void EditWatch(bool duplicate = false) private void EditWatch(bool duplicate = false)
@ -380,7 +388,7 @@ namespace BizHawk.Client.EmuHawk
} }
} }
UpdateValues(); GeneralUpdate();
} }
else if (SelectedSeparators.Any() && !duplicate) else if (SelectedSeparators.Any() && !duplicate)
{ {
@ -406,7 +414,7 @@ namespace BizHawk.Client.EmuHawk
} }
} }
UpdateValues(); GeneralUpdate();
} }
} }
@ -476,7 +484,7 @@ namespace BizHawk.Client.EmuHawk
{ {
_watches.Clear(); _watches.Clear();
WatchListView.RowCount = _watches.Count; WatchListView.RowCount = _watches.Count;
UpdateValues(); GeneralUpdate();
UpdateWatchCount(); UpdateWatchCount();
UpdateStatusBar(); UpdateStatusBar();
_sortReverse = false; _sortReverse = false;
@ -735,7 +743,7 @@ namespace BizHawk.Client.EmuHawk
Changes(); Changes();
UpdateWatchCount(); UpdateWatchCount();
WatchListView.RowCount = _watches.Count; WatchListView.RowCount = _watches.Count;
UpdateValues(); GeneralUpdate();
} }
} }
@ -755,7 +763,7 @@ namespace BizHawk.Client.EmuHawk
} }
WatchListView.RowCount = _watches.Count; WatchListView.RowCount = _watches.Count;
UpdateValues(); GeneralUpdate();
UpdateWatchCount(); UpdateWatchCount();
} }
} }
@ -778,7 +786,7 @@ namespace BizHawk.Client.EmuHawk
if (poke.ShowHawkDialog(this) == DialogResult.OK) if (poke.ShowHawkDialog(this) == DialogResult.OK)
{ {
UpdateValues(); GeneralUpdate();
} }
} }
} }
@ -816,7 +824,7 @@ namespace BizHawk.Client.EmuHawk
private void ClearChangeCountsMenuItem_Click(object sender, EventArgs e) private void ClearChangeCountsMenuItem_Click(object sender, EventArgs e)
{ {
_watches.ClearChangeCounts(); _watches.ClearChangeCounts();
UpdateValues(); GeneralUpdate();
} }
private void MoveUpMenuItem_Click(object sender, EventArgs e) private void MoveUpMenuItem_Click(object sender, EventArgs e)
@ -981,7 +989,7 @@ namespace BizHawk.Client.EmuHawk
} }
else else
{ {
UpdateValues(); GeneralUpdate();
} }
} }
@ -1057,7 +1065,7 @@ namespace BizHawk.Client.EmuHawk
_watches.Load(filePaths[0], append: false); _watches.Load(filePaths[0], append: false);
Config.RecentWatches.Add(_watches.CurrentFileName); Config.RecentWatches.Add(_watches.CurrentFileName);
WatchListView.RowCount = _watches.Count; WatchListView.RowCount = _watches.Count;
UpdateValues(); GeneralUpdate();
} }
} }
@ -1217,7 +1225,7 @@ namespace BizHawk.Client.EmuHawk
} }
WatchListView.RowCount = _watches.Count; WatchListView.RowCount = _watches.Count;
UpdateValues(); GeneralUpdate();
UpdateWatchCount(); UpdateWatchCount();
UpdateStatusBar(); UpdateStatusBar();
} }