Rewind Config - don't crash on load when rewind is off for the core currently loaded

This commit is contained in:
adelikat 2013-08-24 21:40:42 +00:00
parent 6193be13e9
commit cec62d38f5
2 changed files with 48 additions and 29 deletions

View File

@ -8,7 +8,7 @@ namespace BizHawk.MultiClient
{ {
public partial class MainForm public partial class MainForm
{ {
private StreamBlobDatabase RewindBuf;// = new StreamBlobDatabase(Global.Config.Rewind_OnDisk, Global.Config.Rewind_BufferSize * (long)1024 * (long)1024); public StreamBlobDatabase RewindBuf;// = new StreamBlobDatabase(Global.Config.Rewind_OnDisk, Global.Config.Rewind_BufferSize * (long)1024 * (long)1024);
private RewindThreader RewindThread; private RewindThreader RewindThread;
private byte[] LastState; private byte[] LastState;
@ -17,13 +17,13 @@ namespace BizHawk.MultiClient
private bool RewindDeltaEnable = false; private bool RewindDeltaEnable = false;
public float Rewind_FullnessRatio { get { return RewindBuf.FullnessRatio; } } public float Rewind_FullnessRatio { get { return RewindBuf.FullnessRatio; } }
public int Rewind_Count { get { return RewindBuf.Count; } } public int Rewind_Count { get { return RewindBuf != null ? RewindBuf.Count : 0; } }
public long Rewind_Size { get { return RewindBuf.Size; } } public long Rewind_Size { get { return RewindBuf != null ? RewindBuf.Size : 0; } }
/// <summary> /// <summary>
/// Manages a ring buffer of storage which can continually chow its own tail to keep growing forward. /// Manages a ring buffer of storage which can continually chow its own tail to keep growing forward.
/// Probably only useful for the rewind buffer, so I didnt put it in another file /// Probably only useful for the rewind buffer, so I didnt put it in another file
/// </summary> /// </summary>
class StreamBlobDatabase : IDisposable public class StreamBlobDatabase : IDisposable
{ {
public void Dispose() public void Dispose()
{ {

View File

@ -16,12 +16,23 @@ namespace BizHawk.MultiClient
} }
private void RewindConfig_Load(object sender, EventArgs e) private void RewindConfig_Load(object sender, EventArgs e)
{
if (Global.MainForm.RewindBuf != null)
{ {
FullnessLabel.Text = String.Format("{0:0.00}", Global.MainForm.Rewind_FullnessRatio * 100) + "%"; FullnessLabel.Text = String.Format("{0:0.00}", Global.MainForm.Rewind_FullnessRatio * 100) + "%";
RewindFramesUsedLabel.Text = Global.MainForm.Rewind_Count.ToString(); RewindFramesUsedLabel.Text = Global.MainForm.Rewind_Count.ToString();
StateSize = Global.Emulator.SaveStateBinary().Length; }
RewindIsThreadedCheckbox.Checked = Global.Config.Rewind_IsThreaded; else
{
FullnessLabel.Text = "N/A";
RewindFramesUsedLabel.Text = "N/A";
}
try
{
DiskBufferCheckbox.Checked = Global.Config.Rewind_OnDisk; DiskBufferCheckbox.Checked = Global.Config.Rewind_OnDisk;
RewindIsThreadedCheckbox.Checked = Global.Config.Rewind_IsThreaded;
StateSize = Global.Emulator.SaveStateBinary().Length;
BufferSizeUpDown.Value = Global.Config.Rewind_BufferSize; BufferSizeUpDown.Value = Global.Config.Rewind_BufferSize;
MediumStateSize = Global.Config.Rewind_MediumStateSize; MediumStateSize = Global.Config.Rewind_MediumStateSize;
@ -51,6 +62,14 @@ namespace BizHawk.MultiClient
LargeStateTrackbar.Value = large_state_size_kb; LargeStateTrackbar.Value = large_state_size_kb;
LargeStateUpDown.Value = (decimal)large_state_size_kb; LargeStateUpDown.Value = (decimal)large_state_size_kb;
} }
catch (Exception ex)
{
int x = 0;
x++;
int y = x;
y++;
}
}
private void SetStateSize() private void SetStateSize()
{ {