Esempio n. 1
0
 public static KeyCodeToString Instance()
 {
     if (KeyCodeToString.instance == null)
     {
         KeyCodeToString.instance = new KeyCodeToString();
     }
     return(KeyCodeToString.instance);
 }
Esempio n. 2
0
 private string GetKeyText(InputActionData data)
 {
     if (data == null)
     {
         return(string.Empty);
     }
     return(KeyCodeToString.GetString(data.m_KeyCode));
 }
Esempio n. 3
0
 public static string GetString(KeyCode key_code)
 {
     if (!KeyCodeToString.s_Initialized)
     {
         KeyCodeToString.Initialize();
     }
     return(KeyCodeToString.s_Dict[(int)key_code]);
 }
Esempio n. 4
0
 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();
 }
Esempio n. 5
0
    public string ConvertBindingToText(KeyCode keyCode)
    {
        if (!IsCustomKey(keyCode))
        {
            return(keyCode.ToString());
        }

        return(KeyCodeToString.Convert(keyCode));
    }
Esempio n. 6
0
    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);
    }
Esempio n. 7
0
    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;
    }
Esempio n. 8
0
    private InputManager()
    {
        buttonKeys     = new Dictionary <ButtonName, KeyCode>();
        joystickKeys   = new Dictionary <ButtonName, KeyCode>();
        keysName       = new Dictionary <ButtonName, string>();
        this.joysticks = new int[2];

        // TODO : Change menu with these strings
        // TODO : Change inputs in project settings
        buttonKeys[ButtonName.Left]    = KeyCode.Q;
        buttonKeys[ButtonName.Right]   = KeyCode.D;
        buttonKeys[ButtonName.Jump]    = KeyCode.Space;
        buttonKeys[ButtonName.Action]  = KeyCode.E;
        buttonKeys[ButtonName.Left2]   = KeyCode.LeftArrow;
        buttonKeys[ButtonName.Right2]  = KeyCode.RightArrow;
        buttonKeys[ButtonName.Jump2]   = KeyCode.UpArrow;
        buttonKeys[ButtonName.Action2] = KeyCode.Keypad0;
        buttonKeys[ButtonName.Pause]   = KeyCode.Escape;
        buttonKeys[ButtonName.None]    = KeyCode.None;

        joystickKeys[ButtonName.Left]    = KeyCode.None;
        joystickKeys[ButtonName.Right]   = KeyCode.None;
        joystickKeys[ButtonName.Jump]    = KeyCode.None;
        joystickKeys[ButtonName.Action]  = KeyCode.None;
        joystickKeys[ButtonName.Left2]   = KeyCode.None;
        joystickKeys[ButtonName.Right2]  = KeyCode.None;
        joystickKeys[ButtonName.Jump2]   = KeyCode.None;
        joystickKeys[ButtonName.Action2] = KeyCode.None;
        joystickKeys[ButtonName.Pause]   = KeyCode.None;
        joystickKeys[ButtonName.None]    = KeyCode.None;

        ButtonName[] values = (ButtonName[])ButtonName.GetValues(typeof(ButtonName));
        foreach (ButtonName button in values)
        {
            keysName.Add(button, KeyCodeToString.Instance().Convert(buttonKeys[button]));
        }

        this.joysticks[0] = -1;
        this.joysticks[1] = -1;
    }
Esempio n. 9
0
    void OnGUI()
    {
        if (keyAsToChange)
        {
            Event e = Event.current;
            if (e != null && e.isKey)
            {
                string keycodeString = KeyCodeToString.Instance().Convert(e.keyCode);

                if (keycodeString != null)
                {
                    InputManager.Instance().SetKeyName(buttonName, e.keyCode, keycodeString);
                    this.textField.text = InputManager.Instance().GetKeyName(buttonName);

                    keyAsToChange         = false;
                    buttonAlreadySelected = false;

                    button.colors = normalColorBlock;
                }
            }
        }
    }
Esempio n. 10
0
    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);
    }
Esempio n. 11
0
 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);
     }
 }
Esempio n. 12
0
    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);
    }
Esempio n. 13
0
 private void OnKeyPressed(KeyCode key)
 {
     this.m_KeyCode   = key;
     this.m_Text.text = KeyCodeToString.GetString(key);
     this.m_State     = UIKeyBindButtonState.Focused;
 }
Esempio n. 14
0
 public void SetKeyCode(KeyCode key)
 {
     this.m_KeyCode   = key;
     this.m_Text.text = KeyCodeToString.GetString(key);
 }
Esempio n. 15
0
    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);
    }
Esempio n. 16
0
    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);
            }
        }
    }