2013-12-05 00:44:56 +00:00
using System ;
2013-12-01 01:55:41 +00:00
using System.IO ;
2013-11-23 17:26:33 +00:00
2013-12-07 16:31:04 +00:00
using BizHawk.Emulation.Common ;
2013-11-23 17:26:33 +00:00
namespace BizHawk.Client.Common
{
2013-11-29 19:55:05 +00:00
// TODO: message callback / event handler
// TODO: consider other event handlers, switching modes?
2013-11-23 17:26:33 +00:00
public interface IMovie
{
2013-11-29 19:55:05 +00:00
#region Status
2013-11-23 17:26:33 +00:00
bool IsCountingRerecords { get ; set ; }
bool IsActive { get ; }
bool IsPlaying { get ; }
bool IsRecording { get ; }
bool IsFinished { get ; }
2013-11-23 18:18:58 +00:00
bool Changes { get ; }
2013-11-29 19:55:05 +00:00
2013-11-30 02:50:54 +00:00
#endregion
#region Properties
2013-12-04 15:17:02 +00:00
/// <summary>
2013-12-05 00:44:56 +00:00
/// Gets the total number of frames that count towards the completion time of the movie
2013-12-04 15:17:02 +00:00
/// Possibly (but unlikely different from InputLogLength (could be infinity, or maybe an implementation automatically discounts empty frames at the end of a movie, etc)
/// </summary>
2013-11-30 03:10:05 +00:00
double FrameCount { get ; }
2013-12-04 15:17:02 +00:00
/// <summary>
2013-12-05 00:44:56 +00:00
/// Gets the Fps used to calculate the time of the movie
2013-12-04 15:17:02 +00:00
/// </summary>
double Fps { get ; }
2013-11-30 03:10:05 +00:00
2013-12-04 15:17:02 +00:00
/// <summary>
2013-12-05 00:44:56 +00:00
/// Gets the time calculation based on FrameCount and Fps
2013-12-04 15:17:02 +00:00
/// </summary>
2013-12-02 21:57:48 +00:00
TimeSpan Time { get ; }
2013-11-30 03:10:05 +00:00
/// <summary>
2013-12-05 00:44:56 +00:00
/// Gets the actual length of the input log, should only be used by code that iterates or needs a real length
2013-11-30 03:10:05 +00:00
/// </summary>
int InputLogLength { get ; }
2013-12-02 17:50:29 +00:00
2013-11-30 02:33:26 +00:00
IMovieHeader Header { get ; }
2013-11-29 19:55:05 +00:00
#endregion
2013-11-23 17:26:33 +00:00
2013-11-29 19:55:05 +00:00
#region File Handling API
2014-04-06 16:49:05 +00:00
// Filename of the movie, settable by the client
2013-11-29 19:55:05 +00:00
string Filename { get ; set ; }
2014-04-06 16:49:05 +00:00
/// <summary>
/// Tells the movie to load the contents of Filename
/// </summary>
/// <returns>Return whether or not the file was successfully loaded</returns>
2013-11-23 18:18:58 +00:00
bool Load ( ) ;
2014-04-06 16:49:05 +00:00
/// <summary>
/// Instructs the movie to save the current contents to Filename
/// </summary>
2013-11-23 18:18:58 +00:00
void Save ( ) ;
2014-04-06 16:49:05 +00:00
/// <summary>
/// Extracts the current input log from the user.
/// This is provided as the means for putting the input log into savestates,
/// for the purpose of out of order savestate loading (known as "bullet-proof rerecording")
/// </summary>
/// <returns>returns a string represntation of the input log in its current state</returns>
2013-11-30 02:50:54 +00:00
string GetInputLog ( ) ;
2014-04-06 16:49:05 +00:00
/// <summary>
/// Compares the input log inside reader with the movie's current input to see if the reader's input belongs to the same timeline,
/// in other words, if reader's input is completely contained in the movie's input, then it is considered in the same timeline
/// </summary>
/// <param name="reader">The reader containing the contents of the input log</param>
/// <param name="errorMessage">Returns an error message, if any</param>
/// <returns>Returns whether or not the input log in reader is in the same timeline as the movie</returns>
2013-12-05 00:44:56 +00:00
bool CheckTimeLines ( TextReader reader , out string errorMessage ) ;
2014-04-06 16:49:05 +00:00
/// <summary>
/// Takes reader and extracts the input log, then replaces the movies input log with it
/// </summary>
/// <param name="reader">The reader containing the contents of the input log</param>
/// <param name="errorMessage">Returns an error message, if any</param>
/// <returns></returns>
2013-12-05 00:44:56 +00:00
bool ExtractInputLog ( TextReader reader , out string errorMessage ) ;
2013-11-29 19:55:05 +00:00
#endregion
#region Mode Handling API
/// <summary>
/// Tells the movie to start recording from the beginning.
/// </summary>
void StartNewRecording ( ) ;
/// <summary>
/// Tells the movie to start playback from the beginning
/// </summary>
void StartNewPlayback ( ) ;
/// <summary>
/// Sets the movie to inactive (note that it will still be in memory)
/// The saveChanges flag will tell the movie to save its contents to disk
/// </summary>
2013-11-30 02:20:34 +00:00
/// <param name="saveChanges">if true, will save to disk</param>
2013-11-23 18:18:58 +00:00
void Stop ( bool saveChanges = true ) ;
2013-11-23 17:26:33 +00:00
2013-11-29 19:55:05 +00:00
/// <summary>
/// Switches to record mode
/// </summary>
void SwitchToRecord ( ) ;
/// <summary>
/// Switches to playback mode
/// </summary>
void SwitchToPlay ( ) ;
#endregion
2013-11-23 17:26:33 +00:00
#region Editing API
2013-11-23 18:18:58 +00:00
2013-12-03 15:59:46 +00:00
/// <summary>
2013-12-05 00:44:56 +00:00
/// Replaces the given frame's input with an empty frame
2013-12-03 15:59:46 +00:00
/// </summary>
2013-11-23 17:26:33 +00:00
void ClearFrame ( int frame ) ;
2013-12-03 15:59:46 +00:00
/// <summary>
/// Adds the given input to the movie
/// Note: this edits the input log without the normal movie recording logic applied
/// </summary>
2013-12-07 16:31:04 +00:00
void AppendFrame ( IController source ) ;
2013-12-03 15:59:46 +00:00
/// <summary>
/// Replaces the input at the given frame with the given input
/// Note: this edits the input log without the normal movie recording logic applied
/// </summary>
2013-12-07 16:31:04 +00:00
void PokeFrame ( int frame , IController source ) ;
2013-12-03 15:59:46 +00:00
/// <summary>
/// Records the given input into the given frame,
/// This is subject to normal movie recording logic
/// </summary>
2013-12-07 16:31:04 +00:00
void RecordFrame ( int frame , IController source ) ;
2013-12-03 15:59:46 +00:00
2014-04-06 16:49:05 +00:00
/// <summary>
/// Instructs the movie to remove all input from its input log after frame,
/// AFter truncating, frame will be the last frame of input in the movie's input log
/// </summary>
/// <param name="frame">The frame at which to truncate</param>
2013-12-03 01:43:02 +00:00
void Truncate ( int frame ) ;
2014-04-06 16:49:05 +00:00
/// <summary>
/// Gets a single frame of input from the movie at the given frame
/// The input will be in the same format as represented in the input log when saved as a file
/// </summary>
/// <param name="frame">The frame of input to be retrieved</param>
/// <returns></returns>
2013-12-03 15:59:46 +00:00
string GetInput ( int frame ) ;
2013-11-23 18:18:58 +00:00
2013-11-23 17:26:33 +00:00
#endregion
}
}