internal void Init() { settings = KerbalAlarmClock.settings; //if (Resources.clipAlarms.ContainsKey(settings.AlarmsAlertSound)) // mbARP.clipAlarmsAlert = Resources.clipAlarms[settings.AlarmsAlertSound]; //if (Resources.clipAlarms.ContainsKey(settings.AlarmsWarningSound)) // mbARP.clipAlarmsWarning = Resources.clipAlarms[settings.AlarmsWarningSound]; audiosourceAlarm = mbKAC.gameObject.AddComponent<AudioSource>(); audiosourceAlarm.panLevel = 0; audiosourceAlarm.playOnAwake = false; audiosourceAlarm.loop = false; audiosourceAlarm.Stop(); }
//Awake Event - when the DLL is loaded internal override void Awake() { LogFormatted("Awakening the KerbalAlarmClock-{0}", MonoName); InitVariables(); //Event for when the vessel changes (within a scene). KACWorkerGameState.VesselChanged += KACWorkerGameState_VesselChanged; //Load the Settings values from the file //Settings.Load(); LogFormatted("Loading Settings"); settings = new Settings("PluginData/settings.cfg"); Boolean blnSettingsLoaded = settings.Load(); if (!blnSettingsLoaded) { settings = new Settings("settings.cfg"); blnSettingsLoaded = settings.Load(); if (blnSettingsLoaded) { settings.FilePath = "PluginData/settings.cfg"; System.IO.File.Move(KACUtils.PathPlugin + "/settings.cfg", KACUtils.PathPlugin + "/PluginData/settings.cfg"); } } if (!blnSettingsLoaded) { settings.FilePath = "PluginData/settings.cfg"; LogFormatted("Settings Load Failed"); } else { if (!settings.TimeFormatConverted) { settings.TimeFormatConverted = true; switch (settings.TimeFormat) { case OldPrintTimeFormat.TimeAsUT: settings.DateTimeFormat = DateStringFormatsEnum.TimeAsUT; break; case OldPrintTimeFormat.KSPString: settings.DateTimeFormat = DateStringFormatsEnum.KSPFormatWithSecs; break; case OldPrintTimeFormat.DateTimeString: settings.DateTimeFormat = DateStringFormatsEnum.DateTimeFormat; break; default: settings.DateTimeFormat = DateStringFormatsEnum.KSPFormatWithSecs; break; } settings.Save(); } } //Set up Default Sounds settings.VerifySoundsList(); if (settings.SelectedCalendar == CalendarTypeEnum.Earth) { KSPDateStructure.SetEarthCalendar(settings.EarthEpoch); } //Set initial GameState KACWorkerGameState.LastGUIScene = HighLogic.LoadedScene; //Load Hohmann modelling data - if in flight mode //if ((KACWorkerGameState.LastGUIScene == GameScenes.FLIGHT) && settings.XferModelLoadData) if (settings.XferModelLoadData) settings.XferModelDataLoaded = KACResources.LoadModelPoints(); //get the sounds and set things up KACResources.LoadSounds(); this.ConfigSoundsDDLs(); InitAudio(); //Get whether the toolbar is there settings.BlizzyToolbarIsAvailable = ToolbarManager.ToolbarAvailable; //setup the Toolbar button if necessary if (settings.ButtonStyleToDisplay == Settings.ButtonStyleEnum.Toolbar) { btnToolbarKAC = InitToolbarButton(); } GameEvents.onGUIApplicationLauncherReady.Add(OnGUIAppLauncherReady); GameEvents.onGUIApplicationLauncherDestroyed.Add(DestroyAppLauncherButton); GameEvents.onGameSceneLoadRequested.Add(OnGameSceneLoadRequestedForAppLauncher); GameEvents.Contract.onContractsLoaded.Add(ContractsReady); GameEvents.onGUIAdministrationFacilitySpawn.Add(EnterKSCFacility); GameEvents.onGUIAstronautComplexSpawn.Add(EnterKSCFacility); GameEvents.onGUIMissionControlSpawn.Add(EnterKSCFacility); GameEvents.onGUIRnDComplexSpawn.Add(EnterKSCFacility); GameEvents.onGUIAdministrationFacilityDespawn.Add(LeaveKSCFacility); GameEvents.onGUIAstronautComplexDespawn.Add(LeaveKSCFacility); GameEvents.onGUIMissionControlDespawn.Add(LeaveKSCFacility); GameEvents.onGUIRnDComplexDespawn.Add(LeaveKSCFacility); // Need this one to handle the hideUI cancelling via pause menu GameEvents.onGameUnpause.Add(OnUnpause); blnFilterToVessel = false; if (HighLogic.LoadedScene == GameScenes.TRACKSTATION || HighLogic.LoadedScene == GameScenes.FLIGHT) blnShowFilterToVessel = true; //Set up the updating function - do this 5 times a sec not on every frame. StartRepeatingWorker(settings.BehaviourChecksPerSec); InitDropDowns(); winAlarmImport.KAC = this; winAlarmImport.Visible = false; winAlarmImport.InitWindow(); winConfirmAlarmDelete.Visible = false; winConfirmAlarmDelete.InitWindow(); WarpTransitionCalculator.CalcWarpRateTransitions(); //Hook the Angle renderers if (lstScenesForAngles.Contains(HighLogic.LoadedScene)) { PhaseAngle = MapView.MapCamera.gameObject.AddComponent<AngleRenderPhase>(); EjectAngle = MapView.MapCamera.gameObject.AddComponent<AngleRenderEject>(); } APIAwake(); }
private void CreateAutoContracts(Settings.AutoContractBehaviorEnum TypeOfAuto, Contract.State state, Boolean DontCreateAlarmsInsideMargin, Double margin, AlarmActions action) { if (TypeOfAuto == Settings.AutoContractBehaviorEnum.Next && DontCreateAlarmsInsideMargin) { //find the next valid contract to have an alarm for Contract conNext = lstContracts.Where(ci => ci.ContractState == state && ci.DateNext() > KACWorkerGameState.CurrentTime.UT + margin) .OrderBy(ci => ci.DateNext()) .FirstOrDefault(); if (conNext != null) { AddContractAutoAlarm(conNext, margin, action); } } else if (TypeOfAuto == Settings.AutoContractBehaviorEnum.All || TypeOfAuto == Settings.AutoContractBehaviorEnum.Next) { Boolean FirstOutsideMargin = false; foreach (Contract c in lstContracts.Where(ci => ci.ContractState == state && ci.DateNext() > KACWorkerGameState.CurrentTime.UT).OrderBy(ci => ci.DateNext())) { AddContractAutoAlarm(c, margin, action); FirstOutsideMargin = (c.DateNext() > KACWorkerGameState.CurrentTime.UT + margin); if (TypeOfAuto == Settings.AutoContractBehaviorEnum.Next && FirstOutsideMargin) break; } } }
internal static void SetSkin(Settings.DisplaySkin SkinToSet) { switch (SkinToSet) { case Settings.DisplaySkin.Default: _CurrentSkin = DefKSPSkin; _CurrentSkin.font = DefUnitySkin.font; SetStyleDefaults(); SetKSPStyles(); SetKSPButtons(); break; case Settings.DisplaySkin.Unity: _CurrentSkin = DefUnitySkin; SetStyleDefaults(); //was 12 SetUnityStyles(); SetUnityButtons(); break; case Settings.DisplaySkin.UnityWKSPButtons: _CurrentSkin = DefUnitySkin; SetStyleDefaults(); SetUnityStyles(); SetKSPButtons(); break; default: _CurrentSkin = DefKSPSkin; SetStyleDefaults(); SetKSPStyles(); SetKSPButtons(); break; } SetStyles(); //this throws an error if (OnSkinChanged!=null) OnSkinChanged(); }
internal double GetBurnMarginSecs(Settings.BurnMarginEnum KerMarginType) { Double retBurnMargin = 0; if (KERWrapper.APIReady) { switch (KerMarginType) { case Settings.BurnMarginEnum.None: retBurnMargin = 0; break; case Settings.BurnMarginEnum.Half: retBurnMargin = KERWrapper.KER.HalfBurnTime; break; case Settings.BurnMarginEnum.Full: retBurnMargin = KERWrapper.KER.BurnTime; break; default: retBurnMargin = 0; break; } } else if (VOIDWrapper.APIReady) { switch (KerMarginType) { case Settings.BurnMarginEnum.None: retBurnMargin = 0; break; case Settings.BurnMarginEnum.Half: retBurnMargin = VOIDWrapper.VOID.HalfBurnTime; break; case Settings.BurnMarginEnum.Full: retBurnMargin = VOIDWrapper.VOID.BurnTime; break; default: retBurnMargin = 0; break; } } return retBurnMargin; }