diff --git a/BetterEmote/AssetScripts/CustomAnimationObjects.cs b/BetterEmote/AssetScripts/CustomAnimationObjects.cs index 525e2c0..5cfb8c7 100644 --- a/BetterEmote/AssetScripts/CustomAnimationObjects.cs +++ b/BetterEmote/AssetScripts/CustomAnimationObjects.cs @@ -1,6 +1,7 @@ using BetterEmote.Patches; using BetterEmote.Utils; using GameNetcodeStuff; +using System; using UnityEngine; namespace BetterEmote.AssetScripts @@ -88,14 +89,33 @@ private void DisableEverything() private void FindSign() { Plugin.Debug("FindSign()"); - _sign = _player.transform.Find("ScavengerModel").Find("metarig").Find("Sign").GetComponent(); - _signText = _sign.transform.Find("Text").gameObject; + if (_sign == null && _player != null) + { + Plugin.Debug("Sign is null and player exists"); + _sign = _player.transform.Find("ScavengerModel").Find("metarig").Find("Sign").GetComponent(); + } + if (_signText == null && _sign != null) + { + Plugin.Debug("Sign text is null and sign exists"); + _signText = _sign.transform.Find("Text").gameObject; + } } private void FindLegs() { Plugin.Debug("FindLegs()"); - _legs = _player.transform.Find("ScavengerModel").Find("LEGS").GetComponent(); + if (_legs == null && _player != null) + { + Plugin.Debug("Legs are null and player exists"); + try + { + _legs = _player.transform.Find("ScavengerModel").Find("LEGS").GetComponent(); + } + catch (Exception e) + { + Plugin.StaticLogger.LogWarning("Unable to find custom legs, this should be corrected soon."); + } + } } } } diff --git a/BetterEmote/AssetScripts/EmoteWheel.cs b/BetterEmote/AssetScripts/EmoteWheel.cs index 8d12590..f6179f6 100644 --- a/BetterEmote/AssetScripts/EmoteWheel.cs +++ b/BetterEmote/AssetScripts/EmoteWheel.cs @@ -38,7 +38,7 @@ internal class EmoteWheel : MonoBehaviour public Vector2 controllerValue = Vector2.zero; public static string[] emoteNames; - public static string[] emoteKeybinds; + public static InputBind[] emoteKeybinds; private Vector2 centerScreen; @@ -60,10 +60,10 @@ private void Awake() private void OnEnable() { Plugin.Debug("EmoteWheel.OnEnable()"); - emoteKeybinds = new string[EmoteDefs.getEmoteCount() + 1]; + emoteKeybinds = new InputBind[EmoteDefs.getEmoteCount() + 1]; foreach (string name in Enum.GetNames(typeof(Emote))) { - emoteKeybinds[EmoteDefs.getEmoteNumber(name) - 1] = Settings.keybinds.getByEmote(EmoteDefs.getEmote(name)).GetBindingDisplayString(0, 0); + emoteKeybinds[EmoteDefs.getEmoteNumber(name) - 1] = Keybinds.getDisplayStrings(Settings.keybinds.getByEmote(EmoteDefs.getEmote(name))); } centerScreen = new Vector2(Screen.width / 2, Screen.height / 2); Cursor.visible = true; @@ -254,7 +254,7 @@ private void updatePageInfo() private void displayEmoteInfo() { Plugin.Trace($"EmoteWheel.displayEmoteInfo({selectedEmoteID})"); - string text = selectedEmoteID > emoteKeybinds.Length ? "" : emoteKeybinds[selectedEmoteID - 1]; + InputBind bind = selectedEmoteID > emoteKeybinds.Length ? new InputBind("", "") : emoteKeybinds[selectedEmoteID - 1]; string text2; if (selectedEmoteID <= Enum.GetValues(typeof(Emote)).Length) { @@ -267,7 +267,7 @@ private void displayEmoteInfo() Plugin.Trace("selectedEmoteID out of range of emotes"); text2 = "EMPTY"; } - emoteInformation.text = $"{text2 ?? ""}\n[{(text ?? "").ToUpper()}]"; + emoteInformation.text = $"{text2 ?? ""}\n{Keybinds.formatInputBind(bind)}"; } private void updateSelectionArrow() { diff --git a/BetterEmote/AssetScripts/SignUI.cs b/BetterEmote/AssetScripts/SignUI.cs index 4866c32..9e99595 100644 --- a/BetterEmote/AssetScripts/SignUI.cs +++ b/BetterEmote/AssetScripts/SignUI.cs @@ -16,6 +16,8 @@ public class SignUI : MonoBehaviour private TMP_InputField _inputField; private Text _charactersLeftText; + private Text _submitText; + private Text _cancelText; private TMP_Text _previewText; @@ -49,9 +51,19 @@ private void OnEnable() _inputField.Select(); _inputField.text = string.Empty; _previewText.text = "PREVIEW"; + updateKeybindText(); Player.disableLookInput = true; } + public void updateKeybindText() + { + Plugin.Debug("SignUI.updateKeybindText()"); + InputBind submit = Keybinds.getDisplayStrings(Settings.keybinds.SignSubmit); + InputBind cancel = Keybinds.getDisplayStrings(Settings.keybinds.SignCancel); + _submitText.text = $"{Keybinds.formatInputBind(submit)} Submit"; + _cancelText.text = $"{Keybinds.formatInputBind(cancel)} Cancel"; + } + private void Update() { Plugin.Trace("SignUI.Update()"); @@ -62,30 +74,11 @@ private void Update() Plugin.Debug("SignUI Player isnt performing emote"); Close(true); } - if (Keyboard.current[Key.Enter].wasPressedThisFrame && !Keyboard.current[Key.LeftShift].isPressed) - { - Plugin.Debug("Enter was pressed without shift"); - SubmitText(); - } - if (Player.quickMenuManager.isMenuOpen || EmoteKeybindPatch.emoteWheelIsOpened || Mouse.current["rightButton"].IsPressed(0f)) + if (Player.quickMenuManager.isMenuOpen || EmoteKeybindPatch.emoteWheelIsOpened) { Plugin.Debug("Menu is open or right mouse button is clicked"); Close(true); } - if (Gamepad.all.Count != 0) - { - Plugin.Trace("Has gamepad"); - if (Gamepad.current.buttonWest.isPressed || Gamepad.current.startButton.isPressed) - { - Plugin.Debug("Button west or start button pressed"); - SubmitText(); - } - if (Gamepad.current.buttonEast.isPressed || Gamepad.current.selectButton.isPressed) - { - Plugin.Debug("Button east or select button pressed"); - Close(true); - } - } } private void FindComponents() @@ -96,6 +89,8 @@ private void FindComponents() _submitButton = transform.Find("Submit").GetComponent