diff --git a/BizHawk.Client.Common/FrameworkZipWriter.cs b/BizHawk.Client.Common/FrameworkZipWriter.cs index 1bbe33910b..b6fe6d597e 100644 --- a/BizHawk.Client.Common/FrameworkZipWriter.cs +++ b/BizHawk.Client.Common/FrameworkZipWriter.cs @@ -1,9 +1,6 @@ using System; -using System.Collections.Generic; using System.IO; using System.IO.Compression; -using System.Linq; -using System.Text; namespace BizHawk.Client.Common { @@ -12,13 +9,13 @@ namespace BizHawk.Client.Common private ZipArchive _archive; 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), ZipArchiveMode.Create, false); - if (compressionlevel == 0) + if (compressionLevel == 0) _level = CompressionLevel.NoCompression; - else if (compressionlevel < 5) + else if (compressionLevel < 5) _level = CompressionLevel.Fastest; else _level = CompressionLevel.Optimal; @@ -26,10 +23,8 @@ namespace BizHawk.Client.Common public void WriteItem(string name, Action callback) { - using (var stream = _archive.CreateEntry(name, _level).Open()) - { - callback(stream); - } + using var stream = _archive.CreateEntry(name, _level).Open(); + callback(stream); } public void Dispose() diff --git a/BizHawk.Client.Common/movie/tasproj/TasMovie.IO.cs b/BizHawk.Client.Common/movie/tasproj/TasMovie.IO.cs index 707f1ce477..c3b92de726 100644 --- a/BizHawk.Client.Common/movie/tasproj/TasMovie.IO.cs +++ b/BizHawk.Client.Common/movie/tasproj/TasMovie.IO.cs @@ -14,7 +14,7 @@ namespace BizHawk.Client.Common protected override void Write(string fn, bool backup = false) { var file = new FileInfo(fn); - if (!file.Directory.Exists) + if (file.Directory != null && !file.Directory.Exists) { Directory.CreateDirectory(file.Directory.ToString()); } @@ -70,7 +70,7 @@ namespace BizHawk.Client.Common if (TasStateManager.Settings.SaveStateHistory && !backup) { - bs.PutLump(BinaryStateLump.StateHistory, (BinaryWriter bw) => TasStateManager.Save(bw)); + bs.PutLump(BinaryStateLump.StateHistory, bw => TasStateManager.Save(bw)); } } diff --git a/BizHawk.Client.Common/movie/tasproj/TasMovie.cs b/BizHawk.Client.Common/movie/tasproj/TasMovie.cs index 8053609d4c..5182ca6f2b 100644 --- a/BizHawk.Client.Common/movie/tasproj/TasMovie.cs +++ b/BizHawk.Client.Common/movie/tasproj/TasMovie.cs @@ -56,7 +56,7 @@ namespace BizHawk.Client.Common ChangeLog = new TasMovieChangeLog(this); TasStateManager = new TasStateManager(this); - Session = new TasSession(this); + Session = new TasSession(); Header[HeaderKeys.MOVIEVERSION] = "BizHawk v2.0 Tasproj v1.0"; Markers = new TasMovieMarkerList(this); Markers.CollectionChanged += Markers_CollectionChanged; diff --git a/BizHawk.Client.Common/movie/tasproj/TasSession.cs b/BizHawk.Client.Common/movie/tasproj/TasSession.cs index bafe45bdbd..349fedc0c5 100644 --- a/BizHawk.Client.Common/movie/tasproj/TasSession.cs +++ b/BizHawk.Client.Common/movie/tasproj/TasSession.cs @@ -1,25 +1,14 @@ -using System; -using System.Text; - -namespace BizHawk.Client.Common +namespace BizHawk.Client.Common { public class TasSession { - private readonly TasMovie _movie; - public int CurrentFrame { get; private set; } - public int CurrentBranch { get; private set; } + public int CurrentFrame { get; set; } + public int CurrentBranch { get; set; } = -1; - public TasSession(TasMovie movie) + public void UpdateValues(int frame, int currentBranch) { - _movie = movie; - CurrentFrame = 0; - CurrentBranch = -1; - } - - public void UpdateValues() - { - CurrentFrame = Global.Emulator.Frame; - CurrentBranch = _movie.CurrentBranch; + CurrentFrame = frame; + CurrentBranch = currentBranch; } } } diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs index d0b2d2e890..6290675a95 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs @@ -145,6 +145,7 @@ namespace BizHawk.Client.EmuHawk Movie.AddBranch(branch); BranchView.RowCount = Movie.Branches.Count; Movie.CurrentBranch = Movie.Branches.Count - 1; + Movie.Session.UpdateValues(Global.Emulator.Frame, Movie.CurrentBranch); // TODO: pass in emulator dependency BranchView.ScrollToIndex(Movie.CurrentBranch); Select(Movie.CurrentBranch, true); BranchView.Refresh(); diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs index 334059912a..8829e158e6 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs @@ -51,6 +51,7 @@ namespace BizHawk.Client.EmuHawk refreshNeeded = AutoAdjustInput(); } + CurrentTasMovie.Session.UpdateValues(Emulator.Frame, CurrentTasMovie.CurrentBranch); MaybeFollowCursor(); if (TasView.IsPartiallyVisible(Emulator.Frame) || TasView.IsPartiallyVisible(_lastRefresh))