From a9df8b40d7528b7cab4f23ff6ca9394457969acb Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Thu, 20 Jun 2024 04:13:47 +1000 Subject: [PATCH] Simplify About dialog audio playback --- src/BizHawk.Client.EmuHawk/BizBox.Designer.cs | 1 - src/BizHawk.Client.EmuHawk/BizBox.cs | 11 ++--------- src/BizHawk.Client.EmuHawk/MainForm.Events.cs | 2 +- src/BizHawk.Client.EmuHawk/Properties/Resources.cs | 4 ++++ 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/BizHawk.Client.EmuHawk/BizBox.Designer.cs b/src/BizHawk.Client.EmuHawk/BizBox.Designer.cs index 560e88b544e..bd72bd337ab 100644 --- a/src/BizHawk.Client.EmuHawk/BizBox.Designer.cs +++ b/src/BizHawk.Client.EmuHawk/BizBox.Designer.cs @@ -180,7 +180,6 @@ private void InitializeComponent() this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "About EmuHawk"; this.Load += new System.EventHandler(this.BizBox_Load); - this.Shown += new System.EventHandler(this.BizBox_Shown); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); diff --git a/src/BizHawk.Client.EmuHawk/BizBox.cs b/src/BizHawk.Client.EmuHawk/BizBox.cs index d0c1b638fc1..ef4819dc6d6 100644 --- a/src/BizHawk.Client.EmuHawk/BizBox.cs +++ b/src/BizHawk.Client.EmuHawk/BizBox.cs @@ -5,23 +5,19 @@ using BizHawk.Client.EmuHawk.Properties; using BizHawk.Common; -using BizHawk.Common.IOExtensions; using BizHawk.Emulation.Cores; namespace BizHawk.Client.EmuHawk { public partial class BizBox : Form { - private static readonly byte[] _bizBoxSound = ReflectionCache.EmbeddedResourceStream("Resources.nothawk.wav").ReadAllBytes(); - private readonly Action _playWavFileCallback; - - public BizBox(Action playWavFileCallback) + public BizBox(Action/*?*/ playNotHawkCallSFX = null) { InitializeComponent(); Icon = Resources.Logo; pictureBox1.Image = Resources.CorpHawk; btnCopyHash.Image = Resources.Duplicate; - _playWavFileCallback = playWavFileCallback; + if (playNotHawkCallSFX is not null) Shown += (_, _) => playNotHawkCallSFX(); } private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) @@ -51,9 +47,6 @@ private void BizBox_Load(object sender, EventArgs e) } } - private void BizBox_Shown(object sender, EventArgs e) - => _playWavFileCallback(_bizBoxSound); - private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) => Process.Start((string) ((Control) sender).Tag); diff --git a/src/BizHawk.Client.EmuHawk/MainForm.Events.cs b/src/BizHawk.Client.EmuHawk/MainForm.Events.cs index a797352d11f..d4219a624cc 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.Events.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.Events.cs @@ -2258,7 +2258,7 @@ private void FeaturesMenuItem_Click(object sender, EventArgs e) private void AboutMenuItem_Click(object sender, EventArgs e) { - using var form = new BizBox(b => Sound.PlayWavFile(new MemoryStream(b, false), 1)); + using BizBox form = new(() => Sound.PlayWavFile(Properties.Resources.GetNotHawkCallSFX(), atten: 1.0f)); this.ShowDialogWithTempMute(form); } diff --git a/src/BizHawk.Client.EmuHawk/Properties/Resources.cs b/src/BizHawk.Client.EmuHawk/Properties/Resources.cs index c406b7c0743..33002996784 100644 --- a/src/BizHawk.Client.EmuHawk/Properties/Resources.cs +++ b/src/BizHawk.Client.EmuHawk/Properties/Resources.cs @@ -1,5 +1,6 @@ using System; using System.Drawing; +using System.IO; using System.Windows.Forms; namespace BizHawk.Client.EmuHawk.Properties @@ -211,5 +212,8 @@ internal static class Resources internal static readonly Bitmap YellowLeft = ReadEmbeddedBitmap("YellowLeft"); internal static readonly Bitmap YellowRight = ReadEmbeddedBitmap("YellowRight"); internal static readonly Bitmap YellowUp = ReadEmbeddedBitmap("YellowUp"); + + internal static Stream GetNotHawkCallSFX() + => EmuHawk.ReflectionCache.EmbeddedResourceStream("Resources.nothawk.wav"); } }