Decompiled source of TerminalGamepad v1.3.8

BepInEx/plugins/TerminalGamepad.dll

Decompiled 5 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalCompanyInputUtils.Api;
using TerminalApi;
using TerminalApi.Events;
using TerminalGamepad.Data;
using TerminalGamepad.GUILoader;
using TooManyEmotes;
using TooManyEmotes.Patches;
using UnityEngine;
using UnityEngine.InputSystem;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Terminal Gamepad Supprot")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Terminal Gamepad Supprot")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("0b20b7fd-7f74-416f-9fd4-37c015edbf8d")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace TerminalGamepad
{
	internal class SellMyScrap
	{
		private static bool? _enabled;

		public static List<string> scrapList = new List<string>();

		public static List<string> MainButtonsName = new List<string> { "sell <amount>", "sell quota", "sell all", "sell item", "view overtime", "view scrap", "view config" };

		private static GameObject hangarShip;

		public static GameObject HangarShip
		{
			get
			{
				if ((Object)(object)hangarShip == (Object)null)
				{
					hangarShip = GameObject.Find("/Environment/HangarShip");
				}
				return hangarShip;
			}
		}

		public static bool enabled
		{
			get
			{
				if (!_enabled.HasValue)
				{
					_enabled = Chainloader.PluginInfos.ContainsKey("com.github.zehsteam.SellMyScrap");
				}
				return _enabled.Value;
			}
		}

		public static void Setup()
		{
			if (enabled)
			{
				TerminalGUI.MainButtonNames.Add("Sell");
				TerminalGUI.MainButtonNamesTEMP = TerminalGUI.MainButtonNames;
			}
		}

		public static void GetScrapList()
		{
			scrapList = GetScrapFromShip();
		}

		public static List<string> GetScrapFromShip()
		{
			GrabbableObject[] componentsInChildren = HangarShip.GetComponentsInChildren<GrabbableObject>();
			List<string> list = new List<string>();
			GrabbableObject[] array = componentsInChildren;
			foreach (GrabbableObject val in array)
			{
				if (IsScrapItem(val) && !list.Contains(val.itemProperties.itemName))
				{
					list.Add(val.itemProperties.itemName);
				}
			}
			return list;
		}

		private static bool IsScrapItem(GrabbableObject item)
		{
			if (!item.itemProperties.isScrap)
			{
				return false;
			}
			if (item.isHeld || item.isPocketed || !item.grabbable)
			{
				return false;
			}
			return true;
		}
	}
	internal class TooManyEmotes
	{
		private static bool? _enabled;

		public static List<string> StoreButtonsName = new List<string> { "Lategame Store", "InitAttack", "Cooldown", "Interns", "Scrap Insurance", "Extend Deadline 1", "Contract Info", "Demon", "Bruteforce", "Lookup" };

		public static bool enabled
		{
			get
			{
				if (!_enabled.HasValue)
				{
					_enabled = Chainloader.PluginInfos.ContainsKey("FlipMods.TooManyEmotes");
				}
				return _enabled.Value;
			}
		}

		public static void Setup()
		{
			if (enabled)
			{
				TerminalGUI.MainButtonNames.Add("Emotes");
				TerminalGUI.MainButtonNamesTEMP = TerminalGUI.MainButtonNames;
			}
		}

		public static void GetEmotesList()
		{
			StoreButtonsName = TerminalPatcher.emoteSelection.Select((UnlockableEmote e) => e.displayName).ToList();
		}
	}
	internal class LGU
	{
		private static bool? _enabled;

		public static List<string> MainButtonsName = new List<string> { "Lategame Store", "InitAttack", "Cooldown", "Interns", "Scrap Insurance", "Extend Deadline <amount>", "Contract Info", "Demon", "Bruteforce", "Lookup" };

		public static List<string> MoreUpgradesButtonsName = new List<string>
		{
			"Back Muscles", "Bargain Connections", "Beekeeper", "Better Scanner", "Bigger Lungs", "Charging Booster", "Climbing Gloves", "Discombobulator", "Drop Pod Thrusters", "Efficient Engines",
			"Fast Encryption", "Hunter", "Lethal Deals", "Lightning Rod", "Locksmith", "Malware Broadcaster", "Market Influence", "NV Headset Batteries", "Protein Powder", "Quantum Disruptor",
			"Running Shoes", "Shutter Batteries", "Sick Beats", "Sigurd Access", "Stimpack", "Strong Legs", "Walkie GPS"
		};

		public static List<string> ConfirmButtonNames = new List<string> { "Confirm", "Deny" };

		public static List<string> DemonsButtonNames = new List<string> { "Poltergeist", "Phantom", "Wraith", "Banshee", "Jinn", "Hantu", "Moroi", "Myling", "Goryo", "De ogen" };

		public static List<string> IPButtonNames = new List<string>
		{
			"Submit", "Backspace", "1", "2", "3", "4", "5", "6", "7", "8",
			"9", "0", "."
		};

		public static List<string> ContractButtonNames;

		public static bool enabled => false;

		public static void Setup()
		{
			if (enabled)
			{
				TerminalGUI.MainButtonNames.Add("LateGame");
				TerminalGUI.MainButtonNamesTEMP = TerminalGUI.MainButtonNames;
			}
		}

		public static void ContractMoons()
		{
			ContractButtonNames = new List<string> { "Random" };
			ContractButtonNames.AddRange(TerminalGUI.MoonsButtonNames.Select((string item) => item).ToList());
		}

		public static int CountDots(string input)
		{
			int num = 0;
			foreach (char c in input)
			{
				if (c == '.')
				{
					num++;
				}
			}
			return num;
		}

		public static int CountNumber(string input)
		{
			if (input.Length <= 0)
			{
				return 0;
			}
			char c = input[input.Length - 1];
			if (c == '.')
			{
				return 0;
			}
			return input.Split(new char[1] { '.' }, StringSplitOptions.RemoveEmptyEntries).ToArray()[^1].Length;
		}

		public static int HowManyNumbers(string input)
		{
			int num = CountDots(input);
			int result = 0;
			if (num == 0 || num == 3)
			{
				result = 3;
			}
			else if (num == 1 || num == 2)
			{
				result = 2;
			}
			return result;
		}

		public static bool IsLettersOnly(string input)
		{
			string pattern = "^[a-zA-Z]+$";
			return Regex.IsMatch(input, pattern);
		}

		public static bool IsNumbersOnly(string input)
		{
			string pattern = "^[0-9]+$";
			return Regex.IsMatch(input, pattern);
		}
	}
	[BepInPlugin("Secrecthide.TerminalGamepad", "TerminalGamepad", "1.3.8")]
	[BepInDependency("atomic.terminalapi", "1.5.0")]
	[BepInDependency("com.rune580.LethalCompanyInputUtils", "0.6.3")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	internal class ModBase : BaseUnityPlugin
	{
		private const string GUID = "Secrecthide.TerminalGamepad";

		private const string Name = "TerminalGamepad";

		private const string Version = "1.3.8";

		private readonly Harmony harmony = new Harmony("Secrecthide.TerminalGamepad");

		private static ModBase instance;

		private TerminalGUI myGUI;

		private KeyBinds keybinds = new KeyBinds();

		public static ConfigEntry<string> BoxBackgroundColor;

		public static ConfigEntry<string> AmountBoxbackgroundColor;

		public static ConfigEntry<string> ButtonsColor;

		public static ConfigEntry<string> HighlightedButtonColor;

		public static ConfigEntry<string> ButtonTextColor;

		public static ConfigEntry<string> HighlightedButtonTextColor;

		public static ConfigEntry<string> AmountButtonTextColor;

		public static ConfigEntry<string> BoxTextColor;

		public static ConfigEntry<string> CustomCommads;

		public static ConfigEntry<int> Rows;

		public static ConfigEntry<int> Columns;

		public static ConfigEntry<PagesScrollType> PagesMode;

		private void Awake()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			instance = this;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"TermialGamepad has launched successfully! ENJOY :)");
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
			Events.TerminalStarted += new TerminalEventHandler(OnTerminalBeginUsing);
			Rows = ((BaseUnityPlugin)this).Config.Bind<int>("Customization", "Rows", 2, "Adjust number of Rows");
			Columns = ((BaseUnityPlugin)this).Config.Bind<int>("Customization", "Columns", 8, "Adjust number of columns");
			PagesMode = ((BaseUnityPlugin)this).Config.Bind<PagesScrollType>("Customization", "Pages mode", PagesScrollType.Dynamic, "The way to switch between pages.\n\nOptions:\n[Dynamic]: It checks the bigger count of rows and columns, then chooses automatically between LeftRight and UpDown.\n[UpDown]: It will change between pages by going up or down.\n[LeftRight]: It will change between pages by going left or right.\n[Both]: It is a combination of UpDown and LeftRight.");
			CustomCommads = ((BaseUnityPlugin)this).Config.Bind<string>("Customization", "Custom Commands", "", "You can add other modds commands to shows up in the panel (e.g. \"door, light\")");
			BoxBackgroundColor = ((BaseUnityPlugin)this).Config.Bind<string>("Background Colors", "Box backcground color", "0, 0, 15, 130", "The color of the Box background");
			ButtonsColor = ((BaseUnityPlugin)this).Config.Bind<string>("Background Colors", "Buttons color", "0, 0, 20, 150", "The color of the buttons");
			HighlightedButtonColor = ((BaseUnityPlugin)this).Config.Bind<string>("Background Colors", "Highlighted Button color", "0, 0, 50, 150", "The color of the highlighted button");
			AmountBoxbackgroundColor = ((BaseUnityPlugin)this).Config.Bind<string>("Background Colors", "Amount box color", "0, 0, 50, 255", "The color of the amount box");
			BoxTextColor = ((BaseUnityPlugin)this).Config.Bind<string>("Text Colors", "Box text color", "30, 255, 0, 255", "The color of the box text");
			ButtonTextColor = ((BaseUnityPlugin)this).Config.Bind<string>("Text Colors", "Buttons text color", "20, 142, 0, 255", "The color of the buttons text");
			HighlightedButtonTextColor = ((BaseUnityPlugin)this).Config.Bind<string>("Text Colors", "Highlighted button text color", "36, 255, 0, 255", "The color of the highlighted button text");
			AmountButtonTextColor = ((BaseUnityPlugin)this).Config.Bind<string>("Text Colors", "Amount box text color", "24, 203, 0, 255", "The color of the amount box text");
			BoxTextColor.SettingChanged += delegate
			{
				TerminalGUI.UpdateTextColor();
			};
			ButtonTextColor.SettingChanged += delegate
			{
				TerminalGUI.UpdateTextColor();
			};
			HighlightedButtonTextColor.SettingChanged += delegate
			{
				TerminalGUI.UpdateTextColor();
			};
			AmountButtonTextColor.SettingChanged += delegate
			{
				TerminalGUI.UpdateTextColor();
			};
			CustomCommads.SettingChanged += delegate
			{
				TerminalGUI.UpdateMainButtonNames();
			};
			PagesMode.SettingChanged += delegate
			{
				TerminalGUI.UpdatePagesMode();
			};
		}

		private void OnTerminalBeginUsing(object sender, TerminalEventArgs e)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			if (!Object.op_Implicit((Object)(object)GameObject.Find("TerminalGUI")))
			{
				GameObject val = new GameObject("TerminalGUI");
				Object.DontDestroyOnLoad((Object)(object)val);
				((Object)val).hideFlags = (HideFlags)61;
				val.AddComponent<TerminalGUI>();
				myGUI = (TerminalGUI)(object)val.GetComponent("TerminalGUI");
				myGUI.keybinds = keybinds;
				((BaseUnityPlugin)this).Logger.LogMessage((object)"GUI has been loaded succesfuly");
			}
		}
	}
}
namespace TerminalGamepad.GUILoader
{
	internal class TerminalGUI : MonoBehaviour
	{
		private List<string> ButtonNames;

		public static List<string> MainButtonNamesTEMP;

		private List<string> StoreButtonNames;

		public static List<string> MoonsButtonNames;

		private List<string> BestiaryButtonNames;

		private List<string> LogsButtonNames;

		private List<string> DecorButtonNames;

		private List<string> UpgradeButtonNames;

		private List<string> RadarsName;

		private List<string> StorageButtonNames;

		private List<string> PlayersName;

		private List<string> CodesButtonNames;

		public static List<string> MainButtonNames = new List<string>
		{
			"Store", "Moons", "Scan", "Monitors", "Ping", "Flash", "Transmit", "Codes", "Bestiary", "Logs",
			"Upgrades", "Storage", "Decor"
		};

		private List<string> ConfirmButtonNames = new List<string> { "Confirm", "Deny", "Info" };

		private List<string> InfoButtonNames = new List<string> { "Continue", "Go Back" };

		private List<string> EmptyButtonNames = new List<string> { "Return" };

		private List<string> Keyboard = new List<string>
		{
			"1", "2", "3", "4", "5", "6", "7", "8", "9", "0",
			"Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P",
			"A", "S", "D", "F", "G", "H", "J", "K", "L", "SPACE",
			"Backspace", "Z", "X", "C", "V", "B", "N", "M", "!", "Submit"
		};

		private string tmp;

		private int myCount = 0;

		private int myCountInedx = 0;

		private int Amount = 1;

		private int AmountLimit = 9999;

		private int tempItemAmount;

		private int Page = 1;

		private int totalOfPages = 1;

		private int Rows = 2;

		private int currentRow = 1;

		private int Columns = 8;

		private int Limit = 16;

		private int ButtonIndex = 16;

		private float MenuX;

		private float MenuY;

		private float MenuWidth;

		private float MenuHeight;

		private float ButtonX;

		private float BetweenSpaceX;

		private float BetweenSpaceY;

		private float ButtonY;

		private float ButtonWidth;

		private float ButtonHeight;

		private static GUIStyle boxStyle;

		private static GUIStyle buttonStyle;

		private static GUIStyle hoverbuttonStyle;

		private static GUIStyle normalbuttonStyle;

		private static GUIStyle textFieldStyle;

		private bool isUiVisible = false;

		private bool isStylesLoaded = false;

		private bool justHasBeenLoaded = true;

		private bool isAmountBoxVisible = false;

		private bool boxVisible = true;

		public static bool leftRight = false;

		public static bool upDown = false;

		public static bool dynamic = false;

		public static Pages currentPage;

		public static SubPages currentSubPage;

		internal KeyBinds keybinds;

		private ManualLogSource mls;

		private void Start()
		{
			MainButtonNamesTEMP = MainButtonNames;
			ButtonNames = MainButtonNames;
			mls = Logger.CreateLogSource("TerminalGamepad");
			SetupComp();
			TerminalEvents();
			UpdateMainButtonNames();
			UpdatePagesMode();
			DrawBoxForOneSecond();
		}

		private void SetupComp()
		{
			LGU.Setup();
			TooManyEmotes.Setup();
			SellMyScrap.Setup();
		}

		private void Update()
		{
			try
			{
				if (ButtonNames[myCount] == null)
				{
				}
			}
			catch (ArgumentOutOfRangeException)
			{
				myCount = ButtonNames.Count - 1;
				myCountInedx = myCount - Limit * (Page - 1);
			}
			if (!StartOfRound.Instance.localPlayerController.inTerminalMenu || !isUiVisible)
			{
				return;
			}
			LoadButtonsInfo();
			for (int i = 1; i <= Rows; i++)
			{
				if (myCountInedx <= Columns * i && myCountInedx >= Columns * (i - 1))
				{
					currentRow = i;
				}
			}
			if (TerminalApi.GetTerminalInput().ToLower() != ButtonNames[myCount].ToLower())
			{
				if (currentSubPage != SubPages.Info && currentPage != Pages.Bruteforce && currentPage != Pages.Transmit && currentPage != Pages.Lookup)
				{
					if (currentPage == Pages.Store && currentSubPage == SubPages.None)
					{
						tmp = StoreButtonNames[myCount];
					}
					if (currentPage == Pages.Moons && currentSubPage == SubPages.None)
					{
						tmp = MoonsButtonNames[myCount];
					}
					if (currentPage == Pages.Upgrades && currentSubPage == SubPages.None)
					{
						tmp = UpgradeButtonNames[myCount];
					}
					if (currentPage == Pages.moreUpgrades && currentSubPage == SubPages.None)
					{
						tmp = LGU.MoreUpgradesButtonsName[myCount];
					}
					TerminalApi.SetTerminalInput(ButtonNames[myCount].ToLower());
				}
				if (ButtonNames[myCount].ToLower() == "logs")
				{
					TerminalApi.SetTerminalInput("sigurd");
				}
				if (ButtonNames[myCount].ToLower() == "flash")
				{
					TerminalApi.SetTerminalInput("blind");
				}
				if (ButtonNames[myCount].ToLower() == "go back")
				{
					if (currentPage == Pages.Store)
					{
						TerminalApi.SetTerminalInput("store");
					}
					else if (currentPage == Pages.Moons)
					{
						TerminalApi.SetTerminalInput("moons");
					}
					else if (currentPage == Pages.Upgrades)
					{
						TerminalApi.SetTerminalInput("upgrades");
					}
				}
				if (ButtonNames[myCount].ToLower() == "return")
				{
					TerminalApi.SetTerminalInput("help");
				}
				if (currentPage == Pages.moreUpgrades && currentSubPage == SubPages.None)
				{
					TerminalApi.SetTerminalInput(LGU.MoreUpgradesButtonsName[myCount] + " info");
				}
				if (ButtonNames[myCount].ToLower() == "continue")
				{
					if (currentPage == Pages.Store)
					{
						TerminalApi.SetTerminalInput($"{tmp} {tempItemAmount}");
					}
					else if (currentPage == Pages.Moons || currentPage == Pages.Upgrades)
					{
						TerminalApi.SetTerminalInput(tmp);
					}
				}
				if (currentSubPage == SubPages.LGUConfirm && currentPage == Pages.moreUpgrades)
				{
					if (ButtonNames[myCount].ToLower() == "confirm")
					{
						TerminalApi.SetTerminalInput(tmp);
					}
					else if (ButtonNames[myCount].ToLower() == "deny")
					{
						TerminalApi.SetTerminalInput("Lategame Store");
					}
				}
				if (currentPage == Pages.Monitor)
				{
					if (ButtonNames[myCount].ToLower() == "on/off")
					{
						TerminalApi.SetTerminalInput("view monitor");
					}
					else
					{
						TerminalApi.SetTerminalInput("switch " + PlayersName[myCount]);
					}
				}
				if (currentPage == Pages.Demon)
				{
					TerminalApi.SetTerminalInput("demon " + LGU.DemonsButtonNames[myCount]);
				}
			}
			if (currentPage == Pages.Store && currentSubPage == SubPages.None && TerminalApi.GetTerminalInput() != $"{ButtonNames[myCount].ToLower()} {Amount}")
			{
				TerminalApi.SetTerminalInput($"{ButtonNames[myCount].ToLower()} {Amount}");
			}
			if (currentPage == Pages.Contract && currentSubPage == SubPages.None)
			{
				if (ButtonNames[myCount].ToLower() == "random")
				{
					TerminalApi.SetTerminalInput("Contract");
				}
				else if (ButtonNames[myCount].ToLower() == "41 experimentation")
				{
					TerminalApi.SetTerminalInput("contract experimentation");
				}
				else
				{
					TerminalApi.SetTerminalInput("contract " + LGU.ContractButtonNames[myCount]);
				}
			}
			if (currentPage == Pages.OnlySellThoseScrap && currentSubPage == SubPages.None && SellMyScrap.scrapList.Count > 0)
			{
				TerminalApi.SetTerminalInput("sell item " + SellMyScrap.scrapList[myCount]);
			}
			if (ButtonNames[myCount].ToLower().Contains("amount"))
			{
				TerminalApi.SetTerminalInput(ButtonNames[myCount].Replace("<amount>", Amount.ToString()));
			}
		}

		private void MakeGUIFitsScreen()
		{
			Rows = ModBase.Rows.Value;
			Columns = ModBase.Columns.Value;
			if (dynamic)
			{
				if (Rows > Columns)
				{
					leftRight = false;
					upDown = true;
				}
				else if (Rows < Columns)
				{
					leftRight = true;
					upDown = false;
				}
				else
				{
					leftRight = true;
					upDown = true;
				}
			}
			MenuX = (float)Screen.width * 0.17f;
			MenuY = (float)Screen.height * 0.59f;
			MenuWidth = (float)Screen.width * 0.66f;
			MenuHeight = (float)Screen.height * 0.41f;
			ButtonX = (float)Screen.width * 0.651f;
			ButtonY = (float)Screen.height * 0.388f;
			if (Columns == 1)
			{
				BetweenSpaceX = (float)Screen.width * 0.0135f;
			}
			else if (Columns % 2 == 0)
			{
				BetweenSpaceX = (float)Screen.width * 0.005f;
			}
			else
			{
				BetweenSpaceX = (float)Screen.width * 0.0078f;
			}
			BetweenSpaceY = (float)Screen.height * 0.013f;
			ButtonWidth = (float)Screen.width * 0.63f / (float)Columns;
			ButtonHeight = (float)Screen.height * 0.36f / (float)Rows;
		}

		private void LoadButtonsInfo()
		{
			if (currentPage == Pages.Store || justHasBeenLoaded)
			{
				StoreButtonNames = TerminalApi.Terminal.buyableItemsList.Select((Item item) => item.itemName).Concat(TerminalApi.Terminal.buyableVehicles.Select((BuyableVehicle item) => item.vehicleDisplayName)).ToList();
			}
			if (currentPage == Pages.Moons || justHasBeenLoaded)
			{
				MoonsButtonNames = TerminalApi.Terminal.moonsCatalogueList.Select((SelectableLevel item) => item.PlanetName).ToList();
				MoonsButtonNames.Add("Company");
			}
			if (currentPage == Pages.Upgrades || justHasBeenLoaded)
			{
				UpgradeButtonNames = (from item in StartOfRound.Instance.unlockablesList.unlockables
					where item.alwaysInStock
					select item.unlockableName).ToList();
			}
			if (currentPage == Pages.Storage || justHasBeenLoaded)
			{
				StorageButtonNames = (from item in StartOfRound.Instance.unlockablesList.unlockables
					where item.inStorage
					select item.unlockableName).ToList();
			}
			if (currentPage == Pages.Bestiary || justHasBeenLoaded)
			{
				BestiaryButtonNames = TerminalApi.Terminal.scannedEnemyIDs.Select((int item) => TerminalApi.Terminal.enemyFiles[item].creatureName).ToList();
			}
			if (currentPage == Pages.Logs || justHasBeenLoaded)
			{
				LogsButtonNames = TerminalApi.Terminal.unlockedStoryLogs.Select((int item) => TerminalApi.Terminal.logEntryFiles[item].creatureName).ToList();
			}
			if (currentPage == Pages.Decor || justHasBeenLoaded)
			{
				DecorButtonNames = TerminalApi.Terminal.ShipDecorSelection.Select((TerminalNode item) => item.creatureName).ToList();
			}
			if (currentPage == Pages.Flash || currentPage == Pages.Ping || justHasBeenLoaded)
			{
				RadarsName = (from item in StartOfRound.Instance.mapScreen.radarTargets
					where item.isNonPlayer
					select item.name).ToList();
			}
			if (currentPage == Pages.Monitor || justHasBeenLoaded)
			{
				PlayersName = new List<string> { "On/Off" };
				PlayersName.AddRange(from item in StartOfRound.Instance.allPlayerScripts
					where item.isPlayerControlled
					select item.playerUsername);
				PlayersName.AddRange(from item in StartOfRound.Instance.mapScreen.radarTargets
					where item.isNonPlayer
					select item.name);
			}
			if (!StartOfRound.Instance.inShipPhase)
			{
				TerminalAccessibleObject[] array = Object.FindObjectsOfType<TerminalAccessibleObject>();
				if (array != null)
				{
					CodesButtonNames = array.Select((TerminalAccessibleObject item) => item.objectCode).ToList();
				}
			}
			else
			{
				CodesButtonNames = new List<string>();
			}
			if (currentPage == Pages.Contract)
			{
				LGU.ContractMoons();
			}
			if (currentPage == Pages.Emotes)
			{
				TooManyEmotes.GetEmotesList();
			}
			if (currentPage == Pages.OnlySellThoseScrap)
			{
				SellMyScrap.GetScrapList();
			}
			if (justHasBeenLoaded)
			{
				justHasBeenLoaded = false;
			}
		}

		public static void UpdateTextColor()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//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_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			textFieldStyle.normal.textColor = Color32.op_Implicit(ReadColor(ModBase.AmountButtonTextColor.Value));
			boxStyle.normal.textColor = Color32.op_Implicit(ReadColor(ModBase.BoxTextColor.Value));
			normalbuttonStyle.normal.textColor = Color32.op_Implicit(ReadColor(ModBase.ButtonTextColor.Value));
			hoverbuttonStyle.normal.textColor = Color32.op_Implicit(ReadColor(ModBase.HighlightedButtonTextColor.Value));
		}

		public static void UpdateMainButtonNames()
		{
			string[] array = MainButtonNamesTEMP.ToArray();
			string[] array2 = ReadText(ModBase.CustomCommads.Value);
			MainButtonNames = new string[array.Length + array2.Length].ToList();
			for (int i = 0; i < array.Length; i++)
			{
				MainButtonNames[i] = array[i];
			}
			for (int j = 0; j < array2.Length; j++)
			{
				MainButtonNames[j + array.Length] = array2[j];
			}
		}

		public static void UpdatePagesMode()
		{
			switch (ModBase.PagesMode.Value)
			{
			case PagesScrollType.Dynamic:
				dynamic = true;
				leftRight = false;
				upDown = false;
				break;
			case PagesScrollType.UpDown:
				upDown = true;
				leftRight = false;
				dynamic = false;
				break;
			case PagesScrollType.LeftRight:
				leftRight = true;
				upDown = false;
				dynamic = false;
				break;
			case PagesScrollType.Both:
				upDown = true;
				leftRight = true;
				dynamic = false;
				break;
			}
		}

		private static Color32 ReadColor(string ColorText)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			byte[] array = (from x in ColorText.Split(new char[3] { ',', ' ', '"' }, StringSplitOptions.RemoveEmptyEntries)
				select byte.Parse(x.Trim(), CultureInfo.InvariantCulture)).ToArray();
			return new Color32(array[0], array[1], array[2], array[3]);
		}

		private static string[] ReadText(string Text)
		{
			return Text.Split(new char[2] { ',', '"' }, StringSplitOptions.RemoveEmptyEntries);
		}

		private void OnGUI()
		{
			//IL_0037: 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)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			if (!isStylesLoaded)
			{
				LoadStyles();
			}
			if (boxVisible)
			{
				GUI.Box(new Rect((float)(Screen.width + 100), 0f, 30f, 30f), "test");
			}
			if (isUiVisible && StartOfRound.Instance.localPlayerController.inTerminalMenu)
			{
				totalOfPages = Mathf.CeilToInt((float)ButtonNames.Count / (float)Limit);
				string text = $"Page <{Page}/{totalOfPages}>";
				GUI.backgroundColor = Color32.op_Implicit(ReadColor(ModBase.BoxBackgroundColor.Value));
				GUI.Box(new Rect(MenuX, MenuY, MenuWidth, MenuHeight), text, boxStyle);
				if ((currentPage == Pages.Store || (currentPage == Pages.SellMyScrap && ButtonNames[myCount].ToLower().Contains("amount")) || (currentPage == Pages.LateGame && TerminalApi.GetTerminalInput().ToLower().Contains("deadline"))) && currentSubPage == SubPages.None)
				{
					isAmountBoxVisible = true;
					GUI.backgroundColor = Color32.op_Implicit(ReadColor(ModBase.AmountBoxbackgroundColor.Value));
					GUI.TextField(new Rect(MenuX + (float)Screen.width * 0.006f, MenuY - 20f, 65f, 20f), "Amount: " + Amount, textFieldStyle);
				}
				else
				{
					isAmountBoxVisible = false;
				}
				switch (currentPage)
				{
				case Pages.Main:
					ButtonNames = MainButtonNames;
					break;
				case Pages.Store:
					ButtonNames = StoreButtonNames;
					AmountLimit = 12;
					break;
				case Pages.Moons:
					ButtonNames = MoonsButtonNames;
					break;
				case Pages.Monitor:
					ButtonNames = PlayersName;
					break;
				case Pages.Ping:
					ButtonNames = RadarsName;
					break;
				case Pages.Flash:
					ButtonNames = RadarsName;
					break;
				case Pages.Codes:
					ButtonNames = CodesButtonNames;
					break;
				case Pages.Bestiary:
					ButtonNames = BestiaryButtonNames;
					break;
				case Pages.Logs:
					ButtonNames = LogsButtonNames;
					break;
				case Pages.Upgrades:
					ButtonNames = UpgradeButtonNames;
					break;
				case Pages.Storage:
					ButtonNames = StorageButtonNames;
					break;
				case Pages.Decor:
					ButtonNames = DecorButtonNames;
					break;
				case Pages.Transmit:
					ButtonNames = Keyboard;
					break;
				case Pages.LateGame:
					ButtonNames = LGU.MainButtonsName;
					AmountLimit = 999;
					break;
				case Pages.moreUpgrades:
					ButtonNames = LGU.MoreUpgradesButtonsName;
					break;
				case Pages.Contract:
					ButtonNames = LGU.ContractButtonNames;
					break;
				case Pages.Demon:
					ButtonNames = LGU.DemonsButtonNames;
					break;
				case Pages.Lookup:
					ButtonNames = Keyboard;
					break;
				case Pages.Bruteforce:
					ButtonNames = LGU.IPButtonNames;
					break;
				case Pages.Emotes:
					ButtonNames = TooManyEmotes.StoreButtonsName;
					break;
				case Pages.SellMyScrap:
					ButtonNames = SellMyScrap.MainButtonsName;
					AmountLimit = 999;
					break;
				case Pages.OnlySellThoseScrap:
					ButtonNames = SellMyScrap.scrapList;
					break;
				}
				switch (currentSubPage)
				{
				case SubPages.Confirm:
					ButtonNames = ConfirmButtonNames;
					break;
				case SubPages.Info:
					ButtonNames = InfoButtonNames;
					break;
				case SubPages.LGUConfirm:
					ButtonNames = LGU.ConfirmButtonNames;
					break;
				}
				if (ButtonNames.Count <= 0 || ButtonNames == null)
				{
					ButtonNames = EmptyButtonNames;
				}
				DrawButtons();
			}
		}

		private void DrawButtons()
		{
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			if (ButtonNames != Keyboard)
			{
				MakeGUIFitsScreen();
				Limit = Rows * Columns;
				if (myCount > Limit * Page - 1)
				{
					Page++;
					myCountInedx = myCount - Limit * (Page - 1);
				}
				else if (myCount < Limit * (Page - 1))
				{
					Page--;
					myCountInedx = myCount - Limit * (Page - 1);
				}
				int num = 1;
				for (int i = 0; i < ButtonNames.Count; i++)
				{
					ButtonIndex = i - Limit * (Page - 1);
					num = ButtonIndex / Columns;
					if (i == myCount)
					{
						GUI.backgroundColor = Color32.op_Implicit(ReadColor(ModBase.HighlightedButtonColor.Value));
						buttonStyle = hoverbuttonStyle;
					}
					else
					{
						GUI.backgroundColor = Color32.op_Implicit(ReadColor(ModBase.ButtonsColor.Value));
						buttonStyle = normalbuttonStyle;
					}
					if (ButtonIndex >= 0 && ButtonIndex < Limit)
					{
						GUI.Button(new Rect(MenuX + BetweenSpaceX + (float)(ButtonIndex - Columns * num) * (ButtonX / (float)Columns), MenuY + MenuHeight / ((float)Rows + BetweenSpaceY) + (float)num * (ButtonY / (float)Rows), ButtonWidth, ButtonHeight), ButtonNames[i], buttonStyle);
					}
				}
			}
			else
			{
				DrawKeyboard();
			}
		}

		private void DrawKeyboard()
		{
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			MakeGUIFitsScreen();
			int num = 1;
			Rows = 4;
			Columns = 10;
			Limit = Rows * Columns;
			for (int i = 0; i < ButtonNames.Count; i++)
			{
				float num2 = (float)Screen.width * 0.63f / (float)Columns;
				float num3 = (float)Screen.height * 0.36f / (float)Rows;
				num = i / Columns;
				if (i == myCount)
				{
					GUI.backgroundColor = Color32.op_Implicit(ReadColor(ModBase.HighlightedButtonColor.Value));
					buttonStyle = hoverbuttonStyle;
				}
				else
				{
					GUI.backgroundColor = Color32.op_Implicit(ReadColor(ModBase.ButtonsColor.Value));
					buttonStyle = normalbuttonStyle;
				}
				if (i >= 0 && i < Limit)
				{
					GUI.Button(new Rect(MenuX + BetweenSpaceX + (float)(i - Columns * num) * (ButtonX / (float)Columns), MenuY + MenuHeight / ((float)Rows + BetweenSpaceY) + (float)num * (ButtonY / (float)Rows), num2, num3), ButtonNames[i], buttonStyle);
				}
			}
		}

		private IEnumerator DrawBoxForOneSecond()
		{
			yield return (object)new WaitForSeconds(1f);
			boxVisible = false;
		}

		private void LoadStyles()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Expected O, but got Unknown
			//IL_0085: 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_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: 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_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			isStylesLoaded = true;
			Texture2D background = new Texture2D(10, 10);
			MakeTex(2, 2, Color.white, background);
			boxStyle = new GUIStyle(GUI.skin.box);
			hoverbuttonStyle = new GUIStyle(GUI.skin.button);
			normalbuttonStyle = new GUIStyle(GUI.skin.button);
			textFieldStyle = new GUIStyle(GUI.skin.button);
			hoverbuttonStyle.normal.textColor = Color32.op_Implicit(ReadColor(ModBase.HighlightedButtonTextColor.Value));
			hoverbuttonStyle.normal.background = background;
			hoverbuttonStyle.fontSize = 16;
			hoverbuttonStyle.fontStyle = (FontStyle)1;
			hoverbuttonStyle.wordWrap = true;
			((Object)hoverbuttonStyle.normal.background).hideFlags = (HideFlags)61;
			normalbuttonStyle.normal.textColor = Color32.op_Implicit(ReadColor(ModBase.ButtonTextColor.Value));
			normalbuttonStyle.normal.background = background;
			normalbuttonStyle.fontSize = 14;
			normalbuttonStyle.fontStyle = (FontStyle)0;
			normalbuttonStyle.wordWrap = true;
			((Object)normalbuttonStyle.normal.background).hideFlags = (HideFlags)61;
			boxStyle.normal.textColor = Color32.op_Implicit(ReadColor(ModBase.BoxTextColor.Value));
			boxStyle.normal.background = background;
			boxStyle.fontSize = 10;
			boxStyle.fontStyle = (FontStyle)0;
			((Object)boxStyle.normal.background).hideFlags = (HideFlags)61;
			textFieldStyle.normal.textColor = Color32.op_Implicit(ReadColor(ModBase.AmountButtonTextColor.Value));
			textFieldStyle.normal.background = background;
			textFieldStyle.fontSize = 9;
			textFieldStyle.fontStyle = (FontStyle)1;
			((Object)textFieldStyle.normal.background).hideFlags = (HideFlags)61;
		}

		private void MakeTex(int width, int height, Color col, Texture2D background)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: 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_002f: Expected O, but got Unknown
			Color[] array = (Color[])(object)new Color[width * height];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = col;
			}
			background = new Texture2D(width, height);
			background.SetPixels(array);
			background.Apply();
		}

		private void TerminalEvents()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			Events.TerminalBeginUsing += new TerminalEventHandler(OnTerminalBeginUsing);
			Events.TerminalExited += new TerminalEventHandler(OnTerminalExited);
		}

		private void OnTerminalBeginUsing(object sender, TerminalEventArgs e)
		{
			keybinds.ShowKeyboardKey.Enable();
			keybinds.ShowKeyboardKey.performed += ShowHideKeyboard;
			keybinds.LeftArrow.Enable();
			keybinds.LeftArrow.performed += GoLeft;
			keybinds.RightArrow.Enable();
			keybinds.RightArrow.performed += GoRight;
			keybinds.UpArrow.Enable();
			keybinds.UpArrow.performed += GoUp;
			keybinds.DownArrow.Enable();
			keybinds.DownArrow.performed += GoDown;
			keybinds.Subbmit.Enable();
			keybinds.Subbmit.performed += Subbmit;
			keybinds.PlusAmount.Enable();
			keybinds.PlusAmount.performed += PlusAmount;
			keybinds.MinusAmount.Enable();
			keybinds.MinusAmount.performed += MinusAmount;
			keybinds.Return.Enable();
			keybinds.Return.performed += Return;
			currentPage = Pages.Main;
			currentSubPage = SubPages.None;
		}

		private void OnTerminalExited(object sender, TerminalEventArgs e)
		{
			keybinds.ShowKeyboardKey.Disable();
			keybinds.ShowKeyboardKey.performed -= ShowHideKeyboard;
			keybinds.LeftArrow.Disable();
			keybinds.LeftArrow.performed -= GoLeft;
			keybinds.RightArrow.Disable();
			keybinds.RightArrow.performed -= GoRight;
			keybinds.UpArrow.Disable();
			keybinds.UpArrow.performed -= GoUp;
			keybinds.DownArrow.Disable();
			keybinds.DownArrow.performed -= GoDown;
			keybinds.Subbmit.Disable();
			keybinds.Subbmit.performed -= Subbmit;
			keybinds.PlusAmount.Disable();
			keybinds.PlusAmount.performed -= PlusAmount;
			keybinds.MinusAmount.Disable();
			keybinds.MinusAmount.performed -= MinusAmount;
			keybinds.Return.Disable();
			keybinds.Return.performed -= Return;
			myCount = 0;
			Amount = 1;
			Page = 1;
		}

		private void ShowHideKeyboard(CallbackContext context)
		{
			isUiVisible = !isUiVisible;
			if (StartOfRound.Instance.localPlayerUsingController)
			{
				RoundManager.PlayRandomClip(TerminalApi.Terminal.terminalAudio, TerminalApi.Terminal.keyboardClips, true, 1f, 0, 1000);
			}
		}

		private void Subbmit(CallbackContext context)
		{
			if (myCount >= ButtonNames.Count)
			{
				return;
			}
			Pages pages = currentPage;
			if (StartOfRound.Instance.localPlayerUsingController)
			{
				RoundManager.PlayRandomClip(TerminalApi.Terminal.terminalAudio, TerminalApi.Terminal.keyboardClips, true, 1f, 0, 1000);
			}
			if (ButtonNames == EmptyButtonNames)
			{
				currentPage = Pages.Main;
				TerminalApi.Terminal.OnSubmit();
			}
			if (ButtonNames != EmptyButtonNames)
			{
				bool flag = false;
				if (currentPage == Pages.Main)
				{
					if (TerminalApi.GetTerminalInput().ToLower() == "store")
					{
						currentPage = Pages.Store;
					}
					if (TerminalApi.GetTerminalInput().ToLower() == "moons")
					{
						currentPage = Pages.Moons;
					}
					if (TerminalApi.GetTerminalInput().ToLower() == "bestiary")
					{
						currentPage = Pages.Bestiary;
					}
					if (TerminalApi.GetTerminalInput().ToLower() == "sigurd")
					{
						currentPage = Pages.Logs;
					}
					if (TerminalApi.GetTerminalInput().ToLower() == "storage")
					{
						currentPage = Pages.Storage;
					}
					if (TerminalApi.GetTerminalInput().ToLower() == "blind")
					{
						currentPage = Pages.Flash;
					}
					if (TerminalApi.GetTerminalInput().ToLower() == "ping")
					{
						currentPage = Pages.Ping;
					}
					if (TerminalApi.GetTerminalInput().ToLower() == "monitors")
					{
						currentPage = Pages.Monitor;
					}
					if (TerminalApi.GetTerminalInput().ToLower() == "codes")
					{
						currentPage = Pages.Codes;
					}
					if (TerminalApi.GetTerminalInput().ToLower() == "decor")
					{
						currentPage = Pages.Decor;
					}
					if (TerminalApi.GetTerminalInput().ToLower() == "upgrades")
					{
						currentPage = Pages.Upgrades;
					}
					if (TerminalApi.GetTerminalInput().ToLower() == "transmit")
					{
						currentPage = Pages.Transmit;
						TerminalApi.SetTerminalInput("");
					}
					if (TerminalApi.GetTerminalInput().ToLower() == "lategame" && LGU.enabled)
					{
						currentPage = Pages.LateGame;
					}
					if (TerminalApi.GetTerminalInput().ToLower() == "emotes" && TooManyEmotes.enabled)
					{
						currentPage = Pages.Emotes;
					}
					if (TerminalApi.GetTerminalInput().ToLower() == "sell" && SellMyScrap.enabled)
					{
						currentPage = Pages.SellMyScrap;
					}
					flag = true;
				}
				if (currentPage == Pages.LateGame && !flag)
				{
					if (TerminalApi.GetTerminalInput().ToLower() == "lategame store")
					{
						currentPage = Pages.moreUpgrades;
					}
					if (TerminalApi.GetTerminalInput().ToLower() == "contract info")
					{
						currentPage = Pages.Contract;
					}
					if (TerminalApi.GetTerminalInput().ToLower() == "demon")
					{
						currentPage = Pages.Demon;
					}
					if (TerminalApi.GetTerminalInput().ToLower() == "bruteforce")
					{
						currentPage = Pages.Bruteforce;
						TerminalApi.SetTerminalInput("");
					}
					if (TerminalApi.GetTerminalInput().ToLower() == "lookup")
					{
						currentPage = Pages.Lookup;
						TerminalApi.SetTerminalInput("");
					}
					flag = true;
				}
				if (currentPage == Pages.SellMyScrap && !flag)
				{
					if (TerminalApi.GetTerminalInput().ToLower() == "sell item")
					{
						currentPage = Pages.OnlySellThoseScrap;
					}
					if (ButtonNames[myCount].ToLower().Contains("sell") && !ButtonNames[myCount].ToLower().Contains("item"))
					{
						currentSubPage = SubPages.Confirm;
					}
					flag = true;
				}
				if (currentPage == Pages.Flash && !flag && ButtonNames[myCount].ToLower() == RadarsName[myCount].ToLower())
				{
					TerminalApi.SetTerminalInput("flash " + RadarsName[myCount]);
				}
				if (currentPage == Pages.Ping && !flag && ButtonNames[myCount].ToLower() == RadarsName[myCount].ToLower())
				{
					TerminalApi.SetTerminalInput("ping " + RadarsName[myCount]);
				}
				if (currentPage == Pages.Store && !flag && ButtonNames[myCount].ToLower() == StoreButtonNames[myCount].ToLower())
				{
					tempItemAmount = Amount;
					currentSubPage = SubPages.Confirm;
				}
				if (currentPage == Pages.Decor && !flag && ButtonNames[myCount].ToLower() == DecorButtonNames[myCount].ToLower())
				{
					currentSubPage = SubPages.Confirm;
				}
				if (currentPage == Pages.Moons && !flag && ButtonNames[myCount].ToLower() == MoonsButtonNames[myCount].ToLower())
				{
					currentSubPage = SubPages.Confirm;
				}
				if (currentPage == Pages.Upgrades && !flag && ButtonNames[myCount].ToLower() == UpgradeButtonNames[myCount].ToLower())
				{
					currentSubPage = SubPages.Confirm;
				}
				if (currentPage == Pages.Emotes && !flag && ButtonNames[myCount].ToLower() == TooManyEmotes.StoreButtonsName[myCount].ToLower())
				{
					currentSubPage = SubPages.Confirm;
				}
				if (currentPage == Pages.OnlySellThoseScrap && !flag && ButtonNames[myCount].ToLower() == SellMyScrap.scrapList[myCount].ToLower())
				{
					currentSubPage = SubPages.Confirm;
				}
				if (currentPage == Pages.moreUpgrades && currentSubPage == SubPages.None && !flag)
				{
					currentSubPage = SubPages.LGUConfirm;
					flag = true;
				}
				if (currentPage == Pages.Contract && currentSubPage == SubPages.None && !flag)
				{
					if (ButtonNames[myCount].ToLower() == "random")
					{
						currentSubPage = SubPages.None;
					}
					else
					{
						currentSubPage = SubPages.LGUConfirm;
					}
					flag = true;
				}
				if (currentSubPage == SubPages.LGUConfirm && !flag)
				{
					currentSubPage = SubPages.None;
				}
				if (currentSubPage == SubPages.Confirm && !flag)
				{
					if (TerminalApi.GetTerminalInput().ToLower() == "info")
					{
						if (currentPage != Pages.Decor && currentPage != Pages.Emotes && currentPage != Pages.OnlySellThoseScrap)
						{
							currentSubPage = SubPages.Info;
						}
					}
					else if (TerminalApi.GetTerminalInput().ToLower() == "deny" || TerminalApi.GetTerminalInput().ToLower() == "confirm")
					{
						currentSubPage = SubPages.None;
					}
				}
				if (currentSubPage == SubPages.Info && !flag && TerminalApi.GetTerminalInput().ToLower() == "info")
				{
					if (currentPage == Pages.Decor)
					{
						currentPage = Pages.Decor;
						TerminalApi.SetTerminalInput("decor");
					}
					else
					{
						TerminalApi.SetTerminalInput("deny");
						TerminalApi.Terminal.OnSubmit();
						TerminalApi.SetTerminalInput(tmp + " info");
					}
					flag = true;
				}
				if (currentSubPage == SubPages.Info && !flag)
				{
					if (ButtonNames[myCount].ToLower() == "continue")
					{
						TerminalApi.Terminal.OnSubmit();
						TerminalApi.SetTerminalInput("confirm");
					}
					currentSubPage = SubPages.None;
				}
				if (currentPage == Pages.Bruteforce && !flag)
				{
					if (ButtonNames[myCount] == ".")
					{
						if (LGU.CountDots(TerminalApi.GetTerminalInput()) < 3 && LGU.CountNumber(TerminalApi.GetTerminalInput()) > 0)
						{
							TerminalApi.SetTerminalInput(TerminalApi.GetTerminalInput() + ButtonNames[myCount]);
						}
					}
					else if (ButtonNames[myCount].ToLower() != "submit" && ButtonNames[myCount].ToLower() != "backspace")
					{
						if (LGU.CountNumber(TerminalApi.GetTerminalInput()) < LGU.HowManyNumbers(TerminalApi.GetTerminalInput()))
						{
							TerminalApi.SetTerminalInput(TerminalApi.GetTerminalInput() + ButtonNames[myCount]);
						}
						mls.LogMessage((object)LGU.CountNumber(TerminalApi.GetTerminalInput()));
					}
					else if (ButtonNames[myCount].ToLower() == "backspace" && !flag)
					{
						if (TerminalApi.GetTerminalInput().Length > 0)
						{
							TerminalApi.SetTerminalInput(TerminalApi.GetTerminalInput().Substring(0, TerminalApi.GetTerminalInput().Length - 1));
						}
					}
					else if (!flag)
					{
						TerminalApi.SetTerminalInput("bruteforce " + TerminalApi.GetTerminalInput());
						TerminalApi.Terminal.OnSubmit();
					}
				}
				if (currentPage == Pages.Transmit && !flag)
				{
					if (ButtonNames[myCount].ToLower() != "submit" && ButtonNames[myCount].ToLower() != "space" && ButtonNames[myCount].ToLower() != "backspace")
					{
						TerminalApi.SetTerminalInput(TerminalApi.GetTerminalInput() + ButtonNames[myCount]);
					}
					else if (ButtonNames[myCount].ToLower() == "space")
					{
						TerminalApi.SetTerminalInput(TerminalApi.GetTerminalInput() + " ");
					}
					else if (ButtonNames[myCount].ToLower() == "backspace")
					{
						if (TerminalApi.GetTerminalInput().Length > 0)
						{
							TerminalApi.SetTerminalInput(TerminalApi.GetTerminalInput().Substring(0, TerminalApi.GetTerminalInput().Length - 1));
						}
					}
					else
					{
						TerminalApi.SetTerminalInput("transmit " + TerminalApi.GetTerminalInput());
						TerminalApi.Terminal.OnSubmit();
					}
				}
				if (currentPage == Pages.Lookup && !flag)
				{
					if (ButtonNames[myCount].ToLower() != "submit" && ButtonNames[myCount].ToLower() != "space" && ButtonNames[myCount].ToLower() != "backspace")
					{
						if (TerminalApi.GetTerminalInput().Length < 2 && LGU.IsLettersOnly(ButtonNames[myCount]))
						{
							TerminalApi.SetTerminalInput(TerminalApi.GetTerminalInput() + ButtonNames[myCount]);
						}
						if (TerminalApi.GetTerminalInput().Length == 2)
						{
							TerminalApi.SetTerminalInput(TerminalApi.GetTerminalInput() + "-");
						}
						else if (TerminalApi.GetTerminalInput().Length > 2 && TerminalApi.GetTerminalInput().Length < 6 && LGU.IsNumbersOnly(ButtonNames[myCount]))
						{
							TerminalApi.SetTerminalInput(TerminalApi.GetTerminalInput() + ButtonNames[myCount]);
						}
					}
					else if (ButtonNames[myCount].ToLower() == "backspace" && !flag)
					{
						if (TerminalApi.GetTerminalInput().Length > 0)
						{
							TerminalApi.SetTerminalInput(TerminalApi.GetTerminalInput().Substring(0, TerminalApi.GetTerminalInput().Length - 1));
						}
					}
					else if (ButtonNames[myCount].ToLower() == "submit" && !flag)
					{
						TerminalApi.SetTerminalInput("lookup " + TerminalApi.GetTerminalInput());
						TerminalApi.Terminal.OnSubmit();
					}
				}
				Amount = 1;
				if (currentPage != Pages.Bruteforce && currentPage != Pages.Transmit && currentPage != Pages.Lookup)
				{
					TerminalApi.Terminal.OnSubmit();
				}
			}
			else
			{
				myCount = 0;
				myCountInedx = myCount - Limit * (Page - 1);
			}
			if (currentPage == Pages.Main)
			{
				return;
			}
			switch (pages)
			{
			case Pages.LateGame:
				if (currentPage == Pages.LateGame)
				{
					break;
				}
				goto default;
			default:
				if (pages != Pages.Transmit && pages != Pages.Lookup && pages != Pages.Codes)
				{
					myCount = 0;
					Page = 1;
					myCountInedx = myCount - Limit * (Page - 1);
				}
				break;
			case Pages.Monitor:
			case Pages.Ping:
			case Pages.Flash:
			case Pages.Bruteforce:
				break;
			}
		}

		private void Return(CallbackContext context)
		{
			if (StartOfRound.Instance.localPlayerUsingController)
			{
				RoundManager.PlayRandomClip(TerminalApi.Terminal.terminalAudio, TerminalApi.Terminal.keyboardClips, true, 1f, 0, 1000);
			}
			if (currentPage != Pages.Bruteforce && currentPage != 0)
			{
				Page = 1;
				myCount = 0;
				myCountInedx = myCount - Limit * (Page - 1);
			}
			if (currentPage == Pages.Main)
			{
				return;
			}
			if (ButtonNames == EmptyButtonNames)
			{
				currentPage = Pages.Main;
				TerminalApi.SetTerminalInput("help");
			}
			if ((currentPage == Pages.Store && currentSubPage == SubPages.None) || (currentPage == Pages.Moons && currentSubPage == SubPages.None) || currentPage == Pages.Bestiary || currentPage == Pages.Logs || currentPage == Pages.Storage || currentPage == Pages.Flash || currentPage == Pages.Ping || currentPage == Pages.Monitor || currentPage == Pages.Codes || (currentPage == Pages.Decor && currentSubPage == SubPages.None) || (currentPage == Pages.Upgrades && currentSubPage == SubPages.None) || (currentPage == Pages.LateGame && currentSubPage == SubPages.None) || currentPage == Pages.Transmit || (currentPage == Pages.Emotes && currentSubPage == SubPages.None) || (currentPage == Pages.SellMyScrap && currentSubPage == SubPages.None))
			{
				currentPage = Pages.Main;
				TerminalApi.SetTerminalInput("help");
			}
			if (currentSubPage == SubPages.Confirm)
			{
				currentSubPage = SubPages.None;
				TerminalApi.SetTerminalInput("deny");
				TerminalApi.Terminal.OnSubmit();
				if (currentPage == Pages.Store)
				{
					TerminalApi.SetTerminalInput("store");
				}
				else if (currentPage == Pages.Moons)
				{
					TerminalApi.SetTerminalInput("moons");
				}
				else if (currentPage == Pages.Decor)
				{
					TerminalApi.SetTerminalInput("decor");
				}
				else if (currentPage == Pages.Upgrades)
				{
					TerminalApi.SetTerminalInput("upgrades");
				}
			}
			if (currentSubPage == SubPages.Info)
			{
				currentSubPage = SubPages.None;
				if (currentPage == Pages.Store)
				{
					TerminalApi.SetTerminalInput("store");
				}
				else if (currentPage == Pages.Moons)
				{
					TerminalApi.SetTerminalInput("moons");
				}
				else if (currentPage == Pages.Upgrades)
				{
					TerminalApi.SetTerminalInput("upgrades");
				}
			}
			if (((currentPage == Pages.moreUpgrades || currentPage == Pages.Contract) && currentSubPage == SubPages.None) || currentPage == Pages.Demon || currentPage == Pages.Lookup || currentPage == Pages.Bruteforce)
			{
				currentPage = Pages.LateGame;
				TerminalApi.SetTerminalInput("Lategame");
			}
			if (currentPage == Pages.OnlySellThoseScrap && currentSubPage == SubPages.None)
			{
				currentPage = Pages.SellMyScrap;
				TerminalApi.SetTerminalInput("sell");
			}
			if (currentSubPage == SubPages.LGUConfirm)
			{
				currentSubPage = SubPages.None;
				if (currentPage == Pages.moreUpgrades)
				{
					TerminalApi.SetTerminalInput("Lategame Store");
				}
				else if (currentPage == Pages.Contract)
				{
					TerminalApi.SetTerminalInput("contract info");
					TerminalApi.Terminal.OnSubmit();
					TerminalApi.SetTerminalInput("contract info");
				}
			}
			TerminalApi.Terminal.OnSubmit();
		}

		private void GoDown(CallbackContext context)
		{
			if (StartOfRound.Instance.localPlayerUsingController)
			{
				RoundManager.PlayRandomClip(TerminalApi.Terminal.terminalAudio, TerminalApi.Terminal.keyboardClips, true, 1f, 0, 1000);
			}
			if (isUiVisible)
			{
				myCount += Columns;
				if (myCount > ButtonNames.Count - 1 || (!upDown && currentRow == Rows))
				{
					myCount -= Columns;
				}
				myCountInedx = myCount - Limit * (Page - 1);
			}
		}

		private void GoUp(CallbackContext context)
		{
			if (StartOfRound.Instance.localPlayerUsingController)
			{
				RoundManager.PlayRandomClip(TerminalApi.Terminal.terminalAudio, TerminalApi.Terminal.keyboardClips, true, 1f, 0, 1000);
			}
			if (isUiVisible)
			{
				myCount -= Columns;
				if (myCount < 0 || (!upDown && currentRow == 1))
				{
					myCount += Columns;
				}
				myCountInedx = myCount - Limit * (Page - 1);
			}
		}

		private void GoRight(CallbackContext context)
		{
			if (StartOfRound.Instance.localPlayerUsingController)
			{
				RoundManager.PlayRandomClip(TerminalApi.Terminal.terminalAudio, TerminalApi.Terminal.keyboardClips, true, 1f, 0, 1000);
			}
			if (!isUiVisible)
			{
				return;
			}
			myCount++;
			myCountInedx = myCount - Limit * (Page - 1);
			if (myCount > ButtonNames.Count - 1)
			{
				myCount--;
				myCountInedx = myCount - Limit * (Page - 1);
			}
			else if (myCountInedx > currentRow * Columns - 1)
			{
				if (currentRow != Rows && leftRight)
				{
					myCount--;
					myCountInedx = myCount - Limit * (Page - 1);
				}
				else if (!leftRight)
				{
					myCount--;
					myCountInedx = myCount - Limit * (Page - 1);
				}
			}
		}

		private void GoLeft(CallbackContext context)
		{
			if (StartOfRound.Instance.localPlayerUsingController)
			{
				RoundManager.PlayRandomClip(TerminalApi.Terminal.terminalAudio, TerminalApi.Terminal.keyboardClips, true, 1f, 0, 1000);
			}
			if (!isUiVisible)
			{
				return;
			}
			myCount--;
			myCountInedx = myCount - Limit * (Page - 1);
			if (myCount < 0)
			{
				myCount++;
				myCountInedx = myCount - Limit * (Page - 1);
			}
			else if (myCountInedx < currentRow * Columns - 1 - Columns + 1)
			{
				if (currentRow != 1 && leftRight)
				{
					myCount++;
					myCountInedx = myCount - Limit * (Page - 1);
				}
				else if (!leftRight)
				{
					myCount++;
					myCountInedx = myCount - Limit * (Page - 1);
				}
			}
		}

		private void PlusAmount(CallbackContext context)
		{
			if (StartOfRound.Instance.localPlayerUsingController)
			{
				RoundManager.PlayRandomClip(TerminalApi.Terminal.terminalAudio, TerminalApi.Terminal.keyboardClips, true, 1f, 0, 1000);
			}
			if (isAmountBoxVisible)
			{
				Amount++;
				if (Amount > AmountLimit)
				{
					Amount = 1;
				}
			}
		}

		private void MinusAmount(CallbackContext context)
		{
			if (StartOfRound.Instance.localPlayerUsingController)
			{
				RoundManager.PlayRandomClip(TerminalApi.Terminal.terminalAudio, TerminalApi.Terminal.keyboardClips, true, 1f, 0, 1000);
			}
			if (isAmountBoxVisible)
			{
				Amount--;
				if (Amount < 1)
				{
					Amount = AmountLimit;
				}
			}
		}
	}
	public class KeyBinds : LcInputActions
	{
		[InputAction("<Keyboard>/leftCtrl", Name = "ShowKeyboard", GamepadPath = "<Gamepad>/buttonNorth")]
		public InputAction ShowKeyboardKey { get; set; }

		[InputAction("<Keyboard>/enter", Name = "Subbmit", GamepadPath = "<Gamepad>/buttonSouth")]
		public InputAction Subbmit { get; set; }

		[InputAction("<Keyboard>/alt", Name = "Return", GamepadPath = "<Gamepad>/buttonEast")]
		public InputAction Return { get; set; }

		[InputAction("<Keyboard>/e", Name = "PlusAmount", GamepadPath = "<Gamepad>/rightShoulder")]
		public InputAction PlusAmount { get; set; }

		[InputAction("<Keyboard>/q", Name = "MinusAmount", GamepadPath = "<Gamepad>/leftShoulder")]
		public InputAction MinusAmount { get; set; }

		[InputAction("<Keyboard>/upArrow", Name = "upArrow", GamepadPath = "<Gamepad>/dpad/up")]
		public InputAction UpArrow { get; set; }

		[InputAction("<Keyboard>/downArrow", Name = "downArrow", GamepadPath = "<Gamepad>/dpad/down")]
		public InputAction DownArrow { get; set; }

		[InputAction("<Keyboard>/leftArrow", Name = "leftArrow", GamepadPath = "<Gamepad>/dpad/left")]
		public InputAction LeftArrow { get; set; }

		[InputAction("<Keyboard>/rightArrow", Name = "rightArrow", GamepadPath = "<Gamepad>/dpad/right")]
		public InputAction RightArrow { get; set; }
	}
}
namespace TerminalGamepad.Data
{
	public enum Pages
	{
		Main,
		Store,
		Moons,
		Monitor,
		Ping,
		Flash,
		Codes,
		Bestiary,
		Logs,
		Upgrades,
		Storage,
		Decor,
		Transmit,
		LateGame,
		moreUpgrades,
		Contract,
		Demon,
		Lookup,
		Bruteforce,
		Emotes,
		SellMyScrap,
		OnlySellThoseScrap
	}
	public enum PagesScrollType
	{
		Dynamic,
		UpDown,
		LeftRight,
		Both
	}
	public enum SubPages
	{
		Confirm,
		Info,
		LGUConfirm,
		None
	}
}