Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ GetInputText()

static string Terraria.Main.GetInputText ( string oldString,
bool allowMultiLine = false )
inlinestatic

Definition at line 18593 of file Main.cs.

18594 {
18595 if (dedServ)
18596 {
18597 return "";
18598 }
18599 if (!hasFocus)
18600 {
18601 return oldString;
18602 }
18603 inputTextEnter = false;
18604 inputTextEscape = false;
18605 string text = oldString;
18606 string text2 = "";
18607 if (text == null)
18608 {
18609 text = "";
18610 }
18611 bool flag = false;
18612 if (inputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftControl) || inputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.RightControl))
18613 {
18614 if (inputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Z) && !oldInputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Z))
18615 {
18616 text = "";
18617 }
18618 else if (inputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.X) && !oldInputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.X))
18619 {
18620 Platform.Get<IClipboard>().Value = oldString;
18621 text = "";
18622 }
18623 else if ((inputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.C) && !oldInputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.C)) || (inputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Insert) && !oldInputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Insert)))
18624 {
18625 Platform.Get<IClipboard>().Value = oldString;
18626 }
18627 else if (inputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.V) && !oldInputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.V))
18628 {
18630 }
18631 }
18632 else
18633 {
18634 if (inputText.PressingShift())
18635 {
18636 if (inputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Delete) && !oldInputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Delete))
18637 {
18638 Platform.Get<IClipboard>().Value = oldString;
18639 text = "";
18640 }
18641 if (inputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Insert) && !oldInputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Insert))
18642 {
18644 }
18645 }
18646 for (int i = 0; i < keyCount; i++)
18647 {
18648 int num = keyInt[i];
18649 string text3 = keyString[i];
18650 if (num == 13)
18651 {
18652 inputTextEnter = true;
18653 }
18654 else if (num == 27)
18655 {
18656 inputTextEscape = true;
18657 }
18658 else if (num >= 32 && num != 127)
18659 {
18660 text2 += text3;
18661 }
18662 }
18663 }
18664 keyCount = 0;
18665 text += text2;
18667 inputText = Keyboard.GetState();
18668 Microsoft.Xna.Framework.Input.Keys[] pressedKeys = inputText.GetPressedKeys();
18669 Microsoft.Xna.Framework.Input.Keys[] pressedKeys2 = oldInputText.GetPressedKeys();
18670 if (inputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Back) && oldInputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Back))
18671 {
18672 backSpaceRate -= 0.05f;
18673 if (backSpaceRate < 0f)
18674 {
18675 backSpaceRate = 0f;
18676 }
18677 if (backSpaceCount <= 0)
18678 {
18680 flag = true;
18681 }
18683 }
18684 else
18685 {
18686 backSpaceRate = 7f;
18687 backSpaceCount = 15;
18688 }
18689 for (int j = 0; j < pressedKeys.Length; j++)
18690 {
18691 bool flag2 = true;
18692 for (int k = 0; k < pressedKeys2.Length; k++)
18693 {
18694 if (pressedKeys[j] == pressedKeys2[k])
18695 {
18696 flag2 = false;
18697 }
18698 }
18699 if (string.Concat(pressedKeys[j]) == "Back" && (flag2 || flag) && text.Length > 0)
18700 {
18702 text = ((!array[array.Length - 1].DeleteWhole) ? text.Substring(0, text.Length - 1) : text.Substring(0, text.Length - array[array.Length - 1].TextOriginal.Length));
18703 }
18704 }
18705 return text;
18706 }
static decimal Round(decimal d)
Definition Math.cs:1096
static int keyCount
Definition Main.cs:708
static string PasteTextIn(bool allowMultiLine, string newKeys)
Definition Main.cs:18708
static bool inputTextEscape
Definition Main.cs:1747
static KeyboardState inputText
Definition Main.cs:1960
static bool hasFocus
Definition Main.cs:1781
static bool dedServ
Definition Main.cs:1226
static int backSpaceCount
Definition Main.cs:1912
static KeyboardState oldInputText
Definition Main.cs:1962
static int[] keyInt
Definition Main.cs:712
static float backSpaceRate
Definition Main.cs:1914
static string[] keyString
Definition Main.cs:710
static bool inputTextEnter
Definition Main.cs:1745
static List< TextSnippet > ParseMessage(string text, Color baseColor)

References System.array, Terraria.Main.backSpaceCount, Terraria.Main.backSpaceRate, Terraria.Main.dedServ, Terraria.Main.hasFocus, System.Text.RegularExpressions.i, Terraria.Main.inputText, Terraria.Main.inputTextEnter, Terraria.Main.inputTextEscape, ReLogic.Peripherals.RGB.Keyboard, Terraria.Main.keyCount, Terraria.Main.keyInt, Terraria.Main.keyString, Terraria.Main.oldInputText, Terraria.UI.Chat.ChatManager.ParseMessage(), Terraria.Main.PasteTextIn(), System.Math.Round(), System.text, and Microsoft.Xna.Framework.Color.White.

Referenced by Terraria.Main.DoUpdate_HandleChat(), Terraria.Main.DrawMenu(), Terraria.GameContent.UI.Elements.UISearchBar.DrawSelf(), Terraria.GameContent.UI.States.UIVirtualKeyboard.DrawSelf(), Terraria.Main.InputTextChest(), Terraria.Main.InputTextSign(), Terraria.Social.WeGame.NetClientSocialModule.OnAuthSuccess(), Terraria.Social.Steam.NetClientSocialModule.OnLobbyEntered(), and Terraria.GameContent.UI.Elements.UIWorldListItem.PlayGame().