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

            if (input.IsNewLeftMousePressed() || input.IsNewRightMousePressed() || input.IsNewKeyPress(Keys.Space) || input.IsNewKeyPress(Keys.Enter))
                Canceling();
        }
Пример #2
0
        public override void HandleInput(MyGuiInput input, bool receivedFocusInThisUpdate)
        {
            base.HandleInput(input, receivedFocusInThisUpdate);

            if (input.IsNewLeftMousePressed() || input.IsNewRightMousePressed() || input.IsNewKeyPress(Keys.Space) || input.IsNewKeyPress(Keys.Enter))
            {
                Canceling();
            }
        }
        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 HandleInputEx(MyGuiInput input, bool hasKeyboardActiveControl, bool hasKeyboardActiveControlPrevious, bool receivedFocusInThisUpdate)
        {
            if (!Visible)
            {
                return false;
            }

            bool captured = false;

            // Hoover item if mouse cursor is inside its area
            if (TreeView.Contains(MyGuiManager.MouseCursorPosition.X, MyGuiManager.MouseCursorPosition.Y) &&
                MyGUIHelper.Contains(m_currentOrigin, m_currentSize, MyGuiManager.MouseCursorPosition.X, MyGuiManager.MouseCursorPosition.Y))
            {
                TreeView.HooveredItem = this;
            }

            if (Enabled && DragDrop != null)
            {
                captured = DragDrop.HandleInput(this, input);
            }

            // Single click - expand or focus item
            if (input.IsNewLeftMouseReleased())
            {
                if (GetItemCount() > 0 && MyGUIHelper.Contains(m_currentOrigin + GetExpandIconPosition(), m_expandIconSize, MyGuiManager.MouseCursorPosition.X, MyGuiManager.MouseCursorPosition.Y))
                {
                    IsExpanded = !IsExpanded;
                    captured = true;
                    MyAudio.AddCue2D(MySoundCuesEnum.GuiMouseClick);
                }
                else if (TreeView.HooveredItem == this)
                {
                    TreeView.FocusItem(this);
                    captured = true;
                    MyAudio.AddCue2D(MySoundCuesEnum.GuiMouseClick);
                }
            }

            // Double click - launch Action event
            if (Enabled && /*!captured && */input.IsNewLeftMouseDoubleClick() && TreeView.HooveredItem == this)
            {
                if (Action != null)
                {
                    DoAction();
                }
                else if (GetItemCount() > 0)
                {
                    IsExpanded = !IsExpanded;
                }
                captured = true;
            }

            // Right click - launch RightClick event
            if (/*!captured && */input.IsNewRightMousePressed() && TreeView.HooveredItem == this)
            {
                if (RightClick != null)
                {
                    RightClick(this, EventArgs.Empty);
                }
                captured = true;
                MyAudio.AddCue2D(MySoundCuesEnum.GuiMouseClick);
            }

            return captured;
        }
Пример #5
0
        public bool HandleInputEx(MyGuiInput input, bool hasKeyboardActiveControl, bool hasKeyboardActiveControlPrevious, bool receivedFocusInThisUpdate)
        {
            if (!Visible)
            {
                return(false);
            }

            bool captured = false;

            // Hoover item if mouse cursor is inside its area
            if (TreeView.Contains(MyGuiManager.MouseCursorPosition.X, MyGuiManager.MouseCursorPosition.Y) &&
                MyGUIHelper.Contains(m_currentOrigin, m_currentSize, MyGuiManager.MouseCursorPosition.X, MyGuiManager.MouseCursorPosition.Y))
            {
                TreeView.HooveredItem = this;
            }

            if (Enabled && DragDrop != null)
            {
                captured = DragDrop.HandleInput(this, input);
            }

            // Single click - expand or focus item
            if (input.IsNewLeftMouseReleased())
            {
                if (GetItemCount() > 0 && MyGUIHelper.Contains(m_currentOrigin + GetExpandIconPosition(), m_expandIconSize, MyGuiManager.MouseCursorPosition.X, MyGuiManager.MouseCursorPosition.Y))
                {
                    IsExpanded = !IsExpanded;
                    captured   = true;
                    MyAudio.AddCue2D(MySoundCuesEnum.GuiMouseClick);
                }
                else if (TreeView.HooveredItem == this)
                {
                    TreeView.FocusItem(this);
                    captured = true;
                    MyAudio.AddCue2D(MySoundCuesEnum.GuiMouseClick);
                }
            }

            // Double click - launch Action event
            if (Enabled && /*!captured && */ input.IsNewLeftMouseDoubleClick() && TreeView.HooveredItem == this)
            {
                if (Action != null)
                {
                    DoAction();
                }
                else if (GetItemCount() > 0)
                {
                    IsExpanded = !IsExpanded;
                }
                captured = true;
            }

            // Right click - launch RightClick event
            if (/*!captured && */ input.IsNewRightMousePressed() && TreeView.HooveredItem == this)
            {
                if (RightClick != null)
                {
                    RightClick(this, EventArgs.Empty);
                }
                captured = true;
                MyAudio.AddCue2D(MySoundCuesEnum.GuiMouseClick);
            }

            return(captured);
        }