Пример #1
0
        public override bool HandleInput(MyGuiInput input, bool hasKeyboardActiveControl, bool hasKeyboardActiveControlPrevious, bool receivedFocusInThisUpdate)
        {
            bool baseResult = base.HandleInput(input, hasKeyboardActiveControl, hasKeyboardActiveControlPrevious, receivedFocusInThisUpdate);

            bool captured = false;
            var deltaWheel = input.DeltaMouseScrollWheelValue();
            if (IsMouseOver() && deltaWheel != 0)
            {
                m_verticalScrollbar.ChangeValue(-0.0005f * deltaWheel);
                captured = true;
            }

            bool capturedScrollbar = m_verticalScrollbar.HandleInput(input, hasKeyboardActiveControl, hasKeyboardActiveControlPrevious, receivedFocusInThisUpdate);

            return baseResult || capturedScrollbar || captured;
        }
Пример #2
0
        public override bool HandleInput(MyGuiInput input, bool hasKeyboardActiveControl, bool hasKeyboardActiveControlPrevious, bool receivedFocusInThisUpdate)
        {
            bool baseResult = base.HandleInput(input, hasKeyboardActiveControl, hasKeyboardActiveControlPrevious, receivedFocusInThisUpdate);

            bool captured   = false;
            var  deltaWheel = input.DeltaMouseScrollWheelValue();

            if (IsMouseOver() && deltaWheel != 0)
            {
                m_scrollbar.ChangeValue(-0.0005f * deltaWheel);
                captured = true;
            }

            bool capturedScrollbar = m_scrollbar.HandleInput(input, hasKeyboardActiveControl, hasKeyboardActiveControlPrevious, receivedFocusInThisUpdate);

            return(baseResult || capturedScrollbar || captured);
        }
        public override void HandleInput(MyGuiInput input, bool receivedFocusInThisUpdate)
        {
            base.HandleInput(input, receivedFocusInThisUpdate);

            if (MyGuiInput.ENABLE_DEVELOPER_KEYS)
            {
                if (input.IsNewKeyPress(Keys.C) && input.IsAnyCtrlKeyPressed())
                {
                    CopySector();
                }
                if (input.IsNewKeyPress(Keys.V) && input.IsAnyCtrlKeyPressed())
                {
                    PasteSector();
                }
            }


            if (MyFakes.DRAW_FACTION_AREAS_IN_SOLAR_MAP)
            {
                MySolarMapAreaInput.HandleInput(m_solarMapRender, input, receivedFocusInThisUpdate);
            }

            float   rollIndicator     = input.GetRoll();
            Vector2 rotationIndicator = Vector2.Zero;

            if (input.IsNewRightMousePressed() && MyVideoModeManager.IsHardwareCursorUsed())
            {
                m_oldRotationIndicator = input.GetRotation();
            }

            if (input.IsRightMousePressed())
            {
                if (MyVideoModeManager.IsHardwareCursorUsed())
                {
                    rotationIndicator      = m_oldRotationIndicator - input.GetRotation();
                    m_oldRotationIndicator = input.GetRotation();
                }
                else
                {
                    rotationIndicator = input.GetRotation();
                }
            }
            Vector3 moveIndicator = input.GetPositionDelta();

            if (input.IsKeyPress(Keys.Left))
            {
                moveIndicator.X = -1;
            }
            if (input.IsKeyPress(Keys.Right))
            {
                moveIndicator.X = 1;
            }
            if (input.IsKeyPress(Keys.Up))
            {
                moveIndicator.Z = -1;
            }
            if (input.IsKeyPress(Keys.Down))
            {
                moveIndicator.Z = 1;
            }

            m_camera.Zoom(input.DeltaMouseScrollWheelValue());

            m_camera.MoveAndRotate(moveIndicator, rotationIndicator, rollIndicator, 1);


            bool sectorChanged = false;

            if (m_lastSector != m_camera.TargetSector)
            {
                sectorChanged = true;
                m_lastSector  = m_camera.TargetSector;
            }



            MySolarSystemMapNavigationMark navigationMarkUnderMouse = GetNearestNavigationMarkUnderMouseCursor();

            const float maxHeightForEnter = MySolarSystemMapCamera.SECTOR_SIZE_GAMEUNITS * 16;

            if (sectorChanged) // we have moved camera so deselect sector
            {
                m_selectedSector = null;
            }


            // tool tips
            if (m_lastNavigationMarkUnderMouse != navigationMarkUnderMouse)
            {
                m_toolTip.ClearToolTips();
                if (navigationMarkUnderMouse != null)
                {
                    m_toolTip.AddToolTip(new StringBuilder(GetSectorName(navigationMarkUnderMouse)));
                    if (!String.IsNullOrEmpty(navigationMarkUnderMouse.Description))
                    {
                        m_toolTip.AddToolTip(new StringBuilder(navigationMarkUnderMouse.Description), Color.LightGray);
                    }
                    m_toolTip.AddToolTip(new StringBuilder(navigationMarkUnderMouse.Sector.ToString()), Color.LightGray);
                }
                m_lastNavigationMarkUnderMouse = navigationMarkUnderMouse;
            }



            if (navigationMarkUnderMouse != null)
            {
                MyGuiManager.SetMouseCursorTexture(MyGuiManager.GetMouseCursorHandTexture());

                if (input.IsNewLeftMousePressed() && !m_travelButton.IsMouseOver())
                {
                    MyAudio.AddCue2D(MySoundCuesEnum.GuiMouseClick);
                    if (m_selectedNavigationMark != null)
                    {
                        m_selectedNavigationMark.Highlight = false;
                    }

                    m_selectedNavigationMark           = navigationMarkUnderMouse;
                    m_selectedNavigationMark.Highlight = true;
                    sectorChanged          = true;
                    m_slectionLocked       = true;
                    m_travelButton.Visible = false;
                }
                if (input.IsNewLeftMouseDoubleClick())
                {
                    TravelToSector(navigationMarkUnderMouse.Sector, navigationMarkUnderMouse.MissionID);
                }
            }
            else if (m_camera.CameraDistance < maxHeightForEnter && !m_slectionLocked)
            {
                if (MyGuiScreenGamePlay.CanTravelToSector(m_camera.TargetSector))
                {
                    //MyGuiManager.SetMouseCursorTexture(MyGuiManager.GetMouseCursorHandTexture());
                    if (m_selectedNavigationMark != null)
                    {
                        m_selectedNavigationMark.Highlight = false;
                    }

                    var navigationMarkUnderCamera = GetNavigationMarkUnderCamera();
                    if (navigationMarkUnderCamera != null && navigationMarkUnderCamera.Sector == m_camera.TargetSector)
                    {
                        m_selectedNavigationMark = navigationMarkUnderCamera;
                    }
                    else
                    {
                        m_selectedNavigationMark = new MySolarSystemMapNavigationMark(m_camera.TargetSector, "");
                        m_travelButton.Visible   = false;
                    }
                }
                else
                {
                    m_selectedNavigationMark = null;
                }
            }
            else if (input.IsNewLeftMousePressed())
            {
                if (m_selectedNavigationMark != null)
                {
                    m_selectedNavigationMark.Highlight = false;
                }
                if (!m_travelButton.IsMouseOver())
                {
                    m_selectedNavigationMark = null;
                }
                m_slectionLocked = false;
            }
            else if (sectorChanged && m_camera.CameraDistance > maxHeightForEnter && !m_slectionLocked)
            {
                m_selectedNavigationMark = null;
            }
            else
            {
                MyGuiManager.SetMouseCursorTexture(MyGuiManager.GetMouseCursorArrowTexture());
            }



            if (m_selectedNavigationMark != null)
            {
                if (!m_travelButton.Visible)
                {
                    m_travelButton.Text.Clear();
                    string text = GetSectorName(m_selectedNavigationMark);
                    if (text.Length > 21)
                    {
                        text  = text.Substring(0, 20);
                        text += "…";
                    }
                    m_travelButton.Text.Append(MyTextsWrapper.GetFormatString(MyTextsWrapperEnum.TravelTo, text));
                    //                    float width = MyGuiManager.GetNormalizedSize( MyGuiManager.GetFontMinerWarsBlue(), m_travelButton.Text, 1).X + 0.05f;
                    //  m_travelButton.SetSize(new Vector2(width, MyGuiConstants.BACK_BUTTON_SIZE.Y));
                    m_travelButton.Visible = true;
                }
            }
            else
            {
                m_travelButton.Visible = false;
            }
        }
Пример #4
0
        public bool HandleInput(MyGuiInput input, bool hasKeyboardActiveControl, bool hasKeyboardActiveControlPrevious, bool receivedFocusInThisUpdate)
        {
            var oldHooveredItem = HooveredItem;

            HooveredItem = null;

            bool captured =
                m_body.HandleInput(input, hasKeyboardActiveControl, hasKeyboardActiveControlPrevious, receivedFocusInThisUpdate) ||
                m_vScrollbar.HandleInput(input, hasKeyboardActiveControl, hasKeyboardActiveControlPrevious, receivedFocusInThisUpdate) ||
                m_hScrollbar.HandleInput(input, hasKeyboardActiveControl, hasKeyboardActiveControlPrevious, receivedFocusInThisUpdate);

            if (hasKeyboardActiveControl)
            {
                if (FocusedItem == null &&
                    m_body.GetItemCount() > 0 &&
                    (input.IsNewKeyPress(Keys.Up) ||
                     input.IsNewKeyPress(Keys.Down) ||
                     input.IsNewKeyPress(Keys.Left) ||
                     input.IsNewKeyPress(Keys.Right) ||
                     input.DeltaMouseScrollWheelValue() != 0))
                {
                    FocusItem(m_body[0]);
                }
                else if (FocusedItem != null)
                {
                    if (input.IsNewKeyPress(Keys.Down) || (input.DeltaMouseScrollWheelValue() < 0 && Contains(MyGuiManager.MouseCursorPosition.X, MyGuiManager.MouseCursorPosition.Y)))
                    {
                        FocusItem(NextVisible(m_body, FocusedItem));
                    }

                    if (input.IsNewKeyPress(Keys.Up) || (input.DeltaMouseScrollWheelValue() > 0 && Contains(MyGuiManager.MouseCursorPosition.X, MyGuiManager.MouseCursorPosition.Y)))
                    {
                        FocusItem(PrevVisible(m_body, FocusedItem));
                    }

                    if (input.IsNewKeyPress(Keys.Right))
                    {
                        if (FocusedItem.GetItemCount() > 0)
                        {
                            if (!FocusedItem.IsExpanded)
                            {
                                FocusedItem.IsExpanded = true;
                            }
                            else
                            {
                                var next = NextVisible(FocusedItem, FocusedItem);
                                FocusItem(next);
                            }
                        }
                    }

                    if (input.IsNewKeyPress(Keys.Left))
                    {
                        if (FocusedItem.GetItemCount() > 0 && FocusedItem.IsExpanded)
                        {
                            FocusedItem.IsExpanded = false;
                        }
                        else if (FocusedItem.Parent is MyTreeViewItem)
                        {
                            FocusItem(FocusedItem.Parent as MyTreeViewItem);
                        }
                    }

                    if (FocusedItem.GetItemCount() > 0)
                    {
                        if (input.IsNewKeyPress(Keys.Add))
                        {
                            FocusedItem.IsExpanded = true;
                        }

                        if (input.IsNewKeyPress(Keys.Subtract))
                        {
                            FocusedItem.IsExpanded = false;
                        }
                    }
                }

                if (input.IsNewKeyPress(Keys.PageDown))
                {
                    m_vScrollbar.PageDown();
                }

                if (input.IsNewKeyPress(Keys.PageUp))
                {
                    m_vScrollbar.PageUp();
                }

                captured = captured ||
                           input.IsNewKeyPress(Keys.PageDown) ||
                           input.IsNewKeyPress(Keys.PageUp) ||
                           input.IsNewKeyPress(Keys.Down) ||
                           input.IsNewKeyPress(Keys.Up) ||
                           input.IsNewKeyPress(Keys.Left) ||
                           input.IsNewKeyPress(Keys.Right) ||
                           input.IsNewKeyPress(Keys.Add) ||
                           input.IsNewKeyPress(Keys.Subtract) ||
                           input.DeltaMouseScrollWheelValue() != 0;
            }

            // Hoovered item changed
            if (HooveredItem != oldHooveredItem)
            {
                m_control.ShowToolTip(HooveredItem == null ? null : HooveredItem.ToolTip);
                MyAudio.AddCue2D(MySoundCuesEnum.GuiMouseOver);
            }

            return(captured);
        }
Пример #5
0
        void HandleMouseWheelScroll(MyGuiInput input, ref bool captureInput)
        {
            // MouseWheel movement
            int deltaMouseScrollValue = input.DeltaMouseScrollWheelValue();

            // MouseWheel scroll with scrollbar
            if (m_verticalScrollBar != null)
            {
                bool rowsOffsetChanged = false;
                if (deltaMouseScrollValue < 0)
                {
                    m_rowsOffset = Math.Min(
                        m_rowsOffset + 1, Math.Max(m_rows.Count - m_displayRowsCount, 0));
                    rowsOffsetChanged = true;
                }
                else if (deltaMouseScrollValue > 0)
                {
                    m_rowsOffset = Math.Max(m_rowsOffset - 1, 0);
                    rowsOffsetChanged = true;
                }

                if (rowsOffsetChanged)
                {
                    SetScrollValueByOffset(m_verticalScrollBar, m_rowsOffset, m_displayRowsCount);
                    captureInput = true;
                }
            }
            else // MouseWheel movement
            {
                if (deltaMouseScrollValue < 0)
                {
                    //this.MovePreselected(true, false, true);
                    MovePreselected(true, true);
                    captureInput = true;
                }
                else if (deltaMouseScrollValue > 0)
                {
                    //this.MovePreselected(false, false, true);
                    MovePreselected(false, true);
                    captureInput = true;
                }
            }
        }
Пример #6
0
        public bool HandleInput(MyGuiInput input, bool hasKeyboardActiveControl, bool hasKeyboardActiveControlPrevious, bool receivedFocusInThisUpdate)
        {
            var oldHooveredItem = HooveredItem;
            HooveredItem = null;

            bool captured =
                m_body.HandleInput(input, hasKeyboardActiveControl, hasKeyboardActiveControlPrevious, receivedFocusInThisUpdate) ||
                m_vScrollbar.HandleInput(input, hasKeyboardActiveControl, hasKeyboardActiveControlPrevious, receivedFocusInThisUpdate) ||
                m_hScrollbar.HandleInput(input, hasKeyboardActiveControl, hasKeyboardActiveControlPrevious, receivedFocusInThisUpdate);

            if (hasKeyboardActiveControl)
            {
                if (FocusedItem == null &&
                    m_body.GetItemCount() > 0 &&
                    (input.IsNewKeyPress(Keys.Up) ||
                     input.IsNewKeyPress(Keys.Down) ||
                     input.IsNewKeyPress(Keys.Left) ||
                     input.IsNewKeyPress(Keys.Right) ||
                     input.DeltaMouseScrollWheelValue() != 0))
                {
                    FocusItem(m_body[0]);
                }
                else if (FocusedItem != null)
                {
                    if (input.IsNewKeyPress(Keys.Down) || (input.DeltaMouseScrollWheelValue() < 0 && Contains(MyGuiManager.MouseCursorPosition.X, MyGuiManager.MouseCursorPosition.Y)))
                    {
                        FocusItem(NextVisible(m_body, FocusedItem));
                    }

                    if (input.IsNewKeyPress(Keys.Up) || (input.DeltaMouseScrollWheelValue() > 0 && Contains(MyGuiManager.MouseCursorPosition.X, MyGuiManager.MouseCursorPosition.Y)))
                    {
                        FocusItem(PrevVisible(m_body, FocusedItem));
                    }

                    if (input.IsNewKeyPress(Keys.Right))
                    {
                        if (FocusedItem.GetItemCount() > 0)
                        {
                            if (!FocusedItem.IsExpanded)
                            {
                                FocusedItem.IsExpanded = true;
                            }
                            else
                            {
                                var next = NextVisible(FocusedItem, FocusedItem);
                                FocusItem(next);
                            }
                        }
                    }

                    if (input.IsNewKeyPress(Keys.Left))
                    {
                        if (FocusedItem.GetItemCount() > 0 && FocusedItem.IsExpanded)
                        {
                            FocusedItem.IsExpanded = false;
                        }
                        else if (FocusedItem.Parent is MyTreeViewItem)
                        {
                            FocusItem(FocusedItem.Parent as MyTreeViewItem);
                        }
                    }

                    if (FocusedItem.GetItemCount() > 0)
                    {
                        if (input.IsNewKeyPress(Keys.Add))
                        {
                            FocusedItem.IsExpanded = true;
                        }

                        if (input.IsNewKeyPress(Keys.Subtract))
                        {
                            FocusedItem.IsExpanded = false;
                        }
                    }
                }

                if (input.IsNewKeyPress(Keys.PageDown))
                {
                    m_vScrollbar.PageDown();
                }

                if (input.IsNewKeyPress(Keys.PageUp))
                {
                    m_vScrollbar.PageUp();
                }

                captured = captured ||
                           input.IsNewKeyPress(Keys.PageDown) ||
                           input.IsNewKeyPress(Keys.PageUp) ||
                           input.IsNewKeyPress(Keys.Down) ||
                           input.IsNewKeyPress(Keys.Up) ||
                           input.IsNewKeyPress(Keys.Left) ||
                           input.IsNewKeyPress(Keys.Right) ||
                           input.IsNewKeyPress(Keys.Add) ||
                           input.IsNewKeyPress(Keys.Subtract) ||
                           input.DeltaMouseScrollWheelValue() != 0;
            }

            // Hoovered item changed
            if (HooveredItem != oldHooveredItem)
            {
                m_control.ShowToolTip(HooveredItem == null ? null : HooveredItem.ToolTip);
                MyAudio.AddCue2D(MySoundCuesEnum.GuiMouseOver);
            }

            return captured;
        }