mirror of
https://github.com/muskit/H3VR-TNH-Quality-of-Life-Improvements.git
synced 2026-08-02 00:20:41 -07:00
remove joke func. that kills the long-deprecated "Leaderboard Player Count" mod; clean up logging
This commit is contained in:
@@ -70,11 +70,6 @@ public static AssetBundle bundle;
|
|||||||
// Take and Hold modifications
|
// Take and Hold modifications
|
||||||
private static InPlay playInstance;
|
private static InPlay playInstance;
|
||||||
|
|
||||||
// Searching for old leaderboards player count mod to disable
|
|
||||||
private float lpcSearchTime;
|
|
||||||
private bool lpcStopSearching = false;
|
|
||||||
private float lpcModSearchTimeEnd;
|
|
||||||
|
|
||||||
public static FVRHealthBar hpDisplay;
|
public static FVRHealthBar hpDisplay;
|
||||||
|
|
||||||
// toggle HP visibility from wrist menu
|
// toggle HP visibility from wrist menu
|
||||||
@@ -91,7 +86,7 @@ public static AssetBundle bundle;
|
|||||||
private IEnumerator SceneChangedCoroutine()
|
private IEnumerator SceneChangedCoroutine()
|
||||||
{
|
{
|
||||||
Destroy(playInstance);
|
Destroy(playInstance);
|
||||||
for (int i = 0; i < 11; ++i)
|
for (int i = 1; i <= 10; ++i)
|
||||||
{
|
{
|
||||||
// TNH patches
|
// TNH patches
|
||||||
if (GameObject.Find("_GameManager") != null || FindObjectOfType<TNH_Manager>() != null)
|
if (GameObject.Find("_GameManager") != null || FindObjectOfType<TNH_Manager>() != null)
|
||||||
@@ -101,12 +96,9 @@ public static AssetBundle bundle;
|
|||||||
playerCamera = GameObject.FindGameObjectWithTag("MainCamera");
|
playerCamera = GameObject.FindGameObjectWithTag("MainCamera");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
// Logger.LogInfo(String.Format("Couldn't find a TNH game. Checking again...({0}/10)", i));
|
||||||
{
|
|
||||||
Logger.LogInfo(String.Format("Couldn't find a TNH game. Trying again...({0}/10)", i+1));
|
|
||||||
yield return new WaitForEndOfFrame();
|
yield return new WaitForEndOfFrame();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (playInstance == null)
|
if (playInstance == null)
|
||||||
{
|
{
|
||||||
@@ -162,7 +154,6 @@ public static AssetBundle bundle;
|
|||||||
public MeatKitPlugin(): base()
|
public MeatKitPlugin(): base()
|
||||||
{
|
{
|
||||||
harmony = new Harmony("muskit.TNHQualityOfLifeImprovements");
|
harmony = new Harmony("muskit.TNHQualityOfLifeImprovements");
|
||||||
lpcSearchTime = 30f + 30f * Mathf.Sin(System.DateTime.Today.DayOfYear / 365f); // lolz
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// You are free to edit this method, however please ensure LoadAssets is still called somewhere inside it.
|
// You are free to edit this method, however please ensure LoadAssets is still called somewhere inside it.
|
||||||
@@ -245,9 +236,6 @@ public static AssetBundle bundle;
|
|||||||
HealthExpireIndicationType.Flashing,
|
HealthExpireIndicationType.Flashing,
|
||||||
"Add a visual indication on the Health Crystal's despawn timer.");
|
"Add a visual indication on the Health Crystal's despawn timer.");
|
||||||
|
|
||||||
// calculate end time to search for my deprecated Leaderboard
|
|
||||||
lpcModSearchTimeEnd = Time.time + lpcSearchTime;
|
|
||||||
|
|
||||||
wmbHPToggle = new WristMenuButton("Toggle HP Display", ToggleHPVisibility);
|
wmbHPToggle = new WristMenuButton("Toggle HP Display", ToggleHPVisibility);
|
||||||
|
|
||||||
RunPatches();
|
RunPatches();
|
||||||
@@ -296,30 +284,6 @@ public static AssetBundle bundle;
|
|||||||
hpDisplay.gameObject.SetActive(hpDisplayEnabled);
|
hpDisplay.gameObject.SetActive(hpDisplayEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Its only purpose: to kill the deprecated TNH Leaderboard Player Count mod.
|
|
||||||
/// </summary>
|
|
||||||
private void Update()
|
|
||||||
{
|
|
||||||
if (lpcStopSearching)
|
|
||||||
return;
|
|
||||||
|
|
||||||
foreach (var plugin in Chainloader.PluginInfos)
|
|
||||||
{
|
|
||||||
if (plugin.Key == "me.muskit.tnhLeaderboardPlayerCount")
|
|
||||||
{
|
|
||||||
Logger.LogWarning("TNH Leaderboard Player Count mod detected. Destroying it to avoid interference.");
|
|
||||||
Destroy(plugin.Value.Instance);
|
|
||||||
lpcStopSearching = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Time.realtimeSinceStartup >= lpcModSearchTimeEnd)
|
|
||||||
{
|
|
||||||
Logger.LogInfo(string.Format("Stopping search for TNH Leaderboard Player Count mod after {0} seconds.", lpcSearchTime));
|
|
||||||
lpcStopSearching = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// DO NOT CHANGE OR REMOVE THIS METHOD. It's contents will be overwritten when building your package.
|
// DO NOT CHANGE OR REMOVE THIS METHOD. It's contents will be overwritten when building your package.
|
||||||
private void LoadAssets()
|
private void LoadAssets()
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using BepInEx.Bootstrap;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using FistVR;
|
using FistVR;
|
||||||
@@ -15,26 +14,21 @@ namespace TNHQoLImprovements
|
|||||||
private bool tnhTweakerInstalled = false;
|
private bool tnhTweakerInstalled = false;
|
||||||
|
|
||||||
private string curID;
|
private string curID;
|
||||||
private string loadingStr;
|
|
||||||
|
|
||||||
private TNH_ScoreDisplay scoreDisplay;
|
private TNH_ScoreDisplay scoreDisplay;
|
||||||
private Text lblGlobalScores;
|
private Text lblGlobalScores;
|
||||||
private GameObject gObjLoading;
|
|
||||||
|
|
||||||
#region INITIALIZATION
|
#region INITIALIZATION
|
||||||
public void Init(TNH_ScoreDisplay tnhScore, Text scoreLabel, GameObject gObjLoading)
|
public void Init(TNH_ScoreDisplay tnhScore, Text scoreLabel)
|
||||||
{
|
{
|
||||||
if (initialized)
|
if (initialized)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// don't run with TNHTweaker installed
|
// don't run with TNHTweaker installed
|
||||||
this.gObjLoading = gObjLoading;
|
|
||||||
var loadedAssemblies = System.AppDomain.CurrentDomain.GetAssemblies();
|
var loadedAssemblies = System.AppDomain.CurrentDomain.GetAssemblies();
|
||||||
if (Array.Exists<Assembly>(loadedAssemblies, x => x.GetName().Name == "TakeAndHoldTweaker"))
|
if (Array.Exists<Assembly>(loadedAssemblies, x => x.GetName().Name == "TakeAndHoldTweaker"))
|
||||||
{
|
{
|
||||||
tnhTweakerInstalled = true;
|
tnhTweakerInstalled = true;
|
||||||
this.gObjLoading.transform.GetChild(0).GetComponent<Text>().text = "<color=lightblue><size=30>Online leaderboards player count unavailable for TNHTweaker.</size></color>";
|
|
||||||
this.gObjLoading.SetActive(true);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,9 +36,6 @@ namespace TNHQoLImprovements
|
|||||||
this.lblGlobalScores = scoreLabel;
|
this.lblGlobalScores = scoreLabel;
|
||||||
this.lblGlobalScores.resizeTextForBestFit = true;
|
this.lblGlobalScores.resizeTextForBestFit = true;
|
||||||
this.lblGlobalScores.horizontalOverflow = HorizontalWrapMode.Overflow;
|
this.lblGlobalScores.horizontalOverflow = HorizontalWrapMode.Overflow;
|
||||||
loadingStr = gObjLoading.GetComponentInChildren<Text>().text;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
initialized = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
@@ -71,20 +62,16 @@ namespace TNHQoLImprovements
|
|||||||
|
|
||||||
lblGlobalScores.text = "Global Scores: <color=lightblue>(" + playerCountText + " players)</color>";
|
lblGlobalScores.text = "Global Scores: <color=lightblue>(" + playerCountText + " players)</color>";
|
||||||
curID = id;
|
curID = id;
|
||||||
gObjLoading.SetActive(false);
|
|
||||||
}
|
}
|
||||||
catch (KeyNotFoundException e)
|
catch (KeyNotFoundException e)
|
||||||
{
|
{
|
||||||
lblGlobalScores.text = "Global Scores:";
|
lblGlobalScores.text = "Global Scores:";
|
||||||
gObjLoading.GetComponentInChildren<Text>().text = loadingStr;
|
|
||||||
gObjLoading.SetActive(true);
|
|
||||||
curID = null;
|
curID = null;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
gObjLoading.GetComponentInChildren<Text>().text = string.Format("<color=lightblue><size=30>Unknown error occured trying to retrieve online player count.</size></color>\n" +
|
MeatKitPlugin.Logger.LogWarning("Unknown error occurred trying to retrieve online player count.");
|
||||||
"<color=red>{0}</color>", e);
|
MeatKitPlugin.Logger.LogWarning(e);
|
||||||
gObjLoading.SetActive(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ namespace TNHQoLImprovements
|
|||||||
{
|
{
|
||||||
public static class LeaderboardPlayerCountPatch
|
public static class LeaderboardPlayerCountPatch
|
||||||
{
|
{
|
||||||
private static GameObject gObjLoading;
|
|
||||||
private static Text uiGlobalText;
|
private static Text uiGlobalText;
|
||||||
|
|
||||||
public static void Patch(Harmony harmony)
|
public static void Patch(Harmony harmony)
|
||||||
@@ -22,29 +21,18 @@ namespace TNHQoLImprovements
|
|||||||
public static void Setup(TNH_ScoreDisplay __instance)
|
public static void Setup(TNH_ScoreDisplay __instance)
|
||||||
{
|
{
|
||||||
GameObject gObjLeaderboard = null;
|
GameObject gObjLeaderboard = null;
|
||||||
gObjLoading = GameObject.Instantiate(MeatKitPlugin.bundle.LoadAsset<GameObject>("PlayerCount_LoadingText"));
|
|
||||||
if (__instance.gameObject.name == "_MainMenu") // lobby
|
if (__instance.gameObject.name == "_MainMenu") // lobby
|
||||||
{
|
{
|
||||||
gObjLeaderboard = __instance.transform.GetChild(3).gameObject; // MainMenuCanvas_RightFar
|
gObjLeaderboard = __instance.transform.GetChild(3).gameObject; // MainMenuCanvas_RightFar
|
||||||
gObjLoading.transform.SetParent(gObjLeaderboard.transform, false);
|
|
||||||
gObjLoading.GetComponent<RectTransform>().pivot = new Vector2(0, 1);
|
|
||||||
gObjLoading.transform.localPosition = new Vector3(520, 380, 0);
|
|
||||||
gObjLoading.transform.GetChild(0).GetComponent<Text>().alignment = TextAnchor.UpperLeft;
|
|
||||||
}
|
}
|
||||||
if (__instance.gameObject.name == "_FinalScoreDisplay(Clone)") // game over room
|
if (__instance.gameObject.name == "_FinalScoreDisplay(Clone)") // game over room
|
||||||
{
|
{
|
||||||
gObjLeaderboard = __instance.transform.GetChild(0).gameObject; // ScoreCanvas_PastScores
|
gObjLeaderboard = __instance.transform.GetChild(0).gameObject; // ScoreCanvas_PastScores
|
||||||
gObjLoading.transform.SetParent(gObjLeaderboard.transform, false);
|
|
||||||
gObjLoading.GetComponent<RectTransform>().pivot = new Vector2(1, 1);
|
|
||||||
gObjLoading.transform.localPosition = new Vector3(-520, 380, 0);
|
|
||||||
gObjLoading.transform.GetChild(0).GetComponent<Text>().alignment = TextAnchor.UpperRight;
|
|
||||||
}
|
}
|
||||||
uiGlobalText = gObjLeaderboard.transform.GetChild(0).GetChild(2).GetComponent<Text>();
|
uiGlobalText = gObjLeaderboard.transform.GetChild(0).GetChild(2).GetComponent<Text>();
|
||||||
gObjLoading.transform.rotation = gObjLeaderboard.transform.rotation;
|
|
||||||
gObjLoading.transform.GetChild(0).GetComponent<Text>().font = uiGlobalText.font;
|
|
||||||
|
|
||||||
var playerCountComponent = gObjLeaderboard.AddComponent<LeaderboardPlayerCount>();
|
var playerCountComponent = gObjLeaderboard.AddComponent<LeaderboardPlayerCount>();
|
||||||
playerCountComponent.Init(__instance, uiGlobalText, gObjLoading);
|
playerCountComponent.Init(__instance, uiGlobalText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user