Inheritance: MonoBehaviour
Ejemplo n.º 1
0
            //every button needs to have own handler
            //bug Currently:
            //fontMat,font need to be set solid somewhere in a manager of sorts

            #region Creator

            //Creats a button and calls the need functions
            public static GameObject makeButton(Buttons bu, Transform parent, Vector3 pos = new Vector3(), int fontSize = 20, string text = "", int ToMenu = -1, string url = "", TextAnchor txmach = TextAnchor.UpperLeft)
            {
                GameObject b = null;
                switch (bu)
                {
                    case Buttons.Exit:
                       b = ExitButton.exitButton(fontMat, font, fontSize,txmach);
                        break;
                    case Buttons.ChangeMenu:
                        b = ChangeMenuButton.changeMenuButton(fontMat, font, fontSize, text, ToMenu, txmach);
                        break;
                    case Buttons.Link:
                        b = OpenLinkButton.openLinkButton(fontMat, font, fontSize, text, url, txmach);
                        break;
                    case Buttons.LevelLink:
                        b = menu.factory.button.LoadLevelButton.loadLevelButton(fontMat, font, fontSize, text, url, txmach);
                        break;
                    case Buttons.ResetHighScore:
                        b = ResetHighScoreButton.resetHighScoreButton(fontMat, font, fontSize, txmach);
                        break;
                    default:
                        b=new GameObject();
                        b.name="Buttons.##Error##";
                        Object.DestroyImmediate(b);
                        break;

                }
                b.transform.parent = parent;
                b.transform.position = pos;

                return b;
            }
        public bool ButtonPressed(Buttons button, bool repeat, bool delayRepeat)
        {
            bool returnValue = false;

            if (controlsActive == true)
            {
                if (repeat == true)
                {
                    if (delayRepeat == true)
                    {
                        returnValue = (currentGamePadState.IsButtonDown(button) && doRepeat);
                    }
                    else if (delayRepeat == false)
                    {
                        returnValue = currentGamePadState.IsButtonDown(button);
                    }
                }
                else if (repeat == false)
                {
                    returnValue = (currentGamePadState.IsButtonDown(button) && !previousGamePadState.IsButtonDown(button));
                }
            }
            else
            {
                returnValue = false;
            }

            if (returnValue == true)
            {
                lastButtonPress = gameTime.TotalGameTime;
            }

            return returnValue;
        }
Ejemplo n.º 3
0
 public GameButton(Buttons buttonCode)
 {
     this.keyCode = Keys.None;
     this.mouseCode = MouseButtons.None;
     this.buttonCode = buttonCode;
     this.inputType = InputType.Button;
 }
Ejemplo n.º 4
0
 string getButtonHelper(Buttons button, int joyNum)
 {
     string buttonName = "";
     switch (button)
     {
         case Buttons.A:
             buttonName = getButtonName(joyNum, "1", "1", "1");
             break;
         case Buttons.B:
             buttonName = getButtonName(joyNum, "2", "2", "2");
             break;
         case Buttons.X:
             buttonName = getButtonName(joyNum, "0", "0", "0");
             break;
         case Buttons.Y:
             buttonName = getButtonName(joyNum, "3", "3", "3");
             break;
         case Buttons.LeftBumper:
             buttonName = getButtonName(joyNum, "4", "4", "4");
             break;
         case Buttons.RightBumper:
             buttonName = getButtonName(joyNum, "5", "5", "5");
             break;
         case Buttons.LeftStickClick:
             buttonName = getButtonName(joyNum, "10", "0", "0");
             break;
         case Buttons.RightStickClick:
             buttonName = getButtonName(joyNum, "11", "0", "0");
             break;
         case Buttons.Start:
             buttonName = getButtonName(joyNum, "9", "9", "9");
             break;
     }
     return buttonName;
 }
Ejemplo n.º 5
0
 public GameButton(Keys keyCode)
 {
     this.keyCode = keyCode;
     this.mouseCode = MouseButtons.None;
     this.buttonCode = Buttons.None;
     this.inputType = InputType.Key;
 }
Ejemplo n.º 6
0
 public GameButton(MouseButtons mouseCode)
 {
     this.keyCode = Keys.None;
     this.mouseCode = mouseCode;
     this.buttonCode = Buttons.None;
     this.inputType = InputType.MouseButton;
 }
Ejemplo n.º 7
0
 public static bool singlePress(Buttons b)
 {
     bool ret = false;
     if (oldState.IsButtonUp(b) && newState.IsButtonDown(b))
         ret = true;
     return ret;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Returrns true if the specified button was just released
 /// </summary>
 /// <param name="Button">Buttons Button</param>
 /// <returns>bool</returns>
 public bool justReleased(Buttons button)
 {
     if ((old.IsButtonDown(button) && current.IsButtonUp(button)))
         return true;
     else
         return false;
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Returrns true if the specified button was just pressed
 /// </summary>
 /// <param name="Button">Buttons Button</param>
 /// <returns>bool</returns>
 public bool justPressed(Buttons Button)
 {
     if ((current.IsButtonDown(Button) && old.IsButtonUp(Button)))
         return true;
     else
         return false;
 }
Ejemplo n.º 10
0
 public override string GetButtonHelper(Buttons button)
 {
     string buttonName = "";
     switch (button)
     {
         case Buttons.A:
             buttonName = getButtonName("1", "1", "1");
             break;
         case Buttons.B:
             buttonName = getButtonName("2", "2", "2");
             break;
         case Buttons.X:
             buttonName = getButtonName("0", "0", "0");
             break;
         case Buttons.Y:
             buttonName = getButtonName("3", "3", "3");
             break;
         case Buttons.LeftBumper:
             buttonName = getButtonName("4", "4", "4");
             break;
         case Buttons.RightBumper:
             buttonName = getButtonName("5", "5", "5");
             break;
         case Buttons.LeftStickClick:
             buttonName = getButtonName("10", "10", "10");
             break;
         case Buttons.RightStickClick:
             buttonName = getButtonName("11", "11", "11");
             break;
         case Buttons.Start:
             buttonName = getButtonName("9", "9", "9");
             break;
     }
     return buttonName;
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Creates a new InputButton from the given key and, optionally, modifiers.
 /// </summary>
 public InputButton(Keys Key, ConsoleModifiers Modifiers = 0)
 {
     this._Button = 0; // Make it not complain about readonly being assigned, even though it's incorrect.
     this._Key = Key;
     this._KeyModifiers = Modifiers;
     this.Type = InputMethod.Key;
 }
Ejemplo n.º 12
0
 public string GetButtonName(Buttons key)
 {
     if (buttonStates.ContainsKey(key))
         return key.ToString();
     else
         return null;
 }
Ejemplo n.º 13
0
        public LocalPlayer(World world, Vector2 position, Category collisionCat, float scale, float limbStrength, float limbDefense, bool evilSkin, Color color, PlayerIndex player)
            : base(world, position, collisionCat, scale, limbStrength, limbDefense, evilSkin, color)
        {
            this.player = player;
            punchBtnPressed = punchKeyPressed = false;
            kickBtnPressed = kickKeyPressed = false;
            shootBtnPressed = shootKeyPressed = false;
            trapBtnPressed = trapKeyPressed = false;
            usesKeyboard = !GamePad.GetState(player).IsConnected;
            lastShootAngle = 0f;

            jumpBtn = Buttons.A;
            rightBtn = Buttons.LeftThumbstickRight;
            leftBtn = Buttons.LeftThumbstickLeft;
            crouchBtn = Buttons.LeftTrigger;
            punchBtn = Buttons.X;
            kickBtn = Buttons.B;
            shootBtn = Buttons.RightTrigger;
            trapBtn = Buttons.Y;

            upKey = Keys.W;
            rightKey = Keys.D;
            leftKey = Keys.A;
            downKey = Keys.S;
            trapKey = Keys.T;
        }
Ejemplo n.º 14
0
 /// <summary>
 /// Creates a new InputButton from the given controller button.
 /// </summary>
 public InputButton(Buttons Button)
 {
     this._Key = 0; // Prevent complaining about readonly.
     this._KeyModifiers = 0;
     this._Button = Button;
     this.Type = InputMethod.Button;
 }
Ejemplo n.º 15
0
 public bool GetButtonValue(Buttons key)
 {
     if (buttonStates.ContainsKey (key))
         return buttonStates [key].value;
     else
         return false;
 }
Ejemplo n.º 16
0
        public void Init(ContentManager cm, float value, float minValue, float maxValue, string bgPath, string path, string t, Color bgColor, Color c, Vector2 targetPos, bool useOrigin, Vector2 hitboxOffset)
        {
            base.Init(cm, bgPath, path, t, bgColor, c, targetPos, useOrigin, hitboxOffset);

            sliderBackgroundTexture = new Sprite();
            sliderBlockTexture = new Sprite();
            valueText = new Text();
            backgroundTexture = new Sprite();
            sliderIcons = new Sprite();

            valueText.Init(cm, path, value.ToString(), Color.White, Vector2.Zero, true);
            backgroundTexture.Init(cm, bgPath, Vector2.Zero, Color.White, 1.0f, true);
            sliderIcons.Init(cm, "OptionsMenu\\sliderBarIcons", Vector2.Zero, Color.White, 1.0f, true);
            sliderBackgroundTexture.Init(cm, "OptionsMenu\\sliderBar", Vector2.Zero, Color.White, 1.0f, true);
            sliderBlockTexture.Init(cm, "OptionsMenu\\sliderBlock", Vector2.Zero, Color.White, 1.0f, true);

            this.value = value;
            this.minValue = minValue;
            this.maxValue = maxValue;

            sliderTargetPos = Vector2.Zero;

            holdTime = 0;
            incTick = 0;
            lastHeldKey = Keys.None;
            lastHeldButton = Buttons.B;

            fadeConstant = 0.1f;

            sliderHitbox = new Rectangle(0, 0, sliderBackgroundTexture.GetTexture.Width, sliderBackgroundTexture.GetTexture.Height);

            SetPos(startingPos);
            SetAlpha(0.0f);
        }
Ejemplo n.º 17
0
        public InputAction(Buttons[] buttons, Keys[] keys, bool newPressOnly)
        {
            this.buttons = buttons != null ? buttons.Clone() as Buttons[] : new Buttons[0];
            this.keys = keys != null ? keys.Clone() as Keys[] : new Keys[0];

            this.newPressOnly = newPressOnly;
        }
Ejemplo n.º 18
0
    /// <summary>Called when a button on the game pad has been pressed</summary>
    /// <param name="button">Button that has been pressed</param>
    /// <returns>
    ///   True if the button press was processed by the control and future game pad
    ///   input belongs to the control until all buttons are released again
    /// </returns>
    internal bool ProcessButtonPress(Buttons button) {

      // If there's an activated control (one being held down by the mouse or having
      // accepted a previous button press), this control will get the button press
      // delivered, whether it wants to or not.
      if(this.activatedControl != null) {
        ++this.heldButtonCount;

        // If one of our children is the activated control, pass on the message
        if(this.activatedControl != this) {
          this.activatedControl.ProcessButtonPress(button);
        } else { // We're the activated control
          OnButtonPressed(button);
        }

        // We're already activated, so this button press is accepted in any case
        return true;
      }

      // A button has been pressed but no control is activated currently. This means we
      // have to look for a control which feels responsible for the button press,
      // starting with ourselves.

      // Does the user code in our derived class feel responsible for this button?
      // If so, we're the new activated control and the button has been handled.
      if(OnButtonPressed(button)) {
        this.activatedControl = this;
        ++this.heldButtonCount;
        return true;
      }

      // Nope, we have to ask our children to find a control that feels responsible.
      bool encounteredOrderingControl = false;
      for(int index = 0; index < this.children.Count; ++index) {
        Control child = this.children[index];

        // We only process one child that has the affectsOrdering field set. This
        // ensures that key presses will not be delivered to windows sitting behind
        // another window. Other siblings that are not windows are asked still, so
        // a bunch of buttons on the desktop would be asked in addition to a window.
        if(child.affectsOrdering) {
          if(encounteredOrderingControl) {
            continue;
          } else {
            encounteredOrderingControl = true;
          }
        }

        // Does this child feel responsible for the button press?
        if(child.ProcessButtonPress(button)) {
          this.activatedControl = child;
          ++this.heldButtonCount;
          return true;
        }
      }

      // Neither we nor any of our children felt responsible for the button. Give up.
      return false;

    }
Ejemplo n.º 19
0
 /// <summary>
 /// Checks if button has been released.
 /// </summary>
 /// <param name="button">The button to check.</param>
 /// <returns></returns>
 public static bool IsButtonReleased(Buttons button)
 {
     if (prevGamePadState.IsButtonDown(button) == true && currentGamePadState.IsButtonDown(button) == false)
         return true;
     else
         return false;
 }
Ejemplo n.º 20
0
 public float GetButtonHoldTime(Buttons key)
 {
     if (buttonStates.ContainsKey(key))
         return buttonStates[key].holdTime;
     else
         return 0;
 }
Ejemplo n.º 21
0
        public InGameMenu(ref Camera _cam, string lvl = "1.txt")
        {
            gameState = GameState.InGameMenu;
            Escape = GameState.InGame;
            level = lvl;
            cam = _cam;

            Buttons returnToGame = new Buttons();
            returnToGame.text = "Go back to game";
            returnToGame.font = Game1.font;
            returnToGame.texture = Game1.cellT;
            returnToGame.couleur = Color.RoyalBlue;
            returnToGame.returnState = GameState.InGame;
            AddButton(returnToGame);

            Buttons menu = new Buttons();
            menu.text = "Main Menu";
            menu.font = Game1.font;
            menu.fontColor = Color.Black;
            menu.texture = Game1.cellT;
            menu.couleur = Color.Yellow;
            menu.Clic += menu_Clic;
            menu.returnState = GameState.MainMenu;
            AddButton(menu);
        }
Ejemplo n.º 22
0
	void Update () {

        // Checks if we need to update the currently selected on on screen
        // This is merely updating the view
        if(selected != oldVal)
        {
            unhighlightSelected(oldVal);
            highlightSelected(selected);
            oldVal = selected;
        }
		if (ms.menuState == MenuState.MenuStates.inMainMenu){
			// Checking for input
			if (Input.GetKeyDown ("up") /*|| Input.GetAxis("Vertical") > 0.4f*/) {
				--selected;
				checkSelection ();
			} else if (Input.GetKeyDown ("down") /*|| Input.GetAxis("Vertical") < 0.4f*/) {
				++selected;
				checkSelection ();
			} else if (Input.GetKeyDown ("escape") || Input.GetButtonDown("XboxStart")) {
				GameObject menu = GameObject.Find ("MainMenu");
				menu.GetComponent<Canvas> ().enabled = true;
				ms.menuState = MenuState.MenuStates.inMainMenu;
			} else if (Input.GetKeyDown("return") || Input.GetButtonDown ("XboxA")) {
				Debug.Log("FROM: enter " + selected);
				makeMenuSelection(((int)selected)-1);
			}
		}
		else if (ms.menuState == MenuState.MenuStates.playerPlaying){
			if (Input.GetKeyDown ("escape") || Input.GetButtonDown("XboxStart")) {
				GameObject menu = GameObject.Find ("MainMenu");
				menu.GetComponent<Canvas> ().enabled = true;
				ms.menuState = MenuState.MenuStates.inMainMenu;
			}
		}
	}
Ejemplo n.º 23
0
	void Start () {
		selected = Buttons.newGame;
        oldVal = selected;
		highlightSelected (selected);
        mousedOver = false;
		ms = GameObject.Find ("Game Controller").GetComponent<MenuState>();
	}
Ejemplo n.º 24
0
    public void SetButtonValue(Buttons key, bool value)
    {
        //checks if the key exist
        if (!buttonStates.ContainsKey(key))
            buttonStates.Add(key, new ButtonSate());

        var state = buttonStates [key];

        //check if the button has been released.
        if(state.value && !value)
        {
            //Debug.Log("Button " + key + " released." + state.holdTime);
            state.holdTime = 0;

        }else if(state.value && value)
        {

                state.holdTime += Time.deltaTime;
               // Debug.Log("Button " + key + " Down " + state.holdTime);
           
        }

        state.value = value;

    }
Ejemplo n.º 25
0
 public void Set(string key, Buttons value)
 {
     if (Mapping.ContainsKey(key))
         Mapping[key].Set(value);
     else
         Mapping.Add(key, new Button(value));
 }
Ejemplo n.º 26
0
 /// <summary>
 /// Check if a mouse button is being held
 /// </summary>
 /// <param name="Key">The mouse button to check.</param>
 /// <returns>A True/False statement.</returns>
 public static bool Holding(Buttons Key)
 {
     if ((Key == Buttons.Left) && (M.LeftButton == ButtonState.Pressed)) return true;
     if ((Key == Buttons.Middle) && (M.MiddleButton == ButtonState.Pressed)) return true;
     if ((Key == Buttons.Right) && (M.RightButton == ButtonState.Pressed)) return true;
     return false;
 }
Ejemplo n.º 27
0
 public void AddGamePadInput(string theAction,
                             Buttons theButton,
                             bool isReleasedPreviously)
 {
     MyInput(theAction).AddGamepadInput(theButton,
                                        isReleasedPreviously);
 }
Ejemplo n.º 28
0
 public static Dictionary<Buttons, String> CreateGamepadDictionary(Buttons gamePad)
 {
     Dictionary<Buttons, String> dictionary =
        new Dictionary<Buttons, String>();
     dictionary.Add(Buttons.A, "");
     dictionary.Add(Buttons.B, "");
     dictionary.Add(Buttons.X, "");
     dictionary.Add(Buttons.Y, "");
     dictionary.Add(Buttons.LeftShoulder, "");
     dictionary.Add(Buttons.RightShoulder, "");
     dictionary.Add(Buttons.LeftTrigger, "");
     dictionary.Add(Buttons.RightTrigger, "");
     dictionary.Add(Buttons.LeftStick, "");
     dictionary.Add(Buttons.RightStick, "");
     dictionary.Add(Buttons.Back, "");
     dictionary.Add(Buttons.Start, "");
     dictionary.Add(Buttons.DPadDown, "");
     dictionary.Add(Buttons.DPadLeft, "");
     dictionary.Add(Buttons.DPadRight, "");
     dictionary.Add(Buttons.DPadUp, "");
     dictionary.Add(Buttons.LeftThumbstickDown, "");
     dictionary.Add(Buttons.LeftThumbstickLeft, "");
     dictionary.Add(Buttons.LeftThumbstickRight, "");
     dictionary.Add(Buttons.LeftThumbstickUp, "");
     dictionary.Add(Buttons.RightThumbstickDown,"");
     dictionary.Add(Buttons.RightThumbstickLeft, "");
     dictionary.Add(Buttons.RightThumbstickRight,"");
     dictionary.Add(Buttons.RightThumbstickUp,"");
     return dictionary;
 }
Ejemplo n.º 29
0
        private void ControllerInput(PlayerIndex i, Buttons b, GamePadMessage m)
        {
            if (m == GamePadMessage.Pressed && b == Buttons.Start)
            {
                if (_players[i] == null)
                {
                    Vector2 spawnPos = GetSpawnPosition();

                    GameObject go = new GameObject(string.Format("player_{0}", i));
                    Console.WriteLine("Spawning Player: " + go.Name);
                    go.Transform.Position = spawnPos;
                    go.Transform.Scale = new Vector2(0.25f);
                    var p = go.AddComponent<Player>();
                    Model2D model = new Model2D(go, string.Format("Player\\hero{0}", (int)i + 1));
                    go.AddComponent(model);
                    model.UseAnimations = true;
                    var rigid = go.AddComponent<RigidBody>();
                    rigid.HasDrag = true;
                    p.Index = i;
                    _players[i] = p;
                    if (i == PlayerIndex.One)
                        Camera.Instance.TrackingObject = go;
                }
            }
        }
Ejemplo n.º 30
0
        public static ButtonState GetButtonState(KeyboardState keyBoardState, Buttons b)
        {



            for (int i = 1; i <= (int)Input.Buttons.Y; i *= 2)
            {
                if (((int)b & i) == 0) continue;

                if (b == Input.Buttons.LeftTrigger)
                {
                    System.Diagnostics.Debug.WriteLine(string.Format("Is Pressed - "));
                }

                if (keyMappings.ContainsKey(b))
                {
                    return keyBoardState.IsKeyDown(keyMappings[b]) ? ButtonState.Pressed : ButtonState.Released;
                }
                else
                {
                    return ButtonState.Released;
                }
            }
            return ButtonState.Released;
        }
Ejemplo n.º 31
0
 public PadButton(int gamepadIndex, Buttons button)
 {
     GamepadIndex = gamepadIndex;
     Button       = button;
 }
Ejemplo n.º 32
0
 void AddButtonIndex(int index)
 {
     Buttons.Add(index);
 }
Ejemplo n.º 33
0
 /// <summary>
 /// Checks if a given button is released from being held down.
 /// </summary>
 /// <param name="button">The button to check.</param>
 /// <returns>Returns true if the button is released from being held down.</returns>
 public bool IsGamePadReleased(Buttons button)
 {
     return(gState.IsButtonUp(button) && gStatePrevious.IsButtonDown(button));
 }
Ejemplo n.º 34
0
 /// <summary>
 /// Checks if a given button is currently not held down.
 /// </summary>
 /// <param name="button">The button to check.</param>
 /// <returns>Returns true if the button is not held down.</returns>
 public bool IsGamePadUp(Buttons button)
 {
     return(gState.IsButtonUp(button));
 }
Ejemplo n.º 35
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (StopProcessing)
        {
            // Do nothing
        }
        else
        {
            if (Buttons != null)
            {
                if (AllowSelection)
                {
                    ScriptHelper.RegisterJQuery(Page);
                    StringBuilder selectionScript = new StringBuilder();
                    selectionScript.AppendLine("function SelectButton(elem)");
                    selectionScript.AppendLine("{");
                    selectionScript.AppendLine("    var selected = '" + SelectedSuffix + "';");
                    selectionScript.AppendLine("    var jElem =$j(elem);");
                    // Get first parent table
                    selectionScript.AppendLine("    var parentTable = jElem.parents('table').get(0);");
                    selectionScript.AppendLine("    if (parentTable != null) {");
                    // Remove selected class from current group of buttons
                    selectionScript.AppendLine("        $j(parentTable).find('.' + elem.className).removeClass(selected);");
                    selectionScript.AppendLine("    }");
                    selectionScript.AppendLine("    jElem.addClass(selected);");
                    selectionScript.AppendLine("}");
                    ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "selectionScript", ScriptHelper.GetScript(selectionScript.ToString()));

                    StringBuilder indexSelection = new StringBuilder();
                    indexSelection.AppendLine("function SelectButtonIndex_" + ClientID + "(index)");
                    indexSelection.AppendLine("{");
                    indexSelection.AppendLine("    var elem = document.getElementById('" + ClientID + "_" + BUTTON_PANEL_SHORTID + "'+index);");
                    indexSelection.AppendLine("    SelectButton(elem);");
                    indexSelection.AppendLine("");
                    indexSelection.AppendLine("}");
                    ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "indexSelection_" + ClientID, ScriptHelper.GetScript(indexSelection.ToString()));
                }

                if (AllowToggle)
                {
                    // Toggle script
                    StringBuilder toggleScript = new StringBuilder();
                    toggleScript.AppendLine("function ToggleButton(elem)");
                    toggleScript.AppendLine("{");
                    toggleScript.AppendLine("    var selected = '" + SelectedSuffix.Trim() + "';");
                    toggleScript.AppendLine("    var jElem =$j(elem);");
                    // Get first parent table
                    toggleScript.AppendLine("    jElem.toggleClass(selected);");
                    toggleScript.AppendLine("}");
                    ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "toggleScript", ScriptHelper.GetScript(toggleScript.ToString()));
                }

                int buttonsCount = Buttons.GetUpperBound(0) + 1;
                InnerControls = new List <Panel>(buttonsCount);
                for (identifier = 0; identifier < buttonsCount; identifier++)
                {
                    // Check array dimensions
                    if (Buttons.GetUpperBound(1) != 8)
                    {
                        Controls.Add(GetError(GetString("unimenubuttons.wrongdimensions")));
                        continue;
                    }

                    string     caption     = Buttons[identifier, 0];
                    string     tooltip     = Buttons[identifier, 1];
                    string     cssClass    = Buttons[identifier, 2];
                    string     onClick     = Buttons[identifier, 3];
                    string     redirectUrl = Buttons[identifier, 4];
                    string     imagePath   = Buttons[identifier, 5];
                    string     alt         = Buttons[identifier, 6];
                    string     align       = Buttons[identifier, 7];
                    string     minWidth    = Buttons[identifier, 8];
                    ImageAlign imageAlign  = ParseImageAlign(align);

                    // Generate button image
                    Image buttonImage = new Image();
                    buttonImage.ID = "img" + identifier;
                    buttonImage.EnableViewState = false;
                    buttonImage.AlternateText   = alt ?? caption;
                    if (!string.IsNullOrEmpty(imagePath))
                    {
                        buttonImage.ImageUrl = ResolveUrl(imagePath);
                    }
                    buttonImage.ImageAlign = imageAlign;

                    // Generate button text
                    Literal captionLiteral = new Literal();
                    captionLiteral.ID = "ltlCaption" + identifier;
                    captionLiteral.EnableViewState = false;
                    string separator = (imageAlign == ImageAlign.Top) ? "<br />" : "\n";
                    captionLiteral.Text = separator + caption;

                    // Generate button link
                    HyperLink buttonLink = new HyperLink();
                    buttonLink.ID = "btn" + identifier;
                    buttonLink.EnableViewState = false;

                    buttonLink.Controls.Add(buttonImage);
                    buttonLink.Controls.Add(captionLiteral);

                    if (!string.IsNullOrEmpty(redirectUrl))
                    {
                        buttonLink.NavigateUrl = ResolveUrl(redirectUrl);
                    }

                    // Generate left border
                    CMSPanel pnlLeft = new CMSPanel();
                    pnlLeft.ID      = "pnlLeft" + identifier;
                    pnlLeft.ShortID = "pl" + identifier;

                    pnlLeft.EnableViewState = false;
                    pnlLeft.CssClass        = "Left" + cssClass;

                    // Generate middle part of button
                    CMSPanel pnlMiddle = new CMSPanel();
                    pnlMiddle.ID      = "pnlMiddle" + identifier;
                    pnlMiddle.ShortID = "pm" + identifier;

                    pnlMiddle.EnableViewState = false;
                    pnlMiddle.CssClass        = "Middle" + cssClass;
                    pnlMiddle.Controls.Add(buttonLink);
                    if (!string.IsNullOrEmpty(minWidth))
                    {
                        pnlMiddle.Style.Add("min-width", minWidth + "px");

                        // IE7 issue with min-width
                        CMSPanel pnlMiddleTmp = new CMSPanel();
                        pnlMiddleTmp.EnableViewState = false;
                        pnlMiddleTmp.Style.Add("width", minWidth + "px");
                        pnlMiddle.Controls.Add(pnlMiddleTmp);
                    }

                    // Generate right border
                    CMSPanel pnlRight = new CMSPanel();
                    pnlRight.ID      = "pnlRight" + identifier;
                    pnlRight.ShortID = "pr" + identifier;

                    pnlRight.EnableViewState = false;
                    pnlRight.CssClass        = "Right" + cssClass;

                    // Generate whole button
                    CMSPanel pnlButton = new CMSPanel();
                    pnlButton.ID      = "pnlButton" + identifier;
                    pnlButton.ShortID = BUTTON_PANEL_SHORTID + identifier;

                    pnlButton.EnableViewState = false;
                    if ((AllowSelection || AllowToggle) && (identifier == SelectedIndex))
                    {
                        cssClass += SelectedSuffix;
                    }

                    pnlButton.CssClass = cssClass;

                    if (AllowToggle)
                    {
                        pnlButton.CssClass += " Toggle";
                    }

                    //Generate button table (IE7 issue)
                    Table     tabButton     = new Table();
                    TableRow  tabRow        = new TableRow();
                    TableCell tabCellLeft   = new TableCell();
                    TableCell tabCellMiddle = new TableCell();
                    TableCell tabCellRight  = new TableCell();

                    tabButton.CellPadding = 0;
                    tabButton.CellSpacing = 0;

                    tabButton.Rows.Add(tabRow);
                    tabRow.Cells.Add(tabCellLeft);
                    tabRow.Cells.Add(tabCellMiddle);
                    tabRow.Cells.Add(tabCellRight);

                    // Add inner controls
                    tabCellLeft.Controls.Add(pnlLeft);
                    tabCellMiddle.Controls.Add(pnlMiddle);
                    tabCellRight.Controls.Add(pnlRight);

                    pnlButton.Controls.Add(tabButton);

                    pnlButton.ToolTip = tooltip ?? caption;

                    if (AllowSelection)
                    {
                        onClick = "SelectButton(this);" + onClick;
                    }
                    else if (AllowToggle)
                    {
                        onClick = "ToggleButton(this);" + onClick;
                    }

                    pnlButton.Attributes["onclick"] = CheckChanges ? "if (CheckChanges()) {" + onClick + "}" : onClick;

                    // In case of horizontal layout
                    if (HorizontalLayout)
                    {
                        // Stack buttons underneath
                        pnlButton.Style.Add("clear", "both");
                    }
                    else
                    {
                        // Stack buttons side-by-sode
                        pnlButton.Style.Add("float", "left");
                    }

                    // Fill collection of buttons
                    InnerControls.Insert(identifier, pnlButton);
                }

                // Calculate number of needed panels
                int panelCount = InnerControls.Count / MaximumItems;
                if ((InnerControls.Count % MaximumItems) > 0)
                {
                    panelCount++;
                }

                // Initialize list of panels
                List <Panel> panels = new List <Panel>();

                Table    tabGroup    = new Table();
                TableRow tabGroupRow = new TableRow();

                tabGroup.CellPadding = 0;
                tabGroup.CellSpacing = 0;
                tabGroup.Rows.Add(tabGroupRow);

                // Fill each panel
                for (int panelIndex = 0; panelIndex < panelCount; panelIndex++)
                {
                    // Create new instance of panel
                    CMSPanel outerPanel = new CMSPanel();
                    outerPanel.EnableViewState = false;
                    outerPanel.ID      = "pnlOuter" + panelIndex;
                    outerPanel.ShortID = "po" + panelIndex;

                    // In case of horizontal layout
                    if (HorizontalLayout)
                    {
                        // Stack panels side-by-side
                        outerPanel.Style.Add("float", "left");
                    }
                    else
                    {
                        // Stack panels underneath
                        outerPanel.Style.Add("clear", "both");
                    }
                    // Add buttons to panel
                    for (int buttonIndex = (panelIndex * MaximumItems); buttonIndex < (panelCount * MaximumItems) + panelCount; buttonIndex++)
                    {
                        if (((buttonIndex % MaximumItems) < MaximumItems) && (InnerControls.Count > buttonIndex))
                        {
                            outerPanel.Controls.Add(InnerControls[buttonIndex]);
                        }
                    }
                    // Add panel to collection of panels
                    panels.Add(outerPanel);
                }

                // Add all panels to control
                foreach (Panel panel in panels)
                {
                    TableCell tabGroupCell = new TableCell();
                    tabGroupCell.VerticalAlign = VerticalAlign.Top;

                    tabGroupCell.Controls.Add(panel);
                    tabGroupRow.Cells.Add(tabGroupCell);
                }

                Controls.Add(tabGroup);
            }
            else
            {
                Controls.Add(GetError(GetString("unimenubuttons.wrongdimensions")));
            }
        }
    }
Ejemplo n.º 36
0
 public static bool IsPressedButton(Buttons b)
 {
     return(b != 0 && CurrentGamepadState.IsButtonDown(b));
 }
Ejemplo n.º 37
0
 public DirectionGamePadButton(Buttons button, PlayerIndex player = PlayerIndex.One, bool leftStick = true) : base(button, player, leftStick)
 {
     _gamePadButton = new GamePadButton(button, player);
 }
Ejemplo n.º 38
0
 public ConfirmationMessage()
 {
     Icon = Toolkit.CurrentEngine.Defaults.MessageDialog.QuestionIcon;
     Buttons.Add(Command.Cancel);
 }
Ejemplo n.º 39
0
 /// <summary>
 /// The button was released between this and last frame (and is still released in the current frame)
 /// </summary>
 /// <param name="button">On button</param>
 /// <returns>True if the button was just released, otherwise false</returns>
 public bool IsJustReleased(Buttons button)
 {
     return(LastFrame.IsButtonDown(button) && CurrentFrame.IsButtonUp(button));
 }
Ejemplo n.º 40
0
 /// <summary>
 /// The button is currently pressed
 /// </summary>
 /// <param name="button">The button</param>
 /// <returns>True if the button is currently pressed, otherwise false</returns>
 public bool IsKeyPressed(Buttons button)
 {
     return(CurrentFrame.IsButtonDown(button));
 }
Ejemplo n.º 41
0
 public KeyPad(Buttons key, int playerIndex)
 {
     this.key         = key;
     this.playerIndex = playerIndex;
 }
Ejemplo n.º 42
0
        void Build()
        {
            Width = 400;
            Title = GettextCatalog.GetString("Add Package Source");
            int labelWidth = 80;

            var mainVBox = new VBox();

            Content = mainVBox;

            // Package source name.
            var packageSourceNameHBox = new HBox();

            mainVBox.PackStart(packageSourceNameHBox);

            var packageSourceNameLabel = new Label();

            packageSourceNameLabel.Text          = GettextCatalog.GetString("Name");
            packageSourceNameLabel.TextAlignment = Alignment.End;
            packageSourceNameLabel.WidthRequest  = labelWidth;
            packageSourceNameHBox.PackStart(packageSourceNameLabel);

            packageSourceNameTextEntry = new TextEntry();
            packageSourceNameHBox.PackEnd(packageSourceNameTextEntry, true);

            // Package source URL.
            var packageSourceUrlHBox = new HBox();

            mainVBox.PackStart(packageSourceUrlHBox);

            var packageSourceUrlLabel = new Label();

            packageSourceUrlLabel.Text          = GettextCatalog.GetString("URL");
            packageSourceUrlLabel.TextAlignment = Alignment.End;
            packageSourceUrlLabel.WidthRequest  = labelWidth;
            packageSourceUrlHBox.PackStart(packageSourceUrlLabel);

            packageSourceUrlTextEntry = new TextEntry();
            packageSourceUrlHBox.PackEnd(packageSourceUrlTextEntry, true);

            // Package source username.
            var packageSourceUserNameHBox = new HBox();

            mainVBox.PackStart(packageSourceUserNameHBox);

            var packageSourceUserNameLabel = new Label();

            packageSourceUserNameLabel.Text          = GettextCatalog.GetString("Username");
            packageSourceUserNameLabel.TextAlignment = Alignment.End;
            packageSourceUserNameLabel.WidthRequest  = labelWidth;
            packageSourceUserNameHBox.PackStart(packageSourceUserNameLabel);

            packageSourceUserNameTextEntry = new TextEntry();
            packageSourceUserNameTextEntry.PlaceholderText = GettextCatalog.GetString("Private sources only");
            packageSourceUserNameHBox.PackEnd(packageSourceUserNameTextEntry, true);

            // Package source password.
            var packageSourcePasswordHBox = new HBox();

            mainVBox.PackStart(packageSourcePasswordHBox);

            var packageSourcePasswordLabel = new Label();

            packageSourcePasswordLabel.Text          = GettextCatalog.GetString("Password");
            packageSourcePasswordLabel.TextAlignment = Alignment.End;
            packageSourcePasswordLabel.WidthRequest  = labelWidth;
            packageSourcePasswordHBox.PackStart(packageSourcePasswordLabel);

            packageSourcePasswordTextEntry = new PasswordEntry();
            packageSourcePasswordTextEntry.PlaceholderText = GettextCatalog.GetString("Private sources only");
            packageSourcePasswordHBox.PackEnd(packageSourcePasswordTextEntry, true);

            // Buttons at bottom of dialog.
            var cancelButton = new DialogButton(Command.Cancel);

            Buttons.Add(cancelButton);

            addPackageSourceButton           = new DialogButton(Command.Ok);
            addPackageSourceButton.Label     = GettextCatalog.GetString("Add Source");
            addPackageSourceButton.Sensitive = false;
            Buttons.Add(addPackageSourceButton);

            savePackageSourceButton         = new DialogButton(Command.Apply);
            savePackageSourceButton.Label   = GettextCatalog.GetString("Save");
            savePackageSourceButton.Visible = false;
            Buttons.Add(savePackageSourceButton);
        }
Ejemplo n.º 43
0
 private void PushButton(Buttons button)
 {
     NativeMethods.SendMessage(this.process.MainWindowHandle, WM_COMMAND, (int)button, 0);
 }
Ejemplo n.º 44
0
 private void AssignButtonMap(Buttons button, IKey iKey)
 {
     this.revButtonMap.Add(iKey, button);
     this.buttonMap.Add(button, iKey);
 }
Ejemplo n.º 45
0
 public bool ButtonDown(Buttons button)
 {
     return(_state.IsButtonDown(button));
 }
Ejemplo n.º 46
0
 public static bool ButtonDown(Buttons button, PlayerIndex index)
 {
     return(GamePadStates[(int)index].IsButtonDown(button));
 }
Ejemplo n.º 47
0
 public bool ButtonClicked(Buttons button)
 {
     return(_state.IsButtonDown(button) && _oldState.IsButtonUp(button));
 }
Ejemplo n.º 48
0
 private static bool ButtonHeld(Buttons button)
 {
     return(_previousGamepadState.IsButtonDown(button) && _currentGamepadState.IsButtonDown(button));
 }
Ejemplo n.º 49
0
        private void HandleInput(Buttons input)
        {
            switch (input)
            {
            case Buttons.Fire:
                if (_P.playerToolCooldown <= 0)
                {
                    switch (_P.playerTools[_P.playerToolSelected])
                    {
                    // Disabled as everyone speed-mines now.
                    //case PlayerTools.Pickaxe:
                    //    if (_P.playerClass != PlayerClass.Miner)
                    //        _P.FirePickaxe();
                    //    break;

                    case PlayerTools.ConstructionGun:
                        _P.FireConstructionGun(_P.playerBlocks[_P.playerBlockSelected]);        //, !(button == MouseButton.LeftButton));//_P.FireConstructionGun(_P.playerBlocks[_P.playerBlockSelected]);
                        break;

                    case PlayerTools.DeconstructionGun:
                        _P.FireDeconstructionGun();
                        break;

                    case PlayerTools.Detonator:
                        _P.PlaySound(InfiniminerSound.ClickHigh);
                        _P.FireDetonator();
                        break;

                    case PlayerTools.ProspectingRadar:
                        _P.FireRadar();
                        break;
                    }
                }
                break;

            case Buttons.Jump:
            {
                Vector3 footPosition = _P.playerPosition + new Vector3(0f, -1.5f, 0f);
                if (_P.blockEngine.SolidAtPointForPlayer(footPosition) && _P.playerVelocity.Y == 0)
                {
                    _P.playerVelocity.Y = JUMPVELOCITY;
                    float amountBelowSurface = ((ushort)footPosition.Y) + 1 - footPosition.Y;
                    _P.playerPosition.Y += amountBelowSurface + 0.01f;
                }
            }
            break;

            case Buttons.ToolUp:
                _P.PlaySound(InfiniminerSound.ClickLow);
                _P.playerToolSelected += 1;
                if (_P.playerToolSelected >= _P.playerTools.Length)
                {
                    _P.playerToolSelected = 0;
                }
                break;

            case Buttons.ToolDown:
                _P.PlaySound(InfiniminerSound.ClickLow);
                _P.playerToolSelected -= 1;
                if (_P.playerToolSelected < 0)
                {
                    _P.playerToolSelected = _P.playerTools.Length;
                }
                break;

            case Buttons.Tool1:
                _P.playerToolSelected = 0;
                _P.PlaySound(InfiniminerSound.ClickLow);
                if (_P.playerToolSelected >= _P.playerTools.Length)
                {
                    _P.playerToolSelected = _P.playerTools.Length - 1;
                }
                break;

            case Buttons.Tool2:
                _P.playerToolSelected = 1;
                _P.PlaySound(InfiniminerSound.ClickLow);
                if (_P.playerToolSelected >= _P.playerTools.Length)
                {
                    _P.playerToolSelected = _P.playerTools.Length - 1;
                }
                break;

            case Buttons.Tool3:
                _P.playerToolSelected = 2;
                _P.PlaySound(InfiniminerSound.ClickLow);
                if (_P.playerToolSelected >= _P.playerTools.Length)
                {
                    _P.playerToolSelected = _P.playerTools.Length - 1;
                }
                break;

            case Buttons.Tool4:
                _P.playerToolSelected = 3;
                _P.PlaySound(InfiniminerSound.ClickLow);
                if (_P.playerToolSelected >= _P.playerTools.Length)
                {
                    _P.playerToolSelected = _P.playerTools.Length - 1;
                }
                break;

            case Buttons.Tool5:
                _P.playerToolSelected = 4;
                _P.PlaySound(InfiniminerSound.ClickLow);
                if (_P.playerToolSelected >= _P.playerTools.Length)
                {
                    _P.playerToolSelected = _P.playerTools.Length - 1;
                }
                break;

            case Buttons.BlockUp:
                if (_P.playerTools[_P.playerToolSelected] == PlayerTools.ConstructionGun)
                {
                    _P.PlaySound(InfiniminerSound.ClickLow);
                    _P.playerBlockSelected += 1;
                    if (_P.playerBlockSelected >= _P.playerBlocks.Length)
                    {
                        _P.playerBlockSelected = 0;
                    }
                }
                break;

            case Buttons.BlockDown:
                if (_P.playerTools[_P.playerToolSelected] == PlayerTools.ConstructionGun)
                {
                    _P.PlaySound(InfiniminerSound.ClickLow);
                    _P.playerBlockSelected -= 1;
                    if (_P.playerBlockSelected < 0)
                    {
                        _P.playerBlockSelected = _P.playerBlocks.Length - 1;
                    }
                }
                break;

            case Buttons.Deposit:
                if (_P.AtBankTerminal())
                {
                    _P.DepositOre();
                    _P.PlaySound(InfiniminerSound.ClickHigh);
                }
                break;

            case Buttons.Withdraw:
                if (_P.AtBankTerminal())
                {
                    _P.WithdrawOre();
                    _P.PlaySound(InfiniminerSound.ClickHigh);
                }
                break;

            case Buttons.Ping:
            {
                NetOutgoingMessage msgBuffer = _P.netClient.CreateMessage();
                msgBuffer.Write((byte)InfiniminerMessage.PlayerPing);
                msgBuffer.Write(_P.playerMyId);
                _P.netClient.SendMessage(msgBuffer, NetDeliveryMethod.ReliableUnordered);
            }
            break;

            case Buttons.ChangeClass:
                nextState = "Infiniminer.States.ClassSelectionState";
                break;

            case Buttons.ChangeTeam:
                nextState = "Infiniminer.States.TeamSelectionState";
                break;

            case Buttons.SayAll:
                _P.chatMode = ChatMessageType.SayAll;
                startChat   = DateTime.Now;
                break;

            case Buttons.SayTeam:
                _P.chatMode = _P.playerTeam == PlayerTeam.Red ? ChatMessageType.SayRedTeam : ChatMessageType.SayBlueTeam;
                startChat   = DateTime.Now;
                break;
            }
        }
Ejemplo n.º 50
0
 public DoubleInput(Node parent, string name, Keys key, Buttons button, PlayerIndex pi)
     : base(parent, name)
 {
     Key    = new KeyboardInput(this, name + "key", key);
     Button = new GamepadInput(this, name + "gamepad", button, pi);
 }
Ejemplo n.º 51
0
        private void load([CanBeNull] IdleTracker idleTracker)
        {
            const float controls_area_height = 25f;

            if (idleTracker != null)
            {
                isIdle.BindTo(idleTracker.IsIdle);
            }

            OsuScrollContainer scrollContainer;

            InternalChildren = new Drawable[]
            {
                ListingPollingComponent = CreatePollingComponent().With(c => c.Filter.BindTarget = filter),
                popoverContainer        = new PopoverContainer
                {
                    Name             = @"Rooms area",
                    RelativeSizeAxes = Axes.Both,
                    Padding          = new MarginPadding
                    {
                        Horizontal = WaveOverlayContainer.WIDTH_PADDING,
                        Top        = Header.HEIGHT + controls_area_height + 20,
                    },
                    Child = scrollContainer = new OsuScrollContainer
                    {
                        RelativeSizeAxes         = Axes.Both,
                        ScrollbarOverlapsContent = false,
                        Child = roomsContainer = new RoomsContainer
                        {
                            Filter       = { BindTarget = filter },
                            SelectedRoom = { BindTarget = SelectedRoom }
                        }
                    },
                },
                loadingLayer = new LoadingLayer(true),
                new FillFlowContainer
                {
                    Name             = @"Header area flow",
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y,
                    Padding          = new MarginPadding {
                        Horizontal = WaveOverlayContainer.WIDTH_PADDING
                    },
                    Direction = FillDirection.Vertical,
                    Children  = new Drawable[]
                    {
                        new Container
                        {
                            RelativeSizeAxes = Axes.X,
                            Height           = Header.HEIGHT,
                            Child            = searchTextBox = new BasicSearchTextBox
                            {
                                Anchor           = Anchor.CentreRight,
                                Origin           = Anchor.CentreRight,
                                RelativeSizeAxes = Axes.X,
                                Width            = 0.6f,
                            },
                        },
                        new Container
                        {
                            RelativeSizeAxes = Axes.X,
                            Height           = controls_area_height,
                            Children         = new Drawable[]
                            {
                                Buttons.WithChild(CreateNewRoomButton().With(d =>
                                {
                                    d.Anchor = Anchor.BottomLeft;
                                    d.Origin = Anchor.BottomLeft;
                                    d.Size   = new Vector2(150, 37.5f);
                                    d.Action = () => Open();
                                })),
                                new FillFlowContainer
                                {
                                    Anchor             = Anchor.TopRight,
                                    Origin             = Anchor.TopRight,
                                    AutoSizeAxes       = Axes.Both,
                                    Direction          = FillDirection.Horizontal,
                                    Spacing            = new Vector2(10),
                                    ChildrenEnumerable = CreateFilterControls().Select(f => f.With(d =>
                                    {
                                        d.Anchor = Anchor.TopRight;
                                        d.Origin = Anchor.TopRight;
                                    }))
                                }
                            }
                        }
                    },
                },
            };

            // scroll selected room into view on selection.
            SelectedRoom.BindValueChanged(val =>
            {
                var drawable = roomsContainer.Rooms.FirstOrDefault(r => r.Room == val.NewValue);
                if (drawable != null)
                {
                    scrollContainer.ScrollIntoView(drawable);
                }
            });
        }
Ejemplo n.º 52
0
 public static bool ButtonPressed(Buttons button, PlayerIndex index)
 {
     return(GamePadStates[(int)index].IsButtonDown(button) &&
            LastGamePadState[(int)index].IsButtonUp(button));
 }
Ejemplo n.º 53
0
        public DialogResult ShowDialog(Control parent)
        {
            Gtk.Window parentWindow = null;
            if (parent != null && parent.ParentWindow != null)
            {
                parentWindow = parent.ParentWindow.ControlObject as Gtk.Window;
            }

            control          = new Gtk.MessageDialog(parentWindow, Gtk.DialogFlags.Modal, Type.ToGtk(), Buttons.ToGtk(), false, Text);
            control.TypeHint = Gdk.WindowTypeHint.Dialog;
            var caption = Caption ?? ((parent != null && parent.ParentWindow != null) ? parent.ParentWindow.Title : null);

            if (!string.IsNullOrEmpty(caption))
            {
                control.Title = caption;
            }
            if (Buttons == MessageBoxButtons.YesNoCancel)
            {
                // must add cancel manually
                var b = (Gtk.Button)control.AddButton(Gtk.Stock.Cancel, (int)Gtk.ResponseType.Cancel);
                b.UseStock = true;
            }
            control.DefaultResponse = DefaultButton.ToGtk(Buttons);
            int ret = control.Run();

            control.Destroy();
            var result = ((Gtk.ResponseType)ret).ToEto();

            if (result == DialogResult.None)
            {
                switch (Buttons)
                {
                case MessageBoxButtons.OK:
                    result = DialogResult.Ok;
                    break;

                case MessageBoxButtons.YesNo:
                    result = DialogResult.No;
                    break;

                case MessageBoxButtons.OKCancel:
                case MessageBoxButtons.YesNoCancel:
                    result = DialogResult.Cancel;
                    break;
                }
            }
            return(result);
        }
 private void AttachMinesToButtons()
 {
     Buttons.Random(MinesTotal).ForEach(i => i.IsMined = true);
 }
Ejemplo n.º 55
0
 public bool IsButtonUp(Buttons key)
 {
     return(GamePad.GetState(Index).IsButtonUp(key));
 }
Ejemplo n.º 56
0
        /// <summary>
        /// Take a button press to navigate the menu.
        /// </summary>
        public override void receiveGamePadButton(Buttons key)
        {
            /* Move back and forth between the pages with the shoulder buttons */
            if ((key == Buttons.LeftShoulder) && this.currentPage > 0)
            {
                this.TaskPageBackButton();
            }

            if ((key == Buttons.RightShoulder && this.currentPage < this.taskPages.Count - 1))
            {
                this.TaskPageForwardButton();
            }



            if (Game1.options.SnappyMenus)
            {
                int oldID = this.currentlySnappedComponent.myID;

                /* When there's no tasks in the list */
                if (!this.taskPages.Any())
                {
                    if (key == Buttons.LeftThumbstickDown)
                    {
                        snapToDefaultClickableComponent();
                    }
                    else if (key == Buttons.LeftThumbstickUp)
                    {
                        this.currentlySnappedComponent = this.getComponentWithID(this.upperRightCloseButton.myID);
                    }
                }
                /* We do actually have tasks */
                else
                {
                    /* Jumping from tasks to close/done button */
                    if (key == Buttons.LeftThumbstickDown)
                    {
                        if (oldID == this.upperRightCloseButton.myID)
                        {
                            snapToDefaultClickableComponent();
                        }
                    }
                    else if (key == Buttons.LeftThumbstickUp)
                    {
                        if (oldID == taskType.doneNamingButton.myID)
                        {
                            this.currentlySnappedComponent = this.getComponentWithID(this.taskPages[currentPage].Count - 1);
                        }
                    }

                    /* Jumping between tasks */
                    if (oldID >= 0 && oldID < tasksPerPage && this.TaskPage == -1)
                    {
                        if (key == Buttons.LeftThumbstickDown)
                        {
                            if (oldID < tasksPerPage - 1 && this.taskPages[this.currentPage].Count - 1 > oldID)
                            {
                                this.currentlySnappedComponent = this.getComponentWithID(oldID + 1);
                            }
                            else
                            {
                                this.currentlySnappedComponent = this.getComponentWithID(taskType.doneNamingButton.myID);
                            }
                        }
                        else if (key == Buttons.LeftThumbstickUp)
                        {
                            if (oldID > 0)
                            {
                                this.currentlySnappedComponent = this.getComponentWithID(oldID - 1);
                            }
                            else if (oldID == 0)
                            {
                                this.currentlySnappedComponent = this.getComponentWithID(upperRightCloseButton.myID);
                            }
                        }
                    }
                }
                this.snapCursorToCurrentSnappedComponent();
            }
        }
Ejemplo n.º 57
0
 public static bool IsHeldButton(Buttons b)
 {
     return(b != 0 && CurrentGamepadState.IsButtonDown(b) && PreviousGamepadState.IsButtonDown(b));
 }
Ejemplo n.º 58
0
 /// <summary>
 /// Checks if a given button is currently held down.
 /// </summary>
 /// <param name="button">The button to check.</param>
 /// <returns>Returns true if the button is held down.</returns>
 public bool IsGamePadHold(Buttons button)
 {
     return(gState.IsButtonDown(button));
 }
Ejemplo n.º 59
0
 public static bool IsNewButtonPress(Buttons b)
 {
     return(b != 0 && CurrentGamepadState.IsButtonDown(b) && PreviousGamepadState.IsButtonUp(b));
 }
Ejemplo n.º 60
0
 public KeyInputData(Buttons key)
 {
     this.Key = key;
 }