Refactor tasmovie input roll settings handling
this allows loading the input roll settings stored in a tasproj even after it was initially `Load()`ed. This fixes those settings not getting applied when loading an existing, playing tasmovie into TAStudio.
This commit is contained in:
parent
81b6c2793c
commit
2ad7fc095c
|
@ -11,8 +11,8 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
IMovieChangeLog ChangeLog { get; }
|
IMovieChangeLog ChangeLog { get; }
|
||||||
IStateManager TasStateManager { get; }
|
IStateManager TasStateManager { get; }
|
||||||
Func<string> ClientSettingsForSave { get; set; }
|
Func<string> InputRollSettingsForSave { get; set; }
|
||||||
Action<string> GetClientSettingsOnLoad { get; set; }
|
string InputRollSettings { get; }
|
||||||
ITasMovieRecord this[int index] { get; }
|
ITasMovieRecord this[int index] { get; }
|
||||||
ITasSession TasSession { get; }
|
ITasSession TasSession { get; }
|
||||||
TasMovieMarkerList Markers { get; }
|
TasMovieMarkerList Markers { get; }
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
using BizHawk.Common.StringExtensions;
|
using BizHawk.Common.StringExtensions;
|
||||||
|
@ -9,8 +9,8 @@ namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
internal partial class TasMovie
|
internal partial class TasMovie
|
||||||
{
|
{
|
||||||
public Func<string> ClientSettingsForSave { get; set; }
|
public Func<string> InputRollSettingsForSave { get; set; }
|
||||||
public Action<string> GetClientSettingsOnLoad { get; set; }
|
public string InputRollSettings { get; private set; }
|
||||||
|
|
||||||
protected override void AddLumps(ZipStateSaver bs, bool isBackup = false)
|
protected override void AddLumps(ZipStateSaver bs, bool isBackup = false)
|
||||||
{
|
{
|
||||||
|
@ -27,10 +27,10 @@ namespace BizHawk.Client.Common
|
||||||
bs.PutLump(BinaryStateLump.LagLog, tw => LagLog.Save(tw));
|
bs.PutLump(BinaryStateLump.LagLog, tw => LagLog.Save(tw));
|
||||||
bs.PutLump(BinaryStateLump.Markers, tw => tw.WriteLine(Markers.ToString()));
|
bs.PutLump(BinaryStateLump.Markers, tw => tw.WriteLine(Markers.ToString()));
|
||||||
|
|
||||||
if (ClientSettingsForSave != null)
|
if (InputRollSettingsForSave != null)
|
||||||
{
|
{
|
||||||
var clientSettingsJson = ClientSettingsForSave();
|
var inputRollSettingsJson = InputRollSettingsForSave();
|
||||||
bs.PutLump(BinaryStateLump.ClientSettings, (TextWriter tw) => tw.Write(clientSettingsJson));
|
bs.PutLump(BinaryStateLump.ClientSettings, (TextWriter tw) => tw.Write(inputRollSettingsJson));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VerificationLog.Any())
|
if (VerificationLog.Any())
|
||||||
|
@ -99,16 +99,13 @@ namespace BizHawk.Client.Common
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (GetClientSettingsOnLoad != null)
|
bl.GetLump(BinaryStateLump.ClientSettings, abort: false, tr =>
|
||||||
{
|
{
|
||||||
bl.GetLump(BinaryStateLump.ClientSettings, abort: false, tr =>
|
string inputRollSettings = tr.ReadToEnd();
|
||||||
{
|
|
||||||
string clientSettings = tr.ReadToEnd();
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(clientSettings))
|
if (!string.IsNullOrEmpty(inputRollSettings))
|
||||||
GetClientSettingsOnLoad(clientSettings);
|
InputRollSettings = inputRollSettings;
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
bl.GetLump(BinaryStateLump.VerificationLog, abort: false, tr =>
|
bl.GetLump(BinaryStateLump.VerificationLog, abort: false, tr =>
|
||||||
{
|
{
|
||||||
|
|
|
@ -331,12 +331,6 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetTasMovieCallbacks(ITasMovie movie)
|
|
||||||
{
|
|
||||||
movie.ClientSettingsForSave = () => TasView.UserSettingsSerialized();
|
|
||||||
movie.GetClientSettingsOnLoad = json => TasView.LoadSettingsSerialized(json);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static readonly string[] N64CButtonSuffixes = { " C Up", " C Down", " C Left", " C Right" };
|
private static readonly string[] N64CButtonSuffixes = { " C Up", " C Down", " C Left", " C Right" };
|
||||||
|
|
||||||
private void SetUpColumns()
|
private void SetUpColumns()
|
||||||
|
@ -574,7 +568,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
_initializing = true;
|
_initializing = true;
|
||||||
|
|
||||||
SetTasMovieCallbacks(movie);
|
movie.InputRollSettingsForSave = () => TasView.UserSettingsSerialized();
|
||||||
movie.BindMarkersToInput = Settings.BindMarkersToInput;
|
movie.BindMarkersToInput = Settings.BindMarkersToInput;
|
||||||
movie.GreenzoneInvalidated = GreenzoneInvalidated;
|
movie.GreenzoneInvalidated = GreenzoneInvalidated;
|
||||||
movie.PropertyChanged += TasMovie_OnPropertyChanged;
|
movie.PropertyChanged += TasMovie_OnPropertyChanged;
|
||||||
|
@ -590,6 +584,10 @@ namespace BizHawk.Client.EmuHawk
|
||||||
MarkerControl.UpdateTextColumnWidth();
|
MarkerControl.UpdateTextColumnWidth();
|
||||||
TastudioPlayMode();
|
TastudioPlayMode();
|
||||||
UpdateWindowTitle();
|
UpdateWindowTitle();
|
||||||
|
if (CurrentTasMovie.InputRollSettings != null)
|
||||||
|
{
|
||||||
|
TasView.LoadSettingsSerialized(CurrentTasMovie.InputRollSettings);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_initializing = false;
|
_initializing = false;
|
||||||
|
@ -615,14 +613,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var movie = MovieSession.Get(path, loadMovie: false);
|
var movie = MovieSession.Get(path, loadMovie: true);
|
||||||
// we can't load the movie yet, we need to set the callbacks first...
|
|
||||||
if (movie is ITasMovie pendingTasMovie)
|
|
||||||
{
|
|
||||||
SetTasMovieCallbacks(pendingTasMovie);
|
|
||||||
}
|
|
||||||
|
|
||||||
movie.Load();
|
|
||||||
var tasMovie = movie as ITasMovie ?? movie.ToTasMovie();
|
var tasMovie = movie as ITasMovie ?? movie.ToTasMovie();
|
||||||
movieLoadSucceeded = LoadMovie(tasMovie);
|
movieLoadSucceeded = LoadMovie(tasMovie);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue