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 CartographyAdmin v1.0.1
BepInEx/plugins/CartographyAdmin/CartographyAdmin.dll
Decompiled 2 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("CartographyAdmin")] [assembly: AssemblyConfiguration("Release+Deploy")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("CartographyAdmin")] [assembly: AssemblyTitle("CartographyAdmin")] [assembly: AssemblyVersion("1.0.0.0")] namespace CartographyAdmin; public enum EditPermission { BuilderOrWard, AdminsOnly } public enum MenuModifier { Shift, Ctrl, Alt } [BepInPlugin("diffByDefault.CartographyAdmin", "CartographyAdmin", "1.0.1")] public class CartographyAdminPlugin : BaseUnityPlugin { public const string PluginGuid = "diffByDefault.CartographyAdmin"; public const string PluginName = "CartographyAdmin"; public const string PluginVersion = "1.0.1"; private const string GeneralSection = "General"; private const string DuplicatesSection = "Duplicates"; internal static ConfigEntry<MenuModifier> OpenMenuModifier; internal static ConfigEntry<EditPermission> Permission; internal static ConfigEntry<bool> UpdateSharedMarkersFromTable; internal static ConfigEntry<WindowStyle> Style; internal static ConfigEntry<bool> KeepScrollPosition; internal static ConfigEntry<int> ScrollRowsPerStep; internal static ConfigEntry<bool> DuplicatesView; internal static ConfigEntry<float> DuplicateDistance; internal static ManualLogSource Log; private static Harmony _harmony; private void Awake() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; BindConfig(); ((Component)this).gameObject.AddComponent<MarkerManagerWindow>(); _harmony = new Harmony("diffByDefault.CartographyAdmin"); _harmony.PatchAll(typeof(CartographyAdminPlugin).Assembly); Log.LogInfo((object)"CartographyAdmin 1.0.1 loaded."); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private void Update() { if (MarkerManagerWindow.IsOpen) { if (TableAccess.HotkeyPressed() && !MarkerManagerWindow.IsTyping) { MarkerManagerWindow.Close(); } } else { if (!TableAccess.HotkeyPressed() || OtherMenuOpen()) { return; } MapTable hoveredTable = TableAccess.GetHoveredTable(); if ((Object)(object)hoveredTable == (Object)null) { return; } if (!TableAccess.CanManage(hoveredTable, out var reason)) { Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)2, reason, 0, (Sprite)null, false); } } else { MarkerManagerWindow.Open(hoveredTable); } } } private static bool OtherMenuOpen() { if (!InventoryGui.IsVisible() && !Minimap.IsOpen() && !Menu.IsVisible() && !Console.IsVisible() && !TextInput.IsVisible()) { if ((Object)(object)Chat.instance != (Object)null) { return Chat.instance.HasFocus(); } return false; } return true; } private void BindConfig() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Expected O, but got Unknown //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Expected O, but got Unknown //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Expected O, but got Unknown //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Expected O, but got Unknown //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Expected O, but got Unknown //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Expected O, but got Unknown //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Expected O, but got Unknown OpenMenuModifier = ((BaseUnityPlugin)this).Config.Bind<MenuModifier>("General", "OpenMenuModifier", MenuModifier.Shift, new ConfigDescription("The key you hold while pressing E at a cartography table to open its marker manager: Shift (Shift+E), Ctrl (Ctrl+E) or Alt (Alt+E). While the key is held, E doesn't read from or save to the table, so opening the manager never uses the table by accident. Ctrl is also the game's crouch key, so Ctrl+E also crouches or stands you up.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { DispName = "Open Menu Modifier", Order = 40, Description = "Hold this key and press E at a cartography table to open the marker manager." } })); Permission = ((BaseUnityPlugin)this).Config.Bind<EditPermission>("General", "EditPermission", EditPermission.BuilderOrWard, new ConfigDescription("Who can open the marker manager on a table. BuilderOrWard: the player who built the table, players permitted on a ward that covers it, and server admins or the host. A table no ward covers can only be managed by its builder and admins. AdminsOnly: server admins and the host only. This setting only limits your own game; the BuilderOrWard rule always applies to everyone with the mod.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { DispName = "Edit Permission", Order = 30, Description = "Who you allow yourself to manage tables as. It can only make the fixed rule stricter for you." } })); UpdateSharedMarkersFromTable = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "UpdateSharedMarkersFromTable", true, new ConfigDescription("When on, reading a cartography table updates the name, icon and checked state of shared markers you already have. Vanilla never updates a shared marker once you have it. Your own markers are never changed. Off = vanilla behavior.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { DispName = "Update Shared Markers From Table", Order = 20 } })); Style = ((BaseUnityPlugin)this).Config.Bind<WindowStyle>("General", "WindowStyle", WindowStyle.Valheim, new ConfigDescription("Valheim: the marker manager is built from the game's own menu parts, including the warm/cool tint that follows the day/night cycle. Simple: a plain window, as a fallback if the Valheim-styled one looks wrong. Takes effect the next time you open the manager.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { DispName = "Window Style", Order = 10 } })); KeepScrollPosition = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "KeepScrollPosition", true, new ConfigDescription("When on, the marker list stays where you had it scrolled after Save to table, and when you reopen the manager at the same table. Off: the list starts at the top. Valheim window style only.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { DispName = "Keep Scroll Position", Order = 8 } })); ScrollRowsPerStep = ((BaseUnityPlugin)this).Config.Bind<int>("General", "ScrollRowsPerStep", 3, new ConfigDescription("How many markers the list moves per mouse-wheel step. Higher is faster. Valheim window style only.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 20), new object[1] { new ConfigurationManagerAttributes { DispName = "Scroll Rows Per Step", Order = 6 } })); DuplicatesView = ((BaseUnityPlugin)this).Config.Bind<bool>("Duplicates", "DuplicatesView", false, new ConfigDescription("Adds a \"Show only possible duplicates\" button to the marker manager, which lists only markers that have the same icon and are close together, grouped.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { DispName = "Duplicates View", Order = 20 } })); DuplicateDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Duplicates", "DuplicateDistance", 50f, new ConfigDescription("How close (in meters) two markers with the same icon must be to count as possible duplicates.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 500f), new object[1] { new ConfigurationManagerAttributes { DispName = "Duplicate Distance", Order = 10 } })); } } internal sealed class ConfigurationManagerAttributes { public bool? ShowRangeAsPercent; public Action<ConfigEntryBase> CustomDrawer; public CustomHotkeyDrawerFunc CustomHotkeyDrawer; public bool? Browsable; public string Category; public object DefaultValue; public bool? HideDefaultButton; public bool? HideSettingName; public string Description; public string DispName; public int? Order; public bool? ReadOnly; public bool? IsAdvanced; public Func<object, string> ObjToStr; public Func<string, object> StrToObj; } internal delegate bool CustomHotkeyDrawerFunc(ConfigEntryBase setting, ref bool isEditing); internal static class LocalMap { private static readonly FieldRef<Minimap, List<PinData>> PinsRef = AccessTools.FieldRefAccess<Minimap, List<PinData>>("m_pins"); internal const float SameMarkerRadius = 1f; private static readonly FieldRef<Minimap, bool> PinUpdateRequiredRef = AccessTools.FieldRefAccess<Minimap, bool>("m_pinUpdateRequired"); private static readonly MethodInfo DestroyPinMarkerMethod = AccessTools.Method(typeof(Minimap), "DestroyPinMarker", (Type[])null, (Type[])null); internal static long LocalPlayerId { get { if (!((Object)(object)Player.m_localPlayer != (Object)null)) { return 0L; } return Player.m_localPlayer.GetPlayerID(); } } internal static List<PinData> Pins(Minimap minimap) { return PinsRef.Invoke(minimap); } internal static PinData FindPin(Minimap minimap, Vector3 pos, long ownerId) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Invalid comparison between Unknown and I4 //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) PinData result = null; float num = 1f; foreach (PinData item in Pins(minimap)) { if (item.m_save && item.m_ownerID == ownerId && (int)item.m_type != 4) { float num2 = Utils.DistanceXZ(pos, item.m_pos); if (num2 < num) { result = item; num = num2; } } } return result; } internal static void UpdatePin(Minimap minimap, PinData pin, string name, PinType type, bool isChecked) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) DestroyPinMarker(minimap, pin); pin.m_name = name ?? ""; pin.m_type = type; pin.m_icon = GetIcon(type); pin.m_checked = isChecked; pin.m_NamePinData = (string.IsNullOrEmpty(pin.m_name) ? ((PinNameData)null) : new PinNameData(pin)); PinUpdateRequiredRef.Invoke(minimap) = true; } private static void DestroyPinMarker(Minimap minimap, PinData pin) { DestroyPinMarkerMethod.Invoke(minimap, new object[1] { pin }); } internal static Sprite GetIcon(PinType type) { //IL_0021: 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_0027: 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_002d: 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) Minimap instance = Minimap.instance; if ((Object)(object)instance == (Object)null) { return null; } foreach (SpriteData icon in instance.m_icons) { if (icon.m_name == type) { return icon.m_icon; } } return null; } } public enum WindowStyle { Valheim, Simple } internal class MarkerManagerWindow : MonoBehaviour { private const int WindowId = 4433873; private const float VirtualHeight = 1080f; private const float WindowWidth = 1180f; private const float ListHeight = 560f; private const float MaxDistanceFromTable = 10f; private static readonly Color WindowBackground = new Color(0.12f, 0.12f, 0.12f, 0.95f); private static bool _simple; private Vector2 _scroll; private bool _positioned; private Rect _windowRect; private GUIStyle _windowStyle; internal static bool IsOpen { get; private set; } internal static bool IsTyping { get { if (IsOpen) { if (!_simple) { return ValheimMarkerPanel.IsTyping; } return GUIUtility.keyboardControl != 0; } return false; } } internal static void Open(MapTable table) { if (!((Object)(object)table == (Object)null)) { MarkerSession.Begin(table); IsOpen = true; _simple = CartographyAdminPlugin.Style.Value == WindowStyle.Simple || !ValheimMarkerPanel.Show(); } } internal static void Close() { IsOpen = false; GUIUtility.keyboardControl = 0; ValheimMarkerPanel.Hide(); MarkerSession.End(); } private void Update() { //IL_0040: 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) if (IsOpen) { if (!_simple) { ValheimMarkerPanel.HandleWheel(); } MapTable table = MarkerSession.Table; Player localPlayer = Player.m_localPlayer; if ((Object)(object)table == (Object)null || (Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead() || Vector3.Distance(((Component)localPlayer).transform.position, ((Component)table).transform.position) > 10f) { Close(); } } } private void OnGUI() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Expected O, but got Unknown //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) if (IsOpen && _simple) { if ((int)Event.current.type == 4 && (int)Event.current.keyCode == 27) { Event.current.Use(); } float num = (float)Screen.height / 1080f; GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(num, num, 1f)); if (!_positioned) { float num2 = (float)Screen.width / num; _windowRect = new Rect((num2 - 1180f) / 2f, 120f, 1180f, 0f); _positioned = true; } _windowRect = GUILayout.Window(4433873, _windowRect, new WindowFunction(DrawWindow), "Cartography table markers", WindowStyleFor(), Array.Empty<GUILayoutOption>()); } } private void DrawWindow(int id) { //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) int changeCount = MarkerSession.ChangeCount; GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label($"{MarkerSession.Rows.Count} markers on this table" + ((changeCount > 0) ? $", {changeCount} unsaved change(s)" : ""), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(360f) }); GUILayout.Label("Search:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) }); MarkerSession.Filter = GUILayout.TextField(MarkerSession.Filter, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(260f) }); if (CartographyAdminPlugin.DuplicatesView.Value) { if (GUILayout.Button(MarkerSession.DuplicatesButtonLabel, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(220f) })) { MarkerSession.DuplicatesOnly = !MarkerSession.DuplicatesOnly; if (MarkerSession.DuplicatesOnly) { MarkerSession.FindDuplicates(); } } GUILayout.Label(MarkerSession.DuplicatesStatus, Array.Empty<GUILayoutOption>()); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label("", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(28f) }); if (GUILayout.Button(SortLabel(SortColumn.Name, "Name", "(A-Z)", "(Z-A)"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(270f) })) { MarkerSession.SortOn(SortColumn.Name); } GUILayout.Label("Icon", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(160f) }); GUILayout.Label("Crossed out", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(90f) }); GUILayout.Label("Owner", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(170f) }); GUILayout.Label("Position (x, z)", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(130f) }); if (GUILayout.Button(SortLabel(SortColumn.Distance, "Distance", "(near)", "(far)"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(110f) })) { MarkerSession.SortOn(SortColumn.Distance); } GUILayout.EndHorizontal(); _scroll = GUILayout.BeginScrollView(_scroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(560f) }); foreach (MarkerRow item in MarkerSession.VisibleRows()) { DrawRow(item); } GUILayout.EndScrollView(); GUILayout.Label(MarkerSession.Status, Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUI.enabled = changeCount > 0; if (GUILayout.Button("Save to table", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(160f), GUILayout.Height(30f) })) { MarkerSession.Save(); } if (GUILayout.Button("Undo all changes", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(160f), GUILayout.Height(30f) })) { MarkerSession.UndoAll(); } GUI.enabled = true; GUILayout.FlexibleSpace(); if (GUILayout.Button("Close (Esc / Tab)", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(140f), GUILayout.Height(30f) })) { Close(); } GUILayout.EndHorizontal(); GUI.DragWindow(new Rect(0f, 0f, 10000f, 22f)); } private static string SortLabel(SortColumn column, string name, string ascending, string descending) { if (MarkerSession.SortBy == column) { return name + " " + (MarkerSession.SortDescending ? descending : ascending); } return name; } private void DrawRow(MarkerRow row) { //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_001d: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: 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) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) Color color = GUI.color; if (row.Deleted) { GUI.color = new Color(1f, 0.5f, 0.5f); } else if (row.Changed) { GUI.color = new Color(1f, 0.92f, 0.5f); } GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); DrawSprite(GUILayoutUtility.GetRect(24f, 24f, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(24f), GUILayout.Height(24f) }), LocalMap.GetIcon(row.Type)); GUILayout.Space(4f); GUI.enabled = !row.Deleted; row.Name = GUILayout.TextField(row.Name, 40, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(270f) }); if (MarkerSession.IsPlayerIcon(row.Type)) { PinType[] playerIcons = MarkerSession.PlayerIcons; foreach (PinType val in playerIcons) { Color color2 = GUI.color; if (val != row.Type) { GUI.color = new Color(color2.r, color2.g, color2.b, 0.45f); } if (GUILayout.Button(GUIContent.none, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(28f), GUILayout.Height(24f) })) { row.Type = val; } DrawSprite(Shrink(GUILayoutUtility.GetLastRect(), 3f), LocalMap.GetIcon(val)); GUI.color = color2; } } else { GUILayout.Label(((object)Unsafe.As<PinType, PinType>(ref row.Type)/*cast due to .constrained prefix*/).ToString(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(160f) }); } row.Checked = GUILayout.Toggle(row.Checked, "", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(90f) }); GUI.enabled = true; GUILayout.Label(MarkerSession.OwnerLabel(row.Original), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(170f) }); GUILayout.Label($"{row.Original.Pos.x:0}, {row.Original.Pos.z:0}", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(130f) }); GUILayout.Label($"{MarkerSession.DistanceTo(row):0} m", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) }); if (GUILayout.Button(row.Deleted ? "Undo" : "Delete", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) })) { row.Deleted = !row.Deleted; } if (row.Changed && !row.Deleted && GUILayout.Button("Reset", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) })) { row.Reset(); } GUILayout.EndHorizontal(); GUI.color = color; } private GUIStyle WindowStyleFor() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_0056: Expected O, but got Unknown if (_windowStyle != null) { return _windowStyle; } Texture2D val = new Texture2D(1, 1) { hideFlags = (HideFlags)61 }; val.SetPixel(0, 0, WindowBackground); val.Apply(); _windowStyle = new GUIStyle(GUI.skin.window) { border = new RectOffset(0, 0, 0, 0) }; _windowStyle.normal.background = val; _windowStyle.onNormal.background = val; return _windowStyle; } private static Rect Shrink(Rect rect, float by) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) return new Rect(((Rect)(ref rect)).x + by, ((Rect)(ref rect)).y + by, ((Rect)(ref rect)).width - 2f * by, ((Rect)(ref rect)).height - 2f * by); } private static void DrawSprite(Rect rect, Sprite sprite) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_0064: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)sprite == (Object)null) && !((Object)(object)sprite.texture == (Object)null)) { Texture2D texture = sprite.texture; Rect textureRect = sprite.textureRect; GUI.DrawTextureWithTexCoords(rect, (Texture)(object)texture, new Rect(((Rect)(ref textureRect)).x / (float)((Texture)texture).width, ((Rect)(ref textureRect)).y / (float)((Texture)texture).height, ((Rect)(ref textureRect)).width / (float)((Texture)texture).width, ((Rect)(ref textureRect)).height / (float)((Texture)texture).height)); } } } internal class MarkerRow { public SharedMapPin Original; public string Name; public PinType Type; public bool Checked; public bool Deleted; public bool IsMine; public int DuplicateGroup = -1; public bool Changed { get { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) if (!Deleted && !(Name != (Original.Name ?? "")) && Type == Original.Type) { return Checked != Original.Checked; } return true; } } public void Reset() { //IL_0021: 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) Name = Original.Name ?? ""; Type = Original.Type; Checked = Original.Checked; Deleted = false; } } internal enum SortColumn { Name, Distance } internal static class MarkerSession { internal static readonly PinType[] PlayerIcons; private static readonly Dictionary<long, string> NameCache; internal static readonly List<MarkerRow> Rows; internal static string Filter; internal static bool DuplicatesOnly; internal static string Status; internal static SortColumn SortBy; internal static bool SortDescending; private static readonly FieldInfo UserInfoField; private static readonly FieldInfo UserIdField; internal static MapTable Table { get; private set; } internal static string DuplicatesButtonLabel { get { if (!DuplicatesOnly) { return "Show only possible duplicates"; } return "Show all markers"; } } internal static string DuplicatesStatus { get { if (!DuplicatesOnly) { return "(Showing all markers)"; } return "(Showing possible duplicates only)"; } } internal static int ChangeCount { get { int num = 0; foreach (MarkerRow row in Rows) { if (row.Changed) { num++; } } return num; } } internal static void SortOn(SortColumn column) { if (SortBy == column) { SortDescending = !SortDescending; return; } SortBy = column; SortDescending = false; } private static int CompareNames(MarkerRow a, MarkerRow b) { return string.Compare(DisplayName(a.Name), DisplayName(b.Name), StringComparison.OrdinalIgnoreCase); } private static int CompareDistances(MarkerRow a, MarkerRow b) { return DistanceTo(a).CompareTo(DistanceTo(b)); } private static int CompareRows(MarkerRow a, MarkerRow b) { int num = ((SortBy == SortColumn.Name) ? CompareNames(a, b) : CompareDistances(a, b)); if (num == 0) { num = ((SortBy == SortColumn.Name) ? CompareDistances(a, b) : CompareNames(a, b)); } if (!SortDescending) { return num; } return -num; } internal static void Begin(MapTable table) { Table = table; Filter = ""; DuplicatesOnly = false; Status = ""; LoadFrom(SharedMapData.Load(table)); } internal static void End() { Table = null; Rows.Clear(); } internal static void UndoAll() { if (!((Object)(object)Table == (Object)null)) { LoadFrom(SharedMapData.Load(Table)); Status = "Changes discarded."; } } internal static bool IsPlayerIcon(PinType type) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return Array.IndexOf(PlayerIcons, type) >= 0; } internal static float DistanceTo(MarkerRow row) { //IL_001d: 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) if (!((Object)(object)Player.m_localPlayer != (Object)null)) { return 0f; } return Utils.DistanceXZ(((Component)Player.m_localPlayer).transform.position, row.Original.Pos); } private static void LoadFrom(SharedMapData data) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) Rows.Clear(); long localPlayerId = LocalMap.LocalPlayerId; foreach (SharedMapPin pin in data.Pins) { Rows.Add(new MarkerRow { Original = pin, Name = (pin.Name ?? ""), Type = pin.Type, Checked = pin.Checked, IsMine = (pin.OwnerId == localPlayerId) }); } FindDuplicates(); } internal static void FindDuplicates() { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) float value = CartographyAdminPlugin.DuplicateDistance.Value; int count = Rows.Count; int[] parent = new int[count]; for (int i = 0; i < count; i++) { parent[i] = i; } for (int j = 0; j < count; j++) { for (int k = j + 1; k < count; k++) { if (Rows[j].Original.Type == Rows[k].Original.Type && Utils.DistanceXZ(Rows[j].Original.Pos, Rows[k].Original.Pos) <= value) { parent[Find(j)] = Find(k); } } } Dictionary<int, int> dictionary = new Dictionary<int, int>(); for (int l = 0; l < count; l++) { int key = Find(l); dictionary[key] = ((!dictionary.TryGetValue(key, out var value2)) ? 1 : (value2 + 1)); } for (int m = 0; m < count; m++) { int num = Find(m); Rows[m].DuplicateGroup = ((dictionary[num] > 1) ? num : (-1)); } int Find(int num2) { while (parent[num2] != num2) { num2 = (parent[num2] = parent[parent[num2]]); } return num2; } } internal static List<MarkerRow> VisibleRows() { List<MarkerRow> list = new List<MarkerRow>(); foreach (MarkerRow row in Rows) { if ((!DuplicatesOnly || row.DuplicateGroup >= 0) && (Filter.Length <= 0 || DisplayName(row.Name).IndexOf(Filter, StringComparison.OrdinalIgnoreCase) >= 0 || OwnerLabel(row.Original).IndexOf(Filter, StringComparison.OrdinalIgnoreCase) >= 0)) { list.Add(row); } } list.Sort(CompareRows); if (!DuplicatesOnly) { return list; } Dictionary<int, List<MarkerRow>> dictionary = new Dictionary<int, List<MarkerRow>>(); List<int> list2 = new List<int>(); foreach (MarkerRow item in list) { if (!dictionary.TryGetValue(item.DuplicateGroup, out var value)) { value = new List<MarkerRow>(); dictionary[item.DuplicateGroup] = value; list2.Add(item.DuplicateGroup); } value.Add(item); } List<MarkerRow> list3 = new List<MarkerRow>(list.Count); foreach (int item2 in list2) { list3.AddRange(dictionary[item2]); } return list3; } internal static void Save() { //IL_014d: 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) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) string reason = null; if ((Object)(object)Table == (Object)null || !TableAccess.CanManage(Table, out reason)) { Status = ((reason != null) ? Localization.instance.Localize(reason) : "Can't save to this table."); return; } SharedMapData sharedMapData = SharedMapData.Load(Table); int num = 0; int num2 = 0; List<MarkerRow> list = new List<MarkerRow>(); foreach (MarkerRow row in Rows) { if (!row.Changed) { continue; } list.Add(row); SharedMapPin sharedMapPin = sharedMapData.Pins.Find((SharedMapPin p) => p.OwnerId == row.Original.OwnerId && Utils.DistanceXZ(p.Pos, row.Original.Pos) < 0.01f); if (sharedMapPin == null) { num2++; continue; } if (row.Deleted) { sharedMapData.Pins.Remove(sharedMapPin); } else { sharedMapPin.Name = row.Name; sharedMapPin.Type = row.Type; sharedMapPin.Checked = row.Checked; } num++; } sharedMapData.Save(Table); Table.m_writeEffects.Create(((Component)Table).transform.position, ((Component)Table).transform.rotation, (Transform)null, 1f, -1, default(ZDOID)); Minimap instance = Minimap.instance; if ((Object)(object)instance != (Object)null) { foreach (MarkerRow item in list) { if (!item.IsMine) { continue; } PinData val = LocalMap.FindPin(instance, item.Original.Pos, 0L); if (val != null) { if (item.Deleted) { instance.RemovePin(val); } else { LocalMap.UpdatePin(instance, val, item.Name, item.Type, item.Checked); } } } instance.AddSharedMapData(sharedMapData.Write()); } LoadFrom(sharedMapData); Status = $"Saved {num} change(s) to the table." + ((num2 > 0) ? $" {num2} marker(s) had already been removed from the table by someone else." : ""); CartographyAdminPlugin.Log.LogInfo((object)Status); } internal static string DisplayName(string name) { if (string.IsNullOrEmpty(name) || name.IndexOf('$') < 0 || Localization.instance == null) { return name ?? ""; } return Localization.instance.Localize(name); } internal static string OwnerLabel(SharedMapPin pin) { //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) if (pin.OwnerId == LocalMap.LocalPlayerId) { return "You"; } if (NameCache.TryGetValue(pin.OwnerId, out var value)) { return value; } string text; foreach (Player allPlayer in Player.GetAllPlayers()) { if (!((Object)(object)allPlayer != (Object)null) || allPlayer.GetPlayerID() != pin.OwnerId) { continue; } text = (NameCache[pin.OwnerId] = allPlayer.GetPlayerName()); text = text; goto IL_014b; } if (!string.IsNullOrEmpty(pin.Author) && (Object)(object)ZNet.instance != (Object)null) { foreach (PlayerInfo player in ZNet.instance.GetPlayerList()) { if (string.IsNullOrEmpty(player.m_name) || !(UserIdString(player) == pin.Author)) { continue; } string text2 = (NameCache[pin.OwnerId] = player.m_name); text = text2; goto IL_014b; } } return "ID " + (Math.Abs(pin.OwnerId) % 1000000).ToString("000000"); IL_014b: return text; } private static string UserIdString(PlayerInfo info) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) if (UserInfoField == null || UserIdField == null) { return null; } object value = UserInfoField.GetValue(info); if (value == null) { return null; } return UserIdField.GetValue(value)?.ToString(); } static MarkerSession() { PinType[] array = new PinType[5]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); PlayerIcons = (PinType[])(object)array; NameCache = new Dictionary<long, string>(); Rows = new List<MarkerRow>(); Filter = ""; Status = ""; SortBy = SortColumn.Distance; UserInfoField = AccessTools.Field(typeof(PlayerInfo), "m_userInfo"); UserIdField = AccessTools.Field(typeof(CrossNetworkUserInfo), "m_id"); } } [HarmonyPatch(typeof(Minimap), "AddSharedMapData")] internal static class Minimap_AddSharedMapData_Patch { private static void Prefix(Minimap __instance, byte[] dataArray) { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) if (!CartographyAdminPlugin.UpdateSharedMarkersFromTable.Value || (Object)(object)Player.m_localPlayer == (Object)null) { return; } SharedMapData sharedMapData; try { sharedMapData = SharedMapData.Read(dataArray); } catch (Exception ex) { CartographyAdminPlugin.Log.LogWarning((object)("Couldn't read table data, leaving shared markers as they are: " + ex.Message)); return; } long localPlayerId = LocalMap.LocalPlayerId; List<KeyValuePair<PinData, SharedMapPin>> list = new List<KeyValuePair<PinData, SharedMapPin>>(); foreach (SharedMapPin pin in sharedMapData.Pins) { if (pin.OwnerId != 0L && pin.OwnerId != localPlayerId) { PinData val = LocalMap.FindPin(__instance, pin.Pos, pin.OwnerId); if (val != null && (!(val.m_name == pin.Name) || val.m_type != pin.Type || val.m_checked != pin.Checked)) { list.Add(new KeyValuePair<PinData, SharedMapPin>(val, pin)); } } } foreach (KeyValuePair<PinData, SharedMapPin> item in list) { LocalMap.UpdatePin(__instance, item.Key, item.Value.Name, item.Value.Type, item.Value.Checked); } if (list.Count > 0) { CartographyAdminPlugin.Log.LogInfo((object)$"Updated {list.Count} shared marker(s) from the table."); } } } [HarmonyPatch(typeof(Switch), "Interact")] internal static class Switch_Interact_Patch { private static bool Prefix(Switch __instance, ref bool __result) { if (!TableAccess.HotkeyHeld() || (Object)(object)((Component)__instance).GetComponentInParent<MapTable>() == (Object)null) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(MapTable))] internal static class MapTable_HoverText_Patch { [HarmonyPostfix] [HarmonyPatch("GetReadHoverText")] private static void ReadPostfix(MapTable __instance, ref string __result) { AddLine(__instance, ref __result); } [HarmonyPostfix] [HarmonyPatch("GetWriteHoverText")] private static void WritePostfix(MapTable __instance, ref string __result) { AddLine(__instance, ref __result); } private static void AddLine(MapTable table, ref string text) { if (TableAccess.CanManage(table, out var _)) { text = text + "\n[<color=yellow><b>" + TableAccess.HotkeyLabel + "</b></color>] Manage markers"; } } } [HarmonyPatch(typeof(TextInput), "IsVisible")] internal static class TextInput_IsVisible_Patch { private static void Postfix(ref bool __result) { if (MarkerManagerWindow.IsOpen) { __result = true; } } } [HarmonyPatch(typeof(InventoryGui), "Update")] internal static class InventoryGui_Update_Patch { private static bool Prefix() { if (!MarkerManagerWindow.IsOpen) { return true; } if (ZInput.GetButtonDown("Inventory") || ZInput.GetButtonDown("JoyButtonY")) { ZInput.ResetButtonStatus("Inventory"); MarkerManagerWindow.Close(); } return false; } } [HarmonyPatch(typeof(Menu), "Update")] internal static class Menu_Update_Patch { private static bool Prefix() { if (!MarkerManagerWindow.IsOpen) { return true; } if (ZInput.GetKeyDown((KeyCode)27, true) || ZInput.GetButtonDown("JoyMenu") || ZInput.GetButtonDown("JoyButtonB")) { MarkerManagerWindow.Close(); } return false; } } [HarmonyPatch(typeof(ZInput), "GetMouseScrollWheel")] internal static class ZInput_GetMouseScrollWheel_Patch { private static void Postfix(ref float __result) { if (MarkerManagerWindow.IsOpen) { __result = 0f; } } } [HarmonyPatch(typeof(Minimap), "InTextInput")] internal static class Minimap_InTextInput_Patch { private static void Postfix(ref bool __result) { if (MarkerManagerWindow.IsOpen) { __result = true; } } } [HarmonyPatch(typeof(Hud), "UpdateCrosshair")] internal static class Hud_UpdateCrosshair_Patch { private static void Postfix(Hud __instance) { if (MarkerManagerWindow.IsOpen) { ((TMP_Text)__instance.m_hoverName).text = ""; ((Graphic)__instance.m_hoverName).raycastTarget = false; ((Component)__instance.m_crosshair).gameObject.SetActive(false); ((Component)__instance.m_crosshairBow).gameObject.SetActive(false); } } } [HarmonyPatch(typeof(Hud), "UpdateStealth")] internal static class Hud_UpdateStealth_Patch { private static void Postfix(Hud __instance) { if (MarkerManagerWindow.IsOpen) { __instance.m_hidden.SetActive(false); __instance.m_targeted.SetActive(false); __instance.m_targetedAlert.SetActive(false); ((Component)__instance.m_stealthBar).gameObject.SetActive(false); } } } internal class SharedMapPin { public long OwnerId; public string Name; public Vector3 Pos; public PinType Type; public bool Checked; public string Author; } internal class SharedMapData { public const int CurrentVersion = 3; private const int PinsVersion = 2; private const int PinsAuthorVersion = 3; public bool[] Explored = new bool[0]; public List<SharedMapPin> Pins = new List<SharedMapPin>(); public static SharedMapData Read(byte[] decompressed) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) SharedMapData sharedMapData = new SharedMapData(); if (decompressed == null) { return sharedMapData; } ZPackage val = new ZPackage(decompressed); int num = val.ReadInt(); int num2 = val.ReadInt(); sharedMapData.Explored = new bool[num2]; for (int i = 0; i < num2; i++) { sharedMapData.Explored[i] = val.ReadBool(); } if (num >= 2) { int num3 = val.ReadInt(); for (int j = 0; j < num3; j++) { SharedMapPin sharedMapPin = new SharedMapPin { OwnerId = val.ReadLong(), Name = val.ReadString(), Pos = val.ReadVector3(), Type = (PinType)val.ReadInt(), Checked = val.ReadBool() }; sharedMapPin.Author = ((num >= 3) ? val.ReadString() : ""); sharedMapData.Pins.Add(sharedMapPin); } } return sharedMapData; } public byte[] Write() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected I4, but got Unknown ZPackage val = new ZPackage(); val.Write(3); val.Write(Explored.Length); bool[] explored = Explored; foreach (bool flag in explored) { val.Write(flag); } val.Write(Pins.Count); foreach (SharedMapPin pin in Pins) { val.Write(pin.OwnerId); val.Write(pin.Name ?? ""); val.Write(pin.Pos); val.Write((int)pin.Type); val.Write(pin.Checked); val.Write(pin.Author ?? ""); } return val.GetArray(); } public static SharedMapData Load(MapTable table) { ZNetView component = ((Component)table).GetComponent<ZNetView>(); ZDO obj = ((component != null) ? component.GetZDO() : null); byte[] array = ((obj != null) ? obj.GetByteArray(ZDOVars.s_data, (byte[])null) : null); if (array != null) { return Read(Utils.Decompress(array)); } return new SharedMapData(); } public void Save(MapTable table) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown ZNetView component = ((Component)table).GetComponent<ZNetView>(); if (!((Object)(object)component == (Object)null) && component.IsValid()) { component.InvokeRPC("MapData", new object[1] { (object)new ZPackage(Utils.Compress(Write())) }); } } } internal static class TableAccess { private static readonly FieldInfo AllAreasField = AccessTools.Field(typeof(PrivateArea), "m_allAreas"); private static readonly Func<PrivateArea, bool> AreaEnabled = AccessTools.MethodDelegate<Func<PrivateArea, bool>>(AccessTools.Method(typeof(PrivateArea), "IsEnabled", (Type[])null, (Type[])null), (object)null, true); private static readonly Func<PrivateArea, Vector3, float, bool> AreaContains = AccessTools.MethodDelegate<Func<PrivateArea, Vector3, float, bool>>(AccessTools.Method(typeof(PrivateArea), "IsInside", (Type[])null, (Type[])null), (object)null, true); private static readonly Func<PrivateArea, bool> AreaGrantsLocal = AccessTools.MethodDelegate<Func<PrivateArea, bool>>(AccessTools.Method(typeof(PrivateArea), "HaveLocalAccess", (Type[])null, (Type[])null), (object)null, true); internal const KeyCode MenuKey = (KeyCode)101; internal static string HotkeyLabel => $"{CartographyAdminPlugin.OpenMenuModifier.Value}+{(object)(KeyCode)101}"; internal static MapTable GetHoveredTable() { Player localPlayer = Player.m_localPlayer; GameObject val = (((Object)(object)localPlayer != (Object)null) ? ((Humanoid)localPlayer).GetHoverObject() : null); if (!((Object)(object)val != (Object)null)) { return null; } return val.GetComponentInParent<MapTable>(); } internal static bool CanManage(MapTable table, out string reason) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) reason = null; if ((Object)(object)table == (Object)null) { return false; } bool flag = (Object)(object)ZNet.instance != (Object)null && ZNet.instance.LocalPlayerIsAdminOrHost(); if (CartographyAdminPlugin.Permission.Value == EditPermission.AdminsOnly) { if (flag) { return true; } reason = "Only server admins can manage this table's markers."; return false; } if (flag || IsBuilder(table) || HasWardAccess(((Component)table).transform.position)) { return true; } reason = "Only the table's builder, players on a ward here,\nor server admins can manage these markers."; return false; } private static bool IsBuilder(MapTable table) { Piece componentInParent = ((Component)table).GetComponentInParent<Piece>(); Player localPlayer = Player.m_localPlayer; if ((Object)(object)componentInParent != (Object)null && (Object)(object)localPlayer != (Object)null && componentInParent.GetCreator() != 0L) { return componentInParent.GetCreator() == localPlayer.GetPlayerID(); } return false; } private static bool HasWardAccess(Vector3 point) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) if (!(AllAreasField.GetValue(null) is List<PrivateArea> list)) { return false; } foreach (PrivateArea item in list) { if ((Object)(object)item != (Object)null && AreaEnabled(item) && AreaContains(item, point, 0f) && AreaGrantsLocal(item)) { return true; } } return false; } internal static bool ModifierHeld() { switch (CartographyAdminPlugin.OpenMenuModifier.Value) { case MenuModifier.Ctrl: if (!ZInput.GetKey((KeyCode)306, false)) { return ZInput.GetKey((KeyCode)305, false); } return true; case MenuModifier.Alt: if (!ZInput.GetKey((KeyCode)308, false)) { return ZInput.GetKey((KeyCode)307, false); } return true; default: if (!ZInput.GetKey((KeyCode)304, false)) { return ZInput.GetKey((KeyCode)303, false); } return true; } } internal static bool HotkeyPressed() { if (ZInput.GetKeyDown((KeyCode)101, false)) { return ModifierHeld(); } return false; } internal static bool HotkeyHeld() { if (ZInput.GetKey((KeyCode)101, false)) { return ModifierHeld(); } return false; } } internal static class ValheimMarkerPanel { private class RowView { public MarkerRow Row; public GameObject Root; public Image Icon; public TMP_Text Name; public TMP_Text Distance; public GameObject Selected; public GameObject CrossOut; } private const float PanelWidth = 1240f; private const float PanelHeight = 780f; private const float Margin = 30f; private const float HeaderTop = 128f; private const float HeaderHeight = 30f; private const float ListTop = 164f; private const float ListWidth = 560f; private const float ListHeight = 486f; private const float DetailLeft = 640f; private const float DetailWidth = 570f; private static GameObject _canvas; private static RectTransform _panel; private static TMP_FontAsset _font; private static TMP_FontAsset _bodyFont; private static Color _textColor = Color.white; private static readonly Color BodyColor = Color.white; private static readonly Color LabelColor = new Color(1f, 0.647f, 0f); private const float ScrollbarWidth = 20f; private const float RowDistanceWidth = 110f; private static float _rowHeight = 30f; private static TMP_Text _summary; private static TMP_Text _status; private static TMP_Text _hint; private static TMP_Text _typeNote; private static TMP_Text _owner; private static TMP_Text _position; private static TMP_Text _distance; private static TMP_Text _duplicatesStatus; private static TMP_InputField _search; private static TMP_InputField _nameField; private static TMP_Text _nameHeader; private static TMP_Text _distanceHeader; private static RectTransform _listContent; private static ScrollRect _scroll; private static Button _duplicates; private static Button _crossOut; private static Button _delete; private static Button _reset; private static Button _save; private static Button _undoAll; private static Image _detailIcon; private static GameObject _detailCrossOut; private static MapTable _lastTable; private static bool _buttonLayoutLogged; private static bool _crossOutMissingLogged; private static GameObject _detailRoot; private static readonly List<KeyValuePair<PinType, Image>> IconButtons = new List<KeyValuePair<PinType, Image>>(); private static readonly List<RowView> RowViews = new List<RowView>(); private static MarkerRow _selected; private static bool _suppressEvents; internal static bool IsTyping { get { if ((Object)(object)_canvas == (Object)null || !_canvas.activeSelf || (Object)(object)EventSystem.current == (Object)null) { return false; } GameObject currentSelectedGameObject = EventSystem.current.currentSelectedGameObject; TMP_InputField val = (((Object)(object)currentSelectedGameObject != (Object)null) ? currentSelectedGameObject.GetComponent<TMP_InputField>() : null); if ((Object)(object)val != (Object)null) { return val.isFocused; } return false; } } internal static bool Show() { try { if ((Object)(object)_canvas == (Object)null) { Build(); } _selected = null; _suppressEvents = true; _search.text = ""; _suppressEvents = false; ((Component)_duplicates).gameObject.SetActive(CartographyAdminPlugin.DuplicatesView.Value); ((Component)_duplicatesStatus).gameObject.SetActive(CartographyAdminPlugin.DuplicatesView.Value); RefreshDuplicatesControls(); _canvas.SetActive(true); bool num = (Object)(object)MarkerSession.Table != (Object)null && (Object)(object)MarkerSession.Table == (Object)(object)_lastTable; _lastTable = MarkerSession.Table; RebuildList(num && CartographyAdminPlugin.KeepScrollPosition.Value); return true; } catch (Exception arg) { CartographyAdminPlugin.Log.LogError((object)$"Couldn't build the Valheim-styled marker manager, using the simple window instead: {arg}"); if ((Object)(object)_canvas != (Object)null) { Object.Destroy((Object)(object)_canvas); } _canvas = null; return false; } } internal static void Hide() { _selected = null; if (!((Object)(object)_canvas == (Object)null)) { if ((Object)(object)EventSystem.current != (Object)null) { EventSystem.current.SetSelectedGameObject((GameObject)null); } ClearRows(); _canvas.SetActive(false); } } private static void Build() { //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Expected O, but got Unknown //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Expected O, but got Unknown //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Expected O, but got Unknown //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Unknown result type (might be due to invalid IL or missing references) InventoryGui instance = InventoryGui.instance; Minimap instance2 = Minimap.instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance2 == (Object)null) { throw new InvalidOperationException("The inventory or map UI isn't loaded yet."); } TMP_InputField nameInput = (TMP_InputField)(object)instance2.m_nameInput; Button takeAllButton = instance.m_takeAllButton; Scrollbar recipeListScroll = instance.m_recipeListScroll; GameObject recipeElementPrefab = instance.m_recipeElementPrefab; TMP_Text containerName = instance.m_containerName; if ((Object)(object)nameInput == (Object)null || (Object)(object)takeAllButton == (Object)null || (Object)(object)recipeListScroll == (Object)null || (Object)(object)recipeElementPrefab == (Object)null || (Object)(object)containerName == (Object)null) { throw new InvalidOperationException("A Valheim UI part to copy wasn't found."); } _font = containerName.font; _textColor = ((Graphic)containerName).color; _bodyFont = (((Object)(object)instance.m_recipeDecription != (Object)null && (Object)(object)instance.m_recipeDecription.font != (Object)null) ? instance.m_recipeDecription.font : _font); _rowHeight = ((instance.m_recipeListSpace > 0f) ? instance.m_recipeListSpace : 30f); _canvas = new GameObject("CartographyAdmin_MarkerManager", new Type[1] { typeof(RectTransform) }); _canvas.SetActive(false); Canvas obj = _canvas.AddComponent<Canvas>(); obj.renderMode = (RenderMode)0; obj.sortingOrder = 30; CanvasScaler obj2 = _canvas.AddComponent<CanvasScaler>(); obj2.uiScaleMode = (ScaleMode)1; obj2.referenceResolution = new Vector2(1920f, 1080f); obj2.screenMatchMode = (ScreenMatchMode)0; obj2.matchWidthOrHeight = 1f; _canvas.AddComponent<GraphicRaycaster>(); GameObject val = new GameObject("Panel", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(_canvas.transform, false); _panel = (RectTransform)val.transform; RectTransform panel = _panel; RectTransform panel2 = _panel; RectTransform panel3 = _panel; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0.5f, 0.5f); panel3.pivot = val2; Vector2 anchorMin = (panel2.anchorMax = val2); panel.anchorMin = anchorMin; _panel.sizeDelta = new Vector2(1240f, 780f); CopyImage(FindPanelImage((Transform)(object)instance.m_container), val.AddComponent<Image>()); TMP_Text obj3 = MakeText((Transform)(object)_panel, "Cartography table markers", 30f, 18f, 1180f, 44f, containerName.fontSize * 1.2f); obj3.fontStyle = (FontStyles)1; obj3.alignment = (TextAlignmentOptions)4098; _summary = MakeBodyText((Transform)(object)_panel, "", 30f, 62f, 1180f, 28f, containerName.fontSize * 0.8f); _search = MakeInput(nameInput, (Transform)(object)_panel, "Search names or owners...", 30f, 88f, 400f, 36f); ((UnityEvent<string>)(object)_search.onValueChanged).AddListener((UnityAction<string>)delegate(string value) { if (!_suppressEvents) { MarkerSession.Filter = value ?? ""; RebuildList(); } }); _duplicates = MakeButton(takeAllButton, (Transform)(object)_panel, MarkerSession.DuplicatesButtonLabel, 450f, 88f, 320f, 36f, delegate { MarkerSession.DuplicatesOnly = !MarkerSession.DuplicatesOnly; if (MarkerSession.DuplicatesOnly) { MarkerSession.FindDuplicates(); } RefreshDuplicatesControls(); RebuildList(); }); _duplicatesStatus = MakeBodyText((Transform)(object)_panel, "", 784f, 88f, 330f, 36f, 20f); ((Graphic)_duplicatesStatus).color = LabelColor; _nameHeader = MakeSortHeader(takeAllButton, 30f, 240f, SortColumn.Name); _distanceHeader = MakeSortHeader(takeAllButton, 370f, 220f, SortColumn.Distance); BuildList(recipeListScroll); BuildDetail(nameInput, takeAllButton); _status = MakeBodyText((Transform)(object)_panel, "", 30f, 668f, 1180f, 30f, containerName.fontSize * 0.8f); _save = MakeButton(takeAllButton, (Transform)(object)_panel, "Save to table", 30f, 706f, 240f, 48f, delegate { MarkerSession.Save(); _selected = null; RebuildList(CartographyAdminPlugin.KeepScrollPosition.Value); }); _undoAll = MakeButton(takeAllButton, (Transform)(object)_panel, "Undo all changes", 290f, 706f, 240f, 48f, delegate { MarkerSession.UndoAll(); _selected = null; RebuildList(); }); MakeButton(takeAllButton, (Transform)(object)_panel, "Close", 970f, 706f, 240f, 48f, MarkerManagerWindow.Close); } private static void BuildList(Scrollbar scrollTemplate) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Expected O, but got Unknown //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Expected O, but got Unknown //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Expected O, but got Unknown //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("List", new Type[1] { typeof(RectTransform) }); val.transform.SetParent((Transform)(object)_panel, false); Place((RectTransform)val.transform, 30f, 164f, 560f, 486f); ((Graphic)val.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.35f); _scroll = val.AddComponent<ScrollRect>(); GameObject val2 = new GameObject("Viewport", new Type[1] { typeof(RectTransform) }); val2.transform.SetParent(val.transform, false); RectTransform val3 = (RectTransform)val2.transform; val3.anchorMin = Vector2.zero; val3.anchorMax = Vector2.one; val3.offsetMin = new Vector2(4f, 4f); val3.offsetMax = new Vector2(-4f, -4f); val2.AddComponent<RectMask2D>(); GameObject val4 = new GameObject("Content", new Type[1] { typeof(RectTransform) }); val4.transform.SetParent((Transform)(object)val3, false); _listContent = (RectTransform)val4.transform; _listContent.anchorMin = new Vector2(0f, 1f); _listContent.anchorMax = new Vector2(1f, 1f); _listContent.pivot = new Vector2(0.5f, 1f); _listContent.sizeDelta = new Vector2(0f, 0f); GameObject val5 = Object.Instantiate<GameObject>(((Component)scrollTemplate).gameObject, (Transform)(object)_panel); ((Object)val5).name = "Scrollbar"; StripGamepad(val5); val5.SetActive(true); Scrollbar component = val5.GetComponent<Scrollbar>(); component.onValueChanged = new ScrollEvent(); component.direction = (Direction)2; Place((RectTransform)val5.transform, 596f, 164f, 20f, 486f); Image val6 = val5.GetComponent<Image>(); if ((Object)(object)val6 == (Object)null) { val6 = val5.AddComponent<Image>(); } ((Graphic)val6).color = (Color)(((Object)(object)val6.sprite != (Object)null) ? Color.white : new Color(0f, 0f, 0f, 0.45f)); ((Graphic)val6).raycastTarget = false; _scroll.content = _listContent; _scroll.viewport = val3; _scroll.horizontal = false; _scroll.vertical = true; _scroll.movementType = (MovementType)2; _scroll.scrollSensitivity = 0f; _scroll.verticalScrollbar = component; _scroll.verticalScrollbarVisibility = (ScrollbarVisibility)0; } private static void BuildDetail(TMP_InputField inputTemplate, Button buttonTemplate) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Expected O, but got Unknown //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) float num = (((Object)(object)_font != (Object)null) ? 22f : 20f); _hint = MakeBodyText((Transform)(object)_panel, "Select a marker on the left.", 640f, 164f, 570f, 40f, num); _detailRoot = new GameObject("Detail", new Type[1] { typeof(RectTransform) }); _detailRoot.transform.SetParent((Transform)(object)_panel, false); RectTransform val = (RectTransform)_detailRoot.transform; val.anchorMin = Vector2.zero; val.anchorMax = Vector2.one; Vector2 offsetMin = (val.offsetMax = Vector2.zero); val.offsetMin = offsetMin; GameObject val2 = new GameObject("Icon", new Type[1] { typeof(RectTransform) }); val2.transform.SetParent((Transform)(object)val, false); Place((RectTransform)val2.transform, 640f, 164f, 64f, 64f); _detailIcon = val2.AddComponent<Image>(); _detailIcon.preserveAspect = true; ((Graphic)_detailIcon).raycastTarget = false; _detailCrossOut = MakeCrossOutMark(((Component)_detailIcon).transform); ((Graphic)MakeBodyText((Transform)(object)val, "Name", 724f, 162f, 300f, 26f, num * 0.85f)).color = LabelColor; _nameField = MakeInput(inputTemplate, (Transform)(object)val, "No name", 724f, 188f, 486f, 40f); _nameField.characterLimit = 40; ((UnityEvent<string>)(object)_nameField.onValueChanged).AddListener((UnityAction<string>)delegate(string value) { if (!_suppressEvents && _selected != null) { _selected.Name = value ?? ""; RefreshSelected(); } }); ((Graphic)MakeBodyText((Transform)(object)val, "Icon", 640f, 252f, 300f, 26f, num * 0.85f)).color = LabelColor; IconButtons.Clear(); for (int num2 = 0; num2 < MarkerSession.PlayerIcons.Length; num2++) { PinType val3 = MarkerSession.PlayerIcons[num2]; IconButtons.Add(new KeyValuePair<PinType, Image>(val3, MakeIconButton((Transform)(object)val, val3, 640f + (float)num2 * 64f, 280f, 56f))); } _typeNote = MakeBodyText((Transform)(object)val, "", 640f, 280f, 570f, 56f, num * 0.85f); _crossOut = MakeButton(buttonTemplate, (Transform)(object)val, "Cross out", 640f, 360f, 190f, 38f, delegate { if (_selected != null && !_selected.Deleted) { _selected.Checked = !_selected.Checked; RefreshSelected(); } }); _owner = MakeBodyText((Transform)(object)val, "", 640f, 428f, 570f, 30f, num); _position = MakeBodyText((Transform)(object)val, "", 640f, 460f, 570f, 30f, num); _distance = MakeBodyText((Transform)(object)val, "", 640f, 492f, 570f, 30f, num); _delete = MakeButton(buttonTemplate, (Transform)(object)val, "Delete", 640f, 556f, 240f, 44f, delegate { if (_selected != null) { _selected.Deleted = !_selected.Deleted; RefreshSelected(); } }); _reset = MakeButton(buttonTemplate, (Transform)(object)val, "Reset", 900f, 556f, 240f, 44f, delegate { if (_selected != null) { _selected.Reset(); RefreshSelected(); } }); } private static void ClearRows() { foreach (RowView rowView in RowViews) { if ((Object)(object)rowView.Root != (Object)null) { Object.Destroy((Object)(object)rowView.Root); } } RowViews.Clear(); } private static void RebuildList(bool keepScroll = false) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) float y = _listContent.anchoredPosition.y; ClearRows(); GameObject val = (((Object)(object)InventoryGui.instance != (Object)null) ? InventoryGui.instance.m_recipeElementPrefab : null); List<MarkerRow> list = MarkerSession.VisibleRows(); if ((Object)(object)val != (Object)null) { for (int i = 0; i < list.Count; i++) { RowViews.Add(MakeRow(val, list[i], i)); } } _listContent.sizeDelta = new Vector2(0f, (float)list.Count * _rowHeight); if (keepScroll) { float y2 = _listContent.sizeDelta.y; Rect rect = _scroll.viewport.rect; float num = Mathf.Max(0f, y2 - ((Rect)(ref rect)).height); _listContent.anchoredPosition = new Vector2(_listContent.anchoredPosition.x, Mathf.Clamp(y, 0f, num)); } else { _scroll.verticalNormalizedPosition = 1f; } if (_selected != null && !list.Contains(_selected)) { _selected = null; } RefreshSortHeaders(); RefreshAll(); } private static TMP_Text MakeSortHeader(Button template, float x, float width, SortColumn column) { return ((Component)MakeButton(template, (Transform)(object)_panel, column.ToString(), x, 128f, width, 30f, delegate { MarkerSession.SortOn(column); RebuildList(); })).GetComponentInChildren<TMP_Text>(true); } private static void RefreshDuplicatesControls() { SetButtonText(_duplicates, MarkerSession.DuplicatesButtonLabel); _duplicatesStatus.text = MarkerSession.DuplicatesStatus; } private static void RefreshSortHeaders() { if (!((Object)(object)_nameHeader == (Object)null) && !((Object)(object)_distanceHeader == (Object)null)) { bool flag = MarkerSession.SortBy == SortColumn.Name; bool sortDescending = MarkerSession.SortDescending; _nameHeader.text = ((!flag) ? "Name" : (sortDescending ? "Name (Z-A)" : "Name (A-Z)")); _distanceHeader.text = (flag ? "Distance" : (sortDescending ? "Distance (farthest)" : "Distance (nearest)")); } } private static RowView MakeRow(GameObject template, MarkerRow row, int index) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Expected O, but got Unknown //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Expected O, but got Unknown GameObject val = Object.Instantiate<GameObject>(template, (Transform)(object)_listContent); ((Object)val).name = "Marker"; StripGamepad(val); val.SetActive(true); RectTransform val2 = (RectTransform)val.transform; val2.anchorMin = new Vector2(0f, 1f); val2.anchorMax = new Vector2(1f, 1f); val2.pivot = new Vector2(0.5f, 1f); val2.sizeDelta = new Vector2(0f, _rowHeight); val2.anchoredPosition = new Vector2(0f, (float)(-index) * _rowHeight); Transform val3 = val.transform.Find("Durability"); if ((Object)(object)val3 != (Object)null) { ((Component)val3).gameObject.SetActive(false); } Transform val4 = val.transform.Find("QualityLevel"); if ((Object)(object)val4 != (Object)null) { ((Component)val4).gameObject.SetActive(false); } RowView obj = new RowView { Row = row, Root = val }; Transform obj2 = val.transform.Find("icon"); obj.Icon = ((obj2 != null) ? ((Component)obj2).GetComponent<Image>() : null); Transform obj3 = val.transform.Find("name"); obj.Name = ((obj3 != null) ? ((Component)obj3).GetComponent<TMP_Text>() : null); Transform obj4 = val.transform.Find("selected"); obj.Selected = ((obj4 != null) ? ((Component)obj4).gameObject : null); RowView rowView = obj; if ((Object)(object)rowView.Name != (Object)null) { KeepNameOnOneLine(rowView.Name, val2); } TMP_Text val5 = MakeText(val.transform, "", 0f, 0f, 110f, _rowHeight, ((Object)(object)rowView.Name != (Object)null) ? rowView.Name.fontSize : 18f); if ((Object)(object)rowView.Name != (Object)null && (Object)(object)rowView.Name.font != (Object)null) { val5.font = rowView.Name.font; } ((Graphic)val5).color = LabelColor; RectTransform rectTransform = val5.rectTransform; rectTransform.anchorMin = new Vector2(1f, 0f); rectTransform.anchorMax = new Vector2(1f, 1f); rectTransform.pivot = new Vector2(1f, 0.5f); rectTransform.sizeDelta = new Vector2(110f, 0f); rectTransform.anchoredPosition = new Vector2(-10f, 0f); val5.alignment = (TextAlignmentOptions)4100; rowView.Distance = val5; rowView.CrossOut = (((Object)(object)rowView.Icon != (Object)null) ? MakeCrossOutMark(((Component)rowView.Icon).transform) : null); Button component = val.GetComponent<Button>(); if ((Object)(object)component != (Object)null) { component.onClick = new ButtonClickedEvent(); ((UnityEvent)component.onClick).AddListener((UnityAction)delegate { _selected = row; RefreshAll(); }); } AddHitArea(val); RefreshRow(rowView); return rowView; } private static void RefreshRow(RowView view) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) MarkerRow row = view.Row; if ((Object)(object)view.Icon != (Object)null) { view.Icon.sprite = LocalMap.GetIcon(row.Type); ((Graphic)view.Icon).color = (Color)(row.Deleted ? new Color(1f, 1f, 1f, 0.35f) : Color.white); } if ((Object)(object)view.CrossOut != (Object)null) { view.CrossOut.SetActive(row.Checked); } if ((Object)(object)view.Name != (Object)null) { string text = ((row.Name.Length > 0) ? MarkerSession.DisplayName(row.Name) : "(no name)"); string text2 = " <size=75%><color=#B0A58C>" + MarkerSession.OwnerLabel(row.Original) + "</color></size>"; if (row.Deleted) { view.Name.text = "<color=#FF7A6B><s>" + text + "</s></color>" + text2; } else if (row.Changed) { view.Name.text = "<color=#FFD966>" + text + "</color>" + text2; } else { view.Name.text = text + text2; } } if ((Object)(object)view.Distance != (Object)null) { view.Distance.text = $"{MarkerSession.DistanceTo(row):0} m"; } if ((Object)(object)view.Selected != (Object)null) { view.Selected.SetActive(row == _selected); } } private static void RefreshAll() { foreach (RowView rowView in RowViews) { RefreshRow(rowView); } RefreshDetail(); RefreshSummary(); } private static void RefreshSelected() { foreach (RowView rowView in RowViews) { if (rowView.Row == _selected) { RefreshRow(rowView); } } RefreshDetail(); RefreshSummary(); } private static void RefreshSummary() { int changeCount = MarkerSession.ChangeCount; int count = RowViews.Count; int count2 = MarkerSession.Rows.Count; _summary.text = $"{count2} markers on this table" + ((count != count2) ? $", {count} shown" : "") + ((changeCount > 0) ? $", <color=#FFD966>{changeCount} unsaved change(s)</color>" : ""); _status.text = MarkerSession.Status; ((Selectable)_save).interactable = changeCount > 0; ((Selectable)_undoAll).interactable = changeCount > 0; } private static void RefreshDetail() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) MarkerRow selected = _selected; ((Component)_hint).gameObject.SetActive(selected == null); _detailRoot.SetActive(selected != null); if (selected == null) { return; } _detailIcon.sprite = LocalMap.GetIcon(selected.Type); ((Graphic)_detailIcon).color = (Color)(selected.Deleted ? new Color(1f, 1f, 1f, 0.35f) : Color.white); if ((Object)(object)_detailCrossOut != (Object)null) { _detailCrossOut.SetActive(selected.Checked); } _suppressEvents = true; if (_nameField.text != selected.Name) { _nameField.text = selected.Name; } _suppressEvents = false; ((Selectable)_nameField).interactable = !selected.Deleted; bool flag = MarkerSession.IsPlayerIcon(selected.Type); foreach (KeyValuePair<PinType, Image> iconButton in IconButtons) { ((Component)((Component)iconButton.Value).transform.parent).gameObject.SetActive(flag); ((Graphic)iconButton.Value).color = (Color)((iconButton.Key == selected.Type) ? Color.white : new Color(1f, 1f, 1f, 0.35f)); } ((Component)_typeNote).gameObject.SetActive(!flag); _typeNote.text = (flag ? "" : $"This is a {selected.Type} marker placed by the game; its icon can't be changed."); SetButtonText(_crossOut, selected.Checked ? "Remove cross" : "Cross out"); ((Selectable)_crossOut).interactable = !selected.Deleted; SetButtonText(_delete, selected.Deleted ? "Undo delete" : "Delete"); ((Selectable)_reset).interactable = selected.Changed; _owner.text = "Owner: <color=orange>" + MarkerSession.OwnerLabel(selected.Original) + "</color>"; _position.text = $"Position: <color=orange>{selected.Original.Pos.x:0}, {selected.Original.Pos.z:0}</color>"; _distance.text = $"Distance: <color=orange>{MarkerSession.DistanceTo(selected):0} m</color>"; } private static GameObject MakeCrossOutMark(Transform icon) { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: 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_00c4: Unknown result type (might be due to invalid IL or missing references) Transform val = (((Object)(object)Minimap.instance != (Object)null && (Object)(object)Minimap.instance.m_pinPrefab != (Object)null) ? Minimap.instance.m_pinPrefab.transform.Find("Checked") : null); if ((Object)(object)val == (Object)null) { if (!_crossOutMissingLogged) { CartographyAdminPlugin.Log.LogWarning((object)"Couldn't find the map's cross-out mark; crossed-out markers won't show it in the list."); } _crossOutMissingLogged = true; return null; } GameObject val2 = Object.Instantiate<GameObject>(((Component)val).gameObject, icon, false); ((Object)val2).name = "CrossOut"; Transform transform = val2.transform; RectTransform val3 = (RectTransform)(object)((transform is RectTransform) ? transform : null); if (val3 != null) { val3.anchorMin = Vector2.zero; val3.anchorMax = Vector2.one; val3.pivot = new Vector2(0.5f, 0.5f); Vector2 offsetMin = (val3.offsetMax = Vector2.zero); val3.offsetMin = offsetMin; } Graphic[] componentsInChildren = val2.GetComponentsInChildren<Graphic>(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].raycastTarget = false; } val2.SetActive(false); return val2; } private static void Place(RectTransform rect, float x, float y, float width, float height) { //IL_0014: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0f, 1f); rect.pivot = val; Vector2 anchorMin = (rect.anchorMax = val); rect.anchorMin = anchorMin; rect.anchoredPosition = new Vector2(x, 0f - y); rect.sizeDelta = new Vector2(width, height); } private static TMP_Text MakeText(Transform parent, string text, float x, float y, float width, float height, float fontSize) { //IL_0018: 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_002a: 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) //IL_0040: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Text", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parent, false); Place((RectTransform)val.transform, x, y, width, height); val.SetActive(false); TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>(); if ((Object)(object)_font != (Object)null) { ((TMP_Text)val2).font = _font; } val.SetActive(true); ((TMP_Text)val2).fontSize = fontSize; ((Graphic)val2).color = _textColor; ((TMP_Text)val2).alignment = (TextAlignmentOptions)4097; ((TMP_Text)val2).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)val2).overflowMode = (TextOverflowModes)1; ((Graphic)val2).raycastTarget = false; ((TMP_Text)val2).richText = true; ((TMP_Text)val2).text = text; return (TMP_Text)(object)val2; } private static TMP_Text MakeBodyText(Transform parent, string text, float x, float y, float width, float height, float fontSize) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) TMP_Text val = MakeText(parent, text, x, y, width, height, fontSize); if ((Object)(object)_bodyFont != (Object)null) { val.font = _bodyFont; } ((Graphic)val).color = BodyColor; return val; } private static void KeepNameOnOneLine(TMP_Text name, RectTransform row) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_0031: 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) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) name.textWrappingMode = (TextWrappingModes)0; name.overflowMode = (TextOverflowModes)1; RectTransform rectTransform = name.rectTransform; float x = ((Transform)rectTransform).localPosition.x; Rect rect = rectTransform.rect; float num = x + ((Rect)(ref rect)).xMin; rect = row.rect; float num2 = num - ((Rect)(ref rect)).xMin; Vector2 offsetMin = rectTransform.offsetMin; Vector2 offsetMax = rectTransform.offsetMax; rectTransform.anchorMin = new Vector2(0f, rectTransform.anchorMin.y); rectTransform.anchorMax = new Vector2(1f, rectTransform.anchorMax.y); rectTransform.offsetMin = new Vector2(num2, offsetMin.y); rectTransform.offsetMax = new Vector2(-126f, offsetMax.y); } private static Button MakeButton(Button template, Transform parent, string label, float x, float y, float width, float height, Action onClick) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown GameObject val = Object.Instantiate<GameObject>(((Component)template).gameObject, parent); ((Object)val).name = label; StripGamepad(val); val.SetActive(true); Place((RectTransform)val.transform, x, y, width, height); Button component = val.GetComponent<Button>(); component.onClick = new ButtonClickedEvent(); ((UnityEvent)component.onClick).AddListener((UnityAction)delegate { onClick(); }); ((Selectable)component).interactable = true; SetButtonText(component, label); AddHitArea(val); return component; } internal static void HandleWheel() { //IL_0027: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_00cc: 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) if (!((Object)(object)_scroll == (Object)null) && !((Object)(object)_canvas == (Object)null) && _canvas.activeSelf) { float y = Input.mouseScrollDelta.y; if (!Mathf.Approximately(y, 0f) && RectTransformUtility.RectangleContainsScreenPoint((RectTransform)((Component)_scroll).transform, Vector2.op_Implicit(Input.mousePosition), (Camera)null)) { float y2 = _listContent.sizeDelta.y; Rect rect = _scroll.viewport.rect; float num = Mathf.Max(0f, y2 - ((Rect)(ref rect)).height); float num2 = _listContent.anchoredPosition.y - y * _rowHeight * (float)CartographyAdminPlugin.ScrollRowsPerStep.Value; _scroll.StopMovement(); _listContent.anchoredPosition = new Vector2(_listContent.anchoredPosition.x, Mathf.Clamp(num2, 0f, num)); } } } private static void AddHitArea(GameObject buttonObject) { //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_011d: 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_002b: Unknown result type (might be due to invalid IL or missing references) if (!_buttonLayoutLogged) { _buttonLayoutLogged = true; Graphic[] componentsInChildren = buttonObject.GetComponentsInChildren<Graphic>(true); foreach (Graphic val in componentsInChildren) { Rect rect = val.rectTransform.rect; CartographyAdminPlugin.Log.LogDebug((object)$"Button template part '{((Object)val).name}' ({((object)val).GetType().Name}): {((Rect)(ref rect)).width:0}x{((Rect)(ref rect)).height:0}, raycast {val.raycastTarget}."); } } GameObject val2 = new GameObject("HitArea", new Type[1] { typeof(RectTransform) }); val2.transform.SetParent(buttonObject.transform, false); val2.transform.SetAsFirstSibling(); RectTransform val3 = (RectTransform)val2.transform; val3.anchorMin = Vector2.zero; val3.anchorMax = Vector2.one; Vector2 offsetMin = (val3.offsetMax = Vector2.zero); val3.offsetMin = offsetMin; Image obj = val2.AddComponent<Image>(); ((Graphic)obj).color = new Color(0f, 0f, 0f, 0f); ((Graphic)obj).raycastTarget = true; } private static void SetButtonText(Button button, string label) { TMP_Text componentInChildren = ((Component)button).GetComponentInChildren<TMP_Text>(true); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.text = label; } } private static TMP_InputField MakeInput(TMP_InputField template, Transform parent, string placeholder, float x, float y, float width, float height) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown GameObject obj = Object.Instantiate<GameObject>(((Component)template).gameObject, parent); ((Object)obj).name = "Input"; StripGamepad(obj); obj.SetActive(true); Place((RectTransform)obj.transform, x, y, width, height); TMP_InputField component = obj.GetComponent<TMP_InputField>(); component.onValueChanged = new OnChangeEvent(); component.onEndEdit = new SubmitEvent(); component.onSubmit = new SubmitEvent(); component.onSelect = new SelectionEvent(); component.onDeselect = new SelectionEvent(); component.characterLimit = 0; ((Selectable)component).interactable = true; component.text = ""; Graphic placeholder2 = component.placeholder; TMP_Text val = (TMP_Text)(object)((placeholder2 is TMP_Text) ? placeholder2 : null); if (val != null) { val.text = placeholder; } return component; } private unsafe static Image MakeIconButton(Transform parent, PinType icon, float x, float y, float size) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_0076: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(((object)(*(PinType*)(&icon))/*cast due to .constrained prefix*/).ToString(), new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parent, false); Place((RectTransform)val.transform, x, y, size, size); Image val2 = val.AddComponent<Image>(); ((Graphic)val2).color = new Color(0f, 0f, 0f, 0.35f); Button obj = val.AddComponent<Button>(); ((Selectable)obj).targetGraphic = (Graphic)(object)val2; ((UnityEvent)obj.onClick).AddListener((UnityAction)delegate { //IL_0018: 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) if (_selected != null && !_selected.Deleted && MarkerSession.IsPlayerIcon(_selected.Type)) { _selected.Type = icon; RefreshSelected(); } }); GameObject val3 = new GameObject("Icon", new Type[1] { typeof(RectTransform) }); val3.transform.SetParent(val.transform, false); RectTransform val4 = (RectTransform)val3.transform; val4.anchorMin = Vector2.zero; val4.anchorMax = Vector2.one; val4.offsetMin = new Vector2(6f, 6f); val4.offsetMax = new Vector2(-6f, -6f); Image obj2 = val3.AddComponent<Image>(); obj2.sprite = LocalMap.GetIcon(icon); obj2.preserveAspect = true; ((Graphic)obj2).raycastTarget = false; return obj2; } private static void StripGamepad(GameObject clone) { UIGamePad[] componentsInChildren = clone.GetComponentsInChildren<UIGamePad>(true); foreach (UIGamePad val in componentsInChildren) { if ((Object)(object)val.m_hint != (Object)null) { Object.DestroyImmediate((Object)(object)val.m_hint); } Object.DestroyImmediate((Object)(object)val); } } private static Image FindPanelImage(Transform root) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) Image val = null; Image val2 = null; float num = 0f; float num2 = 0f; Image[] componentsInChildren = ((Component)root).GetComponentsInChildren<Image>(true); foreach (Image val3 in componentsInChildren) { if (!((Object)(object)val3.sprite == (Object)null)) { Rect rect = ((Graphic)val3).rectTransform.rect; float num3 = ((Rect)(ref rect)).width * ((Rect)(ref rect)).height; if ((Object)(object)((Graphic)val3).material != (Object)null && ((Object)((Graphic)val3).material).name.IndexOf("litpanel", StringComparison.OrdinalIgnoreCase) >= 0 && num3 > num) { val = val3; num = num3; } if (num3 > num2) { val2 = val3; num2 = num3; } } } Image val4 = (((Object)(object)val != (Object)null) ? val : val2); if ((Object)(object)val4 == (Object)null) { throw new InvalidOperationException("No panel background found on the chest panel."); } CartographyAdminPlugin.Log.LogInfo((object)("Marker manager background: '" + ((Object)val4).name + "' (sprite '" + ((Object)val4.sprite).name + "', material '" + (((Object)(object)((Graphic)val4).material != (Object)null) ? ((Object)((Graphic)val4).material).name : "none") + "').")); return val4; } private static void CopyImage(Image source, Image target) { //IL_000e: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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) target.sprite = source.sprite; target.type = source.type; ((Graphic)target).material = ((Graphic)source).material; ((Graphic)target).color = new Color(((Graphic)source).color.r, ((Graphic)source).color.g, ((Graphic)source).color.b, 1f); target.pixelsPerUnitMultiplier = source.pixelsPerUnitMultiplier; target.fillCenter = true; } }