add option to play sound on movie end

requested in #2926
This commit is contained in:
Morilli 2025-03-26 19:20:13 +01:00
parent 6ead2ddee8
commit 289c5cff9b
5 changed files with 52 additions and 17 deletions

View File

@ -7,6 +7,7 @@
public bool MoviesOnDisk { get; } public bool MoviesOnDisk { get; }
public int MovieCompressionLevel { get; } public int MovieCompressionLevel { get; }
public bool VBAStyleMovieLoadState { get; } public bool VBAStyleMovieLoadState { get; }
public bool PlaySoundOnMovieEnd { get; set; }
ZwinderStateManagerSettings DefaultTasStateManagerSettings { get; } ZwinderStateManagerSettings DefaultTasStateManagerSettings { get; }
} }
@ -17,6 +18,7 @@
public bool MoviesOnDisk { get; set; } public bool MoviesOnDisk { get; set; }
public int MovieCompressionLevel { get; set; } = 2; public int MovieCompressionLevel { get; set; } = 2;
public bool VBAStyleMovieLoadState { get; set; } public bool VBAStyleMovieLoadState { get; set; }
public bool PlaySoundOnMovieEnd { get; set; }
public ZwinderStateManagerSettings DefaultTasStateManagerSettings { get; set; } = new ZwinderStateManagerSettings(); public ZwinderStateManagerSettings DefaultTasStateManagerSettings { get; set; } = new ZwinderStateManagerSettings();
} }

View File

@ -16,6 +16,7 @@ namespace BizHawk.Client.Common
private readonly Action _pauseCallback; private readonly Action _pauseCallback;
private readonly Action _modeChangedCallback; private readonly Action _modeChangedCallback;
private readonly Action _movieEndSound;
private IMovie _queuedMovie; private IMovie _queuedMovie;
@ -24,7 +25,8 @@ namespace BizHawk.Client.Common
string backDirectory, string backDirectory,
IDialogParent dialogParent, IDialogParent dialogParent,
Action pauseCallback, Action pauseCallback,
Action modeChangedCallback) Action modeChangedCallback,
Action movieEndSound = null)
{ {
Settings = settings; Settings = settings;
BackupDirectory = backDirectory; BackupDirectory = backDirectory;
@ -33,6 +35,7 @@ namespace BizHawk.Client.Common
?? throw new ArgumentNullException(paramName: nameof(pauseCallback)); ?? throw new ArgumentNullException(paramName: nameof(pauseCallback));
_modeChangedCallback = modeChangedCallback _modeChangedCallback = modeChangedCallback
?? throw new ArgumentNullException(paramName: nameof(modeChangedCallback)); ?? throw new ArgumentNullException(paramName: nameof(modeChangedCallback));
_movieEndSound = movieEndSound;
} }
public IMovieConfig Settings { get; } public IMovieConfig Settings { get; }
@ -396,6 +399,9 @@ namespace BizHawk.Client.Common
break; break;
} }
if (Settings.MovieEndAction is not MovieEndAction.Record && Settings.PlaySoundOnMovieEnd)
_movieEndSound?.Invoke();
_modeChangedCallback(); _modeChangedCallback();
} }
} }

View File

@ -84,10 +84,11 @@ namespace BizHawk.Client.EmuHawk
this.PlayMovieMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx(); this.PlayMovieMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.StopMovieMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx(); this.StopMovieMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.PlayFromBeginningMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx(); this.PlayFromBeginningMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.ImportMoviesMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.SaveMovieMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx(); this.SaveMovieMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.SaveMovieAsMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx(); this.SaveMovieAsMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.StopMovieWithoutSavingMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx(); this.StopMovieWithoutSavingMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.toolStripSeparator25 = new System.Windows.Forms.ToolStripSeparator();
this.ImportMoviesMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.toolStripSeparator14 = new BizHawk.WinForms.Controls.ToolStripSeparatorEx(); this.toolStripSeparator14 = new BizHawk.WinForms.Controls.ToolStripSeparatorEx();
this.AutomaticallyBackupMoviesMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx(); this.AutomaticallyBackupMoviesMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.FullMovieLoadstatesMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx(); this.FullMovieLoadstatesMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
@ -96,6 +97,8 @@ namespace BizHawk.Client.EmuHawk
this.MovieEndRecordMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx(); this.MovieEndRecordMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.MovieEndStopMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx(); this.MovieEndStopMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.MovieEndPauseMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx(); this.MovieEndPauseMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.toolStripSeparator32 = new System.Windows.Forms.ToolStripSeparator();
this.MovieEndPlaySoundMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.AVSubMenu = new BizHawk.WinForms.Controls.ToolStripMenuItemEx(); this.AVSubMenu = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.RecordAVMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx(); this.RecordAVMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.ConfigAndRecordAVMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx(); this.ConfigAndRecordAVMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
@ -375,7 +378,6 @@ namespace BizHawk.Client.EmuHawk
this.ShowMenuContextMenuSeparator = new BizHawk.WinForms.Controls.ToolStripSeparatorEx(); this.ShowMenuContextMenuSeparator = new BizHawk.WinForms.Controls.ToolStripSeparatorEx();
this.ShowMenuContextMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx(); this.ShowMenuContextMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.timerMouseIdle = new System.Windows.Forms.Timer(this.components); this.timerMouseIdle = new System.Windows.Forms.Timer(this.components);
this.toolStripSeparator25 = new System.Windows.Forms.ToolStripSeparator();
this.MainformMenu.SuspendLayout(); this.MainformMenu.SuspendLayout();
this.MainStatusBar.SuspendLayout(); this.MainStatusBar.SuspendLayout();
this.MainFormContextMenu.SuspendLayout(); this.MainFormContextMenu.SuspendLayout();
@ -771,11 +773,6 @@ namespace BizHawk.Client.EmuHawk
this.PlayFromBeginningMenuItem.Text = "Play from Beginning"; this.PlayFromBeginningMenuItem.Text = "Play from Beginning";
this.PlayFromBeginningMenuItem.Click += new System.EventHandler(this.PlayFromBeginningMenuItem_Click); this.PlayFromBeginningMenuItem.Click += new System.EventHandler(this.PlayFromBeginningMenuItem_Click);
// //
// ImportMoviesMenuItem
//
this.ImportMoviesMenuItem.Text = "Import Movies...";
this.ImportMoviesMenuItem.Click += new System.EventHandler(this.ImportMovieMenuItem_Click);
//
// SaveMovieMenuItem // SaveMovieMenuItem
// //
this.SaveMovieMenuItem.Text = "&Save Movie"; this.SaveMovieMenuItem.Text = "&Save Movie";
@ -791,6 +788,16 @@ namespace BizHawk.Client.EmuHawk
this.StopMovieWithoutSavingMenuItem.Text = "Stop Movie without Saving"; this.StopMovieWithoutSavingMenuItem.Text = "Stop Movie without Saving";
this.StopMovieWithoutSavingMenuItem.Click += new System.EventHandler(this.StopMovieWithoutSavingMenuItem_Click); this.StopMovieWithoutSavingMenuItem.Click += new System.EventHandler(this.StopMovieWithoutSavingMenuItem_Click);
// //
// toolStripSeparator25
//
this.toolStripSeparator25.Name = "toolStripSeparator25";
this.toolStripSeparator25.Size = new System.Drawing.Size(228, 6);
//
// ImportMoviesMenuItem
//
this.ImportMoviesMenuItem.Text = "Import Movies...";
this.ImportMoviesMenuItem.Click += new System.EventHandler(this.ImportMovieMenuItem_Click);
//
// AutomaticallyBackupMoviesMenuItem // AutomaticallyBackupMoviesMenuItem
// //
this.AutomaticallyBackupMoviesMenuItem.Text = "Automatically Backup Movies"; this.AutomaticallyBackupMoviesMenuItem.Text = "Automatically Backup Movies";
@ -807,7 +814,9 @@ namespace BizHawk.Client.EmuHawk
this.MovieEndFinishMenuItem, this.MovieEndFinishMenuItem,
this.MovieEndRecordMenuItem, this.MovieEndRecordMenuItem,
this.MovieEndStopMenuItem, this.MovieEndStopMenuItem,
this.MovieEndPauseMenuItem}); this.MovieEndPauseMenuItem,
this.toolStripSeparator32,
this.MovieEndPlaySoundMenuItem});
this.MovieEndSubMenu.Text = "On Movie End"; this.MovieEndSubMenu.Text = "On Movie End";
this.MovieEndSubMenu.DropDownOpened += new System.EventHandler(this.MovieEndSubMenu_DropDownOpened); this.MovieEndSubMenu.DropDownOpened += new System.EventHandler(this.MovieEndSubMenu_DropDownOpened);
// //
@ -831,6 +840,18 @@ namespace BizHawk.Client.EmuHawk
this.MovieEndPauseMenuItem.Text = "Pause"; this.MovieEndPauseMenuItem.Text = "Pause";
this.MovieEndPauseMenuItem.Click += new System.EventHandler(this.MovieEndPauseMenuItem_Click); this.MovieEndPauseMenuItem.Click += new System.EventHandler(this.MovieEndPauseMenuItem_Click);
// //
// toolStripSeparator32
//
this.toolStripSeparator32.Name = "toolStripSeparator32";
this.toolStripSeparator32.Size = new System.Drawing.Size(177, 6);
//
// MovieEndPlaySoundMenuItem
//
this.MovieEndPlaySoundMenuItem.Name = "MovieEndPlaySoundMenuItem";
this.MovieEndPlaySoundMenuItem.Size = new System.Drawing.Size(180, 22);
this.MovieEndPlaySoundMenuItem.Text = "Play sound";
this.MovieEndPlaySoundMenuItem.Click += new System.EventHandler(this.MovieEndPlaySoundMenuItem_Click);
//
// AVSubMenu // AVSubMenu
// //
this.AVSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.AVSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
@ -869,7 +890,7 @@ namespace BizHawk.Client.EmuHawk
// //
this.CaptureLuaMenuItem.CheckOnClick = true; this.CaptureLuaMenuItem.CheckOnClick = true;
this.CaptureLuaMenuItem.Name = "CaptureLuaMenuItem"; this.CaptureLuaMenuItem.Name = "CaptureLuaMenuItem";
this.CaptureLuaMenuItem.Size = new System.Drawing.Size(232, 22); this.CaptureLuaMenuItem.Size = new System.Drawing.Size(205, 22);
this.CaptureLuaMenuItem.Text = "Capture Lua"; this.CaptureLuaMenuItem.Text = "Capture Lua";
this.CaptureLuaMenuItem.Click += new System.EventHandler(this.CaptureLuaMenuItem_Click); this.CaptureLuaMenuItem.Click += new System.EventHandler(this.CaptureLuaMenuItem_Click);
// //
@ -986,7 +1007,7 @@ namespace BizHawk.Client.EmuHawk
this.WindowSizeSubMenu.Text = "&Window Size"; this.WindowSizeSubMenu.Text = "&Window Size";
this.WindowSizeSubMenu.DropDownOpened += new System.EventHandler(this.WindowSizeSubMenu_DropDownOpened); this.WindowSizeSubMenu.DropDownOpened += new System.EventHandler(this.WindowSizeSubMenu_DropDownOpened);
// //
// ResizeWithFramebufferMenuItem // DisableResizeWithFramebufferMenuItem
// //
this.DisableResizeWithFramebufferMenuItem.CheckOnClick = true; this.DisableResizeWithFramebufferMenuItem.CheckOnClick = true;
this.DisableResizeWithFramebufferMenuItem.Text = "&Static Size"; this.DisableResizeWithFramebufferMenuItem.Text = "&Static Size";
@ -2389,11 +2410,6 @@ namespace BizHawk.Client.EmuHawk
this.timerMouseIdle.Interval = 2000; this.timerMouseIdle.Interval = 2000;
this.timerMouseIdle.Tick += new System.EventHandler(this.TimerMouseIdle_Tick); this.timerMouseIdle.Tick += new System.EventHandler(this.TimerMouseIdle_Tick);
// //
// toolStripSeparator25
//
this.toolStripSeparator25.Name = "toolStripSeparator25";
this.toolStripSeparator25.Size = new System.Drawing.Size(228, 6);
//
// MainForm // MainForm
// //
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
@ -2779,5 +2795,7 @@ namespace BizHawk.Client.EmuHawk
private System.Windows.Forms.ToolStripSeparator toolStripSeparator25; private System.Windows.Forms.ToolStripSeparator toolStripSeparator25;
private ToolStripMenuItemEx DisableResizeWithFramebufferMenuItem; private ToolStripMenuItemEx DisableResizeWithFramebufferMenuItem;
private ToolStripSeparatorEx toolStripSeparator26; private ToolStripSeparatorEx toolStripSeparator26;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator32;
private System.Windows.Forms.ToolStripMenuItem MovieEndPlaySoundMenuItem;
} }
} }

View File

@ -183,6 +183,7 @@ namespace BizHawk.Client.EmuHawk
MovieEndRecordMenuItem.Checked = Config.Movies.MovieEndAction == MovieEndAction.Record; MovieEndRecordMenuItem.Checked = Config.Movies.MovieEndAction == MovieEndAction.Record;
MovieEndStopMenuItem.Checked = Config.Movies.MovieEndAction == MovieEndAction.Stop; MovieEndStopMenuItem.Checked = Config.Movies.MovieEndAction == MovieEndAction.Stop;
MovieEndPauseMenuItem.Checked = Config.Movies.MovieEndAction == MovieEndAction.Pause; MovieEndPauseMenuItem.Checked = Config.Movies.MovieEndAction == MovieEndAction.Pause;
MovieEndPlaySoundMenuItem.Checked = Config.Movies.PlaySoundOnMovieEnd;
} }
private void AVSubMenu_DropDownOpened(object sender, EventArgs e) private void AVSubMenu_DropDownOpened(object sender, EventArgs e)
@ -1625,5 +1626,12 @@ namespace BizHawk.Client.EmuHawk
private void FormDragDrop(object sender, DragEventArgs e) private void FormDragDrop(object sender, DragEventArgs e)
=> PathsFromDragDrop = (string[]) e.Data.GetData(DataFormats.FileDrop); => PathsFromDragDrop = (string[]) e.Data.GetData(DataFormats.FileDrop);
private void MovieEndPlaySoundMenuItem_Click(object sender, EventArgs e)
{
MovieEndPlaySoundMenuItem.Checked = !MovieEndPlaySoundMenuItem.Checked;
Config.Movies.PlaySoundOnMovieEnd = MovieEndPlaySoundMenuItem.Checked;
}
} }
} }

View File

@ -444,7 +444,8 @@ namespace BizHawk.Client.EmuHawk
Config.PathEntries.MovieBackupsAbsolutePath(), Config.PathEntries.MovieBackupsAbsolutePath(),
this, this,
PauseEmulator, PauseEmulator,
SetMainformMovieInfo); SetMainformMovieInfo,
() => Sound.PlayWavFile(Properties.Resources.GetNotHawkCallSFX(), Config.SoundVolume / 100f));
void MainForm_MouseClick(object sender, MouseEventArgs e) void MainForm_MouseClick(object sender, MouseEventArgs e)
{ {