using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using TMPro; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Mod for MineMogul game")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Max German")] [assembly: AssemblyProduct("UI Tweaks")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("e811d1b0-6776-48c5-b568-342dfc1effc4")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace UITweaks; internal static class ModLog { private static readonly ManualLogSource _bepInExLogger = Logger.CreateLogSource("UI_Tweaks"); internal static void Log(string message, string tag = "") { _bepInExLogger.LogMessage((object)FormatMessage(message, tag)); } internal static void Warn(string message, string tag = "") { _bepInExLogger.LogWarning((object)FormatMessage(message, tag)); } internal static void Error(string message, string tag = "") { _bepInExLogger.LogError((object)FormatMessage(message, tag)); } private static string FormatMessage(string message, string tag) { if (string.IsNullOrEmpty(tag)) { return message; } return "[" + tag + "] " + message; } } [HarmonyPatch] internal static class QuestInfoUIPatch { private static Type _questInfoUIType; static QuestInfoUIPatch() { _questInfoUIType = AccessTools.TypeByName("QuestInfoUI"); } private static MethodBase TargetMethod() { if (_questInfoUIType == null) { Debug.LogWarning((object)"[UI Tweaks] QuestInfoUI type was not found."); return null; } MethodInfo methodInfo = AccessTools.Method(_questInfoUIType, "RefreshDisplay", (Type[])null, (Type[])null); if ((MethodBase?)methodInfo == (MethodBase?)null) { Debug.LogWarning((object)"[UI Tweaks] QuestInfoUI.RefreshDisplay was not found."); } return methodInfo; } private static void Postfix(object __instance) { try { QuestUITweaksPlugin questUITweaksPlugin = Object.FindFirstObjectByType(); if (!((Object)(object)questUITweaksPlugin == (Object)null)) { Component val = (Component)((__instance is Component) ? __instance : null); if (!((Object)(object)val == (Object)null)) { questUITweaksPlugin.ProcessQuestUI(val.gameObject); } } } catch (Exception ex) { Debug.LogError((object)("[UI Tweaks] Harmony patch error: " + ex)); } } } internal class QuestPanelManager { private const string ControlsContainerPath = "MainUI/Hud/Canvas/ControlsContainer"; private const string TopLeftContainerPath = "MainUI/Hud/Canvas/TopLeftContainer"; private readonly QuestUITweaksPlugin _plugin; private readonly QuestUIConfig _config; private GameObject _controlsContainer; private GameObject _topLeftContainer; private bool _controlsVisible = true; private bool _topLeftVisible = true; internal QuestPanelManager(QuestUITweaksPlugin plugin, QuestUIConfig config) { _plugin = plugin; _config = config; } internal void Update() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) KeyboardShortcut value = _config.ControlsToggleKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { ToggleControls(); } value = _config.TopLeftToggleKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { ToggleTopLeft(); } } internal void FindPanels() { GameObject val = GameObject.Find("MainUI/Hud/Canvas/ControlsContainer"); if ((Object)(object)val != (Object)null) { _controlsContainer = val; _controlsVisible = val.activeSelf; } GameObject val2 = GameObject.Find("MainUI/Hud/Canvas/TopLeftContainer"); if ((Object)(object)val2 != (Object)null) { _topLeftContainer = val2; _topLeftVisible = val2.activeSelf; } } private void ToggleControls() { if ((Object)(object)_controlsContainer == (Object)null) { FindPanels(); } if ((Object)(object)_controlsContainer == (Object)null) { ModLog.Warn("ControlsContainer not found."); return; } _controlsVisible = !_controlsVisible; SetPanelVisibility(_controlsContainer, _controlsVisible); ModLog.Log("ControlsContainer: " + (_controlsVisible ? "visible" : "hidden")); } private void ToggleTopLeft() { if ((Object)(object)_topLeftContainer == (Object)null) { FindPanels(); } if ((Object)(object)_topLeftContainer == (Object)null) { ModLog.Warn("TopLeftContainer not found."); return; } _topLeftVisible = !_topLeftVisible; SetPanelVisibility(_topLeftContainer, _topLeftVisible); ModLog.Log("TopLeftContainer: " + (_topLeftVisible ? "visible" : "hidden")); } private void SetPanelVisibility(GameObject panel, bool visible) { if (!((Object)(object)panel == (Object)null)) { CanvasGroup val = panel.GetComponent(); if ((Object)(object)val == (Object)null) { val = panel.AddComponent(); } val.alpha = (visible ? 1f : 0f); val.interactable = visible; val.blocksRaycasts = visible; } } } internal class QuestRequirementManager { private const string QuestInfoPath = "MainUI/Hud/Canvas/TopLeftContainer/QuestInfoContainer/QuestInfoUI(Clone)"; private readonly QuestUITweaksPlugin _plugin; private readonly QuestUIConfig _config; internal QuestRequirementManager(QuestUITweaksPlugin plugin, QuestUIConfig config) { _plugin = plugin; _config = config; } internal void ProcessQuestUI(GameObject questUI) { if ((Object)(object)questUI == (Object)null) { return; } Component[] componentsInChildren = questUI.GetComponentsInChildren(true); foreach (Component val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && ((object)val).GetType().Name == "QuestRequirementUI") { UpdateRequirementVisibility(val); } } } private void UpdateRequirementVisibility(Component requirementComponent) { if (!((Object)(object)requirementComponent == (Object)null)) { GameObject gameObject = requirementComponent.gameObject; UpdateRequirement(gameObject); } } private void UpdateRequirement(GameObject requirement) { if ((Object)(object)requirement == (Object)null) { return; } Transform val = QuestUIHelper.FindChildRecursive(requirement.transform, "CheckBox"); if ((Object)(object)val == (Object)null) { return; } Transform val2 = QuestUIHelper.FindChildRecursive(val, "CheckMark"); if (!((Object)(object)val2 == (Object)null)) { bool activeSelf = ((Component)val2).gameObject.activeSelf; CanvasGroup val3 = requirement.GetComponent(); if ((Object)(object)val3 == (Object)null) { val3 = requirement.AddComponent(); } LayoutElement val4 = requirement.GetComponent(); if ((Object)(object)val4 == (Object)null) { val4 = requirement.AddComponent(); } if (_config.HideCompletedRequirements.Value && activeSelf) { val3.alpha = 0f; val3.interactable = false; val3.blocksRaycasts = false; val4.ignoreLayout = true; } else { val3.alpha = 1f; val3.interactable = true; val3.blocksRaycasts = true; val4.ignoreLayout = false; } } } internal void Refresh() { GameObject val = GameObject.Find("MainUI/Hud/Canvas/TopLeftContainer/QuestInfoContainer/QuestInfoUI(Clone)"); if ((Object)(object)val == (Object)null) { ModLog.Warn("QuestInfoUI not found while refreshing requirements."); return; } ProcessQuestUI(val); Canvas.ForceUpdateCanvases(); RectTransform component = val.GetComponent(); if ((Object)(object)component != (Object)null) { LayoutRebuilder.ForceRebuildLayoutImmediate(component); } ModLog.Log("Quest requirements refreshed."); } } internal class QuestUIFontManager { private const string QuestInfoPath = "MainUI/Hud/Canvas/TopLeftContainer/QuestInfoContainer/QuestInfoUI(Clone)"; private const string ControlsTextPath = "MainUI/Hud/Canvas/ControlsContainer/ControlsText"; private readonly QuestUITweaksPlugin _plugin; private readonly QuestUIConfig _config; internal QuestUIFontManager(QuestUITweaksPlugin plugin, QuestUIConfig config) { _plugin = plugin; _config = config; } internal void ApplyFonts() { ApplyQuestFont(); ApplyControlsFont(); } internal void ApplyQuestFont() { GameObject val = GameObject.Find("MainUI/Hud/Canvas/TopLeftContainer/QuestInfoContainer/QuestInfoUI(Clone)"); if ((Object)(object)val == (Object)null) { ModLog.Warn("QuestInfoUI not found."); } else { ApplyQuestFont(val); } } internal void ApplyQuestFont(GameObject questUI) { if ((Object)(object)questUI == (Object)null) { return; } TMP_Text[] componentsInChildren = questUI.GetComponentsInChildren(true); foreach (TMP_Text val in componentsInChildren) { if (!((Object)(object)val == (Object)null)) { val.fontSize = _config.QuestFontSize.Value; } } } internal void ApplyControlsFont() { GameObject val = GameObject.Find("MainUI/Hud/Canvas/ControlsContainer/ControlsText"); if ((Object)(object)val == (Object)null) { ModLog.Warn("ControlsText not found."); return; } TMP_Text component = val.GetComponent(); if ((Object)(object)component == (Object)null) { ModLog.Warn("ControlsText does not have TMP_Text."); return; } component.fontSize = _config.ControlsFontSize.Value; ModLog.Log("Controls font size applied: " + _config.ControlsFontSize.Value); } } internal class QuestUIConfig { private const float MinFontSize = 10f; private const float MaxFontSize = 20f; internal ConfigEntry QuestFontSize { get; } internal ConfigEntry ControlsFontSize { get; } internal ConfigEntry ControlsToggleKey { get; } internal ConfigEntry TopLeftToggleKey { get; } internal ConfigEntry HideCompletedRequirements { get; } internal QuestUIConfig(ConfigFile config) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) QuestFontSize = config.Bind("Quest UI", "Quest Font Size", 11f, new ConfigDescription("Quest font size.", (AcceptableValueBase)(object)new AcceptableValueRange(10f, 20f), Array.Empty())); QuestFontSize.Value = Mathf.Clamp(QuestFontSize.Value, 10f, 20f); ControlsFontSize = config.Bind("Quest UI", "Controls Font Size", 11f, new ConfigDescription("Controls font size.", (AcceptableValueBase)(object)new AcceptableValueRange(10f, 20f), Array.Empty())); ControlsFontSize.Value = Mathf.Clamp(ControlsFontSize.Value, 10f, 20f); TopLeftToggleKey = config.Bind("Panels", "TopLeft Toggle Key", new KeyboardShortcut((KeyCode)283, Array.Empty()), "Key used to hide/show TopLeftContainer."); ControlsToggleKey = config.Bind("Panels", "Controls Toggle Key", new KeyboardShortcut((KeyCode)284, Array.Empty()), "Key used to hide/show ControlsContainer."); HideCompletedRequirements = config.Bind("Quest Requirements", "Hide Completed Requirements", true, "Hide completed quest requirements."); } } internal static class ModInfo { public const string PLUGIN_GUID = "com.maxgerman.uitweaks"; public const string PLUGIN_NAME = "UI Tweaks"; public const string PLUGIN_VERSION = "1.0.0"; public const string ASSEMBLY_VERSION = "1.0.0"; public const string FILE_VERSION = "1.0.0"; public const string INFORMATIONAL_VERSION = "1.0.0"; public const string HARMONY_ID = "com.maxgerman.uitweaks"; public const string LOG_PREFIX = "[UI Tweaks] "; public const string DISPLAY_NAME_SHORT = "UITweaks"; public const string DISPLAY_NAME_LONG = "UI Tweaks"; internal const string Guid = "com.maxgerman.uitweaks"; internal const string Name = "UI Tweaks"; internal const string Version = "1.0.0"; } [BepInPlugin("com.maxgerman.uitweaks", "UI Tweaks", "1.0.0")] public class QuestUITweaksPlugin : BaseUnityPlugin { public static ManualLogSource Log; private Harmony _harmony; internal QuestUIConfig UIConfig { get; private set; } internal QuestUIFontManager Fonts { get; private set; } internal QuestPanelManager Panels { get; private set; } internal QuestRequirementManager Requirements { get; private set; } private void Awake() { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown UIConfig = new QuestUIConfig(((BaseUnityPlugin)this).Config); Fonts = new QuestUIFontManager(this, UIConfig); Panels = new QuestPanelManager(this, UIConfig); Requirements = new QuestRequirementManager(this, UIConfig); UIConfig.QuestFontSize.SettingChanged += OnSettingChanged; UIConfig.ControlsFontSize.SettingChanged += OnSettingChanged; UIConfig.HideCompletedRequirements.SettingChanged += OnSettingChanged; _harmony = new Harmony("com.maxgerman.uitweaks"); _harmony.PatchAll(); SceneManager.sceneLoaded += OnSceneLoaded; ModLog.Log("UI Tweaks initialized."); } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { ModLog.Log("Scene loaded: " + ((Scene)(ref scene)).name); Fonts.ApplyFonts(); Panels.FindPanels(); Requirements.Refresh(); } private void Update() { if (Panels != null) { Panels.Update(); } } private void OnSettingChanged(object sender, EventArgs args) { if (sender == UIConfig.QuestFontSize || sender == UIConfig.ControlsFontSize) { Fonts.ApplyFonts(); } if (sender == UIConfig.HideCompletedRequirements) { Requirements.Refresh(); } } internal void ProcessQuestUI(GameObject questUI) { if (!((Object)(object)questUI == (Object)null)) { Fonts.ApplyQuestFont(questUI); Requirements.ProcessQuestUI(questUI); } } private void OnDisable() { if (UIConfig != null) { UIConfig.QuestFontSize.SettingChanged -= OnSettingChanged; UIConfig.ControlsFontSize.SettingChanged -= OnSettingChanged; UIConfig.HideCompletedRequirements.SettingChanged -= OnSettingChanged; } SceneManager.sceneLoaded -= OnSceneLoaded; if (_harmony != null) { _harmony.UnpatchSelf(); } } } internal static class QuestUIHelper { internal static Transform FindChildRecursive(Transform parent, string name) { if ((Object)(object)parent == (Object)null) { return null; } for (int i = 0; i < parent.childCount; i++) { Transform child = parent.GetChild(i); if (((Object)child).name == name) { return child; } Transform val = FindChildRecursive(child, name); if ((Object)(object)val != (Object)null) { return val; } } return null; } }