| using System; |
| using System; |
| using TMPro; |
| using TMPro; |
| using UnityEngine; |
| using UnityEngine; |
| |
| |
| public class Console : Terminal |
| public class Console : Terminal |
| { |
| { |
| public static global::Console instance |
| public static global::Console instance |
| { |
| { |
| get |
| get |
| { |
| { |
| return global::Console.m_instance; |
| return global::Console.m_instance; |
| } |
| } |
| } |
| } |
| |
| |
| public override void Awake() |
| public override void Awake() |
| { |
| { |
| base.LoadQuickSelect(); |
| base.LoadQuickSelect(); |
| base.Awake(); |
| base.Awake(); |
| global::Console.m_instance = this; |
| global::Console.m_instance = this; |
| base.AddString(string.Concat(new string[] |
| base.AddString(string.Concat(new string[] |
| { |
| { |
| "Valheim ", |
| "Valheim ", |
| global::Version.GetVersionString(false), |
| global::Version.GetVersionString(false), |
| " (network version ", |
| " (network version ", |
| . | 23U.ToString(), |
| 27U.ToString(), |
| ")" |
| ")" |
| })); |
| })); |
| base.AddString(""); |
| base.AddString(""); |
| base.AddString("type \"help\" - for commands"); |
| base.AddString("type \"help\" - for commands"); |
| base.AddString(""); |
| base.AddString(""); |
| this.m_chatWindow.gameObject.SetActive(false); |
| this.m_chatWindow.gameObject.SetActive(false); |
| } |
| } |
| |
| |
| public override void Update() |
| public override void Update() |
| { |
| { |
| this.m_focused = false; |
| this.m_focused = false; |
| if (ZNet.instance && ZNet.instance.InPasswordDialog()) |
| if (ZNet.instance && ZNet.instance.InPasswordDialog()) |
| { |
| { |
| this.m_chatWindow.gameObject.SetActive(false); |
| this.m_chatWindow.gameObject.SetActive(false); |
| return; |
| return; |
| } |
| } |
| if (!this.IsConsoleEnabled()) |
| if (!this.IsConsoleEnabled()) |
| { |
| { |
| return; |
| return; |
| } |
| } |
| if (ZInput.GetButtonDown("Console") || (global::Console.IsVisible() && ZInput.GetKeyDown(KeyCode.Escape, true)) || (global::Console.IsVisible() && ZInput.GetButtonDown("JoyButtonB")) || (ZInput.GetButton("JoyLTrigger") && ZInput.GetButton("JoyLBumper") && ZInput.GetButtonDown("JoyStart"))) |
| if (ZInput.GetButtonDown("Console") || (global::Console.IsVisible() && ZInput.GetKeyDown(KeyCode.Escape, true)) || (global::Console.IsVisible() && ZInput.GetButtonDown("JoyButtonB")) || (ZInput.GetButton("JoyLTrigger") && ZInput.GetButton("JoyLBumper") && ZInput.GetButtonDown("JoyStart"))) |
| { |
| { |
| this.m_chatWindow.gameObject.SetActive(!this.m_chatWindow.gameObject.activeSelf); |
| this.m_chatWindow.gameObject.SetActive(!this.m_chatWindow.gameObject.activeSelf); |
| if (ZInput.IsGamepadActive()) |
| if (ZInput.IsGamepadActive()) |
| { |
| { |
| base.AddString("Gamepad console controls:\n A: Enter text when empty (only in big picture mode), or send text when not.\n LB: Erase.\n DPad up/down: Cycle history.\n DPad right: Autocomplete.\n DPad left: Show commands (help).\n Left Stick: Scroll.\n RStick + LStick: show/hide console.\n X+DPad: Save quick select option.\n Y+DPad: Load quick select option."); |
| base.AddString("Gamepad console controls:\n A: Enter text when empty (only in big picture mode), or send text when not.\n LB: Erase.\n DPad up/down: Cycle history.\n DPad right: Autocomplete.\n DPad left: Show commands (help).\n Left Stick: Scroll.\n RStick + LStick: show/hide console.\n X+DPad: Save quick select option.\n Y+DPad: Load quick select option."); |
| } |
| } |
| if (this.m_chatWindow.gameObject.activeInHierarchy) |
| if (this.m_chatWindow.gameObject.activeInHierarchy) |
| { |
| { |
| this.m_input.ActivateInputField(); |
| this.m_input.ActivateInputField(); |
| } |
| } |
| } |
| } |
| if (this.m_chatWindow.gameObject.activeInHierarchy) |
| if (this.m_chatWindow.gameObject.activeInHierarchy) |
| { |
| { |
| this.m_focused = true; |
| this.m_focused = true; |
| } |
| } |
| if (this.m_focused) |
| if (this.m_focused) |
| { |
| { |
| if (ZInput.GetButtonDown("JoyTabLeft") && this.m_input.text.Length > 0) |
| if (ZInput.GetButtonDown("JoyTabLeft") && this.m_input.text.Length > 0) |
| { |
| { |
| this.m_input.text = this.m_input.text.Substring(0, this.m_input.text.Length - 1); |
| this.m_input.text = this.m_input.text.Substring(0, this.m_input.text.Length - 1); |
| } |
| } |
| else if (ZInput.GetButtonDown("JoyDPadLeft")) |
| else if (ZInput.GetButtonDown("JoyDPadLeft")) |
| { |
| { |
| base.TryRunCommand("help", false, false); |
| base.TryRunCommand("help", false, false); |
| } |
| } |
| } |
| } |
| string text; |
| string text; |
| if (global::Console.instance && Terminal.m_threadSafeConsoleLog.TryDequeue(out text)) |
| if (global::Console.instance && Terminal.m_threadSafeConsoleLog.TryDequeue(out text)) |
| { |
| { |
| global::Console.instance.AddString(text); |
| global::Console.instance.AddString(text); |
| } |
| } |
| string text2; |
| string text2; |
| if (Player.m_localPlayer && Terminal.m_threadSafeMessages.TryDequeue(out text2)) |
| if (Player.m_localPlayer && Terminal.m_threadSafeMessages.TryDequeue(out text2)) |
| { |
| { |
| Player.m_localPlayer.Message(MessageHud.MessageType.TopLeft, text2, 0, null); |
| Player.m_localPlayer.Message(MessageHud.MessageType.TopLeft, text2, 0, null); |
| } |
| } |
| base.Update(); |
| base.Update(); |
| if (ZInput.GetButtonDown("JoyDPadLeft") && !ZInput.GetButton("JoyButtonX") && !ZInput.GetButton("JoyButtonY")) |
| if (ZInput.GetButtonDown("JoyDPadLeft") && !ZInput.GetButton("JoyButtonX") && !ZInput.GetButton("JoyButtonY")) |
| { |
| { |
| base.TryRunCommand("help", false, false); |
| base.TryRunCommand("help", false, false); |
| } |
| } |
| } |
| } |
| |
| |
| public static bool IsVisible() |
| public static bool IsVisible() |
| { |
| { |
| return global::Console.m_instance && global::Console.m_instance.m_chatWindow.gameObject.activeInHierarchy; |
| return global::Console.m_instance && global::Console.m_instance.m_chatWindow.gameObject.activeInHierarchy; |
| } |
| } |
| |
| |
| public void Print(string text) |
| public void Print(string text) |
| { |
| { |
| base.AddString(text); |
| base.AddString(text); |
| } |
| } |
| |
| |
| public bool IsConsoleEnabled() |
| public bool IsConsoleEnabled() |
| { |
| { |
| return global::Console.m_consoleEnabled; |
| return global::Console.m_consoleEnabled; |
| } |
| } |
| |
| |
| public static void SetConsoleEnabled(bool enabled) |
| public static void SetConsoleEnabled(bool enabled) |
| { |
| { |
| global::Console.m_consoleEnabled = enabled; |
| global::Console.m_consoleEnabled = enabled; |
| } |
| } |
| |
| |
| protected override Terminal m_terminalInstance |
| protected override Terminal m_terminalInstance |
| { |
| { |
| get |
| get |
| { |
| { |
| return global::Console.m_instance; |
| return global::Console.m_instance; |
| } |
| } |
| } |
| } |
| |
| |
| private static global::Console m_instance; |
| private static global::Console m_instance; |
| |
| |
| private static bool m_consoleEnabled; |
| private static bool m_consoleEnabled; |
| |
| |
| public TMP_Text m_devTest; |
| public TMP_Text m_devTest; |
| } |
| } |
| |
| |