using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("TitleScreenQuickAccess")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+ff867110100cd39994eddef134b703e5596719d9")]
[assembly: AssemblyProduct("TitleScreenQuickAccess")]
[assembly: AssemblyTitle("TitleScreenQuickAccess")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
namespace TitleScreenQuickAccess
{
[BepInPlugin("com.github.end-4.titleScreenQuickAccess", "TitleScreenQuickAccess", "1.0.2")]
public class Core : BaseUnityPlugin
{
internal class TooltipHandler : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler, IPointerClickHandler, ISelectHandler, IDeselectHandler
{
public string message = "";
private static GameObject? tooltipObj;
private static TMP_Text? textComp;
private bool hasMouse;
private Vector3 prevMousePos;
public void hideTooltip()
{
handleExit();
}
private void handleEnter()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Expected O, but got Unknown
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: 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_009d: 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_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Expected O, but got Unknown
//IL_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: 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)
if ((Object)(object)tooltipObj == (Object)null)
{
tooltipObj = new GameObject("QuickAccessTooltip");
GameObject val = GameObject.Find("Canvas");
if ((Object)(object)val != (Object)null)
{
tooltipObj.transform.SetParent(val.transform, false);
}
RectTransform val2 = tooltipObj.GetComponent<RectTransform>();
if ((Object)(object)val2 == (Object)null)
{
val2 = tooltipObj.AddComponent<RectTransform>();
}
val2.pivot = new Vector2(0.5f, 0f);
GameObject val3 = new GameObject("TooltipBackground");
val3.transform.SetParent(tooltipObj.transform, false);
RectTransform obj = val3.AddComponent<RectTransform>();
obj.anchorMin = Vector2.zero;
obj.anchorMax = Vector2.one;
obj.sizeDelta = Vector2.zero;
Image val4 = val3.AddComponent<Image>();
Image component = ((Component)this).GetComponent<Image>();
if ((Object)(object)component != (Object)null)
{
val4.sprite = component.sprite;
val4.type = component.type;
val4.pixelsPerUnitMultiplier = component.pixelsPerUnitMultiplier;
}
((Graphic)val4).color = new Color(1f, 1f, 1f, 1f);
((Graphic)val4).raycastTarget = false;
val3.AddComponent<LayoutElement>().ignoreLayout = true;
ContentSizeFitter obj2 = tooltipObj.AddComponent<ContentSizeFitter>();
obj2.horizontalFit = (FitMode)2;
obj2.verticalFit = (FitMode)2;
((LayoutGroup)tooltipObj.AddComponent<HorizontalLayoutGroup>()).padding = new RectOffset(15, 15, 10, 10);
GameObject val5 = new GameObject("Text");
val5.transform.SetParent(tooltipObj.transform, false);
textComp = (TMP_Text?)(object)val5.AddComponent<TextMeshProUGUI>();
textComp.fontSize = 20f;
textComp.alignment = (TextAlignmentOptions)514;
((Graphic)textComp).raycastTarget = false;
}
TMP_Text componentInChildren = ((Component)this).GetComponentInChildren<TMP_Text>(true);
if ((Object)(object)componentInChildren != (Object)null && (Object)(object)textComp != (Object)null)
{
textComp.font = componentInChildren.font;
}
tooltipObj.SetActive(true);
textComp.text = message;
}
private void handleExit()
{
if ((Object)(object)tooltipObj != (Object)null)
{
tooltipObj.SetActive(false);
}
hasMouse = false;
}
private void positionTooltipHere()
{
//IL_0016: 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_0029: 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_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: 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_0084: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)tooltipObj == (Object)null))
{
RectTransform component = ((Component)this).GetComponent<RectTransform>();
Rect rect = component.rect;
float num = ((Rect)(ref rect)).height * (1f - component.pivot.y) + 15f;
rect = component.rect;
float num2 = ((Rect)(ref rect)).width * (1f - component.pivot.x) / 2f;
tooltipObj.transform.position = ((Component)this).transform.position + new Vector3(num2, num, 0f);
}
}
public void OnPointerEnter(PointerEventData eventData)
{
handleEnter();
hasMouse = true;
}
public void OnSelect(BaseEventData eventData)
{
handleEnter();
if (!hasMouse)
{
positionTooltipHere();
}
}
public void OnPointerExit(PointerEventData eventData)
{
handleExit();
}
public void OnPointerClick(PointerEventData eventData)
{
handleExit();
}
public void OnDeselect(BaseEventData eventData)
{
handleExit();
}
private void Update()
{
//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_001d: 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_004b: 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_0064: Unknown result type (might be due to invalid IL or missing references)
if (hasMouse && !(prevMousePos == Input.mousePosition))
{
prevMousePos = Input.mousePosition;
if ((Object)(object)tooltipObj != (Object)null && tooltipObj.activeSelf)
{
tooltipObj.transform.position = prevMousePos + new Vector3(0f, 40f, 0f);
}
}
}
}
public static string workingPath = Assembly.GetExecutingAssembly().Location;
public static string workingDir = Path.GetDirectoryName(workingPath);
internal static ManualLogSource Log;
public bool hasAngry;
public bool hasPluginConfigurator;
private void Awake()
{
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
Log = ((BaseUnityPlugin)this).Logger;
foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos)
{
string gUID = pluginInfo.Value.Metadata.GUID;
if (!(gUID == "com.eternalUnion.angryLevelLoader"))
{
if (gUID == "com.eternalUnion.pluginConfigurator")
{
hasPluginConfigurator = true;
}
}
else
{
hasAngry = true;
}
}
SceneManager.sceneLoaded += OnSceneLoaded;
Log.LogInfo((object)"TitleScreenQuickAccess loaded!");
Scene activeScene = SceneManager.GetActiveScene();
if (IsMainMenu(activeScene))
{
Log.LogInfo((object)"Detected Main Menu on Awake, creating button...");
CreateQuickAccessButtons();
}
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
Log.LogInfo((object)("Scene Loaded: " + ((Scene)(ref scene)).name + " | Path: " + ((Scene)(ref scene)).path));
if (IsMainMenu(scene))
{
CreateQuickAccessButtons();
}
}
private bool IsMainMenu(Scene scene)
{
if (!(((Scene)(ref scene)).name == "Main Menu") && !(((Scene)(ref scene)).name == "b3e7f2f8052488a45b35549efb98d902"))
{
return ((Scene)(ref scene)).path.Contains("Main Menu");
}
return true;
}
public static Sprite? LoadSpriteFromFile(string path, float pixelsPerUnit = 100f, Vector2? pivot = null, TextureFormat textureFormat = 4, bool mipmap = false)
{
//IL_001d: 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: Expected O, but got Unknown
//IL_0058: 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_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
try
{
if (string.IsNullOrEmpty(path) || !File.Exists(path))
{
return null;
}
byte[] array = File.ReadAllBytes(path);
Texture2D val = new Texture2D(2, 2, textureFormat, mipmap);
if (!ImageConversion.LoadImage(val, array))
{
return null;
}
val.Apply();
Vector2 val2 = (Vector2)(((??)pivot) ?? new Vector2(0.5f, 0.5f));
return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), val2, pixelsPerUnit);
}
catch (Exception)
{
return null;
}
}
private GameObject? FindNestedObject(GameObject baseObject, string path)
{
Transform val = baseObject.transform;
string[] array = path.Split("/");
foreach (string text in array)
{
val = ((Component)val).transform.Find(text);
if ((Object)(object)val == (Object)null)
{
Log.LogWarning((object)(text + " not found for object path " + ((Object)baseObject).name + "/" + path));
return null;
}
}
return ((Component)val).gameObject;
}
public GameObject? FindByChildText(GameObject parent, string targetText)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Expected O, but got Unknown
foreach (Transform item in parent.transform)
{
Transform val = item;
TMP_Text componentInChildren = ((Component)val).GetComponentInChildren<TMP_Text>();
if ((Object)(object)componentInChildren != (Object)null && componentInChildren.text == targetText)
{
return ((Component)val).gameObject;
}
}
return null;
}
private GameObject CreateTitleScreenButton(string name, Vector2 offset, string tooltip = "")
{
//IL_0053: 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_005e: 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_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Expected O, but got Unknown
GameObject gameObject = ((Component)((Component)GameObject.Find("Canvas/Main Menu (1)").transform).transform.Find("LeftSide")).gameObject;
GameObject val = Object.Instantiate<GameObject>(((Component)gameObject.transform.Find("Options")).gameObject, gameObject.transform);
((Object)val).name = name;
RectTransform component = val.GetComponent<RectTransform>();
component.anchoredPosition += new Vector2(offset.x, offset.y + 75f);
((Behaviour)val.GetComponent<HudOpenEffect>()).enabled = true;
val.SetActive(true);
val.GetComponent<Button>().onClick = new ButtonClickedEvent();
if (!string.IsNullOrEmpty(tooltip))
{
val.AddComponent<TooltipHandler>().message = tooltip;
}
return val;
}
private GameObject CreateSquareTitleScreenButton(string name, Vector2 offset, string tooltip = "")
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: 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_0027: Unknown result type (might be due to invalid IL or missing references)
GameObject obj = CreateTitleScreenButton(name, offset, tooltip);
RectTransform component = obj.GetComponent<RectTransform>();
component.sizeDelta = new Vector2(component.sizeDelta.y, component.sizeDelta.y);
return obj;
}
private GameObject CreateSquareTitleScreenIconButton(string name, Vector2 offset, string iconPath, string tooltip = "")
{
//IL_0002: 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_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
GameObject val = CreateSquareTitleScreenButton(name, offset, tooltip);
TMP_Text componentInChildren = val.GetComponentInChildren<TMP_Text>();
if ((Object)(object)componentInChildren != (Object)null)
{
((Component)componentInChildren).gameObject.SetActive(false);
}
GameObject val2 = new GameObject(name + "Button");
val2.transform.SetParent(val.transform, false);
Sprite sprite = LoadSpriteFromFile(iconPath, 100f, null, (TextureFormat)4);
Image obj = val2.AddComponent<Image>();
obj.sprite = sprite;
((Graphic)obj).raycastTarget = false;
val2.GetComponent<RectTransform>().sizeDelta = new Vector2(40f, 40f);
return val;
}
private GameObject? CreateVanillaShortcutButton(string name, Vector2 offset, string iconPath, string canvasPathToClickedButton, string tooltip = "")
{
//IL_0009: 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_001c: 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_0099: Expected O, but got Unknown
GameObject newButton = CreateSquareTitleScreenIconButton(name, offset, iconPath, tooltip);
Scene activeScene = SceneManager.GetActiveScene();
GameObject val = (from obj in ((Scene)(ref activeScene)).GetRootGameObjects()
where ((Object)obj).name == "Canvas"
select obj).FirstOrDefault();
if ((Object)(object)val == (Object)null)
{
return null;
}
GameObject clickedButton = FindNestedObject(val, canvasPathToClickedButton);
if ((Object)(object)clickedButton == (Object)null)
{
return null;
}
((UnityEvent)newButton.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
{
newButton.GetComponent<TooltipHandler>().hideTooltip();
((UnityEvent)clickedButton.GetComponent<Button>().onClick).Invoke();
});
return newButton;
}
private GameObject? CreateCyberGrindButton()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
return CreateVanillaShortcutButton("CustomLevels", new Vector2(426f, 0f), Path.Combine(workingDir, "assets/cybergrind.png"), "Chapter Select/Chapters/The Cyber Grind", "Cyber Grind");
}
private GameObject? CreateSandboxButton()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
return CreateVanillaShortcutButton("Sandbox", new Vector2(426f, -150f), Path.Combine(workingDir, "assets/sandbox.png"), "Chapter Select/Chapters/Sandbox", "Sandbox");
}
private GameObject? CreateCustomLevelButton()
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Expected O, but got Unknown
Scene activeScene = SceneManager.GetActiveScene();
GameObject canvas = (from obj in ((Scene)(ref activeScene)).GetRootGameObjects()
where ((Object)obj).name == "Canvas"
select obj).FirstOrDefault();
if ((Object)(object)canvas == (Object)null)
{
return null;
}
GameObject newButton = CreateSquareTitleScreenIconButton("CustomLevels", new Vector2(502f, 0f), Path.Combine(workingDir, "assets/angry.png"), "Custom levels (Angry Level Loader)");
((UnityEvent)newButton.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
{
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
newButton.GetComponent<TooltipHandler>().hideTooltip();
GameObject val = GameObject.Find("Canvas/Main Menu (1)");
GameObject gameObject = ((Component)canvas.transform.Find("OptionsMenu")).gameObject;
Transform val2 = gameObject.transform.Find("Pages");
Transform val3 = ((Component)val2).transform.Find("ConcretePanel(Clone)");
GameObject val4 = FindNestedObject(canvas, "OptionsMenu/Pages/ConcretePanel(Clone)/Scroll Rect/Contents");
if (!((Object)(object)val4 == (Object)null))
{
GameObject gameObject2 = ((Component)FindByChildText(val4, "Angry Level Loader").transform.Find("Select")).gameObject;
((Component)gameObject.transform.Find("Navigation Rail")).transform.Find("PluginConfiguratorButton(Clone)");
val.SetActive(false);
gameObject.SetActive(true);
foreach (Transform item in val2)
{
((Component)item).gameObject.SetActive(false);
}
((Component)val3).gameObject.SetActive(true);
((UnityEvent)gameObject2.GetComponent<Button>().onClick).Invoke();
}
});
return newButton;
}
private GameObject? CreatePluginConfigButton()
{
//IL_0007: 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_0063: 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_00a7: Expected O, but got Unknown
Scene activeScene = SceneManager.GetActiveScene();
GameObject canvas = (from obj in ((Scene)(ref activeScene)).GetRootGameObjects()
where ((Object)obj).name == "Canvas"
select obj).FirstOrDefault();
if ((Object)(object)canvas == (Object)null)
{
return null;
}
GameObject newButton = CreateSquareTitleScreenIconButton("PluginConfig", new Vector2(426f, -75f), Path.Combine(workingDir, "assets/plugins.png"), "Plugin Configurator");
((UnityEvent)newButton.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
{
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
newButton.GetComponent<TooltipHandler>().hideTooltip();
GameObject val = GameObject.Find("Canvas/Main Menu (1)");
GameObject gameObject = ((Component)canvas.transform.Find("OptionsMenu")).gameObject;
GameObject gameObject2 = ((Component)gameObject.transform.Find("Pages")).gameObject;
GameObject gameObject3 = ((Component)gameObject2.transform.Find("ConcretePanel(Clone)")).gameObject;
val.SetActive(false);
gameObject.SetActive(true);
foreach (Transform item in gameObject2.transform)
{
((Component)item).gameObject.SetActive(false);
}
gameObject3.gameObject.SetActive(true);
});
return newButton;
}
private void CreateQuickAccessButtons()
{
CreateCyberGrindButton();
if (hasAngry)
{
CreateCustomLevelButton();
}
if (hasPluginConfigurator)
{
CreatePluginConfigButton();
}
CreateSandboxButton();
}
}
}