From 84978edc99c46732990d74afab06a5483b28f4ae Mon Sep 17 00:00:00 2001 From: Ape <155788660+ApeMV@users.noreply.github.com> Date: Thu, 5 Feb 2026 14:23:10 +0100 Subject: [PATCH] Tiniest fixes ever and buttons --- AmongUsRevamped.cs | 1 + Modules/Hotkeys.cs | 4 - Modules/RPC.cs | 2 - Modules/Utils.cs | 5 +- Patches/CredentialsPatch.cs | 187 ++++++++++++++++++++---------- Patches/DiscordPatch.cs | 2 +- Patches/EndGamePatches.cs | 2 +- Patches/GameOptionsMenuPatch.cs | 2 - Patches/GameSettingMenuPatch.cs | 1 - Patches/LobbyViewSettingsPatch.cs | 2 - Patches/NumberOptionsPatch.cs | 17 ++- 11 files changed, 148 insertions(+), 77 deletions(-) diff --git a/AmongUsRevamped.cs b/AmongUsRevamped.cs index 037edb3..43ea1d4 100644 --- a/AmongUsRevamped.cs +++ b/AmongUsRevamped.cs @@ -1,6 +1,7 @@ global using HarmonyLib; global using System.Collections.Generic; global using System.Linq; +global using Object = UnityEngine.Object; using AmongUs.GameOptions; using BepInEx; diff --git a/Modules/Hotkeys.cs b/Modules/Hotkeys.cs index 37cbe61..592af52 100644 --- a/Modules/Hotkeys.cs +++ b/Modules/Hotkeys.cs @@ -36,10 +36,6 @@ internal class Hotkeys { MeetingHud.Instance.RpcClose(); } - else - { - PlayerControl.LocalPlayer.ReportDeadBody(PlayerControl.LocalPlayer.Data); - } } if (Shift && GameStartManager.InstanceExists && GameStartManager.Instance != null && GameStartManager.Instance.startState == GameStartManager.StartingStates.Countdown && !HudManager.Instance.Chat.IsOpenOrOpening) diff --git a/Modules/RPC.cs b/Modules/RPC.cs index 2a292b4..f46a198 100644 --- a/Modules/RPC.cs +++ b/Modules/RPC.cs @@ -4,8 +4,6 @@ using UnityEngine; using System; using AmongUs.GameOptions; -using Object = UnityEngine.Object; - namespace AmongUsRevamped { public enum CustomRPC diff --git a/Modules/Utils.cs b/Modules/Utils.cs index 04e98ff..59f62e8 100644 --- a/Modules/Utils.cs +++ b/Modules/Utils.cs @@ -12,8 +12,6 @@ using System.Security.Cryptography; using System.Text; using AmongUs.InnerNet.GameDataMessages; -using Object = UnityEngine.Object; - namespace AmongUsRevamped; public static class Utils @@ -380,7 +378,8 @@ public static class Utils writer.Write(gameOverReason); AmongUsClient.Instance.FinishEndGame(writer); HandlingGameEnd = false; - Logger.Info(" -------- GAME ENDED --------", "ManualEndGame"); + Logger.Info($"{gameOverReason}", "ContinueEndGame"); + Logger.Info(" -------- GAME ENDED --------", "ContinueEndGame"); } public static void DumpLog() diff --git a/Patches/CredentialsPatch.cs b/Patches/CredentialsPatch.cs index 708f44c..cc943a0 100644 --- a/Patches/CredentialsPatch.cs +++ b/Patches/CredentialsPatch.cs @@ -172,82 +172,149 @@ namespace AmongUsRevamped } } } -} -// https://github.com/3X3CODE/MainMenuEnhanced/blob/main/MainMenuEnhanced/VisualPatch.cs -[HarmonyPatch(typeof(MainMenuManager), nameof(MainMenuManager.Start))] -public static class MainMenuManagerStartPatch -{ - public static void Postfix(MainMenuManager __instance) + // https://github.com/3X3CODE/MainMenuEnhanced/blob/main/MainMenuEnhanced/VisualPatch.cs + [HarmonyPatch(typeof(MainMenuManager), nameof(MainMenuManager.Start))] + public static class MainMenuManagerStartPatch { - if (__instance == null) return; - - var bg = GameObject.Find("BackgroundTexture"); - if (bg != null) + private static PassiveButton template; + private static PassiveButton discordButton; + private static PassiveButton gitHubButton; + private static Transform buttonParent; + public static void Postfix(MainMenuManager __instance) { - bg.SetActive(false); - } + if (__instance == null) return; + if (template == null) template = __instance.quitButton; + if (template == null) return; - var leftPanel = GameObject.Find("LeftPanel"); - if (leftPanel != null) - { - leftPanel.gameObject.GetComponent().enabled = false; - } - - var div = GameObject.Find("MainUI/AspectScaler/LeftPanel/Main Buttons/Divider"); - if (div != null) - { - div.SetActive(false); - } - - - Transform tintTrans = __instance.transform.Find("MainUI/Tint"); - var tint = tintTrans.gameObject; - if (tint != null) - { - tint.SetActive(false); - } - - DisableObject("WindowShine"); - DisableComponent("RightPanel"); - DisableComponent("MaskedBlackScreen"); - - Transform playTransform = __instance.transform.Find("MainUI/AspectScaler/LeftPanel/Main Buttons/PlayButton/FontPlacer/Text_TMP"); - if (playTransform != null) - { - var playbutton = playTransform.gameObject; - if (playbutton != null) + if (buttonParent == null) buttonParent = template.transform.parent; + if (discordButton == null) { - if (playbutton.TryGetComponent(out var tmp)) + discordButton = CreateButton( + __instance, + "DiscordButton", + new(2.1f, 4.05f, 1f), + new(88, 101, 242, byte.MaxValue), + new(148, 161, byte.MaxValue, byte.MaxValue), + () => Application.OpenURL("https://discord.gg/83Zhzhyhya"), + "Discord"); + } + + if (gitHubButton == null) + { + gitHubButton = CreateButton( + __instance, + "GitHubButton", + new(3.8f, 4.05f, 1f), + new(153, 153, 153, byte.MaxValue), + new(209, 209, 209, byte.MaxValue), + () => Application.OpenURL("https://github.com/ApeMV/AmongUsRevamped"), + "GitHub"); + } + + var bg = GameObject.Find("BackgroundTexture"); + if (bg != null) + { + bg.SetActive(false); + } + + var leftPanel = GameObject.Find("LeftPanel"); + if (leftPanel != null) + { + leftPanel.gameObject.GetComponent().enabled = false; + } + + var div = GameObject.Find("MainUI/AspectScaler/LeftPanel/Main Buttons/Divider"); + if (div != null) + { + div.SetActive(false); + } + + + Transform tintTrans = __instance.transform.Find("MainUI/Tint"); + var tint = tintTrans.gameObject; + if (tint != null) + { + tint.SetActive(false); + } + + DisableObject("WindowShine"); + DisableComponent("RightPanel"); + DisableComponent("MaskedBlackScreen"); + + Transform playTransform = __instance.transform.Find("MainUI/AspectScaler/LeftPanel/Main Buttons/PlayButton/FontPlacer/Text_TMP"); + if (playTransform != null) + { + var playbutton = playTransform.gameObject; + if (playbutton != null) { - tmp.enabled = false; - } - if (playbutton.TryGetComponent(out var text)) - { - text.text = "Start"; + if (playbutton.TryGetComponent(out var tmp)) + { + tmp.enabled = false; + } + if (playbutton.TryGetComponent(out var text)) + { + text.text = "Start"; + } } } - } - static void DisableObject(string name) - { - var obj = GameObject.Find(name); - if (obj != null) + static void DisableObject(string name) { - obj.SetActive(false); + var obj = GameObject.Find(name); + if (obj != null) + { + obj.SetActive(false); + } + } + + static void DisableComponent(string name) + { + var obj = GameObject.Find(name); + if (obj != null) + { + if (obj.TryGetComponent(out var renderer)) + { + renderer.enabled = false; + } + } } } - static void DisableComponent(string name) + private static PassiveButton CreateButton(MainMenuManager menu, string name, Vector3 localPosition, Color32 normalColor, Color32 hoverColor, Action action, string label) { - var obj = GameObject.Find(name); - if (obj != null) + var parent = menu.transform.Find("MainUI/AspectScaler/LeftPanel/Main Buttons"); + if (parent == null) return null; + + var button = Object.Instantiate(menu.quitButton, parent); + button.name = name; + + button.transform.localPosition = localPosition; + button.transform.localScale = new Vector3(0.8f, 1f, 1f); + + var aspect = button.GetComponent(); + if (aspect != null) { - if (obj.TryGetComponent(out var renderer)) - { - renderer.enabled = false; - } + aspect.enabled = false; } + + button.OnClick = new(); + button.OnClick.AddListener(action); + + var buttonText = button.transform.Find("FontPlacer/Text_TMP").GetComponent(); + Utils.DestroyTranslator(buttonText); + buttonText.text = label; + buttonText.fontSize = buttonText.fontSizeMax = buttonText.fontSizeMin = 3.5f; + buttonText.enableWordWrapping = false; + buttonText.horizontalAlignment = HorizontalAlignmentOptions.Center; + + var normalSprite = button.inactiveSprites.GetComponent(); + var hoverSprite = button.activeSprites.GetComponent(); + normalSprite.color = normalColor; + hoverSprite.color = hoverColor; + + button.gameObject.SetActive(true); + return button; } } } diff --git a/Patches/DiscordPatch.cs b/Patches/DiscordPatch.cs index 2f9894e..5b980a5 100644 --- a/Patches/DiscordPatch.cs +++ b/Patches/DiscordPatch.cs @@ -21,7 +21,7 @@ public class DiscordRPC activity.Assets = new ActivityAssets { - LargeImage = "https://i.imgur.com/cxqgNyW.png" + LargeImage = "https://i.imgur.com/ZnC1toT.png" }; try diff --git a/Patches/EndGamePatches.cs b/Patches/EndGamePatches.cs index 7d3631a..7c6b7d0 100644 --- a/Patches/EndGamePatches.cs +++ b/Patches/EndGamePatches.cs @@ -29,7 +29,7 @@ class NormalGameEndChecker public static bool Prefix() { - if (Options.NoGameEnd.GetBool() || Options.Gamemode.GetValue() == 3) return false; + if (Options.NoGameEnd.GetBool() || Options.Gamemode.GetValue() == 3 || Utils.HandlingGameEnd) return false; var allPlayers = PlayerControl.AllPlayerControls.ToArray(); diff --git a/Patches/GameOptionsMenuPatch.cs b/Patches/GameOptionsMenuPatch.cs index 069107f..75949c0 100644 --- a/Patches/GameOptionsMenuPatch.cs +++ b/Patches/GameOptionsMenuPatch.cs @@ -7,8 +7,6 @@ using System.Collections.Generic; using Il2CppSystem.Collections.Generic; #endif -using Object = UnityEngine.Object; - // https://github.com/Yumenopai/TownOfHost_Y/blob/main/Patches/GameOptionsPatch.cs namespace AmongUsRevamped { diff --git a/Patches/GameSettingMenuPatch.cs b/Patches/GameSettingMenuPatch.cs index bbcff23..8c7b3f1 100644 --- a/Patches/GameSettingMenuPatch.cs +++ b/Patches/GameSettingMenuPatch.cs @@ -1,7 +1,6 @@ using System; using TMPro; using UnityEngine; -using Object = UnityEngine.Object; // https://github.com/Yumenopai/TownOfHost_Y/blob/main/Patches/GameSettingMenuPatch.cs namespace AmongUsRevamped diff --git a/Patches/LobbyViewSettingsPatch.cs b/Patches/LobbyViewSettingsPatch.cs index 1557ef2..ac67102 100644 --- a/Patches/LobbyViewSettingsPatch.cs +++ b/Patches/LobbyViewSettingsPatch.cs @@ -2,8 +2,6 @@ using System; using TMPro; using UnityEngine; -using Object = UnityEngine.Object; - // https://github.com/Rabek009/MoreGamemodes/blob/master/Patches/LobbyViewSettingsPatch.cs namespace AmongUsRevamped { diff --git a/Patches/NumberOptionsPatch.cs b/Patches/NumberOptionsPatch.cs index ec7b53d..6766931 100644 --- a/Patches/NumberOptionsPatch.cs +++ b/Patches/NumberOptionsPatch.cs @@ -9,7 +9,11 @@ public static class NumberOption_Increase { public static bool Prefix(NumberOption __instance) { +#if ANDROID + float increment = __instance.Increment; +#else float increment = Hotkeys.IncrementMultiplier * __instance.Increment; +#endif if (Utils.isHideNSeek || Utils.IsLobby && !Utils.isHideNSeek && __instance.Title != StringNames.GameNumImpostors && __instance.Title != StringNames.GamePlayerSpeed) { @@ -35,7 +39,11 @@ public static class NumberOption_Decrease { public static bool Prefix(NumberOption __instance) { +#if ANDROID + float increment = __instance.Increment; +#else float increment = Hotkeys.IncrementMultiplier * __instance.Increment; +#endif if (Utils.isHideNSeek || Utils.IsLobby && !Utils.isHideNSeek && __instance.Title != StringNames.GameNumImpostors && __instance.Title != StringNames.GamePlayerSpeed) { @@ -71,17 +79,24 @@ public static class NumberOption_Initialize { case StringNames.GameVotingTime: case StringNames.GameDiscussTime: + case StringNames.EscapeTime: + case StringNames.FinalEscapeTime: __instance.Increment = 5f; break; + case StringNames.GameKillCooldown: __instance.Increment = 0.5f; break; + case StringNames.GamePlayerSpeed: + case StringNames.SeekerFinalSpeed: case StringNames.GameCrewLight: case StringNames.GameImpostorLight: + case StringNames.CrewmateFlashlightSize: + case StringNames.ImpostorFlashlightSize: __instance.Increment = 0.05f; break; - + default: __instance.Increment = 1f; break;