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
{
// reserved
Legacy, LegacyFast,
// reserved concept: we can run other events through here (should probably rename then)
Reset,
/// <summary>
/// Called by other tools and other events outside of a frame loop
/// </summary>
General,
/// <summary>
/// Called before a frame emulates
/// </summary>
PreFrame,
FastPreFrame,
/// <summary>
/// Called after a frame emulates
/// </summary>
PostFrame
PostFrame,
FastPostFrame
}
public interface IToolForm
{
/// <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>
void UpdateValues();
/// <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();
void UpdateValues(ToolFormUpdateType type);
/// <summary>
/// Will be called anytime the dialog needs to be restarted, such as when a new ROM is loaded
@ -51,14 +40,6 @@
/// </summary>
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
bool Focus();
bool ContainsFocus { get; }

View File

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

View File

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

View File

@ -7,7 +7,7 @@ using BizHawk.Emulation.Common;
namespace BizHawk.Client.EmuHawk
{
public partial class NESSoundConfig : Form, IToolForm
public partial class NESSoundConfig : ToolFormBase, IToolForm
{
[RequiredService]
private NES NES { get; set; }
@ -15,19 +15,6 @@ namespace BizHawk.Client.EmuHawk
private NES.NESSettings _oldSettings;
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()
{
NESSoundConfig_Load(null, null);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -437,7 +437,7 @@ namespace BizHawk.Client.EmuHawk
if (marker != null)
{
Tastudio.CurrentTasMovie.Markers.Remove(marker);
Tastudio.UpdateValues();
Tastudio.RefreshDialog();
}
}
}
@ -456,7 +456,7 @@ namespace BizHawk.Client.EmuHawk
else
{
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 bool UpdateBefore => true;
private IEnumerable<LuaFile> SelectedItems => LuaListView.SelectedRows.Select(index => LuaImp.ScriptList[index]);
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)
{
// Hack for previous config settings

View File

@ -87,21 +87,6 @@ namespace BizHawk.Client.EmuHawk
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()
{
if (_unsavedZones.Count == 0 || IsDisposed)

View File

@ -187,7 +187,7 @@ namespace BizHawk.Client.EmuHawk
}
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 bool UpdateBefore => true;
#endregion
private void CancelBtn_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -38,9 +38,7 @@ namespace BizHawk.Client.EmuHawk
base.OnShown(e);
}
public void NewUpdate(ToolFormUpdateType type) { }
public void UpdateValues()
protected override void UpdateAfter()
{
foreach (var entry in _psgEntries)
{
@ -147,11 +145,6 @@ namespace BizHawk.Client.EmuHawk
lvChannels.EndUpdate();
}
public void FastUpdate()
{
// Todo
}
private class PsgEntry
{
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)
private static readonly byte[] EmptyWav = {
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);
}
#region IToolForm
public void NewUpdate(ToolFormUpdateType type) { }
public void UpdateValues()
protected override void UpdateBefore()
{
DrawBacks();
DrawSprites();
@ -45,11 +41,6 @@ namespace BizHawk.Client.EmuHawk
bmpViewSPPal.Refresh();
}
public void FastUpdate()
{
// Do nothing
}
static unsafe void Draw16x16(byte* src, int* dest, int pitch, int* pal)
{
int inc = pitch - 16;
@ -164,14 +155,10 @@ namespace BizHawk.Client.EmuHawk
CheckBoxVDC2_CheckedChanged(null, null);
}
public bool UpdateBefore => true;
#endregion
private void CheckBoxVDC2_CheckedChanged(object sender, EventArgs e)
{
_vdc = checkBoxVDC2.Checked ? Emu.VDC2 : Emu.VDC1;
UpdateValues();
GeneralUpdate();
}
private void BmpViewBGPal_MouseClick(object sender, MouseEventArgs e)

View File

@ -135,9 +135,7 @@ namespace BizHawk.Client.EmuHawk
bmpViewPalette.Refresh();
}
public void NewUpdate(ToolFormUpdateType type) { }
public void UpdateValues()
protected override void UpdateBefore()
{
unsafe
{
@ -150,18 +148,11 @@ namespace BizHawk.Client.EmuHawk
}
}
public void FastUpdate()
{
// Do nothing
}
public void Restart()
{
UpdateValues();
GeneralUpdate();
}
public bool UpdateBefore => true;
private void bmpViewPalette_MouseClick(object sender, MouseEventArgs e)
{
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>();
public bool UpdateBefore => false;
[RequiredService]
private LibsnesCore Emulator { get; set; }
@ -130,9 +128,7 @@ namespace BizHawk.Client.EmuHawk
: $"@{address:X4} ({address / 1024}K)";
}
public void NewUpdate(ToolFormUpdateType type) { }
public void UpdateValues()
protected override void UpdateAfter()
{
SyncCore();
if (Visible && !checkScanlineControl.Checked)
@ -142,11 +138,6 @@ namespace BizHawk.Client.EmuHawk
}
}
public void FastUpdate()
{
// To do
}
public void UpdateToolsLoadstate()
{
SyncCore();

View File

@ -22,13 +22,14 @@ namespace BizHawk.Client.EmuHawk
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
public bool UpdateBefore => false;
public void NewUpdate(ToolFormUpdateType type) { }
private int _lastRefresh;
public void UpdateValues()
protected override void GeneralUpdate()
{
RefreshDialog();
}
protected override void UpdateAfter()
{
if (!IsHandleCreated || IsDisposed || CurrentTasMovie == null)
{
@ -62,11 +63,6 @@ namespace BizHawk.Client.EmuHawk
RefreshDialog(refreshNeeded, refreshBranches: false);
}
public void FastUpdate()
{
// Do nothing
}
public void Restart()
{
if (!IsHandleCreated || IsDisposed)

View File

@ -33,29 +33,11 @@ namespace BizHawk.Client.EmuHawk
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()
{
// Do nothing
}
#endregion
private void SetToolTips()
{
// 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()
{
SetTools();

View File

@ -18,6 +18,34 @@ namespace BizHawk.Client.EmuHawk
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)
{
if (!Directory.Exists(path))

View File

@ -464,42 +464,24 @@ namespace BizHawk.Client.EmuHawk
private void UpdateBefore()
{
var beforeList = _tools.Where(t => t.UpdateBefore);
foreach (var tool in beforeList)
foreach (var tool in _tools)
{
if (!tool.IsDisposed
|| (tool is RamWatch && _config.DisplayRamWatch)) // RAM Watch hack, on screen display should run even if RAM Watch is closed
{
tool.UpdateValues();
}
}
foreach (var tool in _tools)
{
if (!tool.IsDisposed)
{
tool.NewUpdate(ToolFormUpdateType.PreFrame);
tool.UpdateValues(ToolFormUpdateType.PreFrame);
}
}
}
private void UpdateAfter()
{
var afterList = _tools.Where(t => !t.UpdateBefore);
foreach (var tool in afterList)
foreach (var tool in _tools)
{
if (!tool.IsDisposed
|| (tool is RamWatch && _config.DisplayRamWatch)) // RAM Watch hack, on screen display should run even if RAM Watch is closed
{
tool.UpdateValues();
}
}
foreach (var tool in _tools)
{
if (!tool.IsDisposed)
{
tool.NewUpdate(ToolFormUpdateType.PostFrame);
tool.UpdateValues(ToolFormUpdateType.PostFrame);
}
}
}
@ -516,7 +498,7 @@ namespace BizHawk.Client.EmuHawk
if (!tool.IsDisposed ||
(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);
}
/// <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>
/// If T exists, this call will close the tool, and remove it from memory
/// </summary>
@ -732,13 +698,12 @@ namespace BizHawk.Client.EmuHawk
public void FastUpdateBefore()
{
var beforeList = _tools.Where(t => t.UpdateBefore);
foreach (var tool in beforeList)
foreach (var tool in _tools)
{
if (!tool.IsDisposed
|| (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);
}
var afterList = _tools.Where(t => !t.UpdateBefore);
foreach (var tool in afterList)
foreach (var tool in _tools)
{
if (!tool.IsDisposed
|| (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 Cheats Cheats => GetTool<Cheats>();
public HexEditor HexEditor => GetTool<HexEditor>();
public VirtualpadTool VirtualPad => GetTool<VirtualpadTool>();
@ -889,11 +851,7 @@ namespace BizHawk.Client.EmuHawk
UpdateValues<RamWatch>();
UpdateValues<RamSearch>();
UpdateValues<HexEditor>();
if (Has<Cheats>())
{
Cheats.UpdateDialog();
}
UpdateValues<Cheats>();
_owner.UpdateCheatStatus();
}

View File

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

View File

@ -127,10 +127,6 @@ namespace BizHawk.Client.EmuHawk
}
}
#region IToolForm Implementation
public bool UpdateBefore => false;
public void Restart()
{
if (!IsHandleCreated || IsDisposed)
@ -141,9 +137,7 @@ namespace BizHawk.Client.EmuHawk
CreatePads();
}
public void NewUpdate(ToolFormUpdateType type) { }
public void UpdateValues()
protected override void UpdateAfter()
{
if (!IsHandleCreated || IsDisposed)
{
@ -178,7 +172,7 @@ namespace BizHawk.Client.EmuHawk
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
@ -188,8 +182,6 @@ namespace BizHawk.Client.EmuHawk
}
}
#endregion
#region Menu
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));
ParentTool?.UpdateValues();
ParentTool?.UpdateValues(ToolFormUpdateType.General);
if (success)
{

View File

@ -71,8 +71,6 @@ namespace BizHawk.Client.EmuHawk
[ConfigPersist]
public RamSearchSettings Settings { get; set; }
public bool UpdateBefore => false;
private void HardSetDisplayTypeDropDown(Common.DisplayType type)
{
foreach (var item in DisplayTypeDropdown.Items)
@ -248,14 +246,21 @@ namespace BizHawk.Client.EmuHawk
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>
/// 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()
private void FrameUpdate()
{
if (_searches.Count > 0)
{
@ -278,7 +283,7 @@ namespace BizHawk.Client.EmuHawk
}
}
public void FastUpdate()
private void MinimalUpdate()
{
if (_searches.Count > 0)
{

View File

@ -99,15 +99,13 @@ namespace BizHawk.Client.EmuHawk
public IEnumerable<Watch> Watches => _watches.Where(x => !x.IsSeparator);
public bool UpdateBefore => false;
#region API
public void AddWatch(Watch watch)
{
_watches.Add(watch);
WatchListView.RowCount = _watches.Count;
UpdateValues();
GeneralUpdate();
UpdateWatchCount();
Changes();
}
@ -165,7 +163,7 @@ namespace BizHawk.Client.EmuHawk
Config.RecentWatches.Add(path);
WatchListView.RowCount = _watches.Count;
UpdateWatchCount();
UpdateValues();
GeneralUpdate();
UpdateStatusBar();
_watches.Changes = false;
}
@ -189,7 +187,7 @@ namespace BizHawk.Client.EmuHawk
UpdateWatchCount();
Config.RecentWatches.Add(_watches.CurrentFileName);
UpdateStatusBar();
UpdateValues();
GeneralUpdate();
PokeAddressToolBarItem.Enabled =
FreezeAddressToolBarItem.Enabled =
SelectedIndices.Any()
@ -212,7 +210,7 @@ namespace BizHawk.Client.EmuHawk
{
_watches.RefreshDomains(MemoryDomains);
_watches.Reload();
UpdateValues();
GeneralUpdate();
UpdateStatusBar();
}
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()
@ -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()
{
_watches.Changes = true;
@ -336,7 +344,7 @@ namespace BizHawk.Client.EmuHawk
WatchListView.RowCount = _watches.Count;
UpdateWatchCount();
UpdateStatusBar();
UpdateValues();
GeneralUpdate();
}
private void EditWatch(bool duplicate = false)
@ -380,7 +388,7 @@ namespace BizHawk.Client.EmuHawk
}
}
UpdateValues();
GeneralUpdate();
}
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();
WatchListView.RowCount = _watches.Count;
UpdateValues();
GeneralUpdate();
UpdateWatchCount();
UpdateStatusBar();
_sortReverse = false;
@ -735,7 +743,7 @@ namespace BizHawk.Client.EmuHawk
Changes();
UpdateWatchCount();
WatchListView.RowCount = _watches.Count;
UpdateValues();
GeneralUpdate();
}
}
@ -755,7 +763,7 @@ namespace BizHawk.Client.EmuHawk
}
WatchListView.RowCount = _watches.Count;
UpdateValues();
GeneralUpdate();
UpdateWatchCount();
}
}
@ -778,7 +786,7 @@ namespace BizHawk.Client.EmuHawk
if (poke.ShowHawkDialog(this) == DialogResult.OK)
{
UpdateValues();
GeneralUpdate();
}
}
}
@ -816,7 +824,7 @@ namespace BizHawk.Client.EmuHawk
private void ClearChangeCountsMenuItem_Click(object sender, EventArgs e)
{
_watches.ClearChangeCounts();
UpdateValues();
GeneralUpdate();
}
private void MoveUpMenuItem_Click(object sender, EventArgs e)
@ -981,7 +989,7 @@ namespace BizHawk.Client.EmuHawk
}
else
{
UpdateValues();
GeneralUpdate();
}
}
@ -1057,7 +1065,7 @@ namespace BizHawk.Client.EmuHawk
_watches.Load(filePaths[0], append: false);
Config.RecentWatches.Add(_watches.CurrentFileName);
WatchListView.RowCount = _watches.Count;
UpdateValues();
GeneralUpdate();
}
}
@ -1217,7 +1225,7 @@ namespace BizHawk.Client.EmuHawk
}
WatchListView.RowCount = _watches.Count;
UpdateValues();
GeneralUpdate();
UpdateWatchCount();
UpdateStatusBar();
}