Files
BepInEx/Projects/BanquetForFools/Source/Assembly-CSharp/KeyControl.cs
2025-05-21 20:40:04 +02:00

1186 lines
22 KiB
C#

using System;
using System.Collections.Generic;
using UnityEngine;
// Token: 0x0200008C RID: 140
public class KeyControl : MonoBehaviour
{
// Token: 0x06000DDD RID: 3549 RVA: 0x0010560C File Offset: 0x0010380C
public KeyCode GetHotkey(string type)
{
int num = 0;
using (List<string>.Enumerator enumerator = this.keyFunction.GetEnumerator())
{
while (enumerator.MoveNext())
{
if (enumerator.Current == type)
{
return this.keys[num];
}
num++;
}
}
return this.keys[0];
}
// Token: 0x06000DDE RID: 3550 RVA: 0x00105684 File Offset: 0x00103884
public string GetHotkeyString(string type)
{
if (Links.x.joy)
{
return "";
}
int num = 0;
using (List<string>.Enumerator enumerator = this.keyFunction.GetEnumerator())
{
while (enumerator.MoveNext())
{
if (enumerator.Current == type)
{
return this.keyStrings[num];
}
num++;
}
}
return this.keyStrings[0];
}
// Token: 0x06000DDF RID: 3551 RVA: 0x0010570C File Offset: 0x0010390C
public string GetHotkeyByIndex(int n)
{
int num = 0;
foreach (string text in this.keyFunction)
{
if (num == n)
{
string text2 = this.keyStrings[num];
return this.GetKeyReal(text2);
}
num++;
}
return "";
}
// Token: 0x06000DE0 RID: 3552 RVA: 0x00105784 File Offset: 0x00103984
public string GetHudHotkey(int index)
{
string text = this.keyStrings[index + 13];
return this.GetKeyReal(text);
}
// Token: 0x06000DE1 RID: 3553 RVA: 0x001057A8 File Offset: 0x001039A8
public string GetKeyReal(string theKey)
{
string text = theKey;
if (text.Contains("0"))
{
text = "0";
}
if (text.Contains("1"))
{
text = "1";
}
if (text.Contains("2"))
{
text = "2";
}
if (text.Contains("3"))
{
text = "3";
}
if (text.Contains("4"))
{
text = "4";
}
if (text.Contains("5"))
{
text = "5";
}
if (text.Contains("6"))
{
text = "6";
}
if (text.Contains("7"))
{
text = "7";
}
if (text.Contains("8"))
{
text = "8";
}
if (text.Contains("9"))
{
text = "9";
}
if (text.Contains("Plus"))
{
text = "+";
}
if (text.Contains("Equals"))
{
text = "+";
}
if (text.Contains("Minus"))
{
text = "-";
}
if (text.Contains("Caret"))
{
text = "~";
}
if (text.Contains("Delete"))
{
text = "Del";
}
if (text.Contains("Comma"))
{
text = ",";
}
if (text.Contains("Quest"))
{
text = "?";
}
if (text.Contains("Period"))
{
text = ".";
}
if (text.Contains("Semi"))
{
text = ";";
}
if (text.Contains("Quote"))
{
text = "'";
}
if (text.Contains("Left Shift"))
{
text = "LS";
}
if (text.Contains("Right Shift"))
{
text = "RS";
}
if (text.Contains("Left Control"))
{
text = "LC";
}
if (text.Contains("Right Control"))
{
text = "RC";
}
if (text.Contains("Left Meta"))
{
text = "LC";
}
if (text.Contains("Right Meta"))
{
text = "RC";
}
if (text.Contains("Left Apple"))
{
text = "LC";
}
if (text.Contains("Right Apple"))
{
text = "RC";
}
if (text.Contains("Left Option"))
{
text = "LA";
}
if (text.Contains("Right Option"))
{
text = "RA";
}
if (text.Contains("Left Shift"))
{
text = "LS";
}
if (text.Contains("Caps"))
{
text = "CP";
}
if (text.Contains("Left Arrow"))
{
text = "Lt";
}
if (text.Contains("Right Arrow"))
{
text = "Rt";
}
if (text.Contains("Up Arrow"))
{
text = "Up";
}
if (text.Contains("Down Arrow"))
{
text = "Dn";
}
if (text.Contains("Left Bracket"))
{
text = "[";
}
if (text.Contains("Right Brack"))
{
text = "]";
}
if (text.Contains("Backslash"))
{
text = "|";
}
return text;
}
// Token: 0x06000DE2 RID: 3554 RVA: 0x00105AA0 File Offset: 0x00103CA0
public int GetKeyIconIndex(string theKey)
{
int num = 0;
if (theKey.Contains("0"))
{
return 0;
}
if (theKey.Contains("1"))
{
return 1;
}
if (theKey.Contains("2"))
{
return 2;
}
if (theKey.Contains("3"))
{
return 3;
}
if (theKey.Contains("4"))
{
return 4;
}
if (theKey.Contains("5"))
{
return 5;
}
if (theKey.Contains("6"))
{
return 6;
}
if (theKey.Contains("7"))
{
return 7;
}
if (theKey.Contains("8"))
{
return 8;
}
if (theKey.Contains("9"))
{
return 9;
}
if (theKey.Contains("Plus"))
{
return 72;
}
if (theKey.Contains("Equals"))
{
return 72;
}
if (theKey.Contains("Minus"))
{
return 61;
}
if (theKey.Contains("Caret"))
{
return 87;
}
if (theKey.Contains("Delete"))
{
return 30;
}
if (theKey.Contains("Comma"))
{
return 59;
}
if (theKey.Contains("Quest"))
{
return 76;
}
if (theKey.Contains("Period"))
{
return 60;
}
if (theKey.Contains("Semi"))
{
return 80;
}
if (theKey.Contains("Quote"))
{
return 77;
}
if (theKey.Contains("Left Shift"))
{
return 82;
}
if (theKey.Contains("Right Shift"))
{
return 82;
}
if (theKey.Contains("Left Control"))
{
return 28;
}
if (theKey.Contains("Right Control"))
{
return 28;
}
if (theKey.Contains("Left Meta"))
{
return 27;
}
if (theKey.Contains("Right Meta"))
{
return 27;
}
if (theKey.Contains("Left Apple"))
{
return 27;
}
if (theKey.Contains("Right Apple"))
{
return 27;
}
if (theKey.Contains("Left Option"))
{
return 14;
}
if (theKey.Contains("Right Option"))
{
return 14;
}
if (theKey.Contains("Caps"))
{
return 26;
}
if (theKey.Contains("Left Arrow"))
{
return 16;
}
if (theKey.Contains("Right Arrow"))
{
return 17;
}
if (theKey.Contains("Up Arrow"))
{
return 18;
}
if (theKey.Contains("Down Arrow"))
{
return 15;
}
if (theKey.Contains("Left Bracket"))
{
return 23;
}
if (theKey.Contains("Right Brack"))
{
return 24;
}
if (theKey.Contains("Backslash"))
{
return 83;
}
if (theKey.Contains("Escape"))
{
return 36;
}
if (theKey == "A")
{
return 13;
}
if (theKey == "B")
{
return 20;
}
if (theKey == "C")
{
return 25;
}
if (theKey == "D")
{
return 29;
}
if (theKey == "E")
{
return 31;
}
if (theKey == "F")
{
return 37;
}
if (theKey == "G")
{
return 50;
}
if (theKey == "H")
{
return 51;
}
if (theKey == "I")
{
return 53;
}
if (theKey == "J")
{
return 55;
}
if (theKey == "K")
{
return 56;
}
if (theKey == "L")
{
return 57;
}
if (theKey == "M")
{
return 58;
}
if (theKey == "N")
{
return 66;
}
if (theKey == "O")
{
return 68;
}
if (theKey == "P")
{
return 69;
}
if (theKey == "Q")
{
return 75;
}
if (theKey == "R")
{
return 78;
}
if (theKey == "S")
{
return 79;
}
if (theKey == "T")
{
return 85;
}
if (theKey == "U")
{
return 88;
}
if (theKey == "V")
{
return 89;
}
if (theKey == "W")
{
return 90;
}
if (theKey == "X")
{
return 92;
}
if (theKey == "Y")
{
return 93;
}
if (theKey == "Z")
{
return 94;
}
if (theKey == "Esc")
{
return 36;
}
if (theKey == "LMB")
{
return 62;
}
if (theKey == "LMBDouble")
{
return 65;
}
if (theKey == "RMB")
{
return 64;
}
if (theKey == "Space")
{
return 84;
}
if (theKey == "Tab")
{
return 86;
}
return num;
}
// Token: 0x06000DE3 RID: 3555 RVA: 0x00105FA7 File Offset: 0x001041A7
public void Setup()
{
if (ES3.FileExists("Keys.es3"))
{
this.DoLoad();
}
this.DoSave();
Links.x.pocketWheel.SetHotkeys(Links.x.mk);
}
// Token: 0x06000DE4 RID: 3556 RVA: 0x00105FDA File Offset: 0x001041DA
private void Start()
{
this.dragging = false;
this.hoverBox = null;
this.hoverObj = null;
this.EndDrag();
}
// Token: 0x06000DE5 RID: 3557 RVA: 0x00105FF7 File Offset: 0x001041F7
public void DoSave()
{
ES3.Save<List<string>>("Keys", this.keyStrings, "Keys.es3");
}
// Token: 0x06000DE6 RID: 3558 RVA: 0x00106010 File Offset: 0x00104210
public void SetNewKey(KeyDrag keyDrag, KeyDrop keyDrop)
{
int num = 0;
using (List<string>.Enumerator enumerator = this.keyFunction.GetEnumerator())
{
while (enumerator.MoveNext())
{
if (enumerator.Current == keyDrag.keyFunction)
{
this.keys[num] = this.ConvertToKeyCode(keyDrop.key);
this.keyStrings[num] = keyDrop.key;
}
num++;
}
}
this.DoSave();
}
// Token: 0x06000DE7 RID: 3559 RVA: 0x001060A0 File Offset: 0x001042A0
public void StartDrag()
{
for (int i = 0; i < this.allDrops.Count; i++)
{
this.allDrops[i].StartDrag();
}
}
// Token: 0x06000DE8 RID: 3560 RVA: 0x001060D4 File Offset: 0x001042D4
public void EndDrag()
{
for (int i = 0; i < this.allDrops.Count; i++)
{
this.allDrops[i].EndDrag();
}
if (Links.x.gaia.sceneLoaded)
{
this.DoSave();
Links.x.fellowship.UpdateHotkeys();
}
Links.x.pocketWheel.SetHotkeys(Links.x.mk);
}
// Token: 0x06000DE9 RID: 3561 RVA: 0x00106148 File Offset: 0x00104348
public KeyDrop GetMatchingDrop(string s)
{
for (int i = 0; i < this.allDrops.Count; i++)
{
if (this.allDrops[i].key == s)
{
return this.allDrops[i];
}
}
return null;
}
// Token: 0x06000DEA RID: 3562 RVA: 0x00106194 File Offset: 0x00104394
public bool KeyOn(KeyDrop keyDrop)
{
if (this.hoverObj && this.hoverObj.savedBox && this.hoverObj.savedBox == keyDrop)
{
return false;
}
for (int i = 0; i < this.keys.Count; i++)
{
if (this.allKeys[i] && this.keys[i] == keyDrop.keyCode)
{
return true;
}
}
return false;
}
// Token: 0x06000DEB RID: 3563 RVA: 0x00106218 File Offset: 0x00104418
public KeyCode ConvertToKeyCode(string s)
{
for (int i = 0; i < this.allDrops.Count; i++)
{
if (s == this.allDrops[i].key)
{
return this.allDrops[i].keyCode;
}
}
return KeyCode.None;
}
// Token: 0x06000DEC RID: 3564 RVA: 0x00106268 File Offset: 0x00104468
public void DoLoad()
{
List<string> list = ES3.Load<List<string>>("Keys", "Keys.es3");
if (list.Count != this.keyStrings.Count)
{
int count = list.Count;
for (int i = 0; i < this.keyStrings.Count; i++)
{
if (i >= count)
{
list.Add(this.keyStrings[i]);
}
}
for (int j = 0; j < list.Count; j++)
{
this.keyStrings[j] = list[j];
}
}
else
{
this.keyStrings = ES3.Load<List<string>>("Keys", "Keys.es3");
}
this.SetKeys();
Links.x.pocketWheel.SetHotkeys(Links.x.mk);
}
// Token: 0x06000DED RID: 3565 RVA: 0x00106328 File Offset: 0x00104528
public string FindOpenPartyKey()
{
if (this.everyKey.Count == 0)
{
this.everyKey.Add("Z");
this.everyKey.Add("X");
this.everyKey.Add("C");
this.everyKey.Add("V");
this.everyKey.Add("Alpha 5");
this.everyKey.Add("Alpha 6");
this.everyKey.Add("Alpha 7");
this.everyKey.Add("Alpha 8");
this.everyKey.Add("A");
this.everyKey.Add("S");
this.everyKey.Add("D");
this.everyKey.Add("F");
this.everyKey.Add("G");
this.everyKey.Add("H");
this.everyKey.Add("J");
this.everyKey.Add("K");
this.everyKey.Add("L");
this.everyKey.Add("B");
this.everyKey.Add("N");
this.everyKey.Add("M");
this.everyKey.Add("Q");
this.everyKey.Add("W");
this.everyKey.Add("E");
this.everyKey.Add("R");
this.everyKey.Add("T");
this.everyKey.Add("Y");
this.everyKey.Add("U");
this.everyKey.Add("I");
this.everyKey.Add("O");
this.everyKey.Add("P");
this.everyKey.Add("Alpha 9");
this.everyKey.Add("Alpha 0");
}
for (int i = 0; i < this.everyKey.Count; i++)
{
if (!this.keyStrings.Contains(this.everyKey[i]))
{
return this.everyKey[i];
}
}
return "None";
}
// Token: 0x06000DEE RID: 3566 RVA: 0x00106588 File Offset: 0x00104788
public string FindOpenAttackKey()
{
if (this.everyKey.Count == 0)
{
this.everyKey.Add("Left Control");
this.everyKey.Add("Left Option");
this.everyKey.Add("Space");
this.everyKey.Add("Z");
this.everyKey.Add("X");
this.everyKey.Add("C");
this.everyKey.Add("V");
this.everyKey.Add("Alpha 5");
this.everyKey.Add("Alpha 6");
this.everyKey.Add("Alpha 7");
this.everyKey.Add("Alpha 8");
this.everyKey.Add("A");
this.everyKey.Add("S");
this.everyKey.Add("D");
this.everyKey.Add("F");
this.everyKey.Add("G");
this.everyKey.Add("H");
this.everyKey.Add("J");
this.everyKey.Add("K");
this.everyKey.Add("L");
this.everyKey.Add("B");
this.everyKey.Add("N");
this.everyKey.Add("M");
this.everyKey.Add("Q");
this.everyKey.Add("W");
this.everyKey.Add("E");
this.everyKey.Add("R");
this.everyKey.Add("T");
this.everyKey.Add("Y");
this.everyKey.Add("U");
this.everyKey.Add("I");
this.everyKey.Add("O");
this.everyKey.Add("P");
this.everyKey.Add("Alpha 9");
this.everyKey.Add("Alpha 0");
}
for (int i = 0; i < this.everyKey.Count; i++)
{
if (!this.keyStrings.Contains(this.everyKey[i]))
{
return this.everyKey[i];
}
}
return "None";
}
// Token: 0x06000DEF RID: 3567 RVA: 0x00106818 File Offset: 0x00104A18
public void SetKeys()
{
bool flag = false;
for (int i = 0; i < this.allKeys.Count; i++)
{
if (this.allKeys[i])
{
if (this.allKeys[i].gameObject.name.Contains("Party") && this.keyStrings[i] == "None")
{
if (this.allKeys[i].gameObject.name == "Party 1")
{
string text = "Alpha 1";
if (this.keyStrings.Contains(text))
{
this.keyStrings[i] = this.FindOpenPartyKey();
}
else
{
this.keyStrings[i] = text;
}
}
if (this.allKeys[i].gameObject.name == "Party 2")
{
string text2 = "Alpha 2";
if (this.keyStrings.Contains(text2))
{
this.keyStrings[i] = this.FindOpenPartyKey();
}
else
{
this.keyStrings[i] = text2;
}
}
if (this.allKeys[i].gameObject.name == "Party 3")
{
string text3 = "Alpha 3";
if (this.keyStrings.Contains(text3))
{
this.keyStrings[i] = this.FindOpenPartyKey();
}
else
{
this.keyStrings[i] = text3;
}
}
if (this.allKeys[i].gameObject.name == "Party 4")
{
string text4 = "Alpha 4";
if (this.keyStrings.Contains(text4))
{
this.keyStrings[i] = this.FindOpenPartyKey();
}
else
{
this.keyStrings[i] = text4;
}
}
}
if (this.allKeys[i].gameObject.name.Contains("Commands") && this.keyStrings[i] == "None")
{
string text5 = "Left Shift";
if (this.keyStrings.Contains(text5))
{
text5 = "Left Control";
if (this.keyStrings.Contains(text5))
{
this.keyStrings[i] = this.FindOpenAttackKey();
}
}
else
{
this.keyStrings[i] = text5;
}
}
if (this.allKeys[i].gameObject.name.Contains("Attack") && this.keyStrings[i] == "None")
{
string text6 = "Z";
if (this.keyStrings.Contains(text6))
{
text6 = "Alpha 1";
if (this.keyStrings.Contains(text6))
{
this.keyStrings[i] = this.FindOpenAttackKey();
}
else
{
flag = true;
this.keyStrings[i] = text6;
}
}
else
{
this.keyStrings[i] = text6;
}
}
if (this.allKeys[i].gameObject.name.Contains("Pin") && this.keyStrings[i] == "None")
{
string text7 = "X";
if (flag)
{
text7 = "Alpha 2";
}
if (this.keyStrings.Contains(text7))
{
text7 = "Alpha 2";
if (flag)
{
text7 = "X";
}
if (this.keyStrings.Contains(text7))
{
this.keyStrings[i] = this.FindOpenAttackKey();
}
else
{
this.keyStrings[i] = text7;
}
}
else
{
this.keyStrings[i] = text7;
}
}
if (this.allKeys[i].gameObject.name.Contains("Charge") && this.keyStrings[i] == "None")
{
string text8 = "C";
if (flag)
{
text8 = "Alpha 3";
}
if (this.keyStrings.Contains(text8))
{
text8 = "Alpha 3";
if (flag)
{
text8 = "C";
}
if (this.keyStrings.Contains(text8))
{
this.keyStrings[i] = this.FindOpenAttackKey();
}
else
{
this.keyStrings[i] = text8;
}
}
else
{
this.keyStrings[i] = text8;
}
}
if (this.allKeys[i].gameObject.name.Contains("Rally") && this.keyStrings[i] == "None")
{
string text9 = "V";
if (flag)
{
text9 = "Alpha 4";
}
if (this.keyStrings.Contains(text9))
{
text9 = "Alpha 4";
if (flag)
{
text9 = "V";
}
if (this.keyStrings.Contains(text9))
{
this.keyStrings[i] = this.FindOpenAttackKey();
}
else
{
this.keyStrings[i] = text9;
}
}
else
{
this.keyStrings[i] = text9;
}
}
if (this.allKeys[i].gameObject.name.Contains("Spells") && this.keyStrings[i] == "None")
{
string text10 = "B";
if (flag)
{
text10 = "Alpha 5";
}
if (this.keyStrings.Contains(text10))
{
text10 = "Alpha 5";
if (flag)
{
text10 = "B";
}
if (this.keyStrings.Contains(text10))
{
this.keyStrings[i] = this.FindOpenAttackKey();
}
else
{
this.keyStrings[i] = text10;
}
}
else
{
this.keyStrings[i] = text10;
}
}
if (this.allKeys[i].gameObject.name.Contains("Sneak") && this.keyStrings[i] == "None")
{
string text11 = "F";
if (flag)
{
text11 = "Alpha 6";
}
Debug.Log(text11 + " " + this.keyStrings.Contains(text11).ToString());
if (this.keyStrings.Contains(text11))
{
text11 = "Alpha 6";
if (flag)
{
text11 = "F";
}
if (this.keyStrings.Contains(text11))
{
this.keyStrings[i] = this.FindOpenAttackKey();
}
else
{
this.keyStrings[i] = text11;
}
}
else
{
this.keyStrings[i] = text11;
}
}
if (this.allKeys[i].gameObject.name.Contains("Talk") && this.keyStrings[i] == "None")
{
string text12 = "G";
if (flag)
{
text12 = "Alpha 7";
}
if (this.keyStrings.Contains(text12))
{
text12 = "Alpha 7";
if (flag)
{
text12 = "G";
}
if (this.keyStrings.Contains(text12))
{
this.keyStrings[i] = this.FindOpenAttackKey();
}
else
{
this.keyStrings[i] = text12;
}
}
else
{
this.keyStrings[i] = text12;
}
}
if (this.allKeys[i].gameObject.name.Contains("Item1") && this.keyStrings[i] == "None")
{
string text13 = "H";
if (flag)
{
text13 = "Alpha 8";
}
if (this.keyStrings.Contains(text13))
{
text13 = "Alpha 8";
if (flag)
{
text13 = "H";
}
if (this.keyStrings.Contains(text13))
{
this.keyStrings[i] = this.FindOpenAttackKey();
}
else
{
this.keyStrings[i] = text13;
}
}
else
{
this.keyStrings[i] = text13;
}
}
if (this.allKeys[i].gameObject.name.Contains("Item2") && this.keyStrings[i] == "None")
{
string text14 = "J";
if (flag)
{
text14 = "Alpha 9";
}
if (this.keyStrings.Contains(text14))
{
text14 = "Alpha 9";
if (flag)
{
text14 = "J";
}
if (this.keyStrings.Contains(text14))
{
this.keyStrings[i] = this.FindOpenAttackKey();
}
else
{
this.keyStrings[i] = text14;
}
}
else
{
this.keyStrings[i] = text14;
}
}
if (this.allKeys[i].gameObject.name.Contains("Item3") && this.keyStrings[i] == "None")
{
string text15 = "K";
if (flag)
{
text15 = "Alpha 0";
}
if (this.keyStrings.Contains(text15))
{
text15 = "Alpha 0";
if (flag)
{
text15 = "K";
}
if (this.keyStrings.Contains(text15))
{
this.keyStrings[i] = this.FindOpenAttackKey();
}
else
{
this.keyStrings[i] = text15;
}
}
else
{
this.keyStrings[i] = text15;
}
}
if (this.allKeys[i].gameObject.name.Contains("HUD") && this.keyStrings[i] == "None")
{
string text16 = "Left Option";
if (this.keyStrings.Contains(text16))
{
text16 = "Left Command";
if (this.keyStrings.Contains(text16))
{
text16 = "Left Control";
if (this.keyStrings.Contains(text16))
{
this.keyStrings[i] = this.FindOpenAttackKey();
}
else
{
this.keyStrings[i] = text16;
}
}
else
{
this.keyStrings[i] = text16;
}
}
else
{
this.keyStrings[i] = text16;
}
}
}
this.keys[i] = this.ConvertToKeyCode(this.keyStrings[i]);
this.hoverBox = this.GetMatchingDrop(this.keyStrings[i]);
if (this.hoverBox && this.allKeys[i])
{
this.allKeys[i].SetSavedBox(this.hoverBox);
}
}
}
// Token: 0x04001665 RID: 5733
public KeyDrag dragKey;
// Token: 0x04001666 RID: 5734
public bool dragging;
// Token: 0x04001667 RID: 5735
public List<string> keyFunction = new List<string>();
// Token: 0x04001668 RID: 5736
public List<KeyCode> keys = new List<KeyCode>();
// Token: 0x04001669 RID: 5737
public List<string> keyStrings = new List<string>();
// Token: 0x0400166A RID: 5738
public List<KeyDrag> allKeys = new List<KeyDrag>();
// Token: 0x0400166B RID: 5739
public List<KeyDrop> allDrops = new List<KeyDrop>();
// Token: 0x0400166C RID: 5740
private ES3File es3File;
// Token: 0x0400166D RID: 5741
public bool canDrop;
// Token: 0x0400166E RID: 5742
public KeyDrop hoverBox;
// Token: 0x0400166F RID: 5743
public KeyDrag hoverObj;
// Token: 0x04001670 RID: 5744
public List<string> everyKey = new List<string>();
}