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

403 lines
10 KiB
C#

using System;
using System.Collections;
using System.Reflection;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
// Token: 0x020000BD RID: 189
public class KeyboardScript : MonoBehaviour
{
// Token: 0x060011F3 RID: 4595 RVA: 0x0015F1B8 File Offset: 0x0015D3B8
public void StartMenu(TMP_InputField field, InputField field2, GameObject scriptObject, string type)
{
this.textField = field;
this.textField2 = field2;
this.canvasGroup.alpha = 1f;
this.fieldType = type;
this.scriptHolder = scriptObject;
base.gameObject.SetActive(true);
this.controllerText.spriteAsset = Links.x.GetSpriteSheetAsset(Links.x.gameplay.currentSpriteSheetAsset);
if (type.Contains("Journal"))
{
this.controllerText.text = Links.x.gameplay.keyboardText;
}
else if (type.Contains("Save") || type.Contains("QuickNote") || type.Contains("Spellcrafting") || type.Contains("Map"))
{
this.controllerText.text = Links.x.gameplay.keyboardText2;
}
else if (type.Contains("Creation"))
{
this.controllerText.text = Links.x.gameplay.keyboardText2;
}
else if (type.Contains("Shout"))
{
this.controllerText.text = Links.x.gameplay.keyboardText3;
}
else
{
this.controllerText.text = Links.x.gameplay.keyboardText;
}
if (!this.rt)
{
this.rt = base.gameObject.GetComponent<RectTransform>();
}
Links.x.gameplay.SetInteractableSelected(EventSystem.current, this.selectFirst);
if (type.Contains("Journal") || type.Contains("Save"))
{
if (!this.journal)
{
this.journal = Links.x.journal;
}
this.rt.anchoredPosition3D = this.journal.gameObject.transform.GetChild(2).GetChild(0).gameObject.GetComponent<RectTransform>().anchoredPosition3D;
}
else if (type == "Creation")
{
base.gameObject.transform.position = Links.x.creation.gameObject.transform.GetChild(0).GetChild(0).position;
}
else
{
this.rt.anchoredPosition3D = new Vector3(0f, 0f, 0f);
}
if (field)
{
field.caretPosition = 0;
field.GetType().GetField("m_AllowInput", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(field, true);
if (field.gameObject.activeInHierarchy)
{
field.GetType().InvokeMember("SetCaretVisible", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, field, null);
}
}
else
{
field2.caretPosition = 0;
field2.GetType().GetField("m_AllowInput", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(field2, true);
field2.GetType().InvokeMember("SetCaretVisible", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, field2, null);
}
this.EngLayoutBig.SetActive(true);
this.EngLayoutSml.SetActive(false);
this.SymbLayout.SetActive(false);
}
// Token: 0x060011F4 RID: 4596 RVA: 0x0015F4D8 File Offset: 0x0015D6D8
public void alphabetFunction(string alphabet)
{
int num;
if (this.textField)
{
this.textField.text = this.textField.text + alphabet;
num = this.textField.text.Length;
}
else
{
this.textField2.text = this.textField2.text + alphabet;
num = this.textField2.text.Length;
}
if (num == 1 && this.EngLayoutBig.activeSelf)
{
GameObject currentSelectedGameObject = EventSystem.current.currentSelectedGameObject;
int num2 = -1;
int num3 = 0;
using (IEnumerator enumerator = this.EngLayoutBig.transform.GetEnumerator())
{
while (enumerator.MoveNext())
{
if (((Transform)enumerator.Current).gameObject == currentSelectedGameObject)
{
num2 = num3;
}
num3++;
}
}
if (num2 > -1)
{
num3 = 0;
this.EngLayoutSml.SetActive(true);
foreach (object obj in this.EngLayoutSml.transform)
{
Transform transform = (Transform)obj;
if (num3 == num2)
{
Links.x.gameplay.SetInteractableSelected(EventSystem.current, transform.gameObject);
}
num3++;
}
this.EngLayoutBig.SetActive(false);
}
}
}
// Token: 0x060011F5 RID: 4597 RVA: 0x0015F668 File Offset: 0x0015D868
public void BackSpace()
{
int num;
if (this.textField)
{
num = this.textField.text.Length;
}
else
{
num = this.textField2.text.Length;
}
if (num > 0)
{
if (this.textField)
{
this.textField.text = this.textField.text.Remove(this.textField.text.Length - 1);
return;
}
this.textField2.text = this.textField2.text.Remove(this.textField2.text.Length - 1);
}
}
// Token: 0x060011F6 RID: 4598 RVA: 0x0015F714 File Offset: 0x0015D914
public void Confirm()
{
if (this.fieldType == "Shout")
{
this.scriptHolder.GetComponent<TextParser>().Parse();
}
if (this.fieldType == "Save")
{
this.scriptHolder.GetComponent<SaveLoad>().OverwriteSave();
}
this.CloseAllLayouts(true);
}
// Token: 0x060011F7 RID: 4599 RVA: 0x0015F76C File Offset: 0x0015D96C
public bool IsKey(GameObject obj)
{
Transform parent = Links.x.gameplay.currentEventObject.transform.parent;
return parent == this.EngLayoutSml.transform || parent == this.EngLayoutBig.transform || parent == this.SymbLayout.transform;
}
// Token: 0x060011F8 RID: 4600 RVA: 0x0015F7D0 File Offset: 0x0015D9D0
private void Update()
{
if (this.canvasGroup.alpha > 0f)
{
bool flag = false;
if (!Links.x.gameplay.currentEventObject)
{
flag = true;
}
else if (Links.x.gameplay.currentEventObject.transform.parent)
{
Transform parent = Links.x.gameplay.currentEventObject.transform.parent;
if (!(parent == this.EngLayoutSml.transform) && !(parent == this.EngLayoutBig.transform) && !(parent == this.SymbLayout.transform))
{
flag = true;
}
}
else
{
flag = true;
}
if (flag)
{
if (this.EngLayoutSml.activeSelf)
{
EventSystem.current.SetSelectedGameObject(this.capsBig);
}
if (this.EngLayoutBig.activeSelf)
{
EventSystem.current.SetSelectedGameObject(this.selectFirst);
}
if (this.SymbLayout.activeSelf)
{
EventSystem.current.SetSelectedGameObject(this.abc);
}
}
}
if (Links.x.gameplay.cancelStart)
{
if (this.fieldType == "Shout")
{
this.CloseAllLayouts(false);
}
else if (this.fieldType == "Save")
{
this.CloseAllLayouts(true);
}
else
{
this.Confirm();
}
}
if (this.textField)
{
if (this.textField.text.Length > 0)
{
this.textField.caretPosition = this.textField.text.Length;
}
}
else if (this.textField2 && this.textField2.text.Length > 0)
{
this.textField2.caretPosition = this.textField2.text.Length;
}
if (Links.x.gameplay.interactStart && this.fieldType != "Creation" && this.fieldType != "Save" && this.fieldType != "QuickNote" && this.fieldType != "Spellcrafting" && this.fieldType != "Map" && this.fieldType != "Shout")
{
this.Confirm();
}
if (Links.x.gameplay.allMenusStart && this.fieldType == "Shout")
{
this.Confirm();
}
}
// Token: 0x060011F9 RID: 4601 RVA: 0x0015FA54 File Offset: 0x0015DC54
public void CloseAllLayouts(bool success)
{
if (this.textField)
{
this.textField.DeactivateInputField(false);
}
else
{
this.textField2.DeactivateInputField();
}
this.canvasGroup.alpha = 0f;
if (this.fieldType == "Shout")
{
Debug.Log("Shout");
this.scriptHolder.GetComponent<TextParser>().EndMenuStart();
Links.x.gameplay.endDockNavigation = true;
}
if (this.fieldType == "Map")
{
this.scriptHolder.GetComponent<SceneMap>().ClosePinEditBox();
}
if (this.fieldType == "JournalInput")
{
this.journal.EndTypingField();
}
if (this.fieldType == "QuickNote")
{
Dialogue dialogue = Links.x.dialogue;
dialogue.EndJournalNote();
dialogue.ToggleQuickNote();
}
if (this.fieldType == "Spellcrafting")
{
Links.x.spellcrafting.EndTypingName();
}
if (this.fieldType == "Save")
{
SaveLoad component = this.scriptHolder.GetComponent<SaveLoad>();
if (!success)
{
component.CloseConfirm();
}
else
{
component.ReturnFromKeyboard();
}
}
if (this.fieldType == "Creation")
{
Links.x.creation.CloseKeyboard();
}
this.fieldType == "Load";
bool flag = true;
if (this.fieldType == "JournalLabel")
{
this.journal.EndTypingLabel();
flag = false;
}
if (flag)
{
base.gameObject.SetActive(false);
}
}
// Token: 0x060011FA RID: 4602 RVA: 0x0015FBEB File Offset: 0x0015DDEB
public void ToBigCaps()
{
this.EngLayoutSml.SetActive(false);
this.EngLayoutBig.SetActive(true);
this.SymbLayout.SetActive(false);
EventSystem.current.SetSelectedGameObject(this.capsBig);
}
// Token: 0x060011FB RID: 4603 RVA: 0x0015FC21 File Offset: 0x0015DE21
public void ToSmallCaps()
{
this.EngLayoutSml.SetActive(true);
this.EngLayoutBig.SetActive(false);
this.SymbLayout.SetActive(false);
EventSystem.current.SetSelectedGameObject(this.capsSml);
}
// Token: 0x060011FC RID: 4604 RVA: 0x0015FC57 File Offset: 0x0015DE57
public void ToSymb()
{
this.EngLayoutSml.SetActive(false);
this.EngLayoutBig.SetActive(false);
this.SymbLayout.SetActive(true);
EventSystem.current.SetSelectedGameObject(this.abc);
}
// Token: 0x060011FD RID: 4605 RVA: 0x0015FC8D File Offset: 0x0015DE8D
public void ToABC()
{
this.EngLayoutSml.SetActive(false);
this.EngLayoutBig.SetActive(true);
this.SymbLayout.SetActive(false);
EventSystem.current.SetSelectedGameObject(this.symbLarge);
}
// Token: 0x060011FE RID: 4606 RVA: 0x0015FCC3 File Offset: 0x0015DEC3
public void ShowLayout(GameObject SetLayout)
{
}
// Token: 0x04001DAA RID: 7594
public TMP_InputField textField;
// Token: 0x04001DAB RID: 7595
public InputField textField2;
// Token: 0x04001DAC RID: 7596
public GameObject EngLayoutSml;
// Token: 0x04001DAD RID: 7597
public GameObject EngLayoutBig;
// Token: 0x04001DAE RID: 7598
public GameObject SymbLayout;
// Token: 0x04001DAF RID: 7599
public CanvasGroup canvasGroup;
// Token: 0x04001DB0 RID: 7600
public GameObject scriptHolder;
// Token: 0x04001DB1 RID: 7601
public GameObject selectFirst;
// Token: 0x04001DB2 RID: 7602
public GameObject capsSml;
// Token: 0x04001DB3 RID: 7603
public GameObject capsBig;
// Token: 0x04001DB4 RID: 7604
public GameObject symbLarge;
// Token: 0x04001DB5 RID: 7605
public GameObject abc;
// Token: 0x04001DB6 RID: 7606
public string fieldType;
// Token: 0x04001DB7 RID: 7607
public TextMeshProUGUI controllerText;
// Token: 0x04001DB8 RID: 7608
private RectTransform rt;
// Token: 0x04001DB9 RID: 7609
private Journal journal;
}