Пример #1
0
        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;
                }
            }
        }