/// <summary> /// Initialize the dialog /// </summary> /// <param name="nodeToEdit">The node we'll be editing</param> /// <param name="canEdit">True if we can open the maneuver node editing tools, false otherwise</param> public PlanningNodeEditDialog(PlanningNodeModel nodeToEdit, bool canEdit) : base(-1, -1, pad, new RectOffset(4, 4, 4, 4), TextAnchor.UpperLeft) { editingNode = nodeToEdit; var toprow = new List <DialogGUIBase>() { TooltipExtensions.DeferTooltip(new DialogGUIButton( "PlanningNode_DeleteButtonCaption", () => DeleteNode?.Invoke(), buttonWidth, buttonHeight, false ) { tooltipText = "PlanningNode_DeleteButtonTooltip" }), new DialogGUIFlexibleSpace(), TooltipExtensions.DeferTooltip(new DialogGUIButton( "PlanningNode_CloseButtonCaption", () => CloseDialog?.Invoke(), buttonWidth, buttonHeight, false ) { tooltipText = "PlanningNode_CloseButtonTooltip" }) }; if (canEdit) { toprow.Insert(0, TooltipExtensions.DeferTooltip(new DialogGUIButton( "PlanningNode_NewButtonCaption", () => NewNode?.Invoke(), buttonWidth, buttonHeight, false ) { tooltipText = "PlanningNode_NewButtonTooltip" })); } AddChild(new DialogGUIHorizontalLayout( -1, -1, 8, new RectOffset(0, 0, 0, 0), TextAnchor.MiddleLeft, toprow.ToArray() )); AddChild(new DialogGUIHorizontalLayout( -1, -1, pad, new RectOffset(0, 0, 0, 0), TextAnchor.MiddleLeft, new DialogGUILabel("PlanningNode_NameLabelCaption", buttonWidth / 2), NotifyOnFocus(new DialogGUITextInput( editingNode.name, false, 24, s => { return(editingNode.name = s); }, () => { return(editingNode.name); }, TMP_InputField.ContentType.Standard, buttonHeight ), // Don't trigger other parts of the game while they're typing a name in the text field v => InputLockManager.SetControlLock(MyLocks, "PlanningNodeEditDialogName"), v => InputLockManager.RemoveControlLock("PlanningNodeEditDialogName") ), TooltipExtensions.DeferTooltip(new DialogGUIButton( "PlanningNode_PrevNodeCaption", () => PrevNode?.Invoke(), smallBtnWidth, buttonHeight, false ) { tooltipText = canEdit ? "PlanningNode_PrevNodeTooltip" : "PlanningNode_PrevNodeViewOnlyTooltip" }), TooltipExtensions.DeferTooltip(new DialogGUIButton( "PlanningNode_NextNodeCaption", () => NextNode?.Invoke(), smallBtnWidth, buttonHeight, false ) { tooltipText = canEdit ? "PlanningNode_NextNodeTooltip" : "PlanningNode_NextNodeViewOnlyTooltip" }) )); AddChild(new DialogGUIHorizontalLayout( -1, -1, pad, new RectOffset(0, 0, 0, 0), TextAnchor.MiddleLeft, new DialogGUILabel("PlanningNode_HueLabelCaption", buttonWidth / 2), new DialogGUISlider( () => { if (editingNode != null) { Color.RGBToHSV(editingNode.color, out float hue, out float _, out float _); return(hue); } return(0f); }, 0f, 1f, false, -1, buttonHeight, v => { if (editingNode != null) { editingNode.color = Color.HSVToRGB(v, 0.5f, 0.75f); } } ) )); if (canEdit) { AddChild(new DialogGUIHorizontalLayout( -1, -1, pad, new RectOffset(0, 0, 0, 0), TextAnchor.MiddleLeft, new DialogGUILabel("PlanningNode_BodyLabelCaption", buttonWidth / 2), new DialogGUILabel( () => editingNode.origin.bodyName, -1 ), TooltipExtensions.DeferTooltip(new DialogGUIButton( "PlanningNode_PrevBodyCaption", () => BodyChanged?.Invoke(prevBody(editingNode.origin)), smallBtnWidth, buttonHeight, false ) { tooltipText = "PlanningNode_PrevBodyTooltip" }), TooltipExtensions.DeferTooltip(new DialogGUIButton( "PlanningNode_NextBodyCaption", () => BodyChanged?.Invoke(nextBody(editingNode.origin)), smallBtnWidth, buttonHeight, false ) { tooltipText = "PlanningNode_NextBodyTooltip" }) )); AddChild(TooltipExtensions.DeferTooltip(new DialogGUIToggle( () => editingNode.vessel == null, "PlanningNode_ShowForAllCheckboxCaption", b => { editingNode.vessel = b ? null : FlightGlobals.ActiveVessel; } ) { tooltipText = "PlanningNode_ShowForAllCheckboxTooltip" })); } AddChild(TooltipExtensions.DeferTooltip(new DialogGUIButton( "PlanningNode_WarpToCaption", () => WarpTo?.Invoke(editingNode), buttonWidth, buttonHeight, false ) { tooltipText = "PlanningNode_WarpToTooltip" })); // Don't try to plot a maneuver from the Sun for (int i = 0; i < FlightGlobals.Bodies.Count; ++i) { var b = FlightGlobals.Bodies[i]; if (b.referenceBody != null && b.referenceBody != b) { allowedBodies.Add(b); } } }
private void buttonDelete_Click(object sender, EventArgs e) { DeleteNode?.Invoke(this, EventArgs.Empty); }
public void OnDeleteItem(string name) { DeleteNode?.Invoke(name); }