using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GlobalEnums;
using HarmonyLib;
using InControl;
using Microsoft.CodeAnalysis;
using UI;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("GamepadUISwitcher")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+f66efb6ae1dce7673b2f03e058d3e5c43fc36213")]
[assembly: AssemblyProduct("GamepadUISwitcher")]
[assembly: AssemblyTitle("GamepadUISwitcher")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
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;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.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;
}
}
}
public static class MenuResources
{
public static Font TrajanProRegular { get; private set; }
public static Font TrajanProBold { get; private set; }
public static Font Perpetua { get; private set; }
public static Font NotoSerifCJKSCRegular { get; private set; }
public static RuntimeAnimatorController MenuTopFleurAnimator { get; private set; }
public static RuntimeAnimatorController MenuCursorAnimator { get; private set; }
public static RuntimeAnimatorController MenuButtonFlashAnimator { get; private set; }
public static AnimatorOverrideController TextHideShowAnimator { get; private set; }
public static Sprite ScrollbarHandleSprite { get; private set; }
public static Sprite ScrollbarBackgroundSprite { get; private set; }
static MenuResources()
{
ReloadResources();
}
public static void ReloadResources()
{
RuntimeAnimatorController[] array = Resources.FindObjectsOfTypeAll<RuntimeAnimatorController>();
foreach (RuntimeAnimatorController val in array)
{
if ((Object)(object)val != (Object)null)
{
switch (((Object)val).name)
{
case "Menu Animate In Out":
MenuTopFleurAnimator = val;
break;
case "Menu Fleur":
MenuCursorAnimator = val;
break;
case "Menu Flash Effect":
MenuButtonFlashAnimator = val;
break;
}
}
}
AnimatorOverrideController[] array2 = Resources.FindObjectsOfTypeAll<AnimatorOverrideController>();
foreach (AnimatorOverrideController val2 in array2)
{
if ((Object)(object)val2 != (Object)null)
{
string name = ((Object)val2).name;
if (1 == 0)
{
}
AnimatorOverrideController textHideShowAnimator = (AnimatorOverrideController)((!(name == "TextHideShow")) ? ((object)TextHideShowAnimator) : ((object)val2));
if (1 == 0)
{
}
TextHideShowAnimator = textHideShowAnimator;
}
}
Font[] array3 = Resources.FindObjectsOfTypeAll<Font>();
foreach (Font val3 in array3)
{
if ((Object)(object)val3 != (Object)null)
{
switch (((Object)val3).name)
{
case "TrajanPro-Regular":
TrajanProRegular = val3;
break;
case "TrajanPro-Bold":
TrajanProBold = val3;
break;
case "Perpetua":
Perpetua = val3;
break;
case "NotoSerifCJKsc-Regular":
NotoSerifCJKSCRegular = val3;
break;
}
}
}
Sprite[] array4 = Resources.FindObjectsOfTypeAll<Sprite>();
foreach (Sprite val4 in array4)
{
if (!((Object)(object)val4 != (Object)null))
{
continue;
}
string name2 = ((Object)val4).name;
string text = name2;
if (!(text == "scrollbar_fleur_new"))
{
if (text == "scrollbar_single")
{
ScrollbarBackgroundSprite = val4;
}
}
else
{
ScrollbarHandleSprite = val4;
}
}
}
}
namespace BepInEx
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class BepInAutoPluginAttribute : Attribute
{
public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace BepInEx.Preloader.Core.Patching
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class PatcherAutoPluginAttribute : Attribute
{
public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace UI
{
public class BepinexMenuOptionHorizontal : MenuSelectable, IMoveHandler, IEventSystemHandler, IPointerClickHandler, ISubmitHandler
{
public enum ApplyOnType
{
Scroll,
Submit
}
public Text optionText;
public List<object> optionList;
public Func<object, string>? stringFunc;
public ConfigEntryBase configEntry;
public ApplyOnType applySettingOn;
public CanvasGroup? applyButton;
public int selectedOptionIndex;
private bool hasApplyButton;
private int currentActiveIndex;
private Delegate del;
private bool justUpdatedEntry = false;
private void OnConfigEntryUpdate(object obj, EventArgs evArgs)
{
if (justUpdatedEntry)
{
justUpdatedEntry = false;
}
else
{
RefreshCurrentIndex();
}
}
private void Awake()
{
hasApplyButton = (Object)(object)applyButton != (Object)null;
}
private void OnEnable()
{
if (configEntry != null)
{
EventInfo @event = ((object)configEntry).GetType().GetEvent("SettingChanged");
del = Delegate.CreateDelegate(typeof(EventHandler), this, "OnConfigEntryUpdate");
@event.AddEventHandler(configEntry, del);
}
GameManager.instance.RefreshLanguageText += UpdateText;
RefreshMenuControls();
UpdateApplyButton();
}
private void OnDisable()
{
GameManager.instance.RefreshLanguageText -= UpdateText;
if (configEntry != null)
{
EventInfo @event = ((object)configEntry).GetType().GetEvent("SettingChanged");
@event.RemoveEventHandler(configEntry, del);
}
}
public void OnMove(AxisEventData move)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
if (((Selectable)this).interactable && !MoveOption(move.moveDir))
{
((Selectable)this).OnMove(move);
}
}
public void OnPointerClick(PointerEventData eventData)
{
if (((Selectable)this).interactable)
{
PointerClickCheckArrows(eventData);
}
}
public void OnSubmit(BaseEventData eventData)
{
if (((Selectable)this).interactable)
{
if (applySettingOn == ApplyOnType.Submit)
{
ApplySettings();
}
else
{
MoveOption((MoveDirection)2);
}
}
}
protected bool MoveOption(MoveDirection dir)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0004: 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_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Invalid comparison between Unknown and I4
if ((int)dir != 0)
{
if ((int)dir != 2)
{
return false;
}
IncrementOption();
}
else
{
DecrementOption();
}
if (Object.op_Implicit((Object)(object)base.uiAudioPlayer))
{
base.uiAudioPlayer.PlaySlider();
}
return true;
}
protected void PointerClickCheckArrows(PointerEventData eventData)
{
if (Object.op_Implicit((Object)(object)base.leftCursor) && IsInside(((Component)base.leftCursor).gameObject, eventData))
{
MoveOption((MoveDirection)0);
}
else if (Object.op_Implicit((Object)(object)base.rightCursor) && IsInside(((Component)base.rightCursor).gameObject, eventData))
{
MoveOption((MoveDirection)2);
}
else
{
MoveOption((MoveDirection)2);
}
}
private bool IsInside(GameObject obj, PointerEventData eventData)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
RectTransform component = obj.GetComponent<RectTransform>();
if (Object.op_Implicit((Object)(object)component) && RectTransformUtility.RectangleContainsScreenPoint(component, eventData.position, Camera.main))
{
return true;
}
return false;
}
private string OptionToString(int index)
{
return (stringFunc != null) ? stringFunc(optionList[index]) : optionList[index].ToString();
}
public string GetSelectedOptionText()
{
return OptionToString(selectedOptionIndex);
}
public virtual void SetOptionTo(int optionNumber)
{
if (optionNumber >= 0 && optionNumber < optionList.Count)
{
selectedOptionIndex = optionNumber;
UpdateText();
return;
}
Debug.LogErrorFormat("{0} - Trying to select an option outside the list size (index: {1} listsize: {2})", new object[3]
{
((Object)this).name,
optionNumber,
optionList.Count
});
}
protected virtual void UpdateText()
{
if (!Extensions.IsNullOrEmpty<object>((ICollection<object>)optionList) && !((Object)(object)optionText == (Object)null))
{
optionText.text = GetSelectedOptionText();
FixVerticalAlign component = ((Component)optionText).GetComponent<FixVerticalAlign>();
if (Object.op_Implicit((Object)(object)component))
{
component.AlignText();
}
}
}
protected void UpdateSetting()
{
justUpdatedEntry = true;
configEntry.BoxedValue = optionList[selectedOptionIndex];
}
protected void DecrementOption()
{
if (selectedOptionIndex > 0)
{
selectedOptionIndex--;
if (applySettingOn == ApplyOnType.Scroll)
{
UpdateSetting();
}
UpdateText();
}
else if (selectedOptionIndex == 0)
{
selectedOptionIndex = optionList.Count - 1;
if (applySettingOn == ApplyOnType.Scroll)
{
UpdateSetting();
}
UpdateText();
}
UpdateApplyButton();
}
protected void IncrementOption()
{
if (selectedOptionIndex >= 0 && selectedOptionIndex < optionList.Count - 1)
{
selectedOptionIndex++;
if (applySettingOn == ApplyOnType.Scroll)
{
UpdateSetting();
}
UpdateText();
}
else if (selectedOptionIndex == optionList.Count - 1)
{
selectedOptionIndex = 0;
if (applySettingOn == ApplyOnType.Scroll)
{
UpdateSetting();
}
UpdateText();
}
UpdateApplyButton();
}
public void RefreshMenuControls()
{
RefreshCurrentIndex();
UpdateText();
}
public virtual void ApplySettings()
{
if (selectedOptionIndex >= 0)
{
UpdateSetting();
RefreshCurrentIndex();
HideApplyButton();
}
}
public virtual void UpdateApplyButton()
{
if (currentActiveIndex == selectedOptionIndex)
{
HideApplyButton();
}
else
{
ShowApplyButton();
}
}
public virtual void RefreshCurrentIndex()
{
if (configEntry != null)
{
int num = optionList.IndexOf(configEntry.BoxedValue);
if (num == -1)
{
configEntry.BoxedValue = optionList[0];
SetOptionTo(0);
}
else
{
SetOptionTo(num);
}
}
currentActiveIndex = selectedOptionIndex;
}
protected void HideApplyButton()
{
if (hasApplyButton)
{
applyButton.alpha = 0f;
applyButton.interactable = false;
applyButton.blocksRaycasts = false;
}
}
protected void ShowApplyButton()
{
if (applySettingOn != 0 && hasApplyButton)
{
applyButton.alpha = 1f;
applyButton.interactable = true;
applyButton.blocksRaycasts = true;
}
}
}
public static class Objects
{
public static class FontSize
{
public const int OptionLabel = 46;
public const int OptionText = 38;
public const int OptionDescription = 41;
public const int MenuButton = 45;
}
public static GameObject CreateMenuButton(string buttonId, string label, MenuButtonType actionType, Action<BaseEventData> submitAction)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Expected O, but got Unknown
//IL_0024: 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_002d: 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)
//IL_0052: Expected O, but got Unknown
//IL_0056: 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_007b: Expected O, but got Unknown
//IL_007e: 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_00ca: Expected O, but got Unknown
//IL_00d5: 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)
//IL_0189: Unknown result type (might be due to invalid IL or missing references)
//IL_0190: Expected O, but got Unknown
//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
//IL_0201: Unknown result type (might be due to invalid IL or missing references)
//IL_0206: Unknown result type (might be due to invalid IL or missing references)
//IL_025c: Unknown result type (might be due to invalid IL or missing references)
//IL_0263: Expected O, but got Unknown
//IL_0278: Unknown result type (might be due to invalid IL or missing references)
//IL_028f: Unknown result type (might be due to invalid IL or missing references)
//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
Action<BaseEventData> submitAction2 = submitAction;
GameObject val = new GameObject(buttonId);
val.AddComponent<RectTransform>();
MenuButton val2 = val.AddComponent<MenuButton>();
val2.buttonType = actionType;
Navigation navigation = default(Navigation);
((Navigation)(ref navigation)).mode = (Mode)4;
((Selectable)val2).navigation = navigation;
EventTrigger val3 = val.AddComponent<EventTrigger>();
Entry val4 = new Entry();
val4.eventID = (EventTriggerType)15;
((UnityEvent<BaseEventData>)(object)val4.callback).AddListener((UnityAction<BaseEventData>)delegate(BaseEventData data)
{
submitAction2(data);
});
Entry val5 = new Entry();
val5.eventID = (EventTriggerType)4;
((UnityEvent<BaseEventData>)(object)val5.callback).AddListener((UnityAction<BaseEventData>)delegate(BaseEventData data)
{
submitAction2(data);
});
val3.triggers.AddRange(new <>z__ReadOnlyArray<Entry>((Entry[])(object)new Entry[2] { val4, val5 }));
GameObject val6 = new GameObject("Menu Button Text");
RectTransform val7 = val6.AddComponent<RectTransform>();
val7.anchorMax = Vector2.one;
val7.anchorMin = Vector2.zero;
Text val8 = val6.AddComponent<Text>();
val8.font = MenuResources.TrajanProBold;
val8.fontSize = 45;
val8.lineSpacing = -0.33f;
val8.text = label;
val8.alignment = (TextAnchor)4;
ChangeTextFontScaleOnHandHeld val9 = val6.AddComponent<ChangeTextFontScaleOnHandHeld>();
val9.normalSize = 45f;
val9.handHeldSize = 45f;
val6.AddComponent<FixVerticalAlign>();
ContentSizeFitter val10 = val6.AddComponent<ContentSizeFitter>();
val10.horizontalFit = (FitMode)2;
val10.verticalFit = (FitMode)0;
val6.transform.SetParent(val.transform);
GameObject val11 = new GameObject("CursorRight");
RectTransform val12 = val11.AddComponent<RectTransform>();
val12.sizeDelta = new Vector2(164f, 119f);
val12.anchorMin = new Vector2(1f, 0.5f);
val12.anchorMax = new Vector2(1f, 0.5f);
val12.anchoredPosition = new Vector2(70f, 0f);
((Transform)val12).localScale = Vector2.op_Implicit(new Vector2(-0.9f, 0.9f));
val11.AddComponent<Image>();
Animator val13 = val11.AddComponent<Animator>();
val13.runtimeAnimatorController = MenuResources.MenuCursorAnimator;
val13.updateMode = (AnimatorUpdateMode)2;
((MenuSelectable)val2).rightCursor = val13;
val11.transform.SetParent(val6.transform, false);
GameObject val14 = new GameObject("CursorLeft");
RectTransform val15 = val14.AddComponent<RectTransform>();
val15.sizeDelta = new Vector2(164f, 119f);
val15.anchorMin = new Vector2(0f, 0.5f);
val15.anchorMax = new Vector2(0f, 0.5f);
val15.anchoredPosition = new Vector2(-70f, 0f);
((Transform)val15).localScale = Vector2.op_Implicit(new Vector2(0.9f, 0.9f));
val14.AddComponent<Image>();
Animator val16 = val14.AddComponent<Animator>();
val16.runtimeAnimatorController = MenuResources.MenuCursorAnimator;
val16.updateMode = (AnimatorUpdateMode)2;
((MenuSelectable)val2).leftCursor = val16;
val14.transform.SetParent(val6.transform, false);
Object.DontDestroyOnLoad((Object)(object)val);
return val;
}
public static GameObject CreateBepinexConfigOption<T>(T[] options, ConfigEntry<T> entry, string optionId, string label, string description, Func<T, string>? stringFunc = null)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Expected O, but got Unknown
//IL_0028: 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)
//IL_0073: 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_00a9: Expected O, but got Unknown
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: 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_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_019a: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Expected O, but got Unknown
//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0291: Unknown result type (might be due to invalid IL or missing references)
//IL_0298: Expected O, but got Unknown
//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
//IL_02db: Unknown result type (might be due to invalid IL or missing references)
//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
//IL_0309: Unknown result type (might be due to invalid IL or missing references)
//IL_030e: Unknown result type (might be due to invalid IL or missing references)
//IL_0363: Unknown result type (might be due to invalid IL or missing references)
//IL_036a: Expected O, but got Unknown
//IL_037f: Unknown result type (might be due to invalid IL or missing references)
//IL_0396: Unknown result type (might be due to invalid IL or missing references)
//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
//IL_03db: Unknown result type (might be due to invalid IL or missing references)
//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
//IL_0435: Unknown result type (might be due to invalid IL or missing references)
//IL_043c: Expected O, but got Unknown
//IL_0451: Unknown result type (might be due to invalid IL or missing references)
//IL_0468: Unknown result type (might be due to invalid IL or missing references)
//IL_047f: Unknown result type (might be due to invalid IL or missing references)
//IL_0496: Unknown result type (might be due to invalid IL or missing references)
//IL_04ad: Unknown result type (might be due to invalid IL or missing references)
Func<T, string> stringFunc2 = stringFunc;
GameObject val = new GameObject(optionId);
RectTransform val2 = val.AddComponent<RectTransform>();
val2.sizeDelta = new Vector2(1100f, 60f);
val.AddComponent<CanvasRenderer>();
BepinexMenuOptionHorizontal bepinexMenuOptionHorizontal = val.AddComponent<BepinexMenuOptionHorizontal>();
bepinexMenuOptionHorizontal.optionList = options.Cast<object>().ToList();
((Selectable)bepinexMenuOptionHorizontal).transition = (Transition)0;
bepinexMenuOptionHorizontal.configEntry = (ConfigEntryBase)(object)entry;
Navigation navigation = default(Navigation);
((Navigation)(ref navigation)).mode = (Mode)4;
((Selectable)bepinexMenuOptionHorizontal).navigation = navigation;
if (stringFunc2 != null)
{
bepinexMenuOptionHorizontal.stringFunc = (object o) => stringFunc2((T)o);
}
GameObject val3 = new GameObject("Menu Option Label");
RectTransform val4 = val3.AddComponent<RectTransform>();
val4.anchoredPosition = new Vector2(450f, 0f);
val4.sizeDelta = new Vector2(900f, 1f);
val4.anchorMax = new Vector2(0f, 1f);
val4.anchorMin = new Vector2(0f, 0f);
Text val5 = val3.AddComponent<Text>();
val5.alignment = (TextAnchor)3;
val5.font = MenuResources.TrajanProBold;
val5.fontSize = 46;
val5.lineSpacing = -0.33f;
val5.text = label;
val5.horizontalOverflow = (HorizontalWrapMode)1;
ChangeTextFontScaleOnHandHeld val6 = val3.AddComponent<ChangeTextFontScaleOnHandHeld>();
val6.handHeldSize = 46f;
val6.normalSize = 46f;
val3.AddComponent<FixVerticalAlign>();
val3.transform.SetParent(val.transform, false);
GameObject val7 = new GameObject("Menu Option Text");
RectTransform val8 = val7.AddComponent<RectTransform>();
val8.anchoredPosition = new Vector2(-100f, 0f);
val8.sizeDelta = new Vector2(200f, 1f);
val8.anchorMax = new Vector2(1f, 1f);
val8.anchorMin = new Vector2(1f, 0f);
Text val9 = val7.AddComponent<Text>();
val9.alignment = (TextAnchor)5;
val9.font = MenuResources.TrajanProBold;
val9.fontSize = 38;
val9.lineSpacing = -0.33f;
val9.horizontalOverflow = (HorizontalWrapMode)1;
ChangeTextFontScaleOnHandHeld val10 = val7.AddComponent<ChangeTextFontScaleOnHandHeld>();
val10.handHeldSize = 38f;
val10.normalSize = 38f;
val7.AddComponent<FixVerticalAlign>();
val7.transform.SetParent(val.transform, false);
bepinexMenuOptionHorizontal.optionText = val9;
GameObject val11 = new GameObject("CursorRight");
RectTransform val12 = val11.AddComponent<RectTransform>();
val12.sizeDelta = new Vector2(164f, 119f);
val12.anchorMin = new Vector2(1f, 0.5f);
val12.anchorMax = new Vector2(1f, 0.5f);
val12.anchoredPosition = new Vector2(70f, 0f);
((Transform)val12).localScale = Vector2.op_Implicit(new Vector2(-0.9f, 0.9f));
val11.AddComponent<Image>();
Animator val13 = val11.AddComponent<Animator>();
val13.runtimeAnimatorController = MenuResources.MenuCursorAnimator;
val13.updateMode = (AnimatorUpdateMode)2;
((MenuSelectable)bepinexMenuOptionHorizontal).rightCursor = val13;
val11.transform.SetParent(val.transform, false);
GameObject val14 = new GameObject("CursorLeft");
RectTransform val15 = val14.AddComponent<RectTransform>();
val15.sizeDelta = new Vector2(164f, 119f);
val15.anchorMin = new Vector2(0f, 0.5f);
val15.anchorMax = new Vector2(0f, 0.5f);
val15.anchoredPosition = new Vector2(-70f, 0f);
((Transform)val15).localScale = Vector2.op_Implicit(new Vector2(0.9f, 0.9f));
val14.AddComponent<Image>();
Animator val16 = val14.AddComponent<Animator>();
val16.runtimeAnimatorController = MenuResources.MenuCursorAnimator;
val16.updateMode = (AnimatorUpdateMode)2;
((MenuSelectable)bepinexMenuOptionHorizontal).leftCursor = val16;
val14.transform.SetParent(val.transform, false);
GameObject val17 = new GameObject("Description");
RectTransform val18 = val17.AddComponent<RectTransform>();
val18.anchoredPosition = new Vector2(2f, -55.8f);
val18.sizeDelta = new Vector2(875.1f, 61f);
val18.anchorMax = new Vector2(0f, 0.5f);
val18.anchorMin = new Vector2(0f, 0.5f);
val18.pivot = new Vector2(0f, 0.5f);
Text val19 = val17.AddComponent<Text>();
val19.alignment = (TextAnchor)3;
val19.font = MenuResources.Perpetua;
val19.fontSize = 41;
val19.lineSpacing = 1f;
val19.text = description;
val19.horizontalOverflow = (HorizontalWrapMode)1;
Animator val20 = val17.AddComponent<Animator>();
val20.runtimeAnimatorController = (RuntimeAnimatorController)(object)MenuResources.TextHideShowAnimator;
val20.updateMode = (AnimatorUpdateMode)2;
ChangeTextFontScaleOnHandHeld val21 = val17.AddComponent<ChangeTextFontScaleOnHandHeld>();
val21.handHeldSize = 41f;
val21.normalSize = 41f;
val17.transform.SetParent(val.transform, false);
((MenuSelectable)bepinexMenuOptionHorizontal).descriptionText = val20;
Object.DontDestroyOnLoad((Object)(object)val);
return val;
}
}
public static class Utils
{
public static void Append<T>(ref T[] arr, T newElem)
{
T[] array = new T[arr.Length + 1];
for (int i = 0; i < arr.Length; i++)
{
array[i] = arr[i];
}
array[arr.Length] = newElem;
arr = array;
}
public static void InsertAfter<T>(ref T[] arr, T existingElem, T newElem)
{
T[] array = new T[arr.Length + 1];
int i;
for (i = 0; i < arr.Length; i++)
{
T val = (array[i] = arr[i]);
if (val != null && val.Equals(existingElem))
{
break;
}
}
if (i != arr.Length)
{
array[++i] = newElem;
for (; i < arr.Length; i++)
{
array[i + 1] = arr[i];
}
arr = array;
}
}
}
}
namespace GamepadUISwitcher
{
[HarmonyPatch(typeof(UIButtonSkins), "GetButtonSkinFor", new Type[] { typeof(InputControlType) })]
public class ButtonSkinsPatch
{
[HarmonyPrefix]
public static void Prefix(ref GamepadType __state, ref InputHandler ___ih)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Expected I4, but got Unknown
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Invalid comparison between Unknown and I4
//IL_001c: 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)
__state = (GamepadType)(int)___ih.activeGamepadType;
if ((int)___ih.activeGamepadType != 0)
{
___ih.activeGamepadType = GamepadUISwitcherPlugin.SelectedGamepadType;
}
}
[HarmonyPostfix]
public static void Postfix(ref GamepadType __state, ref InputHandler ___ih)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
___ih.activeGamepadType = __state;
}
}
public class ControllerDetectPatch
{
[HarmonyPatch(typeof(ControllerDetect), "ShowController")]
[HarmonyPrefix]
public static void ShowAltController(ref GamepadType gamepadType)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected I4, but got Unknown
gamepadType = (GamepadType)(int)GamepadUISwitcherPlugin.SelectedGamepadType;
}
}
public enum GamepadButtonSkinOpt
{
Auto,
Xbox360,
XboxOne,
XboxSeriesX,
DualShock4,
DualSense,
SwitchJoycons,
Switch2Joycons,
SwitchPro,
Switch2Pro,
SteamDeck
}
[BepInPlugin("capitalistspz.gamepaduiswitcher-silksong", "GamepadUISwitcher", "1.0.0")]
public class GamepadUISwitcherPlugin : BaseUnityPlugin
{
internal static ManualLogSource Logger;
internal static readonly GamepadButtonSkinOpt[] GamepadSkinOptions = Enum.GetValues(typeof(GamepadButtonSkinOpt)).Cast<GamepadButtonSkinOpt>().ToArray();
internal static ConfigEntry<GamepadButtonSkinOpt> gamepadSkinConfig;
public const string Id = "capitalistspz.gamepaduiswitcher-silksong";
internal static GamepadType SelectedGamepadType
{
get
{
//IL_0042: 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_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_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_0063: 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_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: 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_0086: Unknown result type (might be due to invalid IL or missing references)
GamepadButtonSkinOpt value = gamepadSkinConfig.Value;
if (1 == 0)
{
}
GamepadType result = (GamepadType)(value switch
{
GamepadButtonSkinOpt.Xbox360 => 3,
GamepadButtonSkinOpt.XboxOne => 2,
GamepadButtonSkinOpt.XboxSeriesX => 12,
GamepadButtonSkinOpt.DualShock4 => 4,
GamepadButtonSkinOpt.DualSense => 11,
GamepadButtonSkinOpt.SwitchJoycons => 9,
GamepadButtonSkinOpt.Switch2Joycons => 14,
GamepadButtonSkinOpt.SwitchPro => 10,
GamepadButtonSkinOpt.Switch2Pro => 15,
GamepadButtonSkinOpt.SteamDeck => 13,
_ => UIManager.instance.ih.activeGamepadType,
});
if (1 == 0)
{
}
return result;
}
}
public static string Name => "GamepadUISwitcher";
public static string Version => "1.0.0";
internal static string SkinOptToString(GamepadButtonSkinOpt type)
{
if (1 == 0)
{
}
string result = type switch
{
GamepadButtonSkinOpt.Auto => "Auto",
GamepadButtonSkinOpt.Xbox360 => "Xbox 360",
GamepadButtonSkinOpt.XboxOne => "Xbox One",
GamepadButtonSkinOpt.XboxSeriesX => "Xbox Series X",
GamepadButtonSkinOpt.DualShock4 => "DualShock 4",
GamepadButtonSkinOpt.DualSense => "DualSense",
GamepadButtonSkinOpt.SwitchJoycons => "Switch Joycons",
GamepadButtonSkinOpt.Switch2Joycons => "Switch 2 Joycons",
GamepadButtonSkinOpt.SwitchPro => "Switch Pro",
GamepadButtonSkinOpt.Switch2Pro => "Switch 2 Pro",
GamepadButtonSkinOpt.SteamDeck => "Steam Deck",
_ => "Unknown",
};
if (1 == 0)
{
}
return result;
}
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
gamepadSkinConfig = ((BaseUnityPlugin)this).Config.Bind<GamepadButtonSkinOpt>("UI", "Gamepad Skin", GamepadButtonSkinOpt.Auto, (ConfigDescription)null);
gamepadSkinConfig.SettingChanged += delegate
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
UIManager.instance.controllerDetect.ShowController(SelectedGamepadType);
UIManager.instance.uiButtonSkins.RefreshButtonMappings();
};
Harmony val = Harmony.CreateAndPatchAll(typeof(UIManagerPatch), (string)null);
val.PatchAll(typeof(ButtonSkinsPatch));
val.PatchAll(typeof(ControllerDetectPatch));
Logger.LogInfo((object)("Plugin " + Name + " (capitalistspz.gamepaduiswitcher-silksong) has loaded!"));
}
public static void SwapXY_AB()
{
//IL_00a3: 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_00b1: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: 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_00df: 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_00ed: 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_00f4: 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_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_026f: Unknown result type (might be due to invalid IL or missing references)
string[] array = new string[9] { "Xbox360Buttons", "XboxOneButtons", "PS4Buttons", "SwitchJoyconButtons", "Switch2JoyconButtons", "SwitchProControllerButtons", "PS5Buttons", "XboxSeriesXButtons", "SteamDeckButtons" };
string[] array2 = array;
foreach (string text in array2)
{
Transform val = ((Component)UIManager.instance.gamepadMenuScreen).transform.Find("Content/ControllerProfiles/" + text);
ControllerButtonPositions component = ((Component)val).GetComponent<ControllerButtonPositions>();
ControllerButtonLabel action = component.action1;
ControllerButtonLabel action2 = component.action2;
InputControlType controllerButton = component.action2.controllerButton;
InputControlType controllerButton2 = component.action1.controllerButton;
action.controllerButton = controllerButton;
action2.controllerButton = controllerButton2;
ControllerButtonLabel action3 = component.action3;
action2 = component.action4;
controllerButton2 = component.action4.controllerButton;
controllerButton = component.action3.controllerButton;
action3.controllerButton = controllerButton2;
action2.controllerButton = controllerButton;
}
UIButtonSkins uiButtonSkins = UIManager.instance.uiButtonSkins;
UIButtonSkins val2 = uiButtonSkins;
Sprite b = uiButtonSkins.b;
Sprite a = uiButtonSkins.a;
uiButtonSkins.a = b;
val2.b = a;
val2 = uiButtonSkins;
a = uiButtonSkins.y;
b = uiButtonSkins.x;
uiButtonSkins.x = a;
val2.y = b;
val2 = uiButtonSkins;
b = uiButtonSkins.ps4circle;
a = uiButtonSkins.ps4x;
uiButtonSkins.ps4x = b;
val2.ps4circle = a;
val2 = uiButtonSkins;
a = uiButtonSkins.ps4square;
b = uiButtonSkins.ps4triangle;
uiButtonSkins.ps4triangle = a;
val2.ps4square = b;
val2 = uiButtonSkins;
b = uiButtonSkins.switchHidB;
a = uiButtonSkins.switchHidA;
uiButtonSkins.switchHidA = b;
val2.switchHidB = a;
val2 = uiButtonSkins;
a = uiButtonSkins.switchHidY;
b = uiButtonSkins.switchHidX;
uiButtonSkins.switchHidX = a;
val2.switchHidY = b;
SonySkin ps = uiButtonSkins.ps5;
SonySkin ps2 = uiButtonSkins.ps5;
b = uiButtonSkins.ps5.circle;
a = uiButtonSkins.ps5.cross;
ps.cross = b;
ps2.circle = a;
SonySkin ps3 = uiButtonSkins.ps5;
ps2 = uiButtonSkins.ps5;
a = uiButtonSkins.ps5.square;
b = uiButtonSkins.ps5.triangle;
ps3.triangle = a;
ps2.square = b;
UIManager.instance.controllerDetect.ShowController(SelectedGamepadType);
}
}
public class UIManagerPatch
{
[HarmonyPatch(typeof(UIManager), "Awake")]
[HarmonyPostfix]
public static void OnAwake()
{
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Expected O, but got Unknown
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: 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_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Expected O, but got Unknown
//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
//IL_01bf: Expected O, but got Unknown
//IL_0238: Unknown result type (might be due to invalid IL or missing references)
//IL_023d: Unknown result type (might be due to invalid IL or missing references)
//IL_024a: Unknown result type (might be due to invalid IL or missing references)
//IL_0251: Unknown result type (might be due to invalid IL or missing references)
//IL_025a: Expected O, but got Unknown
MenuScreen gamepadMenuScreen = UIManager.instance.gamepadMenuScreen;
VerticalLayoutGroup val = Extensions.AddComponentIfNotPresent<VerticalLayoutGroup>(((Component)gamepadMenuScreen).gameObject);
((LayoutGroup)val).childAlignment = (TextAnchor)4;
((HorizontalOrVerticalLayoutGroup)val).childForceExpandHeight = false;
((HorizontalOrVerticalLayoutGroup)val).childForceExpandWidth = false;
((HorizontalOrVerticalLayoutGroup)val).childScaleHeight = true;
((HorizontalOrVerticalLayoutGroup)val).childControlHeight = false;
Transform obj = ((Component)gamepadMenuScreen).transform.Find("Content");
RectTransform val2 = (RectTransform)(object)((obj is RectTransform) ? obj : null);
Transform obj2 = ((Transform)val2).Find("ControllerProfiles");
RectTransform val3 = (RectTransform)(object)((obj2 is RectTransform) ? obj2 : null);
val2.sizeDelta = val3.sizeDelta;
Transform val4 = ((Component)gamepadMenuScreen).transform.Find("Controls");
VerticalLayoutGroup component = ((Component)val4).GetComponent<VerticalLayoutGroup>();
((HorizontalOrVerticalLayoutGroup)component).spacing = ((HorizontalOrVerticalLayoutGroup)component).spacing * 0.75f;
((LayoutGroup)component).childAlignment = (TextAnchor)4;
Transform val5 = val4.Find("RumbleSetting");
GameObject val6 = new GameObject("GamepadSkinSetting");
Extensions.AddComponentIfNotPresent<RectTransform>(val6);
val6.transform.SetParent(val4, false);
val6.transform.SetSiblingIndex(val5.GetSiblingIndex() + 1);
GameObject val7 = Objects.CreateBepinexConfigOption(GamepadUISwitcherPlugin.GamepadSkinOptions, GamepadUISwitcherPlugin.gamepadSkinConfig, "GamepadSkinOptionPopup", "Gamepad Skin", "Choose what the gamepad UI should look like", GamepadUISwitcherPlugin.SkinOptToString);
val7.transform.SetParent(val6.transform, false);
Entry val8 = new Entry
{
selectable = (Selectable)(object)val7.GetComponent<MenuSelectable>(),
alsoAffectParent = true,
forceEnable = false,
condition = null
};
MenuButtonList component2 = ((Component)gamepadMenuScreen).GetComponent<MenuButtonList>();
Entry existingElem = component2.entries.First((Entry entry) => ((Object)entry.selectable).name == "RumblePopupOption");
Utils.InsertAfter(ref component2.entries, existingElem, val8);
GameObject val9 = new GameObject("GamepadButtonSwapOption");
Extensions.AddComponentIfNotPresent<RectTransform>(val9);
val9.transform.SetParent(val4, false);
val9.transform.SetSiblingIndex(val6.transform.GetSiblingIndex() + 1);
GameObject val10 = Objects.CreateMenuButton("GamepadButtonSwapButton", "Swap Face Button Icons", (MenuButtonType)1, delegate
{
GamepadUISwitcherPlugin.SwapXY_AB();
});
val10.transform.SetParent(val9.transform, false);
Entry newElem = new Entry
{
selectable = (Selectable)(object)val10.GetComponent<MenuSelectable>(),
alsoAffectParent = true,
forceEnable = false
};
Utils.InsertAfter(ref component2.entries, val8, newElem);
}
}
}
[CompilerGenerated]
internal sealed class <>z__ReadOnlyArray<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
int ICollection.Count => _items.Length;
bool ICollection.IsSynchronized => false;
object ICollection.SyncRoot => this;
object IList.this[int index]
{
get
{
return _items[index];
}
set
{
throw new NotSupportedException();
}
}
bool IList.IsFixedSize => true;
bool IList.IsReadOnly => true;
int IReadOnlyCollection<T>.Count => _items.Length;
T IReadOnlyList<T>.this[int index] => _items[index];
int ICollection<T>.Count => _items.Length;
bool ICollection<T>.IsReadOnly => true;
T IList<T>.this[int index]
{
get
{
return _items[index];
}
set
{
throw new NotSupportedException();
}
}
public <>z__ReadOnlyArray(T[] items)
{
_items = items;
}
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable)_items).GetEnumerator();
}
void ICollection.CopyTo(Array array, int index)
{
((ICollection)_items).CopyTo(array, index);
}
int IList.Add(object value)
{
throw new NotSupportedException();
}
void IList.Clear()
{
throw new NotSupportedException();
}
bool IList.Contains(object value)
{
return ((IList)_items).Contains(value);
}
int IList.IndexOf(object value)
{
return ((IList)_items).IndexOf(value);
}
void IList.Insert(int index, object value)
{
throw new NotSupportedException();
}
void IList.Remove(object value)
{
throw new NotSupportedException();
}
void IList.RemoveAt(int index)
{
throw new NotSupportedException();
}
IEnumerator<T> IEnumerable<T>.GetEnumerator()
{
return ((IEnumerable<T>)_items).GetEnumerator();
}
void ICollection<T>.Add(T item)
{
throw new NotSupportedException();
}
void ICollection<T>.Clear()
{
throw new NotSupportedException();
}
bool ICollection<T>.Contains(T item)
{
return ((ICollection<T>)_items).Contains(item);
}
void ICollection<T>.CopyTo(T[] array, int arrayIndex)
{
((ICollection<T>)_items).CopyTo(array, arrayIndex);
}
bool ICollection<T>.Remove(T item)
{
throw new NotSupportedException();
}
int IList<T>.IndexOf(T item)
{
return ((IList<T>)_items).IndexOf(item);
}
void IList<T>.Insert(int index, T item)
{
throw new NotSupportedException();
}
void IList<T>.RemoveAt(int index)
{
throw new NotSupportedException();
}
}