private void AddGroupBox(string text, ModDebugScreenComponent screenType, List <MyGuiControlBase> controlGroup) { var box = AddCheckBox(text, true, null, controlGroup: controlGroup); box.IsChecked = false; box.OnCheckedChanged += sender => { if (sender.IsChecked) { foreach (var myGuiControlBase in controlGroup) { if (myGuiControlBase != sender && myGuiControlBase is MyGuiControlCheckbox chb) { chb.IsChecked = false; } } var newScreen = screenType.Construct(); newScreen.Closed += source => box.IsChecked = false; _activeScreen?.CloseScreen(); _container.AddScreen(newScreen); _activeScreen = newScreen; } else if (_activeScreen != null && _activeScreen.GetType() == screenType.ScreenType) { _container.RemoveScreen(_activeScreen); _activeScreen = null; } }; }
private void SwitchTimingScreen() { if (!(m_currentStatisticsScreen is MyGuiScreenDebugTiming)) { if (m_currentStatisticsScreen != null) { RemoveScreen(m_currentStatisticsScreen); } AddScreen(m_currentStatisticsScreen = new MyGuiScreenDebugTiming()); } else { Debug.Assert(MyRenderProxy.DrawRenderStats != MyRenderProxy.MyStatsState.NoDraw); if (MyRenderProxy.DrawRenderStats == MyRenderProxy.MyStatsState.ShouldFinish) { // We finished cycling through stat groups RemoveScreen(m_currentStatisticsScreen); m_currentStatisticsScreen = null; } else { MyRenderProxy.DrawRenderStats = MyRenderProxy.MyStatsState.MoveNext; } } }
private void RemoveActiveScreen() { if (_activeScreen == null) { return; } _container.RemoveScreen(_activeScreen); _activeScreen = null; }
private static void ShowModDebugScreen() { if (m_currentDebugScreen == null) { MyScreenManager.AddScreen(m_currentDebugScreen = new MyGuiScreenDebugOfficial()); m_currentDebugScreen.Closed += (screen) => m_currentDebugScreen = null; } else if (m_currentDebugScreen is MyGuiScreenDebugOfficial) { m_currentDebugScreen.RecreateControls(false); } }
private void F12Handling() { if (MyInput.Static.IsNewKeyPressed(MyKeys.F12)) { if (MyInput.Static.ENABLE_DEVELOPER_KEYS) { ShowDeveloperDebugScreen(); } else { if (m_currentDebugScreen is MyGuiScreenDebugDeveloper) { RemoveScreen(m_currentDebugScreen); m_currentDebugScreen = null; } else { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption : MyTexts.Get(MyCommonTexts.MessageBoxF12Question), messageText : MyTexts.Get(MyCommonTexts.MessageBoxTextF12Question), buttonType : MyMessageBoxButtonsType.YES_NO, callback : delegate(MyGuiScreenMessageBox.ResultEnum result) { if (result == MyGuiScreenMessageBox.ResultEnum.YES) { ShowDeveloperDebugScreen(); } })); } } } if (MyFakes.ALT_AS_DEBUG_KEY) { MyScreenManager.InputToNonFocusedScreens = MyInput.Static.IsAnyAltKeyPressed() && !MyInput.Static.IsKeyPress(MyKeys.Tab); } else { MyScreenManager.InputToNonFocusedScreens = MyInput.Static.IsKeyPress(MyKeys.ScrollLock) && !MyInput.Static.IsKeyPress(MyKeys.Tab); } if (MyScreenManager.InputToNonFocusedScreens != m_wasInputToNonFocusedScreens) { if (MyScreenManager.InputToNonFocusedScreens && m_currentDebugScreen != null) { SetMouseCursorVisibility(MyScreenManager.InputToNonFocusedScreens); } m_wasInputToNonFocusedScreens = MyScreenManager.InputToNonFocusedScreens; } }
private void ShowDeveloperDebugScreen() { if (!(m_currentDebugScreen is MyGuiScreenDebugOfficial) && !(m_currentDebugScreen is MyGuiScreenDebugDeveloper)) { if (m_currentDebugScreen != null) { RemoveScreen(m_currentDebugScreen); } var devScreen = new MyGuiScreenDebugDeveloper(); AddScreen(m_currentDebugScreen = devScreen); m_currentDebugScreen.Closed += (screen) => m_currentDebugScreen = null; } }
private void SwitchInputScreen() { if (!(m_currentStatisticsScreen is MyGuiScreenDebugInput)) { if (m_currentStatisticsScreen != null) { RemoveScreen(m_currentStatisticsScreen); } AddScreen(m_currentStatisticsScreen = new MyGuiScreenDebugInput()); } else { RemoveScreen(m_currentStatisticsScreen); m_currentStatisticsScreen = null; } }
public static void SwitchModDebugScreen() { if (MyInput.Static.ENABLE_DEVELOPER_KEYS || !Sync.MultiplayerActive) { if (m_currentDebugScreen != null) { if (m_currentDebugScreen is MyGuiScreenDebugOfficial) { m_currentDebugScreen.CloseScreen(); m_currentDebugScreen = null; } } else { ShowModDebugScreen(); } } }
private void SwitchStatisticsScreen() { #if !XB1 if (!(m_currentStatisticsScreen is MyGuiScreenDebugStatistics)) { if (m_currentStatisticsScreen != null) { RemoveScreen(m_currentStatisticsScreen); } AddScreen(m_currentStatisticsScreen = new MyGuiScreenDebugStatistics()); } else { RemoveScreen(m_currentStatisticsScreen); m_currentStatisticsScreen = null; } #else // XB1 System.Diagnostics.Debug.Assert(false, "XB1 TODO?"); #endif // XB1 }
private static void SwitchStatisticsScreen() { if (!(m_currentStatisticsScreen is MyGuiScreenDebugStatistics)) { if (m_currentStatisticsScreen != null) RemoveScreen(m_currentStatisticsScreen); AddScreen(m_currentStatisticsScreen = new MyGuiScreenDebugStatistics()); } else { RemoveScreen(m_currentStatisticsScreen); m_currentStatisticsScreen = null; } }
private void F12Handling() { if (MyInput.Static.IsNewKeyPressed(MyKeys.F12)) { if (MyInput.Static.ENABLE_DEVELOPER_KEYS) ShowDeveloperDebugScreen(); else { if (m_currentDebugScreen is MyGuiScreenDebugDeveloper) { RemoveScreen(m_currentDebugScreen); m_currentDebugScreen = null; } else { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxF12Question), messageText: MyTexts.Get(MyCommonTexts.MessageBoxTextF12Question), buttonType: MyMessageBoxButtonsType.YES_NO, callback: delegate(MyGuiScreenMessageBox.ResultEnum result) { if (result == MyGuiScreenMessageBox.ResultEnum.YES) ShowDeveloperDebugScreen(); })); } } } if (MyFakes.ALT_AS_DEBUG_KEY) { MyScreenManager.InputToNonFocusedScreens = MyInput.Static.IsAnyAltKeyPressed() && !MyInput.Static.IsKeyPress(MyKeys.Tab); } else { MyScreenManager.InputToNonFocusedScreens = MyInput.Static.IsKeyPress(MyKeys.ScrollLock) && !MyInput.Static.IsKeyPress(MyKeys.Tab); } if (MyScreenManager.InputToNonFocusedScreens != m_wasInputToNonFocusedScreens) { if (MyScreenManager.InputToNonFocusedScreens && m_currentDebugScreen != null) { SetMouseCursorVisibility(MyScreenManager.InputToNonFocusedScreens); } m_wasInputToNonFocusedScreens = MyScreenManager.InputToNonFocusedScreens; } }
private void SwitchTimingScreen() { if (!(m_currentStatisticsScreen is MyGuiScreenDebugTiming)) { if (m_currentStatisticsScreen != null) RemoveScreen(m_currentStatisticsScreen); AddScreen(m_currentStatisticsScreen = new MyGuiScreenDebugTiming()); } else { Debug.Assert(MyRenderProxy.DrawRenderStats != MyRenderProxy.MyStatsState.NoDraw); if (MyRenderProxy.DrawRenderStats == MyRenderProxy.MyStatsState.ShouldFinish) { // We finished cycling through stat groups RemoveScreen(m_currentStatisticsScreen); m_currentStatisticsScreen = null; } else { MyRenderProxy.DrawRenderStats = MyRenderProxy.MyStatsState.MoveNext; } } }
// Sends input (keyboard/mouse) to screen which has focus (top-most) public void HandleInput() { ProfilerShort.Begin("MyGuiManager.HandleInput"); try { if (MyInput.Static.IsAnyAltKeyPressed() && MyInput.Static.IsNewKeyPressed(MyKeys.F4)) { MyAnalyticsTracker.SendGameEnd("Alt+F4", MySandboxGame.TotalTimeInMilliseconds / 1000); // Exit application MySandboxGame.ExitThreadSafe(); return; } // Screenshot(s) if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.SCREENSHOT)) { MyGuiAudio.PlaySound(MyGuiSounds.HudMouseClick); TakeScreenshot(); } bool newPressf12 = MyInput.Static.IsNewKeyPressed(MyKeys.F12); bool newPressf2 = MyInput.Static.IsNewKeyPressed(MyKeys.F2); if ((newPressf2 || newPressf12) && MyInput.Static.IsAnyShiftKeyPressed() && MyInput.Static.IsAnyAltKeyPressed()) { if (MySession.Static != null && MySession.Static.CreativeMode) { if (newPressf12) { MyDebugDrawSettings.DEBUG_DRAW_PHYSICS = !MyDebugDrawSettings.DEBUG_DRAW_PHYSICS; if (!m_shapeRenderingMessageBoxShown) { m_shapeRenderingMessageBoxShown = true; AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption: new StringBuilder("PHYSICS SHAPES"), messageText: new StringBuilder("Enabled physics shapes rendering. This feature is for modders only and is not part of the gameplay."))); } } } else { AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption: new StringBuilder("MODDING HELPER KEYS"), messageText: new StringBuilder("Use of helper key combinations for modders is only allowed in creative mode."))); } return; } if (MyInput.Static.IsNewKeyPressed(MyKeys.H) && MyInput.Static.IsAnyCtrlKeyPressed()) { if (MyFakes.ENABLE_NETGRAPH) { MyHud.IsNetgraphVisible = !MyHud.IsNetgraphVisible; } } if (MyInput.Static.IsNewKeyPressed(MyKeys.F11)) { if (MyInput.Static.IsAnyShiftKeyPressed() && !MyInput.Static.IsAnyCtrlKeyPressed()) { SwitchTimingScreen(); } } if (MyFakes.ENABLE_MISSION_SCREEN && MyInput.Static.IsNewKeyPressed(MyKeys.U)) { MyScreenManager.AddScreen(new MyGuiScreenMission()); } if (!MyInput.Static.ENABLE_DEVELOPER_KEYS && Sync.MultiplayerActive && m_currentDebugScreen is MyGuiScreenDebugOfficial) { RemoveScreen(m_currentDebugScreen); m_currentDebugScreen = null; } bool inputHandled = false; if (MySession.Static != null && MySession.Static.CreativeMode || MyInput.Static.ENABLE_DEVELOPER_KEYS) { F12Handling(); } if (MyInput.Static.ENABLE_DEVELOPER_KEYS) { // Statistics screen if (MyInput.Static.IsNewKeyPressed(MyKeys.F11) && !MyInput.Static.IsAnyShiftKeyPressed() && MyInput.Static.IsAnyCtrlKeyPressed()) { SwitchStatisticsScreen(); } if (MyInput.Static.IsAnyShiftKeyPressed() && MyInput.Static.IsAnyAltKeyPressed() && MyInput.Static.IsAnyCtrlKeyPressed() && MyInput.Static.IsNewKeyPressed(MyKeys.Home)) { throw new InvalidOperationException("Controlled crash"); } // Forge GC to run if (MyInput.Static.IsNewKeyPressed(MyKeys.Pause) && MyInput.Static.IsAnyShiftKeyPressed()) { GC.Collect(GC.MaxGeneration); } if (MyInput.Static.IsAnyCtrlKeyPressed() && MyInput.Static.IsNewKeyPressed(MyKeys.F2)) { //Reload textures if (MyInput.Static.IsKeyPress(MyKeys.LeftShift)) { MyDefinitionManager.Static.ReloadDecalMaterials(); VRageRender.MyRenderProxy.ReloadTextures(); } else if (MyInput.Static.IsKeyPress(MyKeys.LeftAlt)) { VRageRender.MyRenderProxy.ReloadModels(); } else { VRageRender.MyRenderProxy.ReloadEffects(); } } //WS size if (MyInput.Static.IsNewKeyPressed(MyKeys.F3) && MyInput.Static.IsKeyPress(MyKeys.LeftShift)) { #if !XB1 WinApi.SetProcessWorkingSetSize(Process.GetCurrentProcess().Handle, -1, -1); #endif // !XB1 } inputHandled = HandleDebugInput(); } if (!inputHandled) { MyScreenManager.HandleInput(); } } finally { ProfilerShort.End(); } }
private void SwitchInputScreen() { if (!(m_currentStatisticsScreen is MyGuiScreenDebugInput)) { if (m_currentStatisticsScreen != null) RemoveScreen(m_currentStatisticsScreen); AddScreen(m_currentStatisticsScreen = new MyGuiScreenDebugInput()); } else { RemoveScreen(m_currentStatisticsScreen); m_currentStatisticsScreen = null; } }
private void ShowDeveloperDebugScreen() { if (!(m_currentDebugScreen is MyGuiScreenDebugOfficial) && !(m_currentDebugScreen is MyGuiScreenDebugDeveloper)) { if (m_currentDebugScreen != null) RemoveScreen(m_currentDebugScreen); var devScreen = new MyGuiScreenDebugDeveloper(); AddScreen(m_currentDebugScreen = devScreen); m_currentDebugScreen.Closed += (screen) => m_currentDebugScreen = null; } }
// Sends input (keyboard/mouse) to screen which has focus (top-most) public static void HandleInput() { if (m_input == null) { // No input support return; } // Update/gather input bool isGameFocused = m_input.Update(); #if RENDER_PROFILING MyRenderProfiler.HandleInput(m_input); #endif // Screenshot(s) if (m_input.IsNewKeyPress(Keys.F4)) { TakeScreenshot(); //MyVoxelMap vm = MyVoxelMaps.GetVoxelMaps()[0]; //vm.SaveVoxelContents("StaticAsteroid_A_1000m.vox"); /* MyVoxelMap voxelMap = new MyVoxelMap(); voxelMap.Init(Vector3.Zero, new MyMwcVector3Int(384, 384, 384), MyMwcVoxelMaterialsEnum.Stone_03); MyEntities.Add(voxelMap); MyEntity asteroid = MyEntities.GetEntityById(new MyEntityIdentifier(546099)); Matrix matrix = asteroid.WorldMatrix; matrix.Translation = new Vector3(); bool changed = false; MyVoxelImport.Run(voxelMap, MinerWars.AppCode.Game.Models.MyModels.GetModel(Models.MyModelsEnum.StaticAsteroid1000m_A_LOD0), MyvoxelImportAction.AddVoxels, matrix, 1, null, ref changed); BoundingBox boundingBox = voxelMap.WorldAABB; // Get min and max cell coordinate where camera bounding box can fit MyMwcVector3Int cellCoordMin = voxelMap.GetVoxelCoordinateFromMeters(boundingBox.Min); MyMwcVector3Int cellCoordMax = voxelMap.GetVoxelCoordinateFromMeters(boundingBox.Max); voxelMap.InvalidateCache(cellCoordMin, cellCoordMax); voxelMap.CalcAverageDataCellMaterials(); voxelMap.SaveVoxelContents("VoxelMap_546099.vox");*/ } // hide demo access info if (m_input.IsAnyAltKeyPressed() && m_input.IsKeyPress(Keys.G) && m_demoScreen != null) { MyGuiManager.RemoveScreen(m_demoScreen); } // Statistics screen if (m_input.IsNewKeyPress(Keys.F11)) { if (!m_input.IsAnyShiftKeyPressed() && !m_input.IsAnyCtrlKeyPressed()) { if (m_input.IsAnyAltPress()) { // ALT + F11 Dump loaded resources. //MyMinerGame.GraphicsDeviceManager.DbgDumpLoadedResources(true); MyTextureManager.DbgDumpLoadedTextures(true); } else { if (m_input.IsAnyCtrlKeyPressed()) { SwitchInputScreen(); } else { SwitchStatisticsScreen(); } } } else { if (m_input.IsAnyShiftKeyPressed()) { SwitchTimingScreen(); } else if (m_input.IsAnyCtrlKeyPressed()) { SwitchInputScreen(); } } } if (MyGuiInput.ENABLE_DEVELOPER_KEYS) { // Forge GC to run if (m_input.IsNewKeyPress(Keys.Pause) && m_input.IsAnyShiftKeyPressed()) { //if (m_input.IsAnyAltKeyPressed()) //{ // for (int i = 0; i < 2048; i++) // { // byte[] data = new byte[1024]; // Create gargabe to force GC to run // data[data.Length - 1] = 123; // } //} GC.Collect(GC.MaxGeneration); } if (m_input.IsAnyControlPress()) { //Reload textures if (m_input.IsNewKeyPress(Keys.F2) && m_input.IsKeyPress(Keys.LeftShift)) { MyTextureManager.ReloadTextures(); } } else { //Reload shaders if (m_input.IsNewKeyPress(Keys.F2) && m_input.IsKeyPress(Keys.LeftShift)) { MyMinerGame.Static.RootDirectoryEffects = MyMinerGame.Static.RootDirectoryDebug; MyRender.LoadEffects(); //m_spriteBatchOwn = new MyGuiSpriteBatchOwn(); // Reload shader in sprite batch //MyTextureManager.ReloadTextures(); } } //WS size if (m_input.IsNewKeyPress(Keys.F3) && m_input.IsKeyPress(Keys.LeftShift)) { MyUtils.SetProcessWorkingSetSize(Process.GetCurrentProcess().Handle, -1, -1); } // Forced logoff if (m_input.IsAnyCtrlKeyPressed() && m_input.IsNewKeyPress(Keys.Subtract)) { MySectorServiceClient.HardClose(); MyClientServer.Logout(); } //These keys are to be used just for developers or testing // Only for develop, on test and public, it crashes(obfuscation) //if (MyMwcFinalBuildConstants.IS_DEVELOP) { // Game debug screen if (m_input.IsNewKeyPress(Keys.F9)) { // if (m_currentDebugScreen != null) // RemoveScreen(m_currentDebugScreen); // AddScreen(m_currentDebugScreen = new MyGuiScreenDebugDeveloper()); } /* if (!(m_currentStatisticsScreen is MyGuiScreenDebugStatistics)) { if (m_currentStatisticsScreen != null) RemoveScreen(m_currentStatisticsScreen); AddScreen(m_currentStatisticsScreen = new MyGuiScreenDebugStatistics()); } */ if (m_input.IsNewKeyPress(Keys.F12)) { if (m_input.IsAnyCtrlKeyPressed() && m_input.IsAnyAltKeyPressed()) { // Simulate device lost MyMinerGame.Static.UnloadContent(); MyMinerGame.Static.LoadContent(); return; } else { // if (!MyMwcFinalBuildConstants.IS_PUBLIC) { // Develop screen if (!(m_currentDebugScreen is MyGuiScreenDebugDeveloper)) { if (m_currentDebugScreen != null) RemoveScreen(m_currentDebugScreen); AddScreen(m_currentDebugScreen = new MyGuiScreenDebugDeveloper()); } else { RemoveScreen(m_currentDebugScreen); m_currentDebugScreen = null; } } } } if (MyFakes.ALT_AS_DEBUG_KEY) { m_inputToNonFocusedScreens = m_input.IsAnyAltKeyPressed() && !m_input.IsKeyPress(Keys.Tab); } else { m_inputToNonFocusedScreens = m_input.IsKeyPress(Keys.ScrollLock) && !m_input.IsKeyPress(Keys.Tab); } } } // Forward input to screens only if there are screens and if game has focus (is active) if ((isGameFocused == true) && (m_screens.Count > 0)) { // Get screen from top of the stack - that one has focus MyGuiScreenBase screenWithFocus = GetScreenWithFocus();// m_screens[m_screens.Count - 1]; if (m_inputToNonFocusedScreens) { bool inputIsShared = false; for (int i = (m_screens.Count - 1); i >= 0; i--) { MyGuiScreenBase screen = m_screens[i]; if (screen.CanShareInput() || m_screens.Count == 1) { screen.HandleInput(m_input, m_lastScreenWithFocus != screenWithFocus); inputIsShared = true; } } m_inputToNonFocusedScreens &= inputIsShared; UpdateMouseCursor(); } else if (screenWithFocus != null) { if (screenWithFocus.GetDrawMouseCursor() == true) { UpdateMouseCursor(); } if (screenWithFocus.CanHandleInputDuringTransition() && IsScreenTransitioning(screenWithFocus)) { screenWithFocus.HandleInput(m_input, m_lastScreenWithFocus != screenWithFocus); } else if ((screenWithFocus.GetState() == MyGuiScreenState.OPENED)) { // Disallow to enter input during transition phase of screens bool handleInput = true; if (IsAnyScreenInTransition()) { handleInput = false; } if (handleInput) { // Send input to screen which has focus - and is fully opened, thus it's not in any sort of transition screenWithFocus.HandleInput(m_input, m_lastScreenWithFocus != screenWithFocus); } } } m_lastScreenWithFocus = screenWithFocus; } }
// Sends input (keyboard/mouse) to screen which has focus (top-most) public void HandleInput() { ProfilerShort.Begin("MyGuiManager.HandleInput"); try { if (MyInput.Static.IsAnyAltKeyPressed() && MyInput.Static.IsNewKeyPressed(MyKeys.F4)) { MyAnalyticsTracker.SendGameEnd("Alt+F4", MySandboxGame.TotalTimeInMilliseconds / 1000); // Exit application MySandboxGame.ExitThreadSafe(); return; } // Screenshot(s) if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.SCREENSHOT)) { MyGuiAudio.PlaySound(MyGuiSounds.HudMouseClick); TakeScreenshot(); } bool newPressf12 = MyInput.Static.IsNewKeyPressed(MyKeys.F12); bool newPressf2 = MyInput.Static.IsNewKeyPressed(MyKeys.F2); if ((newPressf2 || newPressf12) && MyInput.Static.IsAnyShiftKeyPressed() && MyInput.Static.IsAnyAltKeyPressed()) { if (MySession.Static != null && MySession.Static.CreativeMode) { if (newPressf12) { MyDebugDrawSettings.DEBUG_DRAW_PHYSICS = !MyDebugDrawSettings.DEBUG_DRAW_PHYSICS; if (!m_shapeRenderingMessageBoxShown) { m_shapeRenderingMessageBoxShown = true; AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption: new StringBuilder("PHYSICS SHAPES"), messageText: new StringBuilder("Enabled physics shapes rendering. This feature is for modders only and is not part of the gameplay."))); } } } else { AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption: new StringBuilder("MODDING HELPER KEYS"), messageText: new StringBuilder("Use of helper key combinations for modders is only allowed in creative mode."))); } return; } if (MyInput.Static.IsNewKeyPressed(MyKeys.H) && MyInput.Static.IsAnyCtrlKeyPressed()) { if (MyFakes.ENABLE_NETGRAPH) { MyHud.IsNetgraphVisible = !MyHud.IsNetgraphVisible; } } if (MyInput.Static.IsNewKeyPressed(MyKeys.F11)) { if (MyInput.Static.IsAnyShiftKeyPressed() && !MyInput.Static.IsAnyCtrlKeyPressed()) { SwitchTimingScreen(); } } if (MyFakes.ENABLE_MISSION_SCREEN && MyInput.Static.IsNewKeyPressed(MyKeys.U)) { MyScreenManager.AddScreen(new MyGuiScreenMission()); } if (!MyInput.Static.ENABLE_DEVELOPER_KEYS && Sync.MultiplayerActive && m_currentDebugScreen is MyGuiScreenDebugOfficial) { RemoveScreen(m_currentDebugScreen); m_currentDebugScreen = null; } bool inputHandled = false; if (MySession.Static != null && MySession.Static.CreativeMode || MyInput.Static.ENABLE_DEVELOPER_KEYS) F12Handling(); if (MyInput.Static.ENABLE_DEVELOPER_KEYS) { // Statistics screen if (MyInput.Static.IsNewKeyPressed(MyKeys.F11) && !MyInput.Static.IsAnyShiftKeyPressed() && MyInput.Static.IsAnyCtrlKeyPressed()) { SwitchStatisticsScreen(); } if (MyInput.Static.IsAnyShiftKeyPressed() && MyInput.Static.IsAnyAltKeyPressed() && MyInput.Static.IsAnyCtrlKeyPressed() && MyInput.Static.IsNewKeyPressed(MyKeys.Home)) { throw new InvalidOperationException("Controlled crash"); } // Forge GC to run if (MyInput.Static.IsNewKeyPressed(MyKeys.Pause) && MyInput.Static.IsAnyShiftKeyPressed()) { GC.Collect(GC.MaxGeneration); } if (MyInput.Static.IsAnyCtrlKeyPressed() && MyInput.Static.IsNewKeyPressed(MyKeys.F2)) { //Reload textures if (MyInput.Static.IsKeyPress(MyKeys.LeftShift)) { VRageRender.MyRenderProxy.ReloadTextures(); } else if (MyInput.Static.IsKeyPress(MyKeys.LeftAlt)) { VRageRender.MyRenderProxy.ReloadModels(); } else { VRageRender.MyRenderProxy.ReloadEffects(); } } //WS size if (MyInput.Static.IsNewKeyPressed(MyKeys.F3) && MyInput.Static.IsKeyPress(MyKeys.LeftShift)) { WinApi.SetProcessWorkingSetSize(Process.GetCurrentProcess().Handle, -1, -1); } inputHandled = HandleDebugInput(); } if (!inputHandled) MyScreenManager.HandleInput(); } finally { ProfilerShort.End(); } }
private void SwitchStatisticsScreen() { #if !XB1 if (!(m_currentStatisticsScreen is MyGuiScreenDebugStatistics)) { if (m_currentStatisticsScreen != null) RemoveScreen(m_currentStatisticsScreen); AddScreen(m_currentStatisticsScreen = new MyGuiScreenDebugStatistics()); } else { RemoveScreen(m_currentStatisticsScreen); m_currentStatisticsScreen = null; } #else // XB1 System.Diagnostics.Debug.Assert(false, "XB1 TODO?"); #endif // XB1 }
// Remove screen from the stack public static void RemoveScreen(MyGuiScreenBase screen, bool nullActualScreen = false) { Debug.Assert(screen != null); if (IsAnyScreenOpening() == false) { MyGuiScreenBase previousCanHideScreen = GetPreviousScreen(screen, x => x.CanHide()); if (previousCanHideScreen != null && (previousCanHideScreen.GetState() == MyGuiScreenState.HIDDEN || previousCanHideScreen.GetState() == MyGuiScreenState.HIDING)) { previousCanHideScreen.UnhideScreen(); } } m_screensToRemove.Add(screen); if (nullActualScreen) { m_currentDebugScreen = null; } }