using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.Json;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Utils.Collections;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using ProjectM;
using ProjectM.Network;
using ProjectM.UI;
using StunShared.UI;
using Stunlock.Network;
using Stunlock.Network.Steam;
using TMPro;
using Unity.Collections;
using Unity.Entities;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("KinCreator")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+711254f94702daf8506ba4b6561c6f1451fe5a5d")]
[assembly: AssemblyProduct("KinCreator")]
[assembly: AssemblyTitle("KinCreator")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace KinCreator
{
[BepInPlugin("Kindred.KinCreator", "KinCreator", "1.0.0")]
internal class Plugin : BasePlugin
{
private Harmony _harmony;
private static MonoBehaviour _monoBehaviour;
public static readonly string DirectoryPath = Path.Combine(Paths.ConfigPath, "KinCreator");
public static ConfigEntry<string> _serverAddress;
public static ConfigEntry<string> _password;
public static ConfigEntry<bool> _autoReconnect;
public static ConfigEntry<int> _retryInterval;
internal static Plugin Instance { get; set; }
public static ManualLogSource LogInstance => ((BasePlugin)Instance).Log;
public static PresetManager Presets { get; set; }
public override void Load()
{
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Expected O, but got Unknown
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
Instance = this;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val;
if (Application.productName == "VRisingServer")
{
ManualLogSource logInstance = LogInstance;
val = new BepInExInfoLogInterpolatedStringHandler(22, 3, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("KinCreator");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.0.0");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] is a client mod! (");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Application.productName);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")");
}
logInstance.LogInfo(val);
return;
}
ClassInjector.RegisterTypeInIl2Cpp<CoroutineHost>();
_harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
InitConfig();
Presets = new PresetManager();
ManualLogSource logInstance2 = LogInstance;
val = new BepInExInfoLogInterpolatedStringHandler(20, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("KinCreator");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.0.0");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] loaded on client!");
}
logInstance2.LogInfo(val);
}
public override bool Unload()
{
((BasePlugin)this).Config.Clear();
_harmony.UnpatchSelf();
return true;
}
private static void InitConfig()
{
if (!Directory.Exists(DirectoryPath))
{
Directory.CreateDirectory(DirectoryPath);
}
_autoReconnect = ((BasePlugin)Instance).Config.Bind<bool>("AutoReconnect", "Enabled", true, "Enables automatic reconnections when attempting to join full servers.");
_retryInterval = ((BasePlugin)Instance).Config.Bind<int>("AutoReconnect", "RetryInterval", 15, "Time in seconds between reconnection attempts.");
_serverAddress = ((BasePlugin)Instance).Config.Bind<string>("AutoReconnect", "ServerAddress", "", "Server address to use for auto-reconnect (stored automatically on connect).");
_password = ((BasePlugin)Instance).Config.Bind<string>("AutoReconnect", "Password", "", "Password to use when auto-reconnecting (blank for none).");
}
public static Coroutine StartCoroutine(IEnumerator routine)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
if ((Object)(object)_monoBehaviour == (Object)null)
{
GameObject val = new GameObject("KinCreator");
_monoBehaviour = (MonoBehaviour)(object)val.AddComponent<CoroutineHost>();
Object.DontDestroyOnLoad((Object)val);
}
return _monoBehaviour.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(routine));
}
public static void Delayed(Action action, float delay = 0.25f)
{
RunDelayed(delay, action).Run();
}
private static IEnumerator RunDelayed(float delay, Action action)
{
yield return (object)new WaitForSeconds(delay);
action?.Invoke();
}
}
internal static class CoroutineExtensions
{
public static void Run(this IEnumerator routine, float delay = 0f)
{
if (delay > 0f)
{
Plugin.StartCoroutine(Delay(routine, delay));
}
else
{
Plugin.StartCoroutine(routine);
}
}
private static IEnumerator Delay(IEnumerator routine, float delay)
{
yield return (object)new WaitForSeconds(delay);
routine.Run();
}
}
internal class CoroutineHost : MonoBehaviour
{
public CoroutineHost(IntPtr ptr)
: base(ptr)
{
}
}
public class CharacterPreset
{
public string Name { get; set; } = "";
public int BodyTypeIndex { get; set; }
public int SkinToneColorIndex { get; set; }
public int FaceIndex { get; set; }
public int EyeColorIndex { get; set; }
public int HairIndex { get; set; }
public int HairColorIndex { get; set; }
public int FeaturesIndex { get; set; }
public int AccessoriesIndex { get; set; }
}
internal class PresetManager
{
private static readonly string _filePath = Path.Combine(Plugin.DirectoryPath, "presets.json");
private static readonly JsonSerializerOptions _jsonOptions = new JsonSerializerOptions
{
WriteIndented = true
};
public Dictionary<string, CharacterPreset> SavedPresets { get; private set; } = new Dictionary<string, CharacterPreset>();
public List<string> PresetNames => SavedPresets.Keys.ToList();
public bool HasPresets => SavedPresets.Count > 0;
public PresetManager()
{
Load();
}
public CharacterPreset GetPreset(string name)
{
if (!SavedPresets.TryGetValue(name, out var value))
{
return null;
}
return value;
}
public string GetNextPresetName()
{
int num = 1;
string text;
while (true)
{
text = $"Preset {num}";
if (!SavedPresets.ContainsKey(text))
{
break;
}
num++;
}
return text;
}
public void SavePreset(string name, CharacterPreset preset)
{
SavedPresets[name] = preset;
Save();
}
public void DeletePreset(string name)
{
if (SavedPresets.Remove(name))
{
Save();
}
}
public bool RenamePreset(string oldName, string newName)
{
if (!SavedPresets.TryGetValue(oldName, out var value))
{
return false;
}
if (SavedPresets.ContainsKey(newName))
{
return false;
}
SavedPresets.Remove(oldName);
value.Name = newName;
SavedPresets[newName] = value;
Save();
return true;
}
private void Save()
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Expected O, but got Unknown
try
{
string contents = JsonSerializer.Serialize(SavedPresets, _jsonOptions);
File.WriteAllText(_filePath, contents);
}
catch (Exception ex)
{
ManualLogSource logInstance = Plugin.LogInstance;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(40, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[PresetManager] Failed to save presets: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
}
logInstance.LogWarning(val);
}
}
private void Load()
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Expected O, but got Unknown
try
{
if (File.Exists(_filePath))
{
string json = File.ReadAllText(_filePath);
SavedPresets = JsonSerializer.Deserialize<Dictionary<string, CharacterPreset>>(json, _jsonOptions) ?? new Dictionary<string, CharacterPreset>();
}
}
catch (Exception ex)
{
ManualLogSource logInstance = Plugin.LogInstance;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(40, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[PresetManager] Failed to load presets: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
}
logInstance.LogWarning(val);
SavedPresets = new Dictionary<string, CharacterPreset>();
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "Kindred.KinCreator";
public const string PLUGIN_NAME = "KinCreator";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace KinCreator.Patches
{
[HarmonyPatch]
internal static class AutoReconnectPatch
{
private const ushort DEFAULT_PORT = 9876;
private static string _serverSession = string.Empty;
private static string _serverPassword = string.Empty;
public static bool _allowRetry;
private static DefaultWorldConsoleCommandSystem DefaultWorldConsoleCommandSystem => World.DefaultGameObjectInjectionWorld.GetOrCreateSystemManaged<DefaultWorldConsoleCommandSystem>();
[HarmonyPatch(typeof(MainMenuNewView), "Update")]
[HarmonyPrefix]
private static void UpdatePrefix()
{
_allowRetry = false;
}
[HarmonyPatch(typeof(ClientBootstrapSystem), "OnStatusChangedEvent")]
[HarmonyPostfix]
private static void OnStatusChangedEventPostfix(ClientBootstrapSystem __instance, StatusChangedEvent statusChangedEvent)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: 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)
ManualLogSource logInstance = Plugin.LogInstance;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(30, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ClientBootstrapSystem] -> ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<ClientConnectState>(statusChangedEvent.Status);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ? ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<ConnectionStatusChangeReason>(__instance.DisconnectChangeReason);
}
logInstance.LogWarning(val);
if (Plugin._autoReconnect.Value && ((object)__instance.DisconnectChangeReason/*cast due to .constrained prefix*/).Equals((object)(ConnectionStatusChangeReason)11))
{
ConnectAddress connectAddress = GetConnectAddress(_serverSession);
_allowRetry = true;
Plugin.Delayed(delegate
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
DoReconnect(connectAddress);
}, Plugin._retryInterval.Value);
}
}
[HarmonyPatch(typeof(ClientSteamTransportLayer), "Connect")]
[HarmonyPostfix]
private static void ClientConnectPostfix(ConnectAddress connectAddress)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: 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_001f: Unknown result type (might be due to invalid IL or missing references)
ManualLogSource logInstance = Plugin.LogInstance;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(31, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ClientSteamTransportLayer] -> ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<ConnectAddress>(connectAddress);
}
logInstance.LogWarning(val);
DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(1, 2);
FixedString32Bytes address = connectAddress.Address;
defaultInterpolatedStringHandler.AppendFormatted(((FixedString32Bytes)(ref address)).Value);
defaultInterpolatedStringHandler.AppendLiteral(":");
defaultInterpolatedStringHandler.AppendFormatted(connectAddress.Port);
_serverSession = defaultInterpolatedStringHandler.ToStringAndClear();
}
private static ConnectAddress GetConnectAddress(string address)
{
//IL_0039: 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)
string[] array = address.Split(':');
string text = array[0];
ushort result;
ushort num = (ushort)((array.Length > 1 && ushort.TryParse(array[1], out result)) ? result : 0);
if (num <= 0)
{
return ConnectAddressUtility.CreateIPv4(text, (ushort)9876, false);
}
return ConnectAddressUtility.CreateIPv4(text, num, false);
}
private static void DoReconnect(ConnectAddress connectAddress)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
if (_allowRetry)
{
Plugin.LogInstance.LogWarning((object)"[AutoReconnect] Retrying...");
DefaultWorldConsoleCommandSystem.DoConnect(connectAddress, _serverPassword);
}
}
}
[HarmonyPatch]
internal static class CharacterCreationMenuPatch
{
private static LocalizedText _saveButtonText;
private static GameObject _presetButtonObject;
private static GameObject _editDeleteContainer;
private static GameObject _editButtonObject;
private static GameObject _deleteButtonObject;
private static CharacterCreationMenuMapper _activeMenuMapper;
private static string _selectedPresetName;
private static TMP_Dropdown _nativeDropdown;
private static string _editingPreset;
private static bool _isEditMode;
private static bool _suppressDropdownCallback;
private static bool _labelLocTextKilled;
private static GenericTextInputPopup _renamePopup;
private static GameObject _renameButtonObject;
private static GameObject _completeButtonHidden;
private static readonly string[] InjectedButtonNames = new string[3] { "SavePreset_StandardButton", "PresetDropdown", "EditDeleteContainer" };
private const float COMPACT_FONT_SIZE = 18f;
private const float COMPACT_BUTTON_WIDTH = 110f;
private const float DROPDOWN_FONT_SIZE = 20f;
private const string BUTTON_PARENT = "HUDCanvas(Clone)/HUDMenuParent/CharacterCreationMenu(Clone)/Root/NewContainer/CharacterCreationScreen(Clone)/Content/LeftMenu/Container_BottomKBAMButtonBar";
private static PresetManager Presets => Plugin.Presets;
[HarmonyPatch(typeof(CharacterCreationMenuMapper), "OnStartRunning")]
[HarmonyPostfix]
public static void OnStartRunningPostfix(CharacterCreationMenuMapper __instance)
{
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Expected O, but got Unknown
try
{
_activeMenuMapper = __instance;
_editingPreset = null;
_isEditMode = false;
_selectedPresetName = null;
_nativeDropdown = null;
_labelLocTextKilled = false;
BuildPresetButtons(__instance);
Plugin.StartCoroutine(EnsurePresetButtons(__instance));
}
catch (Exception ex)
{
ManualLogSource logInstance = Plugin.LogInstance;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(31, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[CharacterCreationMenuMapper]: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
}
logInstance.LogWarning(val);
}
}
private static IEnumerator EnsurePresetButtons(CharacterCreationMenuMapper menuMapper)
{
for (int frame = 0; frame < 150; frame++)
{
yield return null;
if (_activeMenuMapper != menuMapper)
{
break;
}
GameObject val = GameObject.Find("HUDCanvas(Clone)/HUDMenuParent/CharacterCreationMenu(Clone)/Root/NewContainer/CharacterCreationScreen(Clone)/Content/LeftMenu/Container_BottomKBAMButtonBar");
if (!((Object)(object)val == (Object)null))
{
if ((Object)(object)val.transform.Find("SavePreset_StandardButton") == (Object)null)
{
BuildPresetButtons(menuMapper);
}
RectTransform component = val.GetComponent<RectTransform>();
if ((Object)(object)component != (Object)null)
{
LayoutRebuilder.ForceRebuildLayoutImmediate(component);
}
}
}
}
private static void BuildPresetButtons(CharacterCreationMenuMapper menuMapper)
{
//IL_0385: Unknown result type (might be due to invalid IL or missing references)
//IL_038c: Expected O, but got Unknown
//IL_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: Expected O, but got Unknown
//IL_021e: Unknown result type (might be due to invalid IL or missing references)
//IL_0223: Unknown result type (might be due to invalid IL or missing references)
//IL_022a: Unknown result type (might be due to invalid IL or missing references)
//IL_0231: Unknown result type (might be due to invalid IL or missing references)
//IL_0238: Unknown result type (might be due to invalid IL or missing references)
//IL_0244: Expected O, but got Unknown
try
{
GameObject val = GameObject.Find("HUDCanvas(Clone)/HUDMenuParent/CharacterCreationMenu(Clone)/Root/NewContainer/CharacterCreationScreen(Clone)/Content/LeftMenu/Container_BottomKBAMButtonBar");
if ((Object)(object)val == (Object)null)
{
Plugin.LogInstance.LogWarning((object)"[BuildPresetButtons]: button bar not found");
return;
}
for (int num = val.transform.childCount - 1; num >= 0; num--)
{
Transform child = val.transform.GetChild(num);
if (Array.IndexOf(InjectedButtonNames, ((Object)child).name) >= 0)
{
Object.DestroyImmediate((Object)(object)((Component)child).gameObject);
}
}
GameObject val2 = null;
for (int i = 0; i < val.transform.childCount; i++)
{
Transform child2 = val.transform.GetChild(i);
if (((Object)child2).name.Contains("Randomize"))
{
val2 = ((Component)child2).gameObject;
break;
}
}
if ((Object)(object)val2 == (Object)null)
{
val2 = ((Component)val.transform.GetChild(0)).gameObject;
}
GameObject val3 = UIHelper.InstantiateGameObjectUnderAnchor(val2, val.transform);
val3.transform.SetSiblingIndex(val2.transform.GetSiblingIndex() + 1);
((Object)val3).name = "SavePreset_StandardButton";
_saveButtonText = val3.GetComponentInChildren<LocalizedText>();
_saveButtonText.ForceSet("Save New Preset");
SimpleStunButton component = val3.GetComponent<SimpleStunButton>();
((UnityEventBase)component.onClick).RemoveAllListeners();
((UnityEvent)component.onClick).AddListener(UnityAction.op_Implicit((Action)delegate
{
SavePreset(menuMapper);
}));
val3.SetActive(true);
BuildNativeDropdown(val, val3);
_editDeleteContainer = new GameObject("EditDeleteContainer");
_editDeleteContainer.transform.SetParent(val.transform, false);
_editDeleteContainer.transform.SetSiblingIndex(_presetButtonObject.transform.GetSiblingIndex() + 1);
LayoutElement obj = _editDeleteContainer.AddComponent<LayoutElement>();
obj.preferredHeight = 35f;
obj.minHeight = 35f;
obj.flexibleHeight = 0f;
_editDeleteContainer.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
HorizontalLayoutGroup obj2 = _editDeleteContainer.AddComponent<HorizontalLayoutGroup>();
((LayoutGroup)obj2).childAlignment = (TextAnchor)4;
((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandWidth = false;
((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandHeight = true;
((HorizontalOrVerticalLayoutGroup)obj2).childControlHeight = true;
((HorizontalOrVerticalLayoutGroup)obj2).childControlWidth = true;
((HorizontalOrVerticalLayoutGroup)obj2).spacing = 30f;
((LayoutGroup)obj2).padding = new RectOffset
{
left = 0,
right = 0,
top = 0,
bottom = 0
};
TextMeshProUGUI componentInChildren = val3.GetComponentInChildren<TextMeshProUGUI>();
_editButtonObject = UIHelper.InstantiateGameObjectUnderAnchor(val2, _editDeleteContainer.transform);
((Object)_editButtonObject).name = "EditPreset_StandardButton";
ConfigureCompactButton(_editButtonObject, "Edit", componentInChildren);
SimpleStunButton component2 = _editButtonObject.GetComponent<SimpleStunButton>();
((UnityEventBase)component2.onClick).RemoveAllListeners();
((UnityEvent)component2.onClick).AddListener(UnityAction.op_Implicit((Action)OnEditClicked));
_editButtonObject.SetActive(true);
_deleteButtonObject = UIHelper.InstantiateGameObjectUnderAnchor(val2, _editDeleteContainer.transform);
((Object)_deleteButtonObject).name = "DeletePreset_StandardButton";
ConfigureCompactButton(_deleteButtonObject, "Del", componentInChildren);
SimpleStunButton component3 = _deleteButtonObject.GetComponent<SimpleStunButton>();
((UnityEventBase)component3.onClick).RemoveAllListeners();
((UnityEvent)component3.onClick).AddListener(UnityAction.op_Implicit((Action)OnDeleteClicked));
_deleteButtonObject.SetActive(true);
_editDeleteContainer.SetActive(Presets.HasPresets);
RectTransform component4 = val.GetComponent<RectTransform>();
if ((Object)(object)component4 != (Object)null)
{
LayoutRebuilder.ForceRebuildLayoutImmediate(component4);
}
}
catch (Exception ex)
{
ManualLogSource logInstance = Plugin.LogInstance;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(22, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[BuildPresetButtons]: ");
((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(ex.Message);
}
logInstance.LogWarning(val4);
}
}
private static void LockCaptionFont(TextMeshProUGUI tmp)
{
((TMP_Text)tmp).enableAutoSizing = false;
((TMP_Text)tmp).fontSize = 20f;
((TMP_Text)tmp).fontSizeMin = 20f;
((TMP_Text)tmp).fontSizeMax = 20f;
}
private static void ConfigureCompactButton(GameObject btnObj, string label, TextMeshProUGUI reference)
{
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
LocalizedText componentInChildren = btnObj.GetComponentInChildren<LocalizedText>();
if (componentInChildren != null)
{
componentInChildren.ForceSet(label);
}
foreach (TextAccessibilityScaler componentsInChild in btnObj.GetComponentsInChildren<TextAccessibilityScaler>(true))
{
Object.DestroyImmediate((Object)(object)componentsInChild);
}
TextMeshProUGUI componentInChildren2 = btnObj.GetComponentInChildren<TextMeshProUGUI>();
if ((Object)(object)componentInChildren2 != (Object)null)
{
if ((Object)(object)reference != (Object)null)
{
((TMP_Text)componentInChildren2).font = ((TMP_Text)reference).font;
((TMP_Text)componentInChildren2).fontStyle = ((TMP_Text)reference).fontStyle;
((Graphic)componentInChildren2).color = ((Graphic)reference).color;
}
((TMP_Text)componentInChildren2).enableAutoSizing = false;
((TMP_Text)componentInChildren2).fontSize = 18f;
((TMP_Text)componentInChildren2).alignment = (TextAlignmentOptions)514;
((TMP_Text)componentInChildren2).enableWordWrapping = false;
((TMP_Text)componentInChildren2).overflowMode = (TextOverflowModes)0;
}
ContentSizeFitter component = btnObj.GetComponent<ContentSizeFitter>();
if ((Object)(object)component != (Object)null)
{
Object.DestroyImmediate((Object)(object)component);
}
LayoutElement val = btnObj.GetComponent<LayoutElement>();
if ((Object)(object)val == (Object)null)
{
val = btnObj.AddComponent<LayoutElement>();
}
val.preferredWidth = 110f;
val.minWidth = 110f;
val.preferredHeight = 35f;
val.minHeight = 35f;
val.flexibleWidth = 0f;
val.flexibleHeight = 0f;
RectTransform component2 = btnObj.GetComponent<RectTransform>();
if ((Object)(object)component2 != (Object)null)
{
component2.sizeDelta = new Vector2(110f, 35f);
}
StretchChildren(btnObj.transform);
}
private static void StretchChildren(Transform parent, int depth = 0)
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
for (int i = 0; i < parent.childCount; i++)
{
Transform child = parent.GetChild(i);
RectTransform component = ((Component)child).GetComponent<RectTransform>();
if ((Object)(object)component != (Object)null)
{
component.anchorMin = Vector2.zero;
component.anchorMax = Vector2.one;
component.offsetMin = Vector2.zero;
component.offsetMax = Vector2.zero;
}
if (depth < 1)
{
StretchChildren(child, depth + 1);
}
}
}
private static void BuildNativeDropdown(GameObject buttonParent, GameObject saveButtonObject)
{
//IL_027e: Unknown result type (might be due to invalid IL or missing references)
//IL_028c: 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_02de: Unknown result type (might be due to invalid IL or missing references)
//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
//IL_03eb: Unknown result type (might be due to invalid IL or missing references)
//IL_038a: Unknown result type (might be due to invalid IL or missing references)
//IL_057c: Unknown result type (might be due to invalid IL or missing references)
//IL_0416: Unknown result type (might be due to invalid IL or missing references)
//IL_04bb: Unknown result type (might be due to invalid IL or missing references)
//IL_0506: Unknown result type (might be due to invalid IL or missing references)
//IL_053d: Unknown result type (might be due to invalid IL or missing references)
GameObject val = null;
foreach (TMP_Dropdown item in Resources.FindObjectsOfTypeAll<TMP_Dropdown>())
{
if ((Object)(object)item != (Object)null && (Object)(object)((Component)item).gameObject != (Object)null && ((Object)((Component)item).gameObject).name == "FacialhairDropdown")
{
val = ((Component)item).gameObject;
break;
}
}
if ((Object)(object)val == (Object)null)
{
Plugin.LogInstance.LogWarning((object)"[BuildNativeDropdown]: FacialhairDropdown not found");
return;
}
_presetButtonObject = UIHelper.InstantiateGameObjectUnderAnchor(val, buttonParent.transform);
_presetButtonObject.transform.SetSiblingIndex(saveButtonObject.transform.GetSiblingIndex() + 1);
((Object)_presetButtonObject).name = "PresetDropdown";
_nativeDropdown = _presetButtonObject.GetComponent<TMP_Dropdown>();
if ((Object)(object)_nativeDropdown == (Object)null)
{
Plugin.LogInstance.LogWarning((object)"[BuildNativeDropdown]: Cloned object missing TMP_Dropdown component");
Object.Destroy((Object)(object)_presetButtonObject);
_presetButtonObject = null;
return;
}
((UnityEventBase)_nativeDropdown.onValueChanged).RemoveAllListeners();
((UnityEvent<int>)(object)_nativeDropdown.onValueChanged).AddListener(UnityAction<int>.op_Implicit((Action<int>)OnNativeDropdownChanged));
foreach (TextAccessibilityScaler componentsInChild in _presetButtonObject.GetComponentsInChildren<TextAccessibilityScaler>(true))
{
Object.DestroyImmediate((Object)(object)componentsInChild);
}
foreach (LocalizedText componentsInChild2 in _presetButtonObject.GetComponentsInChildren<LocalizedText>(true))
{
Object.DestroyImmediate((Object)(object)componentsInChild2);
}
_labelLocTextKilled = true;
LayoutElement component = saveButtonObject.GetComponent<LayoutElement>();
LayoutElement val2 = _presetButtonObject.GetComponent<LayoutElement>();
if ((Object)(object)val2 == (Object)null)
{
val2 = _presetButtonObject.AddComponent<LayoutElement>();
}
if ((Object)(object)component != (Object)null)
{
val2.preferredWidth = component.preferredWidth;
val2.preferredHeight = component.preferredHeight;
val2.minWidth = component.minWidth;
val2.minHeight = component.minHeight;
val2.flexibleWidth = component.flexibleWidth;
val2.flexibleHeight = component.flexibleHeight;
}
val2.flexibleHeight = 0f;
ContentSizeFitter component2 = _presetButtonObject.GetComponent<ContentSizeFitter>();
if ((Object)(object)component2 != (Object)null)
{
component2.horizontalFit = (FitMode)0;
component2.verticalFit = (FitMode)0;
}
RectTransform component3 = saveButtonObject.GetComponent<RectTransform>();
RectTransform component4 = _presetButtonObject.GetComponent<RectTransform>();
if ((Object)(object)component3 != (Object)null && (Object)(object)component4 != (Object)null)
{
component4.sizeDelta = component3.sizeDelta;
component4.anchorMin = component3.anchorMin;
component4.anchorMax = component3.anchorMax;
}
Image component5 = saveButtonObject.GetComponent<Image>();
Image component6 = _presetButtonObject.GetComponent<Image>();
if ((Object)(object)component6 != (Object)null && (Object)(object)component5 != (Object)null)
{
component6.sprite = component5.sprite;
component6.type = component5.type;
((Graphic)component6).color = ((Graphic)component5).color;
((Graphic)component6).material = ((Graphic)component5).material;
}
Selectable component7 = _presetButtonObject.GetComponent<Selectable>();
if ((Object)(object)component7 != (Object)null)
{
component7.transition = (Transition)3;
}
TextMeshProUGUI componentInChildren = saveButtonObject.GetComponentInChildren<TextMeshProUGUI>();
Transform val3 = _presetButtonObject.transform.Find("Label");
if ((Object)(object)val3 != (Object)null)
{
TextMeshProUGUI component8 = ((Component)val3).GetComponent<TextMeshProUGUI>();
if ((Object)(object)component8 != (Object)null)
{
if ((Object)(object)componentInChildren != (Object)null)
{
((TMP_Text)component8).font = ((TMP_Text)componentInChildren).font;
}
LockCaptionFont(component8);
((TMP_Text)component8).alignment = (TextAlignmentOptions)514;
((Graphic)component8).color = Color.white;
}
_nativeDropdown.captionText = null;
}
Transform val4 = _presetButtonObject.transform.Find("Template");
if ((Object)(object)val4 != (Object)null)
{
Image component9 = ((Component)val4).GetComponent<Image>();
if ((Object)(object)component9 != (Object)null)
{
((Graphic)component9).color = new Color(0.1f, 0.1f, 0.15f, 0.97f);
}
Il2CppArrayBase<TextMeshProUGUI> componentsInChildren = ((Component)val4).GetComponentsInChildren<TextMeshProUGUI>(true);
if (componentsInChildren != null)
{
foreach (TextMeshProUGUI item2 in componentsInChildren)
{
((Graphic)item2).color = Color.white;
((TMP_Text)item2).fontSize = 16f;
}
}
Transform val5 = val4.Find("Viewport");
if ((Object)(object)val5 != (Object)null)
{
Transform val6 = val5.Find("Content");
if ((Object)(object)val6 != (Object)null)
{
Transform val7 = val6.Find("Item");
if ((Object)(object)val7 != (Object)null)
{
Image component10 = ((Component)val7).GetComponent<Image>();
if ((Object)(object)component10 != (Object)null)
{
((Graphic)component10).color = new Color(0.12f, 0.12f, 0.18f, 0.95f);
}
Transform val8 = val7.Find("Item Background");
if ((Object)(object)val8 != (Object)null)
{
Image component11 = ((Component)val8).GetComponent<Image>();
if ((Object)(object)component11 != (Object)null)
{
((Graphic)component11).color = new Color(0.2f, 0.2f, 0.3f, 0.8f);
}
}
Transform val9 = val7.Find("Item Checkmark");
if ((Object)(object)val9 != (Object)null)
{
Image component12 = ((Component)val9).GetComponent<Image>();
if ((Object)(object)component12 != (Object)null)
{
((Graphic)component12).color = Color.white;
}
}
}
}
}
}
Transform val10 = _presetButtonObject.transform.Find("Arrow");
if ((Object)(object)val10 != (Object)null)
{
Image component13 = ((Component)val10).GetComponent<Image>();
if ((Object)(object)component13 != (Object)null)
{
((Graphic)component13).color = Color.white;
}
}
RefreshNativeDropdown();
_presetButtonObject.SetActive(Presets.HasPresets);
}
private static void RefreshNativeDropdown()
{
if ((Object)(object)_nativeDropdown == (Object)null)
{
return;
}
if (!_labelLocTextKilled)
{
GameObject presetButtonObject = _presetButtonObject;
Transform val = ((presetButtonObject != null) ? presetButtonObject.transform.Find("Label") : null);
if ((Object)(object)val != (Object)null)
{
LocalizedText component = ((Component)val).GetComponent<LocalizedText>();
if ((Object)(object)component != (Object)null)
{
Object.Destroy((Object)(object)component);
}
_labelLocTextKilled = true;
}
}
_suppressDropdownCallback = true;
_nativeDropdown.ClearOptions();
List<string> val2 = new List<string>();
val2.Add("Load Preset");
if (Presets.HasPresets)
{
foreach (string presetName in Presets.PresetNames)
{
val2.Add(presetName);
}
}
_nativeDropdown.AddOptions(val2);
string labelText = "Load Preset";
if (!string.IsNullOrEmpty(_selectedPresetName) && Presets.HasPresets)
{
List<string> presetNames = Presets.PresetNames;
for (int i = 0; i < presetNames.Count; i++)
{
if (presetNames[i] == _selectedPresetName)
{
_nativeDropdown.SetValueWithoutNotify(i + 1);
labelText = _selectedPresetName;
break;
}
}
}
else
{
_selectedPresetName = null;
_nativeDropdown.SetValueWithoutNotify(0);
}
_suppressDropdownCallback = false;
SetLabelText(labelText);
}
private static IEnumerator FlashSaveButtonText(string message)
{
_saveButtonText.ForceSet(message);
yield return (object)new WaitForSeconds(5f);
if ((Object)(object)_saveButtonText != (Object)null)
{
_saveButtonText.ForceSet("Save New Preset");
}
}
private static void SetLabelText(string text)
{
if ((Object)(object)_presetButtonObject == (Object)null)
{
return;
}
Transform val = _presetButtonObject.transform.Find("Label");
if ((Object)(object)val != (Object)null)
{
TextMeshProUGUI component = ((Component)val).GetComponent<TextMeshProUGUI>();
if ((Object)(object)component != (Object)null)
{
((TMP_Text)component).text = text;
LockCaptionFont(component);
}
}
}
private static void OnNativeDropdownChanged(int index)
{
if (_suppressDropdownCallback)
{
return;
}
if (index <= 0)
{
_selectedPresetName = null;
SetLabelText("Load Preset");
return;
}
int num = index - 1;
List<string> presetNames = Presets.PresetNames;
if (num >= 0 && num < presetNames.Count)
{
_selectedPresetName = presetNames[num];
SetLabelText(_selectedPresetName);
OnPresetSelected(_selectedPresetName);
}
}
private static void OnEditClicked()
{
if (!string.IsNullOrEmpty(_selectedPresetName))
{
StartEdit(_selectedPresetName);
}
}
private static void OnDeleteClicked()
{
if (!string.IsNullOrEmpty(_selectedPresetName))
{
DeletePreset(_selectedPresetName);
}
}
private static void UpdatePresetUIVisibility()
{
bool hasPresets = Presets.HasPresets;
if ((Object)(object)_presetButtonObject != (Object)null)
{
_presetButtonObject.SetActive(hasPresets);
}
if ((Object)(object)_editDeleteContainer != (Object)null)
{
_editDeleteContainer.SetActive(hasPresets);
}
}
private static void StartEdit(string presetName)
{
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Expected O, but got Unknown
_editingPreset = presetName;
_isEditMode = true;
_saveButtonText.ForceSet("Save Edit");
try
{
CharacterCreationMenuMapper activeMenuMapper = _activeMenuMapper;
SimpleStunButton val = ((activeMenuMapper != null) ? activeMenuMapper._CharacterCreationScreen.ConfirmCharacter : null);
GameObject val2 = (((Object)(object)val != (Object)null) ? ((Component)val).gameObject : null);
if ((Object)(object)val2 == (Object)null)
{
Plugin.LogInstance.LogWarning((object)"[StartEdit]: Complete button not found");
return;
}
_renameButtonObject = UIHelper.InstantiateGameObjectUnderAnchor(val2, val2.transform.parent);
((Object)_renameButtonObject).name = "RenamePreset_StandardButton";
_renameButtonObject.transform.SetSiblingIndex(val2.transform.GetSiblingIndex());
LocalizedText componentInChildren = _renameButtonObject.GetComponentInChildren<LocalizedText>();
if (componentInChildren != null)
{
componentInChildren.ForceSet("Rename");
}
SimpleStunButton component = _renameButtonObject.GetComponent<SimpleStunButton>();
if ((Object)(object)component != (Object)null)
{
((UnityEventBase)component.onClick).RemoveAllListeners();
((UnityEvent)component.onClick).AddListener(UnityAction.op_Implicit((Action)OpenRenameBox));
}
_renameButtonObject.SetActive(true);
val2.SetActive(false);
_completeButtonHidden = val2;
}
catch (Exception ex)
{
ManualLogSource logInstance = Plugin.LogInstance;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(13, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[StartEdit]: ");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message);
}
logInstance.LogWarning(val3);
}
}
private static void OpenRenameBox()
{
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Expected O, but got Unknown
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Expected O, but got Unknown
try
{
CharacterCreationMenuMapper activeMenuMapper = _activeMenuMapper;
GenericPopupSystem val = ((activeMenuMapper != null) ? activeMenuMapper._PopupSystem : null);
_renamePopup = ((val != null) ? val.GenericTextInputPopup : null);
if ((Object)(object)_renamePopup == (Object)null)
{
Plugin.LogInstance.LogWarning((object)"[OpenRenameBox]: text input popup unavailable");
return;
}
_renamePopup.Show(new Data());
Plugin.StartCoroutine(SetupRenamePopup(_renamePopup, _editingPreset));
}
catch (Exception ex)
{
ManualLogSource logInstance = Plugin.LogInstance;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(17, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[OpenRenameBox]: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
}
logInstance.LogWarning(val2);
}
}
private static IEnumerator SetupRenamePopup(GenericTextInputPopup popup, string currentName)
{
for (int i = 0; i < 30; i++)
{
if ((Object)(object)popup == (Object)null)
{
yield break;
}
if (popup.IsOpen)
{
break;
}
yield return null;
}
try
{
popup._IgnoreValidation = true;
if ((Object)(object)popup.InputField != (Object)null)
{
popup.InputField.text = currentName ?? "";
try
{
popup.InputField.caretPosition = popup.InputField.text.Length;
}
catch
{
}
}
LocalizedText header = popup.Header;
if (header != null)
{
header.ForceSet("Rename Preset");
}
if ((Object)(object)popup.ConfirmButton != (Object)null)
{
((Component)popup.ConfirmButton).gameObject.SetActive(true);
LocalizedText confirmButtonText = popup.ConfirmButtonText;
if (confirmButtonText != null)
{
confirmButtonText.ForceSet("Confirm Rename");
}
((UnityEventBase)popup.ConfirmButton.onClick).RemoveAllListeners();
((UnityEvent)popup.ConfirmButton.onClick).AddListener(UnityAction.op_Implicit((Action)OnRenameConfirmed));
}
if ((Object)(object)popup.CancelButton != (Object)null)
{
((Component)popup.CancelButton).gameObject.SetActive(true);
LocalizedText cancelButtonText = popup.CancelButtonText;
if (cancelButtonText != null)
{
cancelButtonText.ForceSet("Cancel");
}
((UnityEventBase)popup.CancelButton.onClick).RemoveAllListeners();
((UnityEvent)popup.CancelButton.onClick).AddListener(UnityAction.op_Implicit((Action)OnRenameCancelled));
}
if ((Object)(object)popup.RandomizeButton != (Object)null)
{
((Component)popup.RandomizeButton).gameObject.SetActive(false);
}
}
catch (Exception ex)
{
ManualLogSource logInstance = Plugin.LogInstance;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(20, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SetupRenamePopup]: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
}
logInstance.LogWarning(val);
}
}
private static void OnRenameConfirmed()
{
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Expected O, but got Unknown
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Expected O, but got Unknown
bool flag = default(bool);
try
{
string editingPreset = _editingPreset;
GenericTextInputPopup renamePopup = _renamePopup;
string text = (((Object)(object)((renamePopup != null) ? renamePopup.InputField : null) != (Object)null) ? _renamePopup.InputField.text : null);
if (string.IsNullOrWhiteSpace(text))
{
text = editingPreset;
}
text = text?.Trim();
if (string.IsNullOrEmpty(editingPreset) || string.IsNullOrEmpty(text) || !(editingPreset != text))
{
return;
}
if (Presets.RenamePreset(editingPreset, text))
{
_selectedPresetName = text;
if ((Object)(object)_nativeDropdown != (Object)null)
{
RefreshNativeDropdown();
}
Plugin.StartCoroutine(FlashSaveButtonText("Renamed!"));
return;
}
ManualLogSource logInstance = Plugin.LogInstance;
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(44, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Rename '");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(editingPreset);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' -> '");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' failed (name already taken).");
}
logInstance.LogWarning(val);
}
catch (Exception ex)
{
ManualLogSource logInstance2 = Plugin.LogInstance;
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(21, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[OnRenameConfirmed]: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
}
logInstance2.LogWarning(val);
}
finally
{
try
{
GenericTextInputPopup renamePopup2 = _renamePopup;
if (renamePopup2 != null)
{
renamePopup2.Hide();
}
}
catch
{
}
ExitEditMode();
}
}
private static void OnRenameCancelled()
{
try
{
GenericTextInputPopup renamePopup = _renamePopup;
if (renamePopup != null)
{
renamePopup.Hide();
}
}
catch
{
}
}
private static void ExitEditMode()
{
_editingPreset = null;
_isEditMode = false;
if ((Object)(object)_saveButtonText != (Object)null)
{
_saveButtonText.ForceSet("Save New Preset");
}
if ((Object)(object)_renameButtonObject != (Object)null)
{
Object.Destroy((Object)(object)_renameButtonObject);
_renameButtonObject = null;
}
if ((Object)(object)_completeButtonHidden != (Object)null)
{
_completeButtonHidden.SetActive(true);
}
_completeButtonHidden = null;
}
private static void DeletePreset(string presetName)
{
Presets.DeletePreset(presetName);
_selectedPresetName = null;
if (_isEditMode)
{
ExitEditMode();
}
if ((Object)(object)_nativeDropdown != (Object)null)
{
RefreshNativeDropdown();
}
UpdatePresetUIVisibility();
}
private static void OnPresetSelected(string presetName)
{
if (_activeMenuMapper == null)
{
return;
}
CharacterPreset preset = Presets.GetPreset(presetName);
if (preset == null)
{
return;
}
_activeMenuMapper._SelectedBodyTypeIndex = preset.BodyTypeIndex;
_activeMenuMapper._SkinToneColorIndex = preset.SkinToneColorIndex;
_activeMenuMapper._FaceIndex = preset.FaceIndex;
_activeMenuMapper._EyeColorIndex = preset.EyeColorIndex;
_activeMenuMapper._HairIndex = preset.HairIndex;
_activeMenuMapper._HairColorIndex = preset.HairColorIndex;
_activeMenuMapper._FeaturesIndex = preset.FeaturesIndex;
_activeMenuMapper._AccessoriesIndex = preset.AccessoriesIndex;
if (!string.IsNullOrEmpty(preset.Name))
{
((UnityEvent)_activeMenuMapper._CharacterCreationScreen.ConfirmCharacter.onClick).AddListener(UnityAction.op_Implicit((Action)delegate
{
try
{
TMP_InputField nameInputField = _activeMenuMapper._CharacterCreationScreen.NameInputField;
if (nameInputField != null)
{
nameInputField.SetText(preset.Name, true);
}
}
catch
{
}
}));
}
if (_isEditMode)
{
ExitEditMode();
}
}
private static void SavePreset(CharacterCreationMenuMapper menuMapper)
{
string text = (_isEditMode ? _editingPreset : null);
if (_isEditMode)
{
ExitEditMode();
}
string text2 = ((!string.IsNullOrEmpty(text)) ? text : Presets.GetNextPresetName());
CharacterPreset preset = new CharacterPreset
{
Name = text2,
BodyTypeIndex = menuMapper._SelectedBodyTypeIndex,
SkinToneColorIndex = menuMapper._SkinToneColorIndex,
FaceIndex = menuMapper._FaceIndex,
EyeColorIndex = menuMapper._EyeColorIndex,
HairIndex = menuMapper._HairIndex,
HairColorIndex = menuMapper._HairColorIndex,
FeaturesIndex = menuMapper._FeaturesIndex,
AccessoriesIndex = menuMapper._AccessoriesIndex
};
Presets.SavePreset(text2, preset);
Plugin.StartCoroutine(FlashSaveButtonText("Saved!"));
_selectedPresetName = text2;
if ((Object)(object)_nativeDropdown != (Object)null)
{
RefreshNativeDropdown();
}
UpdatePresetUIVisibility();
}
}
}