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:
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using BepInEx.Bootstrap;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using FistVR;
|
||||
@@ -15,26 +14,21 @@ namespace TNHQoLImprovements
|
||||
private bool tnhTweakerInstalled = false;
|
||||
|
||||
private string curID;
|
||||
private string loadingStr;
|
||||
|
||||
private TNH_ScoreDisplay scoreDisplay;
|
||||
private Text lblGlobalScores;
|
||||
private GameObject gObjLoading;
|
||||
|
||||
#region INITIALIZATION
|
||||
public void Init(TNH_ScoreDisplay tnhScore, Text scoreLabel, GameObject gObjLoading)
|
||||
public void Init(TNH_ScoreDisplay tnhScore, Text scoreLabel)
|
||||
{
|
||||
if (initialized)
|
||||
return;
|
||||
|
||||
// don't run with TNHTweaker installed
|
||||
this.gObjLoading = gObjLoading;
|
||||
var loadedAssemblies = System.AppDomain.CurrentDomain.GetAssemblies();
|
||||
if (Array.Exists<Assembly>(loadedAssemblies, x => x.GetName().Name == "TakeAndHoldTweaker"))
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -42,9 +36,6 @@ namespace TNHQoLImprovements
|
||||
this.lblGlobalScores = scoreLabel;
|
||||
this.lblGlobalScores.resizeTextForBestFit = true;
|
||||
this.lblGlobalScores.horizontalOverflow = HorizontalWrapMode.Overflow;
|
||||
loadingStr = gObjLoading.GetComponentInChildren<Text>().text;
|
||||
|
||||
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
@@ -71,20 +62,16 @@ namespace TNHQoLImprovements
|
||||
|
||||
lblGlobalScores.text = "Global Scores: <color=lightblue>(" + playerCountText + " players)</color>";
|
||||
curID = id;
|
||||
gObjLoading.SetActive(false);
|
||||
}
|
||||
catch (KeyNotFoundException e)
|
||||
{
|
||||
lblGlobalScores.text = "Global Scores:";
|
||||
gObjLoading.GetComponentInChildren<Text>().text = loadingStr;
|
||||
gObjLoading.SetActive(true);
|
||||
curID = null;
|
||||
}
|
||||
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" +
|
||||
"<color=red>{0}</color>", e);
|
||||
gObjLoading.SetActive(true);
|
||||
MeatKitPlugin.Logger.LogWarning("Unknown error occurred trying to retrieve online player count.");
|
||||
MeatKitPlugin.Logger.LogWarning(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ namespace TNHQoLImprovements
|
||||
{
|
||||
public static class LeaderboardPlayerCountPatch
|
||||
{
|
||||
private static GameObject gObjLoading;
|
||||
private static Text uiGlobalText;
|
||||
|
||||
public static void Patch(Harmony harmony)
|
||||
@@ -22,29 +21,18 @@ namespace TNHQoLImprovements
|
||||
public static void Setup(TNH_ScoreDisplay __instance)
|
||||
{
|
||||
GameObject gObjLeaderboard = null;
|
||||
gObjLoading = GameObject.Instantiate(MeatKitPlugin.bundle.LoadAsset<GameObject>("PlayerCount_LoadingText"));
|
||||
if (__instance.gameObject.name == "_MainMenu") // lobby
|
||||
{
|
||||
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
|
||||
{
|
||||
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>();
|
||||
gObjLoading.transform.rotation = gObjLeaderboard.transform.rotation;
|
||||
gObjLoading.transform.GetChild(0).GetComponent<Text>().font = uiGlobalText.font;
|
||||
|
||||
var playerCountComponent = gObjLeaderboard.AddComponent<LeaderboardPlayerCount>();
|
||||
playerCountComponent.Init(__instance, uiGlobalText, gObjLoading);
|
||||
playerCountComponent.Init(__instance, uiGlobalText);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user