IEnumerator tryExit() { if (needToSavegame) { if (CanSavegame) { if (GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE) != string.Empty) { saveDone = true; ScreenMessages.PostScreenMessage(Localizer.Format("quickexit_gameSaved", RegisterToolbar.MOD), 5); Log("Game saved.", "QExit"); } else { count = 10; Log("Can't save game.", "QExit"); ScreenMessages.PostScreenMessage(Localizer.Format("quickexit_cantSave", RegisterToolbar.MOD), 10); } if (HighLogic.LoadedSceneIsEditor) { List <Part> parts = EditorLogic.fetch.ship != null ? EditorLogic.fetch.ship.Parts : new List <Part>(); if (parts.Count > 0) { ShipConstruction.SaveShip(shipFilename); Log("Ship saved.", "QExit"); ScreenMessages.PostScreenMessage(Localizer.Format("quickexit_shipSaved", RegisterToolbar.MOD), 5); } } } else { count = 10; ClearToSaveStatus clearToSaveStatus = FlightGlobals.ClearToSave(); string _status = FlightGlobals.GetNotClearToSaveStatusReason(clearToSaveStatus, string.Empty); Log("Can't game saved: " + _status, "QExit"); ScreenMessages.PostScreenMessage(Localizer.Format("quickexit_cantSave", RegisterToolbar.MOD) + ": " + _status, 10); } } while (count >= 0) { yield return(new WaitForSecondsRealtime(1f)); Log("Exit in " + count, "QExit"); count--; } if (!IsTryExit) { Log("tryExit stopped", "QExit"); yield break; } Application.Quit(); Log("tryExit ended", "QExit"); }
IEnumerator tryExit() { if (needToSavegame) { if (CanSavegame) { if (GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE) != string.Empty) { saveDone = true; ScreenMessages.PostScreenMessage(string.Format("[{0}] Game saved.", MOD), 5); Log("Game saved.", "QExit"); } else { count = 10; Log("Can't save game.", "QExit"); ScreenMessages.PostScreenMessage(string.Format("[{0}] Can't save game.", MOD), 10); } if (HighLogic.LoadedSceneIsEditor) { ShipConstruction.SaveShip(shipFilename); Log("Ship saved.", "QExit"); ScreenMessages.PostScreenMessage(string.Format("[{0}] Ship saved.", MOD), 5); } } else { count = 10; ClearToSaveStatus clearToSaveStatus = FlightGlobals.ClearToSave(); string _status = FlightGlobals.GetNotClearToSaveStatusReason(clearToSaveStatus, string.Empty); Log("Can't game saved: " + _status, "QExit"); ScreenMessages.PostScreenMessage(string.Format("[{0}] Can't save game: {1}", MOD, _status.ToString()), 10); } } while (count >= 0) { yield return(new WaitForSecondsRealtime(1f)); Log("Exit in " + count, "QExit"); count--; } if (!IsTryExit) { Log("tryExit stopped", "QExit"); yield break; } Application.Quit(); Log("tryExit ended", "QExit"); }
IEnumerator tryExit() { Log.Info("tryExit"); if (CanSavegame) { if (GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE) != string.Empty) { //saveDone = true; ScreenMessages.PostScreenMessage(Localizer.Format("pm_gameSaved", MOD), 5); MyLog("Game saved.", "QExit"); } else { count = 10; MyLog("Can't save game.", "QExit"); ScreenMessages.PostScreenMessage(Localizer.Format("pm_cantSave", MOD), 10); } } else { count = 10; ClearToSaveStatus clearToSaveStatus = FlightGlobals.ClearToSave(); string _status = FlightGlobals.GetNotClearToSaveStatusReason(clearToSaveStatus, string.Empty); MyLog("Can't game saved: " + _status, "QExit"); ScreenMessages.PostScreenMessage(Localizer.Format("pm_cantSave", MOD) + ": " + _status, 10); } while (count >= 0) { yield return(new WaitForSecondsRealtime(1f)); MyLog("Exit in " + count, "QExit"); count--; } Log.Info("tryExit, ready to exit"); if (!IsTryExit) { MyLog("tryExit stopped", "QExit"); yield break; } Log.Info("tryExit, before ApplicationQuit"); Application.Quit(); MyLog("tryExit ended", "QExit"); }