more lobby info

This commit is contained in:
D1GQ committed 2024-08-24 16:32:07 -05:00
1 parent 2ab2a5962b
commit 792d380c51
4 files changed
+129

No files matched your search

+60
View File
@@ -289,4 +289,64 @@ public static class Utils
return $"{Tag}: {PlatformName}";
}
public static string GetPlatformName(Platforms platform, bool useTag = false)
{
string Tag = string.Empty;
string PlatformName;
switch (platform)
{
case Platforms.StandaloneSteamPC:
PlatformName = "Steam";
Tag = "PC";
break;
case Platforms.StandaloneEpicPC:
PlatformName = "Epic Games";
Tag = "PC";
break;
case Platforms.StandaloneWin10:
PlatformName = "Microsoft Store";
Tag = "PC";
break;
case Platforms.StandaloneMac:
PlatformName = "Mac OS";
Tag = "PC";
break;
case Platforms.StandaloneItch:
PlatformName = "Itch.io";
Tag = "PC";
break;
case Platforms.Xbox:
PlatformName = "Xbox";
Tag = "Console";
break;
case Platforms.Playstation:
PlatformName = "Playstation";
Tag = "Console";
break;
case Platforms.Switch:
PlatformName = "Switch";
Tag = "Console";
break;
case Platforms.Android:
PlatformName = "Android";
Tag = "Mobile";
break;
case Platforms.IPhone:
PlatformName = "IPhone";
Tag = "Mobile";
break;
case Platforms.Unknown:
PlatformName = "None";
break;
default:
return string.Empty;
}
if (useTag == false)
return PlatformName;
return $"{Tag}: {PlatformName}";
}
}
+20
View File
@@ -61,6 +61,13 @@ class GamePlayManager
}
catch { }
}
[HarmonyPatch(nameof(LobbyBehaviour.RpcExtendLobbyTimer))]
[HarmonyPostfix]
private static void RpcExtendLobbyTimer_Postfix(/*LobbyBehaviour __instance*/)
{
GameStartManagerPatch.lobbyTimer += 30f;
}
}
[HarmonyPatch(typeof(IntroCutscene))]
@@ -124,10 +131,23 @@ class GamePlayManager
[HarmonyPatch(typeof(GameStartManager))]
public class GameStartManagerPatch
{
public static float lobbyTimer = 600f;
public static string lobbyTimerDisplay = "";
[HarmonyPatch(nameof(GameStartManager.Start))]
[HarmonyPostfix]
private static void Start_Postfix(/*GameStartManager __instance*/)
{
lobbyTimer = 600f;
}
[HarmonyPatch(nameof(GameStartManager.Update))]
[HarmonyPrefix]
private static void Update_Prefix(GameStartManager __instance)
{
lobbyTimer = Mathf.Max(0f, lobbyTimer -= Time.deltaTime);
int minutes = (int)lobbyTimer / 60;
int seconds = (int)lobbyTimer % 60;
lobbyTimerDisplay = $"{minutes:00}:{seconds:00}";
__instance.MinPlayers = 1;
}
[HarmonyPatch(nameof(GameStartManager.Update))]
+16
View File
@@ -0,0 +1,16 @@
using InnerNet;
using HarmonyLib;
namespace BetterAmongUs;
[HarmonyPatch(typeof(MatchMakerGameButton))]
class MatchMakerGameButtonPatch
{
[HarmonyPatch(nameof(MatchMakerGameButton.SetGame))]
[HarmonyPostfix]
private static void SetGame_Postfix(MatchMakerGameButton __instance)
{
__instance.NameText.text = $"<b><color=#f4f400>{__instance.myListing.HostName}</color></b>\n";
__instance.NameText.text += $"<size=65%><voffset=0.4m><color=#9c9c9c>{Utils.GetPlatformName(__instance.myListing.Platform)} - {GameCode.IntToGameName(__instance.myListing.GameId)}</color></voffset></size>";
}
}
+33
View File
@@ -1,6 +1,7 @@
using HarmonyLib;
using System.Text;
using UnityEngine;
using static BetterAmongUs.Patches.GamePlayManager;
namespace BetterAmongUs.Patches;
@@ -23,6 +24,12 @@ public class PingTrackerPatch
StringBuilder sb = new StringBuilder();
sb.AppendFormat("PING: <b>{0}</b>\n", GetPingColor(AmongUsClient.Instance.Ping));
if (GameStates.IsLobby && GameStates.IsHost && GameStates.IsVanillaServer && !GameStates.IsLocalGame)
{
sb.AppendFormat("Timer: <b>{0}</b>\n", GetTimeColor(GameStartManagerPatch.lobbyTimer));
}
sb.Append($"<color=#00dbdb><size=75%>BetterAmongUs {Main.GetVersionText(true)}</size></color>\n");
sb.AppendFormat("<color=#b0b0b0><size=50%>{0}</size></color>\n", Main.Github);
@@ -76,4 +83,30 @@ public class PingTrackerPatch
return newPing;
}
private static string GetTimeColor(float time)
{
float minutes = (int)time / 60 + 1f;
string color;
switch (minutes)
{
case float n when n <= 1:
color = "#ff0000";
break;
case float n when n <= 3.5f:
color = "#ffa200";
break;
case float n when n <= 5f:
color = "#ffff00";
break;
default:
color = "#00f04c";
break;
}
string newTime = $"<color={color}>{GameStartManagerPatch.lobbyTimerDisplay}</color>";
return newTime;
}
}