properly use TasMovie.Session - fixes #1771
This commit is contained in:
parent
7062ba5b6a
commit
eaca35d3d0
|
@ -1,9 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace BizHawk.Client.Common
|
namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
|
@ -12,13 +9,13 @@ namespace BizHawk.Client.Common
|
||||||
private ZipArchive _archive;
|
private ZipArchive _archive;
|
||||||
private readonly CompressionLevel _level;
|
private readonly CompressionLevel _level;
|
||||||
|
|
||||||
public FrameworkZipWriter(string path, int compressionlevel)
|
public FrameworkZipWriter(string path, int compressionLevel)
|
||||||
{
|
{
|
||||||
_archive = new ZipArchive(new FileStream(path, FileMode.Create, FileAccess.Write),
|
_archive = new ZipArchive(new FileStream(path, FileMode.Create, FileAccess.Write),
|
||||||
ZipArchiveMode.Create, false);
|
ZipArchiveMode.Create, false);
|
||||||
if (compressionlevel == 0)
|
if (compressionLevel == 0)
|
||||||
_level = CompressionLevel.NoCompression;
|
_level = CompressionLevel.NoCompression;
|
||||||
else if (compressionlevel < 5)
|
else if (compressionLevel < 5)
|
||||||
_level = CompressionLevel.Fastest;
|
_level = CompressionLevel.Fastest;
|
||||||
else
|
else
|
||||||
_level = CompressionLevel.Optimal;
|
_level = CompressionLevel.Optimal;
|
||||||
|
@ -26,11 +23,9 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
public void WriteItem(string name, Action<Stream> callback)
|
public void WriteItem(string name, Action<Stream> callback)
|
||||||
{
|
{
|
||||||
using (var stream = _archive.CreateEntry(name, _level).Open())
|
using var stream = _archive.CreateEntry(name, _level).Open();
|
||||||
{
|
|
||||||
callback(stream);
|
callback(stream);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace BizHawk.Client.Common
|
||||||
protected override void Write(string fn, bool backup = false)
|
protected override void Write(string fn, bool backup = false)
|
||||||
{
|
{
|
||||||
var file = new FileInfo(fn);
|
var file = new FileInfo(fn);
|
||||||
if (!file.Directory.Exists)
|
if (file.Directory != null && !file.Directory.Exists)
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(file.Directory.ToString());
|
Directory.CreateDirectory(file.Directory.ToString());
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
if (TasStateManager.Settings.SaveStateHistory && !backup)
|
if (TasStateManager.Settings.SaveStateHistory && !backup)
|
||||||
{
|
{
|
||||||
bs.PutLump(BinaryStateLump.StateHistory, (BinaryWriter bw) => TasStateManager.Save(bw));
|
bs.PutLump(BinaryStateLump.StateHistory, bw => TasStateManager.Save(bw));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
ChangeLog = new TasMovieChangeLog(this);
|
ChangeLog = new TasMovieChangeLog(this);
|
||||||
TasStateManager = new TasStateManager(this);
|
TasStateManager = new TasStateManager(this);
|
||||||
Session = new TasSession(this);
|
Session = new TasSession();
|
||||||
Header[HeaderKeys.MOVIEVERSION] = "BizHawk v2.0 Tasproj v1.0";
|
Header[HeaderKeys.MOVIEVERSION] = "BizHawk v2.0 Tasproj v1.0";
|
||||||
Markers = new TasMovieMarkerList(this);
|
Markers = new TasMovieMarkerList(this);
|
||||||
Markers.CollectionChanged += Markers_CollectionChanged;
|
Markers.CollectionChanged += Markers_CollectionChanged;
|
||||||
|
|
|
@ -1,25 +1,14 @@
|
||||||
using System;
|
namespace BizHawk.Client.Common
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace BizHawk.Client.Common
|
|
||||||
{
|
{
|
||||||
public class TasSession
|
public class TasSession
|
||||||
{
|
{
|
||||||
private readonly TasMovie _movie;
|
public int CurrentFrame { get; set; }
|
||||||
public int CurrentFrame { get; private set; }
|
public int CurrentBranch { get; set; } = -1;
|
||||||
public int CurrentBranch { get; private set; }
|
|
||||||
|
|
||||||
public TasSession(TasMovie movie)
|
public void UpdateValues(int frame, int currentBranch)
|
||||||
{
|
{
|
||||||
_movie = movie;
|
CurrentFrame = frame;
|
||||||
CurrentFrame = 0;
|
CurrentBranch = currentBranch;
|
||||||
CurrentBranch = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UpdateValues()
|
|
||||||
{
|
|
||||||
CurrentFrame = Global.Emulator.Frame;
|
|
||||||
CurrentBranch = _movie.CurrentBranch;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,6 +145,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
Movie.AddBranch(branch);
|
Movie.AddBranch(branch);
|
||||||
BranchView.RowCount = Movie.Branches.Count;
|
BranchView.RowCount = Movie.Branches.Count;
|
||||||
Movie.CurrentBranch = Movie.Branches.Count - 1;
|
Movie.CurrentBranch = Movie.Branches.Count - 1;
|
||||||
|
Movie.Session.UpdateValues(Global.Emulator.Frame, Movie.CurrentBranch); // TODO: pass in emulator dependency
|
||||||
BranchView.ScrollToIndex(Movie.CurrentBranch);
|
BranchView.ScrollToIndex(Movie.CurrentBranch);
|
||||||
Select(Movie.CurrentBranch, true);
|
Select(Movie.CurrentBranch, true);
|
||||||
BranchView.Refresh();
|
BranchView.Refresh();
|
||||||
|
|
|
@ -51,6 +51,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
refreshNeeded = AutoAdjustInput();
|
refreshNeeded = AutoAdjustInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CurrentTasMovie.Session.UpdateValues(Emulator.Frame, CurrentTasMovie.CurrentBranch);
|
||||||
MaybeFollowCursor();
|
MaybeFollowCursor();
|
||||||
|
|
||||||
if (TasView.IsPartiallyVisible(Emulator.Frame) || TasView.IsPartiallyVisible(_lastRefresh))
|
if (TasView.IsPartiallyVisible(Emulator.Frame) || TasView.IsPartiallyVisible(_lastRefresh))
|
||||||
|
|
Loading…
Reference in New Issue