// Consolidated decompiled source — WackyMole-ChangelogEditor v1.1.0 // Generated by Hexium's decompiled-source browser. Best-effort concatenation of every type in this // version's manifest — decompiler output isn't guaranteed to compile as-is. using System; using System.Runtime.CompilerServices; using Microsoft.CodeAnalysis; using HarmonyLib; using TMPro; using UnityEngine; using System.IO; using System.Reflection; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using JetBrains.Annotations; using UnityEngine.SceneManagement; // ---- ChangelogEditor.dll :: Microsoft.CodeAnalysis.EmbeddedAttribute ---- namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } // ---- ChangelogEditor.dll :: System.Runtime.CompilerServices.NullableAttribute ---- 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; } } } // ---- ChangelogEditor.dll :: System.Runtime.CompilerServices.NullableContextAttribute ---- namespace System.Runtime.CompilerServices { [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; } } } // ---- ChangelogEditor.dll :: ChangelogEditor.ChangeLogStartPatch ---- namespace ChangelogEditor { [HarmonyPatch(typeof(ChangeLog), "Start")] internal static class ChangeLogStartPatch { private static bool Prefix(ChangeLog __instance) { ChangelogEditorPlugin.ChangelogGameObject = __instance.gameObject; ChangelogEditorPlugin.UpdateChangelogWidth(null, null); if (ChangelogEditorPlugin.overrideText.Value == ChangelogEditorPlugin.Toggle.On) { __instance.m_textField.text = ChangelogEditorPlugin.customFileText; return false; } if (ChangelogEditorPlugin.shouldChangeText.Value != ChangelogEditorPlugin.Toggle.On) { return true; } __instance.m_textField.text = ChangelogEditorPlugin.customFileText + __instance.m_changeLog.text; return false; } private static void Postfix(ChangeLog __instance) { ChangeLogExtension.topicTmp = Utils.FindChild(__instance.transform, "Topic").GetComponent(); ChangeLogExtension.topicTmp.rectTransform.anchoredPosition += new Vector2(0f, 20f); __instance.UpdateChangelog(); } } } // ---- ChangelogEditor.dll :: ChangelogEditor.ChangeLogLateUpdatePatch ---- namespace ChangelogEditor { [HarmonyPatch(typeof(ChangeLog), "LateUpdate")] internal static class ChangeLogLateUpdatePatch { private static void Postfix(ChangeLog __instance) { ChangeLogExtension.UpdateTopicText(__instance); } } } // ---- ChangelogEditor.dll :: ChangelogEditor.ChangeLogExtension ---- namespace ChangelogEditor { public static class ChangeLogExtension { internal static TextMeshProUGUI topicTmp; public static void UpdateChangelog(this ChangeLog __instance) { __instance.m_hasSetScroll = false; UpdateTopicText(__instance); if (ChangelogEditorPlugin.overrideText.Value == ChangelogEditorPlugin.Toggle.On) { __instance.m_textField.text = ChangelogEditorPlugin.customFileText.ToLiteral(); } else if (ChangelogEditorPlugin.shouldChangeText.Value == ChangelogEditorPlugin.Toggle.On) { __instance.m_textField.text = ChangelogEditorPlugin.customFileText.ToLiteral() + __instance.m_changeLog.text; } else { __instance.m_textField.text = __instance.m_changeLog.text; } __instance.gameObject.SetActive(ChangelogEditorPlugin.shouldShowChangelog.Value == ChangelogEditorPlugin.Toggle.On); } public static void UpdateTopicText(ChangeLog clog) { topicTmp.text = ChangelogEditorPlugin.topicText.Value; } } } // ---- ChangelogEditor.dll :: ChangelogEditor.ChangelogEditorPlugin ---- namespace ChangelogEditor { [BepInPlugin("WackyMole.ChangelogEditor", "ChangelogEditor", "1.1.0")] public class ChangelogEditorPlugin : BaseUnityPlugin { public enum Toggle { On = 1, Off = 0 } private class ConfigurationManagerAttributes { [UsedImplicitly] public int? Order; [UsedImplicitly] public bool? Browsable; [UsedImplicitly] public string Category; [UsedImplicitly] public Action? CustomDrawer; } private class AcceptableShortcuts : AcceptableValueBase { public AcceptableShortcuts() : base(typeof(KeyboardShortcut)) { } public override object Clamp(object value) { return value; } public override bool IsValid(object value) { return true; } public override string ToDescriptionString() { return "# Acceptable values: " + string.Join(", ", UnityInput.Current.SupportedKeyCodes); } } internal const string ModName = "ChangelogEditor"; internal const string ModVersion = "1.1.0"; internal const string Author = "WackyMole"; private const string ModGUID = "WackyMole.ChangelogEditor"; private static string ConfigFileName = "WackyMole.ChangelogEditor.cfg"; private static string ContentFile = "WackyMole.ChangelogEditor.txt"; private static string ConfigFileFullPath; private static string ContentFileFullPath; internal static string ConnectionError; internal static string customFileText; internal static GameObject ChangelogGameObject; private readonly Harmony _harmony = new Harmony("WackyMole.ChangelogEditor"); public static readonly ManualLogSource ChangelogEditorLogger; internal static ConfigEntry shouldShowChangelog; internal static ConfigEntry shouldChangeText; internal static ConfigEntry overrideText; internal static ConfigEntry topicText; internal static ConfigEntry changelogWidth; public void Awake() { shouldShowChangelog = config("1 - Changelog", "Should Show Changelog", Toggle.On, "If on, the changelog will be shown in the main menu. If off, it will not be shown."); shouldChangeText = config("1 - Changelog", "Should Change Text", Toggle.On, "If on, your configuration file's text will be added to the changelog. (at the top). This pulls from the " + ContentFile + " found in your config folder."); overrideText = config("1 - Changelog", "Override Changelog Text", Toggle.Off, "If on, only your custom text that is set will show in the changlog. This deletes the default changelog text."); topicText = TextEntryConfig("1 - Changelog", "Title Text", "Changelog", "Change the title text of the changelog. This is the text that shows up in the top of the changelog."); changelogWidth = config("1 - Changelog", "Width", 445f, "Width of the changelog window."); changelogWidth.SettingChanged += UpdateChangelogWidth; if (!File.Exists(ContentFileFullPath)) { File.WriteAllText(ContentFileFullPath, "This is the content file for ChangelogEditor. You can edit this file to change the changelog text." + Environment.NewLine + "This file can be found currently at: " + ContentFileFullPath + Environment.NewLine + Environment.NewLine); } else { customFileText = File.ReadAllText(ContentFileFullPath, Encoding.UTF8); } Assembly executingAssembly = Assembly.GetExecutingAssembly(); _harmony.PatchAll(executingAssembly); SetupWatcher(); } private void OnDestroy() { base.Config.Save(); changelogWidth.SettingChanged -= UpdateChangelogWidth; } internal static void UpdateChangelogWidth(object sender, EventArgs e) { if (!(ChangelogGameObject == null)) { RectTransform rectTransform = (RectTransform)ChangelogGameObject.transform; RectTransform obj = (RectTransform)ChangelogGameObject.transform.Find("ScrollPanel"); RectTransform rectTransform2 = (RectTransform)ChangelogGameObject.transform.Find("PatchlogScroll"); Vector2 sizeDelta = obj.sizeDelta; rectTransform.sizeDelta = new Vector2(changelogWidth.Value, sizeDelta.y); sizeDelta = new Vector2(changelogWidth.Value, sizeDelta.y); obj.sizeDelta = sizeDelta; Vector2 anchoredPosition = obj.anchoredPosition; rectTransform2.anchoredPosition = new Vector2(anchoredPosition.x, anchoredPosition.y); rectTransform2.anchorMin = new Vector2(0f, 0f); rectTransform2.anchorMax = new Vector2(0f, 1f); rectTransform2.pivot = new Vector2(0f, 0.5f); rectTransform2.anchoredPosition = new Vector2(0f, 0f); } } private void SetupWatcher() { FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath, ConfigFileName); fileSystemWatcher.Changed += ReadConfigValues; fileSystemWatcher.Created += ReadConfigValues; fileSystemWatcher.Renamed += ReadConfigValues; fileSystemWatcher.IncludeSubdirectories = true; fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher.EnableRaisingEvents = true; FileSystemWatcher fileSystemWatcher2 = new FileSystemWatcher(Paths.ConfigPath, ConfigFileName); fileSystemWatcher2.Changed += ReadContent; fileSystemWatcher2.Created += ReadContent; fileSystemWatcher2.Renamed += ReadContent; fileSystemWatcher2.IncludeSubdirectories = true; fileSystemWatcher2.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher2.EnableRaisingEvents = true; FileSystemWatcher fileSystemWatcher3 = new FileSystemWatcher(Paths.ConfigPath, ContentFile); fileSystemWatcher3.Changed += ReadContent; fileSystemWatcher3.Created += ReadContent; fileSystemWatcher3.Renamed += ReadContent; fileSystemWatcher3.IncludeSubdirectories = true; fileSystemWatcher3.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher3.EnableRaisingEvents = true; } private void ReadConfigValues(object sender, FileSystemEventArgs e) { if (!File.Exists(ConfigFileFullPath)) { return; } try { ChangelogEditorLogger.LogDebug("ReadConfigValues called"); base.Config.Reload(); } catch { ChangelogEditorLogger.LogError("There was an issue loading your " + ConfigFileName); ChangelogEditorLogger.LogError("Please check your config entries for spelling and format!"); } } private void ReadContent(object sender, FileSystemEventArgs e) { if (!File.Exists(ContentFileFullPath)) { return; } try { customFileText = File.ReadAllText(ContentFileFullPath, Encoding.UTF8); if (!(SceneManager.GetActiveScene().name == "main") && !(ChangelogGameObject.gameObject == null) && (bool)ChangelogGameObject.GetComponent()) { ChangelogGameObject.GetComponent().UpdateChangelog(); } } catch { ChangelogEditorLogger.LogError("There was an issue loading your " + ConfigFileName); ChangelogEditorLogger.LogError("Please check your config entries for spelling and format!"); } } private ConfigEntry config(string group, string name, T value, ConfigDescription description) { return base.Config.Bind(group, name, value, description); } private ConfigEntry config(string group, string name, T value, string description) { return config(group, name, value, new ConfigDescription(description, null)); } internal ConfigEntry TextEntryConfig(string group, string name, T value, string desc) { ConfigurationManagerAttributes configurationManagerAttributes = new ConfigurationManagerAttributes { CustomDrawer = TextAreaDrawer }; return config(group, name, value, new ConfigDescription(desc, null, configurationManagerAttributes)); } internal static void TextAreaDrawer(ConfigEntryBase entry) { GUILayout.ExpandHeight(expand: true); GUILayout.ExpandWidth(expand: true); entry.BoxedValue = GUILayout.TextArea((string)entry.BoxedValue, GUILayout.ExpandWidth(expand: true), GUILayout.ExpandHeight(expand: true)); } static ChangelogEditorPlugin() { string configPath = Paths.ConfigPath; char directorySeparatorChar = Path.DirectorySeparatorChar; ConfigFileFullPath = configPath + directorySeparatorChar + ConfigFileName; string configPath2 = Paths.ConfigPath; directorySeparatorChar = Path.DirectorySeparatorChar; ContentFileFullPath = configPath2 + directorySeparatorChar + ContentFile; ConnectionError = ""; customFileText = ""; ChangelogGameObject = null; ChangelogEditorLogger = BepInEx.Logging.Logger.CreateLogSource("ChangelogEditor"); shouldShowChangelog = null; shouldChangeText = null; overrideText = null; topicText = null; changelogWidth = null; } } }