Decompiled source of SULFUR Native UI Lib v0.10.1
SULFUR Native UI Lib.dll
Decompiled 3 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Serialization.Json; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Logging; using HarmonyLib; using PerfectRandom.Sulfur.Core; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("SULFUR Native UI Lib")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("SULFUR Native UI Lib")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("72a22641-593c-485e-a6bc-6191f7c17244")] [assembly: AssemblyFileVersion("0.10.1.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("0.10.1.0")] namespace Ryuka.Sulfur.NativeUI; [BepInPlugin("ryuka.sulfur.nativeui", "SULFUR Native UI Lib", "0.10.1")] public sealed class Plugin : BaseUnityPlugin { public const string PluginGuid = "ryuka.sulfur.nativeui"; public const string PluginName = "SULFUR Native UI Lib"; public const string PluginVersion = "0.10.1"; private Harmony harmony; internal static ManualLogSource Log { get; private set; } private void Awake() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; harmony = new Harmony("ryuka.sulfur.nativeui"); harmony.PatchAll(); SulfurFontFallback.EnsureRegistered(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"SULFUR Native UI Lib loaded."); } private void OnDestroy() { if (harmony != null) { harmony.UnpatchSelf(); harmony = null; } } } internal static class SulfurReflection { public static T GetField<T>(object obj, string fieldName) { if (obj == null || string.IsNullOrWhiteSpace(fieldName)) { return default(T); } FieldInfo fieldInfo = AccessTools.Field(obj.GetType(), fieldName); if (fieldInfo == null) { return default(T); } object value = fieldInfo.GetValue(obj); if (value is T) { return (T)value; } return default(T); } public static void SetField(object obj, string fieldName, object value) { if (obj != null && !string.IsNullOrWhiteSpace(fieldName)) { FieldInfo fieldInfo = AccessTools.Field(obj.GetType(), fieldName); if (!(fieldInfo == null)) { fieldInfo.SetValue(obj, value); } } } public static object Invoke(object obj, string methodName, params object[] args) { if (obj == null || string.IsNullOrWhiteSpace(methodName)) { return null; } MethodInfo methodInfo = AccessTools.Method(obj.GetType(), methodName, (Type[])null, (Type[])null); if (methodInfo == null) { return null; } return methodInfo.Invoke(obj, args); } } internal static class SulfurFontFallback { private sealed class FallbackSource { public readonly string Label; public readonly string Probe; public readonly string[] Families; public FallbackSource(string label, string probe, string[] families) { Label = label; Probe = probe; Families = families; } } private const string FontStyle = "Regular"; private const int SamplingPointSize = 90; private static readonly List<TMP_FontAsset> fallbackAssets = new List<TMP_FontAsset>(); private static bool built; private static readonly FallbackSource[] Sources = new FallbackSource[2] { new FallbackSource("CJK", "中文测试组拟", new string[10] { "Microsoft YaHei", "Microsoft YaHei UI", "SimHei", "SimSun", "NSimSun", "Noto Sans CJK SC", "Source Han Sans SC", "Malgun Gothic", "Yu Gothic", "Meiryo" }), new FallbackSource("Symbols", "✓✗○●▶", new string[6] { "Segoe UI Symbol", "Arial Unicode MS", "Segoe UI", "Arial", "Microsoft Sans Serif", "Segoe UI Emoji" }) }; public static void EnsureRegistered() { EnsureBuilt(); EnsureInGlobalFallbacks(); } public static void EnsureFontHasFallback(TMP_FontAsset primary) { EnsureBuilt(); if ((Object)(object)primary == (Object)null || fallbackAssets.Count == 0) { return; } try { List<TMP_FontAsset> list = primary.fallbackFontAssetTable; if (list == null) { list = (primary.fallbackFontAssetTable = new List<TMP_FontAsset>()); } foreach (TMP_FontAsset fallbackAsset in fallbackAssets) { if ((Object)(object)fallbackAsset != (Object)null && (Object)(object)fallbackAsset != (Object)(object)primary && !list.Contains(fallbackAsset)) { list.Add(fallbackAsset); } } } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("Attaching glyph fallback to '" + ((Object)primary).name + "' failed: " + ex.Message)); } } } private static void EnsureBuilt() { if (built) { return; } try { TMP_FontAsset val = BuildFromSource(Sources[0]); if ((Object)(object)val == (Object)null) { return; } fallbackAssets.Add(val); for (int i = 1; i < Sources.Length; i++) { TMP_FontAsset val2 = BuildFromSource(Sources[i]); if ((Object)(object)val2 != (Object)null) { fallbackAssets.Add(val2); } } built = true; } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("Glyph fallback setup failed (will retry): " + ex.Message)); } } } private static TMP_FontAsset BuildFromSource(FallbackSource source) { string[] families = source.Families; string value = default(string); foreach (string text in families) { TMP_FontAsset val = TryCreateSystemFontAsset(text); if ((Object)(object)val == (Object)null) { continue; } if (!val.TryAddCharacters(source.Probe, ref value, false) || !string.IsNullOrEmpty(value)) { Object.Destroy((Object)(object)val); continue; } ((Object)val).name = "SULFUR_" + source.Label + "_Fallback (" + text + ")"; Persist(val); ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)("Built " + source.Label + " glyph fallback: " + ((Object)val).name)); } return val; } ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogWarning((object)("No loadable OS font found for " + source.Label + " glyph fallback; those glyphs may be unavailable.")); } return null; } private static TMP_FontAsset TryCreateSystemFontAsset(string familyName) { try { return TMP_FontAsset.CreateFontAsset(familyName, "Regular", 90); } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("CreateFontAsset failed for '" + familyName + "': " + ex.Message)); } return null; } } private static void Persist(TMP_FontAsset asset) { Object.DontDestroyOnLoad((Object)(object)asset); if ((Object)(object)((TMP_Asset)asset).material != (Object)null) { Object.DontDestroyOnLoad((Object)(object)((TMP_Asset)asset).material); } if ((Object)(object)asset.atlasTexture != (Object)null) { Object.DontDestroyOnLoad((Object)(object)asset.atlasTexture); } } private static void EnsureInGlobalFallbacks() { if (fallbackAssets.Count == 0) { return; } try { List<TMP_FontAsset> fallbackFontAssets = TMP_Settings.fallbackFontAssets; if (fallbackFontAssets == null) { return; } foreach (TMP_FontAsset fallbackAsset in fallbackAssets) { if ((Object)(object)fallbackAsset != (Object)null && !fallbackFontAssets.Contains(fallbackAsset)) { fallbackFontAssets.Add(fallbackAsset); } } } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("Registering global glyph fallback failed: " + ex.Message)); } } } } public enum SulfurMessageKind { Info, Warning, Error, Success } public static class SulfurOptionsApi { private static readonly List<SulfurOptionsPage> pages = new List<SulfurOptionsPage>(); public static IReadOnlyList<SulfurOptionsPage> Pages => pages; public static void RegisterPage(SulfurOptionsPage page) { if (page == null) { throw new ArgumentNullException("page"); } if (string.IsNullOrWhiteSpace(page.PageId)) { throw new ArgumentException("PageId is required."); } if (page.BuildPage == null) { throw new ArgumentException("BuildPage is required."); } pages.RemoveAll((SulfurOptionsPage x) => string.Equals(x.PageId, page.PageId, StringComparison.OrdinalIgnoreCase)); pages.Add(page); pages.Sort(delegate(SulfurOptionsPage a, SulfurOptionsPage b) { int num = a.SortOrder.CompareTo(b.SortOrder); return (num != 0) ? num : string.Compare(a.DisplayName, b.DisplayName, StringComparison.OrdinalIgnoreCase); }); if (Plugin.Log != null) { Plugin.Log.LogInfo((object)("Registered SULFUR native options page: " + page.PageId)); } } public static void UnregisterPage(string pageId) { if (!string.IsNullOrWhiteSpace(pageId)) { pages.RemoveAll((SulfurOptionsPage x) => string.Equals(x.PageId, pageId, StringComparison.OrdinalIgnoreCase)); } } internal static SulfurOptionsPage GetPage(string pageId) { return pages.FirstOrDefault((SulfurOptionsPage x) => string.Equals(x.PageId, pageId, StringComparison.OrdinalIgnoreCase)); } } public sealed class SulfurOptionsPage { public string PageId; public string DisplayName; public int SortOrder = 1000; public Func<string> GetDisplayName; public Action<SulfurOptionsContext> BuildPage; internal string ResolvedDisplayName { get { if (GetDisplayName != null) { string text = GetDisplayName(); if (!string.IsNullOrWhiteSpace(text)) { return text; } } if (!string.IsNullOrWhiteSpace(DisplayName)) { return DisplayName; } return PageId; } } } public sealed class SulfurOptionsContext { private sealed class SulfurContainerScope : IDisposable { private readonly SulfurOptionsContext context; private readonly RectTransform groupRoot; private readonly bool active; private bool disposed; public SulfurContainerScope(SulfurOptionsContext context, RectTransform groupRoot, bool active) { this.context = context; this.groupRoot = groupRoot; this.active = active; } public void Dispose() { if (!disposed) { disposed = true; BringBordersToFront(groupRoot); if (active && context != null) { context.EndThemedGroup(); } } } private static void BringBordersToFront(RectTransform root) { if (!((Object)(object)root == (Object)null)) { MoveLast((Transform)(object)root, "BorderOverlay"); } } private static void MoveLast(Transform root, string childName) { Transform val = root.Find(childName); if ((Object)(object)val != (Object)null) { val.SetAsLastSibling(); } } } private readonly OptionsScreen optionsScreen; private readonly RectTransform rootOptionsContainer; private RectTransform currentOptionsContainer; private readonly Stack<RectTransform> containerStack = new Stack<RectTransform>(); private readonly List<OptionsScreenOption> nativeOptions; private readonly string pageId; private TextMeshProUGUI sampleTextCache; private bool sampleTextCacheInitialized; private float nativeOptionWidthCache = -1f; public OptionsScreen OptionsScreen => optionsScreen; public RectTransform OptionsContainer => currentOptionsContainer ?? rootOptionsContainer; public string PageId => pageId; internal SulfurOptionsContext(OptionsScreen optionsScreen, RectTransform optionsContainer, List<OptionsScreenOption> nativeOptions, string pageId) { this.optionsScreen = optionsScreen; rootOptionsContainer = optionsContainer; currentOptionsContainer = optionsContainer; this.nativeOptions = nativeOptions; this.pageId = pageId; } public void Rebuild() { SulfurOptionsScreenBridge.RebuildCurrentCustomPage(optionsScreen); } public void SetFooter(string leftText, string statusText, string primaryButtonText, Action onPrimaryPressed) { SulfurOptionsScreenBridge.SetCustomPageFooter(optionsScreen, leftText, statusText, primaryButtonText, onPrimaryPressed); } public void SetFooterStatus(string statusText) { SulfurOptionsScreenBridge.SetCustomPageFooterStatus(optionsScreen, statusText); } public IDisposable BeginThemedGroup(string name) { //IL_002c: 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_0031: 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) TextMeshProUGUI val = FindSampleText(); Color themeColor = (Color)(((Object)(object)val != (Object)null) ? ((Graphic)val).color : new Color(1f, 0.65f, 0.15f, 1f)); return BeginThemedGroup(name, themeColor, 32f); } public IDisposable BeginThemedGroup(string name, Color themeColor, float indentPixels) { //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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_00e4: 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_0106: 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_012e: 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_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0141: 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_015c: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Expected O, but got Unknown //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: 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_01d8: Unknown result type (might be due to invalid IL or missing references) RectTransform optionsContainer = OptionsContainer; if ((Object)(object)optionsContainer == (Object)null) { return new SulfurContainerScope(this, null, active: false); } float num = Mathf.Max(360f, GetNativeOptionWidth() - indentPixels + 24f); GameObject val = new GameObject(string.IsNullOrWhiteSpace(name) ? "SULFUR_ThemedGroup" : name, new Type[6] { typeof(RectTransform), typeof(LayoutElement), typeof(CanvasRenderer), typeof(Image), typeof(VerticalLayoutGroup), typeof(ContentSizeFitter) }); val.transform.SetParent((Transform)(object)optionsContainer, false); RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = new Vector2(0f, 1f); component.anchorMax = new Vector2(0f, 1f); component.pivot = new Vector2(0f, 1f); component.anchoredPosition = new Vector2(indentPixels, 0f); component.sizeDelta = new Vector2(num, 0f); LayoutElement component2 = val.GetComponent<LayoutElement>(); component2.minWidth = num; component2.preferredWidth = num; component2.flexibleWidth = 0f; Image component3 = val.GetComponent<Image>(); ((Graphic)component3).color = new Color(themeColor.r, themeColor.g, themeColor.b, 0.004f); ((Graphic)component3).raycastTarget = false; VerticalLayoutGroup component4 = val.GetComponent<VerticalLayoutGroup>(); ((LayoutGroup)component4).padding = new RectOffset(18, 14, 10, 12); ((HorizontalOrVerticalLayoutGroup)component4).spacing = 6f; ((LayoutGroup)component4).childAlignment = (TextAnchor)0; ((HorizontalOrVerticalLayoutGroup)component4).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)component4).childControlHeight = false; ((HorizontalOrVerticalLayoutGroup)component4).childForceExpandWidth = true; ((HorizontalOrVerticalLayoutGroup)component4).childForceExpandHeight = false; ContentSizeFitter component5 = val.GetComponent<ContentSizeFitter>(); component5.horizontalFit = (FitMode)0; component5.verticalFit = (FitMode)2; Color borderColor = default(Color); ((Color)(ref borderColor))..ctor(themeColor.r, themeColor.g, themeColor.b, 0.75f); ((Object)CreateBorderOverlay(val.transform, borderColor)).name = "BorderOverlay"; containerStack.Push(currentOptionsContainer); currentOptionsContainer = component; return new SulfurContainerScope(this, component, active: true); } private void EndThemedGroup() { PopContainer(); } internal void PushContainer(RectTransform container) { containerStack.Push(currentOptionsContainer); currentOptionsContainer = container; } internal void PopContainer() { if (containerStack.Count > 0) { currentOptionsContainer = containerStack.Pop(); } else { currentOptionsContainer = rootOptionsContainer; } } private static void CreateBorderLine(Transform parent, string name, Color color, Vector2 anchorMin, Vector2 anchorMax, Vector2 offsetMin, Vector2 offsetMax) { //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_004d: 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_005b: 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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name, new Type[4] { typeof(RectTransform), typeof(LayoutElement), typeof(CanvasRenderer), typeof(Image) }); val.transform.SetParent(parent, false); RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = anchorMin; component.anchorMax = anchorMax; component.offsetMin = offsetMin; component.offsetMax = offsetMax; val.GetComponent<LayoutElement>().ignoreLayout = true; Image component2 = val.GetComponent<Image>(); ((Graphic)component2).color = color; ((Graphic)component2).raycastTarget = false; } private static GameObject CreateBorderOverlay(Transform parent, Color borderColor) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_003e: 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_0054: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: 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_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0142: 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_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0166: 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_018f: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Expected O, but got Unknown GameObject val = new GameObject("BorderOverlay", new Type[2] { typeof(RectTransform), typeof(LayoutElement) }); val.transform.SetParent(parent, false); RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.offsetMin = Vector2.zero; component.offsetMax = Vector2.zero; val.GetComponent<LayoutElement>().ignoreLayout = true; CreateBorderLine(val.transform, "BorderLeft", borderColor, new Vector2(0f, 0f), new Vector2(0f, 1f), new Vector2(2f, 0f), new Vector2(6f, 0f)); CreateBorderLine(val.transform, "BorderRight", borderColor, new Vector2(1f, 0f), new Vector2(1f, 1f), new Vector2(-6f, 0f), new Vector2(-2f, 0f)); CreateBorderLine(val.transform, "BorderTop", borderColor, new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(2f, -3f), new Vector2(-2f, -1f)); CreateBorderLine(val.transform, "BorderBottom", borderColor, new Vector2(0f, 0f), new Vector2(1f, 0f), new Vector2(2f, 1f), new Vector2(-2f, 3f)); return val; } public void ClearFooter() { SulfurOptionsScreenBridge.ClearCustomPageFooter(optionsScreen); } public OptionsScreenOption AddButton(string label, Action onPressed) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown GameObject optionButtonPrefab = SulfurOptionsScreenBridge.GetOptionButtonPrefab(optionsScreen); OptionsScreenOption val = InstantiateOption(optionButtonPrefab); val.SetLabel(label ?? ""); SulfurOptionBinding sulfurOptionBinding = ((Component)val).gameObject.AddComponent<SulfurOptionBinding>(); sulfurOptionBinding.OnUse = delegate { if (onPressed != null) { onPressed(); } }; val.onButtonPressed = new OnButtonPressed(sulfurOptionBinding.InvokeUse); RegisterOption(val); return val; } public OptionsScreenOption AddButton(string label, string description, Action onPressed) { OptionsScreenOption result = AddButton(label, onPressed); AddDescription(description); return result; } public OptionsScreenOption AddInfo(string label) { GameObject val = SulfurOptionsScreenBridge.GetOptionInfoPrefab(optionsScreen); if ((Object)(object)val == (Object)null) { val = SulfurOptionsScreenBridge.GetOptionButtonPrefab(optionsScreen); } OptionsScreenOption val2 = InstantiateOption(val); val2.SetLabel(label ?? ""); RegisterOption(val2); return val2; } public OptionsScreenOption AddToggle(string label, bool value, Action<bool> onChanged) { GameObject optionBoolPrefab = SulfurOptionsScreenBridge.GetOptionBoolPrefab(optionsScreen); OptionsScreenOption val = InstantiateOption(optionBoolPrefab); val.SetLabel(label ?? ""); Toggle componentInChildren = ((Component)val).GetComponentInChildren<Toggle>(true); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.SetIsOnWithoutNotify(value); ((UnityEventBase)componentInChildren.onValueChanged).RemoveAllListeners(); ((UnityEvent<bool>)(object)componentInChildren.onValueChanged).AddListener((UnityAction<bool>)delegate(bool state) { if (onChanged != null) { onChanged(state); } }); } val.onButtonPressed = null; RegisterOption(val); return val; } public OptionsScreenOption AddToggle(string label, string description, bool value, Action<bool> onChanged) { OptionsScreenOption result = AddToggle(label, value, onChanged); AddDescription(description); return result; } public OptionsScreenOption AddCycle(string label, IReadOnlyList<string> values, int currentIndex, Action<int, string> onChanged) { GameObject optionAlternativePrefab = SulfurOptionsScreenBridge.GetOptionAlternativePrefab(optionsScreen); OptionsScreenOption val = InstantiateOption(optionAlternativePrefab); val.SetLabel(label ?? ""); List<string> list = new List<string>(); if (values != null) { list.AddRange(values); } if (list.Count == 0) { list.Add(""); } int num = Mathf.Clamp(currentIndex, 0, list.Count - 1); TextMeshProUGUI alternativeLabelText = SulfurOptionsScreenBridge.GetAlternativeLabelText(val); if ((Object)(object)alternativeLabelText != (Object)null) { ((TMP_Text)alternativeLabelText).text = list[num]; } SulfurOptionBinding sulfurOptionBinding = ((Component)val).gameObject.AddComponent<SulfurOptionBinding>(); sulfurOptionBinding.CycleValues = list; sulfurOptionBinding.CycleIndex = num; sulfurOptionBinding.CycleLabel = alternativeLabelText; sulfurOptionBinding.OnCycleChanged = onChanged; BindCycleButtons(val, sulfurOptionBinding); sulfurOptionBinding.OnUse = null; sulfurOptionBinding.OnHorizontal = sulfurOptionBinding.MoveCycle; val.onButtonPressed = null; RegisterOption(val); return val; } public OptionsScreenOption AddCycle(string label, string description, IReadOnlyList<string> values, int currentIndex, Action<int, string> onChanged) { OptionsScreenOption result = AddCycle(label, values, currentIndex, onChanged); AddDescription(description); return result; } public OptionsScreenOption AddSlider(string label, float value, float min, float max, float step, Action<float> onChanged) { GameObject optionSliderPrefab = SulfurOptionsScreenBridge.GetOptionSliderPrefab(optionsScreen); OptionsScreenOption val = InstantiateOption(optionSliderPrefab); val.SetLabel(label ?? ""); Slider slider = ((Component)val).GetComponentInChildren<Slider>(true); TextMeshProUGUI valueText = SulfurOptionsScreenBridge.GetSliderValueText(val); if ((Object)(object)slider != (Object)null) { slider.minValue = min; slider.maxValue = max; slider.SetValueWithoutNotify(Mathf.Clamp(value, min, max)); SetSliderText(valueText, slider.value); ((UnityEventBase)slider.onValueChanged).RemoveAllListeners(); ((UnityEvent<float>)(object)slider.onValueChanged).AddListener((UnityAction<float>)delegate(float v) { SetSliderText(valueText, v); if (onChanged != null) { onChanged(v); } }); } ((Component)val).gameObject.AddComponent<SulfurOptionBinding>().OnHorizontal = delegate(int delta) { if (!((Object)(object)slider == (Object)null)) { float num = ((step > 0f) ? step : ((max - min) / 20f)); slider.value = Mathf.Clamp(slider.value + num * (float)delta, min, max); } }; RegisterOption(val); return val; } public OptionsScreenOption AddSlider(string label, string description, float value, float min, float max, float step, Action<float> onChanged) { OptionsScreenOption result = AddSlider(label, value, min, max, step, onChanged); AddDescription(description); return result; } private TMP_InputField CreateStandaloneInputField(string name, string value, string placeholder, ContentType contentType) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_013e: 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_0143: 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_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Expected O, but got Unknown //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0268: 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_0282: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Unknown result type (might be due to invalid IL or missing references) //IL_0374: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Unknown result type (might be due to invalid IL or missing references) //IL_0433: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name, new Type[4] { typeof(RectTransform), typeof(LayoutElement), typeof(CanvasRenderer), typeof(Image) }); val.transform.SetParent((Transform)(object)OptionsContainer, false); RectTransform component = val.GetComponent<RectTransform>(); ApplyNativeRowRect(component, 48f); LayoutElement component2 = val.GetComponent<LayoutElement>(); component2.minHeight = 48f; component2.preferredHeight = 48f; component2.minWidth = GetNativeOptionWidth(); component2.preferredWidth = GetNativeOptionWidth(); Image component3 = val.GetComponent<Image>(); ((Graphic)component3).color = new Color(1f, 1f, 1f, 0.055f); ((Graphic)component3).raycastTarget = true; TMP_InputField val2 = val.AddComponent<TMP_InputField>(); ((Selectable)val2).targetGraphic = (Graphic)(object)component3; val2.contentType = contentType; val2.lineType = (LineType)0; val2.shouldHideMobileInput = true; val2.shouldHideSoftKeyboard = true; val2.shouldActivateOnSelect = true; val2.onFocusSelectAll = false; val2.resetOnDeActivation = false; val2.restoreOriginalTextOnEscape = false; TextMeshProUGUI val3 = FindSampleText(); TMP_FontAsset val4 = (((Object)(object)val3 != (Object)null) ? ((TMP_Text)val3).font : null); Color val5 = (((Object)(object)val3 != (Object)null) ? ((Graphic)val3).color : Color.white); float fontSize = (((Object)(object)val3 != (Object)null) ? ((TMP_Text)val3).fontSize : 22f); val2.customCaretColor = true; val2.caretColor = val5; val2.caretWidth = 2; val2.caretBlinkRate = 0.85f; val2.selectionColor = new Color(val5.r, val5.g, val5.b, 0.25f); GameObject val6 = new GameObject("TextArea", new Type[2] { typeof(RectTransform), typeof(RectMask2D) }); val6.transform.SetParent(val.transform, false); RectTransform component4 = val6.GetComponent<RectTransform>(); component4.anchorMin = Vector2.zero; component4.anchorMax = Vector2.one; component4.offsetMin = new Vector2(24f, 0f); component4.offsetMax = new Vector2(-24f, 0f); GameObject val7 = new GameObject("Text", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(TextMeshProUGUI) }); val7.transform.SetParent(val6.transform, false); RectTransform component5 = val7.GetComponent<RectTransform>(); component5.anchorMin = Vector2.zero; component5.anchorMax = Vector2.one; component5.offsetMin = Vector2.zero; component5.offsetMax = Vector2.zero; TextMeshProUGUI component6 = val7.GetComponent<TextMeshProUGUI>(); ((TMP_Text)component6).text = value ?? ""; ((TMP_Text)component6).fontSize = fontSize; ((Graphic)component6).color = val5; ((TMP_Text)component6).alignment = (TextAlignmentOptions)4097; ((Graphic)component6).raycastTarget = false; ((TMP_Text)component6).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)component6).overflowMode = (TextOverflowModes)0; if ((Object)(object)val4 != (Object)null) { ((TMP_Text)component6).font = val4; } GameObject val8 = new GameObject("Placeholder", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(TextMeshProUGUI) }); val8.transform.SetParent(val6.transform, false); RectTransform component7 = val8.GetComponent<RectTransform>(); component7.anchorMin = Vector2.zero; component7.anchorMax = Vector2.one; component7.offsetMin = Vector2.zero; component7.offsetMax = Vector2.zero; TextMeshProUGUI component8 = val8.GetComponent<TextMeshProUGUI>(); ((TMP_Text)component8).text = placeholder ?? ""; ((TMP_Text)component8).fontSize = fontSize; ((Graphic)component8).color = new Color(val5.r, val5.g, val5.b, 0.38f); ((TMP_Text)component8).alignment = (TextAlignmentOptions)4097; ((Graphic)component8).raycastTarget = false; ((TMP_Text)component8).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)component8).overflowMode = (TextOverflowModes)0; if ((Object)(object)val4 != (Object)null) { ((TMP_Text)component8).font = val4; } val2.textViewport = component4; val2.textComponent = (TMP_Text)(object)component6; val2.placeholder = (Graphic)(object)component8; val2.SetTextWithoutNotify(value ?? ""); SulfurInputCaretOverlay.Attach(val2, component6, component4, val5); ((Component)val2).gameObject.AddComponent<SulfurTextInputBinding>().Configure(val2); ((Component)val2).gameObject.AddComponent<SulfurInputVisualState>().Configure(val2, component3); return val2; } private TMP_InputField BuildInlineInputRow(string name, string label, string value, string placeholder, ContentType contentType, float labelWidth) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: 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_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) labelWidth = Mathf.Clamp(labelWidth, 60f, 400f); GameObject val = new GameObject(name, new Type[2] { typeof(RectTransform), typeof(LayoutElement) }); val.transform.SetParent((Transform)(object)OptionsContainer, false); RectTransform component = val.GetComponent<RectTransform>(); ApplyNativeRowRect(component, 48f); LayoutElement component2 = val.GetComponent<LayoutElement>(); component2.minHeight = 48f; component2.preferredHeight = 48f; component2.minWidth = GetNativeOptionWidth(); component2.preferredWidth = GetNativeOptionWidth(); TextMeshProUGUI val2 = FindSampleText(); GameObject val3 = new GameObject("Label", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(TextMeshProUGUI) }); val3.transform.SetParent(val.transform, false); RectTransform component3 = val3.GetComponent<RectTransform>(); component3.anchorMin = new Vector2(0f, 0f); component3.anchorMax = new Vector2(0f, 1f); component3.pivot = new Vector2(0f, 0.5f); component3.sizeDelta = new Vector2(labelWidth, 0f); component3.anchoredPosition = new Vector2(8f, 0f); TextMeshProUGUI component4 = val3.GetComponent<TextMeshProUGUI>(); ((TMP_Text)component4).text = label ?? ""; ((TMP_Text)component4).alignment = (TextAlignmentOptions)4097; ((Graphic)component4).raycastTarget = false; ((TMP_Text)component4).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)component4).overflowMode = (TextOverflowModes)1; if ((Object)(object)val2 != (Object)null) { ((TMP_Text)component4).font = ((TMP_Text)val2).font; ((TMP_Text)component4).fontSharedMaterial = ((TMP_Text)val2).fontSharedMaterial; ((TMP_Text)component4).fontSize = Mathf.Max(14f, ((TMP_Text)val2).fontSize * 0.78f); ((Graphic)component4).color = new Color(((Graphic)val2).color.r, ((Graphic)val2).color.g, ((Graphic)val2).color.b, 0.85f); } else { ((TMP_Text)component4).fontSize = 16f; ((Graphic)component4).color = new Color(1f, 1f, 1f, 0.85f); } GameObject val4 = new GameObject("InputBox", new Type[4] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image), typeof(TMP_InputField) }); val4.transform.SetParent(val.transform, false); RectTransform component5 = val4.GetComponent<RectTransform>(); component5.anchorMin = new Vector2(0f, 0f); component5.anchorMax = new Vector2(1f, 1f); component5.offsetMin = new Vector2(labelWidth + 16f, 6f); component5.offsetMax = new Vector2(0f, -6f); Image component6 = val4.GetComponent<Image>(); ((Graphic)component6).color = new Color(1f, 1f, 1f, 0.055f); ((Graphic)component6).raycastTarget = true; TMP_InputField component7 = val4.GetComponent<TMP_InputField>(); PopulateInputFieldBox(component7, component6, component5, value, placeholder, contentType); return component7; } private void PopulateInputFieldBox(TMP_InputField input, Image background, RectTransform boxRt, string value, string placeholder, ContentType contentType) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Expected O, but got Unknown //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_019b: 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_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0274: 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_0286: 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_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) ((Selectable)input).targetGraphic = (Graphic)(object)background; input.contentType = contentType; input.lineType = (LineType)0; input.shouldHideMobileInput = true; input.shouldHideSoftKeyboard = true; input.shouldActivateOnSelect = true; input.onFocusSelectAll = false; input.resetOnDeActivation = false; input.restoreOriginalTextOnEscape = false; TextMeshProUGUI val = FindSampleText(); TMP_FontAsset val2 = (((Object)(object)val != (Object)null) ? ((TMP_Text)val).font : null); Color val3 = (((Object)(object)val != (Object)null) ? ((Graphic)val).color : Color.white); float fontSize = (((Object)(object)val != (Object)null) ? ((TMP_Text)val).fontSize : 22f); input.customCaretColor = true; input.caretColor = val3; input.caretWidth = 2; input.caretBlinkRate = 0.85f; input.selectionColor = new Color(val3.r, val3.g, val3.b, 0.25f); GameObject val4 = new GameObject("TextArea", new Type[2] { typeof(RectTransform), typeof(RectMask2D) }); val4.transform.SetParent((Transform)(object)boxRt, false); RectTransform component = val4.GetComponent<RectTransform>(); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.offsetMin = new Vector2(12f, 0f); component.offsetMax = new Vector2(-12f, 0f); GameObject val5 = new GameObject("Text", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(TextMeshProUGUI) }); val5.transform.SetParent(val4.transform, false); RectTransform component2 = val5.GetComponent<RectTransform>(); component2.anchorMin = Vector2.zero; component2.anchorMax = Vector2.one; component2.offsetMin = Vector2.zero; component2.offsetMax = Vector2.zero; TextMeshProUGUI component3 = val5.GetComponent<TextMeshProUGUI>(); ((TMP_Text)component3).text = value ?? ""; ((TMP_Text)component3).fontSize = fontSize; ((Graphic)component3).color = val3; ((TMP_Text)component3).alignment = (TextAlignmentOptions)4097; ((Graphic)component3).raycastTarget = false; ((TMP_Text)component3).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)component3).overflowMode = (TextOverflowModes)0; if ((Object)(object)val2 != (Object)null) { ((TMP_Text)component3).font = val2; } GameObject val6 = new GameObject("Placeholder", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(TextMeshProUGUI) }); val6.transform.SetParent(val4.transform, false); RectTransform component4 = val6.GetComponent<RectTransform>(); component4.anchorMin = Vector2.zero; component4.anchorMax = Vector2.one; component4.offsetMin = Vector2.zero; component4.offsetMax = Vector2.zero; TextMeshProUGUI component5 = val6.GetComponent<TextMeshProUGUI>(); ((TMP_Text)component5).text = placeholder ?? ""; ((TMP_Text)component5).fontSize = fontSize; ((Graphic)component5).color = new Color(val3.r, val3.g, val3.b, 0.38f); ((TMP_Text)component5).alignment = (TextAlignmentOptions)4097; ((Graphic)component5).raycastTarget = false; ((TMP_Text)component5).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)component5).overflowMode = (TextOverflowModes)0; if ((Object)(object)val2 != (Object)null) { ((TMP_Text)component5).font = val2; } input.textViewport = component; input.textComponent = (TMP_Text)(object)component3; input.placeholder = (Graphic)(object)component5; input.SetTextWithoutNotify(value ?? ""); SulfurInputCaretOverlay.Attach(input, component3, component, val3); ((Component)input).gameObject.AddComponent<SulfurTextInputBinding>().Configure(input); ((Component)input).gameObject.AddComponent<SulfurInputVisualState>().Configure(input, background); } internal TextMeshProUGUI FindSampleText() { SulfurFontFallback.EnsureRegistered(); if (!sampleTextCacheInitialized) { sampleTextCacheInitialized = true; sampleTextCache = ResolveSampleText(); } if ((Object)(object)sampleTextCache != (Object)null) { SulfurFontFallback.EnsureFontHasFallback(((TMP_Text)sampleTextCache).font); } return sampleTextCache; } private TextMeshProUGUI ResolveSampleText() { TextMeshProUGUI val = FindPrefabSampleText(); TextMeshProUGUI val2 = FindLiveLanguageText(); if ((Object)(object)val == (Object)null) { return val2; } if ((Object)(object)val2 == (Object)null || (Object)(object)((TMP_Text)val2).font == (Object)(object)((TMP_Text)val).font) { return val; } return BuildLanguageSample(val, val2); } private TextMeshProUGUI FindLiveLanguageText() { if ((Object)(object)optionsScreen == (Object)null) { return null; } TextMeshProUGUI[] componentsInChildren = ((Component)optionsScreen).GetComponentsInChildren<TextMeshProUGUI>(true); if (componentsInChildren == null) { return null; } RectTransform optionsContainer = OptionsContainer; TextMeshProUGUI[] array = componentsInChildren; foreach (TextMeshProUGUI val in array) { if (!((Object)(object)val == (Object)null) && !((Object)(object)((TMP_Text)val).font == (Object)null) && (!((Object)(object)optionsContainer != (Object)null) || !((TMP_Text)val).transform.IsChildOf((Transform)(object)optionsContainer))) { return val; } } return null; } private TextMeshProUGUI BuildLanguageSample(TextMeshProUGUI sizeSource, TextMeshProUGUI fontSource) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_006e: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("SulfurStyleSample", new Type[2] { typeof(RectTransform), typeof(TextMeshProUGUI) }); val.transform.SetParent((Transform)(object)OptionsContainer, false); val.SetActive(false); TextMeshProUGUI component = val.GetComponent<TextMeshProUGUI>(); ((TMP_Text)component).font = ((TMP_Text)fontSource).font; ((TMP_Text)component).fontSharedMaterial = ((TMP_Text)fontSource).fontSharedMaterial; ((TMP_Text)component).fontSize = ((TMP_Text)sizeSource).fontSize; ((Graphic)component).color = ((Graphic)sizeSource).color; return component; } private TextMeshProUGUI FindPrefabSampleText() { if ((Object)(object)optionsScreen == (Object)null) { return null; } GameObject[] array = (GameObject[])(object)new GameObject[4] { SulfurOptionsScreenBridge.GetOptionButtonPrefab(optionsScreen), SulfurOptionsScreenBridge.GetOptionInfoPrefab(optionsScreen), SulfurOptionsScreenBridge.GetOptionBoolPrefab(optionsScreen), SulfurOptionsScreenBridge.GetOptionAlternativePrefab(optionsScreen) }; foreach (GameObject val in array) { if ((Object)(object)val == (Object)null) { continue; } TextMeshProUGUI[] componentsInChildren = val.GetComponentsInChildren<TextMeshProUGUI>(true); foreach (TextMeshProUGUI val2 in componentsInChildren) { if ((Object)(object)val2 != (Object)null && (Object)(object)((TMP_Text)val2).font != (Object)null) { return val2; } } } return null; } private void ApplyNativeRowRect(RectTransform rectTransform, float height) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)rectTransform == (Object)null)) { rectTransform.anchorMin = new Vector2(0f, 1f); rectTransform.anchorMax = new Vector2(0f, 1f); rectTransform.pivot = new Vector2(0f, 1f); rectTransform.anchoredPosition = Vector2.zero; rectTransform.sizeDelta = new Vector2(GetNativeOptionWidth(), height); } } internal float GetNativeOptionWidth() { //IL_003a: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) if (nativeOptionWidthCache > 100f) { return nativeOptionWidthCache; } GameObject optionButtonPrefab = SulfurOptionsScreenBridge.GetOptionButtonPrefab(optionsScreen); if ((Object)(object)optionButtonPrefab != (Object)null) { RectTransform component = optionButtonPrefab.GetComponent<RectTransform>(); if ((Object)(object)component != (Object)null && component.sizeDelta.x > 100f) { nativeOptionWidthCache = component.sizeDelta.x; return nativeOptionWidthCache; } } if ((Object)(object)OptionsContainer != (Object)null) { RectTransform component2 = ((Component)OptionsContainer).GetComponent<RectTransform>(); if ((Object)(object)component2 != (Object)null) { Rect rect = component2.rect; if (((Rect)(ref rect)).width > 100f) { rect = component2.rect; nativeOptionWidthCache = ((Rect)(ref rect)).width; return nativeOptionWidthCache; } } } nativeOptionWidthCache = 900f; return nativeOptionWidthCache; } private static bool TryParseNumber(string text, out float value) { value = 0f; if (string.IsNullOrWhiteSpace(text)) { return false; } return float.TryParse(text.Trim().Replace(',', '.'), NumberStyles.Float, CultureInfo.InvariantCulture, out value); } private static float RoundNumber(float value, int decimals) { if (decimals <= 0) { return Mathf.Round(value); } float num = Mathf.Pow(10f, (float)decimals); return Mathf.Round(value * num) / num; } public void AddSection(string label) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: 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_0107: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0244: 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_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) if (!string.IsNullOrWhiteSpace(label)) { GameObject val = new GameObject("SULFUR_Section", new Type[2] { typeof(RectTransform), typeof(LayoutElement) }); val.transform.SetParent((Transform)(object)OptionsContainer, false); RectTransform component = val.GetComponent<RectTransform>(); ApplyNativeRowRect(component, 54f); LayoutElement component2 = val.GetComponent<LayoutElement>(); component2.minHeight = 54f; component2.preferredHeight = 54f; component2.minWidth = GetNativeOptionWidth(); component2.preferredWidth = GetNativeOptionWidth(); component2.flexibleWidth = 0f; GameObject val2 = new GameObject("SectionText", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(TextMeshProUGUI) }); val2.transform.SetParent(val.transform, false); RectTransform component3 = val2.GetComponent<RectTransform>(); component3.anchorMin = Vector2.zero; component3.anchorMax = Vector2.one; component3.offsetMin = new Vector2(12f, 0f); component3.offsetMax = new Vector2(-12f, 0f); TextMeshProUGUI val3 = FindSampleText(); TextMeshProUGUI component4 = val2.GetComponent<TextMeshProUGUI>(); ((TMP_Text)component4).text = label; ((TMP_Text)component4).alignment = (TextAlignmentOptions)4097; ((Graphic)component4).raycastTarget = false; ((TMP_Text)component4).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)component4).overflowMode = (TextOverflowModes)0; ((TMP_Text)component4).fontStyle = (FontStyles)1; if ((Object)(object)val3 != (Object)null) { ((TMP_Text)component4).font = ((TMP_Text)val3).font; ((TMP_Text)component4).fontSharedMaterial = ((TMP_Text)val3).fontSharedMaterial; ((TMP_Text)component4).fontSize = Mathf.Max(18f, ((TMP_Text)val3).fontSize * 0.95f); ((Graphic)component4).color = ((Graphic)val3).color; } else { ((TMP_Text)component4).fontSize = 20f; ((Graphic)component4).color = new Color(1f, 0.65f, 0.15f, 1f); } GameObject val4 = new GameObject("SectionLine", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image) }); val4.transform.SetParent(val.transform, false); RectTransform component5 = val4.GetComponent<RectTransform>(); component5.anchorMin = new Vector2(0f, 0f); component5.anchorMax = new Vector2(1f, 0f); component5.pivot = new Vector2(0.5f, 0.5f); component5.offsetMin = new Vector2(0f, 4f); component5.offsetMax = new Vector2(0f, 8f); Image component6 = val4.GetComponent<Image>(); if ((Object)(object)val3 != (Object)null) { ((Graphic)component6).color = new Color(((Graphic)val3).color.r, ((Graphic)val3).color.g, ((Graphic)val3).color.b, 0.85f); } else { ((Graphic)component6).color = new Color(1f, 0.65f, 0.15f, 0.85f); } ((Graphic)component6).raycastTarget = false; } } public OptionsScreenOption AddDescription(string text) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: 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_0111: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_018c: 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_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrWhiteSpace(text)) { return null; } GameObject val = new GameObject("Description", new Type[2] { typeof(RectTransform), typeof(LayoutElement) }); val.transform.SetParent((Transform)(object)OptionsContainer, false); RectTransform component = val.GetComponent<RectTransform>(); ApplyNativeRowRect(component, 42f); LayoutElement component2 = val.GetComponent<LayoutElement>(); component2.minHeight = 42f; component2.preferredHeight = 42f; component2.minWidth = GetNativeOptionWidth(); component2.preferredWidth = GetNativeOptionWidth(); GameObject val2 = new GameObject("DescriptionText", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(TextMeshProUGUI) }); val2.transform.SetParent(val.transform, false); RectTransform component3 = val2.GetComponent<RectTransform>(); component3.anchorMin = Vector2.zero; component3.anchorMax = Vector2.one; component3.offsetMin = new Vector2(28f, 0f); component3.offsetMax = new Vector2(-12f, 0f); TextMeshProUGUI val3 = FindSampleText(); TextMeshProUGUI component4 = val2.GetComponent<TextMeshProUGUI>(); ((TMP_Text)component4).text = "— " + text; ((TMP_Text)component4).alignment = (TextAlignmentOptions)4097; ((Graphic)component4).raycastTarget = false; ((TMP_Text)component4).textWrappingMode = (TextWrappingModes)1; ((TMP_Text)component4).overflowMode = (TextOverflowModes)0; if ((Object)(object)val3 != (Object)null) { ((TMP_Text)component4).font = ((TMP_Text)val3).font; ((TMP_Text)component4).fontSize = Mathf.Max(14f, ((TMP_Text)val3).fontSize * 0.72f); ((Graphic)component4).color = new Color(((Graphic)val3).color.r, ((Graphic)val3).color.g, ((Graphic)val3).color.b, 0.58f); } else { ((TMP_Text)component4).fontSize = 16f; ((Graphic)component4).color = new Color(1f, 1f, 1f, 0.58f); } return null; } public SulfurTextHandle AddTextRow(string text) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00de: 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_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("SULFUR_TextRow", new Type[2] { typeof(RectTransform), typeof(LayoutElement) }); val.transform.SetParent((Transform)(object)OptionsContainer, false); RectTransform component = val.GetComponent<RectTransform>(); ApplyNativeRowRect(component, 42f); LayoutElement component2 = val.GetComponent<LayoutElement>(); component2.minHeight = 42f; component2.preferredHeight = 42f; component2.minWidth = GetNativeOptionWidth(); component2.preferredWidth = GetNativeOptionWidth(); GameObject val2 = new GameObject("TextRowText", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(TextMeshProUGUI) }); val2.transform.SetParent(val.transform, false); RectTransform component3 = val2.GetComponent<RectTransform>(); component3.anchorMin = Vector2.zero; component3.anchorMax = Vector2.one; component3.offsetMin = new Vector2(28f, 0f); component3.offsetMax = new Vector2(-12f, 0f); TextMeshProUGUI val3 = FindSampleText(); TextMeshProUGUI component4 = val2.GetComponent<TextMeshProUGUI>(); ((TMP_Text)component4).text = text ?? ""; ((TMP_Text)component4).alignment = (TextAlignmentOptions)4097; ((Graphic)component4).raycastTarget = false; ((TMP_Text)component4).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)component4).overflowMode = (TextOverflowModes)1; if ((Object)(object)val3 != (Object)null) { ((TMP_Text)component4).font = ((TMP_Text)val3).font; ((TMP_Text)component4).fontSize = Mathf.Max(14f, ((TMP_Text)val3).fontSize * 0.72f); ((Graphic)component4).color = ((Graphic)val3).color; } else { ((TMP_Text)component4).fontSize = 16f; ((Graphic)component4).color = Color.white; } return new SulfurTextHandle(val, component4); } public void AddWarning(string text) { AddMessage(text, SulfurMessageKind.Warning); } public void AddError(string text) { AddMessage(text, SulfurMessageKind.Error); } public void AddSuccess(string text) { AddMessage(text, SulfurMessageKind.Success); } public void AddMessage(string text, SulfurMessageKind kind) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0119: 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_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0154: 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_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) if (!string.IsNullOrWhiteSpace(text)) { GameObject val = new GameObject("SULFUR_Message_" + kind, new Type[4] { typeof(RectTransform), typeof(LayoutElement), typeof(CanvasRenderer), typeof(Image) }); val.transform.SetParent((Transform)(object)OptionsContainer, false); RectTransform component = val.GetComponent<RectTransform>(); ApplyNativeRowRect(component, 40f); LayoutElement component2 = val.GetComponent<LayoutElement>(); component2.minHeight = 40f; component2.preferredHeight = 40f; component2.minWidth = GetNativeOptionWidth(); component2.preferredWidth = GetNativeOptionWidth(); Image component3 = val.GetComponent<Image>(); ((Graphic)component3).color = GetMessageBackground(kind); ((Graphic)component3).raycastTarget = false; GameObject val2 = new GameObject("MessageText", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(TextMeshProUGUI) }); val2.transform.SetParent(val.transform, false); RectTransform component4 = val2.GetComponent<RectTransform>(); component4.anchorMin = Vector2.zero; component4.anchorMax = Vector2.one; component4.offsetMin = new Vector2(20f, 0f); component4.offsetMax = new Vector2(-20f, 0f); TextMeshProUGUI val3 = FindSampleText(); TextMeshProUGUI component5 = val2.GetComponent<TextMeshProUGUI>(); ((TMP_Text)component5).text = GetMessagePrefix(kind) + text; ((TMP_Text)component5).alignment = (TextAlignmentOptions)4097; ((Graphic)component5).raycastTarget = false; ((TMP_Text)component5).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)component5).overflowMode = (TextOverflowModes)1; if ((Object)(object)val3 != (Object)null) { ((TMP_Text)component5).font = ((TMP_Text)val3).font; ((TMP_Text)component5).fontSize = Mathf.Max(13f, ((TMP_Text)val3).fontSize * 0.66f); ((Graphic)component5).color = new Color(((Graphic)val3).color.r, ((Graphic)val3).color.g, ((Graphic)val3).color.b, 0.9f); } else { ((TMP_Text)component5).fontSize = 17f; ((Graphic)component5).color = new Color(1f, 1f, 1f, 0.9f); } } } public void AddBadgeRow(params string[] badges) { if (badges == null || badges.Length == 0) { return; } List<string> list = new List<string>(); foreach (string text in badges) { if (!string.IsNullOrWhiteSpace(text)) { list.Add(text.Trim()); } } AddBadgeRow(list); } public void AddBadgeRow(IReadOnlyList<string> badges) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown if (badges == null || badges.Count == 0) { return; } GameObject val = new GameObject("SULFUR_BadgeRow", new Type[3] { typeof(RectTransform), typeof(LayoutElement), typeof(HorizontalLayoutGroup) }); val.transform.SetParent((Transform)(object)OptionsContainer, false); RectTransform component = val.GetComponent<RectTransform>(); ApplyNativeRowRect(component, 30f); LayoutElement component2 = val.GetComponent<LayoutElement>(); component2.minHeight = 30f; component2.preferredHeight = 30f; component2.minWidth = GetNativeOptionWidth(); component2.preferredWidth = GetNativeOptionWidth(); HorizontalLayoutGroup component3 = val.GetComponent<HorizontalLayoutGroup>(); ((LayoutGroup)component3).padding = new RectOffset(24, 12, 5, 5); ((HorizontalOrVerticalLayoutGroup)component3).spacing = 8f; ((LayoutGroup)component3).childAlignment = (TextAnchor)3; ((HorizontalOrVerticalLayoutGroup)component3).childControlWidth = false; ((HorizontalOrVerticalLayoutGroup)component3).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)component3).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)component3).childForceExpandHeight = true; foreach (string badge in badges) { if (!string.IsNullOrWhiteSpace(badge)) { CreateBadge(val.transform, badge.Trim()); } } } public void AddDefaultButton(Action onPressed) { AddSmallButton("Default", onPressed); } public void AddSmallButton(string label, Action onPressed) { AddSmallButton(label, onPressed, 0f); } public void AddSmallButton(string label, Action onPressed, float minWidth) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Expected O, but got Unknown //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) string label2 = (string.IsNullOrWhiteSpace(label) ? "Default" : label); float width = ((minWidth > 0f) ? minWidth : CalculateSmallButtonWidth(label2)); GameObject val = new GameObject("SULFUR_SmallButtonRow", new Type[3] { typeof(RectTransform), typeof(LayoutElement), typeof(HorizontalLayoutGroup) }); val.transform.SetParent((Transform)(object)OptionsContainer, false); RectTransform component = val.GetComponent<RectTransform>(); ApplyNativeRowRect(component, 42f); LayoutElement component2 = val.GetComponent<LayoutElement>(); component2.minHeight = 42f; component2.preferredHeight = 42f; component2.minWidth = GetNativeOptionWidth(); component2.preferredWidth = GetNativeOptionWidth(); HorizontalLayoutGroup component3 = val.GetComponent<HorizontalLayoutGroup>(); ((LayoutGroup)component3).padding = new RectOffset(12, 16, 4, 4); ((HorizontalOrVerticalLayoutGroup)component3).spacing = 8f; ((LayoutGroup)component3).childAlignment = (TextAnchor)5; ((HorizontalOrVerticalLayoutGroup)component3).childControlWidth = false; ((HorizontalOrVerticalLayoutGroup)component3).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)component3).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)component3).childForceExpandHeight = true; GameObject val2 = new GameObject("Spacer", new Type[2] { typeof(RectTransform), typeof(LayoutElement) }); val2.transform.SetParent(val.transform, false); val2.GetComponent<LayoutElement>().flexibleWidth = 1f; ApplySmallButtonWidth(CreateSmallButton(val.transform, label2, onPressed), width); } private static void ApplySmallButtonWidth(Button button, float width) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)button == (Object)null) && !(width <= 0f)) { LayoutElement component = ((Component)button).GetComponent<LayoutElement>(); if ((Object)(object)component != (Object)null) { component.minWidth = width; component.preferredWidth = width; } RectTransform component2 = ((Component)button).GetComponent<RectTransform>(); if ((Object)(object)component2 != (Object)null) { component2.sizeDelta = new Vector2(width, component2.sizeDelta.y); } } } private static float CalculateSmallButtonWidth(string label) { if (string.IsNullOrWhiteSpace(label)) { return 96f; } int length = label.Trim().Length; return Mathf.Clamp(72f + (float)length * 14f, 96f, 180f); } public IReadOnlyList<SulfurButtonHandle> AddButtonRow(params SulfurButton[] buttons) { return AddButtonRow((IReadOnlyList<SulfurButton>)buttons); } public IReadOnlyList<SulfurButtonHandle> AddButtonRow(IReadOnlyList<SulfurButton> buttons) { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Expected O, but got Unknown //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Expected O, but got Unknown if (buttons == null || buttons.Count == 0) { return Array.Empty<SulfurButtonHandle>(); } List<SulfurButton> list = new List<SulfurButton>(); foreach (SulfurButton button in buttons) { if (!string.IsNullOrWhiteSpace(button.Label)) { list.Add(button); } } if (list.Count == 0) { return Array.Empty<SulfurButtonHandle>(); } GameObject val = new GameObject("SULFUR_ButtonRow", new Type[3] { typeof(RectTransform), typeof(LayoutElement), typeof(HorizontalLayoutGroup) }); val.transform.SetParent((Transform)(object)OptionsContainer, false); RectTransform component = val.GetComponent<RectTransform>(); ApplyNativeRowRect(component, 42f); LayoutElement component2 = val.GetComponent<LayoutElement>(); component2.minHeight = 42f; component2.preferredHeight = 42f; component2.minWidth = GetNativeOptionWidth(); component2.preferredWidth = GetNativeOptionWidth(); HorizontalLayoutGroup component3 = val.GetComponent<HorizontalLayoutGroup>(); ((LayoutGroup)component3).padding = new RectOffset(12, 16, 4, 4); ((HorizontalOrVerticalLayoutGroup)component3).spacing = 8f; ((LayoutGroup)component3).childAlignment = (TextAnchor)3; ((HorizontalOrVerticalLayoutGroup)component3).childControlWidth = false; ((HorizontalOrVerticalLayoutGroup)component3).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)component3).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)component3).childForceExpandHeight = true; List<SulfurButtonHandle> list2 = new List<SulfurButtonHandle>(list.Count); foreach (SulfurButton item in list) { Button val2 = CreateSmallButton(val.transform, item.Label, item.OnPressed); if (!((Object)(object)val2 == (Object)null)) { float width = ((item.MinWidth > 0f) ? item.MinWidth : CalculateSmallButtonWidth(item.Label)); ApplySmallButtonWidth(val2, width); TextMeshProUGUI componentInChildren = ((Component)val2).GetComponentInChildren<TextMeshProUGUI>(true); list2.Add(new SulfurButtonHandle(((Component)val2).gameObject, val2, componentInChildren)); } } return list2; } public SulfurListHandle AddList() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_0084: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Expected O, but got Unknown float nativeOptionWidth = GetNativeOptionWidth(); GameObject val = new GameObject("SULFUR_List", new Type[4] { typeof(RectTransform), typeof(LayoutElement), typeof(VerticalLayoutGroup), typeof(ContentSizeFitter) }); val.transform.SetParent((Transform)(object)OptionsContainer, false); RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = new Vector2(0f, 1f); component.anchorMax = new Vector2(0f, 1f); component.pivot = new Vector2(0f, 1f); component.anchoredPosition = Vector2.zero; component.sizeDelta = new Vector2(nativeOptionWidth, 0f); LayoutElement component2 = val.GetComponent<LayoutElement>(); component2.minWidth = nativeOptionWidth; component2.preferredWidth = nativeOptionWidth; component2.flexibleWidth = 0f; VerticalLayoutGroup component3 = val.GetComponent<VerticalLayoutGroup>(); ((LayoutGroup)component3).padding = new RectOffset(0, 0, 0, 0); ((HorizontalOrVerticalLayoutGroup)component3).spacing = 4f; ((LayoutGroup)component3).childAlignment = (TextAnchor)0; ((HorizontalOrVerticalLayoutGroup)component3).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)component3).childControlHeight = false; ((HorizontalOrVerticalLayoutGroup)component3).childForceExpandWidth = true; ((HorizontalOrVerticalLayoutGroup)component3).childForceExpandHeight = false; ContentSizeFitter component4 = val.GetComponent<ContentSizeFitter>(); component4.horizontalFit = (FitMode)0; component4.verticalFit = (FitMode)2; return new SulfurListHandle(this, component); } public void AddSpacer(float height = 20f) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("SULFUR_Spacer", new Type[2] { typeof(RectTransform), typeof(LayoutElement) }); val.transform.SetParent((Transform)(object)OptionsContainer, false); LayoutElement component = val.GetComponent<LayoutElement>(); component.minHeight = Mathf.Max(0f, height); component.preferredHeight = Mathf.Max(0f, height); component.flexibleHeight = 0f; } public OptionsScreenOption AddReadonlyText(string label, string value) { string text = (string.IsNullOrWhiteSpace(value) ? (label ?? "") : (label + ": " + value)); return AddDescription(text); } public OptionsScreenOption AddTextInput(string label, string value, Action<string> onChanged) { return AddTextInput(label, null, value, onChanged); } public OptionsScreenOption AddTextInput(string label, string description, string value, Action<string> onChanged) { OptionsScreenOption result = AddInfo(label); AddDescription(description); TMP_InputField obj = CreateStandaloneInputField("TextInput_" + label, value ?? "", "Enter text...", (ContentType)0); ((UnityEventBase)obj.onValueChanged).RemoveAllListeners(); ((UnityEvent<string>)(object)obj.onValueChanged).AddListener((UnityAction<string>)delegate(string text) { if (onChanged != null) { onChanged(text); } }); return result; } public OptionsScreenOption AddNumberInput(string label, float value, float min, float max, int decimals, Action<float> onChanged) { return AddNumberInput(label, null, value, min, max, decimals, onChanged); } public OptionsScreenOption AddNumberInput(string label, string description, float value, float min, float max, int decimals, Action<float> onChanged) { OptionsScreenOption result = AddInfo(label); AddDescription(description); TMP_InputField input = CreateStandaloneInputField("NumberInput_" + label, FormatNumber(value, decimals), "Enter number...", (ContentType)3); ((UnityEventBase)input.onEndEdit).RemoveAllListeners(); ((UnityEvent<string>)(object)input.onEndEdit).AddListener((UnityAction<string>)delegate(string text) { if (!TryParseNumber(text, out var value2)) { input.SetTextWithoutNotify(FormatNumber(value, decimals)); } else { value2 = Mathf.Clamp(value2, min, max); value2 = RoundNumber(value2, decimals); input.SetTextWithoutNotify(FormatNumber(value2, decimals)); if (onChanged != null) { onChanged(value2); } } }); return result; } public TMP_InputField AddInlineTextInput(string label, string value, Action<string> onChanged, float labelWidth = 160f, bool password = false) { TMP_InputField obj = BuildInlineInputRow("SULFUR_InlineText_" + label, label, value ?? "", "Enter text...", (ContentType)(password ? 7 : 0), labelWidth); ((UnityEventBase)obj.onValueChanged).RemoveAllListeners(); ((UnityEvent<string>)(object)obj.onValueChanged).AddListener((UnityAction<string>)delegate(string text) { if (onChanged != null) { onChanged(text); } }); return obj; } public TMP_InputField AddInlineNumberInput(string label, float value, float min, float max, int decimals, Action<float> onChanged, float labelWidth = 160f) { TMP_InputField input = BuildInlineInputRow("SULFUR_InlineNumber_" + label, label, FormatNumber(value, decimals), "Enter number...", (ContentType)3, labelWidth); ((UnityEventBase)input.onEndEdit).RemoveAllListeners(); ((UnityEvent<string>)(object)input.onEndEdit).AddListener((UnityAction<string>)delegate(string text) { if (!TryParseNumber(text, out var value2)) { input.SetTextWithoutNotify(FormatNumber(value, decimals)); } else { value2 = Mathf.Clamp(value2, min, max); value2 = RoundNumber(value2, decimals); input.SetTextWithoutNotify(FormatNumber(value2, decimals)); if (onChanged != null) { onChanged(value2); } } }); return input; } private OptionsScreenOption AddTextInputInternal(string label, string value, string placeholder, ContentType contentType, Action<string> onChanged, Action<string> onEndEdit) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) return AddTextInputInternal(label, value, placeholder, contentType, onChanged, onEndEdit, null); } private OptionsScreenOption AddTextInputInternal(string label, string value, string placeholder, ContentType contentType, Action<string> onChanged, Action<string> onEndEdit, Action<TMP_InputField> afterCreate) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Expected O, but got Unknown GameObject optionButtonPrefab = SulfurOptionsScreenBridge.GetOptionButtonPrefab(optionsScreen); OptionsScreenOption val = InstantiateOption(optionButtonPrefab); val.SetLabel(label ?? ""); TMP_InputField input = CreateInputFieldOnOption(val, value ?? "", placeholder ?? "", contentType); ((Component)input).gameObject.AddComponent<SulfurTextInputBinding>().Configure(input); ((UnityEventBase)input.onValueChanged).RemoveAllListeners(); ((UnityEvent<string>)(object)input.onValueChanged).AddListener((UnityAction<string>)delegate(string text) { if (onChanged != null) { onChanged(text); } }); ((UnityEventBase)input.onEndEdit).RemoveAllListeners(); ((UnityEvent<string>)(object)input.onEndEdit).AddListener((UnityAction<string>)delegate(string text) { if (onEndEdit != null) { onEndEdit(text); } }); val.onButtonPressed = (OnButtonPressed)delegate { if ((Object)(object)EventSystem.current != (Object)null) { EventSystem.current.SetSelectedGameObject(((Component)input).gameObject); } input.ActivateInputField(); }; afterCreate?.Invoke(input); RegisterOption(val); return val; } private TMP_InputField CreateInputFieldOnOption(OptionsScreenOption option, string value, string placeholder, ContentType contentType) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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_00b5: 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_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Expected O, but got Unknown //IL_0133: 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_0155: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) ((Component)option).GetComponent<RectTransform>(); TextMeshProUGUI optionLabelText = SulfurOptionsScreenBridge.GetOptionLabelText(option); GameObject val = new GameObject("SULFUR_TMP_InputField", new Type[4] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image), typeof(TMP_InputField) }); val.transform.SetParent(((Component)option).transform, false); RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = new Vector2(0.52f, 0.18f); component.anchorMax = new Vector2(0.98f, 0.82f); component.pivot = new Vector2(0.5f, 0.5f); component.offsetMin = Vector2.zero; component.offsetMax = Vector2.zero; Image component2 = val.GetComponent<Image>(); ((Graphic)component2).color = new Color(1f, 1f, 1f, 0.08f); ((Graphic)component2).raycastTarget = true; GameObject val2 = new GameObject("Text Area", new Type[2] { typeof(RectTransform), typeof(RectMask2D) }); val2.transform.SetParent(val.transform, false); RectTransform component3 = val2.GetComponent<RectTransform>(); component3.anchorMin = Vector2.zero; component3.anchorMax = Vector2.one; component3.offsetMin = new Vector2(8f, 2f); component3.offsetMax = new Vector2(-8f, -2f); TextMeshProUGUI val3 = CreateInputText(val2.transform, "Placeholder", placeholder, optionLabelText); ((Graphic)val3).color = new Color(1f, 1f, 1f, 0.35f); ((TMP_Text)val3).fontStyle = (FontStyles)2; TextMeshProUGUI val4 = CreateInputText(val2.transform, "Text", value, optionLabelText); ((Graphic)val4).color = (((Object)(object)optionLabelText != (Object)null) ? ((Graphic)optionLabelText).color : Color.white); TMP_InputField component4 = val.GetComponent<TMP_InputField>(); component4.textViewport = component3; component4.textComponent = (TMP_Text)(object)val4; component4.placeholder = (Graphic)(object)val3; ((Selectable)component4).targetGraphic = (Graphic)(object)component2; component4.contentType = contentType; component4.lineType = (LineType)0; component4.shouldActivateOnSelect = true; component4.onFocusSelectAll = false; component4.resetOnDeActivation = false; component4.restoreOriginalTextOnEscape = false; component4.SetTextWithoutNotify(value ?? ""); return component4; } private TextMeshProUGUI CreateInputText(Transform parent, string name, string text, TextMeshProUGUI template) { //IL_002e: 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_0040: 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_0052: 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_0067: 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_00db: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name, new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(TextMeshProUGUI) }); val.transform.SetParent(parent, false); RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.offsetMin = Vector2.zero; component.offsetMax = Vector2.zero; TextMeshProUGUI component2 = val.GetComponent<TextMeshProUGUI>(); ((TMP_Text)component2).text = text ?? ""; ((Graphic)component2).raycastTarget = false; ((TMP_Text)component2).alignment = (TextAlignmentOptions)4097; ((TMP_Text)component2).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)component2).overflowMode = (TextOverflowModes)0; if ((Object)(object)template != (Object)null) { ((TMP_Text)component2).font = ((TMP_Text)template).font; ((TMP_Text)component2).fontSharedMaterial = ((TMP_Text)template).fontSharedMaterial; ((TMP_Text)component2).fontSize = ((TMP_Text)template).fontSize; ((Graphic)component2).color = ((Graphic)template).color; } else { ((TMP_Text)component2).fontSize = 20f; ((Graphic)component2).color = Color.white; } return component2; } internal IEnumerable<Transform> GetChildrenFrom(int startIndex) { if ((Object)(object)OptionsContainer == (Object)null) { yield break; } int num = Mathf.Clamp(startIndex, 0, ((Transform)OptionsContainer).childCount); for (int i = num; i < ((Transform)OptionsContainer).childCount; i++) { Transform child = ((Transform)OptionsContainer).GetChild(i); if ((Object)(object)child != (Object)null) { yield return child; } } } internal int GetChildCount() { if (!((Object)(object)OptionsContainer != (Object)null)) { return 0; } return ((Transform)OptionsContainer).childCount; } private OptionsScreenOption InstantiateOption(GameObject prefab) { if ((Object)(object)prefab == (Object)null) { throw new InvalidOperationException("Option prefab is null."); } GameObject obj = Object.Instantiate<GameObject>(prefab, (Transform)(object)OptionsContainer); obj.SetActive(true); OptionsScreenOption component = obj.GetComponent<OptionsScreenOption>(); if ((Object)(object)component == (Object)null) { throw new InvalidOperationException("Instantiated prefab does not contain OptionsScreenOption."); } return component; } private void RegisterOption(OptionsScreenOption option) { if (!((Object)(object)option == (Object)null)) { nativeOptions.Add(option); } } private static void BindCycleButtons(OptionsScreenOption option, SulfurOptionBinding binding) { //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Expected O, but got Unknown if ((Object)(object)option == (Object)null || (Object)(object)binding == (Object)null) { return; } Button[] componentsInChildren = ((Component)option).GetComponentsInChildren<Button>(true); if (componentsInChildren == null || componentsInChildren.Length == 0) { return; } List<Button> list = new List<Button>(); Button[] array = componentsInChildren; foreach (Button val in array) { if (!((Object)(object)val == (Object)null)) { list.Add(val); } } if (list.Count == 0) { return; } list.Sort(delegate(Button a, Button b) { //IL_001f: 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) RectTransform component = ((Component)a).GetComponent<RectTransform>(); RectTransform component2 = ((Component)b).GetComponent<RectTransform>(); float num2 = (((Object)(object)component != (Object)null) ? component.anchoredPosition.x : 0f); float value = (((Object)(object)component2 != (Object)null) ? component2.anchoredPosition.x : 0f); return num2.CompareTo(value); }); for (int num = 0; num < list.Count; num++) { Button button = list[num]; int direction = DetectCycleButtonDirection(button, num, list.Count); ReplaceButtonClick(button, (UnityAction)delegate { binding.MoveCycle(direction); }); } } private static int DetectCycleButtonDirection(Button button, int index, int count) { if ((Object)(object)button != (Object)null) { string text = ((Object)((Component)button).gameObject).name.ToLowerInvariant(); if (text.Contains("left") || text.Contains("prev") || text.Contains("previous") || text.Contains("minus")) { return -1; } if (text.Contains("right") || text.Contains("next") || text.Contains("plus")) { return 1; } } if (count <= 1) { return 1; } if (index != 0) { return 1; } return -1; } private static void ReplaceButtonClick(Button button, UnityAction action) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown if (!((Object)(object)button == (Object)null)) { button.onClick = new ButtonClickedEvent(); if (action != null) { ((UnityEvent)button.onClick).AddListener(action); } } } private void CreateBadge(Transform parent, string text) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_010b: 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_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0129: 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_0149: 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_0217: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI val = FindSampleText(); GameObject val2 = new GameObject("Badge_" + text, new Type[4] { typeof(RectTransform), typeof(LayoutElement), typeof(CanvasRenderer), typeof(Image) }); val2.transform.SetParent(parent, false); Image component = val2.GetComponent<Image>(); ((Graphic)component).color = new Color(1f, 1f, 1f, 0.08f); ((Graphic)component).raycastTarget = false; LayoutElement component2 = val2.GetComponent<LayoutElement>(); component2.minWidth = Mathf.Clamp((float)text.Length * 9f + 26f, 70f, 220f); component2.preferredWidth = component2.minWidth; component2.minHeight = 26f; component2.preferredHeight = 26f; GameObject val3 = new GameObject("Label", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(TextMeshProUGUI) }); val3.transform.SetParent(val2.transform, false); RectTransform component3 = val3.GetComponent<RectTransform>(); component3.anchorMin = Vector2.zero; component3.anchorMax = Vector2.one; component3.offsetMin = new Vector2(8f, 0f); component3.offsetMax = new Vector2(-8f, 0f); TextMeshProUGUI component4 = val3.GetComponent<TextMeshProUGUI>(); ((TMP_Text)component4).text = text; ((TMP_Text)component4).alignment = (TextAlignmentOptions)514; ((Graphic)component4).raycastTarget = false; ((TMP_Text)component4).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)component4).overflowMode = (TextOverflowModes)1; if ((Object)(object)val != (Object)null) { ((TMP_Text)component4).font = ((TMP_Text)val).font; ((TMP_Text)component4).fontSize = Mathf.Max(11f, ((TMP_Text)val).fontSize * 0.52f); ((Graphic)component4).color = new Color(((Graphic)val).color.r, ((Graphic)val).color.g, ((Graphic)val).color.b, 0.82f); } else { ((TMP_Text)component4).fontSize = 14f; ((Graphic)component4).color = new Color(1f, 1f, 1f, 0.82f); } } private Button CreateSmallButton(Transform parent, string label, Action onPressed) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown //IL_006f: 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_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_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0114: 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_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01af: 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_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Expected O, but got Unknown //IL_0273: 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) GameObject val = new GameObject("SULFUR_SmallButton", new Type[5] { typeof(RectTransform), typeof(LayoutElement), typeof(CanvasRenderer), typeof(Image), typeof(Button) }); val.transform.SetParent(parent, false); val.GetComponent<RectTransform>().sizeDelta = new Vector2(120f, 34f); LayoutElement component = val.GetComponent<LayoutElement>(); component.minHeight = 34f; component.preferredHeight = 34f; component.minWidth = 120f; component.preferredWidth = 120f; Image component2 = val.GetComponent<Image>(); ((Graphic)component2).color = new Color(1f, 1f, 1f, 0.08f); ((Graphic)component2).raycastTarget = true; Button component3 = val.GetComponent<Button>(); ((Selectable)component3).targetGraphic = (Graphic)(object)component2; ((Selectable)component3).transition = (Transition)1; ColorBlock colors = ((Selectable)component3).colors; ((ColorBlock)(ref colors)).disabledColor = new Color(1f, 1f, 1f, 0.35f); ((Selectable)component3).colors = colors; ((UnityEventBase)component3.onClick).RemoveAllListeners(); if (onPressed != null) { ((UnityEvent)component3.onClick).AddListener(new UnityAction(onPressed.Invoke)); } GameObject val2 = new GameObject("Text", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(TextMeshProUGUI) }); val2.transform.SetParent(val.transform, false); RectTransform component4 = val2.GetComponent<RectTransform>(); component4.anchorMin = Vector2.zero; component4.anchorMax = Vector2.one; component4.offsetMin = new Vector2(8f, 0f); component4.offsetMax = new Vector2(-8f, 0f); TextMeshProUGUI val3 = FindSampleText(); TextMeshProUGUI component5 = val2.GetComponent<TextMeshProUGUI>(); ((TMP_Text)component5).text = label ?? ""; ((TMP_Text)component5).alignment = (TextAlignmentOptions)4098; ((Graphic)component5).raycastTarget = false; ((TMP_Text)component5).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)component5).overflowMode = (TextOverflowModes)1; if ((Object)(object)val3 != (Object)null) { ((TMP_Text)component5).font = ((TMP_Text)val3).fo