Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ValheimPinSize v1.1.1
ValheimPinSize.dll
Decompiled a day agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; using Valheim.SettingsGui; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("ValheimPinSize")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Adjust map pin size separately for the minimap and the big map.")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ValheimPinSize")] [assembly: AssemblyTitle("ValheimPinSize")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 ValheimPinSize { [BepInPlugin("timerin.ValheimPinSize", "ValheimPinSize", "1.1.1")] public class Plugin : BaseUnityPlugin { public const string PluginGuid = "timerin.ValheimPinSize"; public const string PluginName = "ValheimPinSize"; public const string PluginVersion = "1.1.1"; internal static ConfigEntry<float> MinimapPinSize; internal static ConfigEntry<float> BigMapPinSize; private void Awake() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown //IL_007f: Unknown result type (might be due to invalid IL or missing references) MinimapPinSize = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MinimapPinSize", 32f, new ConfigDescription("Pin size in pixels on the small minimap. Vanilla is 32.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(8f, 128f), Array.Empty<object>())); BigMapPinSize = ((BaseUnityPlugin)this).Config.Bind<float>("General", "BigMapPinSize", 48f, new ConfigDescription("Pin size in pixels on the big fullscreen map. Vanilla is 48.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(8f, 128f), Array.Empty<object>())); new Harmony("timerin.ValheimPinSize").PatchAll(); } } [HarmonyPatch(typeof(Minimap), "UpdatePins")] internal static class Minimap_UpdatePins_Patch { private static FieldInfo _pinsField; private static void Prefix(Minimap __instance) { if (!((Object)(object)__instance == (Object)null)) { __instance.m_pinSizeSmall = Plugin.MinimapPinSize.Value; __instance.m_pinSizeLarge = Plugin.BigMapPinSize.Value; } } private static void Postfix(Minimap __instance) { if ((Object)(object)__instance == (Object)null) { return; } if (_pinsField == null) { _pinsField = typeof(Minimap).GetField("m_pins", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (_pinsField == null) { return; } } if (!(_pinsField.GetValue(__instance) is IList list)) { return; } RectTransform pinRootLarge = __instance.m_pinRootLarge; foreach (object item in list) { PinData val = (PinData)((item is PinData) ? item : null); if (val != null && !((Object)(object)val.m_uiElement == (Object)null) && !(val.m_worldSize > 0f)) { float num = (((Object)(object)pinRootLarge != (Object)null && (Object)(object)((Transform)val.m_uiElement).parent == (Object)(object)pinRootLarge) ? Plugin.BigMapPinSize.Value : Plugin.MinimapPinSize.Value); float num2 = (val.m_doubleSize ? (num * 2f) : num); if (val.m_animate) { num2 *= 0.8f + Mathf.Sin(Time.time * 5f) * 0.2f; } val.m_uiElement.SetSizeWithCurrentAnchors((Axis)0, num2); val.m_uiElement.SetSizeWithCurrentAnchors((Axis)1, num2); } } } } internal class PinSizeTab : MonoBehaviour, ISettingsTab { internal static Button TabButton; private TMP_Text[] _labels; public event Action<string, int> SharedSettingChanged { add { } remove { } } public void Initialize() { } public void Terminate() { } public void OnTabOpen(Button backButton, Button okButton) { if (!((Object)(object)TabButton == (Object)null)) { List<TMP_Text> list = new List<TMP_Text>(((Component)TabButton).GetComponentsInChildren<TMP_Text>(true)); _labels = list.ToArray(); ApplyLabels(); } } private void LateUpdate() { ApplyLabels(); } private void ApplyLabels() { if (_labels == null) { return; } TMP_Text[] labels = _labels; foreach (TMP_Text val in labels) { if ((Object)(object)val != (Object)null && val.text != "Pin Size") { val.text = "Pin Size"; } } } public void OnOkAsync(OkActionCompletedHandler done) { if (done != null) { done.Invoke(); } } public void OnBack() { } public void OnSharedSettingChanged(string setting, int value) { } } [HarmonyPatch] internal static class Settings_InitializeTabs_Patch { private static MethodBase TargetMethod() { return AccessTools.Method(typeof(Settings), "InitializeTabs", (Type[])null, (Type[])null); } private static void Postfix(Settings __instance) { try { BuildTab(__instance); } catch { } } private static void BuildTab(Settings __instance) { //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Expected O, but got Unknown //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_03b0: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Unknown result type (might be due to invalid IL or missing references) //IL_03cf: Unknown result type (might be due to invalid IL or missing references) //IL_03de: Unknown result type (might be due to invalid IL or missing references) //IL_03e8: Expected O, but got Unknown //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_0471: Unknown result type (might be due to invalid IL or missing references) //IL_0476: Unknown result type (might be due to invalid IL or missing references) //IL_047e: Unknown result type (might be due to invalid IL or missing references) //IL_048b: Expected O, but got Unknown TabHandler componentInChildren = ((Component)__instance).GetComponentInChildren<TabHandler>(); if ((Object)(object)componentInChildren == (Object)null || componentInChildren.m_tabs.Count == 0) { return; } Tab val = componentInChildren.m_tabs[0]; if ((Object)(object)val.m_button == (Object)null || (Object)(object)val.m_page == (Object)null || (Object)(object)((Component)val.m_button).transform.parent.Find("ValheimPinSizeTabButton") != (Object)null) { return; } TMP_Text val2 = null; TMP_Text[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<TMP_Text>(true); foreach (TMP_Text val3 in componentsInChildren) { if (!((Object)(object)((Component)val3).GetComponentInParent<Button>(true) != (Object)null) && !string.IsNullOrEmpty(val3.text)) { val2 = val3; break; } } HashSet<Button> hashSet = new HashSet<Button>(); foreach (Tab tab in componentInChildren.m_tabs) { if ((Object)(object)tab.m_button != (Object)null) { hashSet.Add(tab.m_button); } } Button val4 = null; Button val5 = null; Button val6 = null; Button[] componentsInChildren2 = ((Component)__instance).GetComponentsInChildren<Button>(true); foreach (Button val7 in componentsInChildren2) { if (hashSet.Contains(val7)) { continue; } string text = ((Object)val7).name.ToLowerInvariant(); if (!text.Contains("back") && !text.Contains("ok") && !text.Contains("close") && !text.Contains("cancel") && !text.Contains("delete")) { if ((Object)(object)val6 == (Object)null) { val6 = val7; } if (text.Contains("left")) { val4 = val7; } if (text.Contains("right")) { val5 = val7; } } } if ((Object)(object)val4 == (Object)null || (Object)(object)val5 == (Object)null) { val4 = val6; val5 = val6; } if ((Object)(object)val2 == (Object)null || (Object)(object)val4 == (Object)null || (Object)(object)val5 == (Object)null) { return; } FieldInfo fieldInfo = AccessTools.Field(typeof(Settings), "SettingsTabs"); IList list = ((fieldInfo != null) ? (fieldInfo.GetValue(__instance) as IList) : null); if (list == null) { return; } GameObject val8 = Object.Instantiate<GameObject>(((Component)val.m_button).gameObject, ((Component)val.m_button).transform.parent, false); ((Object)val8).name = "ValheimPinSizeTabButton"; Transform val9 = val8.transform.Find("KeyHint"); if ((Object)(object)val9 != (Object)null) { Object.Destroy((Object)(object)((Component)val9).gameObject); } componentsInChildren = val8.GetComponentsInChildren<TMP_Text>(true); foreach (TMP_Text val10 in componentsInChildren) { if (!IsUnder(val10.transform, "Selected")) { val10.text = "Pin Size"; } } Text[] componentsInChildren3 = val8.GetComponentsInChildren<Text>(true); foreach (Text val11 in componentsInChildren3) { if (!IsUnder(((Component)val11).transform, "Selected")) { val11.text = "Pin Size"; } } GameObject val12 = new GameObject("ValheimPinSizePage", new Type[1] { typeof(RectTransform) }); RectTransform component = val12.GetComponent<RectTransform>(); CopyRect(val.m_page, component); ((Transform)component).SetParent(((Transform)val.m_page).parent, false); val12.SetActive(false); GameObject val13 = new GameObject("Rows", new Type[2] { typeof(RectTransform), typeof(VerticalLayoutGroup) }); RectTransform component2 = val13.GetComponent<RectTransform>(); ((Transform)component2).SetParent((Transform)(object)component, false); component2.anchorMin = Vector2.zero; component2.anchorMax = Vector2.one; component2.offsetMin = Vector2.zero; component2.offsetMax = Vector2.zero; VerticalLayoutGroup component3 = val13.GetComponent<VerticalLayoutGroup>(); ((LayoutGroup)component3).padding = new RectOffset(32, 32, 32, 32); ((HorizontalOrVerticalLayoutGroup)component3).spacing = 24f; ((LayoutGroup)component3).childAlignment = (TextAnchor)1; ((HorizontalOrVerticalLayoutGroup)component3).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)component3).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)component3).childForceExpandWidth = true; ((HorizontalOrVerticalLayoutGroup)component3).childForceExpandHeight = false; AddStepperRow(val13.transform, val2, val4, val5, "ValheimPinSize_MinimapRow", "Minimap pin size", Plugin.MinimapPinSize); AddStepperRow(val13.transform, val2, val4, val5, "ValheimPinSize_BigMapRow", "Big map pin size", Plugin.BigMapPinSize); PinSizeTab pinSizeTab = val12.AddComponent<PinSizeTab>(); Button button = (PinSizeTab.TabButton = val8.GetComponent<Button>()); componentInChildren.m_tabs.Add(new Tab { m_button = button, m_page = component }); list.Add(pinSizeTab); MethodInfo methodInfo = AccessTools.Method(typeof(Settings), "OnSharedSettingChanged", (Type[])null, (Type[])null); if (methodInfo != null) { pinSizeTab.SharedSettingChanged += (Action<string, int>)Delegate.CreateDelegate(typeof(Action<string, int>), __instance, methodInfo); } } private static void AddStepperRow(Transform parent, TMP_Text textTemplate, Button leftTemplate, Button rightTemplate, string rowName, string title, ConfigEntry<float> setting) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Expected O, but got Unknown //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Expected O, but got Unknown //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Expected O, but got Unknown GameObject val = new GameObject(rowName, new Type[3] { typeof(RectTransform), typeof(HorizontalLayoutGroup), typeof(LayoutElement) }); val.transform.SetParent(parent, false); HorizontalLayoutGroup component = val.GetComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)component).spacing = 16f; ((LayoutGroup)component).childAlignment = (TextAnchor)4; ((HorizontalOrVerticalLayoutGroup)component).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)component).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)component).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)component).childForceExpandHeight = false; LayoutElement component2 = val.GetComponent<LayoutElement>(); component2.minHeight = 72f; component2.flexibleWidth = 1f; GameObject obj = Object.Instantiate<GameObject>(((Component)textTemplate).gameObject, val.transform, false); ((Object)obj).name = "Title"; Strip(obj); StripRootLayout(obj); obj.GetComponent<TMP_Text>().text = title; LayoutElement obj2 = obj.AddComponent<LayoutElement>(); obj2.minWidth = 220f; obj2.flexibleWidth = 1f; GameObject obj3 = Object.Instantiate<GameObject>(((Component)leftTemplate).gameObject, val.transform, false); ((Object)obj3).name = "Minus"; Strip(obj3); StripRootLayout(obj3); Button component3 = obj3.GetComponent<Button>(); component3.onClick = new ButtonClickedEvent(); SetButtonText(obj3, "-"); LayoutElement obj4 = obj3.AddComponent<LayoutElement>(); obj4.minWidth = 32f; obj4.minHeight = 32f; obj4.preferredWidth = 32f; obj4.preferredHeight = 32f; obj4.flexibleWidth = 0f; obj4.flexibleHeight = 0f; GameObject val2 = Object.Instantiate<GameObject>(((Component)textTemplate).gameObject, val.transform, false); ((Object)val2).name = "Value"; Strip(val2); StripRootLayout(val2); TMP_Text valueText = val2.GetComponent<TMP_Text>(); valueText.alignment = (TextAlignmentOptions)516; valueText.fontSize *= 0.75f; LayoutElement obj5 = val2.AddComponent<LayoutElement>(); obj5.minWidth = 70f; obj5.flexibleWidth = 0f; GameObject obj6 = Object.Instantiate<GameObject>(((Component)rightTemplate).gameObject, val.transform, false); ((Object)obj6).name = "Plus"; Strip(obj6); StripRootLayout(obj6); Button component4 = obj6.GetComponent<Button>(); component4.onClick = new ButtonClickedEvent(); SetButtonText(obj6, "+"); LayoutElement obj7 = obj6.AddComponent<LayoutElement>(); obj7.minWidth = 32f; obj7.minHeight = 32f; obj7.preferredWidth = 32f; obj7.preferredHeight = 32f; obj7.flexibleWidth = 0f; obj7.flexibleHeight = 0f; ((UnityEvent)component3.onClick).AddListener((UnityAction)delegate { Step(setting, valueText, -1); }); ((UnityEvent)component4.onClick).AddListener((UnityAction)delegate { Step(setting, valueText, 1); }); valueText.text = Mathf.RoundToInt(setting.Value).ToString(); } private static void Step(ConfigEntry<float> setting, TMP_Text valueText, int direction) { setting.Value = Mathf.Clamp((float)(Mathf.RoundToInt(setting.Value) + direction), 8f, 128f); valueText.text = Mathf.RoundToInt(setting.Value).ToString(); } private static void SetButtonText(GameObject buttonObj, string label) { TMP_Text[] componentsInChildren = buttonObj.GetComponentsInChildren<TMP_Text>(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].text = label; } Text[] componentsInChildren2 = buttonObj.GetComponentsInChildren<Text>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { componentsInChildren2[i].text = label; } } private static void StripRootLayout(GameObject obj) { Component[] components = obj.GetComponents<Component>(); foreach (Component val in components) { Type type = ((object)val).GetType(); if (type == typeof(LayoutElement) || type == typeof(HorizontalLayoutGroup) || type == typeof(VerticalLayoutGroup) || type == typeof(ContentSizeFitter)) { Object.Destroy((Object)(object)val); } } } private static void Strip(GameObject obj) { Component[] componentsInChildren = obj.GetComponentsInChildren<Component>(true); foreach (Component val in componentsInChildren) { if (((object)val).GetType().Name == "SettingsTooltip") { Object.Destroy((Object)(object)val); } } } private static bool IsUnder(Transform node, string name) { Transform parent = node.parent; while ((Object)(object)parent != (Object)null) { if (((Object)parent).name == name) { return true; } parent = parent.parent; } return false; } private static void CopyRect(RectTransform source, RectTransform target) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) target.anchorMin = source.anchorMin; target.anchorMax = source.anchorMax; target.offsetMin = source.offsetMin; target.offsetMax = source.offsetMax; target.pivot = source.pivot; target.anchoredPosition = source.anchoredPosition; target.sizeDelta = source.sizeDelta; ((Transform)target).localScale = Vector3.one; } } }