Пример #1
0
        public override void HighlightFromOutside(Menu.MenuInputs input)
        {
            switch (input)
            {
            case Menu.MenuInputs.Left:
                selection = new Point(lastSelectableColumn,
                                      GetClosestNumber(selection.Y, selectableRowsInColumn[lastSelectableColumn].ToArray()));
                break;

            case Menu.MenuInputs.Right:
                selection = new Point(firstSelectableColumn,
                                      GetClosestNumber(selection.Y, selectableRowsInColumn[firstSelectableColumn].ToArray()));
                break;

            case Menu.MenuInputs.Up:
                selection = new Point(GetClosestNumber(selection.X,
                                                       selectableColumnsInRow[lastSelectableRow].ToArray()), lastSelectableRow);
                break;

            case Menu.MenuInputs.Down:
                selection = new Point(GetClosestNumber(selection.X,
                                                       selectableColumnsInRow[firstSelectableRow].ToArray()), firstSelectableRow);
                break;
            }
            ghostSelection = selection;
        }
 public virtual void InputTrigger(Menu.MenuInputs input)
 {
     if (input == Menu.MenuInputs.OK)
     {
         OnButtonTrigger?.Invoke(this, Args);
         Action?.Invoke(this, Args);
     }
 }
Пример #3
0
        // returns true if internal, false if out of bounds
        public override bool HandleSelectionChange(Menu.MenuInputs input)
        {
            UIContainer container = SelectedElement as UIContainer;

            if (container != null && container.HandleSelectionChange(input))
            {
                return(true);
            }

            int columnPlus = input == Menu.MenuInputs.Left ? -1 : input == Menu.MenuInputs.Right ? 1 : 0;
            int rowPlus    = input == Menu.MenuInputs.Up ? -1 : input == Menu.MenuInputs.Down ? 1 : 0;

            if (selection.X + columnPlus > lastSelectableColumn || selection.Y + rowPlus > lastSelectableRow ||
                selection.X + columnPlus < firstSelectableColumn || selection.Y + rowPlus < firstSelectableRow)
            {
                return(false);
            }

            if (columnPlus != 0)
            {
                for (int i = selection.X + columnPlus; i <= lastSelectableColumn && i >= firstSelectableColumn; i += columnPlus)
                {
                    if (selectableRowsInColumn.ContainsKey(i))
                    {
                        int selectableRow = GetClosestNumber(ghostSelection.Y, selectableRowsInColumn[i].ToArray());
                        container?.UnhighlightInternal();
                        SelectedElement.Unhighlight();
                        ghostSelection.X = i;
                        ChangeSelection(i, selectableRow);
                        container = SelectedElement as UIContainer;
                        container?.HighlightFromOutside(input);
                        SelectedElement.Highlight();
                        container?.HighlightInternal();
                        break;
                    }
                }
            }
            else if (rowPlus != 0)
            {
                for (int i = selection.Y + rowPlus; i <= lastSelectableRow && i >= firstSelectableRow; i += rowPlus)
                {
                    if (selectableColumnsInRow.ContainsKey(i))
                    {
                        int selectableColumn = GetClosestNumber(ghostSelection.X, selectableColumnsInRow[i].ToArray());
                        container?.UnhighlightInternal();
                        SelectedElement.Unhighlight();
                        ghostSelection.Y = i;
                        ChangeSelection(selectableColumn, i);
                        container = SelectedElement as UIContainer;
                        container?.HighlightFromOutside(input);
                        SelectedElement.Highlight();
                        container?.HighlightInternal();
                        break;
                    }
                }
            }
            return(true);
        }
Пример #4
0
 public void InputTrigger(Menu.MenuInputs input)
 {
     if (KeyboardInputEnabled)
     {
         for (int i = 0; i < menus.Count; i++)
         {
             menus[i].InputTrigger(input);
         }
     }
 }
Пример #5
0
 public override void InputTrigger(Menu.MenuInputs input)
 {
     if (IsSelectable)
     {
         if (input == Menu.MenuInputs.OK)
         {
             SelectedElement.InputTrigger(input);
         }
         else
         {
             HandleSelectionChange(input);
         }
     }
 }
Пример #6
0
 public OutOfBoundsSelectionEventArgs(Menu.MenuInputs inputDirection)
 {
     this.InputDirection = inputDirection;
 }
 public abstract void HighlightFromOutside(Menu.MenuInputs input);
 /// <returns>True if within container bounds, false if not</returns>
 public abstract bool HandleSelectionChange(Menu.MenuInputs input);