Simplify About dialog audio playback

This commit is contained in:
YoshiRulz 2024-06-20 04:13:47 +10:00
parent 3490b544b4
commit a9df8b40d7
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
4 changed files with 7 additions and 11 deletions

View File

@ -180,7 +180,6 @@
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();

View File

@ -5,23 +5,19 @@ using System.Windows.Forms;
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<byte[]> _playWavFileCallback;
public BizBox(Action<byte[]> 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 @@ namespace BizHawk.Client.EmuHawk
}
}
private void BizBox_Shown(object sender, EventArgs e)
=> _playWavFileCallback(_bizBoxSound);
private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
=> Process.Start((string) ((Control) sender).Tag);

View File

@ -2258,7 +2258,7 @@ namespace BizHawk.Client.EmuHawk
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);
}

View File

@ -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 @@ namespace BizHawk.Client.EmuHawk.Properties
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");
}
}