From 640245cdd5c9e1f2a19481b705d07aa7b8239d05 Mon Sep 17 00:00:00 2001 From: msk <15199219+muskit@users.noreply.github.com> Date: Sun, 30 Jan 2022 14:41:03 -0800 Subject: [PATCH] fixed wave counter's lack of font --- Assets/MeatKit/BuildProfile.asset | 2 +- Assets/MeatKit/MeatKitPlugin.cs | 12 ++++++++++-- Assets/README.md | 7 +++++-- Assets/_Scripts/LeaderboardPlayerCount.cs | 24 +++++++++++++---------- Assets/_Scripts/WaveCounter.cs | 3 ++- 5 files changed, 32 insertions(+), 16 deletions(-) diff --git a/Assets/MeatKit/BuildProfile.asset b/Assets/MeatKit/BuildProfile.asset index afcbe6f..e4b0bd4 100644 --- a/Assets/MeatKit/BuildProfile.asset +++ b/Assets/MeatKit/BuildProfile.asset @@ -13,7 +13,7 @@ MonoBehaviour: m_EditorClassIdentifier: PackageName: TNH_Quality_of_Life_Improvements Author: muskit - Version: 1.1.0 + Version: 1.1.1 Icon: {fileID: 2800000, guid: 785b7946398f5314b95bf593d2d77d67, type: 3} ReadMe: {fileID: 102900000, guid: ab1d6dea017447a48ac348db588a6f35, type: 3} WebsiteURL: https://github.com/muskit/TNH-Quality-of-Life-Improvements diff --git a/Assets/MeatKit/MeatKitPlugin.cs b/Assets/MeatKit/MeatKitPlugin.cs index 886758f..01ac577 100644 --- a/Assets/MeatKit/MeatKitPlugin.cs +++ b/Assets/MeatKit/MeatKitPlugin.cs @@ -88,9 +88,16 @@ public class MeatKitPlugin : BaseUnityPlugin HPReadability.ImproveHPTextReadability(healthCounter.transform.GetChild(0).gameObject); } - // grab Agency FB from game if it's not set - if(fontAgencyFB == null) + GetFonts(); + } + + // called on scene change, find fonts from game if they're not set + private void GetFonts() + { + // Agency FB + if (fontAgencyFB == null) { + var healthCounter = FindObjectOfType(); if (healthCounter != null) { fontAgencyFB = healthCounter.transform.GetChild(0).GetChild(0).GetComponent().font; @@ -108,6 +115,7 @@ public class MeatKitPlugin : BaseUnityPlugin } } } + } public MeatKitPlugin(): base() diff --git a/Assets/README.md b/Assets/README.md index 3874511..ae3acf0 100644 --- a/Assets/README.md +++ b/Assets/README.md @@ -18,7 +18,10 @@ Toggle and customize these features in your mod manager's *Config editor*. For any issues/ideas, please create an issue on the GitHub repo (linked on Thunderstore page). ## Changelog -1.1.0 +1.1.1 +* Fixed wave counter text not showing up during a hold + +**1.1.0** * [TNH] Added win/lose count on hold counter * [TNH] Added enemy waves counter (substitutes token counter during hold if enabled) * [TNH] Added token numerical representation to shop @@ -34,7 +37,7 @@ For any issues/ideas, please create an issue on the GitHub repo (linked on Thund * Searching for the deprecated TNH Leaderboards Player Count mod to kill now stops after 120s -1.0.0 +**1.0.0** * Initial release! **NOTE: [*TNH Leaderboard Player Count*](https://h3vr.thunderstore.io/package/muskit/TNH_Leaderboard_Player_Count/) has been merged with this mod. If installed, please remove that mod as it lacks features and is no longer supported.** \ No newline at end of file diff --git a/Assets/_Scripts/LeaderboardPlayerCount.cs b/Assets/_Scripts/LeaderboardPlayerCount.cs index 428f8c6..dce7e3f 100644 --- a/Assets/_Scripts/LeaderboardPlayerCount.cs +++ b/Assets/_Scripts/LeaderboardPlayerCount.cs @@ -27,20 +27,24 @@ namespace TNHQoLImprovements if (initialized) return; - this.scoreDisplay = tnhScore; + // don't run with TNHTweaker installed + this.gObjLoading = gObjLoading; + var loadedAssemblies = System.AppDomain.CurrentDomain.GetAssemblies(); + if (Array.Exists(loadedAssemblies, x => x.GetName().Name == "TakeAndHoldTweaker")) + { + tnhTweakerInstalled = true; + this.gObjLoading.transform.GetChild(0).GetComponent().text = "Online player count is incompatible with TNHTweaker."; + this.gObjLoading.SetActive(true); + return; + } + + this.scoreDisplay = tnhScore; this.lblGlobalScores = scoreLabel; this.lblGlobalScores.resizeTextForBestFit = true; this.lblGlobalScores.horizontalOverflow = HorizontalWrapMode.Overflow; - this.gObjLoading = gObjLoading; loadingStr = gObjLoading.GetComponentInChildren().text; - var loadedAssemblies = System.AppDomain.CurrentDomain.GetAssemblies(); - if (Array.Exists(loadedAssemblies, x => x.GetName().Name == "TakeAndHoldTweaker")) - { - tnhTweakerInstalled = true; - this.gObjLoading.transform.GetChild(0).GetComponent().text = "Online player count is incompatible with TNHTweaker."; - this.gObjLoading.SetActive(true); - } + initialized = true; } @@ -78,7 +82,7 @@ namespace TNHQoLImprovements } catch (Exception e) { - gObjLoading.GetComponentInChildren().text = string.Format("Unknown error occured trying to retrieve online player count.\n\n" + + gObjLoading.GetComponentInChildren().text = string.Format("Unknown error occured trying to retrieve online player count.\n" + "{0}", e); gObjLoading.SetActive(true); } diff --git a/Assets/_Scripts/WaveCounter.cs b/Assets/_Scripts/WaveCounter.cs index effdab6..735d7c2 100644 --- a/Assets/_Scripts/WaveCounter.cs +++ b/Assets/_Scripts/WaveCounter.cs @@ -16,7 +16,9 @@ namespace TNHQoLImprovements // Use this for initialization void Start() { + transform.GetChild(0).GetComponent().font = MeatKitPlugin.fontAgencyFB; text = transform.GetChild(1).GetComponent(); + text.font = MeatKitPlugin.fontAgencyFB; } // Update is called once per frame @@ -27,7 +29,6 @@ namespace TNHQoLImprovements if(!ReferenceEquals(curHoldPoint, InPlay.tnhManager.m_curHoldPoint)) { - Debug.Log("Hold point updated!"); curHoldPoint = InPlay.tnhManager.m_curHoldPoint; trCurPhaseIdx = Traverse.Create(curHoldPoint).Field("m_phaseIndex"); trMaxPhases = Traverse.Create(curHoldPoint).Field("m_maxPhases");