Decompiled source of ChangeConsoleBind v1.0.0

ChangeConsoleBind.dll

Decompiled a month ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using MelonLoader;
using MelonLoader.Preferences;
using ScheduleOne.UI;
using UnityEngine;
using changeConsoleShortcut;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Core), "changeConsoleShortcut", "1.0.0", "Yipikayei05", null)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: AssemblyTitle("ChangeConsoleBind")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ChangeConsoleBind")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("aac82a27-ae5b-436f-97e7-70b295ff0427")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace changeConsoleShortcut;

public class Core : MelonMod
{
	private MelonPreferences_Category prefs;

	private MelonPreferences_Entry<KeyCode> consoleKeyPref;

	private KeyCode customConsoleKey;

	private bool isAwaitingNewKey = false;

	public override void OnInitializeMelon()
	{
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: 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)
		prefs = MelonPreferences.CreateCategory("ConsoleShortcut");
		consoleKeyPref = prefs.CreateEntry<KeyCode>("ConsoleKey", (KeyCode)282, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		customConsoleKey = consoleKeyPref.Value;
		((MelonBase)this).LoggerInstance.Msg($"Initialized. Console key set to {customConsoleKey}");
	}

	public override void OnUpdate()
	{
		//IL_00a1: 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_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: 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)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		if (isAwaitingNewKey)
		{
			foreach (KeyCode value in Enum.GetValues(typeof(KeyCode)))
			{
				if (Input.GetKeyDown(value))
				{
					customConsoleKey = value;
					consoleKeyPref.Value = value;
					MelonPreferences.Save();
					((MelonBase)this).LoggerInstance.Msg($"New console key set to {(object)value}");
					isAwaitingNewKey = false;
					break;
				}
			}
			return;
		}
		if (Input.GetKeyDown(customConsoleKey))
		{
			ToggleConsoleManually();
		}
		if (Input.GetKeyDown((KeyCode)291))
		{
			isAwaitingNewKey = true;
			((MelonBase)this).LoggerInstance.Msg("Press a new key to assign for opening the console...");
		}
	}

	public void ToggleConsoleManually()
	{
		ConsoleUI val = Object.FindObjectOfType<ConsoleUI>();
		if ((Object)(object)val != (Object)null)
		{
			val.SetIsOpen(true);
			((MelonBase)this).LoggerInstance.Msg("Console opened");
		}
		else
		{
			((MelonBase)this).LoggerInstance.Warning("No instance of Console UI found");
		}
	}
}