static void OnCrash(string logPath, string gameName, string minimumRequirementsPage, bool requiresDX11, Exception e)
        {
            try
            {
                MyRenderException renderException = e as MyRenderException;

                if (renderException != null)
                {
                    MyErrorReporter.ReportRendererCrash(logPath, gameName, minimumRequirementsPage, renderException.Type);
                }
                //else if (requiresDX11 && IsUnsupportedGpu(e))
                //{
                //    MyErrorReporter.ReportNotDX11GPUCrash(gameName, logPath, minimumRequirementsPage);
                //}
                else if (/*IsUnsupportedGpu(e) || */ MyVideoSettingsManager.GpuUnderMinimum) // Uncomment this too
                {
                    MyErrorReporter.ReportGpuUnderMinimumCrash(gameName, logPath, minimumRequirementsPage);
                }
                else if (!MySandboxGame.IsDedicated && IsOutOfMemory(e))
                {
                    MyErrorReporter.ReportOutOfMemory(gameName, logPath, minimumRequirementsPage);
                }
                else if (!MySandboxGame.IsDedicated && IsOutOfVideoMemory(e))
                {
                    MyErrorReporter.ReportOutOfVideoMemory(gameName, logPath, minimumRequirementsPage);
                }
                else
                {
#if !XB1
                    bool isSilentException = false;
                    if (e.Data.Contains("Silent"))
                    {
                        bool.TryParse((string)e.Data["Silent"], out isSilentException);
                    }

                    string arg = (requiresDX11 && IsUnsupportedGpu(e)) ? "reporX" : "report";

                    if (!isSilentException)
                    {
                        ProcessStartInfo pi = new ProcessStartInfo();
                        pi.Arguments             = string.Format("-{2} \"{0}\" \"{1}\"", logPath, gameName, arg);
                        pi.FileName              = Assembly.GetEntryAssembly().Location;
                        pi.UseShellExecute       = false;
                        pi.WindowStyle           = ProcessWindowStyle.Hidden;
                        pi.RedirectStandardInput = true;
                        var p = Process.Start(pi);
                        p.StandardInput.Close();
                    }
#else // XB1
                    System.Diagnostics.Debug.Assert(false, "XB1 TODO?");
#endif // XB1
                }

                MyAnalyticsTracker.ReportError(MyAnalyticsTracker.SeverityEnum.Critical, e, async: false);
            }
            catch
            {
                // When cannot start reporter, do nothing
            }
        }
Example #2
0
 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));
     }
 }
Example #3
0
        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();
        }
Example #4
0
        private static void ReportFileError(Exception ex)
        {
            var exceptionText = ex.ToString();

            if (exceptionText.Contains("System.IO.IOException: The process cannot access the file"))
            {
                int start, end;
                start         = exceptionText.IndexOf('\'');
                end           = exceptionText.IndexOf('\'', start + 1);
                exceptionText = exceptionText.Remove(start, end - start + 1);
            }
            MyAnalyticsTracker.ReportError(MyAnalyticsTracker.SeverityEnum.Error, exceptionText, async: false);
        }
Example #5
0
        //  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();
            }
        }
Example #6
0
 public static void ExitGame()
 {
     MyAnalyticsTracker.SendGameEnd("Exit to Windows", MySandboxGame.TotalTimeInMilliseconds / 1000);
     MyScreenManager.CloseAllScreensNowExcept(null);
     MySandboxGame.ExitThreadSafe();
 }