fix discord rp & character allowance patch

This commit is contained in:
Gurge44 committed 2026-06-28 20:38:33 +02:00
1 parent 9eeddae0b9
commit 3bdc76dd88
8 files changed
+106 -33

No files matched your search

+4 -2
View File
@@ -7,7 +7,8 @@
> While at the time of releasing this, the mod should more-less work on InnerSloth's regions, **I still recommend playing on modded regions** (MEU/MAS/MNA/Niko-EU/Niko-AS/Niko-NA).
## Bug Fixes
- **Fixed most of the memory leaks introduced by the latest Among Us update**
- **Fixed crashes caused by the settings UI** - by Zypherus
- **Fixed the memory leaks introduced by the settings UI in the latest Among Us update**
- CTA data is now synced with non-host modded clients
- Fixed Generator not seeing its charge
- Fixed forged roles having incorrect colors
@@ -15,7 +16,7 @@
- + Mostly internal code-wise fixes
## Changes
- **The HTML log file now contains all data from the other log file (LogOutput.log)**
- **The HTML log file now contains all data from the other log file (LogOutput.log)** (that means you'll only need the HTML log to make bug reports from now on, and only the HTML log will be dumped!)
- More compatibility with [BAU](https://github.com/D1GQ/BetterAmongUs) - by Limeau
- Ghost roles use manual cooldown tracking instead of the protect button cooldown (fixes inconsistencies)
- Renaming commands now check the DenyName list
@@ -31,6 +32,7 @@
## Additions
- New setting under `Apply DenyName List`: `Ban instead of kick on trigger`
- More ability button icons - by Newholiday
### New game mode: Doom Tag - by HayashiUme
- In the Doom Tag gamemode, every player is assigned a target, shown by an arrow.
+1 -2
View File
@@ -948,8 +948,7 @@ public class Main : BasePlugin
if (!OperatingSystem.IsAndroid())
{
// there are some issues with TextBoxPatch and DiscordRPC on Android
if (Translator.GetUserTrueLang() is not (SupportedLangs.SChinese or SupportedLangs.TChinese or SupportedLangs.Korean))
Harmony.PatchAll(typeof(TextBoxPatch));
Harmony.PatchAll(typeof(TextBoxPatch));
Harmony.PatchAll(typeof(DiscordRPC));
}
+3
View File
@@ -68,7 +68,10 @@ internal static class ChatControllerUpdatePatch
ClipboardHelper.PutClipboardString(__instance.freeChatField.textArea.text);
if ((Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)) && Input.GetKeyDown(KeyCode.V))
{
TextBoxPatch.Pasting = true;
__instance.freeChatField.textArea.SetText(__instance.freeChatField.textArea.text + GUIUtility.systemCopyBuffer.Trim());
}
if ((Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)) && Input.GetKeyDown(KeyCode.X))
{
+10
View File
@@ -230,6 +230,12 @@ internal static class ControllerManagerUpdatePatch
{
yield return new WaitForSecondsRealtime(0.1f);
if (GameSettingMenu.Instance)
{
GameSettingMenu.Instance.Close();
yield return new WaitForSecondsRealtime(0.5f);
}
string format = GetString("ResettingOptions");
HudManager hudManager = HudManager.Instance;
hudManager.ShowPopUp(string.Format(format, 0, OptionItem.AllOptions.Count));
@@ -254,6 +260,10 @@ internal static class ControllerManagerUpdatePatch
OptionSaver.Save();
IsResetting = false;
GameOptionsMenuPatch.ReCreateAllSettings();
GameOptionsMenuPatch.RefreshSettingValues();
GameOptionsMenuPatch.RefreshTabButtons();
}
}
}
+17 -13
View File
@@ -15,25 +15,29 @@ internal static class AllMapIconsPatch
[HarmonyPrefix]
public static void GameStartManagerStart_Prefix(GameStartManager __instance)
{
if (__instance.AllMapIcons.TrueForAll((Predicate<MapIconByName>)(x => x.Name != MapNames.Dleks)))
try
{
__instance.AllMapIcons.Insert((int)MapNames.Dleks, new MapIconByName
if (__instance.AllMapIcons.TrueForAll((Predicate<MapIconByName>)(x => x.Name != MapNames.Dleks)))
{
Name = MapNames.Dleks,
MapIcon = Utils.LoadSprite("EHR.Resources.Images.DleksBanner-Wordart.png", 160f)
});
}
if (SubmergedCompatibility.Loaded)
{
if (__instance.AllMapIcons.TrueForAll((Predicate<MapIconByName>)(x => x.Name != (MapNames)6)))
{
__instance.AllMapIcons.Insert((int)(MapNames)6, new MapIconByName
__instance.AllMapIcons.Insert((int)MapNames.Dleks, new MapIconByName
{
Name = (MapNames)6,
MapIcon = Utils.LoadSprite("EHR.Resources.Images.Submerged-Wordart.png", 380f)
Name = MapNames.Dleks,
MapIcon = Utils.LoadSprite("EHR.Resources.Images.DleksBanner-Wordart.png", 160f)
});
}
if (SubmergedCompatibility.Loaded)
{
if (__instance.AllMapIcons.TrueForAll((Predicate<MapIconByName>)(x => x.Name != (MapNames)6)))
{
__instance.AllMapIcons.Insert((int)(MapNames)6, new MapIconByName
{
Name = (MapNames)6,
MapIcon = Utils.LoadSprite("EHR.Resources.Images.Submerged-Wordart.png", 380f)
});
}
}
}
catch { }
}
[HarmonyPatch(nameof(GameStartManager.Start))]
[HarmonyPostfix]
+4 -4
View File
@@ -502,10 +502,10 @@ public static class GameOptionsMenuPatch
string selection = stringOptionItem.Selections[stringOptionItem.Rule.GetValueByIndex(stringOption.Value)];
if (!stringOptionItem.noTranslation) selection = Translator.GetString(selection);
stringOption.ValueText.SetText(selection);
if (!StringOptionPatch.NameCache.ContainsKey(stringOption))
if (!StringOptionPatch.NameCache.TryGetValue(stringOption, out string name))
stringOption.Initialize();
else
stringOption.TitleText.SetText(StringOptionPatch.NameCache[stringOption]);
stringOption.TitleText.SetText(name);
break;
case FloatOptionItem or IntegerOptionItem when optionBehaviour is NumberOption numberOption:
numberOption.Value = optionItem.GetFloat();
@@ -970,10 +970,10 @@ public static class StringOptionPatch
OptionItem item = OptionItem.AllOptions[index];
item.SetValue(__instance.GetInt(), doSave: true, doSync: false);
NotificationPopperPatch.AddSettingsChangeMessage(item);
if (!NameCache.ContainsKey(__instance))
if (!NameCache.TryGetValue(__instance, out string name))
__instance.Initialize();
else
__instance.TitleText.SetText(NameCache[__instance]);
__instance.TitleText.SetText(name);
return false;
}
+39 -9
View File
@@ -45,6 +45,8 @@ public static class GameStartManagerPatch
{
try
{
try { GameStartManagerUpdatePatch.DiscordManagerBridge.Init(); } catch (Exception e) { Utils.ThrowException(e); }
if (!__instance) return;
UpdateSpriteStartButton = true;
@@ -128,12 +130,40 @@ public static class GameStartManagerPatch
private static int MinPlayer;
private static SpriteRenderer LobbyTimerBg;
public static bool Warned;
private static readonly Type DiscordManagerType = AccessTools.TypeByName("DiscordManager");
private static readonly PropertyInfo InstanceExistsProperty = DiscordManagerType?.GetProperty("InstanceExists");
private static readonly PropertyInfo InstanceProperty = DiscordManagerType?.GetProperty("Instance");
private static readonly MethodInfo SetInLobbyHostMethod = DiscordManagerType?.GetMethod("SetInLobbyHost");
private static readonly MethodInfo SetInLobbyClientMethod = DiscordManagerType?.GetMethod("SetInLobbyClient");
public static class DiscordManagerBridge
{
private static bool Initialized;
public static bool Enabled;
public static Func<bool> InstanceExistsGetter;
public static Func<object> InstanceGetter;
public static MethodInfo SetInLobbyHost;
public static MethodInfo SetInLobbyClient;
public static void Init()
{
if (Initialized) return;
Initialized = true;
var discordType = AppDomain.CurrentDomain.GetAssemblies().Select(a =>
{
try { return a.GetType("DiscordManager"); }
catch { return null; }
}).FirstOrDefault(t => t != null);
if (discordType == null) return;
var instanceProp = discordType.BaseType!.GetProperty("Instance", BindingFlags.Public | BindingFlags.Static);
InstanceGetter = (Func<object>)Delegate.CreateDelegate(typeof(Func<object>), instanceProp!.GetGetMethod()!);
var existsProp = discordType.BaseType.GetProperty("InstanceExists", BindingFlags.Public | BindingFlags.Static);
InstanceExistsGetter = (Func<bool>)Delegate.CreateDelegate(typeof(Func<bool>), existsProp!.GetGetMethod()!);
SetInLobbyHost = discordType.GetMethod("SetInLobbyHost", BindingFlags.Public | BindingFlags.Instance);
SetInLobbyClient = discordType.GetMethod("SetInLobbyClient", BindingFlags.Public | BindingFlags.Instance);
Enabled = true;
}
}
public static bool Prefix(GameStartManager __instance)
{
@@ -290,10 +320,10 @@ public static class GameStartManagerPatch
ActionMapGlyphDisplay startButtonGlyph = instance.StartButtonGlyph;
startButtonGlyph?.SetColor(instance.LastPlayerCount >= instance.MinPlayers ? Palette.EnabledColor : Palette.DisabledClear);
if (DiscordManagerType != null && ((bool?)InstanceExistsProperty?.GetValue(null) ?? false))
if (DiscordManagerBridge.Enabled && DiscordManagerBridge.InstanceExistsGetter())
{
MethodInfo method = AmongUsClient.Instance.AmHost && AmongUsClient.Instance.NetworkMode == NetworkModes.OnlineGame ? SetInLobbyHostMethod : SetInLobbyClientMethod;
method?.Invoke(InstanceProperty?.GetValue(null), [instance.LastPlayerCount, GameManager.Instance.LogicOptions.MaxPlayers, AmongUsClient.Instance.GameId]);
var method = AmongUsClient.Instance.AmHost && AmongUsClient.Instance.NetworkMode == NetworkModes.OnlineGame ? DiscordManagerBridge.SetInLobbyHost : DiscordManagerBridge.SetInLobbyClient;
method.Invoke(DiscordManagerBridge.InstanceGetter(), [instance.LastPlayerCount, GameManager.Instance.LogicOptions.MaxPlayers, AmongUsClient.Instance.GameId]);
}
}
+28 -3
View File
@@ -16,20 +16,45 @@ public static class TextBoxPatch
private static TextMeshPro AdditionalInfoText;
public static bool IsInvalidCommand;
private static int CurrentCharPos;
public static bool Pasting;
// from https://github.com/scp222thj/MalumMenu/blob/main/src/Patches/TextBoxTMPPatches.cs
// Well I guess cheat menus sometimes have useful code too....
[HarmonyPatch(typeof(TextBoxTMP), nameof(TextBoxTMP.IsCharAllowed))]
[HarmonyPrefix]
public static bool AllowAllCharacters(TextBoxTMP __instance, [HarmonyArgument(0)] char i, ref bool __result)
public static bool AllowAllCharacters(TextBoxTMP __instance, ref bool __result)
{
if (!__instance.IpMode && i is '\'' or '"' or '’' or '`' or '-' or '–' or '—' or '‐' or '.' or ',' or ':' or ';' or '!' or '?' or '(' or ')' or '[' or ']' or '{' or '}' or '<' or '>' or '+' or '=' or '~' or '^' or '*' or '%' or '&' or '|' or '$' or '€' or '£' or '¥' or '₽' or >= '\u0100' and <= '\u024F' or >= '\u0370' and <= '\u03FF')
string compositionString = Input.compositionString;
if (compositionString.Length > 0)
{
__result = true;
return false;
}
return true;
var input = Pasting ? GUIUtility.systemCopyBuffer.Trim() : Input.inputString;
Pasting = false;
if (input.Length == 0)
{
__result = true;
return false;
}
string currentText = __instance.text ?? string.Empty;
int caretPos = Mathf.Clamp(__instance.caretPos, 0, currentText.Length);
string text = currentText.Insert(caretPos, input);
CurrentCharPos = Mathf.Clamp(CurrentCharPos, 0, text.Length - 1);
char currentChar = text[CurrentCharPos];
if (CurrentCharPos >= text.Length - 1) CurrentCharPos = 0;
else CurrentCharPos++;
__result = currentChar is not ('\b' or '\r' or '[');
return false;
}
[HarmonyPatch(typeof(TextBoxTMP), nameof(TextBoxTMP.SetText))]
[HarmonyPostfix]
public static void ShowCommandHelp(TextBoxTMP __instance)