public override void OnLoad(ConfigNode gameNode) { //reset the list here //KerbalAlarmClock.alarms = new KACAlarmList(); KerbalAlarmClock.alarms.RemoveRange(0, KerbalAlarmClock.alarms.Count); base.OnLoad(gameNode); MonoBehaviourExtended.LogFormatted_DebugOnly("BaseLoadDone. Alarms Count:{0}", KerbalAlarmClock.alarms.Count); MonoBehaviourExtended.LogFormatted_DebugOnly("OnLoad: "); MonoBehaviourExtended.LogFormatted_DebugOnly("{0}", gameNode); if (gameNode.HasNode("KerbalAlarmClockScenario")) { MonoBehaviourExtended.LogFormatted_DebugOnly("Found {0}", "KerbalAlarmClockScenario"); } if (gameNode.HasNode("KACAlarmListStorage")) { MonoBehaviourExtended.LogFormatted_DebugOnly("Found {0}", "KACAlarmListStorage"); } if (gameNode.HasNode("KACAlarmListStorage")) { KerbalAlarmClock.alarms.DecodeFromCN(gameNode.GetNode("KACAlarmListStorage")); } MonoBehaviourExtended.LogFormatted_DebugOnly("ScenarioLoadDone. Alarms Count:{0}", KerbalAlarmClock.alarms.Count); //{MonoBehaviourExtended.LogFormatted_DebugOnly("A");} else {MonoBehaviourExtended.LogFormatted_DebugOnly("B");} //KerbalAlarmClock.alarms.DecodeFromCN(gameNode.GetNode(this.GetType().Name)); }
internal static void CalcWarpRateTransitions() { MonoBehaviourExtended.LogFormatted("WarpRates:{0}", TimeWarp.fetch.warpRates.Length); WarpRateTransitionPeriods = new List <WarpTransition>(); for (int i = 0; i < TimeWarp.fetch.warpRates.Length; i++) { WarpTransition newRate = new WarpTransition(i, TimeWarp.fetch.warpRates[i]); if (i > 0) { newRate.UTToRateDown = (TimeWarp.fetch.warpRates[i] + TimeWarp.fetch.warpRates[i - 1]) / 2; } if (i < TimeWarp.fetch.warpRates.Length - 1) { newRate.UTToRateUp = (TimeWarp.fetch.warpRates[i] + TimeWarp.fetch.warpRates[i + 1]) / 2; } WarpRateTransitionPeriods.Add(newRate); } foreach (WarpTransition wt in WarpRateTransitionPeriods) { List <WarpTransition> warpsTo1Times = WarpRateTransitionPeriods.Where(w => w.Index <= wt.Index).ToList(); wt.UTTo1Times = warpsTo1Times.Sum(w => w.UTToRateDown); } foreach (WarpTransition item in WarpRateTransitionPeriods.OrderBy(w => w.Index)) { MonoBehaviourExtended.LogFormatted_DebugOnly("{0}({1}):Up-{2} Down-{3} To0-{4}", item.Rate, item.Index, item.UTToRateUp, item.UTToRateDown, item.UTTo1Times); } }
void onAppLaunchToggleOff() { MonoBehaviourExtended.LogFormatted_DebugOnly("TOff"); EditorWindowVisible = false; MonoBehaviourExtended.LogFormatted_DebugOnly("{0}", EditorWindowVisible); }
public override void OnSave(ConfigNode gameNode) { base.OnSave(gameNode); MonoBehaviourExtended.LogFormatted_DebugOnly("OnSave: "); MonoBehaviourExtended.LogFormatted_DebugOnly("{0}", gameNode); gameNode.AddNode(KerbalAlarmClock.alarms.EncodeToCN()); }
void ARPResourceList_OnAlarmStateChanged(ARPResource sender, ARPResource.AlarmStateEnum oldValue, ARPResource.AlarmStateEnum newValue, ARPResource.MonitorStateEnum MonitorState) { MonoBehaviourExtended.LogFormatted_DebugOnly("LISTAck-{0}:{1}->{2} ({3})", sender.ResourceDef.name, oldValue, newValue, sender.MonitorState); if (OnAlarmStateChanged != null) { OnAlarmStateChanged(sender, oldValue, newValue, MonitorState); } }
void onAppLaunchToggleOff() { MonoBehaviourExtended.LogFormatted_DebugOnly("TOff"); WindowVisibleByActiveScene = false; settings.Save(); MonoBehaviourExtended.LogFormatted_DebugOnly("{0}", WindowVisibleByActiveScene); }
/// <summary> /// Sets up the App Button - no longer called by the event as that only happens on StartMenu->SpaceCenter now /// </summary> void OnGUIAppLauncherReady() { MonoBehaviourExtended.LogFormatted_DebugOnly("AppLauncherReady"); if (settings.ButtonStyleChosen == Settings.ButtonStyleEnum.Launcher) { btnAppLauncher = InitAppLauncherButton(); } }
internal void CleanResources(List <Int32> ExistingIDs) { List <Int32> IDsToRemove = this.Keys.Except(ExistingIDs).ToList <Int32>(); foreach (Int32 rID in IDsToRemove) { MonoBehaviourExtended.LogFormatted_DebugOnly("Removing Resource-{0}", rID); this.Remove(rID); } }
void onAppLaunchToggleOn() { if (CurrentVessel != null) { MonoBehaviourExtended.LogFormatted_DebugOnly("TOn"); ControlWindowVisible = true; MonoBehaviourExtended.LogFormatted_DebugOnly("{0}", ControlWindowVisible); } }
/// <summary> /// Sets up the App Button - no longer called by the event as that only happens on StartMenu->SpaceCenter now /// </summary> void OnGUIAppLauncherReady() { MonoBehaviourExtended.LogFormatted_DebugOnly("AppLauncherReady"); if (KSPAlternateResourcePanel.settings.ButtonStyleChosen == ARPWindowSettings.ButtonStyleEnum.Launcher || KSPAlternateResourcePanel.settings.ButtonStyleChosen == ARPWindowSettings.ButtonStyleEnum.StockReplace) { btnAppLauncher = InitAppLauncherButton(); if (KSPAlternateResourcePanel.settings.ButtonStyleChosen == ARPWindowSettings.ButtonStyleEnum.StockReplace) { StartCoroutine(ReplaceStockAppButton()); } } }
/// <summary> /// Checks for and adds a PartWindow to the List if not there already - does NOT update resources /// </summary> /// <param name="PartToAddorUpdate">Part to Add the Window For</param> /// <returns>The PartWindow for this part</returns> internal ARPPartWindow AddPartWindow(Part PartToAddorUpdate, KSPAlternateResourcePanel mbARP) { Int32 PartID = PartToAddorUpdate.GetInstanceID(); if (!this.ContainsKey(PartID)) { MonoBehaviourExtended.LogFormatted_DebugOnly("Adding Part Window"); WindowGameObjects.Add(PartID, new GameObject(string.Format("PartWindowObj-{0}", PartID))); ARPPartWindow pwNew = WindowGameObjects[PartID].AddComponent <ARPPartWindow>(); pwNew.Init(PartToAddorUpdate, mbARP); this.Add(PartID, pwNew); } return(this[PartID]); }
/// <summary> /// Sets the current Skin to one of the Pre-Defined types /// </summary> /// <param name="DefaultSkin">Which predefined skin to use</param> internal static void SetCurrent(DefSkinType DefaultSkin) { MonoBehaviourExtended.LogFormatted_DebugOnly("Setting GUISkin to {0}", DefaultSkin); switch (DefaultSkin) { case DefSkinType.Unity: _CurrentSkin = DefUnitySkin; break; case DefSkinType.KSP: _CurrentSkin = DefKSPSkin; break; //case DefSkinType.None: _CurrentSkin = new GUISkin(); break; default: _CurrentSkin = DefKSPSkin; break; } //Now set the tooltip style as well SetCurrentTooltip(); }
/// <summary> /// Sets up the App Button - no longer called by the event as that only happens on StartMenu->SpaceCenter now /// </summary> void OnGUIAppLauncherReady() { MonoBehaviourExtended.LogFormatted_DebugOnly("AppLauncherReady"); if (ApplicationLauncher.Ready) { if (btnAppLauncher == null) { btnAppLauncher = InitAppLauncherButton(); } } else { LogFormatted("App Launcher-Not Actually Ready"); } }
/// <summary> /// Sets up the App Button - no longer called by the event as that only happens on StartMenu->SpaceCenter now /// </summary> void OnGUIAppLauncherReady() { MonoBehaviourExtended.LogFormatted_DebugOnly("AppLauncherReady"); if (ApplicationLauncher.Ready) { if (settings.ButtonStyleChosen == Settings.ButtonStyleEnum.Launcher) { btnAppLauncher = InitAppLauncherButton(); } } else { LogFormatted("App Launcher-Not Actually Ready"); } }
internal ConfigNode EncodeToCN() { KACAlarmListStorage lstTemp = new KACAlarmListStorage(); lstTemp.list = this; //MonoBehaviourExtended.LogFormatted("{0}", lstTemp.list.Count); //foreach (KACAlarm item in lstTemp.list) //{ // MonoBehaviourExtended.LogFormatted("{0}", item.AsConfigNode); //} ConfigNode cnReturn = lstTemp.AsConfigNode; MonoBehaviourExtended.LogFormatted_DebugOnly("Encoding:{0}", cnReturn); //MonoBehaviourExtended.LogFormatted("{0}", cnReturn.GetNode("list")); return(cnReturn); }
public override void OnSave(ConfigNode gameNode) { base.OnSave(gameNode); foreach (KACAlarm a in KerbalAlarmClock.alarms.Where(a => !a.AlarmActionConverted && a.AlarmAction == KACAlarm.AlarmActionEnum.Converted)) { a.AlarmActionConverted = true; } foreach (KACAlarm a in KerbalAlarmClock.alarms.Where(a => a.Actions.Warp == AlarmActions.WarpEnum.PauseGame)) { a.Actions.Message = AlarmActions.MessageEnum.Yes; } MonoBehaviourExtended.LogFormatted_DebugOnly("OnSave: "); MonoBehaviourExtended.LogFormatted_DebugOnly("{0}", gameNode); gameNode.AddNode(KerbalAlarmClock.alarms.EncodeToCN()); }
/// <summary> /// Sets the current skin to one of the custom skins /// </summary> /// <param name="SkinID">The string ID of the custom skin</param> internal static void SetCurrent(string SkinID) { MonoBehaviourExtended.LogFormatted_DebugOnly("Setting GUISkin to {0}", SkinID); //check the skin exists, and throw a log line if it doesnt if (List.ContainsKey(SkinID)) { _CurrentSkin = List[SkinID]; } else { MonoBehaviourExtended.LogFormatted("Unable to change GUISkin to {0}, GUISkin not found", SkinID); } //Now set the tooltip style as well SetCurrentTooltip(); }
/// <summary> /// A tiny man with a little squegee gets in his window cleaning bucket and travels up and down the PartWindowSkyScraper. /// Where he finds Windows for Parts that no longer exist he delicately marks them and then smashes them to pieces with /// an excessive amount of force and vigour /// </summary> internal void CleanWindows() { List <Int32> IDsToRemove = this.Keys.Except(FlightGlobals.ActiveVessel.parts.Select(x => x.GetInstanceID())).ToList <Int32>(); foreach (KeyValuePair <Int32, ARPPartWindow> pwTemp in this) { if (pwTemp.Value.ResourceList.Count < 1 && !IDsToRemove.Contains(pwTemp.Key)) { IDsToRemove.Add(pwTemp.Key); } } foreach (Int32 pID in IDsToRemove) { MonoBehaviourExtended.LogFormatted_DebugOnly("Removing Part Window"); DestroyARPPartWindow(pID); } }
void bwVersionCheck_DoWork(object sender, DoWorkEventArgs e) { //set initial stuff and save it VersionCheckRunning = true; this.VersionCheckResult = "Unknown - check again later"; this.VersionCheckDate_Attempt = DateTime.Now; this.Save(); //now do the download MonoBehaviourExtended.LogFormatted("Reading version from Web"); wwwVersionCheck = new UnityWebRequest(VersionCheckURL); while (!wwwVersionCheck.isDone) { } MonoBehaviourExtended.LogFormatted("Download complete:{0}", wwwVersionCheck.ToString()); MonoBehaviourExtended.LogFormatted_DebugOnly("Content:{0}", wwwVersionCheck.ToString()); VersionCheckRunning = false; }
void OnGUIAppLauncherReady() { MonoBehaviourExtended.LogFormatted_DebugOnly("AppLauncherReady"); if (ApplicationLauncher.Ready) { if (settings.ButtonStyleChosen == Settings.ButtonStyleEnum.Launcher) { btnAppLauncher = InitAppLauncherButton(); //if (WindowVisibleByActiveScene) //{ // LogFormatted("Setting Button True"); // btnAppLauncher.SetTrue(); //} } } else { LogFormatted("App Launcher-Not Actually Ready"); } }
/// <summary> /// Sets up the App Button - no longer called by the event as that only happens on StartMenu->SpaceCenter now /// </summary> void OnGUIAppLauncherReady() { MonoBehaviourExtended.LogFormatted_DebugOnly("AppLauncherReady"); if (ApplicationLauncher.Ready) { if (KSPAlternateResourcePanel.settings.ButtonStyleChosen == ARPWindowSettings.ButtonStyleEnum.Launcher || KSPAlternateResourcePanel.settings.ButtonStyleChosen == ARPWindowSettings.ButtonStyleEnum.StockReplace) { btnAppLauncher = InitAppLauncherButton(); if (KSPAlternateResourcePanel.settings.ButtonStyleChosen == ARPWindowSettings.ButtonStyleEnum.StockReplace) { ReplaceStockAppButton(); } } } else { MonoBehaviourExtended.LogFormatted("App Launcher-Not Actually Ready"); } }
public override void OnLoad(ConfigNode gameNode) { //reset the list here //KerbalAlarmClock.alarms = new KACAlarmList(); KerbalAlarmClock.alarms.RemoveRange(0, KerbalAlarmClock.alarms.Count); base.OnLoad(gameNode); MonoBehaviourExtended.LogFormatted("BaseLoadDone. Alarms Count (Should be 0):{0}", KerbalAlarmClock.alarms.Count); MonoBehaviourExtended.LogFormatted_DebugOnly("OnLoad: "); MonoBehaviourExtended.LogFormatted_DebugOnly("{0}", gameNode); if (gameNode.HasNode("KerbalAlarmClockScenario")) { MonoBehaviourExtended.LogFormatted_DebugOnly("Found {0}", "KerbalAlarmClockScenario"); } if (gameNode.HasNode("KACAlarmListStorage")) { MonoBehaviourExtended.LogFormatted_DebugOnly("Found {0}", "KACAlarmListStorage"); } if (gameNode.HasNode("KACAlarmListStorage")) { KerbalAlarmClock.alarms.DecodeFromCN(gameNode.GetNode("KACAlarmListStorage")); foreach (KACAlarm a in KerbalAlarmClock.alarms) { if (!a.AlarmActionConverted) { a.AlarmActionConvert = a.AlarmAction; a.AlarmAction = KACAlarm.AlarmActionEnum.Converted; a.AlarmActionConverted = true; } } } MonoBehaviourExtended.LogFormatted("ScenarioLoadDone. Alarms Count:{0}", KerbalAlarmClock.alarms.Count); //{MonoBehaviourExtended.LogFormatted_DebugOnly("A");} else {MonoBehaviourExtended.LogFormatted_DebugOnly("B");} //KerbalAlarmClock.alarms.DecodeFromCN(gameNode.GetNode(this.GetType().Name)); }
//internal static Boolean LoadImageFromGameDB(ref Texture2D tex, String FileName, String FolderPath = "") //{ // Boolean blnReturn = false; // try // { // //trim off the tga and png extensions // if (FileName.ToLower().EndsWith(".png")) FileName = FileName.Substring(0, FileName.Length - 4); // if (FileName.ToLower().EndsWith(".tga")) FileName = FileName.Substring(0, FileName.Length - 4); // //default folder // if (FolderPath == "") FolderPath = DBPathTextures; // //Look for case mismatches // if (!GameDatabase.Instance.ExistsTexture(String.Format("{0}/{1}", FolderPath, FileName))) // throw new Exception(); // //now load it // tex = GameDatabase.Instance.GetTexture(String.Format("{0}/{1}", FolderPath, FileName), false); // blnReturn = true; // } // catch (Exception) // { // MonoBehaviourExtended.LogFormatted("Failed to load (are you missing a file - and check case):{0}/{1}", FolderPath, FileName); // } // return blnReturn; //} /// <summary> /// Loads a texture from the file system directly /// </summary> /// <param name="tex">Unity Texture to Load</param> /// <param name="FileName">Image file name</param> /// <param name="FolderPath">Optional folder path of image</param> /// <returns></returns> public static Boolean LoadImageFromFile(ref Texture2D tex, String FileName, String FolderPath = "") { //DebugLogFormatted("{0},{1}",FileName, FolderPath); Boolean blnReturn = false; try { if (FolderPath == "") { FolderPath = PathPluginTextures; } //File Exists check if (File.Exists(String.Format("{0}/{1}", FolderPath, FileName))) { try { MonoBehaviourExtended.LogFormatted_DebugOnly("Loading: {0}", String.Format("{0}/{1}", FolderPath, FileName)); tex.LoadImage(File.ReadAllBytes(String.Format("{0}/{1}", FolderPath, FileName))); blnReturn = true; } catch (Exception ex) { MonoBehaviourExtended.LogFormatted("Failed to load the texture:{0} ({1})", String.Format("{0}/{1}", FolderPath, FileName), ex.Message); } } else { MonoBehaviourExtended.LogFormatted("Cannot find texture to load:{0}", String.Format("{0}/{1}", FolderPath, FileName)); } } catch (Exception ex) { MonoBehaviourExtended.LogFormatted("Failed to load (are you missing a file):{0} ({1})", String.Format("{0}/{1}", FolderPath, FileName), ex.Message); } return(blnReturn); }
internal void DecodeFromCN(ConfigNode AlarmListNode) { try { if (AlarmListNode.CountNodes < 1) { MonoBehaviourExtended.LogFormatted("No Alarms to Load"); } else { MonoBehaviourExtended.LogFormatted_DebugOnly("Decoding:{0}", AlarmListNode); KACAlarmListStorage lstTemp = new KACAlarmListStorage(); ConfigNode.LoadObjectFromConfig(lstTemp, AlarmListNode); //this.Clear(); this.AddRange(lstTemp.list); } } catch (Exception ex) { MonoBehaviourExtended.LogFormatted("Failed to Load Alarms from Save File"); MonoBehaviourExtended.LogFormatted("Message: {0}", ex.Message); MonoBehaviourExtended.LogFormatted("AlarmListNode: {0}", AlarmListNode); } }
void onAppLaunchToggleOn() { MonoBehaviourExtended.LogFormatted_DebugOnly("TOn"); windowMain.Visible = true; }
internal static Boolean Loadv2Alarms(out String LoadMessage, out KACAlarmList oldAlarms) { oldAlarms = new KACAlarmList(); Boolean blnReturn = false; try { //Find old files String[] AlarmFiles = System.IO.Directory.GetFiles(KACUtils.PathTriggerTech, "Alarms-*.txt", System.IO.SearchOption.AllDirectories); String FileToLoad = ""; foreach (String item in AlarmFiles) { System.IO.FileInfo File = new System.IO.FileInfo(item); MonoBehaviourExtended.LogFormatted_DebugOnly("File:{0}", File.Name); if (File.Name == String.Format("Alarms-{0}.txt", HighLogic.CurrentGame.Title)) { FileToLoad = File.FullName; break; } } if (FileToLoad != "") { //parse it to a new list MonoBehaviourExtended.LogFormatted("Loading {0}", FileToLoad); String strFile = System.IO.File.ReadAllText(FileToLoad); String AlarmsFileVersion = ""; while (strFile.Contains("|<ENDLINE>")) { String strAlarm = strFile.Substring(0, strFile.IndexOf("|<ENDLINE>")); strFile = strFile.Substring(strAlarm.Length + "|<ENDLINE>".Length).TrimStart("\r\n".ToCharArray()); if (strAlarm.StartsWith("AlarmsFileVersion|")) { AlarmsFileVersion = strAlarm.Split("|".ToCharArray())[1]; MonoBehaviourExtended.LogFormatted("AlarmsFileVersion:{0}", AlarmsFileVersion); } else if (!strAlarm.StartsWith("VesselID|")) { KACAlarm tmpAlarm; switch (AlarmsFileVersion) { case "3": MonoBehaviourExtended.LogFormatted_DebugOnly("Loading Alarm via v3 loader"); tmpAlarm = UtilitiesLegacy.LoadFromString3(strAlarm, KACWorkerGameState.CurrentTime.UT); break; default: MonoBehaviourExtended.LogFormatted_DebugOnly("Loading Alarm via v2 loader"); tmpAlarm = UtilitiesLegacy.LoadFromString2(strAlarm); break; } oldAlarms.Add(tmpAlarm); } } blnReturn = true; LoadMessage = "Successfully parsed Alarm File"; } else { MonoBehaviourExtended.LogFormatted("Could not find alarms file for: {0}", HighLogic.CurrentGame.Title); LoadMessage = "File not found in TriggerTech Folder"; } } catch (Exception ex) { MonoBehaviourExtended.LogFormatted("Error occured:{0}\r\n{1}", ex.Message, ex.StackTrace); LoadMessage = "Unknown error occured trying to load old file\r\n\r\nError details in output_log.txt"; } return(blnReturn); }
void onAppLaunchHoverOff() { MonoBehaviourExtended.LogFormatted_DebugOnly("HovOff"); MouseOverAppLauncherBtn = false; }
void onAppLaunchHoverOn() { MonoBehaviourExtended.LogFormatted_DebugOnly("HovOn"); MouseOverAppLauncherBtn = true; }
void onAppLaunchToggleOff() { MonoBehaviourExtended.LogFormatted_DebugOnly("TOff"); KSPAlternateResourcePanel.settings.ToggleOn = false; settings.Save(); }
void onAppLaunchToggleOff() { MonoBehaviourExtended.LogFormatted_DebugOnly("TOff"); windowMain.Visible = false; }