Move some version processing from About dialog to `VersionInfo`

This commit is contained in:
YoshiRulz 2024-06-20 03:39:42 +10:00
parent 90c79d2220
commit e5dc04dc37
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
2 changed files with 24 additions and 25 deletions

View File

@ -38,23 +38,9 @@ namespace BizHawk.Client.EmuHawk
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()))
{
@ -63,17 +49,13 @@ namespace BizHawk.Client.EmuHawk
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)
{
@ -81,8 +63,6 @@ namespace BizHawk.Client.EmuHawk
}
private void linkLabel3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Process.Start("https://github.com/TASEmulators/BizHawk/graphs/contributors");
}
=> Process.Start(VersionInfo.BizHawkContributorsListURI);
}
}

View File

@ -21,6 +21,8 @@ namespace BizHawk.Common
public static readonly string? CustomBuildString;
public static readonly string BizHawkContributorsListURI = "https://github.com/TASEmulators/BizHawk/graphs/contributors";
static VersionInfo()
{
var path = Path.Combine(
@ -38,8 +40,25 @@ namespace BizHawk.Common
}
}
public static (string Label, string TargetURI) GetGitCommitLink()
=> ($"Commit :{GIT_BRANCH}@{GIT_SHORTHASH}", $"https://github.com/TASEmulators/BizHawk/commit/{GIT_SHORTHASH}");
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)