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 autoSaveShip() { QDebug.Log("autoSaveShip: start", "QPersistent"); while (HighLogic.LoadedSceneIsEditor && QSettings.Instance.enableEditorAutoSaveShip) { yield return(new WaitForSeconds(QSettings.Instance.editorTimeToSave)); ShipConstruction.SaveShip(shipFilename); QDebug.Log("autoSaveShip: save", "QPersistent"); } QDebug.Log("autoSaveShip: end", "QPersistent"); }
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 AutoSaveShip() { Log.Info("Starting Coroutein AutoSaveShip"); while (true) { yield return(new WaitForSeconds(Configuration.editorTimeIntervalToSave)); Log.Info("AutoSaveShip, after: " + Configuration.editorTimeIntervalToSave); List <Part> parts = EditorLogic.fetch.ship != null ? EditorLogic.fetch.ship.Parts : new List <Part>(); if (parts.Count > 0) { Log.Info("AutoSaveShip, parts.Count: " + parts.Count); ShipConstruction.SaveShip(shipFilename); } } }
IEnumerator autoSaveShip() { QDebug.Log("autoSaveShip: start", "QPersistent"); while (HighLogic.LoadedSceneIsEditor && QSettings.Instance.enableEditorAutoSaveShip) { QDebug.Log("autoSaveShip: before WaitForSeconds(" + QSettings.Instance.editorTimeToSave + ")", "QPersistent"); yield return(new WaitForSeconds(QSettings.Instance.editorTimeToSave)); List <Part> parts = EditorLogic.fetch.ship != null ? EditorLogic.fetch.ship.Parts : new List <Part>(); if (parts.Count > 0) { QDebug.Log("autoSaveShip: before saveShip", "QPersistent"); //ShipConstruction.SaveShip(shipFilename); yield return(new WaitForEndOfFrame()); ShipConstruction.SaveShip(shipFilename); QDebug.Log("autoSaveShip: after saveShip", "QPersistent"); } } QDebug.Log("autoSaveShip: end", "QPersistent"); }