using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using Nebula.ModConfig.EntryTypes;
using Nebula.ModConfig.Toasts;
using Nebula.UI;
using Nebula.Utils;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyCompany("Nebula.ModConfig")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Nebula.ModConfig")]
[assembly: AssemblyTitle("Nebula.ModConfig")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Nebula.ModConfig
{
public class CUIModConfigMenu : CUIMenu
{
public const int MODCONFIG_SUBSTATE = 268435456;
public static Dictionary<Type, Type> entryTypes = new Dictionary<Type, Type>
{
{
typeof(bool),
typeof(CUIModConfigBoolEntry)
},
{
typeof(int),
typeof(CUIModConfigIntEntry)
},
{
typeof(string),
typeof(CUIModConfigStringEntry)
},
{
typeof(Enum),
typeof(CUIModConfigEnumGenericEntry)
},
{
typeof(KeyCode),
typeof(CUIModConfigKeyCodeEntry)
}
};
public CUIButtonInput defaultButtonInput;
public AudioClip applyChangesClip;
public float applyChangesPitch = 1f;
public float applyChangesVolume = 0.45f;
public UIScrollView settingsScrollView;
public float minSpringTargetY;
public float maxSpringTargetY = 100f;
private CUIOption _firstOption;
public CUIButtonInput backButtonInput;
public UIScrollView scrollView;
[Header("Main")]
public UIPanel mainPanel;
public List<UITable> optionsTables;
public List<CUIModConfigEntryBase> entries;
public GameObject optionsRoot;
private string _activeGuid = "";
public bool optionsAreDirty
{
get
{
foreach (CUIModConfigEntryBase entry in entries)
{
if (entry.dirty)
{
return true;
}
}
return false;
}
set
{
entries.ForEach(delegate(CUIModConfigEntryBase e)
{
e.dirty = value;
});
}
}
protected override void OnEnable()
{
//IL_025d: Unknown result type (might be due to invalid IL or missing references)
//IL_0279: Unknown result type (might be due to invalid IL or missing references)
CUIButtonInput[] componentsInChildren = ((Component)base.buttonTable).GetComponentsInChildren<CUIButtonInput>();
CUIButtonInput val = componentsInChildren[^1];
CUIButtonInput[] array = componentsInChildren;
for (int i = 0; i < array.Length; i++)
{
(val.selectOnDown = array[i]).selectOnUp = val;
}
((CUIMenu)this).OnEnable();
foreach (UITable optionsTable in optionsTables)
{
List<Transform> list = new List<Transform>();
for (int j = 0; j < ((Component)optionsTable).transform.childCount; j++)
{
list.Add(((Component)optionsTable).transform.GetChild(j));
}
list.Sort((Comparison<Transform>)UIGrid.SortByName);
List<Transform> list2 = new List<Transform>();
for (int k = 0; k < list.Count; k++)
{
if (Object.op_Implicit((Object)(object)((Component)list[k]).GetComponent<CUIButtonInput>()) && ((Component)list[k]).gameObject.activeSelf)
{
list2.Add(list[k]);
}
}
for (int l = 0; l < list2.Count; l++)
{
CUIButtonInput component = ((Component)list2[l]).GetComponent<CUIButtonInput>();
if (!Object.op_Implicit((Object)(object)component))
{
continue;
}
if (l == 0)
{
component.selectOnUp = ((Component)list2[list2.Count - 1]).GetComponent<CUIButtonInput>();
if (list2.Count > 1)
{
component.selectOnDown = ((Component)list2[l + 1]).GetComponent<CUIButtonInput>();
}
else
{
component.selectOnDown = component;
}
}
else if (l == list2.Count - 1)
{
if (list2.Count > 1)
{
component.selectOnUp = ((Component)list2[l - 1]).GetComponent<CUIButtonInput>();
}
else
{
component.selectOnUp = component;
}
component.selectOnDown = ((Component)list2[0]).GetComponent<CUIButtonInput>();
}
else
{
component.selectOnDown = ((Component)list2[l + 1]).GetComponent<CUIButtonInput>();
component.selectOnUp = ((Component)list2[l - 1]).GetComponent<CUIButtonInput>();
}
BoxCollider component2 = ((Component)component).GetComponent<BoxCollider>();
if (Object.op_Implicit((Object)(object)component2))
{
component2.center = new Vector3(320f, 0f, 0f);
component2.size = new Vector3(640f, 20f, 0f);
}
}
}
base.buttonTable.ResetChildren();
base.buttonTable.Reposition();
CUIButtonInput.ProcessVerticalButtonTable(base.buttonTable.children, false);
SetVerticalScrollbarEnabled(value: false);
Messenger<GameObject>.AddListener("OnNewNGUISelection", (Callback<GameObject>)OnNewNGUISelection);
}
protected override void Update()
{
bool flag = Controls.player.GetButtonDown("Menu Cancel") || Input.GetKeyDown((KeyCode)27);
bool flag2 = !Controls.Instance.isUsingKeyboardMouse || (Object)(object)UICamera.hoveredObject == (Object)null;
if (flag && flag2)
{
AudioMenu.playCancel = true;
if (Object.op_Implicit((Object)(object)UICamera.selectedObject) && Object.op_Implicit((Object)(object)optionsTables.Find((UITable tbl) => (Object)(object)UICamera.selectedObject.transform.parent == (Object)(object)((Component)tbl).transform)))
{
UICamera.selectedObject = ((Component)defaultButtonInput).gameObject;
}
else if (optionsAreDirty)
{
PopupConfirmationMenu();
}
else
{
ReturnToLastMenu();
}
}
}
private void PopupConfirmationMenu()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Expected O, but got Unknown
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected O, but got Unknown
AudioMenu.playConfirm = true;
List<ConfirmationMenuDelegate> list = new List<ConfirmationMenuDelegate>
{
new ConfirmationMenuDelegate(OnApplyConfigsClicked),
new ConfirmationMenuDelegate(OnDiscardConfigsClicked)
};
List<string> list2 = new List<string> { "APPLY", "DISCARD" };
string text = "One or more configs have been modified. Apply changes?";
CUIConfirmationMenu.Show(list2, list, text, "", 1);
}
protected override void OnDisable()
{
Messenger<GameObject>.RemoveListener("OnNewNGUISelection", (Callback<GameObject>)OnNewNGUISelection);
((CUIMenu)this).OnDisable();
if (_activeGuid != "")
{
SetActiveGUIDRootActive(value: false);
_activeGuid = "";
UIProgressBar verticalScrollBar = scrollView.verticalScrollBar;
UIScrollBar val = (UIScrollBar)(object)((verticalScrollBar is UIScrollBar) ? verticalScrollBar : null);
val.barSize = 1f;
((UIProgressBar)val).value = 0f;
SetVerticalScrollbarEnabled(value: false);
}
}
public void SetVerticalScrollbarEnabled(bool value)
{
Collider component = ((Component)scrollView.verticalScrollBar.foregroundWidget).gameObject.GetComponent<Collider>();
component.enabled = value;
}
private void SetActiveGUIDRootActive(bool value)
{
Transform gUIDRoot = GetGUIDRoot(_activeGuid);
((Component)gUIDRoot).gameObject.SetActive(value);
if (value)
{
_firstOption = ((Component)gUIDRoot.GetChild(0)).GetComponent<CUIOption>();
scrollView.UpdateScrollbars(true);
SetVerticalScrollbarEnabled(value: true);
}
}
public Transform GetGUIDRoot(string guid)
{
return ((Component)scrollView).transform.Find("ROOT_" + guid);
}
private void OnNewNGUISelection(GameObject g)
{
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: 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_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: 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_0099: 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)
//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_00f9: 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_012a: Unknown result type (might be due to invalid IL or missing references)
if (Object.op_Implicit((Object)(object)g) && (Object)(object)g.transform.parent == (Object)(object)optionsRoot.transform && !Controls.menuMouseControl)
{
Vector3[] worldCorners = ((UIRect)settingsScrollView.panel).worldCorners;
Vector3 val = (worldCorners[2] + worldCorners[0]) * 0.5f;
Transform cachedTransform = ((UIRect)settingsScrollView.panel).cachedTransform;
Vector3 val2 = cachedTransform.InverseTransformPoint(g.transform.position);
Vector3 val3 = cachedTransform.InverseTransformPoint(val);
Vector3 val4 = val2 - val3;
if (!settingsScrollView.canMoveHorizontally)
{
val4.x = 0f;
}
if (!settingsScrollView.canMoveVertically)
{
val4.y = 0f;
}
val4.z = 0f;
Vector3 val5 = cachedTransform.localPosition - val4;
val5.y = Mathf.Clamp(val5.y, minSpringTargetY, maxSpringTargetY);
SpringPanel val6 = SpringPanel.Begin(((UIRect)settingsScrollView.panel).cachedGameObject, val5, 8f);
val6.mThreshold = 0.25f;
}
}
public void OnBackButtonClicked()
{
if (optionsAreDirty)
{
PopupConfirmationMenu();
}
else
{
ReturnToLastMenu();
}
}
private void CacheAllSettings()
{
foreach (CUIModConfigEntryBase entry in entries)
{
if (entry.dirty)
{
((CUIOption)entry).CacheValues();
}
}
}
private void ReturnToLastMenu()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
Game.Instance.menuSubstate = base.menuSubstateOnCancel;
}
public void OnEditButtonClicked(string guid)
{
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Invalid comparison between Unknown and I4
if (_activeGuid != "")
{
SetActiveGUIDRootActive(value: false);
}
_activeGuid = guid;
if (_activeGuid != "")
{
SetActiveGUIDRootActive(value: true);
}
if ((int)UI.controlScheme == 1)
{
UICamera.selectedObject = ((Component)_firstOption).gameObject;
}
}
public void OnModConfigButtonClicked()
{
Game.Instance.menuSubstate = (MenuSubstate)268435456;
}
public void OnApplyConfigsClicked()
{
CacheAllSettings();
ReturnToLastMenu();
}
public void OnDiscardConfigsClicked()
{
optionsAreDirty = false;
ReturnToLastMenu();
}
}
public class ModConfigButton : MonoBehaviour
{
public CUIModConfigMenu configMenu;
public string guid;
public void OnButtonClicked()
{
configMenu.OnEditButtonClicked(guid);
}
}
public static class ModConfigMenuCreator
{
public static void CreateConfigMenu()
{
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: 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)
GameObject rootObject = GameObjectUtils.GetRootObject("# CUI_2D");
Camera component = ((Component)rootObject.transform.FindChild("Camera")).GetComponent<Camera>();
Transform val = ((Component)component).transform.FindChild("ROOT_Menus");
MenuSubstateGate val2 = NGUITools.AddChild<MenuSubstateGate>(((Component)val).gameObject);
((Object)val2).name = "GATE_ModConfig";
val2.activeStateMask = (MenuSubstate)268435456;
((Component)val2).transform.SetParent(val);
UIAnchor val3 = NGUITools.AddChild<UIAnchor>(((Component)val2).gameObject);
val3.uiCamera = component;
val3.side = (Side)8;
val3.runOnlyOnce = true;
val3.relativeOffset = new Vector2(0f, -0.07f);
((Object)val3).name = "ANCHOR_ModConfig";
((Component)val3).transform.position = new Vector3(0f, -76f, 0f);
((Component)val3).gameObject.SetActive(false);
GameObjectUtils.CopyParentLayer(((Component)val3).gameObject);
val2.gameObjects.Add(((Component)val3).gameObject);
CUIModConfigMenu cUIModConfigMenu = NGUITools.AddChild<CUIModConfigMenu>(((Component)val3).gameObject);
cUIModConfigMenu.applyChangesClip = Resources.Load<AudioClip>("AudioClip/beep_select_04");
cUIModConfigMenu.applyChangesPitch = 0.3f;
cUIModConfigMenu.applyChangesVolume = 0.58f;
cUIModConfigMenu.minSpringTargetY = 1f;
cUIModConfigMenu.maxSpringTargetY = 308f;
cUIModConfigMenu.optionsTables = new List<UITable>();
cUIModConfigMenu.entries = new List<CUIModConfigEntryBase>();
((CUIMenu)cUIModConfigMenu).menuSubstateOnCancel = (MenuSubstate)4;
((Object)cUIModConfigMenu).name = "ROOT_ModConfig";
((Component)cUIModConfigMenu).transform.parent = ((Component)val3).transform;
GameObjectUtils.CopyParentLayer(((Component)cUIModConfigMenu).gameObject);
CreateConfigMenuChildren(cUIModConfigMenu);
Transform val4 = val.FindChild("GATE_OptionsMenu/ANCHOR_OptionsMenu/ROOT_OptionsMenu");
CreateConfigMenuButton(cUIModConfigMenu, ((Component)val4).GetComponent<CUIOptionsMenu>());
ModConfigToastCreator.CreateToasts(val, component);
}
private static void CreateConfigMenuButton(CUIModConfigMenu cfgMenu, CUIOptionsMenu optionsMenu)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Expected O, but got Unknown
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Expected O, but got Unknown
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: 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_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Expected O, but got Unknown
//IL_0081: Expected O, but got Unknown
UIFactory.CreateButton(((Component)((CUIMenu)optionsMenu).buttonTable).gameObject, "011_BUTTON_ModConfig", new ButtonSettings
{
Size = new Vector3(256f, 20f, 0f),
OnClick = new List<EventDelegate>
{
new EventDelegate(new Callback(cfgMenu.OnModConfigButtonClicked))
}
}, new LabelSettings
{
FontSize = 20,
Width = 256,
Text = "MOD SETTINGS"
}, (Pivot)5);
}
private static void CreateConfigMenuChildren(CUIModConfigMenu cfgMenu)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
UIPanel val = NGUITools.AddChild<UIPanel>(((Component)cfgMenu).gameObject);
val.renderQueue = (RenderQueue)0;
val.startingRenderQueue = 3007;
((Object)val).name = "PANEL_ModConfig";
GameObjectUtils.CopyParentLayer(((Component)val).gameObject);
((CUIMenu)cfgMenu).panel = val;
cfgMenu.mainPanel = val;
Rigidbody val2 = ((Component)val).gameObject.AddComponent<Rigidbody>();
val2.useGravity = false;
val2.isKinematic = true;
TweenAlpha val3 = ((Component)val).gameObject.AddComponent<TweenAlpha>();
((Behaviour)val3).enabled = false;
val3.from = 0f;
CUISpringScroller val4 = NGUITools.AddChild<CUISpringScroller>(((Component)val).gameObject);
((Object)val4).name = "MENU_ModConfig";
GameObjectUtils.CopyParentLayer(((Component)val4).gameObject);
CreateConfigMenuLeftPanel(val4, cfgMenu);
CreateConfigMenuRightPanel(val4, cfgMenu);
}
private static void CreateConfigMenuLeftPanel(CUISpringScroller menuRoot, CUIModConfigMenu cfgMenu)
{
//IL_002e: 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_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Expected O, but got Unknown
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: 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_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Expected O, but got Unknown
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
Transform transform = NGUITools.AddChild(((Component)menuRoot).gameObject).transform;
((Object)transform).name = "ROOT_Left";
transform.localPosition = new Vector3(-32f, 0f, 0f);
GameObjectUtils.CopyParentLayer(((Component)transform).gameObject);
Transform transform2 = NGUITools.AddChild(((Component)transform).gameObject).transform;
((Object)transform2).name = "000_ROOT_TITLE";
transform2.localPosition = Vector3.zero;
GameObjectUtils.CopyParentLayer(((Component)transform2).gameObject);
UILabel val = UIFactory.CreateLabel(((Component)transform2).gameObject, "LABEL_Title", new LabelSettings
{
Text = "MOD SETTINGS",
FontSize = 42,
Width = 166,
Font = StockFonts.serifGothic["Heavy"]
}, (Pivot)8);
((Component)val).transform.localPosition = new Vector3(0f, -8f, 0f);
UITexture val2 = UIFactory.CreateTextureBackground(((Component)val).gameObject, new TextureSettings
{
Color = Color.white,
Size = new Vector3(400f, 2f)
}, (Pivot)5);
((Component)val2).transform.localPosition = new Vector3(16f, 0f, 0f);
CreateConfigMenuModButtons(transform, cfgMenu);
}
private static void CreateConfigMenuModButtons(Transform leftRoot, CUIModConfigMenu cfgMenu)
{
//IL_0016: 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_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_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
//IL_019c: Expected O, but got Unknown
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Expected O, but got Unknown
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: Expected O, but got Unknown
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_0157: Expected O, but got Unknown
UITable val = NGUITools.AddChild<UITable>(((Component)leftRoot).gameObject);
val.columns = 1;
val.direction = (Direction)0;
val.sorting = (Sorting)1;
val.padding = new Vector2(0f, 3f);
((Object)val).name = "010_BUTTONS";
GameObjectUtils.CopyParentLayer(((Component)val).gameObject);
((Component)val).transform.localPosition = new Vector3(-256f, -24f, 0f);
((CUIMenu)cfgMenu).buttonTable = val;
int num = 1;
foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos)
{
BaseUnityPlugin instance = pluginInfo.Value.Instance;
if (instance.Config.Count != 0)
{
BepInPlugin metadata = pluginInfo.Value.Metadata;
UIButton val2 = GenerateModButton(num, metadata.GUID, metadata.Name.ToUpper(), new List<EventDelegate>(), ((Component)val).gameObject);
if (num == 1)
{
((Component)val2).GetComponent<CUIButtonInput>().startsSelected = true;
cfgMenu.defaultButtonInput = ((Component)val2).GetComponent<CUIButtonInput>();
}
ModConfigButton modConfigButton = ((Component)val2).gameObject.AddComponent<ModConfigButton>();
modConfigButton.configMenu = cfgMenu;
modConfigButton.guid = metadata.GUID;
val2.onClick.Add(new EventDelegate(new Callback(modConfigButton.OnButtonClicked)));
num++;
}
}
UIButton val3 = GenerateModButton(num, "Back", "BACK", new List<EventDelegate>
{
new EventDelegate(new Callback(cfgMenu.OnBackButtonClicked))
}, ((Component)val).gameObject);
cfgMenu.backButtonInput = ((Component)val3).GetComponent<CUIButtonInput>();
}
private static UIButton GenerateModButton(int i, string name, string text, List<EventDelegate> onClick, GameObject root)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: 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_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: 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_0063: Expected O, but got Unknown
//IL_0063: Expected O, but got Unknown
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
UIButton val = UIFactory.CreateButton(root, (i * 10).ToString("D3") + "_BUTTON_" + name, new ButtonSettings
{
Size = new Vector3(256f, 20f, 0f),
OnClick = onClick
}, new LabelSettings
{
Text = text,
FontSize = 20
}, (Pivot)5);
((Component)val).transform.localPosition = new Vector3(240f, (float)(15 - i * 30), 0f);
return val;
}
private static void CreateConfigMenuRightPanel(CUISpringScroller menuRoot, CUIModConfigMenu cfgMenu)
{
//IL_0036: 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_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: 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_00fb: 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_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
MouseControlGate val = NGUITools.AddChild<MouseControlGate>(((Component)menuRoot).gameObject);
((Behaviour)val).enabled = false;
((Object)val).name = "WIDGET_ScrollView";
((Component)val).transform.localPosition = new Vector3(32f, 30f, 0f);
GameObjectUtils.CopyParentLayer(((Component)val).gameObject);
cfgMenu.optionsRoot = ((Component)val).gameObject;
UIPanel val2 = NGUITools.AddChild<UIPanel>(((Component)val).gameObject);
val2.baseClipRegion = new Vector4(320f, -144f, 640f, 288f);
val2.clipping = (Clipping)2;
val2.renderQueue = (RenderQueue)0;
val2.startingRenderQueue = 3007;
((Object)val2).name = "PANEL_ScrollWindow";
GameObjectUtils.CopyParentLayer(((Component)val2).gameObject);
menuRoot.targetRoot = ((Component)val2).transform;
UIScrollView val3 = ((Component)val2).gameObject.AddComponent<UIScrollView>();
val3.dragEffect = (DragEffect)0;
val3.restrictWithinPanel = true;
val3.smoothDragStart = false;
val3.iOSDragEmulation = false;
val3.showScrollBars = (ShowCondition)0;
val3.contentPivot = (Pivot)0;
val3.movement = (Movement)3;
val3.customMovement = Vector2.up;
cfgMenu.settingsScrollView = val3;
cfgMenu.scrollView = val3;
menuRoot.settingsScrollView = val3;
UIScrollBar val4 = UIFactory.CreateVerticalScrollBar(((Component)val).gameObject, "SLIDER_Scrollbar", 1f, val3);
((Component)val4).transform.localPosition = new Vector3(-24f, 0f, 0f);
val.gameObjects.Add(((Component)val4).gameObject);
Rigidbody val5 = ((Component)val2).gameObject.AddComponent<Rigidbody>();
val5.useGravity = false;
val5.isKinematic = true;
CUIScroller val6 = ((Component)val2).gameObject.AddComponent<CUIScroller>();
val6.scrollView = val3;
val6.useControlAxis = false;
val6.mousewheelScrollSpeed = 100f;
CreateConfigMenuModOptions(val2, cfgMenu);
}
private static void CreateConfigMenuModOptions(UIPanel panelRoot, CUIModConfigMenu cfgMenu)
{
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos)
{
BaseUnityPlugin instance = pluginInfo.Value.Instance;
if (instance.Config.Count != 0)
{
UITable val = NGUITools.AddChild<UITable>(((Component)panelRoot).gameObject);
val.columns = 1;
val.sorting = (Sorting)1;
val.direction = (Direction)0;
((Object)val).name = "ROOT_" + pluginInfo.Key;
GameObjectUtils.CopyParentLayer(((Component)val).gameObject);
((Component)val).gameObject.SetActive(false);
cfgMenu.optionsTables.Add(val);
CreateConfigMenuOptionList(instance, ((Component)val).gameObject, cfgMenu);
((Behaviour)val).enabled = true;
}
}
}
private static void CreateConfigMenuOptionList(BaseUnityPlugin plugin, GameObject parent, CUIModConfigMenu cfgMenu)
{
//IL_019c: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
//IL_01c5: Expected O, but got Unknown
SortedDictionary<string, List<ConfigEntryBase>> sortedDictionary = new SortedDictionary<string, List<ConfigEntryBase>>();
foreach (KeyValuePair<ConfigDefinition, ConfigEntryBase> item in plugin.Config)
{
string section = item.Key.Section;
if (!sortedDictionary.ContainsKey(section))
{
sortedDictionary[section] = new List<ConfigEntryBase>();
}
sortedDictionary[section].Add(item.Value);
}
int num = 0;
foreach (KeyValuePair<string, List<ConfigEntryBase>> item2 in sortedDictionary)
{
GenerateModSectionLabel(num, item2.Key, parent);
num++;
foreach (ConfigEntryBase item3 in item2.Value)
{
Type type = item3.BoxedValue.GetType();
Type type2 = type;
while ((object)type2 != null && !CUIModConfigMenu.entryTypes.ContainsKey(type2))
{
type2 = type2.BaseType;
}
if ((object)type2 != null)
{
UIButton val = GenerateModButtonOption(num, item3.Definition.Key, item3, type2, parent);
CUIModConfigEntryBase component = ((Component)val).GetComponent<CUIModConfigEntryBase>();
component.SetupFromType(type);
cfgMenu.entries.Add(component);
if (num == 1)
{
((Component)val).GetComponent<CUIButtonInput>().startsSelected = true;
}
num++;
}
}
UIFactory.CreateLabel(parent, (num * 10 + 9).ToString("D3") + "_SPACER_10", new LabelSettings
{
Color = Color.clear,
FontSize = 10,
Width = 100
}, (Pivot)5);
}
}
private static UILabel GenerateModSectionLabel(int i, string name, GameObject root)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: 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_0064: Expected O, but got Unknown
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
UILabel val = UIFactory.CreateLabel(root, (i * 10).ToString("D3") + "_LABEL_" + name, new LabelSettings
{
Text = TextUtils.PascalNameToTitle(name, true),
Color = new Color(1f, 0.6431f, 0f),
FontSize = 32,
Width = 126
}, (Pivot)3);
((Component)val).transform.localPosition = new Vector3(0f, (float)(-15 - i * 30), 0f);
return val;
}
private static UIButton GenerateModButtonOption(int i, string name, ConfigEntryBase cfgKeyValue, Type valueType, GameObject root)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: 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_0069: Expected O, but got Unknown
//IL_0069: Expected O, but got Unknown
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Expected O, but got Unknown
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
UIButton val = UIFactory.CreateButton(root, (i * 10).ToString("D3") + "_BUTTON_" + name, new ButtonSettings
{
Size = new Vector3(640f, 20f)
}, new LabelSettings
{
Text = TextUtils.PascalNameToTitle(name, true),
FontSize = 20,
Width = 640
}, (Pivot)3);
((Component)val).transform.localPosition = new Vector3(0f, (float)(-15 - i * 30), 0f);
((Component)val).GetComponent<CUIMenuAudioTrigger>().clipType = (AudioClipType)2;
UITexture componentInChildren = ((Component)((Component)val).transform).GetComponentInChildren<UITexture>();
((Component)componentInChildren).transform.localPosition = Vector3.zero;
UILabel val2 = UIFactory.CreateLabel(((Component)val).gameObject, "LABEL_Value", new LabelSettings
{
Text = "VALUE",
FontSize = 20,
Width = 160
}, (Pivot)5);
((Component)val2).transform.localPosition = new Vector3(636f, 0f, 0f);
CUIModConfigEntryBase cUIModConfigEntryBase = GenerateModButtonEntry(cfgKeyValue, valueType, val);
((CUIOption)cUIModConfigEntryBase).valueLabel = val2;
return val;
}
private static CUIModConfigEntryBase GenerateModButtonEntry(ConfigEntryBase cfgKeyValue, Type valueType, UIButton button)
{
Type type = CUIModConfigMenu.entryTypes[valueType];
CUIModConfigEntryBase cUIModConfigEntryBase = (CUIModConfigEntryBase)(object)((Component)button).gameObject.AddComponent(type);
cUIModConfigEntryBase.SetReferenceData(cfgKeyValue);
return cUIModConfigEntryBase;
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "Nebula.ModConfig";
public const string PLUGIN_NAME = "Nebula.ModConfig";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace Nebula.ModConfig.Toasts
{
public class CUIConfigValueToast : CUIMenu
{
[Serializable]
public class Query
{
[TextArea(2, 5)]
public CUIModConfigEntryBase source;
public MenuSubstate menuSubstateOnExit;
public AudioClip clip;
public string GetKeyText()
{
return $"Set value for \"{TextUtils.PascalNameToTitle(source.GetDataKey(), false)}.\"";
}
public Query(CUIModConfigEntryBase source, MenuSubstate menuSubstateOnExit)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
this.source = source;
this.menuSubstateOnExit = menuSubstateOnExit;
}
}
public enum State
{
Inactive,
InitialDelay,
Outro,
Toast
}
public enum ToastType
{
None,
String,
KeyCode
}
public const int CONFIGTOAST_SUBSTATE = 536870912;
public static CUIConfigValueToast instance;
public static readonly List<string> buttonTitles = new List<string> { "APPLY", "DISCARD" };
private static readonly Dictionary<string, ToastType> toastTypeNames = new Dictionary<string, ToastType>
{
{
typeof(string).FullName,
ToastType.String
},
{
typeof(KeyCode).FullName,
ToastType.KeyCode
}
};
public readonly List<EventDelegate> callbackEvents = new List<EventDelegate>();
public CUIButtonInput defaultButtonInput;
public AudioClip applyChangesClip;
public float applyChangesPitch = 1f;
public float applyChangesVolume = 0.45f;
[Header("Timings")]
public float initialDelay = 0.1f;
public float toastIntroDuration = 0.2f;
public float toastOutroDuration = 0.2f;
public float outroDelay = 0.25f;
[Header("System")]
public UIPanel toastPanel;
public UILabel toastLabel;
public UITexture toastLabelBackground;
public UIInput inputField;
public UIButton keycodeButton;
public UILabel keycodeLabel;
public List<UIButton> bottomButtons = new List<UIButton>();
public List<UILabel> bottomButtonLabels = new List<UILabel>();
public AudioSource audioSource;
public UITable toastTable;
public List<UITweener> transitionInTweens = new List<UITweener>();
public List<UITweener> transitionOutTweens = new List<UITweener>();
private float _delayRemaining = 1f;
private KeyCode keyCode;
private EventDelegate _callback;
private static Query _query;
private State _state = State.Outro;
private static ToastType _type;
public EventDelegate callback
{
set
{
_callback = value;
}
}
public State state
{
get
{
return _state;
}
set
{
if (value != _state)
{
OnNewState(value, _state);
_state = value;
}
}
}
public static ToastType type
{
get
{
return _type;
}
set
{
if (value != _type)
{
instance.OnNewType(value, _type);
_type = value;
}
}
}
private void OnNewState(State newState, State oldState)
{
switch (newState)
{
case State.Inactive:
ResetTweens();
((Behaviour)toastPanel).enabled = false;
break;
case State.InitialDelay:
_delayRemaining = initialDelay;
break;
case State.Outro:
break;
case State.Toast:
((MonoBehaviour)this).StartCoroutine(ToastSequence());
break;
}
}
private void OnNewType(ToastType newType, ToastType oldType)
{
switch (oldType)
{
case ToastType.String:
((Component)inputField).gameObject.SetActive(false);
break;
case ToastType.KeyCode:
((Component)keycodeButton).gameObject.SetActive(false);
break;
}
CUIButtonInput val = null;
switch (newType)
{
case ToastType.String:
{
string valueStringRaw = _query.source.GetValueStringRaw();
inputField.label.maxLineCount = TextUtils.GetLineCount(valueStringRaw);
inputField.value = valueStringRaw;
((Component)inputField).gameObject.SetActive(true);
val = ((Component)inputField).GetComponent<CUIButtonInput>();
break;
}
case ToastType.KeyCode:
keycodeLabel.text = _query.source.GetValueStringUncolored();
((Component)keycodeButton).gameObject.SetActive(true);
val = ((Component)keycodeButton).GetComponent<CUIButtonInput>();
break;
default:
throw new NotSupportedException("New toast type not recognized");
case ToastType.None:
break;
}
foreach (UIButton bottomButton in bottomButtons)
{
CUIButtonInput component = ((Component)bottomButton).GetComponent<CUIButtonInput>();
component.selectOnDown = val;
component.selectOnUp = val;
}
}
protected override void OnEnable()
{
state = State.InitialDelay;
((Behaviour)inputField).enabled = true;
((CUIMenu)this).OnEnable();
}
protected override void Update()
{
switch (state)
{
case State.Inactive:
break;
case State.InitialDelay:
if (_delayRemaining <= 0f)
{
state = State.Toast;
}
else
{
_delayRemaining -= Time.deltaTime;
}
break;
case State.Outro:
break;
case State.Toast:
ToastUpdate();
break;
}
}
private void ToastUpdate()
{
if (Controls.lockAll)
{
if (type == ToastType.KeyCode)
{
CaptureInput();
}
if (type == ToastType.String && !inputField.isSelected)
{
SetInputLock(lockAll: false);
}
}
else if (inputField.isSelected)
{
SetInputLock(lockAll: true);
}
else
{
bool flag = Controls.player.GetButtonDown("Menu Cancel") || Input.GetKeyDown((KeyCode)27);
bool flag2 = !Controls.Instance.isUsingKeyboardMouse || (Object)(object)UICamera.hoveredObject == (Object)null;
if (flag && flag2)
{
AudioMenu.playCancel = true;
OnDiscardImmediate();
}
}
}
private void SetInputLock(bool lockAll)
{
Controls.lockAll = true;
if (type == ToastType.String)
{
((Behaviour)inputField).enabled = lockAll;
}
bottomButtons.ForEach(delegate(UIButton b)
{
((Component)b).gameObject.SetActive(!lockAll);
});
}
private void CaptureInput()
{
//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_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Invalid comparison between Unknown and I4
//IL_0028: 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)
Event current = Event.current;
if (current.isKey)
{
KeyCode val = current.keyCode;
if ((int)val != 0)
{
keyCode = val;
keycodeLabel.text = ((object)(KeyCode)(ref val)).ToString().ToUpper();
((UIWidget)keycodeLabel).SetDirty();
SetInputLock(lockAll: false);
}
}
}
public static void ActivateWithQuery(CUIModConfigEntryBase source, MenuSubstate menuSubstateOnExit)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
_query = new Query(source, menuSubstateOnExit);
Type valueType = source.GetValueType();
if (!toastTypeNames.ContainsKey(valueType.FullName))
{
throw new NotSupportedException("Toast does not support config values of type " + valueType.FullName);
}
type = toastTypeNames[valueType.FullName];
Game.Instance.menuSubstate = (MenuSubstate)536870912;
}
private IEnumerator ToastSequence()
{
_callback = null;
toastLabel.text = _query.GetKeyText();
((UIWidget)toastLabel).SetDirty();
for (int i = 0; i < bottomButtonLabels.Count; i++)
{
if (buttonTitles.Count > i)
{
((Component)bottomButtons[i]).gameObject.SetActive(true);
bottomButtonLabels[i].text = buttonTitles[i];
}
else
{
((Component)bottomButtons[i]).gameObject.SetActive(false);
}
}
if ((Object)(object)_query.clip != (Object)null)
{
audioSource.PlayOneShot(_query.clip);
}
((Behaviour)toastPanel).enabled = true;
((UIRect)toastPanel).alpha = 0f;
toastPanel.Refresh();
RepositionTable();
PlayTweens(transitionInTweens);
yield return (object)new WaitForSeconds(toastIntroDuration);
while (_callback == null)
{
yield return null;
}
PlayTweens(transitionOutTweens);
yield return (object)new WaitForSeconds(toastOutroDuration);
((Behaviour)toastPanel).enabled = false;
ResetTweens();
yield return null;
FireCallback();
yield return null;
state = State.Outro;
}
private void ResetTweens()
{
for (int i = 0; i < transitionOutTweens.Count; i++)
{
transitionOutTweens[i].ResetToBeginning();
((Behaviour)transitionOutTweens[i]).enabled = false;
}
for (int j = 0; j < transitionInTweens.Count; j++)
{
transitionInTweens[j].ResetToBeginning();
((Behaviour)transitionInTweens[j]).enabled = false;
}
}
private void PlayTweens(List<UITweener> tweeners)
{
for (int i = 0; i < tweeners.Count; i++)
{
((Behaviour)tweeners[i]).enabled = true;
tweeners[i].PlayForward();
}
}
[ContextMenu("Reposition Table")]
private void RepositionTable()
{
//IL_0027: 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_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: 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_0081: 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)
toastTable.Reposition();
((Component)toastLabel).transform.localPosition = new Vector3(10f, 0f, 0f);
Vector3 localPosition = ((Component)toastTable).transform.localPosition;
Bounds val = NGUIMath.CalculateRelativeWidgetBounds(((Component)toastTable).transform);
localPosition.y = ((Bounds)(ref val)).extents.y;
((Component)toastTable).transform.localPosition = localPosition;
((UIWidget)toastLabelBackground).width = (int)((Bounds)(ref val)).extents.x * 2;
((UIWidget)toastLabelBackground).height = (int)((Bounds)(ref val)).extents.y * 2;
}
private void FireCallback()
{
if (_callback != null)
{
_callback.Execute();
}
}
public void OnApplyImmediate()
{
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Expected O, but got Unknown
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Expected O, but got Unknown
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
string value = inputField.value;
switch (_type)
{
case ToastType.String:
{
CUIModConfigEntry<string> cUIModConfigEntry2 = (CUIModConfigEntry<string>)_query.source;
cUIModConfigEntry2.value = value;
break;
}
case ToastType.KeyCode:
{
CUIModConfigEntry<KeyCode> cUIModConfigEntry = (CUIModConfigEntry<KeyCode>)_query.source;
cUIModConfigEntry.value = keyCode;
break;
}
}
_callback = new EventDelegate(new Callback(ExitToQuerySubstate));
}
public void OnDiscardImmediate()
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Expected O, but got Unknown
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
_callback = new EventDelegate(new Callback(ExitToQuerySubstate));
}
private void ExitToQuerySubstate()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
Game.Instance.menuSubstate = _query.menuSubstateOnExit;
Controls.lockAll = false;
type = ToastType.None;
}
public void OnKeyCodeClicked()
{
SetInputLock(lockAll: true);
}
public void OnInputFieldSubmit()
{
SetInputLock(lockAll: false);
UICamera.selectedObject = ((Component)bottomButtons[0]).gameObject;
}
}
internal static class ModConfigToastCreator
{
public static void CreateToasts(Transform menuRoot, Camera uiCam)
{
//IL_001f: 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_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Expected O, but got Unknown
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Expected O, but got Unknown
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Expected O, but got Unknown
//IL_0160: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: Expected O, but got Unknown
MenuSubstateGate val = NGUITools.AddChild<MenuSubstateGate>(((Component)menuRoot).gameObject);
((Object)val).name = "GATE_ConfigToast";
val.activeStateMask = (MenuSubstate)536870912;
((Component)val).transform.SetParent(menuRoot);
UIAnchor val2 = NGUITools.AddChild<UIAnchor>(((Component)val).gameObject);
val2.uiCamera = uiCam;
val2.side = (Side)8;
val2.runOnlyOnce = true;
val2.relativeOffset = new Vector2(0f, -0.07f);
((Object)val2).name = "ANCHOR_ConfigToast";
((Component)val2).transform.position = new Vector3(0f, -76f, 0f);
((Component)val2).gameObject.SetActive(false);
GameObjectUtils.CopyParentLayer(((Component)val2).gameObject);
val.gameObjects.Add(((Component)val2).gameObject);
CUIConfigValueToast cUIConfigValueToast = (CUIConfigValueToast.instance = NGUITools.AddChild<CUIConfigValueToast>(((Component)val2).gameObject));
cUIConfigValueToast.audioSource = ((Component)GameObjectUtils.GetRootObject("# AUDIO").transform.FindChild("AUDIO_StoryToast")).GetComponent<AudioSource>();
cUIConfigValueToast.applyChangesClip = Resources.Load<AudioClip>("AudioClip/beep_select_04");
cUIConfigValueToast.applyChangesPitch = 0.3f;
cUIConfigValueToast.applyChangesVolume = 0.58f;
((CUIMenu)cUIConfigValueToast).menuSubstateOnCancel = (MenuSubstate)268435456;
((Object)cUIConfigValueToast).name = "ROOT_ConfigToast";
cUIConfigValueToast.callbackEvents.Add(new EventDelegate(new Callback(cUIConfigValueToast.OnApplyImmediate)));
cUIConfigValueToast.callbackEvents.Add(new EventDelegate(new Callback(cUIConfigValueToast.OnDiscardImmediate)));
((Component)cUIConfigValueToast).transform.parent = ((Component)val2).transform;
GameObjectUtils.CopyParentLayer(((Component)cUIConfigValueToast).gameObject);
CreateConfigToastChildren(cUIConfigValueToast);
cUIConfigValueToast.state = CUIConfigValueToast.State.Inactive;
}
private static void CreateConfigToastChildren(CUIConfigValueToast toast)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: 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)
//IL_00c3: 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_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
//IL_020e: Unknown result type (might be due to invalid IL or missing references)
//IL_0216: Unknown result type (might be due to invalid IL or missing references)
//IL_023e: Unknown result type (might be due to invalid IL or missing references)
//IL_026a: 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)
//IL_027b: 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_029a: Unknown result type (might be due to invalid IL or missing references)
//IL_02ac: Expected O, but got Unknown
//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
UIPanel val = NGUITools.AddChild<UIPanel>(((Component)toast).gameObject);
val.renderQueue = (RenderQueue)0;
val.startingRenderQueue = 3038;
((Object)val).name = "ROOT_ConfigEntry";
GameObjectUtils.CopyParentLayer(((Component)val).gameObject);
toast.toastPanel = val;
Rigidbody val2 = ((Component)val).gameObject.AddComponent<Rigidbody>();
val2.useGravity = false;
val2.isKinematic = true;
TweenAlpha val3 = ((Component)val).gameObject.AddComponent<TweenAlpha>();
val3.from = 0f;
((UITweener)val3).duration = 0.2f;
((Behaviour)val3).enabled = false;
toast.transitionInTweens.Add((UITweener)(object)val3);
TweenPosition val4 = ((Component)val).gameObject.AddComponent<TweenPosition>();
val4.from = new Vector3(240f, 0f, 0f);
((UITweener)val4).duration = 0.2f;
val4.to = Vector3.zero;
toast.transitionInTweens.Add((UITweener)(object)val4);
TweenAlpha val5 = ((Component)val).gameObject.AddComponent<TweenAlpha>();
val5.to = 0f;
((UITweener)val5).duration = 0.2f;
((Behaviour)val5).enabled = false;
toast.transitionOutTweens.Add((UITweener)(object)val5);
TweenPosition val6 = ((Component)val).gameObject.AddComponent<TweenPosition>();
val6.to = new Vector3(-240f, 0f, 0f);
((UITweener)val6).duration = 0.2f;
val6.from = Vector3.zero;
toast.transitionOutTweens.Add((UITweener)(object)val6);
UITexture val7 = NGUITools.AddWidget<UITexture>(((Component)val).gameObject);
((UIWidget)val7).color = new Color(0f, 0f, 0f, 0.9608f);
((UIWidget)val7).width = 720;
((UIWidget)val7).height = 115;
((UIWidget)val7).depth = -1;
((UIWidget)val7).mainTexture = (Texture)(object)Resources.Load<Texture2D>("ui/ngui/textures/fill_64x");
((UIWidget)val7).pivot = (Pivot)4;
((Component)val7).transform.localPosition = new Vector3(0f, 0f, 0f);
toast.toastLabelBackground = val7;
UITable val8 = NGUITools.AddChild<UITable>(((Component)val).gameObject);
val8.columns = 1;
val8.sorting = (Sorting)0;
val8.direction = (Direction)0;
((Object)val8).name = "TABLE_ConfigEntry";
((Component)val8).transform.localPosition = new Vector3(-360f, 56f, 0f);
GameObjectUtils.CopyParentLayer(((Component)val8).gameObject);
toast.toastTable = val8;
UILabel val9 = UIFactory.CreateLabel(((Component)val8).gameObject, "LABEL_Header", new LabelSettings
{
Text = "HEADER",
Font = StockFonts.blender["Bold"],
FontSize = 32,
Width = 320
}, (Pivot)0);
((Component)val9).transform.localPosition = new Vector3(10f, 7f, 0f);
toast.toastLabel = val9;
CreateInputHandlers(toast, val8);
CreateConfigToastButtons(toast, val8);
}
private static void CreateInputHandlers(CUIConfigValueToast toast, UITable table)
{
//IL_0022: 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_003d: 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_0052: 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_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_006d: 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_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Expected O, but got Unknown
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Expected O, but got Unknown
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Expected O, but got Unknown
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: 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)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Expected O, but got Unknown
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Expected O, but got Unknown
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0155: 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_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Expected O, but got Unknown
//IL_0178: Expected O, but got Unknown
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
Color val = default(Color);
((Color)(ref val))..ctor(0.25f, 0.25f, 0.25f);
UIInput val2 = UIFactory.CreateInput(((Component)table).gameObject, "INPUT_Text", new InputFieldSettings
{
Font = StockFonts.blender["Bold"],
Text = "Place text here",
FontSize = 24,
Width = 656,
Overflow = (Overflow)1,
BackgroundColor = new Color(val.r, val.g, val.b),
StartsSelected = true
}, (Pivot)4);
val2.onSubmit = new List<EventDelegate>
{
new EventDelegate(new Callback(toast.OnInputFieldSubmit))
};
((Component)val2).transform.localPosition = new Vector3(0f, -16f, 0f);
((Component)val2).gameObject.SetActive(false);
toast.inputField = val2;
UIButton val3 = UIFactory.CreateButton(((Component)table).gameObject, "BUTTON_KeyCode", new ButtonSettings
{
Size = new Vector3(360f, 40f),
OnClick = new List<EventDelegate>
{
new EventDelegate(new Callback(toast.OnKeyCodeClicked))
},
Color = val,
StartsSelected = true
}, new LabelSettings
{
Width = 360,
Effect = (Effect)0,
Text = "KEYCODE",
FontSize = 24
}, (Pivot)4);
((Component)val3).transform.localPosition = new Vector3(0f, -16f, 0f);
((Component)val3).gameObject.SetActive(false);
toast.keycodeButton = val3;
CUIMenuAudioTrigger component = ((Component)val3).GetComponent<CUIMenuAudioTrigger>();
component.clipType = (AudioClipType)2;
toast.keycodeLabel = ((Component)val3).GetComponentInChildren<UILabel>();
}
private static void CreateConfigToastButtons(CUIConfigValueToast toast, UITable table)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
UIGrid val = NGUITools.AddChild<UIGrid>(((Component)table).gameObject);
val.arrangement = (Arrangement)1;
val.sorting = (Sorting)0;
val.cellWidth = 400f;
val.cellHeight = 400f;
((Behaviour)val).enabled = false;
((Component)val).transform.localPosition = new Vector3(0f, -116f, 0f);
GameObjectUtils.CopyParentLayer(((Component)val).gameObject);
List<string> buttonTitles = CUIConfigValueToast.buttonTitles;
CUIButtonInput val2 = null;
CUIButtonInput val3 = null;
CUIButtonInput[] componentsInChildren = ((Component)table).GetComponentsInChildren<CUIButtonInput>();
for (int i = 0; i < buttonTitles.Count; i++)
{
CUIButtonInput val4 = GenerateConfigToastButton(i, val, toast);
((Component)val4).transform.localPosition = new Vector3((float)(-180 + 360 * i), 0f, 0f);
if ((Object)(object)val3 != (Object)null)
{
val4.selectOnLeft = val3;
val3.selectOnRight = val4;
CUIButtonInput[] array = componentsInChildren;
foreach (CUIButtonInput val5 in array)
{
val5.selectOnUp = val4;
}
}
else
{
val2 = val4;
}
if (i == buttonTitles.Count - 1)
{
val2.selectOnLeft = val4;
val4.selectOnRight = val2;
CUIButtonInput[] array2 = componentsInChildren;
foreach (CUIButtonInput val6 in array2)
{
val6.selectOnDown = val4;
}
}
}
}
private static CUIButtonInput GenerateConfigToastButton(int i, UIGrid grid, CUIConfigValueToast toast)
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: 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_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: 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_008c: 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)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Expected O, but got Unknown
//IL_00bf: Expected O, but got Unknown
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
int num = i + 1;
UIButton val = UIFactory.CreateButton(((Component)grid).gameObject, num.ToString("D3") + "_BUTTON", new ButtonSettings
{
Size = new Vector3(360f, 40f, 0f),
OnClick = new List<EventDelegate> { toast.callbackEvents[i] },
Color = new Color(0.1176f, 0.1176f, 0.1176f),
DisabledColor = Color.black
}, new LabelSettings
{
Width = 360,
Text = "BUTTON " + num,
FontSize = 20
}, (Pivot)4);
toast.bottomButtons.Add(val);
UILabel componentInChildren = ((Component)val).GetComponentInChildren<UILabel>();
toast.bottomButtonLabels.Add(componentInChildren);
CUIButtonInput component = ((Component)val).GetComponent<CUIButtonInput>();
if (i == 0)
{
component.startsSelected = true;
}
((Component)val).GetComponent<BoxCollider>().center = Vector3.zero;
return component;
}
}
}
namespace Nebula.ModConfig.EntryTypes
{
public class CUIModConfigBoolEntry : CUIModConfigEntry<bool>
{
private void ToggleValue()
{
base.value = !base.value;
}
protected override void AdjustValueBackward()
{
ToggleValue();
}
protected override void AdjustValueForward()
{
ToggleValue();
}
public override string GetValueStringUncolored()
{
return base.value ? "ON" : "OFF";
}
}
public abstract class CUIModConfigCycleEntry<T> : CUIModConfigEntry<T>
{
public List<T> cycle { protected get; set; } = new List<T>();
protected int GetValueIndex()
{
return cycle.IndexOf(base.value);
}
protected void CycleBy(int by)
{
int index = MathUtils.CanonicalMod(GetValueIndex() + by, cycle.Count);
base.value = cycle[index];
}
protected override void AdjustValueForward()
{
CycleBy(1);
}
protected override void AdjustValueBackward()
{
CycleBy(-1);
}
}
public abstract class CUIModConfigEntry<T> : CUIModConfigEntryBase
{
protected T _value;
protected ConfigEntry<T> dataTyped
{
get
{
return (ConfigEntry<T>)(object)data;
}
set
{
data = (ConfigEntryBase)(object)value;
}
}
public T value
{
get
{
return _value;
}
set
{
_value = value;
dirty = true;
}
}
public void SetReferenceData(ConfigEntry<T> dataTyped)
{
this.dataTyped = dataTyped;
}
public override Type GetValueType()
{
return typeof(T);
}
protected override void CacheCurrentValue()
{
dataTyped.Value = value;
dirty = false;
}
protected override void OnEnable()
{
if (!dirty)
{
_value = dataTyped.Value;
}
((CUIOption)this).RefreshButton(false);
}
protected abstract void AdjustValueForward();
protected abstract void AdjustValueBackward();
protected override void OnClick()
{
if (UICamera.currentTouchID == -2)
{
AdjustValueBackward();
}
else
{
AdjustValueForward();
}
((CUIOption)this).RefreshButton(false);
}
protected override void OnButtonRight()
{
AdjustValueForward();
((CUIOption)this).RefreshButton(true);
}
protected override void OnButtonLeft()
{
AdjustValueBackward();
((CUIOption)this).RefreshButton(true);
}
public override string GetValueStringRaw()
{
return value.ToString();
}
public override string GetValueStringUncolored()
{
return GetValueStringRaw().ToUpper();
}
protected override string GetValueString()
{
return $"[{((CUIOption)this).GetOptionColorMarkup()}]{GetValueStringUncolored()}";
}
public override string GetConfigString()
{
return "";
}
}
public abstract class CUIModConfigEntryBase : CUIOption
{
[HideInInspector]
protected ConfigEntryBase data;
public bool dirty = false;
public void SetReferenceData(ConfigEntryBase data)
{
this.data = data;
}
public string GetDataKey()
{
return data.Definition.Key;
}
public string GetDataSection()
{
return data.Definition.Section;
}
public abstract Type GetValueType();
public abstract string GetValueStringRaw();
public abstract string GetValueStringUncolored();
public virtual void SetupFromType(Type type)
{
}
}
public abstract class CUIModConfigEnumEntry<TEnum> : CUIModConfigCycleEntry<TEnum> where TEnum : Enum
{
protected override void OnEnable()
{
if (base.cycle.Count == 0)
{
TEnum[] collection = (TEnum[])Enum.GetValues(typeof(TEnum));
base.cycle = new List<TEnum>(collection);
}
base.OnEnable();
}
}
public class CUIModConfigEnumGenericEntry : CUIModConfigCycleEntry<object>
{
protected override void CacheCurrentValue()
{
data.BoxedValue = base.value;
dirty = false;
}
protected override void OnEnable()
{
if (!dirty)
{
_value = data.BoxedValue;
}
((CUIOption)this).RefreshButton(false);
}
public override void SetupFromType(Type type)
{
foreach (object value in Enum.GetValues(type))
{
base.cycle.Add(value);
}
}
}
public class CUIModConfigIntEntry : CUIModConfigEntry<int>
{
private void AdjustValueBy(int by)
{
base.value += by;
}
protected override void AdjustValueBackward()
{
AdjustValueBy(-1);
}
protected override void AdjustValueForward()
{
AdjustValueBy(1);
}
}
public class CUIModConfigKeyCodeEntry : CUIModConfigEntry<KeyCode>
{
protected override void AdjustValueBackward()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
base.value = (KeyCode)((ConfigEntryBase)base.dataTyped).DefaultValue;
}
protected override void AdjustValueForward()
{
CUIConfigValueToast.ActivateWithQuery(this, (MenuSubstate)268435456);
}
}
public class CUIModConfigStringEntry : CUIModConfigEntry<string>
{
public const int DISPLAY_LENGTH_MAX = 10;
protected override void AdjustValueBackward()
{
base.value = (string)((ConfigEntryBase)base.dataTyped).DefaultValue;
}
protected override void AdjustValueForward()
{
CUIConfigValueToast.ActivateWithQuery(this, (MenuSubstate)268435456);
}
public override string GetValueStringUncolored()
{
if (base.value.Length <= 10)
{
return base.value;
}
string text = base.value.Substring(0, 7);
return text.PadRight(10, '.');
}
}
}