public void Save() { Log.Info("Configuration.Save"); FileOperations.SaveConfiguration(this, FILE_NAME); AS.changeCallbacks = true; }
public void Load() { Log.Info("Configuration.Load"); FileOperations.LoadConfiguration(this, FILE_NAME); }
public void FixedUpdate() // public void LateUpdate () { string pngName; if (doSave || (AS.configuration.autoSave && ((Time.realtimeSinceStartup - lastBackup) > AS.configuration.minBetweenSaves * 60))) { lastBackup = Time.realtimeSinceStartup; SaveFilesHandlers sfh = new SaveFilesHandlers(); sfh.startBackup(this); doSave = false; } if (doSnapshots || snapshotInProgress) { Log.Info("In LateUpdate, doSnapshots"); if (screenshotTaken && configuration.noGUIOnScreenshot == true && System.IO.File.Exists(screenshotFile) && wasUIVisible) { GameEvents.onShowUI.Fire(); } // If there is a png file waiting to be converted, then don't do another screenshot if (pngToConvert != "") { Log.Info("pngToConvert: " + pngToConvert); if (System.IO.File.Exists(pngToConvert)) { Log.Info("Converting screenshot to JPG. New name: " + jpgName); ConvertToJPG(pngToConvert, jpgName, configuration.JPGQuality); System.IO.FileInfo file = new System.IO.FileInfo(pngToConvert); if (!configuration.keepOrginalPNG) { Log.Info("AutomatedScreenshots: Delete PNG file"); file.Delete(); } pngToConvert = ""; snapshotInProgress = false; } } else { snapshotInProgress = false; if (AS.configuration.precrashSnapshots) { if (FlightGlobals.ActiveVessel != null) { Vessel vessel = FlightGlobals.ActiveVessel; if ((-vessel.verticalSpeed > AS.configuration.hsMinVerticalSpeed) && ((FlightGlobals.ship_altitude / -vessel.verticalSpeed < AS.configuration.secondsUntilImpact) || (FlightGlobals.ship_altitude < AS.configuration.hsAltitudeLimit) )) { if (Time.realtimeSinceStartup - lastPrecrashUpdate > configuration.hsScreenshotInterval) { this.precrash = true; lastPrecrashUpdate = Time.realtimeSinceStartup; Log.Info("vessel.verticalSpeed: " + vessel.verticalSpeed.ToString()); Log.Info("FlightGlobals.ship_altitude: " + FlightGlobals.ship_altitude.ToString()); Log.Info("FlightGlobals.ship_altitude / -vessel.verticalSpeed: " + (FlightGlobals.ship_altitude / -vessel.verticalSpeed).ToString()); } } } } if ((this.specialScene && !this.newScene) || this.precrash || dualScreenshots == 1 || ( /*AS.configuration.screenshotAtIntervals && */ ((this.newScene && (this.sceneReady && Time.realtimeSinceStartup - sceneReadyAt > 0.1) && Time.realtimeSinceStartup - lastSceneUpdate > 1) || ((Time.realtimeSinceStartup - lastUpdate) > configuration.screenshotInterval && !this.newScene) ) )) { Log.Info("this.specialScene: " + this.specialScene.ToString()); Log.Info("this.precrash: " + this.precrash.ToString()); Log.Info("dualScreenshots: " + dualScreenshots.ToString()); Log.Info("this.newScene: " + this.newScene.ToString()); Log.Info("this.sceneReady: " + this.sceneReady.ToString()); Log.Info("Time.realtimeSinceStartup - sceneReadyAt: " + (Time.realtimeSinceStartup - sceneReadyAt).ToString()); Log.Info("Time.realtimeSinceStartup - lastSceneUpdate: " + (Time.realtimeSinceStartup - lastSceneUpdate).ToString()); Log.Info("Time.realtimeSinceStartup - lastUpdate: " + (Time.realtimeSinceStartup - lastUpdate).ToString()); Log.Info("Taking screenshot"); Log.Info("CurrentDirectory: " + System.IO.Directory.GetCurrentDirectory()); Log.Info("FileOperations.ScreenshotFolder: " + FileOperations.ScreenshotFolder()); snapshotInProgress = true; newScene = false; this.specialScene = false; lastUpdate = Time.realtimeSinceStartup; //check if directory doesn't exist if (!System.IO.Directory.Exists(FileOperations.ScreenshotFolder())) { Log.Info("Directory does not exist"); //if it doesn't, try to create it try { Log.Info("Trying to create directory"); System.IO.Directory.CreateDirectory(FileOperations.ScreenshotFolder()); } catch (Exception e) { Log.Error("Exception trying to create directory: " + e); return; } Log.Info("Directory created"); } do { cnt++; string s = AddInfo(configuration.filename, cnt, sceneReady, specialScene, precrash); pngName = System.IO.Path.GetFullPath(FileOperations.ScreenshotFolder()) + s + ".png"; jpgName = System.IO.Path.GetFullPath(FileOperations.ScreenshotFolder()) + s + ".jpg"; } while (System.IO.File.Exists(pngName) || System.IO.File.Exists(jpgName)); this.precrash = false; // // I make the assumption that if the player wants the gui during the screenshot, then // it will be left visible. // wasUIVisible = uiVisiblity.isVisible() | configuration.guiOnScreenshot; //Log.Info ("Update: Screenshotfolder:" + pngName); if (configuration.noGUIOnScreenshot == true) { GameEvents.onHideUI.Fire(); } if (configuration.noGUIOnScreenshot && configuration.guiOnScreenshot) { if (dualScreenshots == 0) { dualScreenshots = 1; } else if (dualScreenshots == 1) { dualScreenshots = 0; GameEvents.onShowUI.Fire(); } } screenshotTaken = true; screenshotFile = pngName; // // If Historian is available, then tell it to activate // Version.set_m_Active(); // Change second number for supersize. If non-zero, // then multiplies the resolution by that number // Must be an integer Application.CaptureScreenshot(pngName, configuration.supersize); if (configuration.convertToJPG) { pngToConvert = pngName; } } } } }