Skip to content

Commit

Permalink
Merge branch 'TASEmulators:master' into add-gameboy-memory-callback-v…
Browse files Browse the repository at this point in the history
…alues
  • Loading branch information
roydmerkel authored Jun 19, 2024
2 parents 6311d2d + a9df8b4 commit c670022
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void Execute(GeneratorExecutionContext context)

var rev = ExecuteGitWithArguments($"-C {projectDir} rev-list HEAD --count") ?? string.Empty;
var branch = ExecuteGitWithArguments($"-C {projectDir} rev-parse --abbrev-ref HEAD") ?? "master";
var shortHash = ExecuteGitWithArguments($"-C {projectDir} log -1 --format=\"%h\"") ?? "000000000";
var hash = ExecuteGitWithArguments($"-C {projectDir} log -1 --format=\"%H\"") ?? "0000000000000000000000000000000000000000";

// Generated source code
string source = $@"namespace BizHawk.Common
Expand All @@ -58,7 +58,8 @@ public static partial class VersionInfo
{{
public const string SVN_REV = ""{rev}"";
public const string GIT_BRANCH = ""{branch}"";
public const string GIT_SHORTHASH = ""{shortHash}"";
public const string GIT_HASH = ""{hash}"";
public const string GIT_SHORTHASH = ""{hash.Substring(startIndex: 0, length: 9)}"";
}}
}}
";
Expand Down
Binary file modified References/BizHawk.SrcGen.VersionInfo.dll
Binary file not shown.
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.

43 changes: 7 additions & 36 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 All @@ -38,23 +34,9 @@ private void OK_Click(object sender, EventArgs e)
private void BizBox_Load(object sender, EventArgs e)
{
DeveloperBuildLabel.Visible = VersionInfo.DeveloperBuild;

#if true //TODO prepare for re-adding x86 and adding ARM/RISC-V
const string targetArch = "x64";
#else
var targetArch = IntPtr.Size is 8 ? "x64" : "x86";
#endif
#if DEBUG
const string buildConfig = "Debug";
#else
const string buildConfig = "Release";
#endif
VersionLabel.Text = $"Version {VersionInfo.MainVersion}";
VersionLabel.Text += VersionInfo.DeveloperBuild
? $" — dev build ({buildConfig}, {targetArch})"
: $" ({targetArch})";
VersionLabel.Text = VersionInfo.GetFullVersionDetails();
DateLabel.Text = VersionInfo.ReleaseDate;

(linkLabel2.Text, linkLabel2.Tag) = VersionInfo.GetGitCommitLink();
foreach (var core in CoreInventory.Instance.SystemsFlat.Where(core => core.CoreAttr.Released)
.OrderByDescending(core => core.Name.ToLowerInvariant()))
{
Expand All @@ -63,26 +45,15 @@ private void BizBox_Load(object sender, EventArgs e)
Dock = DockStyle.Top
});
}

linkLabel2.Text = $"Commit :{VersionInfo.GIT_BRANCH}@{VersionInfo.GIT_SHORTHASH}";
}

private void BizBox_Shown(object sender, EventArgs e)
=> _playWavFileCallback(_bizBoxSound);

private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Process.Start($"https://github.com/TASEmulators/BizHawk/commit/{VersionInfo.GIT_SHORTHASH}");
}
=> Process.Start((string) ((Control) sender).Tag);

private void btnCopyHash_Click(object sender, EventArgs e)
{
Clipboard.SetText(VersionInfo.GIT_SHORTHASH);
}
=> Clipboard.SetText(VersionInfo.GIT_HASH);

private void linkLabel3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Process.Start("https://github.com/TASEmulators/BizHawk/graphs/contributors");
}
=> Process.Start(VersionInfo.BizHawkContributorsListURI);
}
}
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");
}
}
21 changes: 20 additions & 1 deletion src/BizHawk.Common/VersionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public static partial class VersionInfo

public static readonly string? CustomBuildString;

public static readonly string BizHawkContributorsListURI = "https://github.com/TASEmulators/BizHawk/graphs/contributors";

static VersionInfo()
{
var path = Path.Combine(
Expand All @@ -38,8 +40,25 @@ static VersionInfo()
}
}

public static (string Label, string TargetURI) GetGitCommitLink()
=> ($"Commit :{GIT_BRANCH}@{GIT_SHORTHASH}", $"https://github.com/TASEmulators/BizHawk/commit/{GIT_HASH}");

public static string GetFullVersionDetails()
{
//TODO prepare for AArch64/RISC-V
var targetArch = UIntPtr.Size is 8 ? "x64" : "x86";
#if DEBUG
const string buildConfig = "Debug";
#else
const string buildConfig = "Release";
#endif
return DeveloperBuild
? $"Version {MainVersion} — dev build ({buildConfig}, {targetArch})"
: $"Version {MainVersion} ({targetArch})";
}

public static string GetEmuVersion()
=> DeveloperBuild ? $"GIT {GIT_BRANCH}#{GIT_SHORTHASH}" : $"Version {MainVersion}";
=> DeveloperBuild ? $"GIT {GIT_BRANCH}#{GIT_SHORTHASH}" : $"Version {MainVersion}"; // intentionally leaving '#' here to differentiate it from the "proper" one in `Help` > `About...` --yoshi

/// <summary>"2.5.1" => 0x02050100</summary>
public static uint VersionStrToInt(string s)
Expand Down

0 comments on commit c670022

Please sign in to comment.