Decompiled source of Chatter v2.12.0
Chatter.dll
Decompiled a day 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.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using ComfyLib; using GUIFramework; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Chatter")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Chatter")] [assembly: AssemblyCopyright("Copyright © 2022")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("801a13e7-7e13-469e-924d-e74cad364371")] [assembly: AssemblyFileVersion("2.12.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.12.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ComfyLib { public static class CodeMatcherExtensions { public static CodeMatcher CopyOperand<T>(this CodeMatcher matcher, out T target) { target = (T)matcher.Operand; return matcher; } } public static class ConfigFileExtensions { internal sealed class ConfigurationManagerAttributes { public Action<ConfigEntryBase> CustomDrawer; public bool? Browsable; public bool? HideDefaultButton; public bool? HideSettingName; public bool? IsAdvanced; public int? Order; public bool? ReadOnly; } private static readonly Dictionary<string, int> _sectionToSettingOrder = new Dictionary<string, int>(); private static int GetSettingOrder(string section) { if (!_sectionToSettingOrder.TryGetValue(section, out var value)) { value = 0; } _sectionToSettingOrder[section] = value - 1; return value; } public static ConfigEntry<T> BindInOrder<T>(this ConfigFile config, string section, string key, T defaultValue, string description, AcceptableValueBase acceptableValues, bool browsable = true, bool hideDefaultButton = false, bool hideSettingName = false, bool isAdvanced = false, bool readOnly = false) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown return config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, acceptableValues, new object[1] { new ConfigurationManagerAttributes { Browsable = browsable, CustomDrawer = null, HideDefaultButton = hideDefaultButton, HideSettingName = hideSettingName, IsAdvanced = isAdvanced, Order = GetSettingOrder(section), ReadOnly = readOnly } })); } public static ConfigEntry<T> BindInOrder<T>(this ConfigFile config, string section, string key, T defaultValue, string description, Action<ConfigEntryBase> customDrawer = null, bool browsable = true, bool hideDefaultButton = false, bool hideSettingName = false, bool isAdvanced = false, bool readOnly = false) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown return config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Browsable = browsable, CustomDrawer = customDrawer, HideDefaultButton = hideDefaultButton, HideSettingName = hideSettingName, IsAdvanced = isAdvanced, Order = GetSettingOrder(section), ReadOnly = readOnly } })); } public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action settingChangedHandler) { configEntry.SettingChanged += delegate { settingChangedHandler(); }; } public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action<T> settingChangedHandler) { configEntry.SettingChanged += delegate(object _, EventArgs eventArgs) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) settingChangedHandler((T)((SettingChangedEventArgs)eventArgs).ChangedSetting.BoxedValue); }; } public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action<ConfigEntry<T>> settingChangedHandler) { configEntry.SettingChanged += delegate(object _, EventArgs eventArgs) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) settingChangedHandler((ConfigEntry<T>)((SettingChangedEventArgs)eventArgs).ChangedSetting.BoxedValue); }; } } public static class StringExtensions { public static readonly char[] CommaSeparator = new char[1] { ',' }; public static readonly char[] ColonSeparator = new char[1] { ':' }; public static bool TryParseValue<T>(this string text, out T value) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) try { Vector2 value2; Vector3 value3; ZDOID value4; if (typeof(T) == typeof(string)) { value = (T)(object)text; } else if (typeof(T) == typeof(Vector2) && text.TryParseVector2(out value2)) { value = (T)(object)value2; } else if (typeof(T) == typeof(Vector3) && text.TryParseVector3(out value3)) { value = (T)(object)value3; } else if (typeof(T) == typeof(ZDOID) && text.TryParseZDOID(out value4)) { value = (T)(object)value4; } else if (typeof(T).IsEnum) { value = (T)Enum.Parse(typeof(T), text); } else { value = (T)Convert.ChangeType(text, typeof(T)); } return true; } catch (Exception arg) { Debug.LogError((object)$"Failed to convert value '{text}' to type {typeof(T)}: {arg}"); } value = default(T); return false; } public static bool TryParseVector2(this string text, out Vector2 value) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) string[] array = text.Split(CommaSeparator, 2, StringSplitOptions.RemoveEmptyEntries); if (array.Length == 2 && float.TryParse(array[0], NumberStyles.Float, CultureInfo.InvariantCulture, out var result) && float.TryParse(array[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result2)) { value = new Vector2(result, result2); return true; } value = default(Vector2); return false; } public static bool TryParseVector3(this string text, out Vector3 value) { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) string[] array = text.Split(CommaSeparator, 3, StringSplitOptions.RemoveEmptyEntries); if (array.Length == 3 && float.TryParse(array[0], NumberStyles.Float, CultureInfo.InvariantCulture, out var result) && float.TryParse(array[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result2) && float.TryParse(array[2], NumberStyles.Float, CultureInfo.InvariantCulture, out var result3)) { value = new Vector3(result, result2, result3); return true; } value = default(Vector3); return false; } public static bool TryParseZDOID(this string text, out ZDOID value) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) string[] array = text.Split(ColonSeparator, 2, StringSplitOptions.RemoveEmptyEntries); if (array.Length == 2 && long.TryParse(array[0], NumberStyles.Integer, CultureInfo.InvariantCulture, out var result) && uint.TryParse(array[1], NumberStyles.Integer, CultureInfo.InvariantCulture, out var result2)) { value = new ZDOID(result, result2); return true; } value = default(ZDOID); return false; } } public static class BehaviourExtensions { public static T SetEnabled<T>(this T behaviour, bool enabled) where T : Behaviour { ((Behaviour)behaviour).enabled = enabled; return behaviour; } } public static class GameObjectExtensions { public static GameObject SetParent(this GameObject gameObject, Transform transform, bool worldPositionStays = false) { gameObject.transform.SetParent(transform, worldPositionStays); return gameObject; } } public static class ObjectExtensions { public static T FirstByNameOrThrow<T>(this IEnumerable<T> unityObjects, string name) where T : Object { foreach (T unityObject in unityObjects) { if (((Object)unityObject).name == name) { return unityObject; } } throw new InvalidOperationException($"Could not find Unity object of type {typeof(T)} with name: {name}"); } public static T Ref<T>(this T unityObject) where T : Object { if (!Object.op_Implicit((Object)(object)unityObject)) { return default(T); } return unityObject; } public static T SetName<T>(this T unityObject, string name) where T : Object { ((Object)unityObject).name = name; return unityObject; } } public sealed class DummyIgnoreDrag : MonoBehaviour, IBeginDragHandler, IEventSystemHandler, IEndDragHandler, IDragHandler { public void OnBeginDrag(PointerEventData eventData) { } public void OnDrag(PointerEventData eventData) { } public void OnEndDrag(PointerEventData eventData) { } } public static class UIBuilder { public static TextMeshProUGUI CreateLabel(Transform parentTransform) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI obj = Object.Instantiate<TextMeshProUGUI>(UnifiedPopup.instance.bodyText, parentTransform, false); ((Object)obj).name = "Label"; ((TMP_Text)obj).fontSize = 16f; ((TMP_Text)obj).richText = true; ((Graphic)obj).color = Color.white; ((TMP_Text)obj).enableAutoSizing = false; ((TMP_Text)obj).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)obj).overflowMode = (TextOverflowModes)0; ((TMP_Text)obj).text = string.Empty; return obj; } } public static class CanvasGroupExtensions { public static CanvasGroup SetAlpha(this CanvasGroup canvasGroup, float alpha) { canvasGroup.alpha = alpha; return canvasGroup; } public static CanvasGroup SetBlocksRaycasts(this CanvasGroup canvasGroup, bool blocksRaycasts) { canvasGroup.blocksRaycasts = blocksRaycasts; return canvasGroup; } } public static class ColorExtensions { public static Color SetAlpha(this Color color, float alpha) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) color.a = alpha; return color; } } public static class ContentSizeFitterExtensions { public static ContentSizeFitter SetHorizontalFit(this ContentSizeFitter fitter, FitMode fitMode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) fitter.horizontalFit = fitMode; return fitter; } public static ContentSizeFitter SetVerticalFit(this ContentSizeFitter fitter, FitMode fitMode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) fitter.verticalFit = fitMode; return fitter; } } public static class LayoutGroupExtensions { public static T SetChildAlignment<T>(this T layoutGroup, TextAnchor alignment) where T : HorizontalOrVerticalLayoutGroup { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((LayoutGroup)(object)layoutGroup).childAlignment = alignment; return layoutGroup; } public static T SetChildControl<T>(this T layoutGroup, bool? width = null, bool? height = null) where T : HorizontalOrVerticalLayoutGroup { if (!width.HasValue && !height.HasValue) { throw new ArgumentException("Value for width or height must be provided."); } if (width.HasValue) { ((HorizontalOrVerticalLayoutGroup)layoutGroup).childControlWidth = width.Value; } if (height.HasValue) { ((HorizontalOrVerticalLayoutGroup)layoutGroup).childControlHeight = height.Value; } return layoutGroup; } public static T SetChildForceExpand<T>(this T layoutGroup, bool? width = null, bool? height = null) where T : HorizontalOrVerticalLayoutGroup { if (!width.HasValue && !height.HasValue) { throw new ArgumentException("Value for width or height must be provided."); } if (width.HasValue) { ((HorizontalOrVerticalLayoutGroup)layoutGroup).childForceExpandWidth = width.Value; } if (height.HasValue) { ((HorizontalOrVerticalLayoutGroup)layoutGroup).childForceExpandHeight = height.Value; } return layoutGroup; } public static T SetPadding<T>(this T layoutGroup, int? left = null, int? right = null, int? top = null, int? bottom = null) where T : HorizontalOrVerticalLayoutGroup { if (!left.HasValue && !right.HasValue && !top.HasValue && !bottom.HasValue) { throw new ArgumentException("Value for left, right, top or bottom must be provided."); } if (left.HasValue) { ((LayoutGroup)(object)layoutGroup).padding.left = left.Value; } if (right.HasValue) { ((LayoutGroup)(object)layoutGroup).padding.right = right.Value; } if (top.HasValue) { ((LayoutGroup)(object)layoutGroup).padding.top = top.Value; } if (bottom.HasValue) { ((LayoutGroup)(object)layoutGroup).padding.bottom = bottom.Value; } return layoutGroup; } public static T SetSpacing<T>(this T layoutGroup, float spacing) where T : HorizontalOrVerticalLayoutGroup { ((HorizontalOrVerticalLayoutGroup)layoutGroup).spacing = spacing; return layoutGroup; } } public static class ImageExtensions { public static T SetColor<T>(this T image, Color color) where T : Image { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Graphic)(object)image).color = color; return image; } public static T SetFillAmount<T>(this T image, float amount) where T : Image { ((Image)image).fillAmount = amount; return image; } public static T SetFillCenter<T>(this T image, bool fillCenter) where T : Image { ((Image)image).fillCenter = fillCenter; return image; } public static T SetFillMethod<T>(this T image, FillMethod fillMethod) where T : Image { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Image)image).fillMethod = fillMethod; return image; } public static T SetFillOrigin<T>(this T image, OriginHorizontal origin) where T : Image { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected I4, but got Unknown ((Image)image).fillOrigin = (int)origin; return image; } public static T SetFillOrigin<T>(this T image, OriginVertical origin) where T : Image { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected I4, but got Unknown ((Image)image).fillOrigin = (int)origin; return image; } public static T SetMaskable<T>(this T image, bool maskable) where T : Image { ((MaskableGraphic)(object)image).maskable = maskable; return image; } public static T SetMaterial<T>(this T image, Material material) where T : Image { ((Graphic)(object)image).material = material; return image; } public static T SetPixelsPerUnitMultiplier<T>(this T image, float pixelsPerUnitMultiplier) where T : Image { ((Image)image).pixelsPerUnitMultiplier = pixelsPerUnitMultiplier; return image; } public static T SetPreserveAspect<T>(this T image, bool preserveAspect) where T : Image { ((Image)image).preserveAspect = preserveAspect; return image; } public static T SetRaycastTarget<T>(this T image, bool raycastTarget) where T : Image { ((Graphic)(object)image).raycastTarget = raycastTarget; return image; } public static T SetSprite<T>(this T image, Sprite sprite) where T : Image { ((Image)image).sprite = sprite; return image; } public static T SetType<T>(this T image, Type type) where T : Image { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Image)image).type = type; return image; } } public static class LayoutElementExtensions { public static T SetFlexible<T>(this T layoutElement, float? width = null, float? height = null) where T : LayoutElement { if (!width.HasValue && !height.HasValue) { throw new ArgumentException("Value for width or height must be provided."); } if (width.HasValue) { ((LayoutElement)layoutElement).flexibleWidth = width.Value; } if (height.HasValue) { ((LayoutElement)layoutElement).flexibleHeight = height.Value; } return layoutElement; } public static T SetIgnoreLayout<T>(this T layoutElement, bool ignoreLayout) where T : LayoutElement { ((LayoutElement)layoutElement).ignoreLayout = ignoreLayout; return layoutElement; } public static T SetMinimum<T>(this T layoutElement, float? width = null, float? height = null) where T : LayoutElement { if (!width.HasValue && !height.HasValue) { throw new ArgumentException("Value for width or height must be provided."); } if (width.HasValue) { ((LayoutElement)layoutElement).minWidth = width.Value; } if (height.HasValue) { ((LayoutElement)layoutElement).minHeight = height.Value; } return layoutElement; } public static T SetPreferred<T>(this T layoutElement, float? width = null, float? height = null) where T : LayoutElement { if (!width.HasValue && !height.HasValue) { throw new ArgumentException("Value for width or height must be provided."); } if (width.HasValue) { ((LayoutElement)layoutElement).preferredWidth = width.Value; } if (height.HasValue) { ((LayoutElement)layoutElement).preferredHeight = height.Value; } return layoutElement; } } public static class RectMask2DExtensions { public static T SetPadding<T>(this T rectMask, Vector4 padding) where T : RectMask2D { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((RectMask2D)rectMask).padding = padding; return rectMask; } public static T SetSoftness<T>(this T rectMask, Vector2Int softness) where T : RectMask2D { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((RectMask2D)rectMask).softness = softness; return rectMask; } } public static class RectTransformExtensions { public static RectTransform SetAnchorMin(this RectTransform rectTransform, Vector2 anchorMin) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) rectTransform.anchorMin = anchorMin; return rectTransform; } public static RectTransform SetAnchorMax(this RectTransform rectTransform, Vector2 anchorMax) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) rectTransform.anchorMax = anchorMax; return rectTransform; } public static RectTransform SetPivot(this RectTransform rectTransform, Vector2 pivot) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) rectTransform.pivot = pivot; return rectTransform; } public static RectTransform SetPosition(this RectTransform rectTransform, Vector2 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) rectTransform.anchoredPosition = position; return rectTransform; } public static RectTransform SetSizeDelta(this RectTransform rectTransform, Vector2 sizeDelta) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) rectTransform.sizeDelta = sizeDelta; return rectTransform; } } public static class ScrollbarExtensions { public static T SetDirection<T>(this T scrollbar, Direction direction) where T : Scrollbar { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Scrollbar)scrollbar).direction = direction; return scrollbar; } public static T SetHandleRect<T>(this T scrollbar, RectTransform handleRect) where T : Scrollbar { ((Scrollbar)scrollbar).handleRect = handleRect; return scrollbar; } } public static class SelectableExtensions { public static T SetColors<T>(this T selectable, ColorBlock colors) where T : Selectable { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Selectable)selectable).colors = colors; return selectable; } public static T SetImage<T>(this T selectable, Image image) where T : Selectable { ((Selectable)selectable).image = image; return selectable; } public static T SetInteractable<T>(this T selectable, bool interactable) where T : Selectable { ((Selectable)selectable).interactable = interactable; return selectable; } public static T SetSpriteState<T>(this T selectable, SpriteState spriteState) where T : Selectable { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Selectable)selectable).spriteState = spriteState; return selectable; } public static T SetTargetGraphic<T>(this T selectable, Graphic graphic) where T : Selectable { ((Selectable)selectable).targetGraphic = graphic; return selectable; } public static T SetTransition<T>(this T selectable, Transition transition) where T : Selectable { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Selectable)selectable).transition = transition; return selectable; } public static T SetNavigationMode<T>(this T selectable, Mode mode) where T : Selectable { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) Navigation navigation = ((Selectable)selectable).navigation; ((Navigation)(ref navigation)).mode = mode; ((Selectable)selectable).navigation = navigation; return selectable; } } public static class SliderExtensions { public static T SetDirection<T>(this T slider, Direction direction) where T : Slider { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Slider)slider).direction = direction; return slider; } public static T SetFillRect<T>(this T slider, RectTransform fillRect) where T : Slider { ((Slider)slider).fillRect = fillRect; return slider; } public static T SetHandleRect<T>(this T slider, RectTransform handleRect) where T : Slider { ((Slider)slider).handleRect = handleRect; return slider; } public static T SetMaxValue<T>(this T slider, float maxValue) where T : Slider { ((Slider)slider).maxValue = maxValue; return slider; } public static T SetMinValue<T>(this T slider, float minValue) where T : Slider { ((Slider)slider).minValue = minValue; return slider; } public static T SetWholeNumbers<T>(this T slider, bool wholeNumbers) where T : Slider { ((Slider)slider).wholeNumbers = wholeNumbers; return slider; } } public static class ScrollRectExtensions { public static T SetContent<T>(this T scrollRect, RectTransform content) where T : ScrollRect { ((ScrollRect)scrollRect).content = content; return scrollRect; } public static T SetHorizontal<T>(this T scrollRect, bool horizontal) where T : ScrollRect { ((ScrollRect)scrollRect).horizontal = horizontal; return scrollRect; } public static T SetMovementType<T>(this T scrollRect, MovementType movementType) where T : ScrollRect { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((ScrollRect)scrollRect).movementType = movementType; return scrollRect; } public static T SetScrollSensitivity<T>(this T scrollRect, float sensitivity) where T : ScrollRect { ((ScrollRect)scrollRect).scrollSensitivity = sensitivity; return scrollRect; } public static T SetVertical<T>(this T scrollRect, bool vertical) where T : ScrollRect { ((ScrollRect)scrollRect).vertical = vertical; return scrollRect; } public static T SetVerticalScrollbar<T>(this T scrollRect, Scrollbar verticalScrollbar) where T : ScrollRect { ((ScrollRect)scrollRect).verticalScrollbar = verticalScrollbar; return scrollRect; } public static T SetVerticalScrollPosition<T>(this T scrollRect, float position) where T : ScrollRect { ((ScrollRect)scrollRect).verticalNormalizedPosition = position; return scrollRect; } public static T SetVerticalScrollbarVisibility<T>(this T scrollRect, ScrollbarVisibility visibility) where T : ScrollRect { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((ScrollRect)scrollRect).verticalScrollbarVisibility = visibility; return scrollRect; } public static T SetViewport<T>(this T scrollRect, RectTransform viewport) where T : ScrollRect { ((ScrollRect)scrollRect).viewport = viewport; return scrollRect; } } public static class TextMeshProExtensions { public static T SetAlignment<T>(this T tmpText, TextAlignmentOptions alignment) where T : TMP_Text { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((TMP_Text)tmpText).alignment = alignment; return tmpText; } public static T SetCharacterSpacing<T>(this T tmpText, float characterSpacing) where T : TMP_Text { ((TMP_Text)tmpText).characterSpacing = characterSpacing; return tmpText; } public static T SetColor<T>(this T tmpText, Color color) where T : TMP_Text { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Graphic)(object)tmpText).color = color; return tmpText; } public static T SetEnableAutoSizing<T>(this T tmpText, bool enableAutoSizing) where T : TMP_Text { ((TMP_Text)tmpText).enableAutoSizing = enableAutoSizing; return tmpText; } public static T SetFont<T>(this T tmpText, TMP_FontAsset font) where T : TMP_Text { ((TMP_Text)tmpText).font = font; return tmpText; } public static T SetFontSize<T>(this T tmpText, float fontSize) where T : TMP_Text { ((TMP_Text)tmpText).fontSize = fontSize; return tmpText; } public static T SetFontMaterial<T>(this T tmpText, Material fontMaterial) where T : TMP_Text { ((TMP_Text)tmpText).fontMaterial = fontMaterial; return tmpText; } public static T SetLineSpacing<T>(this T tmpText, float lineSpacing) where T : TMP_Text { ((TMP_Text)tmpText).lineSpacing = lineSpacing; return tmpText; } public static T SetMargin<T>(this T tmpText, Vector4 margin) where T : TMP_Text { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((TMP_Text)tmpText).margin = margin; return tmpText; } public static T SetOverflowMode<T>(this T tmpText, TextOverflowModes overflowMode) where T : TMP_Text { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((TMP_Text)tmpText).overflowMode = overflowMode; return tmpText; } public static T SetRichText<T>(this T tmpText, bool richText) where T : TMP_Text { ((TMP_Text)tmpText).richText = richText; return tmpText; } public static T SetTextWrappingMode<T>(this T tmpText, TextWrappingModes textWrappingMode) where T : TMP_Text { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((TMP_Text)tmpText).textWrappingMode = textWrappingMode; return tmpText; } } public static class Texture2DExtensions { public static Texture2D SetFilterMode(this Texture2D texture, FilterMode filterMode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((Texture)texture).filterMode = filterMode; return texture; } public static Texture2D SetWrapMode(this Texture2D texture, TextureWrapMode wrapMode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((Texture)texture).wrapMode = wrapMode; return texture; } } public static class ToggleExtensions { public static T SetGraphic<T>(this T toggle, Graphic graphic) where T : Toggle { ((Toggle)toggle).graphic = graphic; return toggle; } public static T SetIsOn<T>(this T toggle, bool isOn) where T : Toggle { ((Toggle)toggle).isOn = isOn; return toggle; } public static T SetToggleTransition<T>(this T toggle, ToggleTransition toggleTransition) where T : Toggle { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) ((Toggle)toggle).toggleTransition = toggleTransition; return toggle; } } public static class UIFonts { public static readonly Lazy<Dictionary<string, string>> OsFontMap = new Lazy<Dictionary<string, string>>(delegate { Dictionary<string, string> dictionary = new Dictionary<string, string>(); string[] pathsToOSFonts = Font.GetPathsToOSFonts(); foreach (string text in pathsToOSFonts) { dictionary[Path.GetFileNameWithoutExtension(text)] = text; } return dictionary; }); public static readonly string ValheimAveriaSansLibreFont = "Valheim-AveriaSansLibre"; public static readonly string ValheimNorseFont = "Valheim-Norse"; public static readonly string ValheimNorseboldFont = "Valheim-Norsebold"; public static readonly string FallbackNotoSansNormal = "Fallback-NotoSansNormal"; private static readonly Dictionary<string, TMP_FontAsset> _fontAssetCache = new Dictionary<string, TMP_FontAsset>(); public static TMP_FontAsset ValheimAveriaSansLibreFontAsset => ((TMP_Text)UnifiedPopup.instance.bodyText).font; public static TMP_FontAsset GetFontAssetByName(string fontAssetName) { if (!_fontAssetCache.TryGetValue(fontAssetName, out var value)) { value = ((IEnumerable<TMP_FontAsset>)Resources.FindObjectsOfTypeAll<TMP_FontAsset>()).FirstOrDefault((Func<TMP_FontAsset, bool>)((TMP_FontAsset f) => ((Object)f).name == fontAssetName)); if (fontAssetName != ValheimNorseFont && fontAssetName != ValheimNorseboldFont) { ((TMP_Asset)value).material.SetFloat(ShaderUtilities.ID_OutlineWidth, 0.175f); ((TMP_Asset)value).material.SetFloat(ShaderUtilities.ID_FaceDilate, 0.175f); } _fontAssetCache[fontAssetName] = value; } return value; } } public static class UIResources { public static readonly ResourceCache<Sprite> SpriteCache = new ResourceCache<Sprite>(); public static readonly ResourceCache<Material> MaterialCache = new ResourceCache<Material>(); public static Sprite GetSprite(string spriteName) { return SpriteCache.GetResource(spriteName); } public static Material GetMaterial(string materialName) { return MaterialCache.GetResource(materialName); } } public sealed class ResourceCache<T> where T : Object { private readonly Dictionary<string, T> _cache = new Dictionary<string, T>(); public T GetResource(string resourceName) { if (!_cache.TryGetValue(resourceName, out var value)) { value = Resources.FindObjectsOfTypeAll<T>().FirstByNameOrThrow(resourceName); _cache[resourceName] = value; } return value; } } public static class UISpriteBuilder { public static readonly Color32 ColorWhite = Color32.op_Implicit(Color.white); public static readonly Color32 ColorClear = Color32.op_Implicit(Color.clear); private static readonly Dictionary<string, Sprite> _spriteCache = new Dictionary<string, Sprite>(); public static Sprite CreateRect(int width, int height, Color32 color) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) string text = $"Rectangle-{width}w-{height}h-{color}c"; if (_spriteCache.TryGetValue(text, out var value)) { return value; } Texture2D val = new Texture2D(width, height) { name = text, wrapMode = (TextureWrapMode)0, filterMode = (FilterMode)0 }; Color32[] array = (Color32[])(object)new Color32[width * height]; for (int i = 0; i < array.Length; i++) { array[i] = color; } val.SetPixels32(array); val.Apply(); value = Sprite.Create(val, new Rect(0f, 0f, (float)width, (float)height), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0); ((Object)value).name = text; _spriteCache[text] = value; return value; } public static Sprite CreateRoundedCornerSprite(int width, int height, int radius, FilterMode filterMode = 1) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: 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_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0117: 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) string text = $"RoundedCorner-{width}w-{height}h-{radius}r"; if (_spriteCache.TryGetValue(text, out var value)) { return value; } Texture2D val = ObjectExtensions.SetName<Texture2D>(new Texture2D(width, height), text).SetWrapMode((TextureWrapMode)1).SetFilterMode(filterMode); Color32[] array = (Color32[])(object)new Color32[width * height]; for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { array[i * width + j] = (IsCornerPixel(j, i, width, height, radius) ? ColorClear : ColorWhite); } } val.SetPixels32(array); val.Apply(); int k; for (k = 0; k < width && !(Color32.op_Implicit(array[k]) == Color.white); k++) { } int l; for (l = 0; l < height && !(Color32.op_Implicit(array[l * width]) == Color.white); l++) { } value = Sprite.Create(val, new Rect(0f, 0f, (float)width, (float)height), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, new Vector4((float)k, (float)l, (float)k, (float)l)).SetName<Sprite>(text); _spriteCache[text] = value; return value; } public static Sprite CreateSuperellipse(int width, int height, float exponent) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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_0113: 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_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_014f: 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_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) string text = $"Superellipse-{width}w-{height}h-{exponent}e"; if (_spriteCache.TryGetValue(text, out var value)) { return value; } Texture2D val = new Texture2D(width, height) { name = text, wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)0 }; Color32[] array = (Color32[])(object)new Color32[width * height]; int num = width / 2; int num2 = height / 2; float num3 = 1f * ((float)width / 2f); float num4 = 1f * ((float)height / 2f); for (int i = 0; i < num; i++) { for (int j = 0; j < num2; j++) { Color32 val2 = ((Mathf.Pow(Mathf.Abs((float)i / num3), exponent) + Mathf.Pow(Mathf.Abs((float)j / num4), exponent) > 1f) ? ColorClear : ColorWhite); int x2 = i + num; int x3 = -i + num - 1; int y2 = -j + num2 - 1; int y3 = j + num2; array[XYToIndex(x2, y3)] = val2; array[XYToIndex(x2, y2)] = val2; array[XYToIndex(x3, y2)] = val2; array[XYToIndex(x3, y3)] = val2; } } val.SetPixels32(array); val.Apply(); int k; for (k = 0; k < width && !(Color32.op_Implicit(array[k]) == Color.white); k++) { } int l; for (l = 0; l < height && !(Color32.op_Implicit(array[l * width]) == Color.white); l++) { } value = Sprite.Create(val, new Rect(0f, 0f, (float)width, (float)height), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, new Vector4((float)k, (float)l, (float)k, (float)l)); ((Object)value).name = text; _spriteCache[text] = value; return value; int XYToIndex(int x, int y) { return x + y * width; } } private static bool IsCornerPixel(int x, int y, int w, int h, int rad) { if (rad == 0) { return false; } int num = Math.Min(x, w - x); int num2 = Math.Min(y, h - y); if (num == 0 && num2 == 0) { return true; } if (num > rad || num2 > rad) { return false; } num = rad - num; num2 = rad - num2; return Math.Round(Math.Sqrt(num * num + num2 * num2)) > (double)rad; } } public sealed class CircularQueue<T> : ConcurrentQueue<T> { private readonly int _capacity; private readonly Action<T> _dequeueFunc; private T _lastItem; public T LastItem => _lastItem; public CircularQueue(int capacity, Action<T> dequeueFunc) { _capacity = capacity; _dequeueFunc = dequeueFunc; } public void EnqueueItem(T item) { while (base.Count + 1 > _capacity) { if (TryDequeue(out var result)) { _dequeueFunc(result); } } Enqueue(item); _lastItem = item; } public void ClearItems() { T result; while (TryDequeue(out result)) { _dequeueFunc(result); } _lastItem = default(T); } } public sealed class StringListConfigEntry { private readonly List<string> _valuesCache = new List<string>(); private string _lastFocusedControl; private string _editingValue; private static readonly Lazy<GUIStyle> _richTextLabelStyle = new Lazy<GUIStyle>((Func<GUIStyle>)(() => new GUIStyle(GUI.skin.label) { richText = true })); private static readonly Lazy<GUIStyle> _labelStyle = new Lazy<GUIStyle>((Func<GUIStyle>)(() => new GUIStyle(GUI.skin.label) { padding = new RectOffset(5, 5, 5, 5) })); private static readonly Lazy<GUIStyle> _horizontalStyle = new Lazy<GUIStyle>((Func<GUIStyle>)(() => new GUIStyle { padding = new RectOffset(10, 10, 0, 0) })); private static readonly Lazy<GUIStyle> _buttonStyle = new Lazy<GUIStyle>((Func<GUIStyle>)(() => new GUIStyle(GUI.skin.button) { padding = new RectOffset(10, 10, 5, 5) })); private static readonly Lazy<GUIStyle> _textFieldStyle = new Lazy<GUIStyle>((Func<GUIStyle>)(() => new GUIStyle(GUI.skin.textField) { padding = new RectOffset(5, 5, 5, 5), wordWrap = false })); public ConfigEntry<string> ConfigEntry { get; } public string[] ValuesSeparator { get; } public List<string> Values => ConfigEntry.Value.Split(ValuesSeparator, StringSplitOptions.RemoveEmptyEntries).ToList(); public List<string> CachedValues { get; } public event EventHandler<List<string>> ValuesChangedEvent; public StringListConfigEntry(ConfigFile configFile, string section, string key, string description, string valuesSeparator) { ConfigEntry = configFile.BindInOrder(section, key, string.Empty, description, (Action<ConfigEntryBase>)Drawer, browsable: true, hideDefaultButton: true, hideSettingName: true, isAdvanced: false, readOnly: false); ValuesSeparator = new string[1] { valuesSeparator }; CachedValues = Values.ToList(); } private void Drawer(ConfigEntryBase entry) { GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(_horizontalStyle.Value, Array.Empty<GUILayoutOption>()); GUILayout.Label("<b>" + entry.Definition.Key + "</b>\n<i>" + entry.Description.Description + "</i>", _richTextLabelStyle.Value, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUILayout.EndHorizontal(); _valuesCache.Clear(); if (!string.IsNullOrEmpty(entry.BoxedValue.ToString())) { _valuesCache.AddRange(entry.BoxedValue.ToString().Split(ValuesSeparator, StringSplitOptions.None)); } int num = -1; bool flag = false; if (!string.IsNullOrEmpty(entry.BoxedValue.ToString())) { for (int i = 0; i < _valuesCache.Count; i++) { GUILayout.BeginHorizontal(_horizontalStyle.Value, Array.Empty<GUILayoutOption>()); GUILayout.Space(5f); GUILayout.Label($"#{i:D2}", _labelStyle.Value, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); GUILayout.Space(5f); string name = $"{entry.Definition.Key}.{i}"; string value = _valuesCache[i]; if (ShowTextField(name, ref value) && _valuesCache[i] != value) { _valuesCache[i] = value; flag = true; } GUILayout.Space(10f); if (GUILayout.Button("Delete", _buttonStyle.Value, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { num = i; } GUILayout.EndHorizontal(); } } GUILayout.BeginHorizontal(_horizontalStyle.Value, Array.Empty<GUILayoutOption>()); GUILayout.Space(10f); if (GUILayout.Button("Add new entry", _buttonStyle.Value, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { _valuesCache.Add("changemeplease"); flag = true; } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.EndVertical(); if (num >= 0 && num < _valuesCache.Count) { _valuesCache.RemoveAt(num); flag = true; } if (flag) { entry.BoxedValue = string.Join(ValuesSeparator[0], _valuesCache); CachedValues.Clear(); CachedValues.AddRange(Values); this.ValuesChangedEvent?.Invoke(this, Values); } } private bool ShowTextField(string name, ref string value) { //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Invalid comparison between Unknown and I4 //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Invalid comparison between Unknown and I4 //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Invalid comparison between Unknown and I4 //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Invalid comparison between Unknown and I4 //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Invalid comparison between Unknown and I4 GUI.SetNextControlName(name); if (GUI.GetNameOfFocusedControl() != name) { if (_lastFocusedControl == name) { value = _editingValue; GUILayout.TextField(value, _textFieldStyle.Value, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); return true; } GUILayout.TextField(value, _textFieldStyle.Value, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); return false; } if (_lastFocusedControl != name) { _lastFocusedControl = name; _editingValue = value; } bool result = false; if (Event.current.isKey) { KeyCode keyCode = Event.current.keyCode; if ((int)keyCode <= 13) { if ((int)keyCode == 9 || (int)keyCode == 13) { goto IL_00c3; } } else if ((int)keyCode == 27 || (int)keyCode == 271) { goto IL_00c3; } } goto IL_00d7; IL_00c3: value = _editingValue; result = true; Event.current.Use(); goto IL_00d7; IL_00d7: _editingValue = GUILayout.TextField(_editingValue, _textFieldStyle.Value, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); return result; } } public static class StringListConfigEntryExtensions { public static StringListConfigEntry BindInOrder(this ConfigFile config, string section, string key, string description, string valuesSeparator) { return new StringListConfigEntry(config, section, key, description, valuesSeparator); } } } namespace Chatter { [BepInPlugin("redseiko.valheim.chatter", "Chatter", "2.12.0")] public sealed class Chatter : BaseUnityPlugin { public const string PluginGuid = "redseiko.valheim.chatter"; public const string PluginName = "Chatter"; public const string PluginVersion = "2.12.0"; public static Harmony HarmonyInstance { get; private set; } private void Awake() { PluginConfig.BindConfig(((BaseUnityPlugin)this).Config); HarmonyInstance = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "redseiko.valheim.chatter"); } } public static class PluginConfig { [HarmonyPatch(typeof(FejdStartup))] private static class FejdStartupPatch { [HarmonyPostfix] [HarmonyPatch("Awake")] private static void AwakePostfix() { while (_fejdStartupBindConfigQueue.Count > 0) { _fejdStartupBindConfigQueue.Dequeue()?.Invoke(CurrentConfig); } } } private static readonly Queue<Action<ConfigFile>> _fejdStartupBindConfigQueue = new Queue<Action<ConfigFile>>(); public static ConfigFile CurrentConfig { get; private set; } public static ConfigEntry<bool> IsModEnabled { get; private set; } public static ConfigEntry<Vector2> ChatPanelPosition { get; private set; } public static ConfigEntry<Vector2> ChatPanelSizeDelta { get; private set; } public static ConfigEntry<Color> ChatPanelBackgroundColor { get; private set; } public static ConfigEntry<int> HideChatPanelDelay { get; private set; } public static ConfigEntry<float> HideChatPanelAlpha { get; private set; } public static ConfigEntry<KeyboardShortcut> ScrollContentUpShortcut { get; private set; } public static ConfigEntry<KeyboardShortcut> ScrollContentDownShortcut { get; private set; } public static ConfigEntry<float> ScrollContentOffsetInterval { get; private set; } public static ConfigEntry<float> ScrollContentScrollSensitivity { get; private set; } public static ConfigEntry<bool> ShowMessageHudCenterMessages { get; private set; } public static ConfigEntry<bool> ShowChatPanelMessageDividers { get; private set; } public static ConfigEntry<float> ChatPanelContentSpacing { get; private set; } public static ConfigEntry<float> ChatPanelContentRowSpacing { get; private set; } public static ConfigEntry<float> ChatPanelContentSingleRowSpacing { get; private set; } public static ConfigEntry<Type> ChatPanelDefaultMessageTypeToUse { get; private set; } public static ConfigEntry<ChatMessageType> ChatPanelContentRowTogglesToEnable { get; private set; } public static ConfigEntry<MessageLayoutType> ChatMessageLayout { get; private set; } public static ConfigEntry<bool> ChatMessageShowTimestamp { get; private set; } public static ConfigEntry<Color> ChatMessageTextDefaultColor { get; private set; } public static ConfigEntry<Color> ChatMessageTextSayColor { get; private set; } public static ConfigEntry<Color> ChatMessageTextShoutColor { get; private set; } public static ConfigEntry<Color> ChatMessageTextWhisperColor { get; private set; } public static ConfigEntry<Color> ChatMessageTextPingColor { get; private set; } public static ConfigEntry<Color> ChatMessageTextMessageHudColor { get; private set; } public static ConfigEntry<Color> ChatMessageUsernameColor { get; private set; } public static ConfigEntry<Color> ChatMessageTimestampColor { get; private set; } public static ConfigEntry<string> ChatMessageUsernamePrefix { get; private set; } public static ConfigEntry<string> ChatMessageUsernamePostfix { get; private set; } public static StringListConfigEntry SayTextFilterList { get; private set; } public static StringListConfigEntry ShoutTextFilterList { get; private set; } public static StringListConfigEntry WhisperTextFilterList { get; private set; } public static StringListConfigEntry HudCenterTextFilterList { get; private set; } public static StringListConfigEntry OtherTextFilterList { get; private set; } public static ConfigEntry<bool> FilterInWorldShoutText { get; private set; } public static ConfigEntry<string> ChatMessageFontAsset { get; private set; } public static ConfigEntry<float> ChatMessageFontSize { get; private set; } public static void BindConfig(ConfigFile config) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_04f0: Unknown result type (might be due to invalid IL or missing references) //IL_053e: Unknown result type (might be due to invalid IL or missing references) //IL_058c: Unknown result type (might be due to invalid IL or missing references) //IL_05ee: Unknown result type (might be due to invalid IL or missing references) //IL_063c: Unknown result type (might be due to invalid IL or missing references) //IL_069e: Unknown result type (might be due to invalid IL or missing references) //IL_06fb: Unknown result type (might be due to invalid IL or missing references) //IL_0759: Unknown result type (might be due to invalid IL or missing references) //IL_075e: Unknown result type (might be due to invalid IL or missing references) CurrentConfig = config; IsModEnabled = config.Bind<bool>("_Global", "isModEnabled", true, "Globally enable or disable this mod."); IsModEnabled.OnSettingChanged<bool>(ChatPanelController.ToggleChatter); ChatPanelPosition = config.BindInOrder<Vector2>("ChatPanel", "chatPanelPosition", new Vector2(-10f, 125f), "The Vector2 position of the ChatPanel."); ChatPanelPosition.OnSettingChanged(delegate(Vector2 position) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) ChatPanelController.ChatPanel?.PanelRectTransform.SetPosition(position); }); ChatPanelSizeDelta = config.BindInOrder<Vector2>("ChatPanel", "chatPanelSizeDelta", new Vector2(500f, 500f), "The size (width, height) of the ChatPanel."); ChatPanelSizeDelta.OnSettingChanged(delegate(Vector2 sizeDelta) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) ChatPanelController.ChatPanel?.PanelRectTransform.SetSizeDelta(sizeDelta); }); ChatPanelBackgroundColor = config.BindInOrder<Color>("ChatPanel", "chatPanelBackgroundColor", new Color(0f, 0f, 0f, 0.125f), "The background color for the ChatPanel."); ChatPanelBackgroundColor.OnSettingChanged(delegate(Color color) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) ChatPanel chatPanel = ChatPanelController.ChatPanel; if (chatPanel != null) { ImageExtensions.SetColor<Image>(chatPanel.PanelBackground, color); } }); HideChatPanelDelay = config.BindInOrder("ChatPanel.Behaviour", "hideChatPanelDelay", 5, "Delay (in seconds) before hiding the ChatPanel.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 180)); HideChatPanelAlpha = config.BindInOrder("ChatPanel.Behaviour", "hideChatPanelAlpha", 0f, "Color alpha (in %) for the ChatPanel when hidden.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f)); ScrollContentUpShortcut = config.BindInOrder<KeyboardShortcut>("ChatPanel.Scrolling", "scrollContentUpShortcut", new KeyboardShortcut((KeyCode)280, Array.Empty<KeyCode>()), "Keyboard shortcut to scroll the ChatPanel content up."); ScrollContentDownShortcut = config.BindInOrder<KeyboardShortcut>("ChatPanel.Scrolling", "scrollContentDownShortcut", new KeyboardShortcut((KeyCode)281, Array.Empty<KeyCode>()), "Keyboard shortcut to scroll the ChatPanel content down."); ScrollContentOffsetInterval = config.BindInOrder("ChatPanel.Scrolling", "scrollContentOffsetInterval", 200f, "Interval (in pixels) to scroll the ChatPanel content up/down.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-1000f, 1000f)); ScrollContentScrollSensitivity = config.BindInOrder("ChatPanel.Scrolling", "scrollContentScrollSensitivity", 1000f, "ChatPanel content ScrollRect.scrollSensitivity value.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2000f)); ScrollContentScrollSensitivity.OnSettingChanged<float>(ChatPanelController.SetScrollContentScrollSensitivity); ShowMessageHudCenterMessages = config.BindInOrder("ChatPanel.Content", "showMessageHudCenterMessages", defaultValue: true, "Show messages from the MessageHud that display in the top-center (usually boss messages)."); ShowChatPanelMessageDividers = config.BindInOrder("ChatPanel.Content", "showChatPanelMessageDividers", defaultValue: true, "Show the horizontal dividers between groups of messages."); ShowChatPanelMessageDividers.OnSettingChanged<bool>(ContentRowManager.ToggleMessageDividers); ChatPanelContentSpacing = config.BindInOrder("ChatPanel.Spacing", "chatPanelContentSpacing", 10f, "Spacing (px) between `Content.Row` when using 'WithRowHeader` layout.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-100f, 100f)); ChatPanelContentSpacing.OnSettingChanged<float>((Action)delegate { ChatPanelController.ChatPanel?.SetContentSpacing(); }); ChatPanelContentRowSpacing = config.BindInOrder("ChatPanel.Spacing", "chatPanelContentRowSpacing", 2f, "Spacing (px) between `Content.Row.Body` when using 'WithRowHeader' layout.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-100f, 100f)); ChatPanelContentRowSpacing.OnSettingChanged<float>(ContentRowManager.SetContentRowSpacing); ChatPanelContentSingleRowSpacing = config.BindInOrder("ChatPanel.Spacing", "chatPanelContentSingleRowSpacing", 10f, "Spacing (in pixels) to use between rows when using 'SingleRow' layout.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-100f, 100f)); ChatPanelContentSingleRowSpacing.OnSettingChanged<float>((Action)delegate { ChatPanelController.ChatPanel?.SetContentSpacing(); }); ChatPanelDefaultMessageTypeToUse = config.BindInOrder<Type>("ChatPanel.Defaults", "chatPanelDefaultMessageTypeToUse", (Type)1, "ChatPanel input default message type to use on game start. Ping value is ignored."); ChatPanelContentRowTogglesToEnable = config.BindInOrder("ChatPanel.Defaults", "chatPanelContentRowTogglesToEnable", ChatMessageType.Text | ChatMessageType.HudCenter | ChatMessageType.Say | ChatMessageType.Shout | ChatMessageType.Whisper, "ChatPanel content row toggles to enable on game start."); ChatMessageLayout = config.BindInOrder("ChatMessage.Layout", "chatMessageLayout", MessageLayoutType.WithHeaderRow, "Determines which layout to use when displaying a chat message."); ChatMessageLayout.OnSettingChanged<MessageLayoutType>(ContentRowManager.RebuildContentRows); ChatMessageShowTimestamp = config.BindInOrder("ChatMessage.Layout", "chatMessageShowTimestamp", defaultValue: true, "Show a timestamp for each group of chat messages (except system/default)."); ChatMessageShowTimestamp.OnSettingChanged<bool>(ContentRowManager.ToggleShowTimestamp); ChatMessageTextDefaultColor = config.BindInOrder<Color>("ChatMessage.Text.Colors", "chatMessageTextDefaultColor", Color.white, "Color for default/system chat messages."); ChatMessageTextDefaultColor.OnSettingChanged(delegate(Color color) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) ContentRowManager.SetMessageTextColor(color, ChatMessageType.Text); }); ChatMessageTextSayColor = config.BindInOrder<Color>("ChatMessage.Text.Colors", "chatMessageTextSayColor", Color.white, "Color for 'normal/say' chat messages."); ChatMessageTextSayColor.OnSettingChanged(delegate(Color color) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) ContentRowManager.SetMessageTextColor(color, ChatMessageType.Say); }); ChatMessageTextShoutColor = config.BindInOrder<Color>("ChatMessage.Text.Colors", "chatMessageTextShoutColor", Color.yellow, "Color for 'shouting' chat messages."); ChatMessageTextShoutColor.OnSettingChanged(delegate(Color color) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) ContentRowManager.SetMessageTextColor(color, ChatMessageType.Shout); }); ChatMessageTextWhisperColor = config.BindInOrder<Color>("ChatMessage.Text.Colors", "chatMessageTextWhisperColor", new Color(0.502f, 0f, 0.502f, 1f), "Color for 'whisper' chat messages."); ChatMessageTextWhisperColor.OnSettingChanged(delegate(Color color) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) ContentRowManager.SetMessageTextColor(color, ChatMessageType.Whisper); }); ChatMessageTextPingColor = config.BindInOrder<Color>("ChatMessage.Text.Colors", "chatMessageTextPingColor", Color.cyan, "Color for 'ping' chat messages."); ChatMessageTextPingColor.OnSettingChanged(delegate(Color color) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) ContentRowManager.SetMessageTextColor(color, ChatMessageType.Ping); }); ChatMessageTextMessageHudColor = config.BindInOrder<Color>("ChatMessage.Text.Colors", "chatMessageTextMessageHudColor", new Color(1f, 0.807f, 0f, 1f), "Color for 'MessageHud' chat messages."); ChatMessageTextMessageHudColor.OnSettingChanged(delegate(Color color) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) ContentRowManager.SetMessageTextColor(color, ChatMessageType.HudCenter); }); ChatMessageUsernameColor = config.BindInOrder<Color>("ChatMessage.Text.Colors", "chatMessageUsernameColor", new Color(1f, 0.647f, 0f), "Color for the username shown in chat messages."); ChatMessageUsernameColor.OnSettingChanged((Action<Color>)ContentRowManager.SetUsernameTextColor); ChatMessageTimestampColor = config.BindInOrder<Color>("ChatMessage.Text.Colors", "chatMessageTimestampColor", Color32.op_Implicit(new Color32((byte)244, (byte)246, (byte)247, byte.MaxValue)), "Color for any timestamp shown in the chat messages."); ChatMessageTimestampColor.OnSettingChanged((Action<Color>)ContentRowManager.SetTimestampTextColor); ChatMessageUsernamePrefix = ConfigFileExtensions.BindInOrder(config, "ChatMessage.WithHeaderRow", "chatMessageUsernamePrefix", string.Empty, "If non-empty, adds the text to the beginning of a ChatMesage username in 'WithHeaderRow' mode."); ChatMessageUsernamePostfix = ConfigFileExtensions.BindInOrder(config, "ChatMessage.WithHeaderRow", "chatMessageUsernamePostfix", string.Empty, "If non-empty, adds the text to the end of a ChatMessage username in 'WithHeaderRow' mode."); BindFilters(config); LateBindConfig(BindChatMessageFontConfig); } private static void BindFilters(ConfigFile config) { SayTextFilterList = config.BindInOrder("Filters", "sayTextFilterList", "Filter list for Say message texts.", "\t"); ShoutTextFilterList = config.BindInOrder("Filters", "shoutTextFilterList", "Filter list for Shout message texts.", "\t"); FilterInWorldShoutText = config.BindInOrder("Filters", "filterInWorldShoutText", defaultValue: false, "If true, will also filter in-world Shout message texts."); WhisperTextFilterList = config.BindInOrder("Filters", "whisperTextFilterList", "Filter list for Whipser message texts.", "\t"); HudCenterTextFilterList = config.BindInOrder("Filters", "messageHudTextFilterList", "Filter list for MessageHud.Center message texts.", "\t"); OtherTextFilterList = config.BindInOrder("Filters", "otherHudTextFilterList", "Filter list for all other message texts.", "\t"); } public static void BindChatMessageFontConfig(ConfigFile config) { string[] array = (from f in Resources.FindObjectsOfTypeAll<TMP_FontAsset>() select ((Object)f).name into f orderby f select f).Distinct().ToArray(); ChatMessageFontAsset = config.BindInOrder("ChatMessage.Text.Font", "chatMessageTextFontAsset", "Valheim-AveriaSansLibre", "FontAsset (TMP) to use for ChatMessage text.", (AcceptableValueBase)(object)new AcceptableValueList<string>(array)); ChatMessageFontAsset.OnSettingChanged(delegate(string fontName) { ChatPanelController.ChatPanel?.SetContentFontAsset(UIFonts.GetFontAssetByName(fontName)); }); ChatMessageFontSize = config.BindInOrder("ChatMessage.Text.Font", "chatMessageTextFontSize", 16f, "The font size to use for chat messages.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(6f, 64f)); ChatMessageFontSize.OnSettingChanged(delegate(float fontSize) { ChatPanelController.ChatPanel?.SetContentFontSize(fontSize); }); } public static void LateBindConfig(Action<ConfigFile> lateBindConfigAction) { _fejdStartupBindConfigQueue.Enqueue(lateBindConfigAction); } } public sealed class ChatMessage { public ChatMessageType MessageType { get; set; } = ChatMessageType.Text; public DateTime Timestamp { get; set; } = DateTime.MinValue; public long SenderId { get; set; } public Vector3 Position { get; set; } = Vector3.zero; public Type TalkerType { get; set; } = (Type)1; public string Username { get; set; } = string.Empty; public string Text { get; set; } = string.Empty; } public static class ChatPanelController { public static ChatPanel ChatPanel { get; private set; } public static GuiInputField VanillaInputField { get; set; } public static void ToggleChatter(bool toggleOn) { ToggleChatter(Chat.m_instance, toggleOn); } public static void ToggleChatter(Chat chat, bool toggleOn) { TerminalCommands.ToggleCommands(toggleOn); if (Object.op_Implicit((Object)(object)chat)) { ToggleVanillaChat(chat, !toggleOn); ToggleChatPanel(chat, toggleOn); ((Terminal)chat).m_input = (toggleOn ? ChatPanel.TextInput.InputField : VanillaInputField); } } public static void ToggleVanillaChat(Chat chat, bool toggleOn) { ((Component)((TMP_Text)((Terminal)chat).m_output).transform.parent).gameObject.SetActive(toggleOn); ((Component)((Terminal)chat).m_output).gameObject.SetActive(toggleOn); } public static void ToggleChatPanel(Chat chat, bool toggleOn) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_0111: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)ChatPanel?.Panel)) { ChatPanel = new ChatPanel(((Component)Hud.m_instance).transform); ((Transform)ChatPanel.Panel.GetComponent<RectTransform>().SetAnchorMin(Vector2.right).SetAnchorMax(Vector2.right) .SetPivot(Vector2.right) .SetPosition(PluginConfig.ChatPanelPosition.Value) .SetSizeDelta(PluginConfig.ChatPanelSizeDelta.Value)).SetAsFirstSibling(); ChatPanel.PanelDragger.OnEndDragEvent += OnChatterChatPanelEndDrag; ChatPanel.PanelResizer.OnEndDragEvent += OnChatterChatPanelEndResize; ((UnityEvent<string>)(object)((TMP_InputField)ChatPanel.TextInput.InputField).onSubmit).AddListener((UnityAction<string>)OnChatterTextInputFieldSubmit); ChatPanel.SetChatTextInputPrefix(PluginConfig.ChatPanelDefaultMessageTypeToUse.Value); ChatPanel.SetupContentRowToggles(PluginConfig.ChatPanelContentRowTogglesToEnable.Value); ChatPanel.SetContentSpacing(); ContentRowManager.RebuildContentRows(); } ChatPanel.Panel.SetActive(toggleOn); } public static void SetScrollContentScrollSensitivity(float scrollSensitivity) { if (TryGetChatPanel(out var chatPanel)) { chatPanel.ContentScrollRect.SetScrollSensitivity<ScrollRect>(scrollSensitivity); } } public static bool TryGetChatPanel(out ChatPanel chatPanel) { chatPanel = ChatPanel; return Object.op_Implicit((Object)(object)chatPanel?.Panel); } private static void OnChatterChatPanelEndDrag(object sender, Vector3 position) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) PluginConfig.ChatPanelPosition.Value = Vector2.op_Implicit(position); } private static void OnChatterChatPanelEndResize(object send, Vector2 sizeDelta) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) PluginConfig.ChatPanelSizeDelta.Value = sizeDelta; } private static void OnChatterTextInputFieldSubmit(string input) { Chat.m_instance.SendInput(); } } public static class ContentRowManager { public static CircularQueue<ContentRow> MessageRows { get; } = new CircularQueue<ContentRow>(50, DestroyContentRow); public static void CreateContentRow(ChatMessage message) { if (!Object.op_Implicit((Object)(object)ChatPanelController.ChatPanel?.Content)) { return; } if (ShouldCreateContentRow(message)) { ContentRow contentRow = new ContentRow(message, PluginConfig.ChatMessageLayout.Value, ChatPanelController.ChatPanel.Content.transform); MessageRows.EnqueueItem(contentRow); SetupContentRow(contentRow); bool flag = ChatPanelController.ChatPanel.IsMessageTypeToggleActive(message.MessageType); GameObject obj = contentRow.Divider.Ref<GameObject>(); if (obj != null) { obj.SetActive(flag && PluginConfig.ShowChatPanelMessageDividers.Value); } contentRow.Row.SetActive(flag); } TextMeshProUGUI obj2 = MessageRows.LastItem.AddBodyLabel(message); ((TMP_Text)obj2).font = UIFonts.GetFontAssetByName(PluginConfig.ChatMessageFontAsset.Value); ((TMP_Text)obj2).fontSize = PluginConfig.ChatMessageFontSize.Value; } public static bool ShouldCreateContentRow(ChatMessage message) { if (PluginConfig.ChatMessageLayout.Value != MessageLayoutType.SingleRow && !MessageRows.IsEmpty && MessageRows.LastItem != null && MessageRows.LastItem.Message?.MessageType == message.MessageType && MessageRows.LastItem.Message?.SenderId == message.SenderId) { return MessageRows.LastItem.Message?.Username != message.Username; } return true; } public static void DestroyContentRow(ContentRow row) { if (Object.op_Implicit((Object)(object)row.Row)) { Object.Destroy((Object)(object)row.Row); } if (Object.op_Implicit((Object)(object)row.Divider)) { Object.Destroy((Object)(object)row.Divider); } } public static void RebuildContentRows() { MessageRows.ClearItems(); if (!Object.op_Implicit((Object)(object)ChatPanelController.ChatPanel?.Panel)) { return; } foreach (ChatMessage item in ChatMessageUtils.MessageHistory) { CreateContentRow(item); } } public static void SetupContentRow(ContentRow row) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) if (row.LayoutType == MessageLayoutType.WithHeaderRow) { ((TMP_Text)row.HeaderLeftLabel).font = UIFonts.GetFontAssetByName(PluginConfig.ChatMessageFontAsset.Value); ((TMP_Text)row.HeaderLeftLabel).fontSize = PluginConfig.ChatMessageFontSize.Value; ((TMP_Text)row.HeaderLeftLabel).text = ChatMessageUtils.GetUsernameText(row.Message.Username); ((Graphic)row.HeaderLeftLabel).color = PluginConfig.ChatMessageUsernameColor.Value; ((TMP_Text)row.HeaderRightLabel).font = UIFonts.GetFontAssetByName(PluginConfig.ChatMessageFontAsset.Value); ((TMP_Text)row.HeaderRightLabel).fontSize = PluginConfig.ChatMessageFontSize.Value; ((TMP_Text)row.HeaderRightLabel).text = ChatMessageUtils.GetTimestampText(row.Message.Timestamp); ((Graphic)row.HeaderRightLabel).color = PluginConfig.ChatMessageTimestampColor.Value; ((Component)row.HeaderRightLabel).gameObject.SetActive(PluginConfig.ChatMessageShowTimestamp.Value); row.RowLayoutGroup.SetSpacing<VerticalLayoutGroup>(PluginConfig.ChatPanelContentRowSpacing.Value); } else if (row.LayoutType == MessageLayoutType.SingleRow) { row.RowLayoutGroup.SetSpacing<VerticalLayoutGroup>(PluginConfig.ChatPanelContentSingleRowSpacing.Value); } } public static void ToggleContentRows(bool toggleOn, ChatMessageType messageType) { foreach (ContentRow messageRow in MessageRows) { if (messageRow.Message.MessageType == messageType) { GameObject obj = messageRow.Row.Ref<GameObject>(); if (obj != null) { obj.SetActive(toggleOn); } GameObject obj2 = messageRow.Divider.Ref<GameObject>(); if (obj2 != null) { obj2.SetActive(toggleOn); } } } } public static void SetContentRowSpacing(float spacing) { foreach (ContentRow messageRow in MessageRows) { messageRow?.RowLayoutGroup.Ref<VerticalLayoutGroup>()?.SetSpacing<VerticalLayoutGroup>(spacing); } } public static void SetMessageTextColor(Color color, ChatMessageType messageType) { //IL_009f: Unknown result type (might be due to invalid IL or missing references) if (PluginConfig.ChatMessageLayout.Value == MessageLayoutType.SingleRow) { RebuildContentRows(); return; } foreach (TMP_Text item in from label in MessageRows.Where(delegate(ContentRow row) { ChatMessage message = row.Message; return message != null && message.MessageType == messageType && Object.op_Implicit((Object)(object)row.Row); }).SelectMany((ContentRow row) => row.Row.GetComponentsInChildren<TMP_Text>(true)) where ((Object)label).name == "BodyLabel" select label) { ((Graphic)item).color = color; } } public static void SetUsernameTextColor(Color color) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) if (PluginConfig.ChatMessageLayout.Value == MessageLayoutType.SingleRow) { RebuildContentRows(); return; } foreach (ContentRow messageRow in MessageRows) { if (messageRow != null) { TextMeshProUGUI obj = messageRow.HeaderLeftLabel.Ref<TextMeshProUGUI>(); if (obj != null) { TextMeshProExtensions.SetColor<TextMeshProUGUI>(obj, color); } } } } public static void SetTimestampTextColor(Color color) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) if (PluginConfig.ChatMessageLayout.Value == MessageLayoutType.SingleRow) { RebuildContentRows(); return; } foreach (ContentRow messageRow in MessageRows) { if (messageRow != null) { TextMeshProUGUI obj = messageRow.HeaderRightLabel.Ref<TextMeshProUGUI>(); if (obj != null) { TextMeshProExtensions.SetColor<TextMeshProUGUI>(obj, color); } } } } public static void ToggleShowTimestamp(bool toggleOn) { if (PluginConfig.ChatMessageLayout.Value == MessageLayoutType.SingleRow) { RebuildContentRows(); return; } foreach (ContentRow messageRow in MessageRows) { if (messageRow != null) { TextMeshProUGUI headerRightLabel = messageRow.HeaderRightLabel; if (headerRightLabel != null) { ((Component)headerRightLabel).gameObject.SetActive(toggleOn); } } } } public static void ToggleMessageDividers(bool toggleOn) { foreach (ContentRow messageRow in MessageRows) { if (messageRow != null) { GameObject obj = messageRow.Divider.Ref<GameObject>(); if (obj != null) { obj.SetActive(toggleOn); } } } } } [Flags] public enum ChatMessageType { None = 0, Text = 1, HudCenter = 2, Say = 4, Shout = 8, Whisper = 0x10, Ping = 0x20 } public enum MessageLayoutType { WithHeaderRow, SingleRow } public static class TerminalCommands { [CompilerGenerated] private static class <>O { public static ConsoleEvent <0>__RunShoutCommand; public static ConsoleEvent <1>__RunWhisperCommand; } private static readonly List<ConsoleCommand> _commands = new List<ConsoleCommand>(); public static void ToggleCommands(bool toggleOn) { DeregisterCommands(_commands); _commands.Clear(); if (toggleOn) { _commands.AddRange(RegisterCommands()); } UpdateCommandLists(); } private static ConsoleCommand[] RegisterCommands() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown ConsoleCommand[] array = new ConsoleCommand[2]; object obj = <>O.<0>__RunShoutCommand; if (obj == null) { ConsoleEvent val = RunShoutCommand; <>O.<0>__RunShoutCommand = val; obj = (object)val; } array[0] = new ConsoleCommand("shout", "(Chatter) shout <message>", (ConsoleEvent)obj, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj2 = <>O.<1>__RunWhisperCommand; if (obj2 == null) { ConsoleEvent val2 = RunWhisperCommand; <>O.<1>__RunWhisperCommand = val2; obj2 = (object)val2; } array[1] = new ConsoleCommand("whisper", "(Chatter) whisper <message>", (ConsoleEvent)obj2, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); return (ConsoleCommand[])(object)array; } public static void RunShoutCommand(ConsoleEventArgs args) { if (args.FullLine.Length < 7) { ChatPanelController.ChatPanel?.SetChatTextInputPrefix((Type)2); } else if (Object.op_Implicit((Object)(object)Chat.m_instance)) { Chat.m_instance.SendText((Type)2, args.FullLine.Substring(6)); } } public static void RunWhisperCommand(ConsoleEventArgs args) { if (args.FullLine.Length < 9) { ChatPanelController.ChatPanel?.SetChatTextInputPrefix((Type)0); } else if (Object.op_Implicit((Object)(object)Chat.m_instance)) { Chat.m_instance.SendText((Type)0, args.FullLine.Substring(8)); } } private static void DeregisterCommands(List<ConsoleCommand> commands) { foreach (ConsoleCommand command in commands) { if (Terminal.commands[command.Command] == command) { Terminal.commands.Remove(command.Command); } } } private static void UpdateCommandLists() { Terminal[] array = Object.FindObjectsByType<Terminal>((FindObjectsInactive)1, (FindObjectsSortMode)0); for (int i = 0; i < array.Length; i++) { array[i].updateCommandList(); } } } public sealed class ChatPanel { public GameObject Panel { get; private set; } public RectTransform PanelRectTransform { get; private set; } public Image PanelBackground { get; private set; } public CanvasGroup PanelCanvasGroup { get; private set; } public RectTransformDragger PanelDragger { get; private set; } public GameObject ContentViewport { get; private set; } public GameObject Content { get; private set; } public VerticalLayoutGroup ContentLayoutGroup { get; private set; } public ScrollRect ContentScrollRect { get; private set; } public InputFieldCell TextInput { get; private set; } public ToggleRow MessageTypeToggleRow { get; private set; } public ResizeCell ResizerCell { get; private set; } public RectTransformResizer PanelResizer { get; private set; } public ChatPanel(Transform parentTransform) { Panel = CreateChildPanel(parentTransform); PanelRectTransform = Panel.GetComponent<RectTransform>(); PanelBackground = Panel.GetComponent<Image>(); PanelCanvasGroup = Panel.GetComponent<CanvasGroup>(); PanelDragger = Panel.GetComponent<RectTransformDragger>(); ContentViewport = CreateChildViewport(Panel.transform); Content = CreateChildContent(ContentViewport.transform); ContentLayoutGroup = Content.GetComponent<VerticalLayoutGroup>(); ContentScrollRect = CreateChildScrollRect(ContentViewport, Content); TextInput = new InputFieldCell(Panel.transform); LayoutElement layoutElement = TextInput.Cell.AddComponent<LayoutElement>().SetFlexible<LayoutElement>((float?)1f, (float?)null); float? height = 35f; layoutElement.SetPreferred<LayoutElement>((float?)null, height); MessageTypeToggleRow = new ToggleRow(Panel.transform); MessageTypeToggleRow.Row.AddComponent<LayoutElement>().SetIgnoreLayout<LayoutElement>(ignoreLayout: true); ResizerCell = new ResizeCell(MessageTypeToggleRow.Row.transform); ResizerCell.Cell.AddComponent<LayoutElement>().SetIgnoreLayout<LayoutElement>(ignoreLayout: true); PanelResizer = ResizerCell.Cell.AddComponent<RectTransformResizer>().SetTargetRectTransform(Panel.GetComponent<RectTransform>()); } private GameObject CreateChildPanel(Transform parentTransform) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("ChatPanel", new Type[1] { typeof(RectTransform) }); val.SetParent(parentTransform); val.AddComponent<GraphicRaycaster>(); val.GetComponent<RectTransform>().SetAnchorMin(new Vector2(0.5f, 0.5f)).SetAnchorMax(new Vector2(0.5f, 0.5f)) .SetPivot(new Vector2(0.5f, 0.5f)) .SetPosition(Vector2.zero) .SetSizeDelta(new Vector2(400f, 400f)); val.AddComponent<VerticalLayoutGroup>().SetChildControl<VerticalLayoutGroup>((bool?)true, (bool?)true).SetChildForceExpand<VerticalLayoutGroup>((bool?)false, (bool?)false) .SetPadding<VerticalLayoutGroup>((int?)8, (int?)8, (int?)8, (int?)8) .SetSpacing<VerticalLayoutGroup>(10f); ImageExtensions.SetColor<Image>(val.AddComponent<Image>().SetType<Image>((Type)1).SetSprite<Image>(UISpriteBuilder.CreateSuperellipse(400, 400, 15f)), new Color(0f, 0f, 0f, 0.4f)); val.AddComponent<CanvasGroup>().SetAlpha(1f).SetBlocksRaycasts(blocksRaycasts: true); val.AddComponent<RectTransformDragger>().SetTargetRectTransform(val.GetComponent<RectTransform>()); return val; } private GameObject CreateChildViewport(Transform parentTransform) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown GameObject val = new GameObject("Viewport", new Type[1] { typeof(RectTransform) }); GameObjectExtensions.SetParent(val, parentTransform); ImageExtensions.SetColor<Image>(val.AddComponent<Image>().SetType<Image>((Type)3), Color.clear); val.AddComponent<RectMask2D>(); val.AddComponent<LayoutElement>().SetFlexible<LayoutElement>((float?)1f, (float?)1f); return val; } private GameObject CreateChildContent(Transform parentTransform) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_00c9: Expected O, but got Unknown GameObject val = new GameObject("Content", new Type[1] { typeof(RectTransform) }); GameObjectExtensions.SetParent(val, parentTransform); val.GetComponent<RectTransform>().SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.right) .SetPivot(Vector2.zero) .SetPosition(Vector2.zero) .SetSizeDelta(Vector2.zero); val.AddComponent<VerticalLayoutGroup>().SetChildControl<VerticalLayoutGroup>((bool?)true, (bool?)true).SetChildForceExpand<VerticalLayoutGroup>((bool?)false, (bool?)false) .SetPadding<VerticalLayoutGroup>((int?)8, (int?)8, (int?)null, (int?)null) .SetSpacing<VerticalLayoutGroup>(10f); val.AddComponent<ContentSizeFitter>().SetHorizontalFit((FitMode)0).SetVerticalFit((FitMode)2); return val; } private ScrollRect CreateChildScrollRect(GameObject viewport, GameObject content) { ScrollRect obj = viewport.AddComponent<ScrollRect>(); obj.SetViewport<ScrollRect>(viewport.GetComponent<RectTransform>()).SetContent<ScrollRect>(content.GetComponent<RectTransform>()).SetHorizontal<ScrollRect>(horizontal: false) .SetVertical<ScrollRect>(vertical: true) .SetMovementType<ScrollRect>((MovementType)1) .SetScrollSensitivity<ScrollRect>(PluginConfig.ScrollContentScrollSensitivity.Value); return obj; } public void OffsetContentVerticalScrollPosition(float offset) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) Transform transform = Content.transform; float num = offset / ((RectTransform)((transform is RectTransform) ? transform : null)).sizeDelta.y; ScrollRect contentScrollRect = ContentScrollRect; contentScrollRect.verticalNormalizedPosition += num; } public void SetContentVerticalScrollPosition(float position) { ContentScrollRect.verticalNormalizedPosition = position; } public void ToggleGrabber(bool toggleOn) { MessageTypeToggleRow.Row.SetActive(toggleOn); } } public sealed class ContentRow { public ChatMessage Message { get; private set; } public MessageLayoutType LayoutType { get; private set; } public GameObject Row { get; private set; } public VerticalLayoutGroup RowLayoutGroup { get; private set; } public GameObject Divider { get; private set; } public GameObject Header { get; private set; } public TextMeshProUGUI HeaderLeftLabel { get; private set; } public TextMeshProUGUI HeaderRightLabel { get; private set; } public ContentRow(ChatMessage message, MessageLayoutType layoutType, Transform parentTransform) { Message = message; LayoutType = layoutType; if (layoutType == MessageLayoutType.WithHeaderRow) { Divider = CreateDivider(parentTransform); } Row = CreateChildRow(parentTransform); RowLayoutGroup = Row.GetComponent<VerticalLayoutGroup>(); if (layoutType == MessageLayoutType.WithHeaderRow) { (Header, HeaderLeftLabel, HeaderRightLabel) = CreateHeader(Row.transform); } } public TextMeshProUGUI AddBodyLabel(ChatMessage message) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI val = CreateChildBodyLabel(Row.transform); ((TMP_Text)val).text = ChatMessageUtils.GetContentRowBodyText(message); if (LayoutType == MessageLayoutType.WithHeaderRow) { ((Graphic)val).color = ChatMessageUtils.GetMessageTextColor(message.MessageType); } return val; } private GameObject CreateChildRow(Transform parentTransform) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_006b: Expected O, but got Unknown GameObject val = new GameObject("Message", new Type[1] { typeof(RectTransform) }); GameObjectExtensions.SetParent(val, parentTransform); val.GetComponent<RectTransform>().SetSizeDelta(Vector2.zero); val.AddComponent<VerticalLayoutGroup>().SetChildControl<VerticalLayoutGroup>((bool?)true, (bool?)true).SetChildForceExpand<VerticalLayoutGroup>((bool?)true, (bool?)false) .SetSpacing<VerticalLayoutGroup>(2f); return val; } private GameObject CreateDivider(Transform parentTransform) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown GameObject val = new GameObject("Divider", new Type[1] { typeof(RectTransform) }); GameObjectExtensions.SetParent(val, parentTransform); ImageExtensions.SetColor<Image>(val.AddComponent<Image>().SetSprite<Image>(UISpriteBuilder.CreateRect(10, 10, Color32.op_Implicit(Color.white))).SetType<Image>((Type)3), new Color(1f, 1f, 1f, 0.0625f)).SetRaycastTarget<Image>(raycastTarget: true).SetMaskable<Image>(maskable: true); LayoutElement layoutElement = val.AddComponent<LayoutElement>().SetFlexible<LayoutElement>((float?)1f, (float?)null); float? height = 1f; layoutElement.SetPreferred<LayoutElement>((float?)null, height); return val; } private (GameObject header, TextMeshProUGUI leftCell, TextMeshProUGUI rightCell) CreateHeader(Transform parentTransform) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_00b2: 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_00c4: Expected O, but got Unknown GameObject val = new GameObject("Header", new Type[1] { typeof(RectTransform) }); val.SetParent(parentTransform); val.AddComponent<HorizontalLayoutGroup>().SetChildControl<HorizontalLayoutGroup>((bool?)true, (bool?)true).SetChildForceExpand<HorizontalLayoutGroup>((bool?)false, (bool?)false) .SetPadding<HorizontalLayoutGroup>((int?)0, (int?)0, (int?)0, (int?)0); TextMeshProUGUI val2 = UIBuilder.CreateLabel(val.transform); ((Object)val2).name = "HeaderLeftLabel"; ((TMP_Text)val2).text = "LeftLabel"; ((TMP_Text)val2).alignment = (TextAlignmentOptions)513; GameObject val3 = new GameObject("Spacer", new Type[1] { typeof(RectTransform) }); GameObjectExtensions.SetParent(val3, val.transform); val3.AddComponent<LayoutElement>().SetFlexible<LayoutElement>((float?)1f, (float?)null); TextMeshProUGUI val4 = UIBuilder.CreateLabel(val.transform); ((Object)val4).name = "HeaderRightLabel"; ((TMP_Text)val4).text = "RightLabel"; ((TMP_Text)val4).alignment = (TextAlignmentOptions)516; return (val, val2, val4); } private TextMeshProUGUI CreateChildBodyLabel(Transform parentTransform) { TextMeshProUGUI obj = UIBuilder.CreateLabel(parentTransform); ((Object)obj).name = "BodyLabel"; ((TMP_Text)obj).alignment = (TextAlignmentOptions)513; ((TMP_Text)obj).textWrappingMode = (TextWrappingModes)1; return obj; } } public sealed class InputFieldCell { public GameObject Cell { get; private set; } public Image Background { get; private set; } public GuiInputField InputField { get; private set; } public TextMeshProUGUI InputFieldPlaceholder { get; private set; } public InputFieldCell(Transform parentTransform) { Cell = CreateChildCell(parentTransform); Background = Cell.GetComponent<Image>(); InputField = CreateChildInputField(Cell.transform); InputFieldPlaceholder = ((Component)((TMP_InputField)InputField).placeholder).GetComponent<TextMeshProUGUI>(); InputField.SetTargetGraphic<GuiInputField>((Graphic)(object)Background).SetTransition<GuiInputField>((Transition)1).SetNavigationMode<GuiInputField>((Mode)0); } private GameObject CreateChildCell(Transform parentTransform) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_0072: Expected O, but got Unknown GameObject val = new GameObject("Cell", new Type[1] { typeof(RectTransform) }); GameObjectExtensions.SetParent(val, parentTransform); ImageExtensions.SetColor<Image>(val.AddComponent<Image>().SetType<Image>((Type)1).SetSprite<Image>(UISpriteBuilder.CreateSuperellipse(128, 128, 10f)), new Color(0.1f, 0.1f, 0.1f, 0.3f)); val.AddComponent<RectMask2D>(); return val; } private GuiInputField CreateChildInputField(Transform parentTransform) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_002d: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_010f: 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_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Text Area", new Type[1] { typeof(RectTransform) }); val.SetParent(parentTransform); val.GetComponent<RectTransform>().SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.one) .SetPivot(new Vector2(0.5f, 0.5f)) .SetSizeDelta(new Vector2(-16f, -8f)) .SetPosition(Vector2.zero); TextMeshProUGUI val2 = UIBuilder.CreateLabel(val.transform); val2.SetName<TextMeshProUGUI>("Text"); ((TMP_Text)val2).rectTransform.SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.one).SetSizeDelta(Vector2.zero) .SetPosition(Vector2.zero); ((TMP_Text)val2).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)val2).overflowMode = (TextOverflowModes)2; ((TMP_Text)val2).richText = false; ((TMP_Text)val2).alignment = (TextAlignmentOptions)513; ((Graphic)val2).color = Color.white; ((TMP_Text)val2).text = string.Empty; TextMeshProUGUI val3 = UIBuilder.CreateLabel(val.transform); val3.SetName<TextMeshProUGUI>("Placeholder"); ((TMP_Text)val3).rectTransform.SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.one).SetSizeDelta(Vector2.zero) .SetPosition(Vector2.zero); ((TMP_Text)val3).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)val3).overflowMode = (TextOverflowModes)2; ((TMP_Text)val3).richText = true; ((TMP_Text)val3).alignment = (TextAlignmentOptions)513; ((Graphic)val3).color = new Color(1f, 1f, 1f, 0.3f); ((TMP_Text)val3).text = "..."; GuiInputField obj = ((Component)parentTransform).gameObject.AddComponent<GuiInputField>(); ((TMP_InputField)obj).textViewport = val.GetComponent<RectTransform>(); ((TMP_InputField)obj).textComponent = (TMP_Text)(object)val2; ((TMP_InputField)obj).placeholder = (Graphic)(object)val3; ((TMP_InputField)obj).onFocusSelectAll = false; obj.OnInputLayoutChanged(); ((TMP_InputField)obj).MoveToStartOfLine(false, false); return obj; } } public sealed class ResizeCell { public GameObject Cell { get; private set; } public Image Background { get; private set; } public TMP_Text Label { get; private set; } public ResizeCell(Transform parentTransform) { Cell = CreateChildCell(parentTransform); Background = Cell.GetComponent<Image>(); Label = CreateChildLabel(Cell.transform); } private GameObject CreateChildCell(Transform parentTransform) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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_00cc: Expected O, but got Unknown GameObject val = new GameObject("Resizer", new Type[1] { typeof(RectTransform) }); GameObjectExtensions.SetParent(val, parentTransform); val.GetComponent<RectTransform>().SetAnchorMin(new Vector2(0f, 0.5f)).SetAnchorMax(new Vector2(0f, 0.5f)) .SetPivot(new Vector2(0f, 0.5f)) .SetSizeDelta(new Vector2(42.5f, 42.5f)) .SetPosition(new Vector2(5f, 0f)); ImageExtensions.SetColor<Image>(val.AddComponent<Image>().SetType<Image>((Type)1).SetSprite<Image>(UIResources.GetSprite("button")), new Color(1f, 1f, 1f, 0.95f)); return val; } private TMP_Text CreateChildLabel(Transform parentTransform) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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 obj = UIBuilder.CreateLabel(parentTransform); ((Component)obj).GetComponent<RectTransform>().SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.one) .SetPivot(new Vector2(0.5f, 0.5f)) .SetSizeDelta(Vector2.zero); ((TMP_Text)obj).alignment = (TextAlignmentOptions)514; ((TMP_Text)obj).fontSize = 24f; ((TMP_Text)obj).text = "<rotate=45>↔</rotate>"; return (TMP_Text)(object)obj; } } public sealed class ToggleCell { public static readonly Color BackgroundColorOn = new Color(1f, 1f, 1f, 0.95f); public static readonly Color BackgroundColorOff = new Color(0.5f, 0.5f, 0.5f, 0.95f); public static readonly Color LabelColorOn = Color.white; public static readonly Color LabelColorOff = Color.gray; public GameObject Cell { get; private set; } public Image Background { get; private set; } public TextMeshProUGUI Label { get; private set; } public Toggle Toggle { get; private set; } public ToggleCell(Transform parentTransform) { Cell = CreateChildCell(parentTransform); Background = Cell.GetComponent<Image>(); Label = CreateChildLabel(Cell.transform); Toggle = Cell.AddComponent<Toggle>(); ((UnityEvent<bool>)(object)Toggle.onValueChanged).AddListener((UnityAction<bool>)OnToggleValueChanged);