private void OnGUIAppLauncherReady() { if (applauncherButton == null) { ToolbarInfo tb = GetToolbarInfo(); var m = new System.Collections.Generic.Dictionary <GameScenes, AppScenes>(); m.Add(GameScenes.FLIGHT, AppScenes.FLIGHT); m.Add(GameScenes.EDITOR, AppScenes.SPH | AppScenes.VAB); m.Add(GameScenes.SPACECENTER, AppScenes.SPACECENTER); // and so on ... AppScenes v = AppScenes.NEVER; foreach (GameScenes s in tb.visibleInScenes) { v |= m[s]; } applauncherButton = KSP.UI.Screens.ApplicationLauncher.Instance.AddModApplication( OnShowByToolbar, OnHideByToolbar, null, null, null, null, v, (Texture)GameDatabase.Instance.GetTexture(tb.launcherTexture, false)); if (visibleByToolbars) { applauncherButton.SetTrue(false); } } }
private void AddButton() { if (appButton == null) { appButton = KSP.UI.Screens.ApplicationLauncher.Instance.AddModApplication(OnShow, OnClose, null, null, null, null, KSP.UI.Screens.ApplicationLauncher.AppScenes.SPACECENTER | KSP.UI.Screens.ApplicationLauncher.AppScenes.SPH | KSP.UI.Screens.ApplicationLauncher.AppScenes.TRACKSTATION | KSP.UI.Screens.ApplicationLauncher.AppScenes.VAB, appIcon); } }
private void RemoveButton() { if (appButton != null) { GameEvents.onGUIApplicationLauncherReady.Remove(AddButton); GameEvents.onGUIApplicationLauncherDestroyed.Remove(RemoveButton); KSP.UI.Screens.ApplicationLauncher.Instance.RemoveModApplication(appButton); appButton = null; } }
public FocusOverlay() { // Load texture on create, removal of the old Textures class satellite = RTUtil.LoadImage("texSatellite"); // New AppLauncher Button instead of floating satellite button var actives = KSP.UI.Screens.ApplicationLauncher.AppScenes.TRACKSTATION | KSP.UI.Screens.ApplicationLauncher.AppScenes.MAPVIEW; mButton = KSP.UI.Screens.ApplicationLauncher.Instance.AddModApplication(OnButtonDown, OnButtonUp, null, null, null, null, actives, satellite); mButtonImg = mButton.GetComponent<UnityEngine.UI.Image>(); RebuildTrackingListeners(); MapView.OnEnterMapView += OnEnterMapView; MapView.OnExitMapView += OnExitMapView; }
private void OnGUIAppLauncherReady() { if (KSP.UI.Screens.ApplicationLauncher.Ready) { _appButtonStock = KSP.UI.Screens.ApplicationLauncher.Instance.AddModApplication( OnIconClickHandler, OnIconClickHandler, DummyVoid, DummyVoid, DummyVoid, DummyVoid, KSP.UI.Screens.ApplicationLauncher.AppScenes.FLIGHT | KSP.UI.Screens.ApplicationLauncher.AppScenes.SPACECENTER, (Texture)GameDatabase.Instance.GetTexture("PAPIPlugin/icon_button", false) ); } }
public FocusOverlay() { // Load texture on create, removal of the old Textures class satellite = RTUtil.LoadImage("texSatellite"); // New AppLauncher Button instead of floating satellite button var actives = KSP.UI.Screens.ApplicationLauncher.AppScenes.TRACKSTATION | KSP.UI.Screens.ApplicationLauncher.AppScenes.MAPVIEW; mButton = KSP.UI.Screens.ApplicationLauncher.Instance.AddModApplication(OnButtonDown, OnButtonUp, null, null, null, null, actives, satellite); mButtonImg = mButton.GetComponent <UnityEngine.UI.Image>(); RebuildTrackingListeners(); MapView.OnEnterMapView += OnEnterMapView; MapView.OnExitMapView += OnExitMapView; }
void AddButton() { if (KSP.UI.Screens.ApplicationLauncher.Ready) { appButton = KSP.UI.Screens.ApplicationLauncher.Instance.AddModApplication( onAppLaunchToggleOn, onAppLaunchToggleOff, onAppLaunchHoverOn, onAppLaunchHoverOff, onAppLaunchEnable, onAppLaunchDisable, KSP.UI.Screens.ApplicationLauncher.AppScenes.FLIGHT, Asset.Texture2D.LoadFromFile("Toolbar", "toolbarButton3838") ); app = this; } }
protected void TearDownToolbars() { // unregister, or else errors occur GameEvents.onHideUI.Remove(OnHideByKspGui); GameEvents.onShowUI.Remove(OnShowByKspGui); GameEvents.onGUIApplicationLauncherReady.Remove(OnGUIAppLauncherReady); if (applauncherButton != null) { KSP.UI.Screens.ApplicationLauncher.Instance.RemoveModApplication(applauncherButton); applauncherButton = null; } if (toolbarButton != null) { toolbarButton.Destroy(); toolbarButton = null; } }
void AddButton() { if (KSP.UI.Screens.ApplicationLauncher.Ready && !NavUtilLib.GlobalVariables.Settings.useBlizzy78ToolBar) { appButton = KSP.UI.Screens.ApplicationLauncher.Instance.AddModApplication( onAppLaunchToggleOn, onAppLaunchToggleOff, onAppLaunchHoverOn, onAppLaunchHoverOff, onAppLaunchEnable, onAppLaunchDisable, KSP.UI.Screens.ApplicationLauncher.AppScenes.FLIGHT, (Texture)GameDatabase.Instance.GetTexture("KerbalScienceFoundation/NavInstruments/CommonTextures/toolbarButton3838", false) ); ; app = this; } }
public void Awake() { //Get values from cfg MenuWindow = new Rect(Screen.width / 2 + int.Parse(Konf.GetValue("WindowPosX")), Screen.height / 2 + int.Parse(Konf.GetValue("WindowPosY")), 400, 400); KlinicPriceString = Konf.GetValue("Cost"); StockPrice = bool.Parse(Konf.GetValue("Stock price")); //create appbutton if (appLauncherButton == null) { Texture2D texture = new Texture2D(36, 36, TextureFormat.RGBA32, false); texture.LoadImage(File.ReadAllBytes(RelPath + "/files/button.png")); appLauncherButton = KSP.UI.Screens.ApplicationLauncher.Instance.AddModApplication( () => { ButtonPress = true; }, () => { ButtonPress = false; }, null, null, null, null, KSP.UI.Screens.ApplicationLauncher.AppScenes.SPACECENTER, texture); } }
protected virtual void Dispose(bool disposing) { LightConfig.Destroy(); if (_blizzy78Button != null) { _blizzy78Button.Destroy(); _blizzy78Button = null; } if (_appButtonStock != null) { KSP.UI.Screens.ApplicationLauncher.Instance.RemoveModApplication(_appButtonStock); _appButtonStock = null; } if (_groupWindow != null) { _groupWindow.SetVisible(false); _groupWindow = null; } }
// See the Unity manual on execution order for more information. // http://docs.unity3d.com/Manual/ExecutionOrder.html private void OnGUI() { if (bad_installation_popup_ != null) { UnityEngine.Debug.LogError("Spawning: " + bad_installation_popup_); // No-one seems to understand what |anchorMin| and |anchorMax| do at this // time. PopupDialog.SpawnPopupDialog( anchorMin : default(UnityEngine.Vector2), anchorMax : default(UnityEngine.Vector2), title : "Principia", message : bad_installation_popup_, buttonMessage : "OK", persistAcrossScenes : true, skin : null, isModal : true); bad_installation_popup_ = null; return; } if (is_post_apocalyptic_) { UnityEngine.GUI.skin = null; apocalypse_window_rectangle_.xMin = apocalypse_window_x_; apocalypse_window_rectangle_.yMin = apocalypse_window_y_; apocalypse_window_rectangle_ = UnityEngine.GUILayout.Window( id : this.GetHashCode(), screenRect : apocalypse_window_rectangle_, func : (int id) => { UnityEngine.GUILayout.BeginVertical(); UnityEngine.GUILayout.TextArea(revelation_); UnityEngine.GUILayout.EndVertical(); }, text : "Principia", options : UnityEngine.GUILayout.MinWidth(500)); apocalypse_window_x_ = (int)apocalypse_window_rectangle_.xMin; apocalypse_window_y_ = (int)apocalypse_window_rectangle_.yMin; } if (KSP.UI.Screens.ApplicationLauncher.Ready && toolbar_button_ == null) { UnityEngine.Texture toolbar_button_texture; LoadTextureOrDie(out toolbar_button_texture, "toolbar_button.png"); toolbar_button_ = KSP.UI.Screens.ApplicationLauncher.Instance.AddModApplication( onTrue : ShowMainWindow, onFalse : HideMainWindow, onHover : null, onHoverOut : null, onEnable : null, onDisable : null, visibleInScenes : KSP.UI.Screens.ApplicationLauncher.AppScenes. ALWAYS, texture : toolbar_button_texture); } // Make sure the state of the toolbar button remains consistent with the // state of the window. if (show_main_window_) { toolbar_button_.SetTrue(makeCall : false); } else { toolbar_button_.SetFalse(makeCall : false); } if (hide_all_gui_) { return; } else if (show_main_window_) { UnityEngine.GUI.skin = null; main_window_rectangle_.xMin = main_window_x_; main_window_rectangle_.yMin = main_window_y_; main_window_rectangle_ = UnityEngine.GUILayout.Window( id : this.GetHashCode(), screenRect : main_window_rectangle_, func : DrawMainWindow, text : "Principia", options : UnityEngine.GUILayout.MinWidth(500)); main_window_x_ = (int)main_window_rectangle_.xMin; main_window_y_ = (int)main_window_rectangle_.yMin; render_windows(); } }
void AddButton() { if (KSP.UI.Screens.ApplicationLauncher.Ready && !NavUtilLib.GlobalVariables.Settings.useBlizzy78ToolBar) { appButton = KSP.UI.Screens.ApplicationLauncher.Instance.AddModApplication( onAppLaunchToggleOn, onAppLaunchToggleOff, onAppLaunchHoverOn, onAppLaunchHoverOff, onAppLaunchEnable, onAppLaunchDisable, KSP.UI.Screens.ApplicationLauncher.AppScenes.FLIGHT, (Texture)GameDatabase.Instance.GetTexture("KerbalScienceFoundation/NavInstruments/CommonTextures/toolbarButton3838", false) ); ; app = this; } }