using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using DG.Tweening;
using DG.Tweening.Core;
using DG.Tweening.Plugins.Options;
using HarmonyLib;
using ModSettingsApi.Api;
using ModSettingsApi.Manager;
using ModSettingsApi.Models;
using ModSettingsApi.Models.Enums;
using ModSettingsApi.Models.Ui;
using ModSettingsApi.Models.UiWrapper;
using ModSettingsApi.Models.Variants;
using ModSettingsApi.Patches;
using TMPro;
using UI.CustomElements.CustomSliders;
using UI.CustomElements.Tabs.SettingsTabs;
using UI.MainMenu;
using UnityEngine;
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("ModSettingsApi")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+57cd89a8f95ed0047af0929fa482032fdd189907")]
[assembly: AssemblyProduct("ModSettingsApi")]
[assembly: AssemblyTitle("ModSettingsApi")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace ModSettingsApi
{
[BepInPlugin("Edsil.ModSettingsApi", "ModSettingsApi", "1.0.0")]
public class BepinexLoader : BaseUnityPlugin
{
public const string MODNAME = "ModSettingsApi";
public const string AUTHOR = "Edsil";
public const string GUID = "Edsil.ModSettingsApi";
public const string VERSION = "1.0.0";
public static Harmony ModSettingsApiHarmony { get; } = new Harmony("ModSettingsApi");
public static ManualLogSource Log { get; set; }
public static GameObject ModSettingsApi { get; private set; }
public void Awake()
{
ModSettingsApi = ((Component)this).gameObject;
Log = ((BaseUnityPlugin)this).Logger;
ModSettingsApiHarmony.PatchAll(typeof(MainMenuUiPatches));
ConfigEntry<bool> val = ((BaseUnityPlugin)this).Config.Bind<bool>("Development", "DebugMessages", false, "If this mod writes debug Messages, mainly used for PrintF debugging.");
ConfigEntry<bool> val2 = ((BaseUnityPlugin)this).Config.Bind<bool>("Development", "DebugView", false, "If this mod creates test views");
LogManager.DebugActive = val.Value;
if (val2.Value)
{
TestDataManager.Init();
DebugModManager.Init();
}
}
}
internal static class Extensions
{
public static T Instantiate<T>(this GameObject gameObject, string name) where T : Component
{
GameObject val = Object.Instantiate<GameObject>(gameObject, gameObject.transform.parent, false);
((Object)val).name = name;
return val.GetComponent<T>();
}
public static GameObject Instantiate(this GameObject gameObject, string name, Transform parent = null)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
GameObject val = new GameObject(name);
Object.DontDestroyOnLoad((Object)(object)val);
val.transform.SetParent(parent);
Object.Instantiate<GameObject>(gameObject, val.transform);
return val;
}
internal static void AddInternalMod()
{
}
}
internal static class LogManager
{
private static readonly ManualLogSource logger;
internal static bool DebugActive { get; set; }
static LogManager()
{
logger = BepinexLoader.Log;
}
public static void Verbose(object msg)
{
logger.LogInfo(msg);
}
public static void Debug(object msg)
{
if (DebugActive)
{
logger.LogMessage(msg);
}
}
public static void Message(object msg)
{
if (DebugActive)
{
logger.LogMessage(msg);
}
}
public static void Error(object msg)
{
logger.LogError(msg);
}
public static void Warn(object msg)
{
logger.LogWarning(msg);
}
internal static void CategoryMessage([CallerMemberName] string category = "unknown???")
{
logger.LogMessage((object)"=======================================================================");
logger.LogMessage((object)category);
logger.LogMessage((object)"=======================================================================");
}
}
}
namespace ModSettingsApi.Patches
{
[HarmonyPatch(typeof(MainMenuUI))]
public static class MainMenuUiPatches
{
[HarmonyPatch("Awake")]
[HarmonyPostfix]
public static void AwakePostfix(MainMenuUI __instance)
{
LogManager.CategoryMessage("AwakePostfix");
SettingsManager.Init(__instance);
}
[HarmonyPatch(typeof(MainMenuUI), "HideNews")]
[HarmonyPrefix]
public static void HideNewsPrefix()
{
PanelUiManager.Instance?.ClosePanel();
}
}
}
namespace ModSettingsApi.Models
{
public class TabModel
{
private ObservableCollection<IVariant> _settings;
public string ModName { get; set; }
public ObservableCollection<IVariant> Settings
{
get
{
return _settings;
}
set
{
if (_settings != null)
{
_settings.CollectionChanged -= SettingsListChanged;
}
_settings = value;
if (value == null)
{
return;
}
_settings.CollectionChanged += SettingsListChanged;
foreach (IVariant item in value)
{
item.ParentMod = this;
}
}
}
public TabModel(string modName, IEnumerable<IVariant> settings)
{
ModName = modName;
Settings = new ObservableCollection<IVariant>(settings);
}
public override string ToString()
{
return ModName;
}
private void SettingsListChanged(object sender, NotifyCollectionChangedEventArgs e)
{
foreach (object newItem in e.NewItems)
{
if (newItem is IVariant variant)
{
variant.ParentMod = this;
}
}
}
}
}
namespace ModSettingsApi.Models.Variants
{
public class ButtonVariant : IVariant
{
public string SettingsText { get; }
public string ButtonText { get; }
public SettingsVariant Variant => SettingsVariant.Button;
[IgnoreDataMember]
TabModel IVariant.ParentMod { get; set; }
public UnityAction ButtonClick { get; set; }
public UnityAction<ButtonVariant> ButtonClick_SelfRef { get; set; }
public ButtonVariant(string settingsName, string buttonText, UnityAction click)
{
SettingsText = settingsName;
ButtonText = buttonText;
ButtonClick = click;
}
public ButtonVariant(string settingsName, string buttonText, UnityAction<ButtonVariant> click)
{
SettingsText = settingsName;
ButtonText = buttonText;
ButtonClick_SelfRef = click;
}
public void InvokeSetting()
{
UnityAction buttonClick = ButtonClick;
if (buttonClick != null)
{
buttonClick.Invoke();
}
ButtonClick_SelfRef?.Invoke(this);
}
}
public class ComboBoxVariant : IVariant
{
public string SettingsText { get; }
public SettingsVariant Variant => SettingsVariant.ComboBox;
public List<IComboBoxData> Settings { get; }
public IComboBoxData CurrentValue { get; private set; }
public virtual UnityAction<IComboBoxData> ValueChanged { get; }
[IgnoreDataMember]
TabModel IVariant.ParentMod { get; set; }
public ComboBoxVariant(string settingsName, UnityAction<IComboBoxData> valueChanged, List<IComboBoxData> settings)
: this(settingsName, valueChanged, settings, settings.FirstOrDefault())
{
}
public ComboBoxVariant(string settingsName, UnityAction<IComboBoxData> valueChanged, List<IComboBoxData> settings, IComboBoxData defaultValue)
{
Settings = settings;
SettingsText = settingsName;
ValueChanged = valueChanged;
CurrentValue = defaultValue;
}
internal void ValueHasChanged(int index)
{
if (CurrentValue != Settings[index])
{
CurrentValue = Settings[index];
ValueChanged.Invoke(CurrentValue);
}
}
}
public class ComboBoxOptionData : IComboBoxData
{
public string Text { get; set; }
public Sprite Image { get; set; }
public ComboBoxOptionData(string text = null, Sprite image = null)
{
Text = text;
Image = image;
}
}
public interface IComboBoxData
{
string Text { get; set; }
Sprite Image { get; set; }
}
public interface IVariant
{
string SettingsText { get; }
SettingsVariant Variant { get; }
[IgnoreDataMember]
internal TabModel ParentMod { get; set; }
}
internal class ListNavigatorVariant : IVariant
{
public string SettingsText { get; }
public SettingsVariant Variant => SettingsVariant.ListNavigator;
public bool CurrentValue { get; set; }
[IgnoreDataMember]
TabModel IVariant.ParentMod { get; set; }
}
internal class SliderVariant : IVariant
{
public string SettingsText { get; }
public SettingsVariant Variant => SettingsVariant.Slider;
public object CurrentValue { get; set; }
[IgnoreDataMember]
TabModel IVariant.ParentMod { get; set; }
public SliderVariant(string settingsText)
{
SettingsText = settingsText;
}
}
public class TextBoxVariant : IVariant
{
public string SettingsText { get; }
public string GreyText { get; }
public SettingsVariant Variant => SettingsVariant.TextInput;
public string CurrentValue { get; set; }
public UnityAction<string> ValueChanged { get; set; }
[IgnoreDataMember]
TabModel IVariant.ParentMod { get; set; }
public TextBoxVariant(string settingsText, string greyText, UnityAction<string> valueChanged, string defaultValue)
{
SettingsText = settingsText;
GreyText = greyText;
ValueChanged = valueChanged;
CurrentValue = defaultValue;
}
internal void TextHasChanged(string newValue)
{
if (!(CurrentValue == newValue))
{
CurrentValue = newValue;
ValueChanged?.Invoke(newValue);
}
}
}
public class ToggleButtonVariant : IVariant
{
public string SettingsText { get; }
public SettingsVariant Variant => SettingsVariant.ToggleButton;
public bool CurrentValue { get; set; }
public UnityAction<bool> ValueChanged { get; }
[IgnoreDataMember]
TabModel IVariant.ParentMod { get; set; }
public ToggleButtonVariant(string settingsName, UnityAction<bool> valueChanged, bool defaultValue = false)
{
SettingsText = settingsName;
ValueChanged = valueChanged;
CurrentValue = defaultValue;
}
internal void OnValueHasChanged(bool newValue)
{
if (CurrentValue != newValue)
{
CurrentValue = newValue;
ValueChanged?.Invoke(newValue);
}
}
}
}
namespace ModSettingsApi.Models.Ui
{
public class SettingButtonWrapper : BaseSetting<ButtonVariant, SettingButtonWrapper>
{
private readonly TextMeshProUGUI _text;
private readonly TextMeshProUGUI _buttonText;
private readonly Button _button;
public SettingButtonWrapper(GameObject managedGameobject)
{
_managedGameObject = managedGameobject;
_button = ((Component)_managedGameObject.transform.Find("CustomButton")).GetComponent<Button>();
_buttonText = ((Component)_button).GetComponentInChildren<TextMeshProUGUI>();
_text = ((Component)_managedGameObject.transform.Find("Full Screen")).GetComponent<TextMeshProUGUI>();
}
public static SettingButtonWrapper Create(SettingToggleButtonWrapper existingWrapper, GameObject existingButton)
{
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
GameObject val = Object.Instantiate<GameObject>(existingWrapper.ManagedGameObject, existingWrapper.ManagedGameObject.transform.parent);
val.SetActive(true);
((Object)val).name = "Custom_ButtonSetting";
Transform val2 = val.transform.Find("FullScreenToggle");
((Component)val2).gameObject.SetActive(false);
Object.Destroy((Object)(object)((Component)val2).gameObject);
RectTransform component = Object.Instantiate<GameObject>(existingButton, val.transform).GetComponent<RectTransform>();
((Object)component).name = "CustomButton";
component.anchoredPosition = new Vector2(250f, 0f);
return new SettingButtonWrapper(val);
}
public override SettingButtonWrapper Instatiate(Transform parent, ButtonVariant settingModel)
{
GameObject val = Object.Instantiate<GameObject>(base.ManagedGameObject, parent);
val.gameObject.SetActive(true);
((Object)val).name = ((IVariant)settingModel).ParentMod.ModName + "_Button_" + settingModel.SettingsText;
SettingButtonWrapper settingButtonWrapper = new SettingButtonWrapper(val);
return settingButtonWrapper.Instantiate(settingModel);
}
private SettingButtonWrapper Instantiate(ButtonVariant settingModel)
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Expected O, but got Unknown
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Expected O, but got Unknown
((TMP_Text)_text).SetText(settingModel.SettingsText, true);
((TMP_Text)_buttonText).SetText(settingModel.ButtonText, true);
((UnityEventBase)_button.onClick).RemoveAllListeners();
_button.onClick = new ButtonClickedEvent();
((UnityEvent)_button.onClick).AddListener(new UnityAction(settingModel.InvokeSetting));
return this;
}
}
public class SettingComboBoxWrapper : BaseSetting<ComboBoxVariant, SettingComboBoxWrapper>
{
private readonly TextMeshProUGUI _text;
private readonly TMP_Dropdown _dropDown;
public SettingComboBoxWrapper(GameObject managedGameObject)
{
_managedGameObject = managedGameObject;
_text = ((Component)_managedGameObject.transform.Find("Resolution")).GetComponent<TextMeshProUGUI>();
_dropDown = ((Component)_managedGameObject.transform.Find("Dropdown")).GetComponent<TMP_Dropdown>();
}
public override SettingComboBoxWrapper Instatiate(Transform parent, ComboBoxVariant settingModel)
{
GameObject val = Object.Instantiate<GameObject>(base.ManagedGameObject, parent);
val.SetActive(true);
((Object)val).name = ((IVariant)settingModel).ParentMod.ModName + "_Combo_" + settingModel.SettingsText;
SettingComboBoxWrapper settingComboBoxWrapper = new SettingComboBoxWrapper(val);
return settingComboBoxWrapper.Instantiate(settingModel);
}
private SettingComboBoxWrapper Instantiate(ComboBoxVariant settingModel)
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Expected O, but got Unknown
_dropDown.options.Clear();
for (int i = 0; i < settingModel.Settings.Count; i++)
{
IComboBoxData comboBoxData = settingModel.Settings[i];
OptionData item = new OptionData(comboBoxData.Text, comboBoxData.Image);
_dropDown.options.Add(item);
if (comboBoxData == settingModel.CurrentValue)
{
_dropDown.value = i;
}
}
DropdownEvent onValueChanged = _dropDown.onValueChanged;
if (onValueChanged != null)
{
((UnityEventBase)onValueChanged).RemoveAllListeners();
}
_dropDown.onValueChanged = new DropdownEvent();
((UnityEvent<int>)(object)_dropDown.onValueChanged).AddListener((UnityAction<int>)settingModel.ValueHasChanged);
((TMP_Text)_text).SetText(settingModel.SettingsText, true);
return this;
}
}
internal class SettingSliderWrapper : BaseSetting<SliderVariant, SettingSliderWrapper>
{
private readonly TextMeshProUGUI _text;
private readonly SliderValueDisplay _sliderDisplay;
public SettingSliderWrapper(GameObject managedGameObject)
{
_managedGameObject = managedGameObject;
_text = ((Component)_managedGameObject.transform.Find("Music")).GetComponent<TextMeshProUGUI>();
}
public override SettingSliderWrapper Instatiate(Transform parent, SliderVariant settingModel)
{
return null;
}
}
public class SettingToggleButtonWrapper : BaseSetting<ToggleButtonVariant, SettingToggleButtonWrapper>
{
private readonly TextMeshProUGUI _text;
private readonly Toggle _toggle;
internal Toggle Toggle => _toggle;
public SettingToggleButtonWrapper(GameObject managedGameObject)
{
_managedGameObject = managedGameObject;
_text = _managedGameObject.GetComponentInChildren<TextMeshProUGUI>();
_toggle = ((Component)_managedGameObject.transform.Find("FullScreenToggle")).GetComponent<Toggle>();
}
public override SettingToggleButtonWrapper Instatiate(Transform parent, ToggleButtonVariant settingModel)
{
GameObject val = Object.Instantiate<GameObject>(base.ManagedGameObject, parent);
val.SetActive(true);
((Object)val).name = ((IVariant)settingModel).ParentMod.ModName + "_ToggleButton_" + settingModel.SettingsText;
SettingToggleButtonWrapper settingToggleButtonWrapper = new SettingToggleButtonWrapper(val);
return settingToggleButtonWrapper.Instantiate(settingModel);
}
private SettingToggleButtonWrapper Instantiate(ToggleButtonVariant settingModel)
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Expected O, but got Unknown
((TMP_Text)_text).SetText(settingModel.SettingsText, true);
((UnityEventBase)_toggle.onValueChanged).RemoveAllListeners();
_toggle.isOn = settingModel.CurrentValue;
_toggle.onValueChanged = new ToggleEvent();
((UnityEvent<bool>)(object)_toggle.onValueChanged).AddListener((UnityAction<bool>)settingModel.OnValueHasChanged);
return this;
}
}
}
namespace ModSettingsApi.Models.UiWrapper
{
public abstract class BaseSetting<T, ParentSetting> : IBaseSetting where T : IVariant where ParentSetting : IBaseSetting
{
protected GameObject _managedGameObject;
public GameObject ManagedGameObject => _managedGameObject;
public abstract ParentSetting Instatiate(Transform parent, T settingModel);
}
public interface IBaseSetting
{
GameObject ManagedGameObject { get; }
}
public class SettingTextBoxWrapper : BaseSetting<TextBoxVariant, SettingTextBoxWrapper>
{
private readonly TextMeshProUGUI _text;
private readonly TextMeshProUGUI _greyText;
private readonly TMP_InputField _textBox;
public SettingTextBoxWrapper(GameObject managedGameObject)
{
_managedGameObject = managedGameObject;
_text = ((Component)_managedGameObject.transform.Find("Full Screen")).GetComponent<TextMeshProUGUI>();
_greyText = ((Component)_managedGameObject.transform.Find("CustomTextBox/Text Area/Placeholder")).GetComponent<TextMeshProUGUI>();
_textBox = ((Component)_managedGameObject.transform.Find("CustomTextBox")).GetComponent<TMP_InputField>();
}
public static SettingTextBoxWrapper Create(SettingToggleButtonWrapper existingWrapper, GameObject existingTextBox)
{
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
GameObject val = Object.Instantiate<GameObject>(existingWrapper.ManagedGameObject, existingWrapper.ManagedGameObject.transform.parent);
((Object)val).name = "Custom_TextBoxSetting";
Transform val2 = val.transform.Find("FullScreenToggle");
((Component)val2).gameObject.SetActive(false);
Object.Destroy((Object)(object)((Component)val2).gameObject);
RectTransform component = Object.Instantiate<GameObject>(existingTextBox, val.transform).GetComponent<RectTransform>();
((Object)component).name = "CustomTextBox";
component.anchoredPosition = new Vector2(250f, 0f);
component.offsetMax = new Vector2(377f, 28.5f);
component.offsetMin = new Vector2(123f, -28.5f);
return new SettingTextBoxWrapper(val);
}
public override SettingTextBoxWrapper Instatiate(Transform parent, TextBoxVariant settingModel)
{
GameObject val = Object.Instantiate<GameObject>(base.ManagedGameObject, parent);
val.SetActive(true);
((Object)val).name = ((IVariant)settingModel).ParentMod.ModName + "_TextBox_" + settingModel.SettingsText;
SettingTextBoxWrapper settingTextBoxWrapper = new SettingTextBoxWrapper(val);
return settingTextBoxWrapper.Instantiate(settingModel);
}
private SettingTextBoxWrapper Instantiate(TextBoxVariant settingModel)
{
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Expected O, but got Unknown
((TMP_Text)_text).SetText(settingModel.SettingsText, true);
((TMP_Text)_greyText).SetText(settingModel.GreyText, true);
_textBox.textComponent.SetText(settingModel.CurrentValue, true);
((UnityEventBase)_textBox.onValueChanged).RemoveAllListeners();
_textBox.onValueChanged = new OnChangeEvent();
((UnityEvent<string>)(object)_textBox.onValueChanged).AddListener((UnityAction<string>)settingModel.TextHasChanged);
return this;
}
}
}
namespace ModSettingsApi.Models.Enums
{
public enum SettingsVariant
{
Button,
ToggleButton,
ComboBox,
ListNavigator,
Slider,
TextInput
}
}
namespace ModSettingsApi.Manager
{
public class PanelUiManager
{
private readonly MainMenuUI _ui;
private readonly List<TabModel> _modsToRender;
private bool _initialized;
private GameObject _modView;
private SettingComboBoxWrapper _uiComboBox;
private SettingToggleButtonWrapper _uiToggleButton;
private SettingSliderWrapper _uiSlider;
private SettingTextBoxWrapper _uiTextBox;
private SettingButtonWrapper _uiButton;
private GameObject _tabSplitter;
private GameObject _tabButton;
private RectTransform _panel;
private HorizontalLayoutGroup _tabs;
private GameObject _tabButton2;
private TextMeshProUGUI _tabButton2Text;
private TextMeshProUGUI _tabButtonText;
public static PanelUiManager Instance { get; set; }
public Dictionary<TabModel, GameObject> Views { get; set; } = new Dictionary<TabModel, GameObject>();
public TabModel CurrentActive { get; set; }
public Dictionary<TabModel, List<object>> DebugComponentList { get; set; } = new Dictionary<TabModel, List<object>>();
public bool IsOpen { get; set; }
public GameObject CreateModView(VerticalLayoutGroup existingView, string name)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
Transform parent = ((Component)existingView).transform.parent;
VerticalLayoutGroup val = Object.Instantiate<VerticalLayoutGroup>(existingView, parent, true);
((Object)val).name = name;
((Component)val).transform.localScale = Vector3.one;
return ((Component)val).gameObject;
}
private void BuildView()
{
LogManager.Message("Start building modded views.");
foreach (KeyValuePair<TabModel, GameObject> view in Views)
{
TabModel key = view.Key;
GameObject value = view.Value;
List<object> list = new List<object>();
DebugComponentList.Add(key, list);
LogManager.Message("Building view for " + key.ModName);
foreach (IVariant setting in key.Settings)
{
switch (setting.Variant)
{
case SettingsVariant.Button:
{
SettingButtonWrapper item5 = _uiButton.Instatiate(value.transform, (ButtonVariant)setting);
list.Add(item5);
break;
}
case SettingsVariant.ToggleButton:
{
SettingToggleButtonWrapper item4 = _uiToggleButton.Instatiate(value.transform, (ToggleButtonVariant)setting);
list.Add(item4);
break;
}
case SettingsVariant.Slider:
{
SettingSliderWrapper item3 = _uiSlider.Instatiate(value.transform, (SliderVariant)setting);
list.Add(item3);
break;
}
case SettingsVariant.ComboBox:
{
SettingComboBoxWrapper item2 = _uiComboBox.Instatiate(value.transform, (ComboBoxVariant)setting);
list.Add(item2);
break;
}
case SettingsVariant.TextInput:
{
SettingTextBoxWrapper item = _uiTextBox.Instatiate(value.transform, (TextBoxVariant)setting);
list.Add(item);
break;
}
}
}
}
}
public PanelUiManager(MainMenuUI gameUi, List<TabModel> modsToRender)
{
Instance = this;
_ui = gameUi;
_modsToRender = modsToRender;
_panel = ((Component)_ui.settingsPanel).gameObject.Instantiate<RectTransform>("ModSettingsPanel");
_tabs = ((Component)_panel).GetComponentInChildren<HorizontalLayoutGroup>();
}
public void OpenPanel()
{
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Expected O, but got Unknown
if (!_initialized)
{
Initialize();
BuildView();
OpenApiView();
_initialized = true;
}
_ui.CloseRoomSelection();
_ui.CloseWorkshop();
_ui.CloseCredits();
_ui.HideNews();
_ui.CloseSettings();
TweenSettingsExtensions.OnComplete<TweenerCore<Vector3, Vector3, VectorOptions>>(ShortcutExtensions.DOScale(((Component)_panel).transform, 1.1f, 0.25f), (TweenCallback)delegate
{
ShortcutExtensions.DOScale(((Component)_panel).transform, 1f, 0.1f);
});
IsOpen = true;
}
public void ClosePanel()
{
if (IsOpen)
{
_ui.ShowNews();
ShortcutExtensions.DOScale(((Component)_panel).transform, 0f, 0.25f);
IsOpen = false;
}
}
private void Initialize()
{
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Expected O, but got Unknown
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Expected O, but got Unknown
//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
//IL_01b2: Expected O, but got Unknown
//IL_0225: Unknown result type (might be due to invalid IL or missing references)
//IL_022f: Expected O, but got Unknown
//IL_023e: Unknown result type (might be due to invalid IL or missing references)
//IL_0248: Expected O, but got Unknown
//IL_034e: Unknown result type (might be due to invalid IL or missing references)
//IL_0355: Expected O, but got Unknown
LogManager.Message("Instatiate Tab elements.");
Button component = ((Component)((Component)_panel).transform.Find("CloseButton")).GetComponent<Button>();
((UnityEventBase)component.onClick).RemoveAllListeners();
((UnityEvent)component.onClick).AddListener(new UnityAction(ClosePanel));
foreach (RectTransform item in (Transform)((Component)_tabs).GetComponentInChildren<RectTransform>())
{
RectTransform val = item;
LogManager.Message("Found tab children: " + ((Object)val).name);
switch (((Object)val).name)
{
case "Splitter":
if (_tabSplitter == null)
{
_tabSplitter = ((Component)val).gameObject;
((Object)_tabSplitter).name = "Modded_TabSplitter";
_tabSplitter.gameObject.SetActive(false);
}
else
{
Object.Destroy((Object)(object)((Component)val).gameObject);
}
break;
case "General":
if (!((Object)(object)_tabButton != (Object)null))
{
_tabButton = ((Component)val).gameObject;
_tabButton.transform.SetParent(((Component)_tabs).transform);
_tabButtonText = _tabButton.GetComponentInChildren<TextMeshProUGUI>();
((TMP_Text)_tabButtonText).SetText("Modded Tab", true);
Button component3 = _tabButton.GetComponent<Button>();
((UnityEventBase)component3.onClick).RemoveAllListeners();
((UnityEvent)component3.onClick).AddListener(new UnityAction(OpenApiView));
}
break;
case "Graphics":
if (!((Object)(object)_tabButton2 != (Object)null))
{
_tabButton2 = ((Component)val).gameObject;
_tabButton2.transform.SetParent(((Component)_tabs).transform);
_tabButton2Text = _tabButton2.GetComponentInChildren<TextMeshProUGUI>();
Button component2 = _tabButton2.GetComponent<Button>();
((UnityEventBase)component2.onClick).RemoveAllListeners();
component2.onClick = new ButtonClickedEvent();
((UnityEvent)component2.onClick).AddListener(new UnityAction(OpenModView));
_tabButton2.SetActive(false);
}
break;
default:
Object.Destroy((Object)(object)((Component)val).gameObject);
break;
}
}
LogManager.Message("Instatiate inner view setting options.");
SettingsTab[] componentsInChildren = ((Component)_panel).GetComponentsInChildren<SettingsTab>();
foreach (SettingsTab val2 in componentsInChildren)
{
LogManager.Message("Found View child: " + ((Object)val2).name);
switch (((Object)val2).name)
{
case "General":
{
((Object)val2).name = "ModSettingsController";
VerticalLayoutGroup componentInChildren3 = ((Component)val2).GetComponentInChildren<VerticalLayoutGroup>(true);
LogManager.Message("General found layoutGroup: " + (((Object)(object)componentInChildren3 != (Object)null) ? "Yes" : "No"));
GameObject val8 = new GameObject("TempObject");
RectTransform[] componentsInChildren4 = ((Component)componentInChildren3).GetComponentsInChildren<RectTransform>();
foreach (RectTransform val9 in componentsInChildren4)
{
if (!(((Object)val9).name == "TabView"))
{
LogManager.Message("Remove from GeneralView: " + ((Object)val9).name);
((Component)val9).gameObject.SetActive(false);
((Component)val9).transform.SetParent(val8.transform);
}
}
LogManager.Message("Creating ModdedView.");
_modView = CreateModView(componentInChildren3, "ModdedView");
TabModel tabModel = new TabModel("ModSettingsAPI", new List<IVariant>());
Views.Add(tabModel, _modView);
foreach (TabModel mod in _modsToRender)
{
GameObject val10 = CreateModView(componentInChildren3, "ModView_" + mod.ModName);
tabModel.Settings.Add(new ButtonVariant(mod.ModName, "Open", (UnityAction<ButtonVariant>)delegate
{
OpenModView(mod);
}));
Views.Add(mod, val10.gameObject);
}
Object.Destroy((Object)(object)((Component)componentInChildren3).gameObject);
break;
}
case "Graphics":
{
VerticalLayoutGroup componentInChildren2 = ((Component)val2).GetComponentInChildren<VerticalLayoutGroup>(true);
RectTransform[] componentsInChildren3 = ((Component)componentInChildren2).GetComponentsInChildren<RectTransform>();
foreach (RectTransform val5 in componentsInChildren3)
{
LogManager.Message("Found in graphic child: " + ((Object)val5).name);
if (((Object)val5).name == "Resolution")
{
if (_uiComboBox == null)
{
GameObject val6 = Object.Instantiate<GameObject>(((Component)val5).gameObject, _modView.transform);
((Object)val6).name = "Modded_ComboBox";
_uiComboBox = new SettingComboBoxWrapper(val6);
}
}
else if (((Object)val5).name == "FullScreen" && _uiToggleButton == null)
{
GameObject val7 = Object.Instantiate<GameObject>(((Component)val5).gameObject, _modView.transform);
((Object)val7).name = "Modded_Toggle";
_uiToggleButton = new SettingToggleButtonWrapper(val7);
}
}
Object.Destroy((Object)(object)((Component)componentInChildren2).gameObject);
break;
}
case "Audio":
{
VerticalLayoutGroup componentInChildren = ((Component)val2).GetComponentInChildren<VerticalLayoutGroup>(true);
LogManager.Message("Graphics found layoutGroup: " + (((Object)(object)componentInChildren != (Object)null) ? "Yes" : "No"));
RectTransform[] componentsInChildren2 = ((Component)componentInChildren).GetComponentsInChildren<RectTransform>();
foreach (RectTransform val3 in componentsInChildren2)
{
if (((Object)val3).name == "Music")
{
GameObject val4 = Object.Instantiate<GameObject>(((Component)val3).gameObject, _modView.transform);
((Object)val4).name = "Modded_Slider";
_uiSlider = new SettingSliderWrapper(val4);
break;
}
}
Object.Destroy((Object)(object)componentInChildren);
break;
}
default:
Object.Destroy((Object)(object)((Component)val2).gameObject);
break;
}
}
Transform val11 = ((Transform)_ui.workshopPanel).Find("FurnitureUpload/WorkshopTitle");
_uiTextBox = SettingTextBoxWrapper.Create(_uiToggleButton, ((Component)val11).gameObject);
Transform val12 = ((Transform)_ui.workshopPanel).Find("FurnitureUpload/UploadToWorkshop");
_uiButton = SettingButtonWrapper.Create(_uiToggleButton, ((Component)val12).gameObject);
_uiComboBox.ManagedGameObject.SetActive(false);
_uiToggleButton.ManagedGameObject.SetActive(false);
_uiSlider.ManagedGameObject.SetActive(false);
_uiTextBox.ManagedGameObject.SetActive(false);
_uiButton.ManagedGameObject.SetActive(false);
}
private void OpenModView(TabModel openMod)
{
LogManager.Message("Open mod " + openMod.ModName);
CurrentActive = openMod;
((TMP_Text)_tabButton2Text).SetText(openMod.ModName ?? "", true);
OpenModView();
}
private void OpenApiView()
{
//IL_0060: 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)
LogManager.Message("Open API View.");
foreach (KeyValuePair<TabModel, GameObject> view in Views)
{
view.Value.SetActive(false);
}
((Graphic)_tabButton2Text).color = new Color(0.7f, 0.7f, 0.7f);
((Graphic)_tabButtonText).color = new Color(1f, 1f, 1f);
_modView.SetActive(true);
}
private void OpenModView()
{
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
foreach (KeyValuePair<TabModel, GameObject> view in Views)
{
if (view.Key == CurrentActive)
{
view.Value.SetActive(true);
}
else
{
view.Value.SetActive(false);
}
}
_tabButton2.SetActive(true);
_tabSplitter.SetActive(true);
((Graphic)_tabButtonText).color = new Color(0.7f, 0.7f, 0.7f);
((Graphic)_tabButton2Text).color = new Color(1f, 1f, 1f);
}
}
internal class SettingsManager
{
private static SettingsManager _instance;
private static PanelUiManager _panelManager;
private static bool _initialized;
private readonly MainMenuUI _ui;
private bool _modSettingsOpened;
private Button _vanillaSettingsButton;
private TextMeshProUGUI _vanillaSettingsText;
private Button _moddedButton;
private TextMeshProUGUI _moddedText;
private RectTransform _panel;
private HorizontalLayoutGroup _tabs;
private SettingsTab _view;
public static SettingsManager Instance
{
get
{
if (_instance == null)
{
throw new Exception("Please call Init(MainMenuUI Object)");
}
return _instance;
}
private set
{
_instance = value;
}
}
public static List<TabModel> Tabs { get; set; } = new List<TabModel>();
protected SettingsManager(MainMenuUI ui)
{
_ui = ui;
}
public static void Init(MainMenuUI ui)
{
if (_initialized)
{
throw new Exception("SettingsManager is already initialized!");
}
Instance = new SettingsManager(ui);
Instance.Init();
}
private void Init()
{
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Expected O, but got Unknown
if (_initialized)
{
throw new Exception("SettingsManager is already initialized!");
}
_vanillaSettingsButton = _ui.openSettingsButton;
_vanillaSettingsText = ((IEnumerable<TextMeshProUGUI>)((Component)_ui).gameObject.GetComponentsInChildren<TextMeshProUGUI>()).FirstOrDefault((Func<TextMeshProUGUI, bool>)((TextMeshProUGUI x) => ((Object)((Component)x).gameObject).name == "SettingsText"));
BuildModSettingsButton();
((UnityEvent)_moddedButton.onClick).AddListener(new UnityAction(ToggleModSettings));
}
public void Testing()
{
Transform[] componentsInChildren = ((Component)_panel).GetComponentsInChildren<Transform>();
Transform[] array = componentsInChildren;
foreach (Transform val in array)
{
LogManager.Debug("Found in Panel: " + ((Object)val).name);
}
HorizontalLayoutGroup component = ((Component)_panel).GetComponent<HorizontalLayoutGroup>();
}
private void ToggleModSettings()
{
if (_panelManager == null)
{
_panelManager = new PanelUiManager(_ui, Tabs);
}
if (!_panelManager.IsOpen)
{
_panelManager.OpenPanel();
}
else
{
_panelManager.ClosePanel();
}
}
private void BuildModSettingsButton()
{
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: 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_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_018a: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0209: Unknown result type (might be due to invalid IL or missing references)
//IL_0220: Unknown result type (might be due to invalid IL or missing references)
//IL_022b: Unknown result type (might be due to invalid IL or missing references)
//IL_0235: Unknown result type (might be due to invalid IL or missing references)
//IL_0242: Unknown result type (might be due to invalid IL or missing references)
//IL_0259: Unknown result type (might be due to invalid IL or missing references)
//IL_0264: Unknown result type (might be due to invalid IL or missing references)
//IL_026e: Unknown result type (might be due to invalid IL or missing references)
_moddedButton = ((Component)_ui.openSettingsButton).gameObject.Instantiate<Button>("ModSettingsOpenButton");
_moddedText = ((Component)_vanillaSettingsText).gameObject.Instantiate<TextMeshProUGUI>("ModSettingsText");
LogManager.Message($"Changing ModSettings Text Fontsize from {((TMP_Text)_moddedText).fontSize} to 44");
((TMP_Text)_moddedText).fontSize = 44f;
((TMP_Text)_moddedText).SetText("ModSettings", true);
RectTransform component = ((Component)_vanillaSettingsButton).GetComponent<RectTransform>();
RectTransform component2 = ((Component)_vanillaSettingsText).GetComponent<RectTransform>();
RectTransform component3 = ((Component)_moddedButton).GetComponent<RectTransform>();
RectTransform component4 = ((Component)_moddedText).GetComponent<RectTransform>();
RectTransform component5 = ((Component)_ui.openRoomSelectionButton).GetComponent<RectTransform>();
float num = ((Transform)component5).position.y - component5.sizeDelta.y - ((Transform)component).position.y;
float num2 = num / 2f;
float x = component.sizeDelta.x;
float num3 = x / 2f - num2;
LogManager.Message($"pixels between buttons: {num}, button length is: {x}, singleLength: {num3}");
component.sizeDelta = new Vector2(num3, component.sizeDelta.y);
component2.sizeDelta = new Vector2(num3, component2.sizeDelta.y);
component3.sizeDelta = new Vector2(num3, component3.sizeDelta.y);
component4.sizeDelta = new Vector2(num3, component4.sizeDelta.y);
((Transform)component).position = new Vector3(((Transform)component).position.x - (num3 / 2f + num2), ((Transform)component).position.y, ((Transform)component).position.z);
((Transform)component2).position = new Vector3(((Transform)component2).position.x - (num3 / 2f + num2), ((Transform)component2).position.y, ((Transform)component2).position.z);
((Transform)component3).position = new Vector3(((Transform)component3).position.x + (num3 / 2f + num2), ((Transform)component3).position.y, ((Transform)component3).position.z);
((Transform)component4).position = new Vector3(((Transform)component4).position.x + (num3 / 2f + num2), ((Transform)component4).position.y, ((Transform)component4).position.z);
}
public static void AddModTab(TabModel mod)
{
Tabs.Add(mod);
Tabs = Tabs.OrderBy((TabModel x) => x.ModName).ToList();
LogManager.Debug("New tab got added to the modded settings.");
}
}
public static class TestDataManager
{
public static void Init()
{
List<IVariant> list = new List<IVariant>();
list.Add(new ToggleButtonVariant("TestToggle", ToggleChangedTest, defaultValue: true));
ComboBoxVariant item = new ComboBoxVariant("TestCombo", ComboValueChanged, new List<IComboBoxData>
{
new ComboBoxOptionData("Option_1"),
new ComboBoxOptionData("Option_2"),
new ComboBoxOptionData("Option_3"),
new ComboBoxOptionData("Option_4")
});
list.Add(item);
list.Add(new ButtonVariant("ButtonOption", "BtnText", (UnityAction<ButtonVariant>)ButtonPressed));
list.Add(new TextBoxVariant("TextBoxOption", "GreyText", TextBoxHasChanged, "TextBoxDefaultValue"));
TabModel modSettings = new TabModel("TestData Mod", list);
ModdedSettingsApi.AddMod(modSettings);
}
public static void ButtonPressed(ButtonVariant sender)
{
LogManager.Message("TestDataManager: Button pressed, sender: " + sender.SettingsText);
}
private static void ToggleChangedTest(bool newValue)
{
LogManager.Message($"TestDataManager: Toggle changed, new Value: {newValue}");
}
private static void ComboValueChanged(IComboBoxData data)
{
LogManager.Message("TestDataManager: Combo value changed, new Value: " + data.Text);
}
private static void TextBoxHasChanged(string newValue)
{
LogManager.Message("TestDataManager: TextBox value changed, new Value: " + newValue);
}
}
public static class DebugModManager
{
public enum TestEnum
{
en1,
en2,
en3
}
public static void Init()
{
List<IVariant> list = new List<IVariant>();
list.Add(new ToggleButtonVariant("DebugToggle", ToggleChangedDebug, defaultValue: true));
ComboBoxVariant item = new ComboBoxVariant("DebugCombo", ComboValueChanged, new List<IComboBoxData>
{
new ComboBoxOptionData("Debug_1"),
new ComboBoxOptionData("Debug_2"),
new ComboBoxOptionData("Debug_3"),
new ComboBoxOptionData("Debug_4")
});
list.Add(item);
list.Add(new ButtonVariant("ButtonDebugOption", "BtnText", (UnityAction<ButtonVariant>)ButtonPressed));
list.Add(new TextBoxVariant("TextBoxDebugOption", "GreyText", TextBoxHasChanged, "TextBoxDefaultValue"));
TabModel modSettings = new TabModel("DebugData Mod", list);
ModdedSettingsApi.AddMod(modSettings);
}
public static void ButtonPressed(ButtonVariant sender)
{
LogManager.Message("DebugDataManager: Button pressed, sender: " + sender.SettingsText);
}
private static void ToggleChangedDebug(bool newValue)
{
LogManager.Message($"DebugDataManager: Toggle changed, new Value: {newValue}");
}
private static void ComboValueChanged(IComboBoxData data)
{
LogManager.Message("DebugDataManager: Combo value changed, new Value: " + data.Text);
}
private static void TextBoxHasChanged(string newValue)
{
LogManager.Message("DebugDataManager: TextBox value changed, new Value: " + newValue);
}
}
}
namespace ModSettingsApi.Api
{
public static class ModdedSettingsApi
{
public static void AddMod(TabModel modSettings)
{
SettingsManager.AddModTab(modSettings);
}
}
}