Propagate success through to caller for movie load/restart
This commit is contained in:
parent
0076c8802b
commit
7fdc3f992d
|
@ -55,6 +55,6 @@
|
|||
|
||||
bool WantsToControlRestartMovie { get; }
|
||||
|
||||
void RestartMovie();
|
||||
bool RestartMovie();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -484,9 +484,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
private void PlayFromBeginningMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
RestartMovie();
|
||||
}
|
||||
=> _ = RestartMovie();
|
||||
|
||||
private void ImportMovieMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
|
|
@ -87,25 +87,16 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
private void LoadMovie(string filename, string archive = null)
|
||||
private bool LoadMovie(string filename, string archive = null)
|
||||
{
|
||||
if (Emulator.IsNull())
|
||||
{
|
||||
OpenRom();
|
||||
if (Emulator.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (Tools.IsLoaded<TAStudio>())
|
||||
{
|
||||
Tools.TAStudio.LoadMovieFile(filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
StartNewMovie(MovieSession.Get(filename), false);
|
||||
if (Emulator.IsNull()) return false;
|
||||
}
|
||||
return Tools.IsLoaded<TAStudio>()
|
||||
? Tools.TAStudio.LoadMovieFile(filename)
|
||||
: StartNewMovie(MovieSession.Get(filename), false);
|
||||
}
|
||||
|
||||
private void LoadRom(string filename, string archive = null)
|
||||
|
@ -299,10 +290,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
if (sortedFiles[LoadOrdering.MovieFile].Count + sortedFiles[LoadOrdering.LegacyMovieFile].Count > 1)
|
||||
break;
|
||||
|
||||
if (value == LoadOrdering.MovieFile)
|
||||
LoadMovie(filename, fileInformation.ArchiveName);
|
||||
else
|
||||
LoadLegacyMovie(filename, fileInformation.ArchiveName);
|
||||
if (value == LoadOrdering.MovieFile) _ = LoadMovie(filename, fileInformation.ArchiveName);
|
||||
else LoadLegacyMovie(filename, fileInformation.ArchiveName);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -278,7 +278,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
StopMovie();
|
||||
break;
|
||||
case "Play from beginning":
|
||||
RestartMovie();
|
||||
_ = RestartMovie();
|
||||
break;
|
||||
case "Save Movie":
|
||||
SaveMovie();
|
||||
|
|
|
@ -99,17 +99,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
private void RestartMovie()
|
||||
private bool RestartMovie()
|
||||
{
|
||||
if (IsSlave && Master.WantsToControlRestartMovie)
|
||||
{
|
||||
Master.RestartMovie();
|
||||
}
|
||||
else if (MovieSession.Movie.IsActive())
|
||||
{
|
||||
StartNewMovie(MovieSession.Movie, false);
|
||||
AddOnScreenMessage("Replaying movie file in read-only mode");
|
||||
}
|
||||
if (IsSlave && Master.WantsToControlRestartMovie) return Master.RestartMovie();
|
||||
if (!MovieSession.Movie.IsActive()) return false;
|
||||
var success = StartNewMovie(MovieSession.Movie, false);
|
||||
if (success) AddOnScreenMessage("Replaying movie file in read-only mode");
|
||||
return success;
|
||||
}
|
||||
|
||||
private void ToggleReadOnly()
|
||||
|
|
|
@ -32,7 +32,9 @@
|
|||
public bool Rewind() => false;
|
||||
|
||||
public bool WantsToControlRestartMovie => false;
|
||||
public void RestartMovie() { }
|
||||
|
||||
public bool RestartMovie()
|
||||
=> false;
|
||||
|
||||
// TODO: We want to prevent movies and probably other things
|
||||
}
|
||||
|
|
|
@ -120,15 +120,14 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public bool WantsToControlRestartMovie { get; }
|
||||
|
||||
public void RestartMovie()
|
||||
public bool RestartMovie()
|
||||
{
|
||||
if (AskSaveChanges())
|
||||
{
|
||||
WantsToControlStopMovie = false;
|
||||
StartNewMovieWrapper(CurrentTasMovie);
|
||||
WantsToControlStopMovie = true;
|
||||
RefreshDialog();
|
||||
}
|
||||
if (!AskSaveChanges()) return false;
|
||||
WantsToControlStopMovie = false;
|
||||
var success = StartNewMovieWrapper(CurrentTasMovie);
|
||||
WantsToControlStopMovie = true;
|
||||
RefreshDialog();
|
||||
return success;
|
||||
}
|
||||
|
||||
public bool WantsToControlReboot { get; private set; } = true;
|
||||
|
|
|
@ -95,39 +95,42 @@ namespace BizHawk.Client.EmuHawk
|
|||
/// <summary>
|
||||
/// Load the movie with the given filename within TAStudio.
|
||||
/// </summary>
|
||||
public void LoadMovieFile(string filename, bool askToSave = true)
|
||||
public bool LoadMovieFile(string filename, bool askToSave = true)
|
||||
{
|
||||
if (askToSave && !AskSaveChanges())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (askToSave && !AskSaveChanges()) return false;
|
||||
if (filename.EndsWith(MovieService.TasMovieExtension))
|
||||
{
|
||||
LoadFileWithFallback(filename);
|
||||
return true; //TODO should this return false if it fell back to a new project?
|
||||
}
|
||||
else if (filename.EndsWith(MovieService.StandardMovieExtension))
|
||||
if (filename.EndsWith(MovieService.StandardMovieExtension))
|
||||
{
|
||||
var result1 = DialogController.ShowMessageBox2("This is a regular movie, a new project must be created from it to use in TAStudio\nProceed?", "Convert movie", EMsgBoxIcon.Question, useOKCancel: true);
|
||||
if (result1)
|
||||
if (!DialogController.ShowMessageBox2(
|
||||
caption: "Convert movie",
|
||||
icon: EMsgBoxIcon.Question,
|
||||
text: "This is a regular movie, a new project must be created from it to use in TAStudio\nProceed?",
|
||||
useOKCancel: true))
|
||||
{
|
||||
_initializing = true; // Starting a new movie causes a core reboot
|
||||
WantsToControlReboot = false;
|
||||
_engaged = false;
|
||||
MainForm.StartNewMovie(MovieSession.Get(filename), false);
|
||||
ConvertCurrentMovieToTasproj();
|
||||
_initializing = false;
|
||||
StartNewMovieWrapper(CurrentTasMovie);
|
||||
_engaged = true;
|
||||
WantsToControlReboot = true;
|
||||
SetUpColumns();
|
||||
UpdateWindowTitle();
|
||||
return false;
|
||||
}
|
||||
_initializing = true; // Starting a new movie causes a core reboot
|
||||
WantsToControlReboot = false;
|
||||
_engaged = false;
|
||||
MainForm.StartNewMovie(MovieSession.Get(filename), false);
|
||||
ConvertCurrentMovieToTasproj();
|
||||
_initializing = false;
|
||||
var success = StartNewMovieWrapper(CurrentTasMovie);
|
||||
_engaged = true;
|
||||
WantsToControlReboot = true;
|
||||
SetUpColumns();
|
||||
UpdateWindowTitle();
|
||||
return success; //TODO is this correct?
|
||||
}
|
||||
else
|
||||
{
|
||||
DialogController.ShowMessageBox("This is not a BizHawk movie!", "Movie load error", EMsgBoxIcon.Error);
|
||||
}
|
||||
DialogController.ShowMessageBox(
|
||||
caption: "Movie load error",
|
||||
icon: EMsgBoxIcon.Error,
|
||||
text: "This is not a BizHawk movie!");
|
||||
return false;
|
||||
}
|
||||
|
||||
private void SaveTasMenuItem_Click(object sender, EventArgs e)
|
||||
|
|
Loading…
Reference in New Issue