Skip to content

Commit

Permalink
Simplify About dialog audio playback
Browse files Browse the repository at this point in the history
  • Loading branch information
YoshiRulz committed Jun 19, 2024
1 parent 3490b54 commit a9df8b4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
1 change: 0 additions & 1 deletion src/BizHawk.Client.EmuHawk/BizBox.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 2 additions & 9 deletions src/BizHawk.Client.EmuHawk/BizBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<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)
Expand Down Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/BizHawk.Client.EmuHawk/MainForm.Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
4 changes: 4 additions & 0 deletions src/BizHawk.Client.EmuHawk/Properties/Resources.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Drawing;
using System.IO;
using System.Windows.Forms;

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

0 comments on commit a9df8b4

Please sign in to comment.