Fix #3417 and improve handling of `default.tasproj` (squashed PR #3462)

* Fix #3417 and improve handling of default.tasproj

* expose SetMovieController in the MovieSession interface (please don't rely on it anywhere else)

* don't use this explicit public in the interface

(is this mentioned anywhere? i assume this is proper style)

* use this helper function
This commit is contained in:
CasualPokePlayer 2022-12-01 09:44:56 -08:00 committed by GitHub
parent 10a38270e5
commit 9393e1b764
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 5 deletions

View File

@ -62,6 +62,11 @@ namespace BizHawk.Client.Common
return new Bk2Controller("", definition ?? MovieController.Definition);
}
public void SetMovieController(ControllerDefinition definition)
{
MovieController = GenerateMovieController(definition);
}
public void HandleFrameBefore()
{
if (Movie.NotActive())

View File

@ -54,6 +54,17 @@ namespace BizHawk.Client.Common
/// </summary>
IMovieController GenerateMovieController(ControllerDefinition definition = null);
/// <summary>
/// Hack only used for TAStudio when starting a new movie
/// This is due to needing to save a "dummy" default.tasproj
/// This dummy file's initial save bypasses the normal queue/run
/// new movie code (which normally sets the controller), although
/// once it saves it goes through the normal queue/run code anyway.
/// TODO: Stop relying on this dummy file so we do not need this ugly hack
/// </summary>
/// <param name="definition">current IEmulator ControllerDefinition</param>
void SetMovieController(ControllerDefinition definition);
void HandleFrameBefore();
void HandleFrameAfter();
void HandleSaveState(TextWriter writer);

View File

@ -602,11 +602,16 @@ namespace BizHawk.Client.EmuHawk
Config.DefaultAuthor);
SetTasMovieCallbacks(tasMovie);
MovieSession.SetMovieController(Emulator.ControllerDefinition); // hack, see interface comment
tasMovie.ClearChanges(); // Don't ask to save changes here.
tasMovie.Save();
if (HandleMovieLoadStuff(tasMovie))
{
}
// let's not keep this longer than we actually need
// the user will be prompted to enter a proper name
// when they want to save
File.Delete(tasMovie.Filename);
// clear all selections
TasView.DeselectAll();
@ -780,11 +785,16 @@ namespace BizHawk.Client.EmuHawk
filename = SuggestedTasProjName();
}
var file = SaveFileDialog(
currentFile: filename,
path: Config!.PathEntries.MovieAbsolutePath(),
TAStudioProjectsFSFilterSet,
this);
FileInfo file;
do
{
file = SaveFileDialog(
currentFile: filename,
path: Config!.PathEntries.MovieAbsolutePath(),
TAStudioProjectsFSFilterSet,
this);
}
while (file?.FullName == DefaultTasProjName()); // disallow saving as this reserved filename
if (file != null)
{