feat: show client structs hash in Game submenu

This commit is contained in:
goaaats 2021-12-05 02:08:43 +01:00
parent 9588e12619
commit 6a977fb59e
No known key found for this signature in database
GPG key ID: F18F057873895461
4 changed files with 33 additions and 3 deletions

View file

@ -105,16 +105,22 @@
<PropertyGroup>
<!-- temp file for the git version (lives in "obj" folder)-->
<VerFile>$(IntermediateOutputPath)gitver</VerFile>
<VerFileClientStructs>$(IntermediateOutputPath)csver</VerFileClientStructs>
</PropertyGroup>
<!-- write the hash to the temp file.-->
<Exec Command="git -C &quot;$(ProjectDir.Replace('\','\\'))&quot; describe --long --always --dirty &gt; $(VerFile)" />
<Exec Command="git -C &quot;$(ProjectDir.Replace('\','\\'))\..\lib\FFXIVClientStructs&quot; describe --long --always --dirty &gt; $(VerFileClientStructs)" />
<!-- read the version into the GitVersion itemGroup-->
<ReadLinesFromFile File="$(VerFile)">
<Output TaskParameter="Lines" ItemName="GitVersion" />
</ReadLinesFromFile>
<ReadLinesFromFile File="$(VerFileClientStructs)">
<Output TaskParameter="Lines" ItemName="GitVersionClientStructs" />
</ReadLinesFromFile>
<!-- Set the BuildHash property to contain the GitVersion, if it wasn't already set.-->
<PropertyGroup>
<BuildHash>@(GitVersion)</BuildHash>
<BuildHashClientStructs>@(GitVersionClientStructs)</BuildHashClientStructs>
</PropertyGroup>
</Target>
<Target Name="WriteGitHash" BeforeTargets="CoreCompile">
@ -132,6 +138,10 @@
<_Parameter1>GitHash</_Parameter1>
<_Parameter2>$(BuildHash)</_Parameter2>
</AssemblyAttributes>
<AssemblyAttributes Include="AssemblyMetadata">
<_Parameter1>GitHashClientStructs</_Parameter1>
<_Parameter2>$(BuildHashClientStructs)</_Parameter2>
</AssemblyAttributes>
</ItemGroup>
<!-- writes the attribute to the customAssemblyInfo file -->
<WriteCodeFragment Language="C#" OutputFile="$(CustomAssemblyInfoFile)" AssemblyAttributes="@(AssemblyAttributes)" />

View file

@ -14,7 +14,7 @@ namespace Dalamud.Game.Network.Structures
}
/// <summary>
/// Category of this ResultDialog packet.
/// Gets the category of this ResultDialog packet.
/// </summary>
public uint Category { get; private set; }

View file

@ -507,6 +507,7 @@ namespace Dalamud.Interface.Internal
var startInfo = Service<DalamudStartInfo>.Get();
ImGui.MenuItem(Util.AssemblyVersion, false);
ImGui.MenuItem(startInfo.GameVersion.ToString(), false);
ImGui.MenuItem($"CS: {Util.GetGitHashClientStructs()}", false);
ImGui.EndMenu();
}

View file

@ -22,7 +22,8 @@ namespace Dalamud.Utility
/// </summary>
public static class Util
{
private static string gitHashInternal;
private static string? gitHashInternal;
private static string? gitHashClientStructsInternal;
/// <summary>
/// Gets an httpclient for usage.
@ -48,11 +49,29 @@ namespace Dalamud.Utility
var asm = typeof(Util).Assembly;
var attrs = asm.GetCustomAttributes<AssemblyMetadataAttribute>();
gitHashInternal = attrs.FirstOrDefault(a => a.Key == "GitHash")?.Value;
gitHashInternal = attrs.First(a => a.Key == "GitHash").Value;
return gitHashInternal;
}
/// <summary>
/// Gets the git hash value from the assembly
/// or null if it cannot be found.
/// </summary>
/// <returns>The git hash of the assembly.</returns>
public static string GetGitHashClientStructs()
{
if (gitHashClientStructsInternal != null)
return gitHashClientStructsInternal;
var asm = typeof(Util).Assembly;
var attrs = asm.GetCustomAttributes<AssemblyMetadataAttribute>();
gitHashClientStructsInternal = attrs.First(a => a.Key == "GitHashClientStructs").Value;
return gitHashClientStructsInternal;
}
/// <summary>
/// Read memory from an offset and hexdump them via Serilog.
/// </summary>