fully support read-only movie opening. I hope this fixes #453
This commit is contained in:
parent
a283b2d1b9
commit
b981e00889
|
@ -19,7 +19,7 @@ namespace BizHawk.Client.Common
|
|||
if (Path.GetExtension(path).EndsWith("bkm"))
|
||||
{
|
||||
var bkm = new BkmMovie(path);
|
||||
bkm.Load();
|
||||
bkm.Load(false);
|
||||
|
||||
// Hackery to fix how things used to work
|
||||
if (bkm.SystemID == "GBC")
|
||||
|
|
|
@ -182,7 +182,7 @@ namespace BizHawk.Client.Common
|
|||
public bool MovieLoad()
|
||||
{
|
||||
MovieControllerAdapter = Movie.LogGeneratorInstance().MovieControllerAdapter;
|
||||
return Movie.Load();
|
||||
return Movie.Load(false);
|
||||
}
|
||||
|
||||
public void StopMovie(bool saveChanges = true)
|
||||
|
@ -463,7 +463,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
if (!record) // The semantics of record is that we are starting a new movie, and even wiping a pre-existing movie with the same path, but non-record means we are loading an existing movie into playback mode
|
||||
{
|
||||
movie.Load();
|
||||
movie.Load(false);
|
||||
if (movie.SystemID != emulator.SystemId)
|
||||
{
|
||||
throw new MoviePlatformMismatchException(
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace BizHawk.Client.Common
|
|||
Write(backupName);
|
||||
}
|
||||
|
||||
public virtual bool Load()
|
||||
public virtual bool Load(bool preload)
|
||||
{
|
||||
var file = new FileInfo(Filename);
|
||||
if (!file.Exists)
|
||||
|
@ -158,7 +158,6 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public bool PreLoadHeaderAndLength(HawkFile hawkFile)
|
||||
{
|
||||
// For now, preload simply loads everything
|
||||
var file = new FileInfo(Filename);
|
||||
if (!file.Exists)
|
||||
{
|
||||
|
@ -166,7 +165,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
Filename = file.FullName;
|
||||
return Load();
|
||||
return Load(true);
|
||||
}
|
||||
|
||||
protected virtual void Write(string fn)
|
||||
|
|
|
@ -58,7 +58,7 @@ namespace BizHawk.Client.Common
|
|||
Write(backupName);
|
||||
}
|
||||
|
||||
public bool Load()
|
||||
public bool Load(bool preload)
|
||||
{
|
||||
var file = new FileInfo(Filename);
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ namespace BizHawk.Client.Common.MovieConversionExtensions
|
|||
}
|
||||
|
||||
var tas = new TasMovie(newFilename, old.StartsFromSavestate);
|
||||
tas.TasStateManager.MountWriteAccess();
|
||||
|
||||
for (var i = 0; i < old.InputLogLength; i++)
|
||||
{
|
||||
|
|
|
@ -140,7 +140,7 @@ namespace BizHawk.Client.Common
|
|||
break;
|
||||
case ".BKM":
|
||||
m.Filename = path;
|
||||
m.Load();
|
||||
m.Load(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ namespace BizHawk.Client.Common
|
|||
/// Tells the movie to load the contents of Filename
|
||||
/// </summary>
|
||||
/// <returns>Return whether or not the file was successfully loaded</returns>
|
||||
bool Load();
|
||||
bool Load(bool preload);
|
||||
|
||||
/// <summary>
|
||||
/// Instructs the movie to save the current contents to Filename
|
||||
|
|
|
@ -107,7 +107,7 @@ namespace BizHawk.Client.Common
|
|||
Changes = false;
|
||||
}
|
||||
|
||||
public override bool Load()
|
||||
public override bool Load(bool preload)
|
||||
{
|
||||
var file = new FileInfo(Filename);
|
||||
if (!file.Exists)
|
||||
|
@ -221,16 +221,20 @@ namespace BizHawk.Client.Common
|
|||
StateManager.Settings.PopulateFromString(tr.ReadToEnd());
|
||||
});
|
||||
|
||||
if (StateManager.Settings.SaveStateHistory)
|
||||
if(!preload)
|
||||
{
|
||||
bl.GetLump(BinaryStateLump.StateHistory, false, delegate(BinaryReader br, long length)
|
||||
if (StateManager.Settings.SaveStateHistory)
|
||||
{
|
||||
StateManager.Load(br);
|
||||
});
|
||||
bl.GetLump(BinaryStateLump.StateHistory, false, delegate(BinaryReader br, long length)
|
||||
{
|
||||
StateManager.Load(br);
|
||||
});
|
||||
}
|
||||
|
||||
// Movie should always have a state at frame 0.
|
||||
if (!this.StartsFromSavestate)
|
||||
StateManager.Capture();
|
||||
}
|
||||
// Movie should always have a state at frame 0.
|
||||
if (!this.StartsFromSavestate)
|
||||
StateManager.Capture();
|
||||
|
||||
bl.GetLump(BinaryStateLump.Markers, false, delegate(TextReader tr)
|
||||
{
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
private Guid guid = Guid.NewGuid();
|
||||
private readonly SortedList<int, byte[]> States = new SortedList<int, byte[]>();
|
||||
private SortedList<int, byte[]> States = new SortedList<int, byte[]>();
|
||||
private string statePath
|
||||
{
|
||||
get
|
||||
|
@ -46,6 +46,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
}
|
||||
|
||||
private bool _isMountedForWrite;
|
||||
private readonly TasMovie _movie;
|
||||
private ulong _expectedStateSize = 0;
|
||||
|
||||
|
@ -80,6 +81,25 @@ namespace BizHawk.Client.Common
|
|||
|
||||
Settings = new TasStateManagerSettings(Global.Config.DefaultTasProjSettings);
|
||||
|
||||
accessed = new List<int>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Mounts this instance for write access. Prior to that it's read-only
|
||||
/// </summary>
|
||||
public void MountWriteAccess()
|
||||
{
|
||||
if (_isMountedForWrite)
|
||||
return;
|
||||
|
||||
_isMountedForWrite = true;
|
||||
|
||||
if (Directory.Exists(statePath))
|
||||
{
|
||||
Directory.Delete(statePath, true); // To delete old files that may still exist.
|
||||
}
|
||||
Directory.CreateDirectory(statePath);
|
||||
|
||||
int limit = 0;
|
||||
|
||||
_expectedStateSize = (ulong)Core.SaveStateBinary().Length;
|
||||
|
@ -90,20 +110,6 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
States = new SortedList<int, byte[]>(limit);
|
||||
|
||||
accessed = new List<int>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Mounts this instance for write access. Prior to that it's read-only
|
||||
/// </summary>
|
||||
public void MountWriteAccess()
|
||||
{
|
||||
if (Directory.Exists(statePath))
|
||||
{
|
||||
Directory.Delete(statePath, true); // To delete old files that may still exist.
|
||||
}
|
||||
Directory.CreateDirectory(statePath);
|
||||
}
|
||||
|
||||
public TasStateManagerSettings Settings { get; set; }
|
||||
|
|
|
@ -30,6 +30,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
try
|
||||
{
|
||||
var tasmovie = (movie as TasMovie);
|
||||
if (tasmovie != null)
|
||||
tasmovie.TasStateManager.MountWriteAccess();
|
||||
Global.MovieSession.QueueNewMovie(movie, record, Global.Emulator);
|
||||
}
|
||||
catch (MoviePlatformMismatchException ex)
|
||||
|
|
|
@ -407,7 +407,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
CurrentTasMovie.Filename = file.FullName;
|
||||
try
|
||||
{
|
||||
CurrentTasMovie.Load();
|
||||
CurrentTasMovie.Load(false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue