Ejemplo n.º 1
0
	public string GetButtonName (GamepadButton button)
	{
		for (int i = 0; i < buttonNames.Count; i++)
		{
			if (buttonNames [i].button == button)
				return buttonNames [i].name;
		}

		return button.ToString ();
	}
Ejemplo n.º 2
0
    public string GetButtonName(GamepadButton button)
    {
        for (int i = 0; i < buttonNames.Count; i++)
        {
            if (buttonNames [i].button == button)
            {
                return(buttonNames [i].name);
            }
        }

        return(button.ToString());
    }
Ejemplo n.º 3
0
        public static string GetPrompt(this GamepadButton button, GamepadType type)
        {
            if (button == GamepadButton.None)
            {
                return("?");
            }

            var imagePath = button.GetPromptImagePath(type);

            if (imagePath != null)
            {
                return('[' + imagePath + ']');
            }
            else
            {
                return(button.ToString().ToProperSpaced());
            }
        }
Ejemplo n.º 4
0
        private static string GetPromptImagePath(this GamepadButton button, GamepadType type)
        {
            if (type == GamepadType.Unknown || type == GamepadType.XboxOne)
            {
                type = GamepadType.Xbox360;
            }
            else if (type == GamepadType.PS4)
            {
                type = GamepadType.PS3;
            }

            string buttonName;

            switch (button)
            {
            case GamepadButton.LeftStickUp:
            case GamepadButton.LeftStickDown:
            case GamepadButton.LeftStickLeft:
            case GamepadButton.LeftStickRight:
            {
                buttonName = "left_stick";
                break;
            }

            case GamepadButton.RightStickUp:
            case GamepadButton.RightStickDown:
            case GamepadButton.RightStickLeft:
            case GamepadButton.RightStickRight:
            {
                buttonName = "right_stick";
                break;
            }

            case GamepadButton.A:
            {
                switch (type)
                {
                case GamepadType.PS3:
                case GamepadType.PS4:
                {
                    buttonName = "cross";
                    break;
                }

                default:
                {
                    buttonName = "a";
                    break;
                }
                }
                break;
            }

            case GamepadButton.B:
            {
                switch (type)
                {
                case GamepadType.PS3:
                case GamepadType.PS4:
                {
                    buttonName = "circle";
                    break;
                }

                default:
                {
                    buttonName = "b";
                    break;
                }
                }
                break;
            }

            case GamepadButton.X:
            {
                switch (type)
                {
                case GamepadType.PS3:
                case GamepadType.PS4:
                {
                    buttonName = "square";
                    break;
                }

                default:
                {
                    buttonName = "x";
                    break;
                }
                }
                break;
            }

            case GamepadButton.Y:
            {
                switch (type)
                {
                case GamepadType.PS3:
                case GamepadType.PS4:
                {
                    buttonName = "triangle";
                    break;
                }

                default:
                {
                    buttonName = "y";
                    break;
                }
                }
                break;
            }

            case GamepadButton.Back:
            {
                switch (type)
                {
                case GamepadType.PS3:
                {
                    buttonName = "select";
                    break;
                }

                case GamepadType.PS4:
                {
                    buttonName = "share";
                    break;
                }

                case GamepadType.XboxOne:
                {
                    buttonName = "view";
                    break;
                }

                default:
                {
                    buttonName = "back";
                    break;
                }
                }
                break;
            }

            case GamepadButton.Start:
            {
                switch (type)
                {
                case GamepadType.PS4:
                {
                    buttonName = "options";
                    break;
                }

                case GamepadType.XboxOne:
                {
                    buttonName = "menu";
                    break;
                }

                default:
                {
                    buttonName = "start";
                    break;
                }
                }
                break;
            }

            default:
            {
                buttonName = button.ToString().ToLowerUnderscored();
                break;
            }
            }

            var path = AssetPath.Combine(
                "gui/prompts/" + type.ToString().ToLowerUnderscored(),
                buttonName + ".png"
                );

            if (Assets.Assets.Exists <Texture>(path))
            {
                return(path);
            }
            return(null);
        }