Decompiled source of SimpleTimePanel v1.1.0

SimpleTimePanel.dll

Decompiled 2 days ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("SimpleTimePanel")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SimpleTimePanel")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("9564f4c0-9bfd-4019-be94-8c8885c43d82")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace RepoAdminTimePanel;

[BepInPlugin("com.spelledeye.simpletimepanel", "SimpleTimePanel", "1.1.0")]
public class Plugin : BaseUnityPlugin
{
	private const string MOD_GUID = "com.spelledeye.simpletimepanel";

	private const string MOD_NAME = "SimpleTimePanel";

	private const string MOD_VERSION = "1.1.0";

	public static ManualLogSource Log;

	private bool isPanelOpen = false;

	private float timeScaleSlider = 1f;

	private const float MAX_TIME_SCALE = 10f;

	private Rect windowRect = new Rect(200f, 200f, 300f, 150f);

	public static ConfigEntry<int> ToggleKeyConfig;

	private int targetVirtualKey = 119;

	[DllImport("user32.dll")]
	private static extern short GetAsyncKeyState(int vKey);

	private void Awake()
	{
		Log = ((BaseUnityPlugin)this).Logger;
		ToggleKeyConfig = ((BaseUnityPlugin)this).Config.Bind<int>("General", "MenuKeyVirtualCode", 119, "Numeric Windows key code (Virtual Key Code). By default 119 = F8. (112 = F1, 45 = Insert, 85 = U)");
		targetVirtualKey = ToggleKeyConfig.Value;
		Log.LogInfo((object)string.Format("{0} successfully loaded! System button code: {1}", "SimpleTimePanel", targetVirtualKey));
	}

	private void Update()
	{
		if ((GetAsyncKeyState(targetVirtualKey) & 1) != 0)
		{
			isPanelOpen = !isPanelOpen;
			if (isPanelOpen)
			{
				Cursor.lockState = (CursorLockMode)0;
				Cursor.visible = true;
			}
			else
			{
				Cursor.lockState = (CursorLockMode)1;
				Cursor.visible = false;
			}
		}
	}

	private void OnGUI()
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Expected O, but got Unknown
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		if (isPanelOpen)
		{
			windowRect = GUI.Window(0, windowRect, new WindowFunction(DrawAdminWindow), "⏳ REPO TIME PANEL by SpelledEye");
		}
	}

	private void DrawAdminWindow(int windowID)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0114: Unknown result type (might be due to invalid IL or missing references)
		Color contentColor = GUI.contentColor;
		GUI.Label(new Rect(20f, 30f, 260f, 20f), $"Time speed: {timeScaleSlider:F2}x");
		timeScaleSlider = GUI.HorizontalSlider(new Rect(20f, 60f, 260f, 30f), timeScaleSlider, 0f, 10f);
		Time.timeScale = timeScaleSlider;
		if (GUI.Button(new Rect(20f, 100f, 120f, 30f), "Reset (1.0x)"))
		{
			timeScaleSlider = 1f;
			Time.timeScale = 1f;
		}
		if (GUI.Button(new Rect(160f, 100f, 120f, 30f), "Pause (0.0x)"))
		{
			timeScaleSlider = 0f;
			Time.timeScale = 0f;
		}
		GUI.contentColor = contentColor;
		GUI.DragWindow(new Rect(0f, 0f, 10000f, 20f));
	}
}