Decompiled source of GiveCorrectChange v1.0.1

GiveCorrectChange.dll

Decompiled 2 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using AcesGamingUK.Common;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
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("GiveCorrectChange")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("GiveCorrectChange")]
[assembly: AssemblyTitle("GiveCorrectChange")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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]
	[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 GiveCorrectChange
{
	[BepInPlugin("com.acesgaminguk.givecorrectchange", "GiveCorrectChange", "1.0.1")]
	public sealed class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		internal static Harmony Harmony;

		internal static ConfigEntry<bool> Enabled;

		internal static ConfigEntry<ChangeMode> Mode;

		internal static ConfigEntry<KeyboardShortcut> ManualHotkey;

		internal static ConfigEntry<bool> ShowPrompt;

		internal static ConfigEntry<float> PromptScale;

		internal static ConfigEntry<string> PromptColour;

		internal static ConfigEntry<Color> CustomPromptColour;

		internal static ConfigEntry<float> PanelX;

		internal static ConfigEntry<float> PanelY;

		internal static Data_Container? ActiveCashRegister;

		internal static bool ManualChangePrepared;

		internal static float ManualPreparedAt;

		private NativePrompt? _prompt;

		private void Awake()
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Expected O, but got Unknown
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Expected O, but got Unknown
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("# General #", "Enable Mod", true, "Turns Give Correct Change on or off.");
			Mode = ((BaseUnityPlugin)this).Config.Bind<ChangeMode>("# General #", "Change Method", ChangeMode.ManualFill, "Manual Fill uses the hotkey. Auto Fill prepares the exact change. Auto Complete finishes cash transactions immediately.");
			ManualHotkey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("# Controls #", "Give Change Key", new KeyboardShortcut((KeyCode)102, Array.Empty<KeyCode>()), "The key used in Manual Fill mode.");
			ShowPrompt = ((BaseUnityPlugin)this).Config.Bind<bool>("# Display #", "Show Prompt", true, "Shows the native Give Change prompt during a cash checkout.");
			PromptScale = ((BaseUnityPlugin)this).Config.Bind<float>("# Display #", "Prompt Size", 1f, new ConfigDescription("Changes the size of the prompt.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 2f), Array.Empty<object>()));
			PromptColour = ((BaseUnityPlugin)this).Config.Bind<string>("# Display #", "Prompt Colour", "Game Default", new ConfigDescription("Changes the prompt background colour.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[8] { "Game Default", "Purple", "Blue", "Orange", "Green", "Red", "Demo Red", "Custom" }), Array.Empty<object>()));
			CustomPromptColour = ((BaseUnityPlugin)this).Config.Bind<Color>("# Display #", "Custom Prompt Colour", new Color(0.36f, 0.16f, 0.46f, 1f), "Used only when Prompt Colour is set to Custom.");
			PanelX = ((BaseUnityPlugin)this).Config.Bind<float>("# Display #", "Prompt Position X", 28f, "Saved horizontal position of the prompt.");
			PanelY = ((BaseUnityPlugin)this).Config.Bind<float>("# Display #", "Prompt Position Y", 340f, "Saved vertical position of the prompt.");
			_prompt = new NativePrompt((MonoBehaviour)(object)this, ((BaseUnityPlugin)this).Logger, ShowPrompt, PromptScale, PromptColour, CustomPromptColour, PanelX, PanelY, GetPromptText, () => Enabled.Value && Mode.Value == ChangeMode.ManualFill && (Object)(object)ActiveCashRegister != (Object)null, "GiveCorrectChangePrompt");
			ManualHotkey.SettingChanged += delegate
			{
				_prompt.Refresh();
			};
			Mode.SettingChanged += delegate
			{
				_prompt.Refresh();
			};
			Enabled.SettingChanged += delegate
			{
				_prompt.Refresh();
			};
			StartupBanner.Write(((BaseUnityPlugin)this).Logger, "Give Correct Change", ((BaseUnityPlugin)this).Info.Metadata.Version.ToString(), "https://github.com/AcesGamingUK/Give-Correct-Change", "Give change key: " + ((object)ManualHotkey.Value/*cast due to .constrained prefix*/).ToString(), "Change method: " + Mode.Value);
			Harmony = new Harmony("com.acesgaminguk.givecorrectchange");
			Harmony.PatchAll();
		}

		private string GetPromptText()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			if (!ManualChangePrepared)
			{
				return $"Press {ManualHotkey.Value} to Give Change";
			}
			return "Change Ready - Click Cash Pile";
		}

		private void Update()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			_prompt?.Tick();
			if (Enabled.Value && Mode.Value == ChangeMode.ManualFill && !((Object)(object)ActiveCashRegister == (Object)null))
			{
				KeyboardShortcut value = ManualHotkey.Value;
				if (((KeyboardShortcut)(ref value)).IsDown())
				{
					CorrectChangeHelper.PrepareCorrectChange(ActiveCashRegister, hideManualPrompt: false);
					_prompt?.Refresh();
				}
			}
		}

		private void OnDestroy()
		{
			Harmony harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			_prompt?.Destroy();
		}
	}
	public enum ChangeMode
	{
		ManualFill,
		AutoFill,
		AutoComplete
	}
	internal static class CorrectChangeHelper
	{
		private static readonly FieldInfo MoneyToReturnField = AccessTools.Field(typeof(Data_Container), "moneyToReturn");

		private static readonly FieldInfo CurrentAmountToReturnField = AccessTools.Field(typeof(Data_Container), "currentAmountToReturn");

		private static readonly FieldInfo AllowMoneyReturnField = AccessTools.Field(typeof(Data_Container), "allowMoneyReturn");

		internal static bool FieldsReady()
		{
			if (MoneyToReturnField != null && CurrentAmountToReturnField != null && AllowMoneyReturnField != null)
			{
				return true;
			}
			Plugin.Log.LogError((object)"Could not find one or more checkout fields. Game update may have changed Data_Container.");
			return false;
		}

		internal static float GetMoneyToReturn(Data_Container container)
		{
			if (!FieldsReady())
			{
				return 0f;
			}
			return Mathf.Round((float)MoneyToReturnField.GetValue(container) * 100f) / 100f;
		}

		internal static void PrepareCorrectChange(Data_Container container, bool hideManualPrompt)
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!Plugin.Enabled.Value || !FieldsReady())
				{
					return;
				}
				float moneyToReturn = GetMoneyToReturn(container);
				if (moneyToReturn < 0f)
				{
					return;
				}
				CurrentAmountToReturnField.SetValue(container, moneyToReturn);
				AllowMoneyReturnField.SetValue(container, true);
				Transform val = ((Component)container).transform.Find("CashRegisterCanvas/Container/CurrentAmount");
				if (Object.op_Implicit((Object)(object)val))
				{
					TextMeshProUGUI component = ((Component)val).GetComponent<TextMeshProUGUI>();
					if (Object.op_Implicit((Object)(object)component))
					{
						((TMP_Text)component).text = ProductListing.Instance.ConvertFloatToTextPrice(moneyToReturn);
						((Graphic)component).color = Color.green;
					}
				}
				Transform val2 = ((Component)container).transform.Find("CashRegister/MoneyGivenBack");
				if (Object.op_Implicit((Object)(object)val2))
				{
					((Component)val2).gameObject.SetActive(true);
				}
				if ((Object)(object)Plugin.ActiveCashRegister == (Object)(object)container)
				{
					Plugin.ManualChangePrepared = true;
					Plugin.ManualPreparedAt = Time.realtimeSinceStartup;
				}
				if (hideManualPrompt && (Object)(object)Plugin.ActiveCashRegister == (Object)(object)container)
				{
					Plugin.ActiveCashRegister = null;
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("Failed to prepare correct change: " + ex));
			}
		}
	}
	[HarmonyPatch(typeof(Data_Container), "UserCode_RpcHidePaymentMethod__Int32__Int32")]
	internal static class DataContainer_RpcHidePaymentMethod_Patch
	{
		private static void Postfix(Data_Container __instance, int index, int amountGiven)
		{
			if (!Plugin.Enabled.Value || index != 0)
			{
				return;
			}
			try
			{
				if (CorrectChangeHelper.FieldsReady() && !(CorrectChangeHelper.GetMoneyToReturn(__instance) < 0f))
				{
					if (Plugin.Mode.Value == ChangeMode.AutoComplete)
					{
						Plugin.ActiveCashRegister = null;
						Plugin.ManualChangePrepared = false;
						__instance.CmdReceivePayment(0f);
					}
					else if (Plugin.Mode.Value == ChangeMode.AutoFill)
					{
						Plugin.ActiveCashRegister = null;
						Plugin.ManualChangePrepared = false;
						CorrectChangeHelper.PrepareCorrectChange(__instance, hideManualPrompt: true);
					}
					else
					{
						Plugin.ManualChangePrepared = false;
						Plugin.ManualPreparedAt = 0f;
						Plugin.ActiveCashRegister = __instance;
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("Failed to set up manual correct change: " + ex));
			}
		}
	}
	[HarmonyPatch(typeof(Data_Container), "UserCode_CmdReceivePayment__Single")]
	internal static class DataContainer_CmdReceivePayment_Patch
	{
		private static void Prefix(Data_Container __instance, ref float returnDifference)
		{
			if (!Plugin.Enabled.Value)
			{
				return;
			}
			try
			{
				if (Plugin.Mode.Value == ChangeMode.AutoFill || Plugin.Mode.Value == ChangeMode.ManualFill)
				{
					float moneyToReturn = CorrectChangeHelper.GetMoneyToReturn(__instance);
					if (Mathf.Abs(__instance.currentAmountToReturn - moneyToReturn) <= 0.011f)
					{
						returnDifference = 0f;
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("Failed to normalize return difference: " + ex));
			}
		}

		private static void Postfix(Data_Container __instance)
		{
			if ((Object)(object)Plugin.ActiveCashRegister == (Object)(object)__instance)
			{
				Plugin.ActiveCashRegister = null;
				Plugin.ManualChangePrepared = false;
				Plugin.ManualPreparedAt = 0f;
			}
		}
	}
	internal static class PluginInfo
	{
		public const string Guid = "com.acesgaminguk.givecorrectchange";

		public const string Name = "GiveCorrectChange";

		public const string DisplayName = "Give Correct Change";

		public const string Version = "1.0.1";

		public const string Author = "AcesGamingUK";

		public const string Website = "https://github.com/AcesGamingUK/Give-Correct-Change";
	}
}
namespace AcesGamingUK.Common
{
	internal static class NativeNotification
	{
		internal static void Show(ManualLogSource log, string message, bool important = true)
		{
			if ((Object)(object)GameCanvas.Instance == (Object)null)
			{
				if (log != null)
				{
					log.LogMessage((object)message.Replace("\n", " | "));
				}
				return;
			}
			GameObject val = ((important && Object.op_Implicit((Object)(object)GameCanvas.Instance.importantNotificationPrefab)) ? GameCanvas.Instance.importantNotificationPrefab : GameCanvas.Instance.notificationPrefab);
			Transform val2 = ((important && Object.op_Implicit((Object)(object)GameCanvas.Instance.importantNotificationParentTransform)) ? GameCanvas.Instance.importantNotificationParentTransform : GameCanvas.Instance.notificationParentTransform);
			if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val2))
			{
				if (log != null)
				{
					log.LogWarning((object)"Could not find the game's notification prefab or parent.");
				}
				if (log != null)
				{
					log.LogMessage((object)message.Replace("\n", " | "));
				}
				return;
			}
			GameObject val3 = Object.Instantiate<GameObject>(val, val2);
			TextMeshProUGUI val4 = val3.GetComponent<TextMeshProUGUI>();
			if (!Object.op_Implicit((Object)(object)val4))
			{
				val4 = val3.GetComponentInChildren<TextMeshProUGUI>(true);
			}
			if (Object.op_Implicit((Object)(object)val4))
			{
				((TMP_Text)val4).text = message;
			}
			val3.SetActive(true);
		}
	}
	internal sealed class NativePrompt
	{
		private readonly MonoBehaviour _owner;

		private readonly ManualLogSource _log;

		private readonly ConfigEntry<bool> _showPrompt;

		private readonly ConfigEntry<float> _scale;

		private readonly ConfigEntry<string> _colourChoice;

		private readonly ConfigEntry<Color> _customColour;

		private readonly ConfigEntry<float> _positionX;

		private readonly ConfigEntry<float> _positionY;

		private readonly Func<string> _textProvider;

		private readonly Func<bool> _visibleProvider;

		private readonly string _objectName;

		private readonly Vector2 _size;

		private GameObject? _panel;

		private RectTransform? _panelRect;

		private TextMeshProUGUI? _panelText;

		private Image? _panelImage;

		private Color _originalColour;

		private bool _dragging;

		private Vector3 _lastMousePosition;

		private string _lastText = string.Empty;

		internal NativePrompt(MonoBehaviour owner, ManualLogSource log, ConfigEntry<bool> showPrompt, ConfigEntry<float> scale, ConfigEntry<string> colourChoice, ConfigEntry<Color> customColour, ConfigEntry<float> positionX, ConfigEntry<float> positionY, Func<string> textProvider, Func<bool> visibleProvider, string objectName, Vector2? size = null)
		{
			//IL_0086: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			_owner = owner;
			_log = log;
			_showPrompt = showPrompt;
			_scale = scale;
			_colourChoice = colourChoice;
			_customColour = customColour;
			_positionX = positionX;
			_positionY = positionY;
			_textProvider = textProvider;
			_visibleProvider = visibleProvider;
			_objectName = objectName;
			_size = (Vector2)(((??)size) ?? new Vector2(320f, 60f));
			_scale.SettingChanged += delegate
			{
				ApplyScale();
			};
			_colourChoice.SettingChanged += delegate
			{
				ApplyColour();
			};
			_customColour.SettingChanged += delegate
			{
				ApplyColour();
			};
			_showPrompt.SettingChanged += delegate
			{
				UpdateVisibility();
			};
		}

		internal void Tick()
		{
			EnsureCreated();
			RefreshText();
			UpdateVisibility();
			HandleDragging();
		}

		internal void Refresh()
		{
			EnsureCreated();
			RefreshText(force: true);
			ApplyScale();
			ApplyColour();
			UpdateVisibility();
		}

		internal void Destroy()
		{
			if (Object.op_Implicit((Object)(object)_panel))
			{
				Object.Destroy((Object)(object)_panel);
			}
			_panel = null;
			_panelRect = null;
			_panelText = null;
			_panelImage = null;
		}

		private void EnsureCreated()
		{
			//IL_00aa: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: 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)
			if (Object.op_Implicit((Object)(object)_panel) || (Object)(object)GameCanvas.Instance == (Object)null)
			{
				return;
			}
			Transform val = ((Component)GameCanvas.Instance).transform.Find("InteractableShowInfo/Container/TitleBCK");
			if (!Object.op_Implicit((Object)(object)val))
			{
				_log.LogWarning((object)"Could not find native prompt source: InteractableShowInfo/Container/TitleBCK");
				return;
			}
			GameObject val2 = Object.Instantiate<GameObject>(((Component)val).gameObject, ((Component)GameCanvas.Instance).transform);
			((Object)val2).name = _objectName;
			RectTransform component = val2.GetComponent<RectTransform>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				_log.LogWarning((object)"Native prompt clone has no RectTransform.");
				Object.Destroy((Object)(object)val2);
				return;
			}
			_panel = val2;
			_panelRect = component;
			component.anchorMin = new Vector2(0f, 1f);
			component.anchorMax = new Vector2(0f, 1f);
			component.pivot = new Vector2(0f, 1f);
			component.sizeDelta = _size;
			component.anchoredPosition = new Vector2(_positionX.Value, 0f - _positionY.Value);
			_panelImage = val2.GetComponent<Image>();
			if (Object.op_Implicit((Object)(object)_panelImage))
			{
				_originalColour = ((Graphic)_panelImage).color;
			}
			Transform obj = val2.transform.Find("Title_Text");
			_panelText = ((obj != null) ? ((Component)obj).GetComponent<TextMeshProUGUI>() : null);
			if (!Object.op_Implicit((Object)(object)_panelText))
			{
				_panelText = val2.GetComponentInChildren<TextMeshProUGUI>(true);
			}
			TextMeshProUGUI panelText = _panelText;
			if (panelText != null && Object.op_Implicit((Object)(object)panelText))
			{
				RectTransform rectTransform = ((TMP_Text)panelText).rectTransform;
				rectTransform.anchorMin = Vector2.zero;
				rectTransform.anchorMax = Vector2.one;
				rectTransform.offsetMin = new Vector2(10f, 4f);
				rectTransform.offsetMax = new Vector2(-10f, -4f);
				((TMP_Text)panelText).alignment = (TextAlignmentOptions)514;
				((TMP_Text)panelText).textWrappingMode = (TextWrappingModes)0;
				((TMP_Text)panelText).enableAutoSizing = true;
				((TMP_Text)panelText).fontSizeMin = 12f;
				((TMP_Text)panelText).fontSizeMax = 28f;
			}
			Graphic[] componentsInChildren = val2.GetComponentsInChildren<Graphic>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				componentsInChildren[i].raycastTarget = false;
			}
			ApplyScale();
			ApplyColour();
			RefreshText(force: true);
			UpdateVisibility();
		}

		private void RefreshText(bool force = false)
		{
			TextMeshProUGUI panelText = _panelText;
			if (panelText != null && Object.op_Implicit((Object)(object)panelText))
			{
				string text = _textProvider?.Invoke() ?? string.Empty;
				if (force || !string.Equals(text, _lastText, StringComparison.Ordinal))
				{
					_lastText = text;
					((TMP_Text)panelText).text = text;
				}
			}
		}

		private void ApplyScale()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			RectTransform panelRect = _panelRect;
			if (panelRect != null && Object.op_Implicit((Object)(object)panelRect))
			{
				float num = Mathf.Clamp(_scale.Value, 0.5f, 2f);
				((Transform)panelRect).localScale = new Vector3(num, num, 1f);
			}
		}

		private void ApplyColour()
		{
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: 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_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: 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_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			Image panelImage = _panelImage;
			if (panelImage != null && Object.op_Implicit((Object)(object)panelImage))
			{
				byte b = (byte)Mathf.RoundToInt(_originalColour.a * 255f);
				Image val = panelImage;
				((Graphic)val).color = (Color)(_colourChoice.Value switch
				{
					"Purple" => new Color(0.36f, 0.16f, 0.46f, _originalColour.a), 
					"Blue" => new Color(0f, 0.69f, 0.94f, _originalColour.a), 
					"Orange" => new Color(0.93f, 0.49f, 0.19f, _originalColour.a), 
					"Green" => new Color(0.18f, 0.65f, 0.31f, _originalColour.a), 
					"Red" => new Color(0.85f, 0.1f, 0.1f, _originalColour.a), 
					"Demo Red" => Color32.op_Implicit(new Color32((byte)64, (byte)2, (byte)2, b)), 
					"Custom" => _customColour.Value, 
					_ => _originalColour, 
				});
			}
		}

		private void UpdateVisibility()
		{
			GameObject panel = _panel;
			if (panel != null && Object.op_Implicit((Object)(object)panel))
			{
				bool flag = _showPrompt.Value && (_visibleProvider?.Invoke() ?? false);
				if (panel.activeSelf != flag)
				{
					panel.SetActive(flag);
				}
			}
		}

		private void HandleDragging()
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			GameObject panel = _panel;
			RectTransform panelRect = _panelRect;
			if (panel == null || panelRect == null || !Object.op_Implicit((Object)(object)panel) || !Object.op_Implicit((Object)(object)panelRect) || !panel.activeInHierarchy || !Cursor.visible)
			{
				_dragging = false;
				return;
			}
			if (Input.GetMouseButtonDown(0) && RectTransformUtility.RectangleContainsScreenPoint(panelRect, Vector2.op_Implicit(Input.mousePosition), (Camera)null))
			{
				_dragging = true;
				_lastMousePosition = Input.mousePosition;
			}
			if (_dragging && Input.GetMouseButton(0))
			{
				Vector3 val = Input.mousePosition - _lastMousePosition;
				_lastMousePosition = Input.mousePosition;
				panelRect.anchoredPosition += new Vector2(val.x, val.y);
				_positionX.Value = panelRect.anchoredPosition.x;
				_positionY.Value = 0f - panelRect.anchoredPosition.y;
			}
			if (Input.GetMouseButtonUp(0))
			{
				_dragging = false;
			}
		}
	}
	internal static class StartupBanner
	{
		internal static void Write(ManualLogSource log, string displayName, string version, string website, params string[] details)
		{
			log.LogWarning((object)"=============================================");
			log.LogMessage((object)(displayName + " v" + version + " Initializing..."));
			log.LogWarning((object)"=============================================");
			log.LogMessage((object)"Author: AcesGamingUK");
			log.LogMessage((object)("GitHub: " + website));
			if (details != null)
			{
				foreach (string text in details)
				{
					if (!string.IsNullOrWhiteSpace(text))
					{
						log.LogMessage((object)text);
					}
				}
			}
			log.LogWarning((object)"=============================================");
			log.LogMessage((object)(displayName + " Initialized successfully!"));
			log.LogWarning((object)"=============================================");
		}
	}
}