Skip to content

Commit

Permalink
Fix version label
Browse files Browse the repository at this point in the history
  • Loading branch information
Lacyway committed Jun 13, 2024
1 parent ce165e6 commit ab7cb2d
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions Fika.Core/UI/Patches/FikaVersionLabel_Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,32 @@ namespace Fika.Core.EssentialPatches
/// </summary>
public class FikaVersionLabel_Patch : ModulePatch
{
private static string _versionLabel;
private static string versionLabel;

protected override MethodBase GetTargetMethod() => PatchConstants.EftTypes.Single(x => x.GetField("Taxonomy", BindingFlags.Public | BindingFlags.Instance) != null).GetMethod("Create", BindingFlags.Public | BindingFlags.Static);
protected override MethodBase GetTargetMethod()
{
return typeof(VersionNumberClass).GetMethod(nameof(VersionNumberClass.Create), BindingFlags.Static | BindingFlags.Public);
}

[PatchPostfix]
internal static void PatchPostfix(string major, object __result)
{
FikaPlugin.EFTVersionMajor = major;

if (string.IsNullOrEmpty(_versionLabel))
if (string.IsNullOrEmpty(versionLabel))
{
string json = RequestHandler.GetJson("/singleplayer/settings/version");
_versionLabel = Json.Deserialize<VersionResponse>(json).Version;
Logger.LogInfo($"Server version: {_versionLabel}");
versionLabel = Json.Deserialize<VersionResponse>(json).Version;
Logger.LogInfo($"Server version: {versionLabel}");
}

string fikaVersion = Assembly.GetAssembly(typeof(FikaVersionLabel_Patch)).GetName().Version.ToString();

Traverse preloaderUiTraverse = Traverse.Create(MonoBehaviourSingleton<PreloaderUI>.Instance);

preloaderUiTraverse.Field("_alphaVersionLabel").Property("LocalizationKey").SetValue("{0}");
preloaderUiTraverse.Field("string_2").SetValue($"Fika {fikaVersion} |");
Traverse.Create(__result).Field("Major").SetValue($"FIKA BETA {fikaVersion} | {_versionLabel}");
preloaderUiTraverse.Field("string_2").SetValue($"FIKA BETA {fikaVersion} | {versionLabel}");
Traverse.Create(__result).Field("Major").SetValue($"{fikaVersion} {versionLabel}");
}
}
}

0 comments on commit ab7cb2d

Please sign in to comment.