private void MakeEventArgs(out EventArgs args, int itemIndex, MySharedButtonsEnum button)
 {
     args.ItemIndex   = itemIndex;
     args.RowIndex    = ComputeRow(itemIndex);
     args.ColumnIndex = ComputeColumn(itemIndex);
     args.Button      = button;
 }
 private void HandleMouseDrag(ref MyGuiControlBase captureInput, MySharedButtonsEnum button, ref bool isDragging)
 {
     if (MyInput.Static.IsNewButtonPressed(button))
     {
         isDragging = true;
         m_mouseDragStartPosition = MyGuiManager.MouseCursorPosition;
     }
     else if (MyInput.Static.IsButtonPressed(button))
     {
         if (isDragging && SelectedItem != null)
         {
             Vector2 mouseDistanceFromLastUpdate = MyGuiManager.MouseCursorPosition - m_mouseDragStartPosition;
             if (mouseDistanceFromLastUpdate.Length() != 0.0f)
             {
                 if (ItemDragged != null)
                 {
                     var dragIdx = ComputeIndex(MyGuiManager.MouseCursorPosition);
                     if (IsValidIndex(dragIdx) && GetItemAt(dragIdx) != null)
                     {
                         EventArgs args;
                         MakeEventArgs(out args, dragIdx, button);
                         ItemDragged(this, args);
                     }
                 }
                 isDragging = false;
             }
             captureInput = this;
         }
     }
     else
     {
         isDragging = false;
     }
 }
Exemplo n.º 3
0
 private void HandleButtonClickDrop(MySharedButtonsEnum button, ref MyGuiControlBase captureInput)
 {
     if (MyInput.Static.IsNewButtonPressed(button))
     {
         HandleDropingItem();
         captureInput = this;
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Starts dragging item
 /// </summary>
 /// <param name="dropHandleType">On which action released drop event</param>
 /// <param name="draggingItem">Item which is dragging</param>
 /// <param name="draggingFrom">Information about item's origin</param>
 public void StartDragging(MyDropHandleType dropHandleType, MySharedButtonsEnum dragButton, MyGuiControlGrid.Item draggingItem, MyDragAndDropInfo draggingFrom, bool includeTooltip = true)
 {
     m_currentDropHandleType = dropHandleType;
     m_dragButton            = dragButton;
     m_draggingGridItem      = draggingItem;
     m_draggingFrom          = draggingFrom;
     m_toolTip = (includeTooltip) ? draggingItem.ToolTip : null;
 }
Exemplo n.º 5
0
 bool ModAPI.IMyInput.IsButtonReleased(MySharedButtonsEnum button)
 {
     return(((IMyInput)this).IsButtonReleased(button));
 }
Exemplo n.º 6
0
 bool ModAPI.IMyInput.IsNewButtonPressed(MySharedButtonsEnum button)
 {
     return(((IMyInput)this).IsNewButtonPressed(button));
 }
 bool ModAPI.IMyInput.IsNewButtonReleased(MySharedButtonsEnum button)
 {
     return(IsNewButtonReleased(button));
 }
Exemplo n.º 8
0
 bool ModAPI.IMyInput.IsNewButtonReleased(MySharedButtonsEnum button) { return ((IMyInput)this).IsNewButtonReleased(button); }
 bool ModAPI.IMyInput.IsNewButtonPressed(MySharedButtonsEnum button) { return IsNewButtonPressed(button); }
Exemplo n.º 10
0
 bool IMyInput.IsNewButtonPressed(MySharedButtonsEnum button) { return false; }
Exemplo n.º 11
0
 public bool IsNewButtonPressed(MySharedButtonsEnum button)
 {
     switch (button)
     {
         case MySharedButtonsEnum.Primary:
             return IsNewPrimaryButtonPressed();
         case MySharedButtonsEnum.Secondary:
             return IsNewSecondaryButtonPressed();
     }
     return false;
 }
Exemplo n.º 12
0
 bool IMyInput.IsButtonReleased(MySharedButtonsEnum button)
 {
     return(false);
 }
Exemplo n.º 13
0
 bool IMyInput.IsNewButtonPressed(MySharedButtonsEnum button)
 {
     return(false);
 }
Exemplo n.º 14
0
        private void HandleNewMousePress(ref MyGuiControlBase captureInput)
        {
            bool cursorInItems = m_itemsRectangle.Contains(MyGuiManager.MouseCursorPosition);

            if (MyInput.Static.IsNewPrimaryButtonReleased() || MyInput.Static.IsNewSecondaryButtonReleased())
            {
                if (cursorInItems)
                {
                    int?mouseOverIndex = ComputeIndex(MyGuiManager.MouseCursorPosition);
                    if (!IsValidIndex(mouseOverIndex.Value))
                    {
                        mouseOverIndex = null;
                    }

                    SelectMouseOverItem(mouseOverIndex);

                    if (SelectedIndex.HasValue && m_itemClicked.HasValue && m_lastClick.HasValue && mouseOverIndex.HasValue)
                    {
                        if (MyGuiManager.TotalTimeInMilliseconds - m_lastClick.Value < MyGuiConstants.CLICK_RELEASE_DELAY && m_itemClicked.Value.ItemIndex == mouseOverIndex.Value)
                        {
                            captureInput = this;
                            MySharedButtonsEnum button = MySharedButtonsEnum.None;
                            if (MyInput.Static.IsNewPrimaryButtonReleased())
                            {
                                button = MySharedButtonsEnum.Primary;
                            }
                            else if (MyInput.Static.IsNewSecondaryButtonReleased())
                            {
                                button = MySharedButtonsEnum.Secondary;
                            }

                            EventArgs args;
                            MakeEventArgs(out args, SelectedIndex.Value, button);

                            var handler = ItemReleased;
                            if (handler != null)
                            {
                                handler(this, args);
                            }
                        }
                    }
                }
                m_itemClicked = null;
                m_lastClick   = null;
            }

            if (MyInput.Static.IsAnyNewMouseOrJoystickPressed() && cursorInItems)
            {
                m_lastClick = MyGuiManager.TotalTimeInMilliseconds;

                int?mouseOverIndex = ComputeIndex(MyGuiManager.MouseCursorPosition);
                if (!IsValidIndex(mouseOverIndex.Value))
                {
                    mouseOverIndex = null;
                }
                SelectMouseOverItem(mouseOverIndex);

                captureInput = this;
                if (SelectedIndex.HasValue && (ItemClicked != null || ItemClickedWithoutDoubleClick != null))
                {
                    MySharedButtonsEnum button = MySharedButtonsEnum.None;
                    if (MyInput.Static.IsNewPrimaryButtonPressed())
                    {
                        button = MySharedButtonsEnum.Primary;
                    }
                    else if (MyInput.Static.IsNewSecondaryButtonPressed())
                    {
                        button = MySharedButtonsEnum.Secondary;
                    }

                    EventArgs args;
                    MakeEventArgs(out args, SelectedIndex.Value, button);
                    var handler = ItemClicked;
                    if (handler != null)
                    {
                        handler(this, args);
                    }

                    m_singleClickEvents = args;
                    m_itemClicked       = args;

                    if (MyInput.Static.IsAnyCtrlKeyPressed() || MyInput.Static.IsAnyShiftKeyPressed())
                    {
                        MyGuiSoundManager.PlaySound(GuiSounds.Item);
                    }
                }
            }

            if (MyInput.Static.IsNewPrimaryButtonPressed() && cursorInItems)
            {
                if (!m_doubleClickStarted.HasValue)
                {
                    m_doubleClickStarted       = MyGuiManager.TotalTimeInMilliseconds;
                    m_doubleClickFirstPosition = MyGuiManager.MouseCursorPosition;
                }
                else if ((MyGuiManager.TotalTimeInMilliseconds - m_doubleClickStarted.Value) <= MyGuiConstants.DOUBLE_CLICK_DELAY &&
                         (m_doubleClickFirstPosition - MyGuiManager.MouseCursorPosition).Length() <= 0.005f)
                {
                    if (SelectedIndex.HasValue && TryGetItemAt(SelectedIndex.Value) != null && ItemDoubleClicked != null)
                    {
                        //Cancel click event when we double click
                        m_singleClickEvents = null;

                        EventArgs args;
                        MakeEventArgs(out args, SelectedIndex.Value, MySharedButtonsEnum.Primary);
                        Debug.Assert(GetItemAt(args.ItemIndex) != null, "Double click should not be reported when clicking on empty position.");
                        ItemDoubleClicked(this, args);
                        MyGuiSoundManager.PlaySound(GuiSounds.Item);
                    }

                    m_doubleClickStarted = null;
                    captureInput         = this;
                }
            }
        }
 private void MakeEventArgs(out EventArgs args, int itemIndex, MySharedButtonsEnum button)
 {
     args.ItemIndex = itemIndex;
     args.RowIndex = ComputeRow(itemIndex);
     args.ColumnIndex = ComputeColumn(itemIndex);
     args.Button = button;
 }
 /// <summary>
 /// Starts dragging item
 /// </summary>
 /// <param name="dropHandleType">On which action released drop event</param>
 /// <param name="draggingItem">Item which is dragging</param>
 /// <param name="draggingFrom">Information about item's origin</param>
 public void StartDragging(MyDropHandleType dropHandleType, MySharedButtonsEnum dragButton, MyGuiControlGrid.Item draggingItem, MyDragAndDropInfo draggingFrom, bool includeTooltip = true)
 {
     m_currentDropHandleType = dropHandleType;
     m_dragButton = dragButton;
     m_draggingGridItem = draggingItem;
     m_draggingFrom = draggingFrom;
     m_toolTip = (includeTooltip) ? draggingItem.ToolTip : null;
 }
 private void HandleMouseDrag(ref MyGuiControlBase captureInput, MySharedButtonsEnum button, ref bool isDragging)
 {
     if (MyInput.Static.IsNewButtonPressed(button))
     {
         isDragging = true;
         m_mouseDragStartPosition = MyGuiManager.MouseCursorPosition;
     }
     else if (MyInput.Static.IsButtonPressed(button))
     {
         if (isDragging && SelectedItem != null)
         {
             Vector2 mouseDistanceFromLastUpdate = MyGuiManager.MouseCursorPosition - m_mouseDragStartPosition;
             if (mouseDistanceFromLastUpdate.Length() != 0.0f)
             {
                 if (ItemDragged != null)
                 {
                     var dragIdx = ComputeIndex(MyGuiManager.MouseCursorPosition);
                     if (IsValidIndex(dragIdx) && GetItemAt(dragIdx) != null)
                     {
                         EventArgs args;
                         MakeEventArgs(out args, dragIdx, button);
                         ItemDragged(this, args);
                     }
                 }
                 isDragging = false;
             }
             captureInput = this;
         }
     }
     else
     {
         isDragging = false;
     }
 }
 private void HandleButtonPressedDrop(MySharedButtonsEnum button, ref MyGuiControlBase captureInput)
 {
     if (MyInput.Static.IsButtonPressed(button))
         captureInput = this;
     else
         HandleDropingItem();
 }
Exemplo n.º 19
0
 public bool IsButtonReleased(MySharedButtonsEnum button)
 {
     switch (button)
     {
         case MySharedButtonsEnum.Primary:
             return IsPrimaryButtonReleased();
         case MySharedButtonsEnum.Secondary:
             return IsSecondaryButtonReleased();
     }
     return false;
 }
 private void HandleButtonClickDrop(MySharedButtonsEnum button, ref MyGuiControlBase captureInput)
 {
     if (MyInput.Static.IsNewButtonPressed(button))
     {
         HandleDropingItem();
         captureInput = this;
     }
 }
Exemplo n.º 21
0
 bool IMyInput.IsButtonReleased(MySharedButtonsEnum button) { return false; }
 bool ModAPI.IMyInput.IsButtonPressed(MySharedButtonsEnum button)
 {
     return(IsButtonPressed(button));
 }
Exemplo n.º 23
0
 bool ModAPI.IMyInput.IsButtonReleased(MySharedButtonsEnum button) { return IsButtonReleased(button); }
Exemplo n.º 24
0
 bool ModAPI.IMyInput.IsButtonPressed(MySharedButtonsEnum button) { return ((IMyInput)this).IsButtonPressed(button); }