using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyTitle("BUG_UIFix")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace BUG_UIFix
{
public static class AllPlanetInfoFix
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static UnityAction <>9__20_0;
internal void <AfterCreate>b__20_0()
{
collapsed.Value = !collapsed.Value;
ApplyCollapsed();
ClampToScreen();
}
}
public const string Guid = "Appun.DSP.plugin.AllPlanetInfo";
private const float CollapsedHeight = 10f;
private const float RowsWidth = 262f;
private static ConfigEntry<float> height;
private static ConfigEntry<float> x;
private static ConfigEntry<float> y;
private static ConfigEntry<bool> saved;
private static ConfigEntry<bool> collapsed;
private static Type ui;
private static FieldInfo lineMax;
private static GameObject content;
private static GameObject collapseButton;
private static readonly Vector3[] corners = (Vector3[])(object)new Vector3[4];
private static GameObject Window => Field("infoWindow");
private static GameObject Field(string name)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
return (GameObject)AccessTools.Field(ui, name).GetValue(null);
}
public static string Apply(Harmony harmony, ConfigFile config)
{
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_0181: Expected O, but got Unknown
//IL_020c: Unknown result type (might be due to invalid IL or missing references)
//IL_021a: Expected O, but got Unknown
//IL_022e: Unknown result type (might be due to invalid IL or missing references)
//IL_023b: Expected O, but got Unknown
//IL_024f: Unknown result type (might be due to invalid IL or missing references)
//IL_025c: Expected O, but got Unknown
if (!Plugin.Loaded("Appun.DSP.plugin.AllPlanetInfo"))
{
return "not loaded, nothing to do";
}
if (AccessTools.TypeByName("DSPAllPlanetInfo.WindowDrag") != null)
{
return "already contains this fix, skipped";
}
ui = AccessTools.TypeByName("DSPAllPlanetInfo.UI").ThrowIfMissing("DSPAllPlanetInfo.UI");
lineMax = AccessTools.Field(AccessTools.TypeByName("DSPAllPlanetInfo.InfoCreater"), "lineMax").ThrowIfMissing("InfoCreater.lineMax");
string[] array = new string[10] { "infoWindow", "WindowTitle", "previousButton", "nextButton", "planetInfoButton", "ItemName", "ItemIcon", "ItemCount", "ItemLogic", "Line" };
foreach (string text in array)
{
AccessTools.Field(ui, text).ThrowIfMissing("UI." + text);
}
MethodInfo methodInfo = AccessTools.Method(ui, "Create", (Type[])null, (Type[])null).ThrowIfMissing("UI.Create");
MethodInfo methodInfo2 = AccessTools.Method(ui, "setWindowPos", (Type[])null, (Type[])null).ThrowIfMissing("UI.setWindowPos");
MethodInfo methodInfo3 = AccessTools.Method(AccessTools.TypeByName("DSPAllPlanetInfo.Hook+UIPlanetDetail_OnOpen_Postfix"), "Postfix", (Type[])null, (Type[])null).ThrowIfMissing("Hook.UIPlanetDetail_OnOpen_Postfix.Postfix");
height = config.Bind<float>("DSPAllPlanetInfo", "WindowHeight", 600f, new ConfigDescription("Height of the Interstellar Logistics window in UI units; more stations go to the next page.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(150f, 1400f), Array.Empty<object>()));
collapsed = config.Bind<bool>("DSPAllPlanetInfo", "WindowCollapsed", false, "Window folded to its title bar (the -/+ button).");
saved = config.Bind<bool>("DSPAllPlanetInfo", "WindowPositionSaved", false, "False: the window opens in the middle of the screen. Set when the window is dragged.");
x = config.Bind<float>("DSPAllPlanetInfo", "WindowX", 0f, "Saved window position (local UI units), written when the window is dragged.");
y = config.Bind<float>("DSPAllPlanetInfo", "WindowY", 0f, "Saved window position (local UI units), written when the window is dragged.");
harmony.Patch((MethodBase)methodInfo2, new HarmonyMethod(typeof(AllPlanetInfoFix), "SetWindowPos", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(AllPlanetInfoFix), "AfterCreate", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
harmony.Patch((MethodBase)methodInfo3, (HarmonyMethod)null, new HarmonyMethod(typeof(AllPlanetInfoFix), "AfterOpen", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
return "logistics window placement, drag, fold and row count fixed";
}
public static int Rows(float windowHeight)
{
return ((int)windowHeight - 30) / 20;
}
private static bool SetWindowPos()
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Expected O, but got Unknown
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
try
{
int uiLayoutHeight = UICanvasScalerHandler.uiLayoutHeight;
int num = uiLayoutHeight * Screen.width / Screen.height;
Field("planetInfoButton").transform.localPosition = new Vector3((float)(-(num / 2) + 50), (float)(uiLayoutHeight / 2 - 30), 0f);
RectTransform val = (RectTransform)Window.transform;
val.sizeDelta = new Vector2(val.sizeDelta.x, height.Value);
if (saved.Value)
{
((Transform)val).localPosition = new Vector3(x.Value, y.Value, 0f);
}
else
{
CenterOnScreen();
}
if ((Object)(object)content != (Object)null)
{
ApplyCollapsed();
}
ClampToScreen();
Field("previousButton").transform.localPosition = new Vector3(-125f, -20f, 0f);
Field("nextButton").transform.localPosition = new Vector3(-20f, -20f, 0f);
return false;
}
catch (Exception ex)
{
Plugin.Log.LogError((object)("DSPAllPlanetInfo window placement: " + ex));
return true;
}
}
private static void AfterOpen()
{
lineMax.SetValue(null, Rows(height.Value));
}
private static void AfterCreate()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
//IL_004d: 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_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: 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_019e: Unknown result type (might be due to invalid IL or missing references)
//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
//IL_01eb: Expected O, but got Unknown
//IL_0204: Unknown result type (might be due to invalid IL or missing references)
//IL_0209: Unknown result type (might be due to invalid IL or missing references)
//IL_020f: Expected O, but got Unknown
//IL_028f: Unknown result type (might be due to invalid IL or missing references)
//IL_0294: Unknown result type (might be due to invalid IL or missing references)
//IL_0299: Unknown result type (might be due to invalid IL or missing references)
//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
//IL_0326: Unknown result type (might be due to invalid IL or missing references)
try
{
GameObject window = Window;
content = new GameObject("content", new Type[1] { typeof(RectTransform) });
RectTransform val = (RectTransform)content.transform;
((Transform)val).SetParent(window.transform, false);
Vector2 anchorMin = (val.anchorMax = ((RectTransform)window.transform).pivot);
val.anchorMin = anchorMin;
val.anchoredPosition = Vector2.zero;
val.sizeDelta = Vector2.zero;
string[] array = new string[5] { "ItemName", "ItemIcon", "ItemCount", "ItemLogic", "Line" };
foreach (string text in array)
{
GameObject[] array2 = (GameObject[])AccessTools.Field(ui, text).GetValue(null);
foreach (GameObject val2 in array2)
{
if ((Object)(object)val2 != (Object)null)
{
val2.transform.SetParent((Transform)(object)val, true);
}
}
}
GameObject obj = Field("previousButton");
obj.transform.SetParent((Transform)(object)val, true);
Field("nextButton").transform.SetParent((Transform)(object)val, true);
collapseButton = Object.Instantiate<GameObject>(obj, window.transform);
((Object)collapseButton).name = "collapseButton";
Object.Destroy((Object)(object)collapseButton.GetComponent<UIButton>());
Object.Destroy((Object)(object)((Component)collapseButton.transform.Find("Text")).GetComponent<Localizer>());
collapseButton.GetComponent<RectTransform>().sizeDelta = new Vector2(24f, 20f);
collapseButton.transform.localPosition = new Vector3(-15f, 15f, 0f);
collapseButton.SetActive(true);
Button component = collapseButton.GetComponent<Button>();
component.onClick = new ButtonClickedEvent();
ButtonClickedEvent onClick = component.onClick;
object obj2 = <>c.<>9__20_0;
if (obj2 == null)
{
UnityAction val3 = delegate
{
collapsed.Value = !collapsed.Value;
ApplyCollapsed();
ClampToScreen();
};
<>c.<>9__20_0 = val3;
obj2 = (object)val3;
}
((UnityEvent)onClick).AddListener((UnityAction)obj2);
array = new string[3] { "black-bg/detail-tabs", "lstm-show-btn", "menu-btn" };
foreach (string text2 in array)
{
Transform val4 = window.transform.Find(text2);
if ((Object)(object)val4 != (Object)null)
{
Object.Destroy((Object)(object)((Component)val4).gameObject);
}
}
Transform obj3 = window.transform.Find("black-bg");
RectTransform val5 = (RectTransform)(object)((obj3 is RectTransform) ? obj3 : null);
Rect rect = ((RectTransform)window.transform).rect;
float num = ((Rect)(ref rect)).width - 262f;
if ((Object)(object)val5 != (Object)null && num > 0f)
{
val5.offsetMin += new Vector2(num, 0f);
}
Graphic val6 = (((Object)(object)val5 != (Object)null) ? ((Component)val5).GetComponent<Graphic>() : null);
if ((Object)(object)val6 != (Object)null)
{
val6.raycastTarget = true;
}
else if ((Object)(object)window.GetComponent<Graphic>() == (Object)null)
{
((Graphic)window.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0f);
}
((Graphic)Field("WindowTitle").GetComponent<Text>()).raycastTarget = true;
window.AddComponent<WindowDrag>();
SetWindowPos();
}
catch (Exception ex)
{
Plugin.Log.LogError((object)("DSPAllPlanetInfo window frame: " + ex));
}
}
private static void ApplyCollapsed()
{
//IL_000a: 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_004e: Unknown result type (might be due to invalid IL or missing references)
RectTransform val = (RectTransform)Window.transform;
content.SetActive(!collapsed.Value);
val.sizeDelta = new Vector2(val.sizeDelta.x, collapsed.Value ? 10f : height.Value);
((Component)collapseButton.transform.Find("Text")).GetComponent<Text>().text = (collapsed.Value ? "+" : "-");
}
private static RectTransform ScreenRect()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Expected O, but got Unknown
return (RectTransform)((Component)Window.GetComponentInParent<Canvas>().rootCanvas).transform;
}
private static void CenterOnScreen()
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: 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_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: 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)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: 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_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: 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_0076: Unknown result type (might be due to invalid IL or missing references)
RectTransform val = (RectTransform)Window.transform;
RectTransform val2 = ScreenRect();
val.GetWorldCorners(corners);
Vector2 val3 = Vector2.op_Implicit(((Transform)val2).InverseTransformPoint((corners[0] + corners[2]) * 0.5f));
Vector3 position = ((Transform)val).position;
Rect rect = val2.rect;
((Transform)val).position = position + ((Transform)val2).TransformVector(Vector2.op_Implicit(((Rect)(ref rect)).center - val3));
}
internal static void ClampToScreen()
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
//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_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: 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_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: 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_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: 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_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: 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_009f: 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)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
RectTransform val = (RectTransform)Window.transform;
RectTransform val2 = ScreenRect();
val.GetWorldCorners(corners);
Vector2 min = Vector2.op_Implicit(((Transform)val2).InverseTransformPoint(corners[0]));
Vector2 max = Vector2.op_Implicit(((Transform)val2).InverseTransformPoint(corners[2]));
max.y += 30f;
((Transform)val).position = ((Transform)val).position + ((Transform)val2).TransformVector(Vector2.op_Implicit(Clamp(min, max, val2.rect)));
Vector3 localPosition = ((Transform)val).localPosition;
if (localPosition.z != 0f)
{
((Transform)val).localPosition = new Vector3(localPosition.x, localPosition.y, 0f);
}
}
public static Vector2 Clamp(Vector2 min, Vector2 max, Rect area)
{
//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_0006: 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_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: 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_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
Vector2 zero = Vector2.zero;
if (max.x > ((Rect)(ref area)).xMax)
{
zero.x = ((Rect)(ref area)).xMax - max.x;
}
if (min.x + zero.x < ((Rect)(ref area)).xMin)
{
zero.x = ((Rect)(ref area)).xMin - min.x;
}
if (min.y < ((Rect)(ref area)).yMin)
{
zero.y = ((Rect)(ref area)).yMin - min.y;
}
if (max.y + zero.y > ((Rect)(ref area)).yMax)
{
zero.y = ((Rect)(ref area)).yMax - max.y;
}
return zero;
}
internal static void SavePosition()
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: 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)
Vector3 localPosition = Window.transform.localPosition;
x.Value = localPosition.x;
y.Value = localPosition.y;
saved.Value = true;
}
}
internal class WindowDrag : MonoBehaviour, IBeginDragHandler, IEventSystemHandler, IDragHandler, IEndDragHandler
{
private Vector3 grab;
private bool Point(PointerEventData e, out Vector3 world)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
return RectTransformUtility.ScreenPointToWorldPointInRectangle((RectTransform)((Component)this).transform, e.position, e.pressEventCamera, ref world);
}
public void OnBeginDrag(PointerEventData e)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
if (Point(e, out var world))
{
grab = ((Component)this).transform.position - world;
}
}
public void OnDrag(PointerEventData e)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: 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)
if (Point(e, out var world))
{
((Component)this).transform.position = world + grab;
AllPlanetInfoFix.ClampToScreen();
}
}
public void OnEndDrag(PointerEventData e)
{
AllPlanetInfoFix.SavePosition();
}
}
public static class GalacticScaleFix
{
public const string Guid = "dsp.galactic-scale.2";
public static string Apply(Harmony harmony)
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Expected O, but got Unknown
if (!Plugin.Loaded("dsp.galactic-scale.2"))
{
return "not loaded, nothing to do";
}
harmony.Patch((MethodBase)AccessTools.Method(typeof(UIPlanetDetail), "SetResCount", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(GalacticScaleFix), "SetResCount", (Type[])null)
{
priority = 0
}, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
return "planet panel layout fixed";
}
private static void SetResCount(int count, RectTransform ___rectTrans, RectTransform ___paramGroup)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: 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)
Vector2 val = default(Vector2);
Vector2 val2 = default(Vector2);
Layout(count, out val.y, out val2.y);
___rectTrans.sizeDelta = new Vector2(___rectTrans.sizeDelta.x, val.y);
___paramGroup.anchoredPosition = new Vector2(___paramGroup.anchoredPosition.x, val2.y);
}
public static void Layout(int count, out float height, out float paramY)
{
int num = Mathf.Max(count * 20, 46);
height = (float)(226 + num) + 20f;
paramY = -106 - num;
}
}
[BepInPlugin("bug.dsp.uifix", "BUG_UIFix", "1.0.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
public const string Guid = "bug.dsp.uifix";
internal static ManualLogSource Log;
private void Awake()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
Harmony harmony = new Harmony("bug.dsp.uifix");
Run("DSPAllPlanetInfo", () => AllPlanetInfoFix.Apply(harmony, ((BaseUnityPlugin)this).Config));
Run("Galactic Scale", () => GalacticScaleFix.Apply(harmony));
Run("UXAssist", () => StarmapFilterFix.Apply(harmony));
}
private static void Run(string mod, Func<string> apply)
{
try
{
Log.LogInfo((object)(mod + ": " + apply()));
}
catch (Exception ex)
{
Log.LogError((object)(mod + " fix skipped, the mod is left as it is: " + ex));
}
}
internal static bool Loaded(string guid)
{
return Chainloader.PluginInfos.ContainsKey(guid);
}
}
internal static class StarmapFilterFix
{
public const string Guid = "org.soardev.uxassist";
private static Component toggler;
private static PropertyInfo checkedProperty;
private static GameObject backdrop;
private static int shieldIndex = -1;
public static string Apply(Harmony harmony)
{
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Expected O, but got Unknown
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Expected O, but got Unknown
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Expected O, but got Unknown
if (!Plugin.Loaded("org.soardev.uxassist"))
{
return "not loaded, nothing to do";
}
Type type = AccessTools.TypeByName("UXAssist.Functions.UI.StarmapFilterUI") ?? throw new MissingMemberException("UXAssist.Functions.UI.StarmapFilterUI");
if (AccessTools.Field(type, "_shieldSiblingIndex") != null)
{
return "already contains this fix, skipped";
}
AccessTools.Field(type, "StarmapFilterToggler").ThrowIfMissing("StarmapFilterUI.StarmapFilterToggler");
harmony.Patch((MethodBase)AccessTools.Method(type, "InitStarmapButtons", (Type[])null, (Type[])null).ThrowIfMissing("StarmapFilterUI.InitStarmapButtons"), (HarmonyMethod)null, new HarmonyMethod(typeof(StarmapFilterFix), "AfterInit", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
harmony.Patch((MethodBase)AccessTools.Method(typeof(UIStarmap), "_OnOpen", (Type[])null, (Type[])null).ThrowIfMissing("UIStarmap._OnOpen"), (HarmonyMethod)null, new HarmonyMethod(typeof(StarmapFilterFix), "MapOpened", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
harmony.Patch((MethodBase)AccessTools.Method(typeof(UIStarmap), "_OnClose", (Type[])null, (Type[])null).ThrowIfMissing("UIStarmap._OnClose"), (HarmonyMethod)null, new HarmonyMethod(typeof(StarmapFilterFix), "MapClosed", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
return "starmap filter drawn above the planet shield panel";
}
private static void AfterInit()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
//IL_0090: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: 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_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: 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_0131: Unknown result type (might be due to invalid IL or missing references)
try
{
toggler = (Component)AccessTools.Field(AccessTools.TypeByName("UXAssist.Functions.UI.StarmapFilterUI"), "StarmapFilterToggler").GetValue(null);
if (!((Object)(object)toggler == (Object)null))
{
checkedProperty = AccessTools.Property(((object)toggler).GetType(), "Checked").ThrowIfMissing("MyCheckButton.Checked");
EventInfo eventInfo = ((object)toggler).GetType().GetEvent("OnChecked").ThrowIfMissing("MyCheckButton.OnChecked");
RectTransform val = (RectTransform)new GameObject("bug-uifix-filter-bg", new Type[1] { typeof(RectTransform) }).transform;
((Transform)val).SetParent(toggler.transform.parent, false);
Vector2 val2 = (val.pivot = new Vector2(0f, 1f));
Vector2 anchorMin = (val.anchorMax = val2);
val.anchorMin = anchorMin;
val.anchoredPosition3D = new Vector3(0f, -24f, 0f);
val.sizeDelta = new Vector2(176f, 382f);
((Transform)val).SetAsFirstSibling();
Image obj = ((Component)val).gameObject.AddComponent<Image>();
((Graphic)obj).color = new Color(0.02f, 0.05f, 0.09f, 0.96f);
((Graphic)obj).raycastTarget = true;
backdrop = ((Component)val).gameObject;
backdrop.SetActive(false);
eventInfo.AddEventHandler(toggler, new Action(Toggled));
}
}
catch (Exception ex)
{
Plugin.Log.LogError((object)("UXAssist starmap filter fix skipped: " + ex));
}
}
private static void Toggled()
{
Sync(mapOpen: true);
}
private static void MapOpened()
{
Sync(mapOpen: true);
}
private static void MapClosed()
{
Sync(mapOpen: false);
}
private static void Sync(bool mapOpen)
{
if ((Object)(object)toggler == (Object)null || checkedProperty == null)
{
return;
}
try
{
bool flag = (bool)checkedProperty.GetValue(toggler, null);
bool flag2 = flag && mapOpen;
if ((Object)(object)backdrop != (Object)null)
{
backdrop.SetActive(flag);
}
Transform transform = ((Component)UIRoot.instance.uiGame).transform;
Transform val = transform.Find("Planet Shield Details");
Transform val2 = toggler.transform;
while ((Object)(object)val2.parent != (Object)null && (Object)(object)val2.parent != (Object)(object)transform)
{
val2 = val2.parent;
}
if (!((Object)(object)val == (Object)null) && !((Object)(object)val2.parent != (Object)(object)transform))
{
if (flag2 && shieldIndex < 0 && val.GetSiblingIndex() > val2.GetSiblingIndex())
{
shieldIndex = val.GetSiblingIndex();
val.SetSiblingIndex(val2.GetSiblingIndex());
}
else if (!flag2 && shieldIndex >= 0)
{
val.SetSiblingIndex(shieldIndex);
shieldIndex = -1;
}
}
}
catch (Exception ex)
{
Plugin.Log.LogError((object)("UXAssist starmap filter fix: " + ex));
}
}
}
internal static class MemberExtensions
{
public static T ThrowIfMissing<T>(this T member, string name) where T : class
{
return member ?? throw new MissingMemberException(name);
}
}
}