private string GetKeyText(InputActionData data) { if (data == null) { return(string.Empty); } return(KeyCodeToString.GetString(data.m_KeyCode)); }
private void OnKeyPressed(KeyCode key) { this.m_KeyCode = key; this.m_Text.text = KeyCodeToString.GetString(key); this.m_State = UIKeyBindButton.UIKeyBindButtonState.Focused; this.m_BindingChanged = true; this.m_Screen.OnBindingChanged(this); this.UpdateImage(); }
public bool SetupKeyCode(KeyCode key) { bool result = this.m_KeyCode != key; this.m_KeyCode = key; this.m_Text.text = KeyCodeToString.GetString(key); this.m_BindingChanged = false; this.UpdateImage(); return(result); }
private void Setup() { this.m_PosY = this.m_Dummy.transform.localPosition.y; this.m_MaxBGWidth = 0f; int num = 0; foreach (DialogNode dialogNode in this.m_Nodes) { if (!dialogNode.m_Additional) { this.AddNode(dialogNode, num++); } } float x = ((RectTransform)HUDManager.Get().m_CanvasGameObject.transform).localScale.x; foreach (UISelectDialogNodeData uiselectDialogNodeData in this.m_UINodeDatas) { uiselectDialogNodeData.m_BG.rectTransform.sizeDelta = new Vector2(this.m_MaxBGWidth, uiselectDialogNodeData.m_BG.rectTransform.sizeDelta.y); Vector3 position = uiselectDialogNodeData.m_BG.transform.position; position.x += this.m_MaxBGWidth * 0.29f * x + uiselectDialogNodeData.m_PadIcon.rectTransform.rect.width * 0.3f * x; uiselectDialogNodeData.m_PadIcon.transform.position = position; uiselectDialogNodeData.m_PadIcon.gameObject.SetActive(false); } string str = (this.m_Nodes[0].m_Prevs.Count > 0 && this.m_Nodes[0].m_Prevs[0].m_IconName != string.Empty) ? this.m_Nodes[0].m_Prevs[0].m_IconName : "Walkie_talkie_icon"; this.m_Icon.texture = Resources.Load <Texture>("HUD/HUD_Walkie_Talkie/" + str); this.m_TimerBelt[GreenHellGame.IsPCControllerActive() ? 0 : 1].gameObject.SetActive(this.m_Duration > 0f); InputActionData actionDataByInputAction = InputsManager.Get().GetActionDataByInputAction(InputsManager.InputAction.ShowSelectDialogNode, ControllerType._Count); this.m_KeyText.text = KeyCodeToString.GetString((actionDataByInputAction != null) ? actionDataByInputAction.m_KeyCode : KeyCode.None); GameObject gameObject = GreenHellGame.IsPCControllerActive() ? this.m_Reply : this.m_ReplyPad; Vector3 position2 = this.m_KeyFrame.transform.position; position2.x = gameObject.transform.position.x; Text component = gameObject.GetComponent <Text>(); TextGenerationSettings generationSettings = component.GetGenerationSettings(component.rectTransform.rect.size); generationSettings.scaleFactor = 1f; float num2 = this.m_TextGen.GetPreferredWidth(component.text, generationSettings) * x; position2.x -= num2 * 0.5f; position2.x -= this.m_KeyFrame.GetComponent <RectTransform>().sizeDelta.x * 1.1f * x; this.m_KeyFrame.transform.position = position2; this.m_PadIcon.transform.position = position2; }
private void Setup() { this.m_PosY = this.m_Dummy.transform.localPosition.y; this.m_MaxBGWidth = 0f; int num = 0; foreach (DialogNode dialogNode in this.m_Nodes) { if (!dialogNode.m_Additional) { this.AddNode(dialogNode.m_Name, num++); } } foreach (UISelectDialogNodeData uiselectDialogNodeData in this.m_UINodeDatas) { uiselectDialogNodeData.m_BG.rectTransform.sizeDelta = new Vector2(this.m_MaxBGWidth, uiselectDialogNodeData.m_BG.rectTransform.sizeDelta.y); } string str = (this.m_Nodes[0].m_Prevs.Count <= 0 || !(this.m_Nodes[0].m_Prevs[0].m_IconName != string.Empty)) ? "Walkie_talkie_icon" : this.m_Nodes[0].m_Prevs[0].m_IconName; this.m_Icon.texture = Resources.Load <Texture>("HUD/HUD_Walkie_Talkie/" + str); this.m_TimerBelt.gameObject.SetActive(this.m_Duration > 0f); this.m_KeyText.text = KeyCodeToString.GetString(InputsManager.Get().GetActionsByInputAction()[43].m_KeyCode); }
protected override void Update() { base.Update(); if (this.m_LastKeyCode != this.m_InputData.m_KeyCode) { this.m_KeyText.text = KeyCodeToString.GetString(this.m_InputData.m_KeyCode); this.m_LastKeyCode = this.m_InputData.m_KeyCode; } if ((this.m_LastSelectDialogDeactivationTime == 0f || Time.time - this.m_LastSelectDialogDeactivationTime > 0.5f) && GreenHellGame.IsPCControllerActive()) { if (InputsManager.Get().IsActionActive(InputsManager.InputAction.ShowSelectDialogNode) && !DialogsManager.Get().IsAnyDialogPlaying()) { if (!HUDSelectDialog.Get().enabled&& Player.Get().m_Animator.GetCurrentAnimatorStateInfo(2).shortNameHash == this.m_IdleHash && !MakeFireController.Get().IsActive()) { HUDSelectDialog.Get().Activate(); this.m_LastSelectDialogDeactivationTime = Time.time; } } else if (HUDSelectDialog.Get().enabled&& !DialogsManager.Get().IsAnyDialogPlaying()) { HUDSelectDialog.Get().Deactivate(); this.m_LastSelectDialogDeactivationTime = Time.time; } } if (this.m_NewDialogsCount == 0 || HUDSelectDialog.Get().enabled || DialogsManager.Get().IsAnyDialogPlaying()) { if (this.m_NewDialogsObject.activeSelf) { this.m_NewDialogsObject.SetActive(false); return; } } else if (!this.m_NewDialogsObject.activeSelf) { this.m_NewDialogsObject.SetActive(true); } }
public string Get(string key) { string text = string.Empty; if (!this.m_LocalizedTexts.TryGetValue(key, out text)) { text = key + " = !!!MISSING TEXT!!!"; return(text); } if (text.Length == 0) { return(text); } int i = 0; int num = 0; int num2 = 0; i = text.IndexOf("[", i); string text2 = text; bool flag = false; while (i >= 0) { flag = true; num = text2.IndexOf("]", i); if (num2 == 0) { text = text2.Substring(num2, i - num2 + 1); } else { text += text2.Substring(num2 + 1, i - num2); } string text3 = text2.Substring(i + 1, num - i - 1); bool flag2 = true; InputsManager.InputAction key2 = InputsManager.InputAction.SkipCutscene; TriggerAction.TYPE key3 = TriggerAction.TYPE.Take; bool flag3 = false; bool flag4 = false; try { key2 = (InputsManager.InputAction)Enum.Parse(typeof(InputsManager.InputAction), text3); flag3 = true; } catch (ArgumentException) { flag2 = false; } if (!flag2) { try { key3 = (TriggerAction.TYPE)Enum.Parse(typeof(TriggerAction.TYPE), text3); flag4 = true; } catch (ArgumentException) { flag2 = false; } } if (flag2) { string str = string.Empty; if (flag3) { KeyCode keyCode = InputsManager.Get().GetActionsByInputAction()[(int)key2].m_KeyCode; str = KeyCodeToString.GetString(keyCode); } else if (flag4) { KeyCode keyCode2 = InputsManager.Get().GetActionsByTriggerAction()[(int)key3].m_KeyCode; str = KeyCodeToString.GetString(keyCode2); } text = text + str + "]"; } else { text = text + text3 + "]"; } num2 = num; i = text2.IndexOf("[", num2); } if (flag) { text += text2.Substring(num + 1, text2.Length - num - 1); } return(text); }
private void OnKeyPressed(KeyCode key) { this.m_KeyCode = key; this.m_Text.text = KeyCodeToString.GetString(key); this.m_State = UIKeyBindButtonState.Focused; }
public void SetKeyCode(KeyCode key) { this.m_KeyCode = key; this.m_Text.text = KeyCodeToString.GetString(key); }
public string Get(string key, bool replace = true) { string text = string.Empty; if (!this.m_LocalizedTexts.TryGetValue(key, out text)) { text = key + " = !!!MISSING TEXT!!!"; return(text); } if (text.Length == 0) { return(text); } if (replace) { int i = 0; int num = 0; int num2 = 0; i = text.IndexOf("[", i); string text2 = text; bool flag = false; while (i >= 0) { flag = true; num = text2.IndexOf("]", i); if (num2 == 0) { text = text2.Substring(num2, i - num2 + 1); } else { text += text2.Substring(num2 + 1, i - num2); } string text3 = text2.Substring(i + 1, num - i - 1); bool flag2 = true; InputsManager.InputAction input_action = InputsManager.InputAction.SkipCutscene; TriggerAction.TYPE trigger_action = TriggerAction.TYPE.Take; bool flag3 = false; bool flag4 = false; if (Enum.TryParse <InputsManager.InputAction>(text3, true, out input_action)) { flag3 = true; } else { flag2 = false; } if (!flag2) { if (Enum.TryParse <TriggerAction.TYPE>(text3, true, out trigger_action)) { flag4 = true; } else { flag2 = false; } } if (flag2) { string str = string.Empty; if (flag3) { InputActionData actionDataByInputAction = InputsManager.Get().GetActionDataByInputAction(input_action, ControllerType._Count); if (actionDataByInputAction == null) { actionDataByInputAction = InputsManager.Get().GetActionDataByInputAction(input_action, (GreenHellGame.Instance.m_Settings.m_ControllerType == ControllerType.Pad) ? ControllerType.PC : ControllerType.Pad); } KeyCode keyCode = (actionDataByInputAction != null) ? actionDataByInputAction.m_KeyCode : KeyCode.None; str = ((keyCode != KeyCode.None) ? KeyCodeToString.GetString(keyCode) : text3); } else if (flag4) { InputActionData actionDataByTriggerAction = InputsManager.Get().GetActionDataByTriggerAction(trigger_action, ControllerType._Count); str = KeyCodeToString.GetString((actionDataByTriggerAction != null) ? actionDataByTriggerAction.m_KeyCode : KeyCode.None); } text = text + str + "]"; } else { text = text + text3 + "]"; } num2 = num; i = text2.IndexOf("[", num2); } if (flag) { text += text2.Substring(num + 1, text2.Length - num - 1); } } return(text); }
private void UpdateActions() { Trigger trigger = this.GetTrigger(); if (!trigger || !trigger.CanExecuteActions() || this.IsExpanded()) { for (int i = 0; i < this.m_Actions.Length; i++) { this.m_KeyFrames[i].gameObject.SetActive(false); this.m_Keys[i].gameObject.SetActive(false); this.m_Actions[i].gameObject.SetActive(false); this.m_PadIcons[i].gameObject.SetActive(false); if (this.m_MouseRMBIcon[i]) { this.m_MouseRMBIcon[i].gameObject.SetActive(false); } } return; } this.m_TriggerActions.Clear(); if (!this.IsExpanded()) { if (Inventory3DManager.Get().gameObject.activeSelf) { Item item = trigger.IsItem() ? ((Item)trigger) : null; if (item) { if (item.m_OnCraftingTable) { this.m_TriggerActions.Add(TriggerAction.TYPE.Remove); } else if (item.CanShowExpandMenu()) { if (GreenHellGame.IsPadControllerActive()) { this.m_TriggerActions.Add(TriggerAction.TYPE.Pick); } this.m_TriggerActions.Add(TriggerAction.TYPE.InventoryExpand); } } } else { trigger.GetActions(this.m_TriggerActions); } } Vector3 position = Vector3.zero; bool flag = GreenHellGame.IsPadControllerActive(); int num = 0; while (num < this.m_TriggerActions.Count && num < 2) { this.m_KeyFrames[num].gameObject.SetActive(!flag); this.m_Keys[num].gameObject.SetActive(!flag); this.m_Actions[num].gameObject.SetActive(true); this.m_PadIcons[num].gameObject.SetActive(flag); if (this.m_MouseRMBIcon[num]) { this.m_MouseRMBIcon[num].gameObject.SetActive(false); } this.m_Keys[num].text = string.Empty; this.m_Actions[num].text = string.Empty; TriggerAction.TYPE type = this.m_TriggerActions[num]; InputActionData inputActionData = InputsManager.Get().GetInputActionData(type); if (inputActionData != null) { if (flag) { this.m_PadIcons[num].sprite = inputActionData.m_PadIcon; } else if (inputActionData.m_KeyCode == KeyCode.Mouse1) { if (this.m_MouseRMBIcon[num]) { this.m_MouseRMBIcon[num].gameObject.SetActive(true); this.m_KeyFrames[num].gameObject.SetActive(false); } this.m_Keys[num].gameObject.SetActive(false); } else { Text text = this.m_Keys[num]; text.text += KeyCodeToString.GetString(inputActionData.m_KeyCode); } if (inputActionData.m_Hold > 0f) { Text text2 = this.m_Actions[num]; text2.text = text2.text + GreenHellGame.Instance.GetLocalization().Get("HUD_Trigger_Hold", true) + " "; } Text text3 = this.m_Actions[num]; text3.text += GreenHellGame.Instance.GetLocalization().Get(TriggerAction.GetText(type), true); } else { this.m_Actions[num].text = GreenHellGame.Instance.GetLocalization().Get(TriggerAction.GetText(type), true); } if (num == 0) { TextGenerationSettings generationSettings = this.m_Actions[num].GetGenerationSettings(this.m_Actions[num].rectTransform.rect.size); float width = ((RectTransform)HUDManager.Get().m_CanvasGameObject.transform).rect.width; float x = ((RectTransform)HUDManager.Get().m_CanvasGameObject.transform).localScale.x; generationSettings.scaleFactor = x; float preferredWidth = this.m_TextGen.GetPreferredWidth(this.m_Actions[num].text, generationSettings); position = this.m_KeyFrames[num].rectTransform.position; position.x += this.m_KeyFrames[num].rectTransform.rect.width * 0.5f * x; position.x += preferredWidth + width * x * 0.01f; position.x += this.m_KeyFrames[num].rectTransform.rect.width * x; } else if (num == 1 && this.m_KeyFrameParents[num] != null) { this.m_KeyFrameParents[num].position = position; } num++; } for (int j = this.m_TriggerActions.Count; j < this.m_Actions.Length; j++) { this.m_KeyFrames[j].gameObject.SetActive(false); this.m_Keys[j].gameObject.SetActive(false); this.m_Actions[j].gameObject.SetActive(false); this.m_PadIcons[j].gameObject.SetActive(false); if (this.m_MouseRMBIcon[j] != null) { this.m_MouseRMBIcon[j].gameObject.SetActive(false); } } }