Exemple #1
0
 /// <summary>
 /// Forward input to the given focusable object.
 /// </summary>
 public void ForwardInput(GameTime gameTime, Focusable focusable)
 {
     ValidateMatchingFocusIndex(focusable);
     GamePadState gamePadState = game.GetGamePadState(focusIndex);
     Input(gameTime, focusable);
     DirectionsInput(gameTime, ref gamePadState, focusable);
     SemanticButtonsInput(gameTime, ref gamePadState, focusable);
 }
Exemple #2
0
 private void DirectionDownRepeat(GameTime gameTime, Direction2D direction, Focusable focusable)
 {
     directionPressedElapsedTime[(int)direction] += (float)gameTime.ElapsedGameTime.TotalSeconds;
     if (directionPressedElapsedTime[(int)direction] <= repeatRate.FirstDelay) return;
     directionPressedElapsedTime2[(int)direction] += (float)gameTime.ElapsedGameTime.TotalSeconds;
     if (directionPressedElapsedTime2[(int)direction] <= repeatRate.RepeatDelay) return;
     directionPressedElapsedTime2[(int)direction] = 0;
     focusable.NotifyDirectionInput(gameTime, InputType.Repeat, direction);
 }
Exemple #3
0
 private void DirectionsInput(GameTime gameTime, ref GamePadState gamePadState, Focusable focusable)
 {
     for (Direction2D direction = 0; direction < Direction2D.Count; ++direction)
     {
         if (!focusable.Focused) break;
         ButtonState directionButtonState = inputRouter.GetDirectionState(direction, ref gamePadState);
         DirectionInput(gameTime, direction, directionButtonState, focusable);
     }
 }
Exemple #4
0
 private void DirectionInput(GameTime gameTime, Direction2D direction, ButtonState directionButtonState, Focusable focusable)
 {
     if (directionButtonState == ButtonState.Pressed)
     {
         if (isDirectionPressed[(int)direction] != ButtonState.Pressed) focusable.NotifyDirectionInput(gameTime, InputType.ClickDown, direction);
         DirectionDownRepeat(gameTime, direction, focusable);
         focusable.NotifyDirectionInput(gameTime, InputType.Down, direction);
     }
     else if (directionButtonState != ButtonState.Pressed)
     {
         if (isDirectionPressed[(int)direction] == ButtonState.Pressed)
         {
             DirectionUp(direction);
             focusable.NotifyDirectionInput(gameTime, InputType.ClickUp, direction);
         }
         // OPTIMIZATION: this functionality is not worth the speed cost
         //DirectionUpRepeat(gameTime, direction);
         //screen.NotifyDirectionInput(gameTime, InputType.Up, direction);
     }
     isDirectionPressed[(int)direction] = directionButtonState;
 }
Exemple #5
0
 private void SemanticButtonInput(GameTime gameTime, SemanticButtonType type, ref GamePadState gamePadState, Focusable focusable)
 {
     ButtonState state = inputRouter.GetSemanticButtonState(type, ref gamePadState);
     if (state == ButtonState.Pressed)
     {
         if (isSemanticButtonPressed[(int)type] != ButtonState.Pressed) SemanticButtonInput(gameTime, type, InputType.ClickDown, focusable);
         SemanticButtonDownRepeat(gameTime, type, focusable);
         SemanticButtonInput(gameTime, type, InputType.Down, focusable);
     }
     else if (state != ButtonState.Pressed)
     {
         if (isSemanticButtonPressed[(int)type] == ButtonState.Pressed)
         {
             SemanticButtonUp(type);
             SemanticButtonInput(gameTime, type, InputType.ClickUp, focusable);
         }
         // OPTIMIZATION: this functionality is not worth the speed cost
         //SemanticButtonUpRepeat(type);
         //SemanticButtonInput(type, InputType.Up);
     }
     isSemanticButtonPressed[(int)type] = state;
 }
Exemple #6
0
 private void SemanticButtonsInput(GameTime gameTime, ref GamePadState gamePadState, Focusable focusable)
 {
     for (SemanticButtonType semantic = 0; semantic < SemanticButtonType.Count; ++semantic)
     {
         if (!focusable.Focused) break;
         SemanticButtonInput(gameTime, semantic, ref gamePadState, focusable);
     }
 }
Exemple #7
0
 private void Input(GameTime gameTime, Focusable focusable)
 {
     focusable.Input(gameTime);
 }
Exemple #8
0
 private void ValidateMatchingFocusIndex(Focusable focusable)
 {
     if (focusable.FocusIndex != focusIndex)
         throw new ArgumentException("Focusable does not match InputForwarder's input index.");
 }
Exemple #9
0
 private void SemanticButtonDownRepeat(GameTime gameTime, SemanticButtonType type, Focusable focusable)
 {
     semanticButtonPressedElapsedTime[(int)type] += (float)gameTime.ElapsedGameTime.TotalSeconds;
     if (semanticButtonPressedElapsedTime[(int)type] <= repeatRate.FirstDelay) return;
     semanticButtonPressedElapsedTime2[(int)type] += (float)gameTime.ElapsedGameTime.TotalSeconds;
     if (semanticButtonPressedElapsedTime2[(int)type] <= repeatRate.RepeatDelay) return;
     semanticButtonPressedElapsedTime2[(int)type] = 0;
     SemanticButtonInput(gameTime, type, InputType.Repeat, focusable);
 }
Exemple #10
0
 private void SemanticButtonInput(GameTime gameTime, SemanticButtonType type, InputType inputType, Focusable focusable)
 {
     switch (type)
     {
         case SemanticButtonType.AffirmButton: focusable.NotifySemanticInput(gameTime, inputType, SemanticInputType.Affirm); break;
         case SemanticButtonType.CancelButton: focusable.NotifySemanticInput(gameTime, inputType, SemanticInputType.Cancel); break;
         case SemanticButtonType.NextPageButton: focusable.NotifySemanticInput(gameTime, inputType, SemanticInputType.NextPage); break;
         case SemanticButtonType.PreviousPageButton: focusable.NotifySemanticInput(gameTime, inputType, SemanticInputType.PreviousPage); break;
     }
 }
Exemple #11
0
 /// <summary>
 /// Set an object focused by the given focus index.
 /// </summary>
 internal void SetFocusedObject(Focusable focusable, PlayerIndex focusIndex)
 {
     FocusDescriptor focusDescriptor = focusDescriptors[(int)focusIndex];
     focusDescriptor.FocusedObject = focusable;
 }