

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using HarmonyLib;
using Il2CppFishNet;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppScheduleOne;
using Il2CppScheduleOne.DevUtilities;
using Il2CppScheduleOne.ItemFramework;
using Il2CppScheduleOne.PlayerScripts;
using Il2CppScheduleOne.UI;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Il2CppTMPro;
using MelonLoader;
using MelonLoader.Utils;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using TextDecorator;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(global::TextDecorator.TextDecorator), "Text Decorator", "0.6.0", "k073l", null)]
[assembly: MelonColor(1, 255, 215, 0)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("TextDecorator-IL2CPP")]
[assembly: AssemblyConfiguration("Release IL2CPP")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+c06a856efeab89e10efdfb8effe0618330b413d2")]
[assembly: AssemblyProduct("TextDecorator-IL2CPP")]
[assembly: AssemblyTitle("TextDecorator-IL2CPP")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[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 TextDecorator
{
public static class BuildInfo
{
public const string Name = "Text Decorator";
public const string Description = "Adds text formatting options to the text input screen.";
public const string Author = "k073l";
public const string Version = "0.6.0";
}
[Serializable]
public class ColorData
{
public int R;
public int G;
public int B;
public ColorData(int r, int g, int b)
{
R = r;
G = g;
B = b;
}
public static ColorData FromColor(Color color)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
return new ColorData(Mathf.RoundToInt(color.r * 255f), Mathf.RoundToInt(color.g * 255f), Mathf.RoundToInt(color.b * 255f));
}
public Color ToColor()
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: 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)
return new Color((float)R / 255f, (float)G / 255f, (float)B / 255f);
}
}
[Serializable]
public class FormatButtonData
{
public string Label;
public string TagKey;
public ColorData ButtonColorData;
[JsonIgnore]
public Color ButtonColor => ButtonColorData.ToColor();
public FormatButtonData(string label, string tagKey, Color buttonColor)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
Label = label;
TagKey = tagKey;
ButtonColorData = ColorData.FromColor(buttonColor);
}
}
[Serializable]
public class CustomColorConfig
{
public List<FormatButtonData> customColors = new List<FormatButtonData>();
}
public class TextDecorator : MelonMod
{
[HarmonyPatch(typeof(TextInputScreen))]
public static class TextInputScreenPatch
{
[CompilerGenerated]
private sealed class <FlashTextCoroutine>d__11 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <FlashTextCoroutine>d__11(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0025: 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: Expected O, but got Unknown
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
((Graphic)warningText).color = Color.yellow;
<>2__current = (object)new WaitForSeconds(0.5f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
((Graphic)warningText).color = Color.white;
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private static Dictionary<string, Button> formatButtons = new Dictionary<string, Button>();
private static List<FormatButtonData> colorButtons = new List<FormatButtonData>
{
new FormatButtonData("R", "color=#FF5555", new Color(1f, 0.33f, 0.33f)),
new FormatButtonData("G", "color=#55FF55", new Color(0.33f, 1f, 0.33f)),
new FormatButtonData("B", "color=#5555FF", new Color(0.33f, 0.33f, 1f)),
new FormatButtonData("Y", "color=#FFFF55", new Color(1f, 1f, 0.33f)),
new FormatButtonData("P", "color=#FF55FF", new Color(1f, 0.33f, 1f))
};
private static readonly Dictionary<string, string> formatTags = new Dictionary<string, string>
{
{ "bold", "b" },
{ "italic", "i" },
{ "underline", "u" },
{ "strikethrough", "s" }
};
private static TMP_InputField inputField;
private static TextMeshProUGUI warningText;
private static readonly string ConfigFilePath = Path.Combine(MelonEnvironment.UserDataDirectory, "TextDecoratorColors.json");
private static void SaveCustomColors()
{
CustomColorConfig customColorConfig = new CustomColorConfig
{
customColors = colorButtons.Where((FormatButtonData b) => !IsDefaultColor(b.TagKey)).ToList()
};
try
{
string contents = JsonConvert.SerializeObject((object)customColorConfig, (Formatting)1);
File.WriteAllText(ConfigFilePath, contents);
}
catch (Exception ex)
{
MelonLogger.Error("Failed to save custom colors: " + ex.Message);
}
}
private static void LoadCustomColors(GameObject buttonPanel)
{
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
if (!File.Exists(ConfigFilePath))
{
return;
}
try
{
string text = File.ReadAllText(ConfigFilePath);
CustomColorConfig customColorConfig = JsonConvert.DeserializeObject<CustomColorConfig>(text);
foreach (FormatButtonData btn in customColorConfig.customColors)
{
formatTags[btn.TagKey] = btn.TagKey;
if (!colorButtons.Any((FormatButtonData b) => b.TagKey == btn.TagKey))
{
colorButtons.Add(btn);
CreateColorButton(buttonPanel, btn.Label, btn.TagKey, btn.ButtonColor, isCustom: true);
}
}
}
catch (Exception ex)
{
MelonLogger.Error("Failed to load custom colors: " + ex.Message);
}
}
private static bool IsDefaultColor(string tagKey)
{
if (1 == 0)
{
}
bool result;
switch (tagKey)
{
case "color=#FF5555":
case "color=#55FF55":
case "color=#5555FF":
case "color=#FFFF55":
case "color=#FF55FF":
result = true;
break;
default:
result = false;
break;
}
if (1 == 0)
{
}
return result;
}
[HarmonyPostfix]
[HarmonyPatch("Open")]
public static void AddFormattingUI(TextInputScreen __instance)
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
//IL_0062: 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_008e: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Expected O, but got Unknown
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
//IL_01e7: Expected O, but got Unknown
//IL_0218: Unknown result type (might be due to invalid IL or missing references)
//IL_0246: Unknown result type (might be due to invalid IL or missing references)
//IL_028e: Unknown result type (might be due to invalid IL or missing references)
//IL_0298: Expected O, but got Unknown
//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
//IL_03d0: Expected O, but got Unknown
//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
//IL_043d: Unknown result type (might be due to invalid IL or missing references)
//IL_0447: Expected O, but got Unknown
//IL_044d: Unknown result type (might be due to invalid IL or missing references)
//IL_0454: Expected O, but got Unknown
//IL_047e: Unknown result type (might be due to invalid IL or missing references)
//IL_049b: Unknown result type (might be due to invalid IL or missing references)
//IL_04ce: Unknown result type (might be due to invalid IL or missing references)
//IL_0528: Unknown result type (might be due to invalid IL or missing references)
//IL_052f: Expected O, but got Unknown
//IL_0559: Unknown result type (might be due to invalid IL or missing references)
//IL_0587: Unknown result type (might be due to invalid IL or missing references)
//IL_0597: Unknown result type (might be due to invalid IL or missing references)
//IL_059e: Expected O, but got Unknown
//IL_05d8: Unknown result type (might be due to invalid IL or missing references)
//IL_05fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0608: Unknown result type (might be due to invalid IL or missing references)
//IL_0615: Unknown result type (might be due to invalid IL or missing references)
//IL_0622: Unknown result type (might be due to invalid IL or missing references)
//IL_039a: Unknown result type (might be due to invalid IL or missing references)
//IL_0376: Unknown result type (might be due to invalid IL or missing references)
inputField = __instance.InputField;
inputField.characterLimit = 10000;
formatButtons.Clear();
GameObject val = new GameObject("FormattingEditorContainer");
val.transform.SetParent(((Component)__instance.Canvas).transform, false);
RectTransform val2 = val.AddComponent<RectTransform>();
val2.anchorMin = new Vector2(0.5f, 0f);
val2.anchorMax = new Vector2(0.5f, 0f);
val2.pivot = new Vector2(0.5f, 0f);
val2.anchoredPosition = new Vector2(0f, 160f);
val2.sizeDelta = new Vector2(480f, 110f);
VerticalLayoutGroup val3 = val.AddComponent<VerticalLayoutGroup>();
((HorizontalOrVerticalLayoutGroup)val3).spacing = 5f;
((LayoutGroup)val3).childAlignment = (TextAnchor)1;
((HorizontalOrVerticalLayoutGroup)val3).childForceExpandWidth = true;
((HorizontalOrVerticalLayoutGroup)val3).childForceExpandHeight = false;
GameObject val4 = new GameObject("WarningText");
val4.transform.SetParent(val.transform, false);
RectTransform val5 = val4.AddComponent<RectTransform>();
val5.sizeDelta = new Vector2(480f, 35f);
warningText = val4.AddComponent<TextMeshProUGUI>();
((TMP_Text)warningText).text = "Warning: Text formatting works only on selections.";
((TMP_Text)warningText).fontSize = 14f;
((Graphic)warningText).color = new Color(1f, 1f, 1f);
((TMP_Text)warningText).alignment = (TextAlignmentOptions)514;
((TMP_Text)warningText).fontStyle = (FontStyles)1;
RectTransform component = ((Component)warningText).GetComponent<RectTransform>();
component.anchorMin = Vector2.zero;
component.anchorMax = Vector2.one;
component.offsetMin = Vector2.zero;
component.offsetMax = Vector2.zero;
GameObject buttonPanel = new GameObject("FormattingButtons");
buttonPanel.transform.SetParent(val.transform, false);
RectTransform val6 = buttonPanel.AddComponent<RectTransform>();
val6.sizeDelta = new Vector2(480f, 50f);
Image val7 = buttonPanel.AddComponent<Image>();
((Graphic)val7).color = new Color(0.2f, 0.2f, 0.2f, 0.8f);
HorizontalLayoutGroup val8 = buttonPanel.AddComponent<HorizontalLayoutGroup>();
((HorizontalOrVerticalLayoutGroup)val8).spacing = 8f;
((LayoutGroup)val8).childAlignment = (TextAnchor)4;
((HorizontalOrVerticalLayoutGroup)val8).childControlWidth = false;
((HorizontalOrVerticalLayoutGroup)val8).childControlHeight = false;
((LayoutGroup)val8).padding = new RectOffset(10, 10, 5, 5);
CreateFormatButton(buttonPanel, "B", "bold");
CreateFormatButton(buttonPanel, "I", "italic");
CreateFormatButton(buttonPanel, "U", "underline");
CreateFormatButton(buttonPanel, "S", "strikethrough");
CreateDivider(buttonPanel);
foreach (FormatButtonData colorButton in colorButtons)
{
if (!formatTags.ContainsKey(colorButton.TagKey))
{
formatTags[colorButton.TagKey] = colorButton.TagKey;
}
if (IsDefaultColor(colorButton.TagKey))
{
CreateColorButton(buttonPanel, colorButton.Label, colorButton.TagKey, colorButton.ButtonColor);
}
else
{
CreateColorButton(buttonPanel, colorButton.Label, colorButton.TagKey, colorButton.ButtonColor, isCustom: true);
}
}
GameObject val9 = new GameObject("CustomColorPanel");
val9.transform.SetParent(val.transform, false);
RectTransform val10 = val9.AddComponent<RectTransform>();
val10.sizeDelta = new Vector2(480f, 40f);
HorizontalLayoutGroup val11 = val9.AddComponent<HorizontalLayoutGroup>();
((HorizontalOrVerticalLayoutGroup)val11).spacing = 10f;
((LayoutGroup)val11).childAlignment = (TextAnchor)4;
((HorizontalOrVerticalLayoutGroup)val11).childControlHeight = false;
((HorizontalOrVerticalLayoutGroup)val11).childControlWidth = false;
((LayoutGroup)val11).padding = new RectOffset(10, 10, 5, 5);
GameObject val12 = new GameObject("HexInputField");
val12.transform.SetParent(val9.transform, false);
RectTransform val13 = val12.AddComponent<RectTransform>();
val13.sizeDelta = new Vector2(150f, 35f);
TMP_InputField hexInput = val12.AddComponent<TMP_InputField>();
RectTransform val14 = new GameObject("Viewport").AddComponent<RectTransform>();
((Transform)val14).SetParent(((Component)hexInput).transform, false);
hexInput.textViewport = val14;
TextMeshProUGUI val15 = new GameObject("Text").AddComponent<TextMeshProUGUI>();
((TMP_Text)val15).transform.SetParent((Transform)(object)val14, false);
((TMP_Text)val15).fontSize = 14f;
((TMP_Text)val15).alignment = (TextAlignmentOptions)4097;
hexInput.textComponent = (TMP_Text)(object)val15;
hexInput.text = "#FFFFFF";
GameObject val16 = new GameObject("AddColorButton");
val16.transform.SetParent(val9.transform, false);
RectTransform val17 = val16.AddComponent<RectTransform>();
val17.sizeDelta = new Vector2(100f, 35f);
Button val18 = val16.AddComponent<Button>();
Image val19 = val16.AddComponent<Image>();
((Graphic)val19).color = new Color(0.3f, 0.3f, 0.3f);
GameObject val20 = new GameObject("Text");
val20.transform.SetParent(val16.transform, false);
TextMeshProUGUI val21 = val20.AddComponent<TextMeshProUGUI>();
((TMP_Text)val21).text = "Add Color";
((TMP_Text)val21).fontSize = 16f;
((Graphic)val21).color = Color.white;
((TMP_Text)val21).alignment = (TextAlignmentOptions)514;
RectTransform component2 = ((Component)val21).GetComponent<RectTransform>();
component2.anchorMin = Vector2.zero;
component2.anchorMax = Vector2.one;
component2.offsetMin = Vector2.zero;
component2.offsetMax = Vector2.zero;
((UnityEvent)val18.onClick).AddListener(UnityAction.op_Implicit((Action)delegate
{
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
string text = hexInput.text.Trim();
if (!text.StartsWith("#"))
{
text = "#" + text;
}
Color buttonColor = default(Color);
if (ColorUtility.TryParseHtmlString(text, ref buttonColor))
{
string tagKey = "color=" + text;
if (!formatTags.ContainsKey(tagKey))
{
string label = text.Substring(1, 2).ToUpper();
formatTags[tagKey] = tagKey;
if (!colorButtons.Any((FormatButtonData b) => b.TagKey == tagKey))
{
FormatButtonData item = new FormatButtonData(label, tagKey, buttonColor);
colorButtons.Add(item);
CreateColorButton(buttonPanel, label, tagKey, buttonColor, isCustom: true);
MelonLogger.Msg("Added custom color button: " + text);
SaveCustomColors();
}
}
}
else
{
MelonLogger.Msg("Invalid HEX color: " + hexInput.text);
}
}));
LoadCustomColors(buttonPanel);
}
private static void FlashWarningText()
{
if (!((Object)(object)warningText == (Object)null))
{
MelonLogger.Msg("No selection, flashing warning text!");
MelonCoroutines.Start(FlashTextCoroutine());
}
}
[IteratorStateMachine(typeof(<FlashTextCoroutine>d__11))]
private static IEnumerator FlashTextCoroutine()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <FlashTextCoroutine>d__11(0);
}
private static void CreateDivider(GameObject parent)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("Divider");
val.transform.SetParent(parent.transform, false);
Image val2 = val.AddComponent<Image>();
((Graphic)val2).color = new Color(0.7f, 0.7f, 0.7f, 0.5f);
RectTransform component = val.GetComponent<RectTransform>();
component.sizeDelta = new Vector2(2f, 40f);
}
private static void CreateFormatButton(GameObject parent, string label, string formatKey)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Expected O, but got Unknown
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Expected O, but got Unknown
//IL_0111: 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_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject(label + "Button");
val.transform.SetParent(parent.transform, false);
Button val2 = val.AddComponent<Button>();
Image val3 = val.AddComponent<Image>();
((Graphic)val3).color = new Color(0.3f, 0.3f, 0.3f);
RectTransform component = val.GetComponent<RectTransform>();
component.sizeDelta = new Vector2(35f, 35f);
Outline val4 = val.AddComponent<Outline>();
((Shadow)val4).effectColor = new Color(1f, 1f, 1f, 0.5f);
((Shadow)val4).effectDistance = new Vector2(1f, -1f);
GameObject val5 = new GameObject("Text");
val5.transform.SetParent(val.transform, false);
TextMeshProUGUI val6 = val5.AddComponent<TextMeshProUGUI>();
((TMP_Text)val6).text = label;
((TMP_Text)val6).fontSize = 20f;
((TMP_Text)val6).fontStyle = (FontStyles)1;
((TMP_Text)val6).alignment = (TextAlignmentOptions)514;
((Graphic)val6).color = Color.white;
RectTransform component2 = ((Component)val6).GetComponent<RectTransform>();
component2.anchorMin = Vector2.zero;
component2.anchorMax = Vector2.one;
component2.offsetMin = Vector2.zero;
component2.offsetMax = Vector2.zero;
((UnityEvent)val2.onClick).AddListener(UnityAction.op_Implicit((Action)delegate
{
ApplyFormatting(formatKey);
}));
formatButtons[formatKey] = val2;
}
private static void CreateColorButton(GameObject parent, string label, string colorKey, Color buttonColor, bool isCustom = false)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: 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)
//IL_00cf: Expected O, but got Unknown
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: 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_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Expected O, but got Unknown
//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
//IL_020a: Unknown result type (might be due to invalid IL or missing references)
//IL_0221: Unknown result type (might be due to invalid IL or missing references)
//IL_0238: Unknown result type (might be due to invalid IL or missing references)
//IL_0266: Unknown result type (might be due to invalid IL or missing references)
//IL_0276: Unknown result type (might be due to invalid IL or missing references)
//IL_027d: Expected O, but got Unknown
//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
//IL_02da: Unknown result type (might be due to invalid IL or missing references)
//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
//IL_0301: Unknown result type (might be due to invalid IL or missing references)
GameObject buttonObj = new GameObject(label + "Button");
buttonObj.transform.SetParent(parent.transform, false);
RectTransform val = buttonObj.AddComponent<RectTransform>();
val.sizeDelta = new Vector2(35f, 35f);
Button val2 = buttonObj.AddComponent<Button>();
Image val3 = buttonObj.AddComponent<Image>();
((Graphic)val3).color = buttonColor;
Outline val4 = buttonObj.AddComponent<Outline>();
((Shadow)val4).effectColor = new Color(1f, 1f, 1f, 0.5f);
((Shadow)val4).effectDistance = new Vector2(1f, -1f);
GameObject val5 = new GameObject("Text");
val5.transform.SetParent(buttonObj.transform, false);
TextMeshProUGUI val6 = val5.AddComponent<TextMeshProUGUI>();
((TMP_Text)val6).text = label;
((TMP_Text)val6).fontSize = 20f;
((TMP_Text)val6).fontStyle = (FontStyles)1;
((TMP_Text)val6).alignment = (TextAlignmentOptions)514;
((Graphic)val6).color = Color.white;
RectTransform component = ((Component)val6).GetComponent<RectTransform>();
component.anchorMin = Vector2.zero;
component.anchorMax = Vector2.one;
component.offsetMin = Vector2.zero;
component.offsetMax = Vector2.zero;
((UnityEvent)val2.onClick).AddListener(UnityAction.op_Implicit((Action)delegate
{
ApplyFormatting(colorKey);
}));
formatButtons[colorKey] = val2;
if (!isCustom)
{
return;
}
GameObject val7 = new GameObject("RemoveButton");
val7.transform.SetParent(buttonObj.transform, false);
RectTransform val8 = val7.AddComponent<RectTransform>();
val8.anchorMin = new Vector2(0f, 1f);
val8.anchorMax = new Vector2(0f, 1f);
val8.pivot = new Vector2(0f, 1f);
val8.anchoredPosition = new Vector2(2f, -2f);
val8.sizeDelta = new Vector2(12f, 12f);
Button val9 = val7.AddComponent<Button>();
Image val10 = val7.AddComponent<Image>();
((Graphic)val10).color = new Color(1f, 0.2f, 0.2f);
GameObject val11 = new GameObject("Text");
val11.transform.SetParent(val7.transform, false);
TextMeshProUGUI val12 = val11.AddComponent<TextMeshProUGUI>();
((TMP_Text)val12).text = "X";
((TMP_Text)val12).fontSize = 10f;
((TMP_Text)val12).alignment = (TextAlignmentOptions)514;
((Graphic)val12).color = Color.white;
RectTransform component2 = ((Component)val12).GetComponent<RectTransform>();
component2.anchorMin = Vector2.zero;
component2.anchorMax = Vector2.one;
component2.offsetMin = Vector2.zero;
component2.offsetMax = Vector2.zero;
((UnityEvent)val9.onClick).AddListener(UnityAction.op_Implicit((Action)delegate
{
Object.Destroy((Object)(object)buttonObj);
formatButtons.Remove(colorKey);
colorButtons.RemoveAll((FormatButtonData b) => b.TagKey == colorKey);
SaveCustomColors();
MelonLogger.Msg("Removed custom color button: " + colorKey);
}));
}
private static void ApplyFormatting(string formatKey)
{
if (!((Object)(object)inputField == (Object)null))
{
int num = inputField.selectionAnchorPosition;
int num2 = inputField.selectionFocusPosition;
if (num > num2)
{
int num3 = num2;
num2 = num;
num = num3;
}
if (num == num2)
{
FlashWarningText();
return;
}
string text = formatTags[formatKey];
string text2 = "<" + text + ">";
string text3 = (formatKey.StartsWith("color") ? "</color>" : ("</" + text + ">"));
MelonLogger.Msg($"Applying formatting: {formatKey} from {num} to {num2}");
MelonLogger.Msg("Tags: " + text2 + " " + text3);
string text4 = inputField.text;
string text5 = TextFormatterUtils.ApplyTag(text4, num, num2, text2, text3);
MelonLogger.Msg("Old text: " + text4 + "; New text: " + text5);
inputField.text = text5;
}
}
[HarmonyPrefix]
[HarmonyPatch("Close")]
public static void CleanupFormattingUI()
{
inputField = null;
formatButtons.Clear();
GameObject val = GameObject.Find("FormattingEditorContainer");
if ((Object)(object)val != (Object)null)
{
Object.Destroy((Object)(object)val);
}
}
}
private static Instance MelonLogger { get; set; }
public override void OnInitializeMelon()
{
MelonLogger = ((MelonBase)this).LoggerInstance;
MelonLogger.Msg("TextDecorator initialized");
}
}
public static class TextFormatterUtils
{
private static readonly Regex tagRegex = new Regex("<.*?>", RegexOptions.Compiled);
public static string ApplyTag(string richText, int plainStart, int plainEnd, string openTag, string closeTag)
{
if (plainStart >= plainEnd)
{
return richText;
}
string text = tagRegex.Replace(richText, "");
if (plainStart < 0 || plainEnd > text.Length)
{
return richText;
}
int richTextIndex = GetRichTextIndex(richText, plainStart);
int richTextIndex2 = GetRichTextIndex(richText, plainEnd);
if (richTextIndex == -1 || richTextIndex2 == -1 || richTextIndex >= richTextIndex2)
{
return richText;
}
string text2 = richText.Substring(0, richTextIndex);
string text3 = richText.Substring(richTextIndex, richTextIndex2 - richTextIndex);
string text4 = richText.Substring(richTextIndex2);
return text2 + openTag + text3 + closeTag + text4;
}
private static int GetRichTextIndex(string richText, int plainIndex)
{
int i = 0;
int num = 0;
bool flag = false;
for (; i < richText.Length; i++)
{
char c = richText[i];
if (c == '<')
{
flag = true;
}
if (!flag)
{
if (num == plainIndex)
{
return i;
}
num++;
}
if (c == '>')
{
flag = false;
}
}
return (num == plainIndex) ? i : (-1);
}
}
}
namespace TextDecorator.Helpers
{
public static class Il2CppListExtensions
{
public static IEnumerable<T> AsEnumerable<T>(this List<T> list)
{
return list ?? new List<T>();
}
public static List<T> ToIl2CppList<T>(this IEnumerable<T> source)
{
List<T> val = new List<T>();
foreach (T item in source)
{
val.Add(item);
}
return val;
}
public static List<T> ConvertToList<T>(List<T> il2CppList)
{
List<T> list = new List<T>();
T[] collection = Il2CppArrayBase<T>.op_Implicit(il2CppList.ToArray());
list.AddRange(collection);
return list;
}
public static IEnumerable<T> AsEnumerable<T>(this List<T> list)
{
IEnumerable<T> result;
if (list != null)
{
result = ((IEnumerable<T>)list._items).Take(list._size);
}
else
{
IEnumerable<T> enumerable = Array.Empty<T>();
result = enumerable;
}
return result;
}
}
public static class Utils
{
[CompilerGenerated]
private sealed class <WaitForNetwork>d__5 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public IEnumerator routine;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitForNetwork>d__5(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
break;
case 1:
<>1__state = -1;
break;
}
if (!InstanceFinder.IsServer && !InstanceFinder.IsClient)
{
<>2__current = null;
<>1__state = 1;
return true;
}
MelonCoroutines.Start(routine);
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <WaitForNetworkSingleton>d__7<T> : IEnumerator<object>, IEnumerator, IDisposable where T : notnull, NetworkSingleton<T>
{
private int <>1__state;
private object <>2__current;
public IEnumerator coroutine;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitForNetworkSingleton>d__7(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
goto IL_0044;
case 1:
<>1__state = -1;
goto IL_0044;
case 2:
{
<>1__state = -1;
return false;
}
IL_0044:
if (!NetworkSingleton<T>.InstanceExists)
{
<>2__current = null;
<>1__state = 1;
return true;
}
<>2__current = coroutine;
<>1__state = 2;
return true;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <WaitForNotNull>d__6 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public object obj;
public float timeout;
public Action onTimeout;
public Action onFinish;
private float <startTime>5__1;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitForNotNull>d__6(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<startTime>5__1 = Time.time;
break;
case 1:
<>1__state = -1;
break;
}
if (obj == null)
{
if (!float.IsNaN(timeout) && Time.time - <startTime>5__1 > timeout)
{
onTimeout?.Invoke();
return false;
}
<>2__current = null;
<>1__state = 1;
return true;
}
onFinish?.Invoke();
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <WaitForPlayer>d__4 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public IEnumerator routine;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitForPlayer>d__4(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
break;
case 1:
<>1__state = -1;
break;
}
if ((Object)(object)Player.Local == (Object)null || (Object)(object)((Component)Player.Local).gameObject == (Object)null)
{
<>2__current = null;
<>1__state = 1;
return true;
}
MelonCoroutines.Start(routine);
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <WaitForSingleton>d__8<T> : IEnumerator<object>, IEnumerator, IDisposable where T : notnull, Singleton<T>
{
private int <>1__state;
private object <>2__current;
public IEnumerator coroutine;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitForSingleton>d__8(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
goto IL_0044;
case 1:
<>1__state = -1;
goto IL_0044;
case 2:
{
<>1__state = -1;
return false;
}
IL_0044:
if (!Singleton<T>.InstanceExists)
{
<>2__current = null;
<>1__state = 1;
return true;
}
<>2__current = coroutine;
<>1__state = 2;
return true;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private static readonly Instance Logger = new Instance("Text Decorator-Utils");
public static List<T> GetAllComponentsInChildrenRecursive<T>(GameObject obj) where T : Component
{
List<T> list = new List<T>();
if ((Object)(object)obj == (Object)null)
{
return list;
}
T[] array = Il2CppArrayBase<T>.op_Implicit(obj.GetComponents<T>());
if (array.Length != 0)
{
list.AddRange(array);
}
for (int i = 0; i < obj.transform.childCount; i++)
{
Transform child = obj.transform.GetChild(i);
list.AddRange(GetAllComponentsInChildrenRecursive<T>(((Component)child).gameObject));
}
return list;
}
public static bool Is<T>(object obj, out T result) where T : Object
{
Object val = (Object)((obj is Object) ? obj : null);
if (val != null)
{
Type val2 = Il2CppType.Of<T>();
Type il2CppType = val.GetIl2CppType();
if (val2.IsAssignableFrom(il2CppType))
{
result = ((Il2CppObjectBase)val).TryCast<T>();
return result != null;
}
}
result = default(T);
return false;
}
public static List<StorableItemDefinition> GetAllStorableItemDefinitions()
{
List<ItemRegister> list = Il2CppListExtensions.ConvertToList<ItemRegister>(Singleton<Registry>.Instance.ItemRegistry);
List<StorableItemDefinition> list2 = new List<StorableItemDefinition>();
foreach (ItemRegister item in list)
{
if (Utils.Is<StorableItemDefinition>((object)item.Definition, out StorableItemDefinition result))
{
list2.Add(result);
}
else
{
Logger.Warning("Definition " + ((object)item.Definition)?.GetType().FullName + " is not a StorableItemDefinition");
}
}
return list2.ToList();
}
[IteratorStateMachine(typeof(<WaitForPlayer>d__4))]
public static IEnumerator WaitForPlayer(IEnumerator routine)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitForPlayer>d__4(0)
{
routine = routine
};
}
[IteratorStateMachine(typeof(<WaitForNetwork>d__5))]
public static IEnumerator WaitForNetwork(IEnumerator routine)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitForNetwork>d__5(0)
{
routine = routine
};
}
[IteratorStateMachine(typeof(<WaitForNotNull>d__6))]
public static IEnumerator WaitForNotNull(object? obj, float timeout = float.NaN, Action onTimeout = null, Action onFinish = null)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitForNotNull>d__6(0)
{
obj = obj,
timeout = timeout,
onTimeout = onTimeout,
onFinish = onFinish
};
}
[IteratorStateMachine(typeof(<WaitForNetworkSingleton>d__7<>))]
public static IEnumerator WaitForNetworkSingleton<T>(IEnumerator coroutine) where T : NetworkSingleton<T>
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitForNetworkSingleton>d__7<T>(0)
{
coroutine = coroutine
};
}
[IteratorStateMachine(typeof(<WaitForSingleton>d__8<>))]
public static IEnumerator WaitForSingleton<T>(IEnumerator coroutine) where T : Singleton<T>
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitForSingleton>d__8<T>(0)
{
coroutine = coroutine
};
}
}
}using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using FishNet;
using HarmonyLib;
using MelonLoader;
using MelonLoader.Utils;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using ScheduleOne;
using ScheduleOne.DevUtilities;
using ScheduleOne.ItemFramework;
using ScheduleOne.PlayerScripts;
using ScheduleOne.UI;
using TMPro;
using TextDecorator;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(global::TextDecorator.TextDecorator), "Text Decorator", "0.6.0", "k073l", null)]
[assembly: MelonColor(1, 255, 215, 0)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("TextDecorator-Mono")]
[assembly: AssemblyConfiguration("Release Mono")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+c06a856efeab89e10efdfb8effe0618330b413d2")]
[assembly: AssemblyProduct("TextDecorator-Mono")]
[assembly: AssemblyTitle("TextDecorator-Mono")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[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 TextDecorator
{
public static class BuildInfo
{
public const string Name = "Text Decorator";
public const string Description = "Adds text formatting options to the text input screen.";
public const string Author = "k073l";
public const string Version = "0.6.0";
}
[Serializable]
public class ColorData
{
public int R;
public int G;
public int B;
public ColorData(int r, int g, int b)
{
R = r;
G = g;
B = b;
}
public static ColorData FromColor(Color color)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
return new ColorData(Mathf.RoundToInt(color.r * 255f), Mathf.RoundToInt(color.g * 255f), Mathf.RoundToInt(color.b * 255f));
}
public Color ToColor()
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: 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)
return new Color((float)R / 255f, (float)G / 255f, (float)B / 255f);
}
}
[Serializable]
public class FormatButtonData
{
public string Label;
public string TagKey;
public ColorData ButtonColorData;
[JsonIgnore]
public Color ButtonColor => ButtonColorData.ToColor();
public FormatButtonData(string label, string tagKey, Color buttonColor)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
Label = label;
TagKey = tagKey;
ButtonColorData = ColorData.FromColor(buttonColor);
}
}
[Serializable]
public class CustomColorConfig
{
public List<FormatButtonData> customColors = new List<FormatButtonData>();
}
public class TextDecorator : MelonMod
{
[HarmonyPatch(typeof(TextInputScreen))]
public static class TextInputScreenPatch
{
[CompilerGenerated]
private sealed class <FlashTextCoroutine>d__11 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <FlashTextCoroutine>d__11(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0025: 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: Expected O, but got Unknown
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
((Graphic)warningText).color = Color.yellow;
<>2__current = (object)new WaitForSeconds(0.5f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
((Graphic)warningText).color = Color.white;
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private static Dictionary<string, Button> formatButtons = new Dictionary<string, Button>();
private static List<FormatButtonData> colorButtons = new List<FormatButtonData>
{
new FormatButtonData("R", "color=#FF5555", new Color(1f, 0.33f, 0.33f)),
new FormatButtonData("G", "color=#55FF55", new Color(0.33f, 1f, 0.33f)),
new FormatButtonData("B", "color=#5555FF", new Color(0.33f, 0.33f, 1f)),
new FormatButtonData("Y", "color=#FFFF55", new Color(1f, 1f, 0.33f)),
new FormatButtonData("P", "color=#FF55FF", new Color(1f, 0.33f, 1f))
};
private static readonly Dictionary<string, string> formatTags = new Dictionary<string, string>
{
{ "bold", "b" },
{ "italic", "i" },
{ "underline", "u" },
{ "strikethrough", "s" }
};
private static TMP_InputField inputField;
private static TextMeshProUGUI warningText;
private static readonly string ConfigFilePath = Path.Combine(MelonEnvironment.UserDataDirectory, "TextDecoratorColors.json");
private static void SaveCustomColors()
{
CustomColorConfig customColorConfig = new CustomColorConfig
{
customColors = colorButtons.Where((FormatButtonData b) => !IsDefaultColor(b.TagKey)).ToList()
};
try
{
string contents = JsonConvert.SerializeObject((object)customColorConfig, (Formatting)1);
File.WriteAllText(ConfigFilePath, contents);
}
catch (Exception ex)
{
MelonLogger.Error("Failed to save custom colors: " + ex.Message);
}
}
private static void LoadCustomColors(GameObject buttonPanel)
{
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
if (!File.Exists(ConfigFilePath))
{
return;
}
try
{
string text = File.ReadAllText(ConfigFilePath);
CustomColorConfig customColorConfig = JsonConvert.DeserializeObject<CustomColorConfig>(text);
foreach (FormatButtonData btn in customColorConfig.customColors)
{
formatTags[btn.TagKey] = btn.TagKey;
if (!colorButtons.Any((FormatButtonData b) => b.TagKey == btn.TagKey))
{
colorButtons.Add(btn);
CreateColorButton(buttonPanel, btn.Label, btn.TagKey, btn.ButtonColor, isCustom: true);
}
}
}
catch (Exception ex)
{
MelonLogger.Error("Failed to load custom colors: " + ex.Message);
}
}
private static bool IsDefaultColor(string tagKey)
{
if (1 == 0)
{
}
bool result;
switch (tagKey)
{
case "color=#FF5555":
case "color=#55FF55":
case "color=#5555FF":
case "color=#FFFF55":
case "color=#FF55FF":
result = true;
break;
default:
result = false;
break;
}
if (1 == 0)
{
}
return result;
}
[HarmonyPostfix]
[HarmonyPatch("Open")]
public static void AddFormattingUI(TextInputScreen __instance)
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
//IL_0062: 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_008e: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Expected O, but got Unknown
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
//IL_01e7: Expected O, but got Unknown
//IL_0218: Unknown result type (might be due to invalid IL or missing references)
//IL_0246: Unknown result type (might be due to invalid IL or missing references)
//IL_028e: Unknown result type (might be due to invalid IL or missing references)
//IL_0298: Expected O, but got Unknown
//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
//IL_03d0: Expected O, but got Unknown
//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
//IL_043d: Unknown result type (might be due to invalid IL or missing references)
//IL_0447: Expected O, but got Unknown
//IL_044d: Unknown result type (might be due to invalid IL or missing references)
//IL_0454: Expected O, but got Unknown
//IL_047e: Unknown result type (might be due to invalid IL or missing references)
//IL_049b: Unknown result type (might be due to invalid IL or missing references)
//IL_04ce: Unknown result type (might be due to invalid IL or missing references)
//IL_0528: Unknown result type (might be due to invalid IL or missing references)
//IL_052f: Expected O, but got Unknown
//IL_0559: Unknown result type (might be due to invalid IL or missing references)
//IL_0587: Unknown result type (might be due to invalid IL or missing references)
//IL_0597: Unknown result type (might be due to invalid IL or missing references)
//IL_059e: Expected O, but got Unknown
//IL_05d8: Unknown result type (might be due to invalid IL or missing references)
//IL_05fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0608: Unknown result type (might be due to invalid IL or missing references)
//IL_0615: Unknown result type (might be due to invalid IL or missing references)
//IL_0622: Unknown result type (might be due to invalid IL or missing references)
//IL_063b: Unknown result type (might be due to invalid IL or missing references)
//IL_0645: Expected O, but got Unknown
//IL_039a: Unknown result type (might be due to invalid IL or missing references)
//IL_0376: Unknown result type (might be due to invalid IL or missing references)
inputField = __instance.InputField;
inputField.characterLimit = 10000;
formatButtons.Clear();
GameObject val = new GameObject("FormattingEditorContainer");
val.transform.SetParent(((Component)__instance.Canvas).transform, false);
RectTransform val2 = val.AddComponent<RectTransform>();
val2.anchorMin = new Vector2(0.5f, 0f);
val2.anchorMax = new Vector2(0.5f, 0f);
val2.pivot = new Vector2(0.5f, 0f);
val2.anchoredPosition = new Vector2(0f, 160f);
val2.sizeDelta = new Vector2(480f, 110f);
VerticalLayoutGroup val3 = val.AddComponent<VerticalLayoutGroup>();
((HorizontalOrVerticalLayoutGroup)val3).spacing = 5f;
((LayoutGroup)val3).childAlignment = (TextAnchor)1;
((HorizontalOrVerticalLayoutGroup)val3).childForceExpandWidth = true;
((HorizontalOrVerticalLayoutGroup)val3).childForceExpandHeight = false;
GameObject val4 = new GameObject("WarningText");
val4.transform.SetParent(val.transform, false);
RectTransform val5 = val4.AddComponent<RectTransform>();
val5.sizeDelta = new Vector2(480f, 35f);
warningText = val4.AddComponent<TextMeshProUGUI>();
((TMP_Text)warningText).text = "Warning: Text formatting works only on selections.";
((TMP_Text)warningText).fontSize = 14f;
((Graphic)warningText).color = new Color(1f, 1f, 1f);
((TMP_Text)warningText).alignment = (TextAlignmentOptions)514;
((TMP_Text)warningText).fontStyle = (FontStyles)1;
RectTransform component = ((Component)warningText).GetComponent<RectTransform>();
component.anchorMin = Vector2.zero;
component.anchorMax = Vector2.one;
component.offsetMin = Vector2.zero;
component.offsetMax = Vector2.zero;
GameObject buttonPanel = new GameObject("FormattingButtons");
buttonPanel.transform.SetParent(val.transform, false);
RectTransform val6 = buttonPanel.AddComponent<RectTransform>();
val6.sizeDelta = new Vector2(480f, 50f);
Image val7 = buttonPanel.AddComponent<Image>();
((Graphic)val7).color = new Color(0.2f, 0.2f, 0.2f, 0.8f);
HorizontalLayoutGroup val8 = buttonPanel.AddComponent<HorizontalLayoutGroup>();
((HorizontalOrVerticalLayoutGroup)val8).spacing = 8f;
((LayoutGroup)val8).childAlignment = (TextAnchor)4;
((HorizontalOrVerticalLayoutGroup)val8).childControlWidth = false;
((HorizontalOrVerticalLayoutGroup)val8).childControlHeight = false;
((LayoutGroup)val8).padding = new RectOffset(10, 10, 5, 5);
CreateFormatButton(buttonPanel, "B", "bold");
CreateFormatButton(buttonPanel, "I", "italic");
CreateFormatButton(buttonPanel, "U", "underline");
CreateFormatButton(buttonPanel, "S", "strikethrough");
CreateDivider(buttonPanel);
foreach (FormatButtonData colorButton in colorButtons)
{
if (!formatTags.ContainsKey(colorButton.TagKey))
{
formatTags[colorButton.TagKey] = colorButton.TagKey;
}
if (IsDefaultColor(colorButton.TagKey))
{
CreateColorButton(buttonPanel, colorButton.Label, colorButton.TagKey, colorButton.ButtonColor);
}
else
{
CreateColorButton(buttonPanel, colorButton.Label, colorButton.TagKey, colorButton.ButtonColor, isCustom: true);
}
}
GameObject val9 = new GameObject("CustomColorPanel");
val9.transform.SetParent(val.transform, false);
RectTransform val10 = val9.AddComponent<RectTransform>();
val10.sizeDelta = new Vector2(480f, 40f);
HorizontalLayoutGroup val11 = val9.AddComponent<HorizontalLayoutGroup>();
((HorizontalOrVerticalLayoutGroup)val11).spacing = 10f;
((LayoutGroup)val11).childAlignment = (TextAnchor)4;
((HorizontalOrVerticalLayoutGroup)val11).childControlHeight = false;
((HorizontalOrVerticalLayoutGroup)val11).childControlWidth = false;
((LayoutGroup)val11).padding = new RectOffset(10, 10, 5, 5);
GameObject val12 = new GameObject("HexInputField");
val12.transform.SetParent(val9.transform, false);
RectTransform val13 = val12.AddComponent<RectTransform>();
val13.sizeDelta = new Vector2(150f, 35f);
TMP_InputField hexInput = val12.AddComponent<TMP_InputField>();
RectTransform val14 = new GameObject("Viewport").AddComponent<RectTransform>();
((Transform)val14).SetParent(((Component)hexInput).transform, false);
hexInput.textViewport = val14;
TextMeshProUGUI val15 = new GameObject("Text").AddComponent<TextMeshProUGUI>();
((TMP_Text)val15).transform.SetParent((Transform)(object)val14, false);
((TMP_Text)val15).fontSize = 14f;
((TMP_Text)val15).alignment = (TextAlignmentOptions)4097;
hexInput.textComponent = (TMP_Text)(object)val15;
hexInput.text = "#FFFFFF";
GameObject val16 = new GameObject("AddColorButton");
val16.transform.SetParent(val9.transform, false);
RectTransform val17 = val16.AddComponent<RectTransform>();
val17.sizeDelta = new Vector2(100f, 35f);
Button val18 = val16.AddComponent<Button>();
Image val19 = val16.AddComponent<Image>();
((Graphic)val19).color = new Color(0.3f, 0.3f, 0.3f);
GameObject val20 = new GameObject("Text");
val20.transform.SetParent(val16.transform, false);
TextMeshProUGUI val21 = val20.AddComponent<TextMeshProUGUI>();
((TMP_Text)val21).text = "Add Color";
((TMP_Text)val21).fontSize = 16f;
((Graphic)val21).color = Color.white;
((TMP_Text)val21).alignment = (TextAlignmentOptions)514;
RectTransform component2 = ((Component)val21).GetComponent<RectTransform>();
component2.anchorMin = Vector2.zero;
component2.anchorMax = Vector2.one;
component2.offsetMin = Vector2.zero;
component2.offsetMax = Vector2.zero;
((UnityEvent)val18.onClick).AddListener((UnityAction)delegate
{
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
string text = hexInput.text.Trim();
if (!text.StartsWith("#"))
{
text = "#" + text;
}
Color buttonColor = default(Color);
if (ColorUtility.TryParseHtmlString(text, ref buttonColor))
{
string tagKey = "color=" + text;
if (!formatTags.ContainsKey(tagKey))
{
string label = text.Substring(1, 2).ToUpper();
formatTags[tagKey] = tagKey;
if (!colorButtons.Any((FormatButtonData b) => b.TagKey == tagKey))
{
FormatButtonData item = new FormatButtonData(label, tagKey, buttonColor);
colorButtons.Add(item);
CreateColorButton(buttonPanel, label, tagKey, buttonColor, isCustom: true);
MelonLogger.Msg("Added custom color button: " + text);
SaveCustomColors();
}
}
}
else
{
MelonLogger.Msg("Invalid HEX color: " + hexInput.text);
}
});
LoadCustomColors(buttonPanel);
}
private static void FlashWarningText()
{
if (!((Object)(object)warningText == (Object)null))
{
MelonLogger.Msg("No selection, flashing warning text!");
MelonCoroutines.Start(FlashTextCoroutine());
}
}
[IteratorStateMachine(typeof(<FlashTextCoroutine>d__11))]
private static IEnumerator FlashTextCoroutine()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <FlashTextCoroutine>d__11(0);
}
private static void CreateDivider(GameObject parent)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("Divider");
val.transform.SetParent(parent.transform, false);
Image val2 = val.AddComponent<Image>();
((Graphic)val2).color = new Color(0.7f, 0.7f, 0.7f, 0.5f);
RectTransform component = val.GetComponent<RectTransform>();
component.sizeDelta = new Vector2(2f, 40f);
}
private static void CreateFormatButton(GameObject parent, string label, string formatKey)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Expected O, but got Unknown
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Expected O, but got Unknown
//IL_0111: 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_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_0170: Expected O, but got Unknown
GameObject val = new GameObject(label + "Button");
val.transform.SetParent(parent.transform, false);
Button val2 = val.AddComponent<Button>();
Image val3 = val.AddComponent<Image>();
((Graphic)val3).color = new Color(0.3f, 0.3f, 0.3f);
RectTransform component = val.GetComponent<RectTransform>();
component.sizeDelta = new Vector2(35f, 35f);
Outline val4 = val.AddComponent<Outline>();
((Shadow)val4).effectColor = new Color(1f, 1f, 1f, 0.5f);
((Shadow)val4).effectDistance = new Vector2(1f, -1f);
GameObject val5 = new GameObject("Text");
val5.transform.SetParent(val.transform, false);
TextMeshProUGUI val6 = val5.AddComponent<TextMeshProUGUI>();
((TMP_Text)val6).text = label;
((TMP_Text)val6).fontSize = 20f;
((TMP_Text)val6).fontStyle = (FontStyles)1;
((TMP_Text)val6).alignment = (TextAlignmentOptions)514;
((Graphic)val6).color = Color.white;
RectTransform component2 = ((Component)val6).GetComponent<RectTransform>();
component2.anchorMin = Vector2.zero;
component2.anchorMax = Vector2.one;
component2.offsetMin = Vector2.zero;
component2.offsetMax = Vector2.zero;
((UnityEvent)val2.onClick).AddListener((UnityAction)delegate
{
ApplyFormatting(formatKey);
});
formatButtons[formatKey] = val2;
}
private static void CreateColorButton(GameObject parent, string label, string colorKey, Color buttonColor, bool isCustom = false)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: 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)
//IL_00cf: Expected O, but got Unknown
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: 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_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_017e: Expected O, but got Unknown
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
//IL_01a9: Expected O, but got Unknown
//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
//IL_0205: Unknown result type (might be due to invalid IL or missing references)
//IL_021c: Unknown result type (might be due to invalid IL or missing references)
//IL_0233: Unknown result type (might be due to invalid IL or missing references)
//IL_0261: Unknown result type (might be due to invalid IL or missing references)
//IL_0271: Unknown result type (might be due to invalid IL or missing references)
//IL_0278: Expected O, but got Unknown
//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0315: Unknown result type (might be due to invalid IL or missing references)
//IL_031f: Expected O, but got Unknown
GameObject buttonObj = new GameObject(label + "Button");
buttonObj.transform.SetParent(parent.transform, false);
RectTransform val = buttonObj.AddComponent<RectTransform>();
val.sizeDelta = new Vector2(35f, 35f);
Button val2 = buttonObj.AddComponent<Button>();
Image val3 = buttonObj.AddComponent<Image>();
((Graphic)val3).color = buttonColor;
Outline val4 = buttonObj.AddComponent<Outline>();
((Shadow)val4).effectColor = new Color(1f, 1f, 1f, 0.5f);
((Shadow)val4).effectDistance = new Vector2(1f, -1f);
GameObject val5 = new GameObject("Text");
val5.transform.SetParent(buttonObj.transform, false);
TextMeshProUGUI val6 = val5.AddComponent<TextMeshProUGUI>();
((TMP_Text)val6).text = label;
((TMP_Text)val6).fontSize = 20f;
((TMP_Text)val6).fontStyle = (FontStyles)1;
((TMP_Text)val6).alignment = (TextAlignmentOptions)514;
((Graphic)val6).color = Color.white;
RectTransform component = ((Component)val6).GetComponent<RectTransform>();
component.anchorMin = Vector2.zero;
component.anchorMax = Vector2.one;
component.offsetMin = Vector2.zero;
component.offsetMax = Vector2.zero;
((UnityEvent)val2.onClick).AddListener((UnityAction)delegate
{
ApplyFormatting(colorKey);
});
formatButtons[colorKey] = val2;
if (!isCustom)
{
return;
}
GameObject val7 = new GameObject("RemoveButton");
val7.transform.SetParent(buttonObj.transform, false);
RectTransform val8 = val7.AddComponent<RectTransform>();
val8.anchorMin = new Vector2(0f, 1f);
val8.anchorMax = new Vector2(0f, 1f);
val8.pivot = new Vector2(0f, 1f);
val8.anchoredPosition = new Vector2(2f, -2f);
val8.sizeDelta = new Vector2(12f, 12f);
Button val9 = val7.AddComponent<Button>();
Image val10 = val7.AddComponent<Image>();
((Graphic)val10).color = new Color(1f, 0.2f, 0.2f);
GameObject val11 = new GameObject("Text");
val11.transform.SetParent(val7.transform, false);
TextMeshProUGUI val12 = val11.AddComponent<TextMeshProUGUI>();
((TMP_Text)val12).text = "X";
((TMP_Text)val12).fontSize = 10f;
((TMP_Text)val12).alignment = (TextAlignmentOptions)514;
((Graphic)val12).color = Color.white;
RectTransform component2 = ((Component)val12).GetComponent<RectTransform>();
component2.anchorMin = Vector2.zero;
component2.anchorMax = Vector2.one;
component2.offsetMin = Vector2.zero;
component2.offsetMax = Vector2.zero;
((UnityEvent)val9.onClick).AddListener((UnityAction)delegate
{
Object.Destroy((Object)(object)buttonObj);
formatButtons.Remove(colorKey);
colorButtons.RemoveAll((FormatButtonData b) => b.TagKey == colorKey);
SaveCustomColors();
MelonLogger.Msg("Removed custom color button: " + colorKey);
});
}
private static void ApplyFormatting(string formatKey)
{
if (!((Object)(object)inputField == (Object)null))
{
int num = inputField.selectionAnchorPosition;
int num2 = inputField.selectionFocusPosition;
if (num > num2)
{
int num3 = num2;
num2 = num;
num = num3;
}
if (num == num2)
{
FlashWarningText();
return;
}
string text = formatTags[formatKey];
string text2 = "<" + text + ">";
string text3 = (formatKey.StartsWith("color") ? "</color>" : ("</" + text + ">"));
MelonLogger.Msg($"Applying formatting: {formatKey} from {num} to {num2}");
MelonLogger.Msg("Tags: " + text2 + " " + text3);
string text4 = inputField.text;
string text5 = TextFormatterUtils.ApplyTag(text4, num, num2, text2, text3);
MelonLogger.Msg("Old text: " + text4 + "; New text: " + text5);
inputField.text = text5;
}
}
[HarmonyPrefix]
[HarmonyPatch("Close")]
public static void CleanupFormattingUI()
{
inputField = null;
formatButtons.Clear();
GameObject val = GameObject.Find("FormattingEditorContainer");
if ((Object)(object)val != (Object)null)
{
Object.Destroy((Object)(object)val);
}
}
}
private static Instance MelonLogger { get; set; }
public override void OnInitializeMelon()
{
MelonLogger = ((MelonBase)this).LoggerInstance;
MelonLogger.Msg("TextDecorator initialized");
}
}
public static class TextFormatterUtils
{
private static readonly Regex tagRegex = new Regex("<.*?>", RegexOptions.Compiled);
public static string ApplyTag(string richText, int plainStart, int plainEnd, string openTag, string closeTag)
{
if (plainStart >= plainEnd)
{
return richText;
}
string text = tagRegex.Replace(richText, "");
if (plainStart < 0 || plainEnd > text.Length)
{
return richText;
}
int richTextIndex = GetRichTextIndex(richText, plainStart);
int richTextIndex2 = GetRichTextIndex(richText, plainEnd);
if (richTextIndex == -1 || richTextIndex2 == -1 || richTextIndex >= richTextIndex2)
{
return richText;
}
string text2 = richText.Substring(0, richTextIndex);
string text3 = richText.Substring(richTextIndex, richTextIndex2 - richTextIndex);
string text4 = richText.Substring(richTextIndex2);
return text2 + openTag + text3 + closeTag + text4;
}
private static int GetRichTextIndex(string richText, int plainIndex)
{
int i = 0;
int num = 0;
bool flag = false;
for (; i < richText.Length; i++)
{
char c = richText[i];
if (c == '<')
{
flag = true;
}
if (!flag)
{
if (num == plainIndex)
{
return i;
}
num++;
}
if (c == '>')
{
flag = false;
}
}
return (num == plainIndex) ? i : (-1);
}
}
}
namespace TextDecorator.Helpers
{
public static class Il2CppListExtensions
{
public static IEnumerable<T> AsEnumerable<T>(this List<T> list)
{
return list ?? new List<T>();
}
}
public static class Utils
{
[CompilerGenerated]
private sealed class <WaitForNetwork>d__5 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public IEnumerator routine;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitForNetwork>d__5(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
break;
case 1:
<>1__state = -1;
break;
}
if (!InstanceFinder.IsServer && !InstanceFinder.IsClient)
{
<>2__current = null;
<>1__state = 1;
return true;
}
MelonCoroutines.Start(routine);
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <WaitForNetworkSingleton>d__7<T> : IEnumerator<object>, IEnumerator, IDisposable where T : notnull, NetworkSingleton<T>
{
private int <>1__state;
private object <>2__current;
public IEnumerator coroutine;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitForNetworkSingleton>d__7(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
goto IL_0044;
case 1:
<>1__state = -1;
goto IL_0044;
case 2:
{
<>1__state = -1;
return false;
}
IL_0044:
if (!NetworkSingleton<T>.InstanceExists)
{
<>2__current = null;
<>1__state = 1;
return true;
}
<>2__current = coroutine;
<>1__state = 2;
return true;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <WaitForNotNull>d__6 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public object obj;
public float timeout;
public Action onTimeout;
public Action onFinish;
private float <startTime>5__1;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitForNotNull>d__6(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<startTime>5__1 = Time.time;
break;
case 1:
<>1__state = -1;
break;
}
if (obj == null)
{
if (!float.IsNaN(timeout) && Time.time - <startTime>5__1 > timeout)
{
onTimeout?.Invoke();
return false;
}
<>2__current = null;
<>1__state = 1;
return true;
}
onFinish?.Invoke();
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <WaitForPlayer>d__4 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public IEnumerator routine;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitForPlayer>d__4(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
break;
case 1:
<>1__state = -1;
break;
}
if ((Object)(object)Player.Local == (Object)null || (Object)(object)((Component)Player.Local).gameObject == (Object)null)
{
<>2__current = null;
<>1__state = 1;
return true;
}
MelonCoroutines.Start(routine);
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <WaitForSingleton>d__8<T> : IEnumerator<object>, IEnumerator, IDisposable where T : notnull, Singleton<T>
{
private int <>1__state;
private object <>2__current;
public IEnumerator coroutine;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitForSingleton>d__8(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
goto IL_0044;
case 1:
<>1__state = -1;
goto IL_0044;
case 2:
{
<>1__state = -1;
return false;
}
IL_0044:
if (!Singleton<T>.InstanceExists)
{
<>2__current = null;
<>1__state = 1;
return true;
}
<>2__current = coroutine;
<>1__state = 2;
return true;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private static readonly Instance Logger = new Instance("Text Decorator-Utils");
public static List<T> GetAllComponentsInChildrenRecursive<T>(GameObject obj) where T : Component
{
List<T> list = new List<T>();
if ((Object)(object)obj == (Object)null)
{
return list;
}
T[] components = obj.GetComponents<T>();
if (components.Length != 0)
{
list.AddRange(components);
}
for (int i = 0; i < obj.transform.childCount; i++)
{
Transform child = obj.transform.GetChild(i);
list.AddRange(GetAllComponentsInChildrenRecursive<T>(((Component)child).gameObject));
}
return list;
}
public static bool Is<T>(object obj, out T result) where T : class
{
if (obj is T val)
{
result = val;
return true;
}
result = null;
return false;
}
public static List<StorableItemDefinition> GetAllStorableItemDefinitions()
{
List<ItemRegister> list = Singleton<Registry>.Instance.ItemRegistry.ToList();
List<StorableItemDefinition> list2 = new List<StorableItemDefinition>();
foreach (ItemRegister item in list)
{
if (Is<StorableItemDefinition>(item.Definition, out var result))
{
list2.Add(result);
}
else
{
Logger.Warning("Definition " + ((object)item.Definition)?.GetType().FullName + " is not a StorableItemDefinition");
}
}
return list2.ToList();
}
[IteratorStateMachine(typeof(<WaitForPlayer>d__4))]
public static IEnumerator WaitForPlayer(IEnumerator routine)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitForPlayer>d__4(0)
{
routine = routine
};
}
[IteratorStateMachine(typeof(<WaitForNetwork>d__5))]
public static IEnumerator WaitForNetwork(IEnumerator routine)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitForNetwork>d__5(0)
{
routine = routine
};
}
[IteratorStateMachine(typeof(<WaitForNotNull>d__6))]
public static IEnumerator WaitForNotNull(object? obj, float timeout = float.NaN, Action onTimeout = null, Action onFinish = null)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitForNotNull>d__6(0)
{
obj = obj,
timeout = timeout,
onTimeout = onTimeout,
onFinish = onFinish
};
}
[IteratorStateMachine(typeof(<WaitForNetworkSingleton>d__7<>))]
public static IEnumerator WaitForNetworkSingleton<T>(IEnumerator coroutine) where T : NetworkSingleton<T>
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitForNetworkSingleton>d__7<T>(0)
{
coroutine = coroutine
};
}
[IteratorStateMachine(typeof(<WaitForSingleton>d__8<>))]
public static IEnumerator WaitForSingleton<T>(IEnumerator coroutine) where T : Singleton<T>
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitForSingleton>d__8<T>(0)
{
coroutine = coroutine
};
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}