Decompiled source of SULFUR Native UI Lib v0.11.1
SULFUR Native UI Lib.dll
Decompiled 2 days 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 I2.Loc; 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.11.1.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("0.11.1.0")] namespace Ryuka.Sulfur.NativeUI; [BepInPlugin("ryuka.sulfur.nativeui", "SULFUR Native UI Lib", "0.11.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.11.1"; private Harmony harmony; internal static ManualLogSource Log { get; private set; } private void Awake() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; SulfurLocalization.LoadPluginLocalization("ryuka.sulfur.nativeui", ((BaseUnityPlugin)this).Info.Location); harmony = new Harmony("ryuka.sulfur.nativeui"); harmony.PatchAll(); SulfurGameFonts.Install(harmony); SulfurGameLanguage.Install(harmony); SulfurLanguage.Initialize(); SulfurFontFallback.EnsureRegistered(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"SULFUR Native UI Lib loaded."); } private void Update() { if (!SulfurLanguage.IsReady) { SulfurLanguage.ConvergeInitial(); } } private void OnDestroy() { if (harmony != null) { harmony.UnpatchSelf(); harmony = null; } } } internal static class SulfurReflection { private struct MemberKey : IEquatable<MemberKey> { private readonly Type type; private readonly string name; public MemberKey(Type type, string name) { this.type = type; this.name = name; } public bool Equals(MemberKey other) { if (type == other.type) { return string.Equals(name, other.name, StringComparison.Ordinal); } return false; } public override bool Equals(object obj) { if (obj is MemberKey) { return Equals((MemberKey)obj); } return false; } public override int GetHashCode() { return (((type != null) ? type.GetHashCode() : 0) * 397) ^ ((name != null) ? StringComparer.Ordinal.GetHashCode(name) : 0); } } private static readonly object cacheLock = new object(); private static readonly Dictionary<MemberKey, FieldInfo> fieldCache = new Dictionary<MemberKey, FieldInfo>(); private static readonly Dictionary<MemberKey, MethodInfo> methodCache = new Dictionary<MemberKey, MethodInfo>(); public static T GetField<T>(object obj, string fieldName) { if (obj == null || string.IsNullOrWhiteSpace(fieldName)) { return default(T); } FieldInfo fieldInfo = ResolveField(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 = ResolveField(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 = ResolveMethod(obj.GetType(), methodName); if (methodInfo == null) { return null; } return methodInfo.Invoke(obj, args); } private static FieldInfo ResolveField(Type type, string name) { MemberKey key = new MemberKey(type, name); lock (cacheLock) { if (fieldCache.TryGetValue(key, out var value)) { return value; } } FieldInfo fieldInfo = AccessTools.Field(type, name); lock (cacheLock) { if (fieldCache.TryGetValue(key, out var value2)) { return value2; } fieldCache[key] = fieldInfo; } if (fieldInfo == null) { WarnMissing("field", type, name); } return fieldInfo; } private static MethodInfo ResolveMethod(Type type, string name) { MemberKey key = new MemberKey(type, name); lock (cacheLock) { if (methodCache.TryGetValue(key, out var value)) { return value; } } MethodInfo methodInfo = AccessTools.Method(type, name, (Type[])null, (Type[])null); lock (cacheLock) { if (methodCache.TryGetValue(key, out var value2)) { return value2; } methodCache[key] = methodInfo; } if (methodInfo == null) { WarnMissing("method", type, name); } return methodInfo; } private static void WarnMissing(string kind, Type type, string name) { if (Plugin.Log != null) { Plugin.Log.LogWarning((object)("SULFUR Native UI: " + kind + " '" + name + "' not found on " + type.FullName + ". The game may have changed; UI that depends on it will not work.")); } } } 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 const float RetryIntervalSeconds = 30f; private const int MaxBuildAttempts = 5; private static int failedAttempts; private static float nextAttemptTime; private static readonly HashSet<string> missingSourceLogged = new HashSet<string>(); 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 || failedAttempts >= 5 || (failedAttempts >= 2 && Time.unscaledTime < nextAttemptTime)) { return; } try { TMP_FontAsset val = BuildFromSource(Sources[0]); if ((Object)(object)val == (Object)null) { OnAttemptFailed(); 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: " + ex.Message)); } OnAttemptFailed(); } } private static void OnAttemptFailed() { failedAttempts++; nextAttemptTime = Time.unscaledTime + 30f; if (failedAttempts >= 5) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("Glyph fallback: giving up after " + failedAttempts + " attempts; non-Latin glyphs missing from the game font may not render.")); } } } 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; } if (missingSourceLogged.Add(source.Label)) { 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 SulfurFontRole { RoundRegular, RoundSemibold, RoundBold, SerifRegular, SerifSemibold, SerifBold } public static class SulfurFonts { private struct Binding { public WeakReference Text; public SulfurFontRole Role; } private const int MinPruneThreshold = 64; private static readonly Dictionary<int, Binding> bindings; private static readonly List<int> deadKeys; private static int pruneThreshold; private static readonly TMP_FontAsset[] lastSeen; private static bool reapplying; private const int RoleCount = 6; public static event Action FontsChanged; static SulfurFonts() { bindings = new Dictionary<int, Binding>(); deadKeys = new List<int>(); pruneThreshold = 64; lastSeen = (TMP_FontAsset[])(object)new TMP_FontAsset[6]; SulfurGameFonts.CacheLoaded += OnGameCacheLoaded; } public static TMP_FontAsset Get(SulfurFontRole role) { ValidateRole(role); TMP_FontAsset val = SulfurGameFonts.TryGet(role); if ((Object)(object)val != (Object)null) { Remember(role, val); } else { val = DefaultFont(); } return WithFallback(val); } public static void Bind(TMP_Text text, SulfurFontRole role) { ValidateRole(role); if (!((Object)(object)text == (Object)null)) { Apply(text, Get(role)); bindings[((Object)text).GetInstanceID()] = new Binding { Text = new WeakReference(text), Role = role }; if (bindings.Count >= pruneThreshold) { Prune(); pruneThreshold = Math.Max(64, bindings.Count * 2); } } } public static TMP_FontAsset WithFallback(TMP_FontAsset font) { if ((Object)(object)font != (Object)null) { SulfurFontFallback.EnsureFontHasFallback(font); } return font; } private static void OnGameCacheLoaded() { if (reapplying) { return; } bool flag = false; for (int i = 0; i < 6; i++) { TMP_FontAsset val = SulfurGameFonts.PeekCached((SulfurFontRole)i); if (!((Object)(object)val == (Object)null) && val != lastSeen[i]) { lastSeen[i] = val; flag = true; } } if (flag) { reapplying = true; try { Reapply(); } finally { reapplying = false; } ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)("Role fonts updated: " + DescribeCache())); } RaiseFontsChanged(); } } private static void Reapply() { deadKeys.Clear(); foreach (KeyValuePair<int, Binding> binding in bindings) { object? target = binding.Value.Text.Target; TMP_Text val = (TMP_Text)((target is TMP_Text) ? target : null); if ((Object)(object)val == (Object)null) { deadKeys.Add(binding.Key); } else { Apply(val, Get(binding.Value.Role)); } } RemoveDead(); } private static void Prune() { deadKeys.Clear(); foreach (KeyValuePair<int, Binding> binding in bindings) { object? target = binding.Value.Text.Target; if ((Object)((target is TMP_Text) ? target : null) == (Object)null) { deadKeys.Add(binding.Key); } } RemoveDead(); } private static void RemoveDead() { foreach (int deadKey in deadKeys) { bindings.Remove(deadKey); } deadKeys.Clear(); } private static void Apply(TMP_Text text, TMP_FontAsset font) { if (!((Object)(object)font == (Object)null) && !((Object)(object)text.font == (Object)(object)font)) { text.font = font; if ((Object)(object)((TMP_Asset)font).material != (Object)null) { text.fontSharedMaterial = ((TMP_Asset)font).material; } } } private static void Remember(SulfurFontRole role, TMP_FontAsset font) { lastSeen[(int)role] = font; } private static TMP_FontAsset DefaultFont() { try { return TMP_Settings.defaultFontAsset; } catch (Exception) { return null; } } private static void RaiseFontsChanged() { Action fontsChanged = SulfurFonts.FontsChanged; if (fontsChanged == null) { return; } Delegate[] invocationList = fontsChanged.GetInvocationList(); foreach (Delegate obj in invocationList) { try { ((Action)obj)(); } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("SulfurFonts.FontsChanged subscriber threw: " + ex)); } } } } private static string DescribeCache() { string[] array = new string[6]; for (int i = 0; i < 6; i++) { TMP_FontAsset val = lastSeen[i]; int num = i; SulfurFontRole sulfurFontRole = (SulfurFontRole)i; array[num] = sulfurFontRole.ToString() + "=" + (((Object)(object)val != (Object)null) ? ((Object)val).name : "-"); } return string.Join(", ", array); } private static void ValidateRole(SulfurFontRole role) { if (role < SulfurFontRole.RoundRegular || role > SulfurFontRole.SerifBold) { throw new ArgumentOutOfRangeException("role", role, "Unknown SulfurFontRole."); } } } internal static class SulfurGameFonts { private static bool unsupported; public static bool Unsupported => unsupported; internal static event Action CacheLoaded; public static void Install(Harmony harmony) { if (unsupported || harmony == null) { return; } try { InstallCore(harmony); ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)"Role fonts: hooked FontLocalizer.LoadFontCache."); } } catch (Exception ex) { MarkUnsupported("hooking FontLocalizer.LoadFontCache failed: " + ex.Message); } } public static TMP_FontAsset TryGet(SulfurFontRole role) { if (unsupported) { return null; } int index = ToGameIndex(role); try { return TryGetCore(index, loadIfEmpty: true); } catch (Exception ex) { MarkUnsupported("reading the game's font cache failed: " + ex.Message); return null; } } public static TMP_FontAsset PeekCached(SulfurFontRole role) { if (unsupported) { return null; } int index = ToGameIndex(role); try { return TryGetCore(index, loadIfEmpty: false); } catch (Exception ex) { MarkUnsupported("reading the game's font cache failed: " + ex.Message); return null; } } [MethodImpl(MethodImplOptions.NoInlining)] private static void InstallCore(Harmony harmony) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.Method(typeof(FontLocalizer), "LoadFontCache", (Type[])null, (Type[])null); if (methodInfo == null) { throw new MissingMethodException("FontLocalizer", "LoadFontCache"); } MethodInfo methodInfo2 = AccessTools.Method(typeof(SulfurGameFonts), "LoadFontCachePostfix", (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } [MethodImpl(MethodImplOptions.NoInlining)] private static TMP_FontAsset TryGetCore(int index, bool loadIfEmpty) { AsyncAssetLoading instance = StaticInstance<AsyncAssetLoading>.Instance; if ((Object)(object)instance == (Object)null) { return null; } TMP_FontAsset[] fontCache = instance.fontCache; if (fontCache == null || index >= fontCache.Length) { throw new InvalidOperationException("fontCache has an unexpected shape"); } if ((Object)(object)fontCache[index] == (Object)null && loadIfEmpty) { FontLocalizer.LoadFontCache(); fontCache = instance.fontCache; } TMP_FontAsset val = fontCache[index]; if (!((Object)(object)val != (Object)null)) { return null; } return val; } private static int ToGameIndex(SulfurFontRole role) { return role switch { SulfurFontRole.RoundRegular => 0, SulfurFontRole.RoundSemibold => 1, SulfurFontRole.RoundBold => 2, SulfurFontRole.SerifRegular => 3, SulfurFontRole.SerifSemibold => 4, SulfurFontRole.SerifBold => 5, _ => throw new ArgumentOutOfRangeException("role", role, "Unknown SulfurFontRole."), }; } private static void LoadFontCachePostfix() { Action cacheLoaded = SulfurGameFonts.CacheLoaded; if (cacheLoaded == null) { return; } try { cacheLoaded(); } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("Role fonts: refresh after LoadFontCache failed: " + ex)); } } } private static void MarkUnsupported(string reason) { if (!unsupported) { unsupported = true; ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("Role fonts are not supported by this game version (" + reason + "). Using TMP's default font with glyph fallback instead.")); } } } } 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."); } SulfurOptionsPage page2 = GetPage(page.PageId); if (page2 != null && page2 != page && Plugin.Log != null) { Plugin.Log.LogWarning((object)("SULFUR native options page id '" + page.PageId + "' is already registered by " + Describe(page2) + "; replacing it with the page from " + Describe(page) + ".")); } 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)); } } private static string Describe(SulfurOptionsPage page) { string text = "'" + (page.DisplayName ?? page.PageId) + "'"; try { MethodInfo methodInfo = ((page.BuildPage != null) ? page.BuildPage.Method : null); if (methodInfo == null || methodInfo.DeclaringType == null) { return text; } Type declaringType = methodInfo.DeclaringType; return text + " (" + declaringType.Assembly.GetName().Name + ": " + declaringType.FullName + "." + methodInfo.Name + ")"; } catch { return text; } } 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; internal const SulfurFontRole OptionsFontRole = SulfurFontRole.SerifRegular; private const float FallbackSampleFontSize = 22f; private TextMeshProUGUI sampleTextCache; private bool sampleTextCacheInitialized; private float nativeOptionWidthCache = -1f; private bool invalidated; private bool deadUseLogged; private readonly List<int> insertPathBuffer = new List<int>(); private readonly List<int> comparePathBuffer = new List<int>(); internal const string BadgeObjectPrefix = "Badge_"; public OptionsScreen OptionsScreen => optionsScreen; public RectTransform OptionsContainer => currentOptionsContainer ?? rootOptionsContainer; public string PageId => pageId; public bool IsAlive { get { if (!invalidated && (Object)(object)optionsScreen != (Object)null) { return (Object)(object)rootOptionsContainer != (Object)null; } return false; } } internal SulfurOptionsContext(OptionsScreen optionsScreen, RectTransform optionsContainer, List<OptionsScreenOption> nativeOptions, string pageId) { this.optionsScreen = optionsScreen; rootOptionsContainer = optionsContainer; currentOptionsContainer = optionsContainer; this.nativeOptions = nativeOptions; this.pageId = pageId; } internal void Invalidate() { invalidated = true; } internal bool EnsureAlive(string operation) { if (IsAlive) { return true; } if (!deadUseLogged) { deadUseLogged = true; if (Plugin.Log != null) { Plugin.Log.LogWarning((object)("SULFUR Native UI: " + operation + " was called on the options context of page '" + pageId + "' after that page was closed or rebuilt; ignored. Use the context passed to the current BuildPage call (see SulfurOptionsContext.IsAlive). Further calls on this context are ignored silently.")); } } return false; } public void Rebuild() { if (!IsAlive || !optionsScreen.IsShown) { return; } SulfurButtonRowNavigator.FocusCarry previous = BeginButtonFocusCarry(); try { SulfurOptionsScreenBridge.RebuildCurrentCustomPage(optionsScreen); } finally { SulfurButtonRowNavigator.EndFocusCarry(previous); } } public void SetFooter(string leftText, string statusText, string primaryButtonText, Action onPrimaryPressed) { if (IsAlive) { SulfurOptionsScreenBridge.SetCustomPageFooter(optionsScreen, leftText, statusText, primaryButtonText, onPrimaryPressed); } } public void SetFooterStatus(string statusText) { if (IsAlive) { 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014b: 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_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0172: 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_018b: Expected O, but got Unknown //IL_01b8: 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_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) if (!EnsureAlive("BeginThemedGroup")) { return new SulfurContainerScope(this, null, active: false); } 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() { if (IsAlive) { SulfurOptionsScreenBridge.ClearCustomPageFooter(optionsScreen); } } public OptionsScreenOption AddButton(string label, Action onPressed) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown if (!EnsureAlive("AddButton")) { return null; } OptionsScreenOption val = InstantiateButtonOption(); 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) { if (!EnsureAlive("AddInfo")) { return null; } return AddInfoRow(label, register: true); } private OptionsScreenOption AddInfoRow(string label, bool register) { GameObject optionInfoPrefab = SulfurOptionsScreenBridge.GetOptionInfoPrefab(optionsScreen); OptionsScreenOption val = (((Object)(object)optionInfoPrefab != (Object)null) ? InstantiateOption(optionInfoPrefab) : InstantiateButtonOption()); val.SetLabel(label ?? ""); if (register) { RegisterOption(val); } return val; } public OptionsScreenOption AddToggle(string label, bool value, Action<bool> onChanged) { if (!EnsureAlive("AddToggle")) { return null; } Toggle toggle; SulfurOptionBinding binding; return BuildToggleOption(label, value, onChanged, out toggle, out binding); } public OptionsScreenOption AddToggle(string label, string description, bool value, Action<bool> onChanged) { OptionsScreenOption result = AddToggle(label, value, onChanged); AddDescription(description); return result; } internal OptionsScreenOption AddToggleCore(string label, string description, bool value, Action<bool> onChanged, out Toggle toggle, out SulfurOptionBinding binding) { toggle = null; binding = null; if (!EnsureAlive("AddToggle")) { return null; } OptionsScreenOption result = BuildToggleOption(label, value, onChanged, out toggle, out binding); AddDescription(description); return result; } public SulfurToggleHandle AddToggleRow(string label, bool value, Action<bool> onChanged) { return AddToggleRow(label, null, value, onChanged); } public SulfurToggleHandle AddToggleRow(string label, string description, bool value, Action<bool> onChanged) { if (!EnsureAlive("AddToggleRow")) { return new SulfurToggleHandle(null, null); } Toggle toggle; SulfurOptionBinding binding; OptionsScreenOption option = BuildToggleOption(label, value, onChanged, out toggle, out binding); GameObject descriptionRow = AddDescriptionRow(description); return new SulfurToggleHandle(new SulfurOptionRowParts(this, option, binding, descriptionRow), toggle); } private OptionsScreenOption BuildToggleOption(string label, bool value, Action<bool> onChanged, out Toggle toggle, out SulfurOptionBinding binding) { GameObject optionBoolPrefab = SulfurOptionsScreenBridge.GetOptionBoolPrefab(optionsScreen); OptionsScreenOption val = InstantiateOption(optionBoolPrefab); val.SetLabel(label ?? ""); binding = ((Component)val).gameObject.AddComponent<SulfurOptionBinding>(); toggle = ((Component)val).GetComponentInChildren<Toggle>(true); if ((Object)(object)toggle != (Object)null) { toggle.SetIsOnWithoutNotify(value); ((UnityEventBase)toggle.onValueChanged).RemoveAllListeners(); binding.BindToggle(toggle, delegate(bool state) { if (onChanged != null) { onChanged(state); } }); } val.onButtonPressed = null; RegisterOption(val); return val; } public OptionsScreenOption AddCycle(string label, IReadOnlyList<string> values, int currentIndex, Action<int, string> onChanged) { if (!EnsureAlive("AddCycle")) { return null; } SulfurOptionBinding binding; return BuildCycleOption(label, values, currentIndex, onChanged, out binding); } public SulfurCycleHandle AddCycleRow(string label, IReadOnlyList<string> values, int currentIndex, Action<int, string> onChanged) { return AddCycleRow(label, null, values, currentIndex, onChanged); } public SulfurCycleHandle AddCycleRow(string label, string description, IReadOnlyList<string> values, int currentIndex, Action<int, string> onChanged) { if (!EnsureAlive("AddCycleRow")) { return new SulfurCycleHandle(null); } SulfurOptionBinding binding; OptionsScreenOption option = BuildCycleOption(label, values, currentIndex, onChanged, out binding); GameObject descriptionRow = AddDescriptionRow(description); return new SulfurCycleHandle(new SulfurOptionRowParts(this, option, binding, descriptionRow)); } private OptionsScreenOption BuildCycleOption(string label, IReadOnlyList<string> values, int currentIndex, Action<int, string> onChanged, out SulfurOptionBinding binding) { 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]; } binding = ((Component)val).gameObject.AddComponent<SulfurOptionBinding>(); binding.CycleValues = list; binding.CycleIndex = num; binding.CycleLabel = alternativeLabelText; binding.OnCycleChanged = onChanged; BindCycleButtons(val, binding); binding.OnUse = null; binding.OnHorizontal = binding.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; } internal OptionsScreenOption AddCycleCore(string label, string description, IReadOnlyList<string> values, int currentIndex, Action<int, string> onChanged, out SulfurOptionBinding binding) { binding = null; if (!EnsureAlive("AddCycle")) { return null; } OptionsScreenOption result = BuildCycleOption(label, values, currentIndex, onChanged, out binding); AddDescription(description); return result; } public OptionsScreenOption AddSlider(string label, float value, float min, float max, float step, Action<float> onChanged) { if (!EnsureAlive("AddSlider")) { return null; } Slider slider; TextMeshProUGUI valueText; SulfurOptionBinding binding; return BuildSliderOption(label, value, min, max, step, onChanged, snapDrags: false, out slider, out valueText, out binding); } 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; } public SulfurSliderHandle AddSliderRow(string label, float value, float min, float max, float step, Action<float> onChanged) { return AddSliderRow(label, null, value, min, max, step, onChanged); } public SulfurSliderHandle AddSliderRow(string label, string description, float value, float min, float max, float step, Action<float> onChanged) { if (!EnsureAlive("AddSliderRow")) { return new SulfurSliderHandle(null, null, null); } Slider slider; TextMeshProUGUI valueText; SulfurOptionBinding binding; OptionsScreenOption option = BuildSliderOption(label, value, min, max, step, onChanged, snapDrags: true, out slider, out valueText, out binding); GameObject descriptionRow = AddDescriptionRow(description); return new SulfurSliderHandle(new SulfurOptionRowParts(this, option, binding, descriptionRow), slider, valueText); } private OptionsScreenOption BuildSliderOption(string label, float value, float min, float max, float step, Action<float> onChanged, bool snapDrags, out Slider slider, out TextMeshProUGUI valueText, out SulfurOptionBinding binding) { GameObject optionSliderPrefab = SulfurOptionsScreenBridge.GetOptionSliderPrefab(optionsScreen); OptionsScreenOption val = InstantiateOption(optionSliderPrefab); val.SetLabel(label ?? ""); Slider rowSlider = ((Component)val).GetComponentInChildren<Slider>(true); TextMeshProUGUI rowValueText = SulfurOptionsScreenBridge.GetSliderValueText(val); slider = rowSlider; valueText = rowValueText; binding = ((Component)val).gameObject.AddComponent<SulfurOptionBinding>(); if ((Object)(object)rowSlider != (Object)null) { rowSlider.minValue = min; rowSlider.maxValue = max; rowSlider.SetValueWithoutNotify(Mathf.Clamp(value, min, max)); SetSliderText(rowValueText, rowSlider.value); ((UnityEventBase)rowSlider.onValueChanged).RemoveAllListeners(); binding.BindSlider(rowSlider, delegate(float v) { SetSliderText(rowValueText, v); if (onChanged != null) { onChanged(v); } }, snapDrags ? step : 0f); } binding.OnHorizontal = delegate(int delta) { if (!((Object)(object)rowSlider == (Object)null)) { float num = ((step > 0f) ? step : ((max - min) / 20f)); rowSlider.value = Mathf.Clamp(rowSlider.value + num * (float)delta, min, max); } }; RegisterOption(val); return val; } 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 = SulfurOptionsScreenBridge.FindOptionPrefabSampleText(optionsScreen); TMP_FontAsset val2 = SulfurFonts.Get(SulfurFontRole.SerifRegular); if ((Object)(object)val2 == (Object)null || ((Object)(object)val != (Object)null && (Object)(object)((TMP_Text)val).font == (Object)(object)val2)) { return val; } return BuildStyleSample(val, val2); } private TextMeshProUGUI BuildStyleSample(TextMeshProUGUI sizeSource, TMP_FontAsset font) { //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_0098: 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) GameObject val = new GameObject("SulfurStyleSample", new Type[2] { typeof(RectTransform), typeof(TextMeshProUGUI) }); val.transform.SetParent((Transform)(object)rootOptionsContainer, false); val.SetActive(false); TextMeshProUGUI component = val.GetComponent<TextMeshProUGUI>(); ((TMP_Text)component).font = font; if ((Object)(object)((TMP_Asset)font).material != (Object)null) { ((TMP_Text)component).fontSharedMaterial = ((TMP_Asset)font).material; } ((TMP_Text)component).fontSize = (((Object)(object)sizeSource != (Object)null) ? ((TMP_Text)sizeSource).fontSize : 22f); ((Graphic)component).color = (((Object)(object)sizeSource != (Object)null) ? ((Graphic)sizeSource).color : Color.white); return component; } 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; } public void AddSection(string label) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0128: 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_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0266: 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_028f: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) if (!string.IsNullOrWhiteSpace(label) && EnsureAlive("AddSection")) { 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) { AddDescriptionRow(text); return null; } private GameObject AddDescriptionRow(string text) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: 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_010a: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: 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_01a4: 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_01be: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrWhiteSpace(text) || !EnsureAlive("AddDescription")) { 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); } SulfurRowHeightFitter.Attach(val, component4, 42f); return val; } public SulfurTextHandle AddTextRow(string text) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_00ca: 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_00e1: 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_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_011c: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) if (!EnsureAlive("AddTextRow")) { return new SulfurTextHandle(null, null); } 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; } SulfurRowHeightFitter.Attach(val, component4, 42f); 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) { AddMessageRow(text, kind, createWhenEmpty: false); } internal GameObject AddMessageRow(string text, SulfurMessageKind kind, bool createWhenEmpty) { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_012c: 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_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: 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_0249: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) bool flag = string.IsNullOrWhiteSpace(text); if ((flag && !createWhenEmpty) || !EnsureAlive("AddMessage")) { return null; } 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 = (flag ? "" : (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); } SulfurRowHeightFitter.Attach(val, component5, 40f); if (flag) { val.SetActive(false); } return val; } 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) { AddBadgeRowObject(badges); } public SulfurBadgeRowHandle AddBadgeRowEx(params string[] badges) { return AddBadgeRowEx((IReadOnlyList<string>)badges); } public SulfurBadgeRowHandle AddBadgeRowEx(IReadOnlyList<string> badges) { if (!EnsureAlive("AddBadgeRowEx")) { return new SulfurBadgeRowHandle(null, null); } GameObject row = AddBadgeRowObject(SulfurBadgeRowHandle.CleanBadges(badges), createWhenEmpty: true); return new SulfurBadgeRowHandle(this, row); } internal GameObject AddBadgeRowObject(IReadOnlyList<string> badges) { return AddBadgeRowObject(badges, createWhenEmpty: false); } internal GameObject AddBadgeRowObject(IReadOnlyList<string> badges, bool createWhenEmpty) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown bool flag = badges == null || badges.Count == 0; if ((flag && !createWhenEmpty) || !EnsureAlive("AddBadgeRow")) { return null; } GameObject val = new GameObject("SULFUR_BadgeRow", new Type[3] { typeof(RectTransform), typeof(LayoutElement), typeof(SulfurBadgeFlowLayout) }); val.transform.SetParent((Transform)(object)OptionsContainer, false); RectTransform component = val.GetComponent<RectTransform>(); ApplyNativeRowRect(component, 30f); LayoutElement component2 = val.GetComponent<LayoutElement>(); component2.minWidth = GetNativeOptionWidth(); component2.preferredWidth = GetNativeOptionWidth(); val.GetComponent<SulfurBadgeFlowLayout>().Configure(30f); if (!flag) { foreach (string badge in badges) { if (!string.IsNullOrWhiteSpace(badge)) { CreateBadge(val.transform, badge.Trim()); } } } if (flag) { val.SetActive(false); } return val; } public void AddDefaultButton(Action onPressed) { AddSmallButton(SulfurUiText.DefaultButton, onPressed); } public void AddSmallButton(string label, Action onPressed) { AddSmallButton(label, onPressed, 0f); } public void AddSmallButton(string label, Action onPressed, float minWidth) { AddSmallButtonRow(label, onPressed, minWidth); } internal GameObject AddSmallButtonRow(string label, Action onPressed, float minWidth) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Expected O, but got Unknown //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) if (!EnsureAlive("AddSmallButton")) { return null; } string label2 = (string.IsNullOrWhiteSpace(label) ? SulfurUiText.DefaultButton : 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; Button button = CreateSmallButton(val.transform, label2, onPressed); ApplySmallButtonWidth(button, width); RegisterNavigationProxy(component, delegate { SulfurNavigationProxy.Press(button); }); return val; } 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Expected O, but got Unknown if (buttons == null || buttons.Count == 0 || !EnsureAlive("AddButtonRow")) { 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); List<Button> list3 = new List<Button>(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)); list3.Add(val2); } } OptionsScreenOption val3 = RegisterNavigationProxy(component, null); if ((Object)(object)val3 != (Object)null) { SulfurOptionBinding component4 = ((Component)val3).GetComponent<SulfurOptionBinding>(); SulfurButtonRowNavigator sulfurButtonRowNavigator = ((Component)val3).gameObject.AddComponent<SulfurButtonRowNavigator>(); sulfurButtonRowNavigator.Configure(component4, list3); sulfurButtonRowNavigator.RestoreCarriedFocus(pageId, nativeOptions.IndexOf(val3)); if ((Object)(object)component4 != (Object)null) { component4.OnUse = sulfurButtonRowNavigator.UseFocused; component4.OnHorizontal = sulfurButtonRowNavigator.Move; } } return list2; } public SulfurListHandle AddList() { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Expected O, but got Unknown if (!EnsureAlive("AddList")) { return new SulfurListHandle(this, null); } 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (EnsureAlive("AddSpacer")) { 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) { TMP_InputField input; return AddTextInputCore(label, description, value, onChanged, out input); } internal OptionsScreenOption AddTextInputCore(string label, string description, string value, Action<string> onChanged, out TMP_InputField input) { input = null; if (!EnsureAlive("AddTextInput")) { return null; } OptionsScreenOption result = AddInfoRow(label, register: false); AddDescription(description); TMP_InputField val = CreateStandaloneInputField("TextInput_" + label, value ?? "", SulfurUiText.TextInputPlaceholder, (ContentType)0); ((UnityEventBase)val.onValueChanged).RemoveAllListeners(); ((UnityEvent<string>)(object)val.onValueChanged).AddListener((UnityAction<string>)delegate(string text) { if (onChanged != null) { onChanged(text); } }); RegisterInputNavigation(val, ((Component)val).GetComponent<RectTransform>(), selectAllOnUse: false); input = val; 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) { SulfurNumberInput model; return AddNumberInputCore(label, description, value, min, max, decimals, onChanged, null, useDouble: false, out model); } public OptionsScreenOption AddNumberInput(string label, double value, double min, double max, int decimals, Action<double> onChanged) { return AddNumberInput(label, null, value, min, max, decimals, onChanged); } public OptionsScreenOption AddNumberInput(string label, string description, double value, double min, double max, int decimals, Action<double> onChanged) { SulfurNumberInput model; return AddNumberInputCore(label, description, value, min, max, decimals, null, onChanged, useDouble: true, out model); } internal OptionsScreenOption AddNumberInputCore(string label, string description, double value, double min, double max, int decimals, Action<float> onFloatChanged, Action<double> onDoubleChanged, bool useDouble, out SulfurNumberInput model) { model = null; if (!EnsureAlive("AddNumberInput")) { return null; } OptionsScreenOption result = AddInfoRow(label, register: false); AddDescription(description); TMP_InputField val = CreateStandaloneInputField("NumberInput_" + label, useDouble ? SulfurNumberInput.FormatDouble(value, decimals) : SulfurNumberInput.FormatFloat((float)value, decimals), SulfurUiText.NumberInputPlace