Пример #1
0
        //  Update all screens
        public static void Update(int totalTimeInMS)
        {
            TotalGamePlayTimeInMilliseconds = totalTimeInMS;

            //  We remove, add, remove because sometimes in ADD when calling LoadContent some screen can be marked for remove, so we
            //  need to make sure it's really removed before we enter UPDATE or DRAW loop
            VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("GuiManager-RemoveScreens");
            RemoveScreens();
            VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();

            VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("GuiManager-AddScreens");
            AddScreens();
            VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();

            VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("GuiManager-RemoveScreens2");
            RemoveScreens();
            VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();

            MyGuiScreenBase screenWithFocus = GetScreenWithFocus();

            //  Update screens
            VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("GuiManager-Update screens");

            for (int i = 0; i < m_screens.Count; i++)
            {
                MyGuiScreenBase screen = m_screens[i];

                VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("Update : " + screen.GetFriendlyName());
                screen.Update(screen == screenWithFocus);
                VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
            }

            VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
        }
Пример #2
0
        //  Add screens - if during update-loop some screen was marked 'for add'
        static void AddScreens()
        {
            // Changed from foreach to for, to allow add screens during enumeration
            for (int i = 0; i < m_screensToAdd.Count; i++)
            {
                MyGuiScreenBase screenToAdd = m_screensToAdd[i];

                if (screenToAdd.IsLoaded == false)
                {
                    screenToAdd.State = MyGuiScreenState.OPENING;
                    screenToAdd.LoadData();
                    screenToAdd.LoadContent();
                }

                // I have enough of screens hidden behind gui screen gameplay
                if (screenToAdd.IsAlwaysFirst())
                {
                    m_screens.Insert(0, screenToAdd);
                }
                else
                {
                    m_screens.Insert(GetIndexOfLastNonTopScreen(), screenToAdd);
                }
            }
            m_screensToAdd.Clear();
        }
Пример #3
0
 private static void NotifyScreenRemoved(MyGuiScreenBase screen)
 {
     if (ScreenRemoved != null)
     {
         ScreenRemoved(screen);
     }
 }
Пример #4
0
        public static MyGuiScreenBase GetScreenWithFocus()
        {
            ProfilerShort.Begin("MyGuiManager.GetScreenWithFocus");

            MyGuiScreenBase screenWithFocus = null;

            if (m_screens.Count > 0)
            {
                //  Get screen from top of the stack - that one has focus
                //  But it can't be closed. If yes, then look for other.
                for (int i = (m_screens.Count - 1); i >= 0; i--)
                {
                    MyGuiScreenBase screen = m_screens[i];

                    bool isOpened = (screen.State == MyGuiScreenState.OPENED) || IsScreenTransitioning(screen);
                    if (isOpened && screen.CanHaveFocus)
                    {
                        screenWithFocus = screen;
                        break;
                    }
                }
            }

            ProfilerShort.End();
            return(screenWithFocus);
        }
Пример #5
0
        //  Find previous screen to screen in screens stack
        public static MyGuiScreenBase GetPreviousScreen(MyGuiScreenBase screen, Predicate <MyGuiScreenBase> condition, Predicate <MyGuiScreenBase> terminatingCondition)
        {
            MyGuiScreenBase previousScreen     = null;
            int             currentScreenIndex = -1;

            if (screen == null)
            {
                currentScreenIndex = GetScreensCount();
            }
            for (int i = GetScreensCount() - 1; i > 0; i--)
            {
                MyGuiScreenBase tempScreen = m_screens[i];
                if (screen == tempScreen)
                {
                    currentScreenIndex = i;
                }
                if (i < currentScreenIndex)
                {
                    if (condition(tempScreen))
                    {
                        previousScreen = tempScreen;
                        break;
                    }

                    if (terminatingCondition(tempScreen))
                    {
                        break;
                    }
                }
            }
            return(previousScreen);
        }
Пример #6
0
        //  Update all screens
        public void Update(int totalTimeInMS)
        {
            VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("MyGuiSandbox::Update");

            HandleRenderProfilerInput();

            TotalGamePlayTimeInMilliseconds = totalTimeInMS;

            MyScreenManager.Update(totalTimeInMS);

            MyGuiScreenBase screenWithFocus = MyScreenManager.GetScreenWithFocus();

            bool gameFocused = (MySandboxGame.Static.IsActive == true
                                &&
                                ((Sandbox.AppCode.MyExternalAppBase.Static == null && MySandboxGame.Static.WindowHandle == GetForegroundWindow())
                                 ||
                                 (Sandbox.AppCode.MyExternalAppBase.Static != null && !Sandbox.AppCode.MyExternalAppBase.IsEditorActive))
                                );

            //We have to know current focus screen because of centerize mouse
            MyInput.Static.Update(gameFocused);

            MyGuiManager.Update(totalTimeInMS);
            MyGuiManager.MouseCursorPosition = MouseCursorPosition;


            MyGuiManager.Camera     = MySector.MainCamera != null ? MySector.MainCamera.WorldMatrix : VRageMath.MatrixD.Identity;
            MyGuiManager.CameraView = MySector.MainCamera != null ? MySector.MainCamera.ViewMatrix : VRageMath.MatrixD.Identity;
            MyGuiManager.TotalTimeInMilliseconds = MySandboxGame.TotalTimeInMilliseconds;

            //We should not need this call
            //EnableSoundsBasedOnWindowFocus();

            VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
        }
Пример #7
0
        public virtual MyGuiControlBase GetNextFocusControl(MyGuiControlBase currentFocusControl, bool forwardMovement)
        {
            int currentIdx = Elements.IndexOf(currentFocusControl);

            if (currentIdx == -1 && !forwardMovement)
            {
                currentIdx = Elements.Count;
            }

            int i = (forwardMovement) ? (currentIdx + 1)
                                      : (currentIdx - 1);
            int step = (forwardMovement) ? +1 : -1;

            while ((forwardMovement && i < Elements.Count) ||
                   (!forwardMovement && i >= 0))
            {
                if (MyGuiScreenBase.CanHaveFocusRightNow(Elements[i]))
                {
                    return(Elements[i]);
                }

                i += step;
            }

            return(Owner.GetNextFocusControl(this, forwardMovement));
        }
Пример #8
0
        //  Add screen to top of the screens stack, so it becomes active (will have focus)
        public static void AddScreen(MyGuiScreenBase screen)
        {
            Debug.Assert(screen != null);

            screen.Closed +=
                delegate(MyGuiScreenBase sender)
            {
                RemoveScreen(sender);
            };

            // Hide tooltips
            var screenWithFocus = GetScreenWithFocus();

            if (screenWithFocus != null)
            {
                screenWithFocus.HideTooltips();
            }

            //  When adding new screen and previous screen is configured to hide(not close), find it and hide it now
            MyGuiScreenBase previousCanHideScreen = null;

            if (screen.CanHideOthers)
            {
                previousCanHideScreen = GetPreviousScreen(null, x => x.CanBeHidden, x => x.CanHideOthers);
            }

            if (previousCanHideScreen != null && previousCanHideScreen.State != MyGuiScreenState.CLOSING)
            {
                previousCanHideScreen.HideScreen();
            }

            MyInput.Static.JoystickAsMouse = screen.JoystickAsMouse;

            m_screensToAdd.Add(screen);
        }
Пример #9
0
 public static void RemoveScreen(MyGuiScreenBase screen)
 {
     Gui.RemoveScreen(screen);
     if (GuiControlRemoved != null)
     {
         GuiControlRemoved(screen);
     }
 }
Пример #10
0
 public static void AddScreen(MyGuiScreenBase screen)
 {
     Gui.AddScreen(screen);
     if (MyAPIGateway.GuiControlCreated != null)
     {
         MyAPIGateway.GuiControlCreated(screen);
     }
 }
Пример #11
0
        public static void HandleInputAfterSimulation()
        {
            for (int i = (m_screens.Count - 1); i >= 0; i--)
            {
                MyGuiScreenBase screen = m_screens[i];

                screen.HandleInputAfterSimulation();
            }
        }
Пример #12
0
 //  Close all screens except one specified and all that are marked as "topmost"
 //  Difference against RemoveAllScreensExcept is that this one closes using CloseScreen, and RemoveAllScreensExcept just removes from the list
 public static void CloseAllScreensExceptThisOneAndAllTopMost(MyGuiScreenBase dontRemove)
 {
     foreach (MyGuiScreenBase screen in m_screens)
     {
         if ((((screen == dontRemove) || (screen.IsTopMostScreen())) == false) && (screen.CanCloseInCloseAllScreenCalls() == true))
         {
             screen.CloseScreen();
         }
     }
 }
Пример #13
0
 //  Remove all screens except the one!
 public static void RemoveAllScreensExcept(MyGuiScreenBase dontRemove)
 {
     foreach (MyGuiScreenBase screen in m_screens)
     {
         if (screen != dontRemove)
         {
             RemoveScreen(screen);
         }
     }
 }
Пример #14
0
 //  Close all screens except the one!
 //  Difference against RemoveAllScreensExcept is that this one closes using CloseScreen, and RemoveAllScreensExcept just removes from the list
 public static void CloseAllScreensExcept(MyGuiScreenBase dontRemove)
 {
     for (int i = m_screens.Count - 1; i >= 0; --i)
     {
         var screen = m_screens[i];
         if ((screen != dontRemove) && (screen.CanCloseInCloseAllScreenCalls() == true))
         {
             screen.CloseScreen();
         }
     }
 }
Пример #15
0
 string GetMouseOverTexture(MyGuiScreenBase screen)
 {
     if (screen != null)
     {
         var mouseOverControl = screen.GetMouseOverControl();
         if (mouseOverControl != null)
         {
             return(mouseOverControl.GetMouseCursorTexture() ?? MyGuiManager.GetMouseCursorTexture());
         }
     }
     return(MyGuiManager.GetMouseCursorTexture());
 }
Пример #16
0
 public MyGuiScreenTextPanel(
     string missionTitle = null,
     string currentObjectivePrefix = null,
     string currentObjective = null,
     string description = null,
     Action<ResultEnum> resultCallback = null,
     Action saveCodeCallback = null,
     string okButtonCaption = null,      
     bool editable = false,
     MyGuiScreenBase previousScreen = null)
     : base(missionTitle, currentObjectivePrefix, currentObjective, description, resultCallback, okButtonCaption, null, null, editable)
 {
     CanHideOthers = editable;
 }
Пример #17
0
 private void AddCloseHandler(MyGuiScreenBase previousScreen, MyGuiScreenLogo logoScreen, Action afterLogosAction)
 {
     previousScreen.Closed += (screen) =>
     {
         if (!screen.Cancelled)
         {
             AddScreen(logoScreen);
         }
         else
         {
             afterLogosAction();
         }
     };
 }
Пример #18
0
        public static bool IsScreenOnTop(MyGuiScreenBase screen)
        {
            int index = GetIndexOfLastNonTopScreen() - 1;

            if (index < 0 || index >= m_screens.Count)
            {
                return(false);
            }
            if (m_screensToAdd.Count > 0)
            {
                return(false);
            }

            return(m_screens[index] == screen);
        }
Пример #19
0
        static int GetIndexOfLastNonTopScreen()
        {
            int max = 0;

            for (int i = 0; i < m_screens.Count; i++)
            {
                MyGuiScreenBase screen = m_screens[i];
                if (screen.IsTopMostScreen() || screen.IsTopScreen())
                {
                    break;
                }
                max = i + 1;
            }
            return(max);
        }
Пример #20
0
        //  Find screen on top of screens, that has status HIDDEN or HIDING
        public static MyGuiScreenBase GetTopHiddenScreen()
        {
            MyGuiScreenBase hiddenScreen = null;

            for (int i = GetScreensCount() - 1; i > 0; i--)
            {
                MyGuiScreenBase screen = m_screens[i];
                if (screen.State == MyGuiScreenState.HIDDEN || screen.State == MyGuiScreenState.HIDING)
                {
                    hiddenScreen = screen;
                    break;
                }
            }
            return(hiddenScreen);
        }
Пример #21
0
        public static void AddScreenNow(MyGuiScreenBase screen)
        {
            Debug.Assert(screen != null);

            screen.Closed +=
                delegate(MyGuiScreenBase sender)
            {
                RemoveScreen(sender);
            };

            // Hide tooltips
            var screenWithFocus = GetScreenWithFocus();

            if (screenWithFocus != null)
            {
                screenWithFocus.HideTooltips();
            }

            //  When adding new screen and previous screen is configured to hide(not close), find it and hide it now
            MyGuiScreenBase previousCanHideScreen = null;

            if (screen.CanHideOthers)
            {
                previousCanHideScreen = GetPreviousScreen(null, x => x.CanBeHidden, x => x.CanHideOthers);
            }

            if (previousCanHideScreen != null && previousCanHideScreen.State != MyGuiScreenState.CLOSING)
            {
                previousCanHideScreen.HideScreen();
            }


            if (screen.IsLoaded == false)
            {
                screen.State = MyGuiScreenState.OPENING;
                screen.LoadData();
                screen.LoadContent();
            }

            if (screen.IsAlwaysFirst())
            {
                m_screens.Insert(0, screen);
            }
            else
            {
                m_screens.Insert(GetIndexOfLastNonTopScreen(), screen);
            }
        }
Пример #22
0
        //  Close all screens except the one NOW!
        //  Difference against RemoveAllScreensExcept is that this one closes using CloseScreen, and RemoveAllScreensExcept just removes from the list
        public static void CloseAllScreensNowExcept(MyGuiScreenBase dontRemove)
        {
            for (int i = m_screens.Count - 1; i >= 0; --i)
            {
                var screen = m_screens[i];
                if ((screen != dontRemove) && (screen.CanCloseInCloseAllScreenCalls() == true))
                {
                    screen.CloseScreenNow();
                }
            }

            foreach (var screen in m_screensToAdd)
            {
                screen.UnloadContent();
            }
            m_screensToAdd.Clear();
        }
Пример #23
0
        //  Remove screen from the stack
        public static void RemoveScreen(MyGuiScreenBase screen)
        {
            Debug.Assert(screen != null);

            if (IsAnyScreenOpening() == false)
            {
                MyGuiScreenBase previousCanHideScreen = GetPreviousScreen(screen, x => x.CanBeHidden, x => x.CanHideOthers);
                if (previousCanHideScreen != null &&
                    (previousCanHideScreen.State == MyGuiScreenState.HIDDEN || previousCanHideScreen.State == MyGuiScreenState.HIDING))
                {
                    previousCanHideScreen.UnhideScreen();
                    MyInput.Static.JoystickAsMouse = previousCanHideScreen.JoystickAsMouse;
                }
            }

            m_screensToRemove.Add(screen);
        }
Пример #24
0
        //  Only for displaying list of active GUI screens in debug console
        public static StringBuilder GetGuiScreensForDebug()
        {
            m_sb.Clear();
            m_sb.ConcatFormat("{0}{1}{2}", "GUI screens: [", m_screens.Count, "]: ");
            var screenWithFocus = GetScreenWithFocus();

            for (int i = 0; i < m_screens.Count; i++)
            {
                MyGuiScreenBase screen = m_screens[i];
                if (screenWithFocus == screen)
                {
                    m_sb.Append("[F]");
                }
                m_sb.Append(screen.GetFriendlyName());
                //m_sb.Replace("MyGuiScreen", ""); //This is doing allocations
                m_sb.Append(i < (m_screens.Count - 1) ? ", " : "");
                //                string[] stateString = { "o", "O", "c", "C", "h", "u", "H" };  // debug: show opening/closing state of screens
                //                sb.Append(screen.GetFriendlyName().Replace("MyGuiScreen", "") + "(" + stateString[(int)(screen.GetState())] + ")" + (i < (m_screens.Count - 1) ? ", " : ""));
            }
            return(m_sb);
        }
Пример #25
0
        static bool IsAnyScreenInTransition()
        {
            bool isTransitioning = false;

            if (m_screens.Count > 0)
            {
                //  Get screen from top of the stack - that one has focus
                //  But it can't be closed. If yes, then look for other.
                for (int i = (m_screens.Count - 1); i >= 0; i--)
                {
                    MyGuiScreenBase screen = m_screens[i];

                    isTransitioning = IsScreenTransitioning(screen);
                    if (isTransitioning)
                    {
                        break;
                    }
                }
            }
            return(isTransitioning);
        }
Пример #26
0
        public static bool IsAnyScreenOpening()
        {
            bool isOpening = false;

            if (m_screens.Count > 0)
            {
                //  Get screen from top of the stack - that one has focus
                //  But it can't be closed. If yes, then look for other.
                for (int i = (m_screens.Count - 1); i >= 0; i--)
                {
                    MyGuiScreenBase screen = m_screens[i];

                    isOpening = screen.State == MyGuiScreenState.OPENING;
                    if (isOpening)
                    {
                        break;
                    }
                }
            }
            return(isOpening);
        }
Пример #27
0
        protected bool IsMouseOverOrKeyboardActive()
        {
            MyGuiScreenBase topMostParentScreen = GetTopMostOwnerScreen();

            if (topMostParentScreen != null)
            {
                switch (topMostParentScreen.State)
                {
                case MyGuiScreenState.OPENED:
                case MyGuiScreenState.OPENING:
                case MyGuiScreenState.UNHIDING:
                    return(IsMouseOver || HasFocus);

                default:
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Пример #28
0
        public void BackToIntroLogos(Action afterLogosAction)
        {
            MyScreenManager.CloseAllScreensNowExcept(null);

            string[] logos = new string[]
            {
                //"Textures\\Logo\\keen_swh",
                //"Textures\\Logo\\game",
                //"Textures\\Logo\\vrage",
            };

            MyGuiScreenBase previousScreen = null;

            foreach (var logo in logos)
            {
                var logoScreen = new MyGuiScreenLogo(logo);
                if (previousScreen != null)
                {
                    AddCloseHandler(previousScreen, logoScreen, afterLogosAction);
                }
                else
                {
                    AddScreen(logoScreen);
                }

                previousScreen = logoScreen;
            }

            if (previousScreen != null)
            {
                previousScreen.Closed += (screen) => afterLogosAction();
            }
            else
            {
                afterLogosAction();
            }
        }
Пример #29
0
        //  Draw all screens
        public static void Draw()
        {
            VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("MyScreenManager::Draw");

            //  Find screen with focus
            MyGuiScreenBase screenWithFocus = GetScreenWithFocus();

            //  Find top screen that has background fade
            MyGuiScreenBase screenFade            = null;
            bool            previousCanHideOthers = false;

            for (int i = (m_screens.Count - 1); i >= 0; i--)
            {
                MyGuiScreenBase screen = m_screens[i];
                bool            screenGetEnableBackgroundFade = screen.EnabledBackgroundFade;
                bool            isScreenFade = false;
                if (screenWithFocus == screen || screen.GetDrawScreenEvenWithoutFocus() || !previousCanHideOthers)
                {
                    if ((screen.State != MyGuiScreenState.CLOSED) && (screenGetEnableBackgroundFade))
                    {
                        isScreenFade = true;
                    }
                }
                else if (IsScreenTransitioning(screen) && screenGetEnableBackgroundFade)
                {
                    isScreenFade = true;
                }

                if (isScreenFade)
                {
                    screenFade = screen;
                    break;
                }
                previousCanHideOthers = screen.CanHideOthers;
            }

            //  Draw all screen, from bottom to top
            for (int i = 0; i < m_screens.Count; i++)
            {
                MyGuiScreenBase screen = m_screens[i];

                bool drawScreen = false;
                if (screenWithFocus == screen || screen.GetDrawScreenEvenWithoutFocus() || !previousCanHideOthers)
                {
                    if (screen.State != MyGuiScreenState.CLOSED && screen.State != MyGuiScreenState.HIDDEN)
                    {
                        drawScreen = true;
                    }
                }
                else if (!screen.CanBeHidden)
                {
                    drawScreen = true;
                }
                else if (IsScreenTransitioning(screen))
                {
                    drawScreen = true;
                }

                if (drawScreen)
                {
                    // Draw background fade before drawing first screen that has it enabled.
                    if (screen == screenFade)
                    {
                        MyGuiManager.DrawSpriteBatch(MyGuiConstants.TEXTURE_BACKGROUND_FADE, MyGuiManager.GetFullscreenRectangle(), screen.BackgroundFadeColor);
                    }

                    screen.Draw();
                }
            }

            //VRageRender.MyRenderProxy.GetRenderProfiler().ProfileCustomValue("Drawcalls", MyPerformanceCounter.PerCameraDrawWrite.TotalDrawCalls);

            VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
        }
        //  This method is called every update (but only if application has focus)
        public override void HandleUnhandledInput(bool receivedFocusInThisUpdate)
        {
            if (MyInput.Static.ENABLE_DEVELOPER_KEYS || (MySession.Static != null && MySession.Static.Settings.EnableSpectator))
            {
                //Set camera to player
                if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.SPECTATOR_NONE))
                {
                    if (MySession.ControlledEntity != null)
                    { //we already are controlling this object

                        if (MyFinalBuildConstants.IS_OFFICIAL)
                        {
                            SetCameraController();
                        }
                        else
                        {
                            var cameraController = MySession.GetCameraControllerEnum();
                            if (cameraController != MyCameraControllerEnum.Entity && cameraController != MyCameraControllerEnum.ThirdPersonSpectator)
                            {
                                SetCameraController();
                            }
                            else
                            {
                                var entities = MyEntities.GetEntities().ToList();
                                int lastKnownIndex = entities.IndexOf(MySession.ControlledEntity.Entity);

                                var entitiesList = new List<MyEntity>();
                                if (lastKnownIndex + 1 < entities.Count)
                                    entitiesList.AddRange(entities.GetRange(lastKnownIndex + 1, entities.Count - lastKnownIndex - 1));

                                if (lastKnownIndex != -1)
                                {
                                    entitiesList.AddRange(entities.GetRange(0, lastKnownIndex + 1));
                                }

                                MyCharacter newControlledObject = null;

                                for (int i = 0; i < entitiesList.Count; i++)
                                {
                                    var character = entitiesList[i] as MyCharacter;
                                    if (character != null && !character.IsDead)
                                    {
                                        newControlledObject = character;
                                        break;
                                    }
                                }

                                if (MySession.LocalHumanPlayer != null && newControlledObject != null)
                                {
                                    MySession.LocalHumanPlayer.Controller.TakeControl(newControlledObject);
                                }
                            }

                            // We could have activated the cube builder in spectator, so deactivate it now
                            if (MyCubeBuilder.Static.IsActivated && !(MySession.ControlledEntity is MyCharacter))
                                MyCubeBuilder.Static.Deactivate();
                        }
                    }
                }

                //Set camera to following third person
                if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.SPECTATOR_DELTA))
                {
                    if (MySession.ControlledEntity != null)
                    {
                        MySession.SetCameraController(MyCameraControllerEnum.SpectatorDelta);
                    }
                }

                //Set camera to spectator
                if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.SPECTATOR_FREE))
                {
                    if (MySession.GetCameraControllerEnum() != MyCameraControllerEnum.Spectator)
                    {
                        MySession.SetCameraController(MyCameraControllerEnum.Spectator);
                    }
                    else if (MyInput.Static.IsAnyShiftKeyPressed())
                    {
                        MyFakes.ENABLE_DEVELOPER_SPECTATOR_CONTROLS = !MyFakes.ENABLE_DEVELOPER_SPECTATOR_CONTROLS;
                    }

                    if (MyInput.Static.IsAnyCtrlKeyPressed() && MySession.ControlledEntity != null)
                    {
                        MySpectator.Static.Position = (Vector3D)MySession.ControlledEntity.Entity.PositionComp.GetPosition() + MySpectator.Static.ThirdPersonCameraDelta;
                        MySpectator.Static.Target = (Vector3D)MySession.ControlledEntity.Entity.PositionComp.GetPosition();
                    }
                }

                //Set camera to static spectator, non movable
                if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.SPECTATOR_STATIC))
                {
                    if (MySession.ControlledEntity != null)
                    {
                        MySession.SetCameraController(MyCameraControllerEnum.SpectatorFixed);

                        if (MyInput.Static.IsAnyCtrlKeyPressed())
                        {
                            MySpectator.Static.Position = (Vector3D)MySession.ControlledEntity.Entity.PositionComp.GetPosition() + MySpectator.Static.ThirdPersonCameraDelta;
                            MySpectator.Static.Target = (Vector3D)MySession.ControlledEntity.Entity.PositionComp.GetPosition();
                        }
                    }
                }

                //Open console
                if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.CONSOLE) && MyInput.Static.IsAnyAltKeyPressed())
                {
                    MyGuiScreenConsole.Show();
                }
            }

            if (MyDefinitionErrors.ShouldShowModErrors)
            {
                MyDefinitionErrors.ShouldShowModErrors = false;
                MyGuiSandbox.ShowModErrors();
            }

            // Switch view - cockpit on/off, third person
            if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.CAMERA_MODE) && CanSwitchCamera)
            {
                MyGuiAudio.PlaySound(MyGuiSounds.HudClick);
                SwitchCamera();
                //if (MySession.IsCameraControlledObject())
                //{
                //    //MySession.SetCameraController(MyCameraControllerEnum.ThirdPersonSpectator);
                //    MySession.Static.CameraController.IsInFirstPersonView = true;
                //}
                //else
                //{
                //    MySession.Static.CameraController.IsInFirstPersonView = false;
                //}
                ////else if (MySession.GetCameraControllerEnum() == MyCameraControllerEnum.ThirdPersonSpectator)
                ////{
                ////    if (MySession.ControlledObject is IMyCameraController)
                ////        MySession.SetCameraController(MyCameraControllerEnum.Entity, MySession.ControlledObject.Entity);
                ////}
            }

            if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.HELP_SCREEN))
            {
                if (MyInput.Static.IsAnyCtrlKeyPressed())
                {
                    switch (MySandboxGame.Config.DebugComponentsInfo)
                    {
                        case MyDebugComponent.MyDebugComponentInfoState.NoInfo:
                            MySandboxGame.Config.DebugComponentsInfo = MyDebugComponent.MyDebugComponentInfoState.EnabledInfo;
                            break;
                        case MyDebugComponent.MyDebugComponentInfoState.EnabledInfo:
                            MySandboxGame.Config.DebugComponentsInfo = MyDebugComponent.MyDebugComponentInfoState.FullInfo;
                            break;
                        case MyDebugComponent.MyDebugComponentInfoState.FullInfo:
                            MySandboxGame.Config.DebugComponentsInfo = MyDebugComponent.MyDebugComponentInfoState.NoInfo;
                            break;
                    }

                    MySandboxGame.Config.Save();
                }
                else
                    if (MyGuiScreenGamePlay.ActiveGameplayScreen == null)
                    {
                        MyGuiAudio.PlaySound(MyGuiSounds.HudMouseClick);
                        MyGuiSandbox.AddScreen(MyGuiScreenGamePlay.ActiveGameplayScreen = MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.HelpScreen));
                    }
            }

            if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.TOGGLE_HUD))
            {
                MyGuiAudio.PlaySound(MyGuiSounds.HudClick);
                MyHud.MinimalHud = !MyHud.MinimalHud;
            }

            if (MyPerGameSettings.SimplePlayerNames && MyInput.Static.IsNewGameControlPressed(MyControlsSpace.BROADCASTING))
            {
                MyHud.LocationMarkers.Visible = !MyHud.LocationMarkers.Visible;
            }

            var controlledObject = MySession.ControlledEntity;
            var currentCameraController = MySession.Static.CameraController;

            if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.MISSION_SETTINGS) && MyGuiScreenGamePlay.ActiveGameplayScreen == null 
                && MyPerGameSettings.Game == Sandbox.Game.GameEnum.SE_GAME
                && MyFakes.ENABLE_MISSION_TRIGGERS)
                {
                MyGuiSandbox.AddScreen(new Sandbox.Game.Screens.MyGuiScreenMissionTriggers());
            }

            // HACK! Do NOT add anything that relies on use objects here!
            // Letting certain use objects which are targeted handle any kind of events, circumventing all normal use object mechanisms.
            // Only used by ropes (and it should stay that way).
            var controlledCharacter = controlledObject as MyCharacter;
            bool handledByUseObject = false;
            if (controlledCharacter != null && controlledCharacter.UseObject != null)
            {
                handledByUseObject = controlledCharacter.UseObject.HandleInput();
            }

            MyStringId context = controlledObject != null ? controlledObject.ControlContext : MySpaceBindingCreator.CX_BASE;

            if (controlledObject != null && !handledByUseObject)
            {
                if (!MySandboxGame.IsPaused)
                {
                    if (context == MySpaceBindingCreator.CX_BUILD_MODE || context == MySpaceBindingCreator.CX_CHARACTER || context == MySpaceBindingCreator.CX_SPACESHIP)
                    {
                        if (MyControllerHelper.IsControl(context, MyControlsSpace.PRIMARY_TOOL_ACTION, MyControlStateType.NEW_PRESSED))
                        {
                            if (MyToolbarComponent.CurrentToolbar.ShouldActivateSlot)
                            {
                                MyToolbarComponent.CurrentToolbar.ActivateStagedSelectedItem();
                            }
                            else
                            {
                                controlledObject.BeginShoot(MyShootActionEnum.PrimaryAction);
                            }
                        }

                        if (MyControllerHelper.IsControl(context, MyControlsSpace.PRIMARY_TOOL_ACTION, MyControlStateType.NEW_RELEASED))
                        {
                            controlledObject.EndShoot(MyShootActionEnum.PrimaryAction);
                        }
                        if (MyControllerHelper.IsControl(context, MyControlsSpace.SECONDARY_TOOL_ACTION, MyControlStateType.NEW_PRESSED))
                        {
                            controlledObject.BeginShoot(MyShootActionEnum.SecondaryAction);
                        }
                        if (MyControllerHelper.IsControl(context, MyControlsSpace.SECONDARY_TOOL_ACTION, MyControlStateType.NEW_RELEASED))
                        {
                            controlledObject.EndShoot(MyShootActionEnum.SecondaryAction);
                        }
                    }

                    if (context == MySpaceBindingCreator.CX_CHARACTER || context == MySpaceBindingCreator.CX_SPACESHIP)
                    {
                        if (MyControllerHelper.IsControl(context, MyControlsSpace.USE, MyControlStateType.NEW_PRESSED))
                        {
                            // Key press
                            if (currentCameraController != null)
                            {
                                if (!currentCameraController.HandleUse())
                                {
                                    controlledObject.Use();
                                }
                            }
                            else
                            {
                                controlledObject.Use();
                            }
                        }
                        else if (MyControllerHelper.IsControl(context, MyControlsSpace.USE, MyControlStateType.PRESSED))
                        {
                            // Key not pressed this frame, holding from previous
                            controlledObject.UseContinues();
                        }
                        else if (MyControllerHelper.IsControl(context, MyControlsSpace.USE, MyControlStateType.NEW_RELEASED))
                        {
                            controlledObject.UseFinished();
                        }

                        //Temp fix until spectators are implemented as entities
                        //Prevents controlled object from getting input while spectator mode is enabled
                        if (!(MySession.Static.CameraController is MySpectatorCameraController && MySpectatorCameraController.Static.SpectatorCameraMovement == MySpectatorCameraMovementEnum.UserControlled))
                        {
                            if (MyControllerHelper.IsControl(context, MyControlsSpace.CROUCH, MyControlStateType.NEW_PRESSED))
                            {
                                controlledObject.Crouch();
                            }
                            if (MyControllerHelper.IsControl(context, MyControlsSpace.CROUCH, MyControlStateType.PRESSED))
                            {
                                controlledObject.Down();
                            }
                            if (MyControllerHelper.IsControl(context, MyControlsSpace.SPRINT, MyControlStateType.PRESSED))
                            {
                                controlledObject.Sprint();
                            }
                            if (MyControllerHelper.IsControl(context, MyControlsSpace.JUMP, MyControlStateType.NEW_PRESSED))
                            {
                                controlledObject.Jump();
                            }
                            if (MyControllerHelper.IsControl(context, MyControlsSpace.JUMP, MyControlStateType.PRESSED))
                            {
                                controlledObject.Up();
                            }
                            if (MyControllerHelper.IsControl(context, MyControlsSpace.SWITCH_WALK, MyControlStateType.NEW_PRESSED))
                            {
                                controlledObject.SwitchWalk();
                            }
                            if (MyControllerHelper.IsControl(context, MyControlsSpace.BROADCASTING, MyControlStateType.NEW_PRESSED))
                            {
                                controlledObject.SwitchBroadcasting();
                            }
                            if (MyControllerHelper.IsControl(context, MyControlsSpace.HELMET, MyControlStateType.NEW_PRESSED))
                            {
                                controlledObject.SwitchHelmet();
                            }
                        }

                        if (MyControllerHelper.IsControl(context, MyControlsSpace.DAMPING, MyControlStateType.NEW_PRESSED))
                        {
                            MyGuiAudio.PlaySound(MyGuiSounds.HudClick);
                            controlledObject.SwitchDamping();
                        }
                        if (MyControllerHelper.IsControl(context, MyControlsSpace.THRUSTS, MyControlStateType.NEW_PRESSED))
                        {
                            MyGuiAudio.PlaySound(MyGuiSounds.HudClick);
                            controlledObject.SwitchThrusts();
                        }
                        if (MyControllerHelper.IsControl(context, MyControlsSpace.HEADLIGHTS, MyControlStateType.NEW_PRESSED))
                        {
                            MyGuiAudio.PlaySound(MyGuiSounds.HudClick);
                            controlledObject.SwitchLights();
                        }
                        if (MyControllerHelper.IsControl(context, MyControlsSpace.TOGGLE_REACTORS, MyControlStateType.NEW_PRESSED))
                        {
                            MyGuiAudio.PlaySound(MyGuiSounds.HudClick);
                            controlledObject.SwitchReactors();
                        }
                        if (MyControllerHelper.IsControl(context, MyControlsSpace.LANDING_GEAR, MyControlStateType.NEW_PRESSED))
                        {
                            MyGuiAudio.PlaySound(MyGuiSounds.HudClick);
                            controlledObject.SwitchLeadingGears();
                        }
                        if (MyControllerHelper.IsControl(context, MyControlsSpace.SUICIDE, MyControlStateType.NEW_PRESSED))
                        {
                            controlledObject.Die();
                        }
                        if ((controlledObject as MyCockpit) != null && MyControllerHelper.IsControl(context, MyControlsSpace.CUBE_COLOR_CHANGE, MyControlStateType.NEW_PRESSED))
                        {
                            (controlledObject as MyCockpit).SwitchWeaponMode();
                        }
                    }
                }
                if (MyControllerHelper.IsControl(context, MyControlsSpace.TERMINAL, MyControlStateType.NEW_PRESSED) && MyGuiScreenGamePlay.ActiveGameplayScreen == null)
                {
                    MyGuiAudio.PlaySound(MyGuiSounds.HudClick);
                    controlledObject.ShowTerminal();
                }

                if (MyControllerHelper.IsControl(context, MyControlsSpace.INVENTORY, MyControlStateType.NEW_PRESSED) && MyGuiScreenGamePlay.ActiveGameplayScreen == null)
                {
                    MyGuiAudio.PlaySound(MyGuiSounds.HudClick);
                    controlledObject.ShowInventory();
                }

                if (MyControllerHelper.IsControl(context, MyControlsSpace.CONTROL_MENU, MyControlStateType.NEW_PRESSED) && MyGuiScreenGamePlay.ActiveGameplayScreen == null)
                {
                    MyGuiAudio.PlaySound(MyGuiSounds.HudClick);
                    m_controlMenu.OpenControlMenu(controlledObject);
                }

                if (!MyCompilationSymbols.RenderProfiling && MyControllerHelper.IsControl(context, MyControlsSpace.CHAT_SCREEN, MyControlStateType.NEW_PRESSED))
                {
                    if (MyGuiScreenChat.Static == null)
                    {
                        Vector2 chatPos = new Vector2(0.01f, 0.84f);
                        chatPos = MyGuiScreenHudBase.ConvertHudToNormalizedGuiPosition(ref chatPos);
                        MyGuiScreenChat chatScreen = new MyGuiScreenChat(chatPos);
                        MyGuiSandbox.AddScreen(chatScreen);
                    }
                }
            }

            MoveAndRotatePlayerOrCamera();

            // Quick save or quick load.
            if (MyInput.Static.IsNewKeyPressed(MyKeys.F5))
            {
                MyGuiAudio.PlaySound(MyGuiSounds.HudMouseClick);
                var currentSession = MySession.Static.CurrentPath;

                if (MyInput.Static.IsAnyShiftKeyPressed())
                {
                    if (MySession.Static.ClientCanSave || Sync.IsServer)
                    {
                        if (!MyAsyncSaving.InProgress)
                        {
                            var messageBox = MyGuiSandbox.CreateMessageBox(
                                buttonType: MyMessageBoxButtonsType.YES_NO,
                                messageText: MyTexts.Get(MySpaceTexts.MessageBoxTextAreYouSureYouWantToQuickSave),
                                messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionPleaseConfirm),
                                callback: delegate(MyGuiScreenMessageBox.ResultEnum callbackReturn)
                                {
                                    if (callbackReturn == MyGuiScreenMessageBox.ResultEnum.YES)
                                        MyAsyncSaving.Start(() => MySector.ResetEyeAdaptation = true);//black screen after save
                                });
                            messageBox.SkipTransition = true;
                            messageBox.CloseBeforeCallback = true;
                            MyGuiSandbox.AddScreen(messageBox);
                        }
                    }
                    else
                        MyHud.Notifications.Add(MyNotificationSingletons.ClientCannotSave);
                }
                else if (Sync.IsServer)
                {
                    ShowLoadMessageBox(currentSession);
                }
                else
                {
                    // Is multiplayer client, reconnect
                    ShowReconnectMessageBox();
                }
            }

            //  Launch main menu
            if (MyInput.Static.IsNewKeyPressed(MyKeys.Escape)
                || MyControllerHelper.IsControl(context, MyControlsGUI.MAIN_MENU, MyControlStateType.NEW_PRESSED))
            {
                MyGuiAudio.PlaySound(MyGuiSounds.HudMouseClick);

                //Allow changing video options from game in DX version
                MyGuiScreenMainMenu.AddMainMenu();
            }

            if (MyInput.Static.IsNewKeyPressed(MyKeys.F3))
            {
                if (Sync.MultiplayerActive)
                {
                    MyGuiAudio.PlaySound(MyGuiSounds.HudMouseClick);
                    MyGuiSandbox.AddScreen(new MyGuiScreenPlayers());
                }
                else
                    MyHud.Notifications.Add(MyNotificationSingletons.MultiplayerDisabled);
            }

            if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.BUILD_SCREEN) && MyGuiScreenGamePlay.ActiveGameplayScreen == null)
            {
                if (MyGuiScreenCubeBuilder.Static == null && (MySession.ControlledEntity is MyShipController || MySession.ControlledEntity is MyCharacter))
                {
                    int offset = 0;
                    if (MyInput.Static.IsAnyShiftKeyPressed()) offset += 6;
                    if (MyInput.Static.IsAnyCtrlKeyPressed()) offset += 12;
                    MyGuiAudio.PlaySound(MyGuiSounds.HudMouseClick);
                    MyGuiSandbox.AddScreen(
                        MyGuiScreenGamePlay.ActiveGameplayScreen = MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.ToolbarConfigScreen,
                                                                                             offset,
                                                                                             MySession.ControlledEntity as MyShipController)
                    );
                }
            }

            if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.PAUSE_GAME))
            {
                MySandboxGame.UserPauseToggle();
            }

            if (MySession.Static != null)
            {
                if (MyInput.Static.IsNewKeyPressed(MyKeys.F10))
                {
                    if (MyPerGameSettings.GUI.VoxelMapEditingScreen != null && MySession.Static.CreativeMode && MyInput.Static.IsAnyShiftKeyPressed())
                    { // Shift+F10
                        MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.VoxelMapEditingScreen));
                    }
                    else
                    { // F10
                        if (MyFakes.ENABLE_BATTLE_SYSTEM && MySession.Static.Battle)
                        {
                            if (MyPerGameSettings.GUI.BattleBlueprintScreen != null)
                                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.BattleBlueprintScreen));
                            else
                                Debug.Fail("No battle blueprint screen");
                        }
                        else
                            MyGuiSandbox.AddScreen(new MyGuiBlueprintScreen(MyCubeBuilder.Static.Clipboard));
                    }
                }
            }

            // F11, mod debug
            if (MyInput.Static.IsNewKeyPressed(MyKeys.F11) && !MyInput.Static.IsAnyShiftKeyPressed() && !MyInput.Static.IsAnyCtrlKeyPressed())
            {
                MyDX9Gui.SwitchModDebugScreen();
            }
        }
        private void AddGroupBox(String text, Type screenType, List<MyGuiControlBase> controlGroup)
        {
            MyGuiControlCheckbox checkBox = AddCheckBox(text, true, null, controlGroup: controlGroup);

            checkBox.IsChecked = s_activeScreen != null && s_activeScreen.GetType() == screenType;
            checkBox.UserData = screenType;

            s_groupList.Add(checkBox);

            checkBox.IsCheckedChanged += delegate(MyGuiControlCheckbox sender)
            {
                var senderScreenType = sender.UserData as Type;
                if (sender.IsChecked)
                {
                    foreach (MyGuiControlCheckbox chb in s_groupList)
                    {
                        if (chb != sender)
                        {
                            chb.IsChecked = false;
                        }
                    }
                    var newScreen = (MyGuiScreenBase)Activator.CreateInstance(senderScreenType);
                    newScreen.Closed += (source) =>
                    {
                        if (source == s_activeScreen) s_activeScreen = null;
                    };
                    MyGuiSandbox.AddScreen(newScreen);
                    s_activeScreen = newScreen;
                }
                else if (s_activeScreen != null && s_activeScreen.GetType() == senderScreenType)
                {
                    s_activeScreen.CloseScreen();
                }
            };
        }
Пример #32
0
 public void AddScreen(MyGuiScreenBase screen)
 {
     MyScreenManager.AddScreen(screen);
 }
Пример #33
0
 public void RemoveScreen(MyGuiScreenBase screen)
 {
     MyScreenManager.RemoveScreen(screen);
 }
Пример #34
0
 string GetMouseOverTexture(MyGuiScreenBase screen)
 {
     if (screen != null)
     {
         var mouseOverControl = screen.GetMouseOverControl();
         if (mouseOverControl != null)
         {
             return mouseOverControl.GetMouseCursorTexture() ?? MyGuiManager.GetMouseCursorTexture();
         }
     }
     return MyGuiManager.GetMouseCursorTexture();
 }
Пример #35
0
 public void RemoveScreen(MyGuiScreenBase screen)
 {
 }
Пример #36
0
        void OnBlueprintScreen_Closed(MyGuiScreenBase source)
        {
            ResourceSink.Update();
            UpdateIsWorking();
            if (m_clipboard.CopiedGrids.Count == 0 || !IsWorking)
            {
                RemoveProjection(false);
                return;
            }
            if (m_clipboard.GridSize != CubeGrid.GridSize)
            {
                RemoveProjection(false);
                ShowNotification(MySpaceTexts.NotificationProjectorGridSize);
                return;
            }
            if (m_clipboard.CopiedGrids.Count > 1)
            {
                ShowNotification(MySpaceTexts.NotificationProjectorMultipleGrids);
            }

            int largestGridIndex = -1;
            int largestGridBlockCount = -1;
            for (int i = 0; i < m_clipboard.CopiedGrids.Count; i++)
            {
                int currentGridBlockCount = m_clipboard.CopiedGrids[i].CubeBlocks.Count;
                if (currentGridBlockCount > largestGridBlockCount)
                {
                    largestGridBlockCount = currentGridBlockCount;
                    largestGridIndex = i;
                }
            }

            ParallelTasks.Parallel.Start(delegate()
            {
                m_originalGridBuilder = (MyObjectBuilder_CubeGrid)m_clipboard.CopiedGrids[largestGridIndex].Clone();
                m_clipboard.ProcessCubeGrid(m_clipboard.CopiedGrids[largestGridIndex]);
                MyEntities.RemapObjectBuilder(m_originalGridBuilder);
            }, 
            delegate()
            {
                SendNewBlueprint(m_originalGridBuilder);
            });
        }
Пример #37
0
        //  Sends input (keyboard/mouse) to screen which has focus (top-most)
        public static void HandleInput()
        {
            ProfilerShort.Begin("MyScreenManager.HandleInput");
            try
            {
                //  Forward input to screens only if there are screens and if game has focus (is active)
                if (m_screens.Count <= 0)
                {
                    return;
                }

                //  Get screen from top of the stack - that one has focus
                MyGuiScreenBase screenWithFocus = GetScreenWithFocus();

                if (m_inputToNonFocusedScreens)
                {
                    bool inputIsShared = false;

                    for (int i = (m_screens.Count - 1); i >= 0; i--)
                    {
                        MyGuiScreenBase screen = m_screens[i];
                        ProfilerShort.Begin(screen.GetType().Name);
                        if (screen.CanShareInput())
                        {
                            screen.HandleInput(m_lastScreenWithFocus != screenWithFocus);
                            inputIsShared = true;
                        }
                        else if (!inputIsShared && screen == screenWithFocus)
                        {
                            screen.HandleInput(m_lastScreenWithFocus != screenWithFocus);
                        }
                        ProfilerShort.End();
                    }

                    m_inputToNonFocusedScreens &= inputIsShared;
                }
                else
                {
                    foreach (var screen in m_screens)
                    {
                        if (screen != screenWithFocus)
                        {
                            screen.InputLost();
                        }
                    }

                    if (screenWithFocus != null)
                    {
                        switch (screenWithFocus.State)
                        {
                        case MyGuiScreenState.OPENED:
                        case MyGuiScreenState.OPENING:
                        case MyGuiScreenState.UNHIDING:
                            ProfilerShort.Begin(screenWithFocus.GetType().Name);
                            screenWithFocus.HandleInput(m_lastScreenWithFocus != screenWithFocus);
                            ProfilerShort.End();
                            break;

                        case MyGuiScreenState.CLOSING:
                        case MyGuiScreenState.HIDING:
                            break;

                        default:
                            Debug.Fail(string.Format("Focused screen in state {0}.", screenWithFocus.State));
                            break;
                        }
                    }
                }

                m_lastScreenWithFocus = screenWithFocus;
            }
            finally { ProfilerShort.End(); }
        }
Пример #38
0
 private void AddCloseHandler(MyGuiScreenBase previousScreen, MyGuiScreenLogo logoScreen, Action afterLogosAction)
 {
     previousScreen.Closed += (screen) =>
     {
         if (!screen.Cancelled)
             AddScreen(logoScreen);
         else
             afterLogosAction();
     };
 }
        //  This method is called every update (but only if application has focus)
        public override void HandleUnhandledInput(bool receivedFocusInThisUpdate)
        {
            //  Launch main menu
            var controlledObject = MySession.Static.ControlledEntity;
            var currentCameraController = MySession.Static.CameraController;
            MyStringId context = controlledObject != null ? controlledObject.ControlContext : MySpaceBindingCreator.CX_BASE;

            if (MyInput.Static.IsNewKeyPressed(MyKeys.Escape)
                || MyControllerHelper.IsControl(context, MyControlsGUI.MAIN_MENU, MyControlStateType.NEW_PRESSED))
            {
                MyGuiAudio.PlaySound(MyGuiSounds.HudMouseClick);

                //Allow changing video options from game in DX version
                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.MainMenu, MySandboxGame.IsPaused == false));
            }

            if (DisableInput)
                return;


            if (MyInput.Static.ENABLE_DEVELOPER_KEYS || (MySession.Static != null && MySession.Static.Settings.EnableSpectator) || (MyMultiplayer.Static != null && MySession.Static.LocalHumanPlayer != null && (MyMultiplayer.Static.IsAdmin(MySession.Static.LocalHumanPlayer.Id.SteamId) || MySession.Static.IsAdminModeEnabled(MySession.Static.LocalHumanPlayer.Id.SteamId))))
            {
                //Set camera to player
                if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.SPECTATOR_NONE))
                {
                    if (MySession.Static.ControlledEntity != null)
                    { //we already are controlling this object

                        if (MyFinalBuildConstants.IS_OFFICIAL)
                        {
                            SetCameraController();
                        }
                        else
                        {
                            var cameraController = MySession.Static.GetCameraControllerEnum();
                            if (cameraController != MyCameraControllerEnum.Entity && cameraController != MyCameraControllerEnum.ThirdPersonSpectator)
                            {
                                SetCameraController();
                            }
                            else
                            {
                                var entities = MyEntities.GetEntities().ToList();
                                int lastKnownIndex = entities.IndexOf(MySession.Static.ControlledEntity.Entity);

                                var entitiesList = new List<MyEntity>();
                                if (lastKnownIndex + 1 < entities.Count)
                                    entitiesList.AddRange(entities.GetRange(lastKnownIndex + 1, entities.Count - lastKnownIndex - 1));

                                if (lastKnownIndex != -1)
                                {
                                    entitiesList.AddRange(entities.GetRange(0, lastKnownIndex + 1));
                                }

                                MyCharacter newControlledObject = null;

                                for (int i = 0; i < entitiesList.Count; i++)
                                {
                                    var character = entitiesList[i] as MyCharacter;
                                    if (character != null && !character.IsDead && character.ControllerInfo.Controller == null)
                                    {
                                        newControlledObject = character;
                                        break;
                                    }
                                }

                                if (MySession.Static.LocalHumanPlayer != null && newControlledObject != null)
                                {
                                    MySession.Static.LocalHumanPlayer.Controller.TakeControl(newControlledObject);
                                }
                            }

                            // We could have activated the cube builder in spectator, so deactivate it now
                            if (!(MySession.Static.ControlledEntity is MyCharacter))
                                MySession.Static.GameFocusManager.Clear();//MyCubeBuilder.Static.Deactivate();
                        }
                    }
                }

                //Set camera to following third person
                if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.SPECTATOR_DELTA))
                {
                    if (MySession.Static.ControlledEntity != null && SpectatorEnabled)
                    {
                        MySpectatorCameraController.Static.TurnLightOff();
                        MySession.Static.SetCameraController(MyCameraControllerEnum.SpectatorDelta);
                    }
                }

                //Set camera to spectator
                if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.SPECTATOR_FREE))
                {
                    if (SpectatorEnabled)
                    {
                        if (MySession.Static.GetCameraControllerEnum() != MyCameraControllerEnum.Spectator)
                        {
                            MySession.Static.SetCameraController(MyCameraControllerEnum.Spectator);
                        }
                        else if (MyInput.Static.IsAnyShiftKeyPressed())
                        {
                            MySpectatorCameraController.Static.AlignSpectatorToGravity = !MySpectatorCameraController.Static.AlignSpectatorToGravity;
                        }

                        if (MyInput.Static.IsAnyCtrlKeyPressed() && MySession.Static.ControlledEntity != null)
                        {
                            MySpectator.Static.Position = (Vector3D)MySession.Static.ControlledEntity.Entity.PositionComp.GetPosition() + MySpectator.Static.ThirdPersonCameraDelta;
                            MySpectator.Static.Target = (Vector3D)MySession.Static.ControlledEntity.Entity.PositionComp.GetPosition();
                        }
                    }
                }

                //Set camera to static spectator, non movable
                if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.SPECTATOR_STATIC))
                {
                    if (MySession.Static.ControlledEntity != null)
                    {
                        MySpectatorCameraController.Static.TurnLightOff();
                        MySession.Static.SetCameraController(MyCameraControllerEnum.SpectatorFixed);

                        if (MyInput.Static.IsAnyCtrlKeyPressed())
                        {
                            MySpectator.Static.Position = (Vector3D)MySession.Static.ControlledEntity.Entity.PositionComp.GetPosition() + MySpectator.Static.ThirdPersonCameraDelta;
                            MySpectator.Static.Target = (Vector3D)MySession.Static.ControlledEntity.Entity.PositionComp.GetPosition();
                        }
                    }
                }

                // This was added because planets, CTG testers were frustrated from testing, because they can't move in creative
                if (MySession.Static != null && (MySession.Static.CreativeMode || MySession.Static.IsAdminModeEnabled(Sync.MyId)) && MyInput.Static.IsNewKeyPressed(MyKeys.Space) && MyInput.Static.IsAnyCtrlKeyPressed())
                {
                    if (MySession.Static.CameraController == MySpectator.Static && MySession.Static.ControlledEntity != null)
                    {
                        MySession.Static.ControlledEntity.Teleport(MySpectator.Static.Position);
                    }
                }

                //Open console
                if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.CONSOLE) && MyInput.Static.IsAnyAltKeyPressed())
                {
                    MyGuiScreenConsole.Show();
                }
            }

            if (MyDefinitionErrors.ShouldShowModErrors)
            {
                MyDefinitionErrors.ShouldShowModErrors = false;
                MyGuiSandbox.ShowModErrors();
            }

            // Switch view - cockpit on/off, third person
            if ((MyInput.Static.IsNewGameControlPressed(MyControlsSpace.CAMERA_MODE)
                || MyControllerHelper.IsControl(MyControllerHelper.CX_CHARACTER, MyControlsSpace.CAMERA_MODE))
                && CanSwitchCamera)
            {
                MyGuiAudio.PlaySound(MyGuiSounds.HudClick);
                SwitchCamera();
            }

            if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.HELP_SCREEN))
            {
                if (MyInput.Static.IsAnyShiftKeyPressed())
                {
                    switch (MySandboxGame.Config.DebugComponentsInfo)
                    {
                        case MyDebugComponent.MyDebugComponentInfoState.NoInfo:
                            MySandboxGame.Config.DebugComponentsInfo = MyDebugComponent.MyDebugComponentInfoState.EnabledInfo;
                            break;
                        case MyDebugComponent.MyDebugComponentInfoState.EnabledInfo:
                            MySandboxGame.Config.DebugComponentsInfo = MyDebugComponent.MyDebugComponentInfoState.FullInfo;
                            break;
                        case MyDebugComponent.MyDebugComponentInfoState.FullInfo:
                            MySandboxGame.Config.DebugComponentsInfo = MyDebugComponent.MyDebugComponentInfoState.NoInfo;
                            break;
                    }

                    MySandboxGame.Config.Save();
                }
                else if (MyInput.Static.IsAnyCtrlKeyPressed() && MyPerGameSettings.GUI.PerformanceWarningScreen != null)
                {
                    MyGuiAudio.PlaySound(MyGuiSounds.HudMouseClick);
                    MyGuiSandbox.AddScreen(MyGuiScreenGamePlay.ActiveGameplayScreen = MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.PerformanceWarningScreen));
                }
                else
                    if (MyGuiScreenGamePlay.ActiveGameplayScreen == null)
                    {
                        MyGuiAudio.PlaySound(MyGuiSounds.HudMouseClick);
                        MyGuiSandbox.AddScreen(MyGuiScreenGamePlay.ActiveGameplayScreen = MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.HelpScreen));
                    }
            }

            if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.TOGGLE_HUD))
            {
                MyGuiAudio.PlaySound(MyGuiSounds.HudClick);
                MyHud.MinimalHud = !MyHud.MinimalHud;
            }

            if (MyPerGameSettings.SimplePlayerNames && MyInput.Static.IsNewGameControlPressed(MyControlsSpace.BROADCASTING))
            {
                MyHud.LocationMarkers.Visible = !MyHud.LocationMarkers.Visible;
            }

            if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.MISSION_SETTINGS) && MyGuiScreenGamePlay.ActiveGameplayScreen == null
                && MyPerGameSettings.Game == Sandbox.Game.GameEnum.SE_GAME
                && MyFakes.ENABLE_MISSION_TRIGGERS)
            {
                if (MySession.Static.Settings.ScenarioEditMode)
                    MyGuiSandbox.AddScreen(new Sandbox.Game.Screens.MyGuiScreenMissionTriggers());
                else
                    if (MySession.Static.IsScenario)
                        MyGuiSandbox.AddScreen(new Sandbox.Game.Screens.MyGuiScreenBriefing());
            }

            bool handledByUseObject = false;
            if (MySession.Static.ControlledEntity is VRage.Game.Entity.UseObject.IMyUseObject)
            {
                handledByUseObject = (MySession.Static.ControlledEntity as VRage.Game.Entity.UseObject.IMyUseObject).HandleInput();
            }

            if (controlledObject != null && !handledByUseObject)
            {
                if (!MySandboxGame.IsPaused)
                {
                    if (MyFakes.ENABLE_NON_PUBLIC_GUI_ELEMENTS && MyInput.Static.IsNewKeyPressed(MyKeys.F2))
                    {
                        if (MyInput.Static.IsAnyShiftKeyPressed() && !MyInput.Static.IsAnyCtrlKeyPressed() && !MyInput.Static.IsAnyAltKeyPressed())
                        {
                            if (MySession.Static.Settings.GameMode == VRage.Library.Utils.MyGameModeEnum.Creative)
                                MySession.Static.Settings.GameMode = VRage.Library.Utils.MyGameModeEnum.Survival;
                            else
                                MySession.Static.Settings.GameMode = VRage.Library.Utils.MyGameModeEnum.Creative;
                        }
                    }

                    if (context == MySpaceBindingCreator.CX_BUILD_MODE || context == MySpaceBindingCreator.CX_CHARACTER || context == MySpaceBindingCreator.CX_SPACESHIP)
                    {
                        if (MyControllerHelper.IsControl(context, MyControlsSpace.PRIMARY_TOOL_ACTION, MyControlStateType.NEW_PRESSED))
                        {
                            if (MyToolbarComponent.CurrentToolbar.ShouldActivateSlot)
                            {
                                MyToolbarComponent.CurrentToolbar.ActivateStagedSelectedItem();
                            }
                            else
                            {
                                controlledObject.BeginShoot(MyShootActionEnum.PrimaryAction);
                            }
                        }

                        if (MyControllerHelper.IsControl(context, MyControlsSpace.PRIMARY_TOOL_ACTION, MyControlStateType.NEW_RELEASED))
                        {
                            controlledObject.EndShoot(MyShootActionEnum.PrimaryAction);
                        }
                        if (MyControllerHelper.IsControl(context, MyControlsSpace.SECONDARY_TOOL_ACTION, MyControlStateType.NEW_PRESSED))
                        {
                            controlledObject.BeginShoot(MyShootActionEnum.SecondaryAction);
                        }
                        if (MyControllerHelper.IsControl(context, MyControlsSpace.SECONDARY_TOOL_ACTION, MyControlStateType.NEW_RELEASED))
                        {
                            controlledObject.EndShoot(MyShootActionEnum.SecondaryAction);
                        }
                    }

                    if (context == MySpaceBindingCreator.CX_CHARACTER || context == MySpaceBindingCreator.CX_SPACESHIP)
                    {
                        if (MyControllerHelper.IsControl(context, MyControlsSpace.USE, MyControlStateType.NEW_PRESSED))
                        {
                            // Key press
                            if (currentCameraController != null)
                            {
                                if (!currentCameraController.HandleUse())
                                {
                                    controlledObject.Use();
                                }
                            }
                            else
                            {
                                controlledObject.Use();
                            }
                        }
                        else if (MyControllerHelper.IsControl(context, MyControlsSpace.USE, MyControlStateType.PRESSED))
                        {
                            // Key not pressed this frame, holding from previous
                            controlledObject.UseContinues();
                        }
                        else if (MyControllerHelper.IsControl(context, MyControlsSpace.USE, MyControlStateType.NEW_RELEASED))
                        {
                            controlledObject.UseFinished();
                        }
                        
                        if (MyControllerHelper.IsControl(context, MyControlsSpace.PICK_UP, MyControlStateType.NEW_PRESSED))
                        {
                            // Key press
                            if (currentCameraController != null)
                            {
                                if (!currentCameraController.HandlePickUp())
                                    controlledObject.PickUp();
                            }
                            else
                            {
                                controlledObject.PickUp();
                            }
                        }
                        else if (MyControllerHelper.IsControl(context, MyControlsSpace.PICK_UP, MyControlStateType.PRESSED))
                        {
                            controlledObject.PickUpContinues();
                        }
                        else if (MyControllerHelper.IsControl(context, MyControlsSpace.PICK_UP, MyControlStateType.NEW_RELEASED))
                        {
                            controlledObject.PickUpFinished();
                        }

                        //Temp fix until spectators are implemented as entities
                        //Prevents controlled object from getting input while spectator mode is enabled
                        if (!(MySession.Static.CameraController is MySpectatorCameraController && MySpectatorCameraController.Static.SpectatorCameraMovement == MySpectatorCameraMovementEnum.UserControlled))
                        {
                            if (MyControllerHelper.IsControl(context, MyControlsSpace.CROUCH, MyControlStateType.NEW_PRESSED))
                            {
                                controlledObject.Crouch();
                            }
                            if (MyControllerHelper.IsControl(context, MyControlsSpace.CROUCH, MyControlStateType.PRESSED))
                            {
                                controlledObject.Down();
                            }

                            if (MyControllerHelper.IsControl(context, MyControlsSpace.SPRINT, MyControlStateType.NEW_PRESSED))
                            {
                                controlledObject.Sprint(true);
                            }
                            else if (MyControllerHelper.IsControl(context, MyControlsSpace.SPRINT, MyControlStateType.NEW_RELEASED))
                            {
                                controlledObject.Sprint(false);
                            }

                            if (MyControllerHelper.IsControl(context, MyControlsSpace.JUMP, MyControlStateType.NEW_PRESSED))
                            {
                                controlledObject.Jump();
                            }
                            if (MyControllerHelper.IsControl(context, MyControlsSpace.JUMP, MyControlStateType.PRESSED))
                            {
                                controlledObject.Up();
                            }
                            if (MyControllerHelper.IsControl(context, MyControlsSpace.SWITCH_WALK, MyControlStateType.NEW_PRESSED))
                            {
                                controlledObject.SwitchWalk();
                            }
                            if (MyControllerHelper.IsControl(context, MyControlsSpace.BROADCASTING, MyControlStateType.NEW_PRESSED))
                            {
                                controlledObject.SwitchBroadcasting();
                            }
                            if (MyControllerHelper.IsControl(context, MyControlsSpace.HELMET, MyControlStateType.NEW_PRESSED))
                            {
                                controlledObject.SwitchHelmet();
                            }
                        }

                        if (MyControllerHelper.IsControl(context, MyControlsSpace.DAMPING, MyControlStateType.NEW_PRESSED))
                        {
                            MyGuiAudio.PlaySound(MyGuiSounds.HudClick);
                            controlledObject.SwitchDamping();
                        }
                        if (MyControllerHelper.IsControl(context, MyControlsSpace.THRUSTS, MyControlStateType.NEW_PRESSED))
                        {
                            if (controlledObject is MyCharacter == false)
                                MyGuiAudio.PlaySound(MyGuiSounds.HudClick);
                            controlledObject.SwitchThrusts();
                        }
                        if (MyControllerHelper.IsControl(context, MyControlsSpace.HEADLIGHTS, MyControlStateType.NEW_PRESSED))
                        {
                            //Switch lights only on Spectator Mode
                            if (MySession.Static.ControlledEntity != null && MySession.Static.CameraController is MySpectatorCameraController && MySpectatorCameraController.Static.SpectatorCameraMovement == MySpectatorCameraMovementEnum.UserControlled)
                            {
                                MySpectatorCameraController.Static.SwitchLight();
                            }
                            else
                            {
                                MyGuiAudio.PlaySound(MyGuiSounds.HudClick);
                                controlledObject.SwitchLights();
                            }
                        }
                        if (MyControllerHelper.IsControl(context, MyControlsSpace.TOGGLE_REACTORS, MyControlStateType.NEW_PRESSED))
                        {
                            MyGuiAudio.PlaySound(MyGuiSounds.HudClick);
                            controlledObject.SwitchReactors();
                        }
                        if (MyControllerHelper.IsControl(context, MyControlsSpace.LANDING_GEAR, MyControlStateType.NEW_PRESSED))
                        {
                            controlledObject.SwitchLeadingGears();
                        }
                        if (MyControllerHelper.IsControl(context, MyControlsSpace.SUICIDE, MyControlStateType.NEW_PRESSED))
                        {
                            controlledObject.Die();
                        }
                        if ((controlledObject as MyCockpit) != null && MyControllerHelper.IsControl(context, MyControlsSpace.CUBE_COLOR_CHANGE, MyControlStateType.NEW_PRESSED))
                        {
                            (controlledObject as MyCockpit).SwitchWeaponMode();
                        }
                    }
                }
                else
                {
                    controlledObject.EndShoot(MyShootActionEnum.PrimaryAction);
                    controlledObject.EndShoot(MyShootActionEnum.SecondaryAction);
                }

                if (MySandboxGame.IsPaused == false)
                {
                    if (MyControllerHelper.IsControl(context, MyControlsSpace.TERMINAL, MyControlStateType.NEW_PRESSED) && MyGuiScreenGamePlay.ActiveGameplayScreen == null)
                    {
                        MyGuiAudio.PlaySound(MyGuiSounds.HudClick);
                        controlledObject.ShowTerminal();
                    }

                    if (MyControllerHelper.IsControl(context, MyControlsSpace.INVENTORY, MyControlStateType.NEW_PRESSED) && MyGuiScreenGamePlay.ActiveGameplayScreen == null)
                    {
                        MyGuiAudio.PlaySound(MyGuiSounds.HudClick);
                        controlledObject.ShowInventory();
                    }

                    if (MyControllerHelper.IsControl(context, MyControlsSpace.CONTROL_MENU, MyControlStateType.NEW_PRESSED) && MyGuiScreenGamePlay.ActiveGameplayScreen == null)
                    {
                        MyGuiAudio.PlaySound(MyGuiSounds.HudClick);
                        m_controlMenu.OpenControlMenu(controlledObject);
                    }
                }
            }
            if (!VRage.Profiler.MyRenderProfiler.ProfilerVisible && MyControllerHelper.IsControl(context, MyControlsSpace.CHAT_SCREEN, MyControlStateType.NEW_PRESSED))
            {
                if (MyGuiScreenChat.Static == null)
                {
                    Vector2 chatPos = new Vector2(0.025f, 0.84f);
                    chatPos = MyGuiScreenHudBase.ConvertHudToNormalizedGuiPosition(ref chatPos);
                    MyGuiScreenChat chatScreen = new MyGuiScreenChat(chatPos);
                    MyGuiSandbox.AddScreen(chatScreen);
                }
            }

            if (MyPerGameSettings.VoiceChatEnabled && MyVoiceChatSessionComponent.Static != null)
            {
                if (MyControllerHelper.IsControl(context, MyControlsSpace.VOICE_CHAT, MyControlStateType.NEW_PRESSED))
                {
                    MyVoiceChatSessionComponent.Static.StartRecording();
                }
                else if (MyVoiceChatSessionComponent.Static.IsRecording && !MyControllerHelper.IsControl(context, MyControlsSpace.VOICE_CHAT, MyControlStateType.PRESSED))
                {
                    MyVoiceChatSessionComponent.Static.StopRecording();
                }
            }


            MoveAndRotatePlayerOrCamera();

            // Quick save or quick load.
            if (MyInput.Static.IsNewKeyPressed(MyKeys.F5))
            {
                if (!MySession.Static.IsScenario)
                {
                    MyGuiAudio.PlaySound(MyGuiSounds.HudMouseClick);
                    var currentSession = MySession.Static.CurrentPath;

                    if (MyInput.Static.IsAnyShiftKeyPressed())
                    {
                        if (Sync.IsServer)
                        {
                            if (!MyAsyncSaving.InProgress)
                            {
                                var messageBox = MyGuiSandbox.CreateMessageBox(
                                    buttonType: MyMessageBoxButtonsType.YES_NO,
                                    messageText: MyTexts.Get(MyCommonTexts.MessageBoxTextAreYouSureYouWantToQuickSave),
                                    messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionPleaseConfirm),
                                    callback: delegate(MyGuiScreenMessageBox.ResultEnum callbackReturn)
                                    {
                                        if (callbackReturn == MyGuiScreenMessageBox.ResultEnum.YES)
                                            MyAsyncSaving.Start(() => MySector.ResetEyeAdaptation = true);//black screen after save
                                    });
                                messageBox.SkipTransition = true;
                                messageBox.CloseBeforeCallback = true;
                                MyGuiSandbox.AddScreen(messageBox);
                            }
                        }
                        else
                            MyHud.Notifications.Add(MyNotificationSingletons.ClientCannotSave);
                    }
                    else if (Sync.IsServer)
                    {
                        ShowLoadMessageBox(currentSession);
                    }
                    else
                    {
                        // Is multiplayer client, reconnect
                        ShowReconnectMessageBox();
                    }
                }
            }

            if (MyInput.Static.IsNewKeyPressed(MyKeys.F3))
            {
                if (Sync.MultiplayerActive)
                {
                    MyGuiAudio.PlaySound(MyGuiSounds.HudMouseClick);
                    MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.PlayersScreen));
                }
                else
                    MyHud.Notifications.Add(MyNotificationSingletons.MultiplayerDisabled);
            }

            if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.FACTIONS_MENU) && !MyInput.Static.IsAnyCtrlKeyPressed())
            {
                //if (MyToolbarComponent.CurrentToolbar.SelectedItem == null || (MyToolbarComponent.CurrentToolbar.SelectedItem != null && MyToolbarComponent.CurrentToolbar.SelectedItem.GetType() != typeof(MyToolbarItemVoxelHand)))
                //{
                MyGuiAudio.PlaySound(MyGuiSounds.HudMouseClick);
                var screen = MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.FactionScreen);
                MyScreenManager.AddScreenNow(screen);
                //}
            }

            // Check if any of windows keys is not pressed.
            bool windowKeyPressed = MyInput.Static.IsKeyPress(MyKeys.LeftWindows) || MyInput.Static.IsKeyPress(MyKeys.RightWindows);

            if (!windowKeyPressed && MyInput.Static.IsNewGameControlPressed(MyControlsSpace.BUILD_SCREEN) && !MyInput.Static.IsAnyCtrlKeyPressed() && MyGuiScreenGamePlay.ActiveGameplayScreen == null)
            {
                if (MyPerGameSettings.GUI.EnableToolbarConfigScreen && MyGuiScreenCubeBuilder.Static == null && (MySession.Static.ControlledEntity is MyShipController || MySession.Static.ControlledEntity is MyCharacter))
                {
                    int offset = 0;
                    if (MyInput.Static.IsAnyShiftKeyPressed()) offset += 6;
                    if (MyInput.Static.IsAnyCtrlKeyPressed()) offset += 12;
                    MyGuiAudio.PlaySound(MyGuiSounds.HudMouseClick);
                    MyGuiSandbox.AddScreen(
                        MyGuiScreenGamePlay.ActiveGameplayScreen = MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.ToolbarConfigScreen,
                                                                                             offset,
                                                                                             MySession.Static.ControlledEntity as MyShipController)
                    );
                }
            }

            if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.PAUSE_GAME))
            {
                MySandboxGame.UserPauseToggle();
            }

            if (MySession.Static != null)
            {
                if (MyInput.Static.IsNewKeyPressed(MyKeys.F10))
                {
                    if (MyInput.Static.IsAnyAltKeyPressed())
                    {
                        // ALT + F10
                        if (MySession.Static.IsAdminMenuEnabled && MyPerGameSettings.Game != GameEnum.UNKNOWN_GAME)
                            MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.AdminMenuScreen));
                        else
                            MyHud.Notifications.Add(MyNotificationSingletons.AdminMenuNotAvailable);
                    }
                    else if (MyPerGameSettings.GUI.VoxelMapEditingScreen != null && (MySession.Static.IsAdminModeEnabled(Sync.MyId) || MySession.Static.CreativeMode) && MyInput.Static.IsAnyShiftKeyPressed())
                    {
                        // Shift + F10
                        MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.VoxelMapEditingScreen));
                    }
                    else
                    {
                        // F10
                        if (MyFakes.ENABLE_BATTLE_SYSTEM && MySession.Static.Battle)
                        {
                            if (MyPerGameSettings.GUI.BattleBlueprintScreen != null)
                                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.BattleBlueprintScreen));
                            else
                                Debug.Fail("No battle blueprint screen");
                        }
                        else
                            MyGuiSandbox.AddScreen(new MyGuiBlueprintScreen(MyClipboardComponent.Static.Clipboard, MySession.Static.CreativeMode || MySession.Static.IsAdminModeEnabled(Sync.MyId)));
                    }
                }
            }

            // F11, mod debug
            if (MyInput.Static.IsNewKeyPressed(MyKeys.F11) && !MyInput.Static.IsAnyShiftKeyPressed() && !MyInput.Static.IsAnyCtrlKeyPressed())
            {
                MyDX9Gui.SwitchModDebugScreen();
            }
        }
Пример #40
0
 public void AddScreen(MyGuiScreenBase screen)
 {
 }
Пример #41
0
 private static bool IsScreenTransitioning(MyGuiScreenBase screen)
 {
     return((screen.State == MyGuiScreenState.CLOSING || screen.State == MyGuiScreenState.OPENING) ||
            (screen.State == MyGuiScreenState.HIDING || screen.State == MyGuiScreenState.UNHIDING));
 }