From 0a5c59d9cdb86766a084ca3c772a95f59c1b7fa5 Mon Sep 17 00:00:00 2001 From: ang-xd Date: Tue, 27 Aug 2024 20:10:01 -0400 Subject: [PATCH] somewhat fix notifications on game start --- .../Options/NotificationPopperPatch.cs | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 MiraAPI/Patches/Options/NotificationPopperPatch.cs diff --git a/MiraAPI/Patches/Options/NotificationPopperPatch.cs b/MiraAPI/Patches/Options/NotificationPopperPatch.cs new file mode 100644 index 0000000..a45bfe6 --- /dev/null +++ b/MiraAPI/Patches/Options/NotificationPopperPatch.cs @@ -0,0 +1,39 @@ +using HarmonyLib; +using Il2CppSystem; +using MiraAPI.Roles; +using System.Linq; + +namespace MiraAPI.Patches.Options; + +[HarmonyPatch(typeof(NotificationPopper))] +public class NotificationPopperPatch +{ + [HarmonyPrefix] + [HarmonyPatch(nameof(NotificationPopper.AddRoleSettingsChangeMessage))] + public static bool RoleChangeMsgPatch(NotificationPopper __instance, + [HarmonyArgument(0)] StringNames key, [HarmonyArgument(1)] int roleCount, [HarmonyArgument(2)] int roleChance, [HarmonyArgument(3)] RoleTeamTypes teamType, + [HarmonyArgument(4)] bool playSound) + { + if (CustomRoleManager.CustomRoles.Values.Any(role => role.StringName == key)) + { + string item = string.Empty; + string text = (teamType == RoleTeamTypes.Crewmate) ? Palette.CrewmateSettingChangeText.ToTextColor() : Palette.ImpostorRed.ToTextColor(); + item = DestroyableSingleton.Instance.GetString(StringNames.LobbyChangeSettingNotificationRole, new Object[] + { + string.Concat( + [ + "", + text, + DestroyableSingleton.Instance.GetString(key, Array.Empty()), + "" + ]), + "" + roleCount.ToString() + "", + "" + roleChance.ToString() + "%" + }); + __instance.SettingsChangeMessageLogic(key, item, playSound); + return false; + } + + return true; + } +} \ No newline at end of file