using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using Microsoft.CodeAnalysis; using Notiffy.API; using Notiffy.Server; using Notiffy.UI; using Notiffy.Utils; using PluginConfig.API; using PluginConfig.API.Decorators; using PluginConfig.API.Fields; using PluginConfig.API.Functionals; using TMPro; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Notiffy")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+e0f1dd749ee9c692d8d02ea3f983c327d473dccb")] [assembly: AssemblyProduct("Notiffy")] [assembly: AssemblyTitle("Notiffy")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Notiffy { public enum PauseMenuButtonTypeEnum { MenuConfiggyAligned, MenuRight, Corner, None } public class ConfigManager { public static PluginConfigurator? config; public static readonly FloatField DefaultTimeout; public static readonly IntField MaxHistory; public static readonly BoolField UseModifierKey; public static readonly KeyCodeField ModifierKey; public static readonly KeyCodeField NotificationPanelKey; public static readonly EnumField PauseMenuButtonType; public static readonly BoolField ShowDebugOptions; public static readonly BoolField FirstRun; public static readonly ButtonField SendTestNotificationButton; public static readonly ButtonField SendUrgentNotificationButton; public static readonly BoolField Silent; private static readonly List ActiveNotifIds; public static void Initialize() { } private static void UpdateDebugOptionsVisibility() { bool value = ShowDebugOptions.value; ((ConfigField)SendTestNotificationButton).hidden = !value; ((ConfigField)SendUrgentNotificationButton).hidden = !value; ((ConfigField)FirstRun).hidden = !value; } public static string GetFormattedPanelKeybind() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) string text = ""; KeyCode value; if (UseModifierKey.value) { string text2 = text; value = ModifierKey.value; text = text2 + "" + ((object)(KeyCode)(ref value)).ToString() + "+"; } string text3 = text; value = NotificationPanelKey.value; return text3 + "" + ((object)(KeyCode)(ref value)).ToString() + ""; } static ConfigManager() { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Expected O, but got Unknown //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Expected O, but got Unknown //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Expected O, but got Unknown //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Expected O, but got Unknown //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Expected O, but got Unknown //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Expected O, but got Unknown //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Expected O, but got Unknown //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Expected O, but got Unknown //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Expected O, but got Unknown //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Expected O, but got Unknown //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Expected O, but got Unknown //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Expected O, but got Unknown //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Expected O, but got Unknown //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Expected O, but got Unknown ActiveNotifIds = new List(); config = PluginConfigurator.Create("Notiffy", "com.github.end-4.notiffy"); string iconPath = Path.Combine(NotiffyPlugin.workingDir, "icon.png"); if (File.Exists(iconPath)) { config.SetIconWithURL(iconPath); } new ConfigHeader(config.rootPanel, "", 10); new ConfigHeader(config.rootPanel, "-- NOTIFICATION SYSTEM --", 24); UseModifierKey = new BoolField(config.rootPanel, "Use modifier key", "modifierKey", true); UseModifierKey.postValueChangeEvent += (PostBoolValueChangeEvent)delegate(bool newValue) { if (ModifierKey != null) { ((ConfigField)ModifierKey).interactable = newValue; } }; ModifierKey = new KeyCodeField(config.rootPanel, "Modifier key", "notificationPanelModkey", (KeyCode)308); ModifierKey.postValueChangeEvent += (PostKeyCodeValueChangeEvent)delegate { NotificationController.UpdateKeybindText(); }; ((ConfigField)ModifierKey).interactable = UseModifierKey.value; NotificationPanelKey = new KeyCodeField(config.rootPanel, "Toggle panel keybind", "notificationPanelKey", (KeyCode)110); NotificationPanelKey.postValueChangeEvent += (PostKeyCodeValueChangeEvent)delegate { NotificationController.UpdateKeybindText(); }; DefaultTimeout = new FloatField(config.rootPanel, "Default timeout (secs)", "defaultTimeout", 6f); MaxHistory = new IntField(config.rootPanel, "Max history length", "maxHistory", 50); PauseMenuButtonType = new EnumField(config.rootPanel, "Pause menu button type", "pauseMenuButtonType", PauseMenuButtonTypeEnum.Corner); PauseMenuButtonType.postValueChangeEvent += delegate { NotificationController.UpdatePopupTail(); MenuPatcher.UpdateAppearance(); }; new ConfigHeader(config.rootPanel, "", 10); new ConfigHeader(config.rootPanel, "-- DEBUG --", 24); ShowDebugOptions = new BoolField(config.rootPanel, "Show debug options", "showDebugOptions", false); ShowDebugOptions.postValueChangeEvent += (PostBoolValueChangeEvent)delegate { UpdateDebugOptionsVisibility(); }; SendTestNotificationButton = new ButtonField(config.rootPanel, "Send test notification", "testNotification"); SendTestNotificationButton.onClick += (OnClick)delegate { uint item = NotificationSystem.NotifySend("Test notification", "The quick blue V1 jumps over the red V2. Sisyphus sells sea shells by the sea shore.", null, iconPath, Urgency.Normal, "NotifySend", 0u, new Dictionary { { "hellYeah", "Hell yeah!" }, { "noThanks", "I'll pass this time..." } }); ActiveNotifIds.Add(item); }; SendUrgentNotificationButton = new ButtonField(config.rootPanel, "Send urgent test notification", "testNotificationUrgent"); SendUrgentNotificationButton.onClick += (OnClick)delegate { NotificationSystem.NotifySend("Urgent notification", "This message should not disappear on its own.", null, "", Urgency.Critical); }; FirstRun = new BoolField(config.rootPanel, "First run", "firstRun", true); UpdateDebugOptionsVisibility(); Silent = new BoolField(config.rootPanel, "Silent", "silent", false); ((ConfigField)Silent).hidden = true; NotificationSystem.ActionInvoked += OnActionInvoked; NotificationSystem.NotificationClosed += OnNotificationClosed; NotificationSystem.NotificationDeleted += OnNotificationDeleted; } private static void PrintActiveNotifIds() { NotiffyPlugin.Log.LogInfo((object)"ACTIVE NOTIFS"); foreach (uint activeNotifId in ActiveNotifIds) { NotiffyPlugin.Log.LogInfo((object)activeNotifId); } } private static void OnActionInvoked(uint id, string actionIdentifier) { PrintActiveNotifIds(); NotiffyPlugin.Log.LogInfo((object)$"Some action invoked: {id}, {actionIdentifier}; current tracked {ActiveNotifIds} -> {ActiveNotifIds.Contains(id)}"); if (ActiveNotifIds.Contains(id)) { NotificationSystem.NotifySend("Action invoked", $"ID: {id}\nAction ID: {actionIdentifier}"); NotiffyPlugin.Log.LogInfo((object)$"INVOKED notification with ID {id}, actionIdentifier: {actionIdentifier}"); ActiveNotifIds.Remove(id); } } private static void OnNotificationClosed(uint id, ClosedReason reason) { if (ActiveNotifIds.Contains(id)) { NotiffyPlugin.Log.LogInfo((object)$"DISMISSED notification with ID {id}"); } } private static void OnNotificationDeleted(uint id) { if (ActiveNotifIds.Contains(id)) { ActiveNotifIds.Remove(id); NotiffyPlugin.Log.LogInfo((object)$"DELETED notification with ID {id}"); } } } [BepInPlugin("com.github.end-4.notiffy", "Notiffy", "0.1.2")] public class NotiffyPlugin : BaseUnityPlugin { public const string PluginGUID = "com.github.end-4.notiffy"; public const string PluginName = "Notiffy"; public const string PluginVersion = "0.1.2"; public static string workingPath = Assembly.GetExecutingAssembly().Location; public static string workingDir = Path.GetDirectoryName(workingPath); internal static ManualLogSource Log; private float previousTimeScale; private void Awake() { Log = Logger.CreateLogSource("Notiffy"); Log.LogInfo((object)"Notiffy is waking up..."); ConfigManager.Initialize(); NotificationSystem.Initialize(); NotificationController.Initialize(); MenuPatcher.Initialize(); UserHints.Initialize(); Log.LogInfo((object)"Notiffy Initialized"); } private void Update() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) if ((!ConfigManager.UseModifierKey.value || Input.GetKey(ConfigManager.ModifierKey.value)) && Input.GetKeyDown(ConfigManager.NotificationPanelKey.value)) { NotificationController.TogglePanel(); } if (Time.timeScale * previousTimeScale > 0f || Time.timeScale + previousTimeScale == 0f) { NotificationController.UpdatePopupTail(); } previousTimeScale = Time.timeScale; } } internal static class UserHints { private static void IssueFirstRunNoticeIfNecessary() { if (ConfigManager.FirstRun.value) { ConfigManager.FirstRun.value = false; NotificationSystem.NotifySend("Notiffy: instructions", "To open notification panel, press [" + ConfigManager.GetFormattedPanelKeybind() + "]. This can be configured in Options > Plugin Config > Notiffy", null, Path.Combine(NotiffyPlugin.workingDir, "icon.png"), Urgency.Critical); } } private static void OnSceneLoaded(Scene s, LoadSceneMode m) { IssueFirstRunNoticeIfNecessary(); } public static void Initialize() { } static UserHints() { SceneManager.sceneLoaded += OnSceneLoaded; } } } namespace Notiffy.Utils { public static class Img2Sprite { public static Sprite LoadNewSprite(string filePath, float pixelsPerUnit = 100f, SpriteMeshType spriteType = 1) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) Texture2D val = LoadTexture(filePath); return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0f, 0f), pixelsPerUnit, 0u, spriteType); } public static Sprite ConvertTextureToSprite(Texture2D texture, float pixelsPerUnit = 100f, SpriteMeshType spriteType = 1) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) return Sprite.Create(texture, new Rect(0f, 0f, (float)((Texture)texture).width, (float)((Texture)texture).height), new Vector2(0f, 0f), pixelsPerUnit, 0u, spriteType); } public static Texture2D LoadTexture(string FilePath) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown if (File.Exists(FilePath)) { byte[] array = File.ReadAllBytes(FilePath); Texture2D val = new Texture2D(2, 2); if (ImageConversion.LoadImage(val, array)) { return val; } } return null; } } } namespace Notiffy.UI { internal static class MenuPatcher { [CompilerGenerated] private static class <>O { public static UnityAction <0>__TogglePanel; } private static string PauseNotifToggleButtonName; private static GameObject _notifButton; private static GameObject? FindNestedObject(GameObject baseObject, string path, bool warnings = true) { Transform val = baseObject.transform; string[] array = path.Split("/"); foreach (string text in array) { val = ((Component)val).transform.Find(text); if ((Object)(object)val == (Object)null) { if (warnings) { NotiffyPlugin.Log.LogWarning((object)(text + " not found for object path " + ((Object)baseObject).name + "/" + path)); } return null; } } return ((Component)val).gameObject; } public static void Initialize() { } static MenuPatcher() { PauseNotifToggleButtonName = "ToggleNotificationPanel"; SceneManager.sceneLoaded += OnSceneLoaded; } private static void OnSceneLoaded(Scene scene, LoadSceneMode mode) { PatchPauseMenu(); } public static void UpdateAppearance() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) RectTransform component = _notifButton.GetComponent(); component.sizeDelta = new Vector2(component.sizeDelta.y, component.sizeDelta.y); bool flag = ConfigManager.PauseMenuButtonType.value == PauseMenuButtonTypeEnum.MenuConfiggyAligned; ((Transform)component).localPosition = new Vector3((float)(flag ? 107 : 170), 90f, 0f); _notifButton.SetActive(ConfigManager.PauseMenuButtonType.value == PauseMenuButtonTypeEnum.MenuRight || ConfigManager.PauseMenuButtonType.value == PauseMenuButtonTypeEnum.MenuConfiggyAligned); } private static void PatchPauseMenu() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Expected O, but got Unknown //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Expected O, but got Unknown //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) Scene activeScene = SceneManager.GetActiveScene(); GameObject baseObject = (from obj in ((Scene)(ref activeScene)).GetRootGameObjects() where ((Object)obj).name == "Canvas" select obj).FirstOrDefault(); if (Object.op_Implicit((Object)(object)FindNestedObject(baseObject, "PauseMenu/" + PauseNotifToggleButtonName, warnings: false))) { return; } GameObject val = FindNestedObject(baseObject, "PauseMenu"); GameObject val2 = FindNestedObject(baseObject, "PauseMenu/Resume"); if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null)) { _notifButton = Object.Instantiate(val2); _notifButton.transform.SetParent(val.transform, false); ((Object)_notifButton).name = PauseNotifToggleButtonName; Button component = _notifButton.GetComponent