using System.Collections.Generic; using System.IO; using BizHawk.Emulation.Common; using System; namespace BizHawk.Client.Common { // TODO: message callback / event handler // TODO: consider other event handlers, switching modes? public interface IMovie { #region Status bool IsCountingRerecords { get; set; } bool IsActive { get; } bool IsPlaying { get; } bool IsRecording { get; } bool IsFinished { get; } bool Changes { get; } bool Loaded { get; } #endregion #region Properties double FrameCount { get; } TimeSpan Time { get; } /// /// Actual length of the input log, should only be used by code that iterates or needs a real length /// int InputLogLength { get; } IMovieHeader Header { get; } #endregion #region File Handling API string Filename { get; set; } bool Load(); void Save(); void SaveAs(); string GetInputLog(); #endregion #region Mode Handling API /// /// Tells the movie to start recording from the beginning. /// This will clear SRAM, and the movie log /// void StartNewRecording(); /// /// Tells the movie to start playback from the beginning /// This will clear SRAM /// void StartNewPlayback(); /// /// 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 /// /// if true, will save to disk void Stop(bool saveChanges = true); /// /// Switches to record mode /// Does not change the movie log or clear SRAM /// void SwitchToRecord(); /// /// Switches to playback mode /// Does not change the movie log or clear SRAM /// void SwitchToPlay(); #endregion #region Editing API /// /// Repalces the given frame's input with an empty frame /// /// void ClearFrame(int frame); /// /// Adds the given input to the movie /// Note: this edits the input log without the normal movie recording logic applied /// /// void AppendFrame(MnemonicsGenerator mg); /// /// Replaces the input at the given frame with the given input /// Note: this edits the input log without the normal movie recording logic applied /// void PokeFrame(int frame, MnemonicsGenerator mg); /// /// Records the given input into the given frame, /// This is subject to normal movie recording logic /// void RecordFrame(int frame, MnemonicsGenerator mg); void Truncate(int frame); string GetInput(int frame); #endregion #region Dubious, should reconsider LoadStateResult CheckTimeLines(TextReader reader, bool onlyGuid, bool ignoreGuidMismatch, out string errorMessage); // No need to return a status, no reason to have hacky flags, no need to pass a textreader void ExtractInputLog(TextReader reader, bool isMultitracking); // how about the movie know if it is multi-tracking rather than having to pass it in #endregion } } // TODO: delete this and refactor code that uses it! public enum LoadStateResult { Pass, GuidMismatch, TimeLineError, FutureEventError, NotInRecording, EmptyLog, MissingFrameNumber }