From 9393e1b764cdfdcff66819efc4c02bb169847b0c Mon Sep 17 00:00:00 2001
From: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Thu, 1 Dec 2022 09:44:56 -0800
Subject: [PATCH] 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
---
.../movie/MovieSession.cs | 5 +++++
.../movie/interfaces/IMovieSession.cs | 11 ++++++++++
.../tools/TAStudio/TAStudio.cs | 20 ++++++++++++++-----
3 files changed, 31 insertions(+), 5 deletions(-)
diff --git a/src/BizHawk.Client.Common/movie/MovieSession.cs b/src/BizHawk.Client.Common/movie/MovieSession.cs
index ad6d1e8c51..52560dee49 100644
--- a/src/BizHawk.Client.Common/movie/MovieSession.cs
+++ b/src/BizHawk.Client.Common/movie/MovieSession.cs
@@ -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())
diff --git a/src/BizHawk.Client.Common/movie/interfaces/IMovieSession.cs b/src/BizHawk.Client.Common/movie/interfaces/IMovieSession.cs
index 7b375733fc..1d8fc1f174 100644
--- a/src/BizHawk.Client.Common/movie/interfaces/IMovieSession.cs
+++ b/src/BizHawk.Client.Common/movie/interfaces/IMovieSession.cs
@@ -54,6 +54,17 @@ namespace BizHawk.Client.Common
///
IMovieController GenerateMovieController(ControllerDefinition definition = null);
+ ///
+ /// 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
+ ///
+ /// current IEmulator ControllerDefinition
+ void SetMovieController(ControllerDefinition definition);
+
void HandleFrameBefore();
void HandleFrameAfter();
void HandleSaveState(TextWriter writer);
diff --git a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs
index f91c5544b4..1e397190b7 100644
--- a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs
+++ b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs
@@ -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)
{