protected void CheckLowMemSwitchToLow() { if (MySandboxGame.Config.LowMemSwitchToLow == MyConfig.LowMemSwitch.TRIGGERED) { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( callback : delegate(MyGuiScreenMessageBox.ResultEnum result) { if (result == MyGuiScreenMessageBox.ResultEnum.YES) { MySandboxGame.Config.LowMemSwitchToLow = MyConfig.LowMemSwitch.ARMED; MySandboxGame.Config.SetToLowQuality(); MySandboxGame.Config.Save(); // Exit game { MyAnalyticsTracker.SendGameEnd("Exit to Windows", MySandboxGame.TotalTimeInMilliseconds / 1000); MyScreenManager.CloseAllScreensNowExcept(null); MySandboxGame.ExitThreadSafe(); } } else { MySandboxGame.Config.LowMemSwitchToLow = MyConfig.LowMemSwitch.USER_SAID_NO; MySandboxGame.Config.Save(); }; }, messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText: MyTexts.Get(MySpaceTexts.LowMemSwitchToLowQuestion), buttonType: MyMessageBoxButtonsType.YES_NO)); } }
private void OnLogoutProgressClosed() { MySandboxGame.Log.WriteLine("Application closed by user"); MyAnalyticsTracker.SendGameEnd("Exit to Windows", MySandboxGame.TotalTimeInMilliseconds / 1000); MyScreenManager.CloseAllScreensNowExcept(null); // Exit application MySandboxGame.ExitThreadSafe(); }
// 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(); } }
public static void ExitGame() { MyAnalyticsTracker.SendGameEnd("Exit to Windows", MySandboxGame.TotalTimeInMilliseconds / 1000); MyScreenManager.CloseAllScreensNowExcept(null); MySandboxGame.ExitThreadSafe(); }