/// <summary> /// Callback when a draw is requested. /// </summary> public void OnDraw() { if (!_hasInitStyles) { InitStyles(); } if (_active) { _windowPos = GUILayout.Window(_winID, _windowPos, OnWindow, "KompLog", _windowStyle); if ((_windowPos.x == 0.0f && _windowPos.y == 0.0f) || _windowPos.yMax > Screen.height) { Vector3 toolPos = Camera.current.WorldToScreenPoint(_toolbarButton.GetAnchor()); _windowPos.x = toolPos.x - _windowPos.width * 0.5f; _windowPos.y = (Screen.height - toolPos.y); if (!ApplicationLauncher.Instance.IsPositionedAtTop) { _windowPos.y -= _windowPos.height; } } } if (_active && _windowPos.Contains(Event.current.mousePosition)) { ControlLock(); } else { ControlUnlock(); } }
private void openDialog(PlanningNodeModel toEdit) { if (editDialog == null) { editDialog = new PlanningNodeEditDialog(toEdit, CanEdit); editDialog.CloseDialog += () => launcher.SetFalse(true); editDialog.NewNode += () => { var nd = new PlanningNodeModel( renderer.vessel?.mainBody ?? FlightGlobals.GetHomeBody(), renderer.vessel); PlanningNodesManager.Instance.nodes.Add(nd); editNode(nd); }; editDialog.DeleteNode += () => { PlanningNodesManager.Instance.nodes.Remove(editDialog.editingNode); OnNodeDeleted(); }; editDialog.PrevNode += () => editNode(PlanningNodesManager.Instance.PrevNode(renderer.vessel, editDialog.editingNode)); editDialog.NextNode += () => editNode(PlanningNodesManager.Instance.NextNode(renderer.vessel, editDialog.editingNode)); editDialog.BodyChanged += OnBodyChanged; editDialog.WarpTo += WarpTo; editDialog.Show(launcher.GetAnchor()); } else { // Already open, just switch to this node editDialog.editingNode = toEdit; } }
void FixedUpdate() { if (!showToolbarButton) { if (AntimatterFactory.Instance.Researched) { showToolbarButton = true; ResetAppLauncher(); } } else { if (showMiniWindow) { Vector3 pos = stockToolbarButton.GetAnchor(); if (ApplicationLauncher.Instance.IsPositionedAtTop) { miniWindowPos = new Rect(Screen.width - 280f, 0f, 240f, 42f); } else { miniWindowPos = new Rect(Screen.width - 280f, Screen.height - 92f, 245f, 42f); } } } if (AntimatterFactory.Instance.Researched && AntimatterFactory.Instance.FirstLoad) { showMainWindow = true; showTips = true; } else { showTips = false; } }
public Vector3 GetAnchor() { if (launcher_btn == null) { return(Vector3.zero); } Vector3 anchor = launcher_btn.GetAnchor(); anchor.x -= 3.0f; return(anchor); }
public Vector3 GetAnchor() { if (appButton == null) { return(Vector3.zero); } Vector3 anchor = appButton.GetAnchor(); anchor.x -= 3.0f; return(anchor); }
public Vector3 GetAnchor() { if (button == null) { return(Vector3.zero); } Vector3 anchor = button.GetAnchor(); anchor.y += 2; return(anchor); }
private Vector3 getAnchor() { if (anchor == null) { if (button == null) { return(Vector3.zero); } anchor = button.GetAnchor(); anchor.x -= 30; } return(anchor); }
/// Use this wrapper to generate a tooltip for an app launcher button. public static TooltipView AppLauncherTooltip( string title, string description, ApplicationLauncherButton button) { Vector3 rt = button.GetAnchor(); // It seems we need to convert from [[-w/2, w/2], [-h/2, h/2]] to [[0,1],[0,1]], // so I just divide and add 0.5. There's probably an API for this. return(new TooltipView( title, description, new Rect( rt.x / Screen.width + 0.5f, rt.y / Screen.height + 0.5f, tooltipWidth, tooltipHeight ) )); }
/// <summary> /// Return the location of the button /// </summary> public Vector3 GetAnchor() { return(launcher?.GetAnchor() ?? Vector3.right); }