internal ApplicationLauncherButton InitAppLauncherButton() { ApplicationLauncherButton retButton = null; ApplicationLauncherButton[] lstButtons = KSPAlternateResourcePanel.FindObjectsOfType <ApplicationLauncherButton>(); LogFormatted("AppLauncher: Creating Button-BEFORE", lstButtons.Length); try { retButton = ApplicationLauncher.Instance.AddModApplication( onAppLaunchToggleOn, onAppLaunchToggleOff, onAppLaunchHoverOn, onAppLaunchHoverOff, null, null, ApplicationLauncher.AppScenes.FLIGHT | ApplicationLauncher.AppScenes.MAPVIEW, (Texture)Resources.texAppLaunchIcon); AppLauncherButtonMutuallyExclusive(settings.AppLauncherMutuallyExclusive); //appButton = ApplicationLauncher.Instance.AddApplication( // onAppLaunchToggleOn, onAppLaunchToggleOff, // onAppLaunchHoverOn, onAppLaunchHoverOff, // null, null, // (Texture)Resources.texAppLaunchIcon); //appButton.VisibleInScenes = ApplicationLauncher.AppScenes.FLIGHT; } catch (Exception ex) { MonoBehaviourExtended.LogFormatted("AppLauncher: Failed to set up App Launcher Button\r\n{0}", ex.Message); retButton = null; } lstButtons = KSPAlternateResourcePanel.FindObjectsOfType <ApplicationLauncherButton>(); LogFormatted("AppLauncher: Creating Button-AFTER", lstButtons.Length); return(retButton); }
//internal ARPPartWindow(Part Part) //{ // this.Part = Part; // this.ResourceList = new ARPResourceList(ARPResourceList.ResourceUpdate.SetValues); //} //TODO: Look at using this // http://answers.unity3d.com/questions/445444/add-component-in-one-line-with-parameters.html /// <summary> /// Have to take this out of the constructor as the object must be created using gameObject.addComponent<> /// </summary> /// <param name="Part">Part that this window is displaying info for</param> internal void Init(Part Part, KSPAlternateResourcePanel mbARP) { this.mbARP = mbARP; this.settings = KSPAlternateResourcePanel.settings; this.PartRef = Part; this.ResourceList = new ARPResourceList(ARPResourceList.ResourceUpdate.SetValues, settings.Resources); this.LeftSide = this.PartScreenPos.x < (mbARP.vectVesselCOMScreen.x - 3); }
private void APIDestroy() { //tear it down APIInstance = null; try { APIInstance.lstResourcesVessel.OnMonitorStateChanged -= API_lstResourcesVessel_OnMonitorStateChanged; } catch (Exception) { } try { APIInstance.lstResourcesVessel.OnAlarmStateChanged -= API_lstResourcesVessel_OnAlarmStateChanged; } catch (Exception) { } LogFormatted("API Cleaned up"); APIReady = false; }
//internal ApplicationLauncherButton btnAppLauncher2 = null; //internal ApplicationLauncherButton InitAppLauncherButton2() //{ // ApplicationLauncherButton retButton = null; // try // { // retButton = ApplicationLauncher.Instance.AddApplication( // onAppLaunchToggleOn, onAppLaunchToggleOff, // onAppLaunchHoverOn, onAppLaunchHoverOff, // null, null, // (Texture)Resources.texAppLaunchIcon); // retButton.VisibleInScenes = ApplicationLauncher.AppScenes.FLIGHT | ApplicationLauncher.AppScenes.MAPVIEW; // //ApplicationLauncher.Instance.EnableMutuallyExclusive(retButton); // //appButton = ApplicationLauncher.Instance.AddApplication( // // onAppLaunchToggleOn, onAppLaunchToggleOff, // // onAppLaunchHoverOn, onAppLaunchHoverOff, // // null, null, // // (Texture)Resources.texAppLaunchIcon); // //appButton.VisibleInScenes = ApplicationLauncher.AppScenes.FLIGHT; // if (KSPAlternateResourcePanel.settings.ToggleOn) // retButton.toggleButton.SetTrue(); // } // catch (Exception ex) // { // MonoBehaviourExtended.LogFormatted("Failed to set up App Launcher Button\r\n{0}", ex.Message); // retButton = null; // } // return retButton; //} internal void DestroyAppLauncherButton() { //LogFormatted_DebugOnly("Destroying AppLauncher Button. Count:{0}", lstButtons.Length); LogFormatted("AppLauncher: Destroying Button-BEFORE NULL CHECK"); if (btnAppLauncher != null) { ApplicationLauncherButton[] lstButtons = KSPAlternateResourcePanel.FindObjectsOfType <ApplicationLauncherButton>(); LogFormatted("AppLauncher: Destroying Button-Button Count:{0}", lstButtons.Length); ApplicationLauncher.Instance.RemoveModApplication(btnAppLauncher); btnAppLauncher = null; } LogFormatted("AppLauncher: Destroying Button-AFTER NULL CHECK"); }
//Init the API Hooks private void APIAwake() { //set up the hookable object APIInstance = this; //set up the events we need APIInstance.lstResourcesVessel.OnMonitorStateChanged+=API_lstResourcesVessel_OnMonitorStateChanged; APIInstance.lstResourcesVessel.OnAlarmStateChanged+=API_lstResourcesVessel_OnAlarmStateChanged; //flag it ready LogFormatted("API Ready"); APIReady = true; }
//Init the API Hooks private void APIAwake() { //set up the hookable object APIInstance = this; //set up the events we need APIInstance.lstResourcesVessel.OnMonitorStateChanged += API_lstResourcesVessel_OnMonitorStateChanged; APIInstance.lstResourcesVessel.OnAlarmStateChanged += API_lstResourcesVessel_OnAlarmStateChanged; //flag it ready LogFormatted("API Ready"); APIReady = true; }
/// <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> /// 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> /// <param name="PartsResource">A PartResource to Add/Update in the PartWindows details</param> /// <returns>The PartWindow for this part</returns> internal ARPPartWindow AddPartWindow(Part PartToAddorUpdate, PartResource PartsResource, KSPAlternateResourcePanel mbARP, Double Period) { //Ensure PartWindow Exists first ARPPartWindow pwTemp = AddPartWindow(PartToAddorUpdate, mbARP); //Then add the Resource pwTemp.ResourceList.SetUTPeriod(Period); pwTemp.ResourceList.UpdateResource(PartsResource, CalcRates: KSPAlternateResourcePanel.settings.ShowRatesForParts); return(pwTemp); }