using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ChatResizer")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+8954575e4eb3be09ac98264c7165016dead46020")]
[assembly: AssemblyProduct("ChatResizer")]
[assembly: AssemblyTitle("ChatResizer")]
[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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace ChatResizer
{
[BepInPlugin("com.jai.ontogether.chatresizer", "Chat Resizer", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
public static ConfigEntry<float> ScaleMultiplier;
public static ConfigEntry<float> FontSize;
private static bool initialized;
private static GameObject gripObject;
private static Transform chatPanelTransform;
private static Transform scrollLocalTransform;
private static Transform scrollGlobalTransform;
private static float showDelay;
private void Awake()
{
//IL_004d: 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_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Expected O, but got Unknown
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Expected O, but got Unknown
ScaleMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Scale", 1f, "Chat scale multiplier (0.5 = half, 2.0 = double)");
FontSize = ((BaseUnityPlugin)this).Config.Bind<float>("General", "FontSize", 16f, "Message font size");
Harmony val = new Harmony("com.jai.ontogether.chatresizer");
Type type = AccessTools.TypeByName("UIManager");
val.Patch((MethodBase)AccessTools.Method(type, "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "UIManager_Awake_Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
Type type2 = AccessTools.TypeByName("TextChannelManager");
val.Patch((MethodBase)AccessTools.Method(type2, "AddMessageUI", new Type[4]
{
typeof(string),
typeof(string),
typeof(bool),
typeof(int)
}, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "AddMessageUI_Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
((BaseUnityPlugin)this).Logger.LogInfo((object)"Chat Resizer loaded");
}
private void Update()
{
if (!((Object)(object)gripObject == (Object)null) && !((Object)(object)chatPanelTransform == (Object)null))
{
bool flag = ((Object)(object)scrollLocalTransform != (Object)null && ((Component)scrollLocalTransform).gameObject.activeInHierarchy) || ((Object)(object)scrollGlobalTransform != (Object)null && ((Component)scrollGlobalTransform).gameObject.activeInHierarchy);
if (gripObject.activeSelf != flag)
{
gripObject.SetActive(flag);
}
}
}
private static void UIManager_Awake_Postfix(UIManager __instance)
{
if (initialized)
{
return;
}
try
{
SetupResizer(__instance.TextContentLocalTransform);
initialized = true;
}
catch (Exception arg)
{
Debug.LogError((object)$"[ChatResizer] {arg}");
}
}
private static void SetupResizer(Transform contentTransform)
{
//IL_007f: 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_0091: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Expected O, but got Unknown
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: 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_01d9: Unknown result type (might be due to invalid IL or missing references)
//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
//IL_020b: Unknown result type (might be due to invalid IL or missing references)
//IL_022a: Unknown result type (might be due to invalid IL or missing references)
//IL_022f: Unknown result type (might be due to invalid IL or missing references)
//IL_0242: Unknown result type (might be due to invalid IL or missing references)
//IL_024d: Unknown result type (might be due to invalid IL or missing references)
//IL_0254: Unknown result type (might be due to invalid IL or missing references)
//IL_025f: Unknown result type (might be due to invalid IL or missing references)
//IL_0274: Unknown result type (might be due to invalid IL or missing references)
//IL_0288: Unknown result type (might be due to invalid IL or missing references)
//IL_0292: Unknown result type (might be due to invalid IL or missing references)
//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)contentTransform == (Object)null)
{
return;
}
Transform parent = contentTransform.parent;
Transform val = ((parent != null) ? parent.parent : null);
if ((Object)(object)val == (Object)null)
{
return;
}
Transform parent2 = val.parent;
if (!((Object)(object)parent2 == (Object)null))
{
chatPanelTransform = parent2;
RectTransform component = ((Component)parent2).GetComponent<RectTransform>();
if (!((Object)(object)component == (Object)null))
{
scrollLocalTransform = parent2.Find("ScrollView_Local");
scrollGlobalTransform = parent2.Find("ScrollView_Global");
Vector3[] array = (Vector3[])(object)new Vector3[4];
component.GetWorldCorners(array);
Vector3 position = array[0];
component.pivot = new Vector2(0.05f, 0.05f);
((Transform)component).position = position;
float num = Mathf.Clamp(ScaleMultiplier.Value, 0.3f, 3f);
parent2.localScale = new Vector3(num, num, 1f);
GameObject val2 = new GameObject("ResizeGrip", new Type[1] { typeof(RectTransform) });
val2.transform.SetParent(parent2, false);
val2.transform.SetAsLastSibling();
Canvas obj = val2.AddComponent<Canvas>();
obj.overrideSorting = true;
obj.sortingOrder = 9999;
val2.AddComponent<GraphicRaycaster>();
RectTransform component2 = val2.GetComponent<RectTransform>();
component2.anchorMin = new Vector2(1f, 1f);
component2.anchorMax = new Vector2(1f, 1f);
component2.pivot = new Vector2(1f, 1f);
component2.anchoredPosition = new Vector2(0f, 0f);
component2.sizeDelta = new Vector2(44f, 44f);
gripObject = val2;
gripObject.SetActive(false);
Color color = default(Color);
((Color)(ref color))..ctor(0.93f, 0.87f, 0.8f, 1f);
CreateGripLine(val2.transform, 0, 32f, 6f, color);
CreateGripLine(val2.transform, 1, 20f, 5.5f, color);
CreateGripLine(val2.transform, 2, 12f, 5f, color);
GameObject val3 = new GameObject("GripHitArea", new Type[1] { typeof(RectTransform) });
val3.transform.SetParent(val2.transform, false);
val3.transform.SetAsLastSibling();
RectTransform component3 = val3.GetComponent<RectTransform>();
component3.anchorMin = Vector2.zero;
component3.anchorMax = Vector2.one;
component3.offsetMin = new Vector2(-14f, -14f);
component3.offsetMax = new Vector2(14f, 14f);
Image obj2 = val3.AddComponent<Image>();
((Graphic)obj2).color = new Color(0f, 0f, 0f, 0f);
((Graphic)obj2).raycastTarget = true;
val3.AddComponent<CornerDragZone>().targetTransform = parent2;
}
}
}
private static void CreateGripLine(Transform parent, int index, float lineLength, float lineThickness, Color color)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: 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_009f: 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_00c9: 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_00e3: Expected O, but got Unknown
//IL_021a: Unknown result type (might be due to invalid IL or missing references)
//IL_0229: Unknown result type (might be due to invalid IL or missing references)
//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject($"GripLine_{index}", new Type[1] { typeof(RectTransform) });
val.transform.SetParent(parent, false);
RectTransform component = val.GetComponent<RectTransform>();
component.anchorMin = new Vector2(0.5f, 0.5f);
component.anchorMax = new Vector2(0.5f, 0.5f);
component.pivot = new Vector2(0.5f, 0.5f);
float num = 7f;
float num2 = (float)index * num;
float num3 = 8f;
component.anchoredPosition = new Vector2(num3 - num2, num3 - num2);
component.sizeDelta = new Vector2(lineLength, lineThickness);
((Transform)component).localRotation = Quaternion.Euler(0f, 0f, -45f);
Image val2 = val.AddComponent<Image>();
((Graphic)val2).color = color;
((Graphic)val2).raycastTarget = false;
Texture2D val3 = new Texture2D(32, 8, (TextureFormat)4, false);
Color val4 = default(Color);
((Color)(ref val4))..ctor(0f, 0f, 0f, 0f);
float num4 = 3.5f;
for (int i = 0; i < 32; i++)
{
for (int j = 0; j < 8; j++)
{
bool flag = true;
if ((float)i < num4)
{
float num5 = num4;
float num6 = 4f;
flag = Mathf.Sqrt(((float)i - num5) * ((float)i - num5) + ((float)j - num6) * ((float)j - num6)) <= num4;
}
else if ((float)i > 32f - num4)
{
float num5 = 32f - num4;
float num6 = 4f;
flag = Mathf.Sqrt(((float)i - num5) * ((float)i - num5) + ((float)j - num6) * ((float)j - num6)) <= num4;
}
else
{
flag = (float)j >= 4f - num4 && (float)j <= 4f + num4;
}
val3.SetPixel(i, j, flag ? Color.white : val4);
}
}
val3.Apply();
((Texture)val3).filterMode = (FilterMode)1;
Sprite sprite = Sprite.Create(val3, new Rect(0f, 0f, 32f, 8f), new Vector2(0.5f, 0.5f), 100f);
val2.sprite = sprite;
val2.type = (Type)0;
val2.preserveAspect = false;
}
private static void AddMessageUI_Postfix(string userName, string text, bool isLocal, int senderIndex)
{
try
{
UIManager i = MonoSingleton<UIManager>.I;
if ((Object)(object)i == (Object)null)
{
return;
}
Transform val = (isLocal ? i.TextContentLocalTransform : i.TextContentGlobalTransform);
if (!((Object)(object)val == (Object)null) && val.childCount != 0)
{
TMP_Text componentInChildren = ((Component)val.GetChild(val.childCount - 1)).gameObject.GetComponentInChildren<TMP_Text>(true);
if ((Object)(object)componentInChildren != (Object)null)
{
componentInChildren.fontSize = FontSize.Value;
}
}
}
catch
{
}
}
}
public class CornerDragZone : MonoBehaviour, IBeginDragHandler, IEventSystemHandler, IDragHandler, IEndDragHandler
{
public Transform targetTransform;
private Vector2 startMouse;
private float startScale;
public void OnBeginDrag(PointerEventData eventData)
{
//IL_0011: 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_0022: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)targetTransform == (Object)null))
{
startMouse = eventData.position;
startScale = targetTransform.localScale.x;
}
}
public void OnDrag(PointerEventData eventData)
{
//IL_0010: 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_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: 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_005a: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)targetTransform == (Object)null))
{
Vector2 val = eventData.position - startMouse;
float num = (val.x + val.y) * 0.001f;
float num2 = Mathf.Clamp(startScale + num, 0.3f, 3f);
targetTransform.localScale = new Vector3(num2, num2, 1f);
}
}
public void OnEndDrag(PointerEventData eventData)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)targetTransform == (Object)null))
{
Plugin.ScaleMultiplier.Value = targetTransform.localScale.x;
((ConfigEntryBase)Plugin.ScaleMultiplier).ConfigFile.Save();
}
}
}
}