using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
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: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("Jor02")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+3b95e8201248fcaf0ffd5c34b191a9d640f43625")]
[assembly: AssemblyProduct("RadialQuickMessage")]
[assembly: AssemblyTitle("RadialQuickMessage")]
[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 RadialQuickMessage
{
public class RadialButton : MonoBehaviour
{
public string label;
public string? message;
public RadialContent[]? radialContent;
public Image image;
}
[Serializable]
public class RadialContent
{
public string? Label;
public string? Message;
public RadialContent[]? Children;
}
internal class RadialMenuManager : MonoBehaviour
{
[CompilerGenerated]
private sealed class <CenterCursor>d__24 : 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 <CenterCursor>d__24(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;
Cursor.lockState = (CursorLockMode)1;
<>2__current = null;
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
Cursor.lockState = (CursorLockMode)0;
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();
}
}
public UnityEvent<string?> OnMessageClicked = new UnityEvent<string>();
public float RadialSize = 250f;
public float InnerCircleRange = 0.2f;
public Color MenuColor = new Color(0f, 0f, 0f, 0.6039216f);
public Color HoverColor = new Color(0.25098038f, 28f / 51f, 1f, 1f);
public Sprite RadialSprite;
public Sprite CenterSprite;
public Sprite SeparatorSprite;
public TextMeshProUGUI ReferenceLabel;
private GameObject outerButtonRoot;
private RadialButton radialCenterButton;
private RadialButton[] outerButtons = new RadialButton[0];
private int sliceHovered = -1;
private RadialContent[] currentContent;
private Stack<RadialContent[]> menuStack = new Stack<RadialContent[]>();
private List<string?> selectedMessageStack = new List<string>();
public void Open(RadialContent[] content)
{
menuStack.Clear();
selectedMessageStack.Clear();
GenerateMenu(content, pushToStack: false);
}
public void Close()
{
if ((Object)(object)radialCenterButton != (Object)null)
{
Object.Destroy((Object)(object)((Component)radialCenterButton).gameObject);
}
Object.Destroy((Object)(object)outerButtonRoot);
}
public bool IsOpen()
{
if (!((Object)(object)radialCenterButton != (Object)null))
{
return (Object)(object)outerButtonRoot != (Object)null;
}
return true;
}
private void GenerateMenu(RadialContent[] newContent, bool pushToStack = true)
{
if (Object.op_Implicit((Object)(object)RadialSprite) && Object.op_Implicit((Object)(object)CenterSprite) && Object.op_Implicit((Object)(object)SeparatorSprite))
{
((MonoBehaviour)this).StartCoroutine(CenterCursor());
if (pushToStack && currentContent != null)
{
menuStack.Push(currentContent);
}
currentContent = newContent;
sliceHovered = -1;
if (menuStack.Count > 0)
{
GenerateCenterButton();
}
else if ((Object)(object)radialCenterButton != (Object)null)
{
Object.Destroy((Object)(object)((Component)radialCenterButton).gameObject);
}
GenerateRadialSlices(currentContent);
Utils.SetLayerRecursively(((Component)this).gameObject, LayerMask.NameToLayer("UI"));
}
}
private void GenerateCenterButton()
{
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Expected O, but got Unknown
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: 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_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_0160: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)radialCenterButton != (Object)null)
{
Object.Destroy((Object)(object)((Component)radialCenterButton).gameObject);
}
GameObject val = new GameObject("Center", new Type[3]
{
typeof(RectTransform),
typeof(Image),
typeof(RadialButton)
});
val.transform.SetParent(((Component)this).transform, false);
val.GetComponent<RectTransform>().sizeDelta = new Vector2(RadialSize, RadialSize);
Image component = val.GetComponent<Image>();
component.sprite = CenterSprite;
((Graphic)component).color = MenuColor;
RadialButton component2 = val.GetComponent<RadialButton>();
component2.image = component;
radialCenterButton = component2;
if ((Object)(object)ReferenceLabel != (Object)null)
{
Transform transform = ((Component)this).transform;
RectTransform val2 = (RectTransform)(object)((transform is RectTransform) ? transform : null);
Vector2 val3 = Vector2.op_Implicit(((Object)(object)val2 != (Object)null) ? ((Transform)val2).position : ((Component)this).transform.position);
TextMeshProUGUI val4 = Object.Instantiate<TextMeshProUGUI>(ReferenceLabel, val.transform);
((TMP_Text)val4).text = "BACK";
((Behaviour)val4).enabled = true;
((TMP_Text)val4).alignment = (TextAlignmentOptions)514;
((MaskableGraphic)val4).maskable = false;
((TMP_Text)val4).margin = Vector4.zero;
RectTransform component3 = ((Component)val4).GetComponent<RectTransform>();
component3.pivot = new Vector2(0.5f, 0.5f);
((Transform)component3).position = Vector2.op_Implicit(val3);
((Transform)component3).rotation = Quaternion.identity;
((Transform)component3).localScale = Vector3.one;
((Component)component3).gameObject.SetActive(true);
}
}
private void GenerateRadialSlices(params RadialContent[] content)
{
int num = content.Length;
if (num <= 0)
{
RadialQuickMessage.Logger.LogWarning((object)"Number of slices must be greater than 0.");
return;
}
Object.Destroy((Object)(object)outerButtonRoot);
Transform parent = CreateSeparatorMasks(num);
outerButtons = new RadialButton[num];
for (int i = 0; i < num; i++)
{
outerButtons[i] = CreateOuterButton(i, num, parent, content[i]);
}
}
private Transform CreateSeparatorMasks(int numberOfSlices)
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Expected O, but got Unknown
//IL_0088: 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)
Transform val = null;
for (int i = 0; i < numberOfSlices; i++)
{
GameObject val2 = new GameObject($"Separator_{i}", new Type[3]
{
typeof(RectTransform),
typeof(Image),
typeof(Mask)
});
val2.transform.SetParent(((Object)(object)val == (Object)null) ? ((Component)this).transform : val, false);
if (i == 0)
{
outerButtonRoot = val2;
}
RectTransform component = val2.GetComponent<RectTransform>();
component.sizeDelta = new Vector2(RadialSize, RadialSize);
((Transform)component).localRotation = Quaternion.Euler(0f, 0f, -360f / (float)numberOfSlices + (float)((numberOfSlices == 2 && i == 0) ? 90 : 0));
Image component2 = val2.GetComponent<Image>();
component2.sprite = SeparatorSprite;
val2.GetComponent<Mask>().showMaskGraphic = false;
val = val2.transform;
}
return val;
}
private RadialButton CreateOuterButton(int index, int totalSlices, Transform parent, RadialContent content)
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Expected O, but got Unknown
//IL_0064: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
//IL_01af: Unknown result type (might be due to invalid IL or missing references)
//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ba: 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_0219: Unknown result type (might be due to invalid IL or missing references)
//IL_0244: Unknown result type (might be due to invalid IL or missing references)
//IL_0250: Unknown result type (might be due to invalid IL or missing references)
//IL_0252: Unknown result type (might be due to invalid IL or missing references)
//IL_025e: Unknown result type (might be due to invalid IL or missing references)
//IL_026a: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject($"Slice_{index}", new Type[3]
{
typeof(RectTransform),
typeof(Image),
typeof(RadialButton)
});
val.transform.SetParent(parent, false);
RectTransform component = val.GetComponent<RectTransform>();
component.sizeDelta = new Vector2(RadialSize, RadialSize);
((Transform)component).localRotation = Quaternion.Euler(0f, 0f, -360f * (float)index / (float)totalSlices);
Image component2 = val.GetComponent<Image>();
component2.sprite = RadialSprite;
((Graphic)component2).color = MenuColor;
component2.type = (Type)3;
component2.fillMethod = (FillMethod)4;
component2.fillOrigin = 2;
component2.fillAmount = 1f / (float)totalSlices;
RadialButton component3 = val.GetComponent<RadialButton>();
component3.image = component2;
component3.label = content.Label ?? content.Message ?? "Error";
component3.message = content.Message;
component3.radialContent = content.Children;
if ((Object)(object)ReferenceLabel != (Object)null)
{
Transform transform = ((Component)this).transform;
RectTransform val2 = (RectTransform)(object)((transform is RectTransform) ? transform : null);
Vector2 val3 = Vector2.op_Implicit(((Object)(object)val2 != (Object)null) ? ((Transform)val2).position : ((Component)this).transform.position);
float num = RadialSize * 0.35f;
float num2 = -360f / (float)totalSlices;
float num3 = ((float)index + 0.5f) * num2 + (float)((totalSlices == 2) ? (-180) : 90);
float num4 = num3 * (MathF.PI / 180f);
Vector2 val4 = default(Vector2);
((Vector2)(ref val4))..ctor(Mathf.Cos(num4), Mathf.Sin(num4));
Vector2 val5 = val3 + val4 * num;
TextMeshProUGUI val6 = Object.Instantiate<TextMeshProUGUI>(ReferenceLabel, val.transform);
((TMP_Text)val6).text = (content.Label ?? content.Message ?? "Error").ToUpper();
((Behaviour)val6).enabled = true;
((TMP_Text)val6).alignment = (TextAlignmentOptions)514;
((MaskableGraphic)val6).maskable = false;
((TMP_Text)val6).margin = Vector4.zero;
((TMP_Text)val6).lineSpacing = -50f;
RectTransform component4 = ((Component)val6).GetComponent<RectTransform>();
component4.pivot = new Vector2(0.5f, 0.5f);
((Transform)component4).position = Vector2.op_Implicit(val5);
((Transform)component4).rotation = Quaternion.identity;
((Transform)component4).localScale = Vector3.one;
((Component)component4).gameObject.SetActive(true);
}
return component3;
}
[IteratorStateMachine(typeof(<CenterCursor>d__24))]
private IEnumerator CenterCursor()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <CenterCursor>d__24(0);
}
private void Update()
{
//IL_001d: 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_002d: 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_0037: 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_0084: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)radialCenterButton == (Object)null && (Object)(object)outerButtonRoot == (Object)null)
{
return;
}
Vector2 val = SemiFunc.UIMousePosToUIPos() - Vector2.op_Implicit(((Component)this).transform.position);
float magnitude = ((Vector2)(ref val)).magnitude;
if (magnitude > RadialSize * 0.5f)
{
sliceHovered = -1;
UpdateSliceColors();
return;
}
int num = -1;
if (magnitude < RadialSize * InnerCircleRange)
{
num = 0;
}
else if (outerButtons.Length != 0)
{
float num2 = Mathf.Atan2(0f - val.y, val.x) * 57.29578f + (float)((outerButtons.Length == 2) ? 180 : 90);
num2 = (num2 + 360f) % 360f;
float num3 = 360f / (float)outerButtons.Length;
num = Mathf.FloorToInt(num2 / num3) + 1;
}
if (sliceHovered != num)
{
sliceHovered = num;
if (UpdateSliceColors())
{
MenuManager.instance.MenuEffectClick((MenuClickEffectType)4, (MenuPage)null, -1f, -1f, true);
}
}
if (!Input.GetMouseButtonUp(0))
{
return;
}
MenuManager.instance.MenuEffectClick((MenuClickEffectType)1, (MenuPage)null, 1f, 1f, true);
RadialButton radialButton = GetRadialButton(sliceHovered);
if (sliceHovered == 0)
{
GoBack();
return;
}
if (radialButton.radialContent != null && radialButton.radialContent.Length != 0)
{
selectedMessageStack.Add(radialButton.message);
GenerateMenu(radialButton.radialContent);
return;
}
string text = radialButton.message;
for (int num4 = selectedMessageStack.Count - 1; num4 >= 0; num4--)
{
string text2 = selectedMessageStack[num4];
if (!string.IsNullOrEmpty(text2) && text2.Contains("{$}"))
{
text = text2.Replace("{$}", text);
}
else if (!string.IsNullOrEmpty(text2))
{
text = text2 + text;
}
}
if (OnMessageClicked != null)
{
OnMessageClicked.Invoke(text);
}
}
private void GoBack()
{
if (menuStack.Count > 0)
{
RadialContent[] newContent = menuStack.Pop();
if (selectedMessageStack.Count > 0)
{
selectedMessageStack.RemoveAt(selectedMessageStack.Count - 1);
}
GenerateMenu(newContent, pushToStack: false);
}
}
private bool UpdateSliceColors()
{
//IL_002c: 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_0091: Unknown result type (might be due to invalid IL or missing references)
for (int i = 0; i < outerButtons.Length; i++)
{
if ((Object)(object)outerButtons[i] == (Object)null)
{
Close();
return false;
}
Image component = ((Component)outerButtons[i]).GetComponent<Image>();
((Graphic)component).color = MenuColor;
}
if ((Object)(object)radialCenterButton != (Object)null)
{
((Graphic)radialCenterButton.image).color = MenuColor;
}
if (sliceHovered != -1)
{
RadialButton radialButton = GetRadialButton(sliceHovered);
if ((Object)(object)radialButton == (Object)null)
{
return false;
}
((Graphic)radialButton.image).color = HoverColor;
}
return true;
}
private RadialButton GetRadialButton(int index)
{
if (outerButtons.Length == 0 || index == 0)
{
return radialCenterButton;
}
return outerButtons[index - 1];
}
}
[BepInPlugin("Jor02.RadialQuickMessage", "RadialQuickMessage", "1.0")]
[BepInProcess("REPO.exe")]
public class RadialQuickMessage : BaseUnityPlugin
{
private RadialMenuManager radialMenu;
private RadialQuickMessageConfig config;
private CursorLockMode prevLockMode;
internal static RadialQuickMessage Instance { get; private set; }
internal static ManualLogSource Logger => Instance._logger;
private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;
internal Harmony? Harmony { get; set; }
private void Awake()
{
Instance = this;
((Component)this).gameObject.transform.parent = null;
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
config = new RadialQuickMessageConfig(this);
config.OnContentChanged += OnConfigChanged;
Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
}
private void OnConfigChanged(RadialContent[] _)
{
//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_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
radialMenu.MenuColor = config.MenuColor.Value;
radialMenu.HoverColor = config.HoverColor.Value;
}
private void Update()
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: 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_004f: 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)
if (!ChatManager.instance.localPlayerAvatarFetched)
{
return;
}
if ((Object)(object)radialMenu != (Object)null)
{
if (!radialMenu.IsOpen() && UnityInput.Current.GetKey(config.OpenMenuKey.Value))
{
prevLockMode = Cursor.lockState;
radialMenu.Open(config.Content);
}
else if (radialMenu.IsOpen())
{
SemiFunc.CameraOverrideStopAim();
MenuCursor.instance.Show();
if (!UnityInput.Current.GetKey(config.OpenMenuKey.Value))
{
radialMenu.Close();
Cursor.lockState = prevLockMode;
}
}
}
else
{
CreateRadialMenuManager();
}
}
private void CreateRadialMenuManager()
{
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Expected O, but got Unknown
//IL_009b: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
//IL_0157: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)radialMenu != (Object)null)
{
Object.Destroy((Object)(object)radialMenu);
}
GameObject val = GameObject.Find("UI/HUD/HUD Canvas/HUD/");
TextMeshProUGUI component = GameObject.Find("UI/HUD/HUD Canvas/HUD/Chat/Chat Text/").GetComponent<TextMeshProUGUI>();
GameObject val2 = new GameObject("RadialMenu", new Type[2]
{
typeof(RectTransform),
typeof(RadialMenuManager)
});
val2.transform.SetParent(val.transform, false);
val2.transform.SetSiblingIndex(val.transform.childCount - 2);
RectTransform component2 = val2.GetComponent<RectTransform>();
component2.anchorMin = new Vector2(0.5f, 0.5f);
component2.anchorMax = new Vector2(0.5f, 0.5f);
component2.pivot = new Vector2(0.5f, 0.5f);
component2.anchoredPosition = Vector2.zero;
radialMenu = val2.GetComponent<RadialMenuManager>();
radialMenu.OnMessageClicked.AddListener((UnityAction<string>)RelayMessage);
radialMenu.RadialSprite = Utils.CreateSpriteFromBytes(Resources.RadialCircle);
radialMenu.CenterSprite = Utils.CreateSpriteFromBytes(Resources.RadialCenter);
radialMenu.SeparatorSprite = Utils.CreateSpriteFromBytes(Resources.RadialSeparator);
radialMenu.MenuColor = config.MenuColor.Value;
radialMenu.HoverColor = config.HoverColor.Value;
radialMenu.ReferenceLabel = component;
}
private void RelayMessage(string? message)
{
ChatManager.instance.ForceSendMessage(message ?? "Error");
}
private void OnDestroy()
{
config?.Dispose();
}
}
internal class RadialQuickMessageConfig
{
private readonly RadialQuickMessage plugin;
private readonly ManualLogSource logger;
private FileSystemWatcher? contentWatcher;
private static readonly JsonSerializerSettings serializerSettings = new JsonSerializerSettings
{
NullValueHandling = (NullValueHandling)1
};
public string ContentFilePath { get; private set; }
public ConfigEntry<KeyCode> OpenMenuKey { get; private set; }
public ConfigEntry<Color> MenuColor { get; private set; }
public ConfigEntry<Color> HoverColor { get; private set; }
public RadialContent[] Content { get; private set; }
public event Action<RadialContent[]>? OnContentChanged;
public RadialQuickMessageConfig(RadialQuickMessage plugin)
{
this.plugin = plugin;
logger = RadialQuickMessage.Logger;
string path = ((BaseUnityPlugin)plugin).Info.Metadata.GUID + ".content.json";
ContentFilePath = Path.Combine(Paths.ConfigPath, path);
BindConfig();
LoadRadialContent();
StartWatchingContentFile();
}
private void BindConfig()
{
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
OpenMenuKey = ((BaseUnityPlugin)plugin).Config.Bind<KeyCode>("Radial Menu", "Open Menu Key", (KeyCode)102, "Key used to open the radial menu.");
MenuColor = ((BaseUnityPlugin)plugin).Config.Bind<Color>("Radial Menu", "Menu Color", new Color(0f, 0f, 0f, 0.6f), "Background color of the radial menu.");
HoverColor = ((BaseUnityPlugin)plugin).Config.Bind<Color>("Radial Menu", "Hover Color", new Color(0.25f, 0.55f, 1f, 1f), "Hover color of the radial menu.");
OpenMenuKey.SettingChanged += delegate
{
this.OnContentChanged?.Invoke(Content);
};
MenuColor.SettingChanged += delegate
{
this.OnContentChanged?.Invoke(Content);
};
HoverColor.SettingChanged += delegate
{
this.OnContentChanged?.Invoke(Content);
};
}
private void LoadRadialContent()
{
logger.LogInfo((object)("Loading radial content from " + ContentFilePath + "."));
if (!File.Exists(ContentFilePath))
{
logger.LogWarning((object)"Radial content file not found. Creating default.");
Content = GetDefaultRadialContent();
SaveRadialContent();
return;
}
try
{
string text = File.ReadAllText(ContentFilePath);
Content = JsonConvert.DeserializeObject<RadialContent[]>(text);
}
catch (Exception ex)
{
logger.LogError((object)("Failed to load radial content: " + ex.Message));
Content = GetSyntaxErrorRadialContent(ex.Message);
}
}
private void SaveRadialContent()
{
try
{
string contents = JsonConvert.SerializeObject((object)Content, (Formatting)1, serializerSettings);
File.WriteAllText(ContentFilePath, contents);
logger.LogInfo((object)"Radial content saved successfully.");
}
catch (Exception ex)
{
logger.LogError((object)("Failed to save radial content: " + ex.Message));
}
}
private void StartWatchingContentFile()
{
string directoryName = Path.GetDirectoryName(ContentFilePath);
string fileName = Path.GetFileName(ContentFilePath);
contentWatcher = new FileSystemWatcher(directoryName, fileName)
{
NotifyFilter = (NotifyFilters.FileName | NotifyFilters.Size | NotifyFilters.LastWrite)
};
contentWatcher.Changed += delegate
{
ReloadContentDelayed();
};
contentWatcher.Renamed += delegate
{
ReloadContentDelayed();
};
contentWatcher.EnableRaisingEvents = true;
}
private void ReloadContentDelayed()
{
Task.Delay(200).ContinueWith(delegate
{
try
{
LoadRadialContent();
this.OnContentChanged?.Invoke(Content);
logger.LogInfo((object)"Radial content reloaded from file.");
}
catch (Exception ex)
{
logger.LogError((object)("Error reloading radial content: " + ex.Message));
}
});
}
private RadialContent[] GetSyntaxErrorRadialContent(string error)
{
return new RadialContent[2]
{
new RadialContent
{
Message = "Syntax Error"
},
new RadialContent
{
Message = "Full Error..",
Children = new RadialContent[1]
{
new RadialContent
{
Message = error
}
}
}
};
}
private RadialContent[] GetDefaultRadialContent()
{
return new RadialContent[7]
{
new RadialContent
{
Label = "HI..",
Children = new RadialContent[4]
{
new RadialContent
{
Message = "Hi"
},
new RadialContent
{
Message = "Hello"
},
new RadialContent
{
Message = "Heya"
},
new RadialContent
{
Message = "Greetings"
}
}
},
new RadialContent
{
Label = "Reactions..",
Children = new RadialContent[5]
{
new RadialContent
{
Label = "Thanks",
Message = "Thanks!"
},
new RadialContent
{
Message = "LOL"
},
new RadialContent
{
Label = "Haha",
Message = "Haha!"
},
new RadialContent
{
Label = "Wow",
Message = "Wow!"
},
new RadialContent
{
Message = "LMAO"
}
}
},
new RadialContent
{
Label = "I spot..",
Message = "I spot {$}.",
Children = new RadialContent[5]
{
new RadialContent
{
Label = "Valuable..",
Message = "{$} valuable",
Children = new RadialContent[4]
{
new RadialContent
{
Message = "Heavy"
},
new RadialContent
{
Message = "Expensive"
},
new RadialContent
{
Message = "Small"
},
new RadialContent
{
Message = "Big"
}
}
},
new RadialContent
{
Label = "Common..",
Children = new RadialContent[6]
{
new RadialContent
{
Message = "Animal"
},
new RadialContent
{
Message = "Duck"
},
new RadialContent
{
Message = "Gnome"
},
new RadialContent
{
Message = "Eye"
},
new RadialContent
{
Message = "Skull"
},
new RadialContent
{
Message = "Head"
}
}
},
new RadialContent
{
Label = "Human-like..",
Children = new RadialContent[5]
{
new RadialContent
{
Message = "Baby"
},
new RadialContent
{
Message = "Big guy"
},
new RadialContent
{
Message = "Stick lady"
},
new RadialContent
{
Label = "Blind",
Message = "Blind guy"
},
new RadialContent
{
Message = "Upscream"
}
}
},
new RadialContent
{
Label = "Supernatural..",
Children = new RadialContent[6]
{
new RadialContent
{
Message = "Shadow Child"
},
new RadialContent
{
Message = "Hugger"
},
new RadialContent
{
Message = "Spewer"
},
new RadialContent
{
Label = "Invisible",
Message = "Invisible dude"
},
new RadialContent
{
Message = "Laser guy"
},
new RadialContent
{
Message = "Alien"
}
}
},
new RadialContent
{
Label = "Other..",
Children = new RadialContent[2]
{
new RadialContent
{
Message = "Frog"
},
new RadialContent
{
Label = "Blowey",
Message = "Blowey guy"
}
}
}
}
},
new RadialContent
{
Message = "MONSTER"
},
new RadialContent
{
Message = "RUN"
},
new RadialContent
{
Label = "HELP..",
Message = "HELP {$}",
Children = new RadialContent[4]
{
new RadialContent
{
Label = "."
},
new RadialContent
{
Label = "carry",
Message = "carry please"
},
new RadialContent
{
Message = "kill"
},
new RadialContent
{
Message = "reach"
}
}
},
new RadialContent
{
Label = "Bye..",
Children = new RadialContent[2]
{
new RadialContent
{
Label = "Goodbye",
Message = "Goodbye!"
},
new RadialContent
{
Label = "Bye",
Message = "Bye!"
}
}
}
};
}
public void Dispose()
{
contentWatcher?.Dispose();
}
}
[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[DebuggerNonUserCode]
[CompilerGenerated]
internal class Resources
{
private static ResourceManager resourceMan;
private static CultureInfo resourceCulture;
[EditorBrowsable(EditorBrowsableState.Advanced)]
internal static ResourceManager ResourceManager
{
get
{
if (resourceMan == null)
{
ResourceManager resourceManager = new ResourceManager("RadialQuickMessage.Resources", typeof(Resources).Assembly);
resourceMan = resourceManager;
}
return resourceMan;
}
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
internal static CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
internal static byte[] RadialCenter
{
get
{
object @object = ResourceManager.GetObject("RadialCenter", resourceCulture);
return (byte[])@object;
}
}
internal static byte[] RadialCircle
{
get
{
object @object = ResourceManager.GetObject("RadialCircle", resourceCulture);
return (byte[])@object;
}
}
internal static byte[] RadialSeparator
{
get
{
object @object = ResourceManager.GetObject("RadialSeparator", resourceCulture);
return (byte[])@object;
}
}
internal Resources()
{
}
}
internal class Utils
{
public static Sprite CreateSpriteFromBytes(byte[] imageData)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Expected O, but got Unknown
//IL_0043: 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)
Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
ImageConversion.LoadImage(val, imageData);
Rect val2 = default(Rect);
((Rect)(ref val2))..ctor(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height);
Vector2 val3 = default(Vector2);
((Vector2)(ref val3))..ctor(0.5f, 0.5f);
return Sprite.Create(val, val2, val3);
}
public static void SetLayerRecursively(GameObject obj, int newLayer)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
obj.layer = newLayer;
foreach (Transform item in obj.transform)
{
Transform val = item;
SetLayerRecursively(((Component)val).gameObject, newLayer);
}
}
}
}