2019-06-15 19:31:06 +00:00
|
|
|
|
using System;
|
2019-06-15 21:06:35 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
2019-06-15 19:31:06 +00:00
|
|
|
|
|
|
|
|
|
namespace BizHawk.Client.Common
|
|
|
|
|
{
|
2019-06-15 20:19:18 +00:00
|
|
|
|
public interface IStateManager
|
2019-06-15 19:31:06 +00:00
|
|
|
|
{
|
2019-06-15 21:13:16 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Retrieves the savestate for the given frame,
|
|
|
|
|
/// If this frame does not have a state currently, will return an empty array
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>A savestate for the given frame or an empty array if there isn't one</returns>
|
2019-06-15 21:43:21 +00:00
|
|
|
|
byte[] this[int frame] { get; }
|
2019-06-15 19:31:06 +00:00
|
|
|
|
|
|
|
|
|
TasStateManagerSettings Settings { get; set; }
|
|
|
|
|
|
|
|
|
|
Action<int> InvalidateCallback { set; }
|
|
|
|
|
|
2019-06-15 21:13:16 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Requests that the current emulator state be captured
|
|
|
|
|
/// Unless force is true, the state may or may not be captured depending on the logic employed by "green-zone" management
|
|
|
|
|
/// </summary>
|
2019-06-15 19:31:06 +00:00
|
|
|
|
void Capture(bool force = false);
|
|
|
|
|
|
|
|
|
|
bool HasState(int frame);
|
|
|
|
|
|
2019-06-15 21:13:16 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Clears out all savestates after the given frame number
|
|
|
|
|
/// </summary>
|
2019-06-15 19:31:06 +00:00
|
|
|
|
bool Invalidate(int frame);
|
|
|
|
|
|
2019-06-15 20:19:18 +00:00
|
|
|
|
void Clear();
|
2019-06-15 19:31:06 +00:00
|
|
|
|
|
|
|
|
|
void Save(BinaryWriter bw);
|
|
|
|
|
|
|
|
|
|
void Load(BinaryReader br);
|
|
|
|
|
|
|
|
|
|
KeyValuePair<int, byte[]> GetStateClosestToFrame(int frame);
|
|
|
|
|
|
|
|
|
|
bool Any();
|
|
|
|
|
|
2019-06-15 19:49:43 +00:00
|
|
|
|
int Count { get; }
|
|
|
|
|
|
2019-06-15 20:19:18 +00:00
|
|
|
|
int Last { get; }
|
2019-06-15 19:31:06 +00:00
|
|
|
|
|
2019-06-15 20:44:34 +00:00
|
|
|
|
void UpdateStateFrequency();
|
|
|
|
|
|
2019-06-15 21:13:16 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns index of the state right above the given frame
|
|
|
|
|
/// </summary>
|
2019-06-15 20:43:22 +00:00
|
|
|
|
int GetStateIndexByFrame(int frame);
|
2019-06-15 19:31:06 +00:00
|
|
|
|
|
2019-06-15 21:13:16 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns frame of the state at the given index
|
|
|
|
|
/// </summary>
|
2019-06-15 20:43:22 +00:00
|
|
|
|
int GetStateFrameByIndex(int index);
|
2019-06-15 19:31:06 +00:00
|
|
|
|
|
2019-06-15 21:17:49 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Directly remove a state from the given frame, if it exists
|
|
|
|
|
/// Should only be called by pruning operations
|
|
|
|
|
/// </summary>
|
2019-06-15 20:44:34 +00:00
|
|
|
|
bool Remove(int frame);
|
2019-06-15 19:31:06 +00:00
|
|
|
|
}
|
|
|
|
|
}
|