private void RenderTriggerMenu() { if (ImGui.BeginPopupModal(TriggerMenuLabel, WindowFlags.AlwaysAutoResize)) { if (!NewTriggerMenu.Render()) { if (NewTriggerMenu.TriggerComposite != null) { // We saved, not canceled. if (NewTriggerMenu.Parent == null) { // We are saving the root Plugin.Settings.LoadedProfile.Composite = NewTriggerMenu.TriggerComposite; } else { // Add the saved trigger to the parent NewTriggerMenu.Parent.Children.Add(NewTriggerMenu.TriggerComposite); } } NewTriggerMenu = null; ImGui.CloseCurrentPopup(); } ImGui.EndPopup(); } }
public SpectrumAnalyzer(XsaCore xsa) : base("SA", xsa) { trigger = new TriggerMenu(Xsa); // Add SAN Measurements.Add(typeof(SAN), new SAN(Xsa)); }
public WCDMA(XsaCore xsa) : base("WCDMA", xsa) { trigger = new TriggerMenu(xsa); // Add LPST Measurements.Add(typeof(ListPowerStep), new ListPowerStep(xsa)); Measurements.Add(typeof(CombinedWcdma), new CombinedWcdma(xsa)); Measurements.Add(typeof(Acp), new Acp(xsa)); }
public void Render() { if (ImGui.SmallButton("Reload")) { // Validate current tree var root = Plugin.Settings.LoadedProfile.Composite; if (root == null) { // Warn the user that there is no profile to reload StartNewOKMenu("No profile to reload."); } else { if (!ValidateTree(Plugin.Settings.LoadedProfile.Composite, out string error)) { StartNewOKMenu(error); } else { // Everything seems good. Load the tree Plugin.CreateAndStartTreeFromLoadedProfile(); } } } ImGuiExtension.ToolTip("The tree MUST be reloaded in order for changes to take effect."); ImGui.SameLine(); ImGui.Spacing(); ImGui.SameLine(); if (ImGui.SmallButton("Save")) { ImGui.OpenPopup("Save Profile"); } RenderSaveProfileMenu(); ImGui.SameLine(); ImGui.Spacing(); ImGui.SameLine(); if (ImGui.SmallButton("Load")) { ImGui.OpenPopup("Load Profile"); } RenderLoadProfileMenu(); ImGui.SameLine(); ImGui.Spacing(); ImGui.SameLine(); if (ImGui.SmallButton("Clear") || Plugin.Settings.LoadedProfile == null) { Plugin.Settings.LoadedProfile = new Profile.LoadedProfile(); } ImGuiExtension.ToolTip("Clear the tree to start over."); RenderOkMenu(); ImGui.Spacing(); ImGui.Separator(); ImGui.Text("Loaded Tree"); ImGui.Spacing(); if (Plugin.Settings.LoadedProfile.Composite == null) { if (ImGui.Button("+")) { ImGui.OpenPopup(TriggerMenuLabel); NewTriggerMenu = new TriggerMenu(Plugin.ExtensionParameter, null); } ImGuiExtension.ToolTip("Add root"); // If start profile is clicked, trigger menu is rendered RenderTriggerMenu(); } else { var menuAction = CreateTreeForComposite(null, Plugin.Settings.LoadedProfile.Composite, 0); if (menuAction == ProfileMenuAction.Remove) { // Was asked to remove the root node. Plugin.Settings.LoadedProfile.Composite = null; } } }
private ProfileMenuAction CreateTreeForComposite(TriggerComposite parent, TriggerComposite composite, int depth) { String typeTag = ""; if (composite.Type == TriggerType.Action) { typeTag = "[A]"; } else if (composite.Type == TriggerType.Decorator) { typeTag = "[D]"; } else if (composite.Type == TriggerType.PrioritySelector) { typeTag = "[P]"; } else if (composite.Type == TriggerType.Sequence) { typeTag = "[S]"; } string label = depth + ":" + typeTag + composite.Name; ImGui.PushID("Composite" + depth + label); try { Vector4 chosenColor = GreenColor; if (!ValidateTree(composite, out string error)) { chosenColor = RedColor; } if (composite.Type == TriggerType.Action) { // Push an ID so everything below remains unique ImGuiNative.igIndent(); var profileAction = CreateTriggerTextWithPopupMenu(label, chosenColor, parent); if (profileAction == ProfileMenuAction.Edit) { ImGui.OpenPopup(TriggerMenuLabel); NewTriggerMenu = new TriggerMenu(Plugin.ExtensionParameter, parent, composite); } else if (profileAction != ProfileMenuAction.None) { // Pass it up, maybe someone above knows how to deal with it return(profileAction); } RenderTriggerMenu(); ImGuiNative.igUnindent(); } else if (ImGui.TreeNodeEx("", TreeNodeFlags.OpenOnArrow | TreeNodeFlags.DefaultOpen)) { ImGui.SameLine(); var profileAction = CreateTriggerTextWithPopupMenu(label, chosenColor, parent); if (profileAction == ProfileMenuAction.Edit) { ImGui.OpenPopup(TriggerMenuLabel); NewTriggerMenu = new TriggerMenu(Plugin.ExtensionParameter, parent, composite); } else if (profileAction != ProfileMenuAction.None) { // Pass it up, maybe someone above knows how to deal with it return(profileAction); } // Decorators can only have one child if (composite.Type != TriggerType.Decorator || (composite.Children == null || composite.Children.Count == 0)) { if (ImGui.Button("+")) { ImGui.OpenPopup(TriggerMenuLabel); NewTriggerMenu = new TriggerMenu(Plugin.ExtensionParameter, composite); } ImGuiExtension.ToolTip("Add Child"); } if (composite.Children != null && composite.Children.Any()) { List <TriggerComposite> childrenToRemove = new List <TriggerComposite>(); List <TriggerComposite> childrenToMoveUp = new List <TriggerComposite>(); List <TriggerComposite> childrenToMoveDown = new List <TriggerComposite>(); foreach (var child in composite.Children) { var childAction = CreateTreeForComposite(composite, child, depth + 1); if (childAction == ProfileMenuAction.Remove) { childrenToRemove.Add(child); } else if (childAction == ProfileMenuAction.MoveUp) { childrenToMoveUp.Add(child); } else if (childAction == ProfileMenuAction.MoveDown) { childrenToMoveDown.Add(child); } } // Remove all children who were requested deletion childrenToRemove.ForEach(x => composite.Children.Remove(x)); childrenToMoveUp.ForEach(x => { var index = composite.Children.IndexOf(x); composite.Children.Remove(x); composite.Children.Insert(Math.Max(0, index - 1), x); }); childrenToMoveDown.ForEach(x => { var index = composite.Children.IndexOf(x); composite.Children.Remove(x); composite.Children.Insert(index + 1, x); }); } RenderTriggerMenu(); ImGui.TreePop(); } else { // Tree is closed, but we still want to display the text. ImGui.SameLine(); var profileAction = CreateTriggerTextWithPopupMenu(label, chosenColor, parent); if (profileAction == ProfileMenuAction.Edit) { ImGui.OpenPopup(TriggerMenuLabel); NewTriggerMenu = new TriggerMenu(Plugin.ExtensionParameter, parent, composite); } else if (profileAction != ProfileMenuAction.None) { // Pass it up, maybe someone above knows how to deal with it return(profileAction); } RenderTriggerMenu(); } } finally { // Just to make sure we pop the ID, no matter if we return early ImGui.PopID(); } return(ProfileMenuAction.None); }
private void LoadMenus() { markerMenu = new MarkerMenu(this); triggerMenu = new TriggerMenu(this); }