Beispiel #1
0
        ContextActions NewHpMenu(string n)
        {
            var retval = ContextActions.None;

            if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
            {
                ImGui.OpenPopup(n + "_HardpointContext");
            }
            if (ImGui.BeginPopupContextItem(n + "_HardpointContext"))
            {
                if (Theme.BeginIconMenu(Icons.PlusCircle, "New"))
                {
                    if (Theme.IconMenuItem(Icons.Cube_Purple, "Fixed Hardpoint", true))
                    {
                        retval = ContextActions.NewFixed;
                    }
                    if (Theme.IconMenuItem(Icons.Rev_LightSeaGreen, "Revolute Hardpoint", true))
                    {
                        retval = ContextActions.NewRevolute;
                    }
                    ImGui.EndMenu();
                }
                ImGui.EndPopup();
            }
            return(retval);
        }
Beispiel #2
0
        public static void DropdownButton(string id, ref int selected, IReadOnlyList <DropdownOption> options)
        {
            ImGui.PushID(id);
            bool   clicked  = false;
            string text     = $"{options[selected].Icon}  {options[selected].Name}  ";
            var    textSize = ImGui.CalcTextSize(text);
            var    cpos     = ImGuiNative.igGetCursorPosX();
            var    cposY    = ImGuiNative.igGetCursorPosY();

            clicked = ImGui.Button($"{options[selected].Icon}  {options[selected].Name}  ");
            var style = ImGui.GetStyle();
            var tPos  = new Vector2(cpos, cposY) + new Vector2(textSize.X + style.FramePadding.X, textSize.Y);

            Theme.TinyTriangle(tPos.X, tPos.Y);
            if (clicked)
            {
                ImGui.OpenPopup(id + "#popup");
            }
            if (ImGui.BeginPopup(id + "#popup"))
            {
                ImGui.MenuItem(id, false);
                for (int i = 0; i < options.Count; i++)
                {
                    var opt = options[i];
                    if (Theme.IconMenuItem(opt.Icon, opt.Name, true))
                    {
                        selected = i;
                    }
                }
                ImGui.EndPopup();
            }
            ImGui.PopID();
        }
Beispiel #3
0
 ContextActions EditDeleteHpMenu(string n)
 {
     if (ImGui.IsItemClicked(1))
     {
         ImGui.OpenPopup(n + "_HardpointEditCtx");
     }
     if (ImGui.BeginPopupContextItem(n + "_HardpointEditCtx"))
     {
         if (Theme.IconMenuItem("Edit", "edit", Color4.White, true))
         {
             return(ContextActions.Edit);
         }
         if (Theme.IconMenuItem("Delete", "delete", Color4.White, true))
         {
             return(ContextActions.Delete);
         }
         ImGui.EndPopup();
     }
     return(ContextActions.None);
 }
        public static void DropdownButton(string id, ref int selected, IReadOnlyList <DropdownOption> options)
        {
            ImGui.PushID(id);
            bool         clicked = false;
            const string PADDING = "       ";
            string       text    = PADDING + ImGuiExt.IDSafe(options[selected].Name) + "   ";
            var          w       = ImGui.CalcTextSize(text).X;

            clicked = ImGui.Button(text);
            ImGui.SameLine();
            var cpos  = ImGuiNative.igGetCursorPosX();
            var cposY = ImGuiNative.igGetCursorPosY();

            Theme.TinyTriangle(cpos - 15, cposY + 15);
            ImGuiNative.igSetCursorPosX(cpos - w - 13);
            ImGuiNative.igSetCursorPosY(cposY + 2);
            Theme.Icon(options[selected].Icon, Color4.White);
            ImGui.SameLine();
            ImGuiNative.igSetCursorPosY(cposY);
            ImGui.SetCursorPosX(cpos - 6);
            ImGui.Dummy(Vector2.Zero);
            if (clicked)
            {
                ImGui.OpenPopup(id + "#popup");
            }
            if (ImGui.BeginPopup(id + "#popup"))
            {
                ImGui.MenuItem(id, false);
                for (int i = 0; i < options.Count; i++)
                {
                    var opt = options[i];
                    if (Theme.IconMenuItem(opt.Name, opt.Icon, Color4.White, true))
                    {
                        selected = i;
                    }
                }
                ImGui.EndPopup();
            }
            ImGui.PopID();
        }
Beispiel #5
0
 ContextActions EditDeleteHpMenu(string n)
 {
     if (ImGui.IsItemClicked(1))
     {
         ImGui.OpenPopup(n + "_HardpointEditCtx");
     }
     if (ImGui.BeginPopupContextItem(n + "_HardpointEditCtx"))
     {
         if (Theme.IconMenuItem("Edit", "edit", Color4.White, true))
         {
             return(ContextActions.Edit);
         }
         if (Theme.IconMenuItem("Delete", "delete", Color4.White, true))
         {
             return(ContextActions.Delete);
         }
         if (Theme.BeginIconMenu("Duplicate", "duplicate", Color4.White))
         {
             if (Theme.IconMenuItem("Mirror X", "axis_x", Color4.Red, true))
             {
                 return(ContextActions.MirrorX);
             }
             if (Theme.IconMenuItem("Mirror Y", "axis_y", Color4.LightGreen, true))
             {
                 return(ContextActions.MirrorY);
             }
             if (Theme.IconMenuItem("Mirror Z", "axis_z", Color4.LightBlue, true))
             {
                 return(ContextActions.MirrorZ);
             }
             ImGui.EndMenu();
         }
         ImGui.EndPopup();
     }
     return(ContextActions.None);
 }
Beispiel #6
0
 ContextActions NewHpMenu(string n)
 {
     if (ImGui.IsItemClicked(1))
     {
         ImGui.OpenPopup(n + "_HardpointContext");
     }
     if (ImGui.BeginPopupContextItem(n + "_HardpointContext"))
     {
         if (Theme.BeginIconMenu("New", "add", Color4.White))
         {
             if (Theme.IconMenuItem("Fixed Hardpoint", "fix", Color4.Purple, true))
             {
                 return(ContextActions.NewFixed);
             }
             if (Theme.IconMenuItem("Revolute Hardpoint", "rev", Color4.LightSeaGreen, true))
             {
                 return(ContextActions.NewRevolute);
             }
             ImGui.EndMenu();
         }
         ImGui.EndPopup();
     }
     return(ContextActions.None);
 }
Beispiel #7
0
 ContextActions EditDeleteHpMenu(string n)
 {
     if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
     {
         ImGui.OpenPopup(n + "_HardpointEditCtx");
     }
     if (ImGui.BeginPopupContextItem(n + "_HardpointEditCtx"))
     {
         if (Theme.IconMenuItem(Icons.Edit, "Edit", true))
         {
             return(ContextActions.Edit);
         }
         if (Theme.IconMenuItem(Icons.TrashAlt, "Delete", true))
         {
             return(ContextActions.Delete);
         }
         if (Theme.BeginIconMenu(Icons.Clone, "Duplicate"))
         {
             if (ImGui.MenuItem("Mirror X"))
             {
                 return(ContextActions.MirrorX);
             }
             if (ImGui.MenuItem("Mirror Y"))
             {
                 return(ContextActions.MirrorY);
             }
             if (ImGui.MenuItem("Mirror Z"))
             {
                 return(ContextActions.MirrorZ);
             }
             ImGui.EndMenu();
         }
         ImGui.EndPopup();
     }
     return(ContextActions.None);
 }
Beispiel #8
0
 void DoNodeMenu(string id, LUtfNode node, LUtfNode parent)
 {
     if (ImGui.BeginPopupContextItem(id))
     {
         ImGui.MenuItem(node.Name, false);
         ImGui.MenuItem(string.Format("CRC: 0x{0:X}", CrcTool.FLModelCrc(node.Name)), false);
         ImGui.Separator();
         if (Theme.IconMenuItem(Icons.Edit, "Rename", node != Utf.Root))
         {
             text.SetText(node.Name);
             renameNode = node;
             popups.OpenPopup("Rename Node");
         }
         if (Theme.IconMenuItem(Icons.TrashAlt, "Delete", node != Utf.Root))
         {
             deleteParent = parent;
             deleteNode   = node;
             Confirm("Are you sure you want to delete: '" + node.Name + "'?", () =>
             {
                 if (selectedNode == deleteNode)
                 {
                     selectedNode = null;
                 }
                 deleteParent.Children.Remove(deleteNode);
             });
         }
         if (Theme.IconMenuItem(Icons.Eraser, "Clear", node.Children != null || node.Data != null))
         {
             clearNode = node;
             Confirm("Clearing this node will delete all data and children. Continue?", () =>
             {
                 clearNode.Data = null;
                 if (clearNode == Utf.Root)
                 {
                     clearNode.Children = new List <LUtfNode>();
                 }
                 else
                 {
                     clearNode.Children = null;
                 }
             });
         }
         ImGui.Separator();
         if (Theme.BeginIconMenu(Icons.PlusCircle, "Add"))
         {
             if (ImGui.MenuItem("Child"))
             {
                 text.SetText("");
                 addParent = null;
                 addNode   = node;
                 if (node.Data != null)
                 {
                     Confirm("Adding a node will clear data. Continue?", () =>
                     {
                         popups.OpenPopup("New Node");
                     });
                 }
                 else
                 {
                     popups.OpenPopup("New Node");
                 }
             }
             if (ImGui.MenuItem("Before", node != Utf.Root))
             {
                 text.SetText("");
                 addParent = parent;
                 addNode   = node;
                 addOffset = 0;
                 popups.OpenPopup("New Node");
             }
             if (ImGui.MenuItem("After", node != Utf.Root))
             {
                 text.SetText("");
                 addParent = parent;
                 addNode   = node;
                 addOffset = 1;
                 popups.OpenPopup("New Node");
             }
             ImGui.EndMenu();
         }
         ImGui.Separator();
         if (Theme.IconMenuItem(Icons.Cut, "Cut", node != Utf.Root))
         {
             parent.Children.Remove(node);
             main.ClipboardCopy = false;
             main.Clipboard     = node;
         }
         if (Theme.IconMenuItem(Icons.Copy, "Copy", node != Utf.Root))
         {
             main.ClipboardCopy = true;
             main.Clipboard     = node.MakeCopy();
         }
         if (main.Clipboard != null)
         {
             if (Theme.BeginIconMenu(Icons.Paste, "Paste"))
             {
                 if (ImGui.MenuItem("Before", node != Utf.Root))
                 {
                     if (main.ClipboardCopy)
                     {
                         var cpy = main.Clipboard.MakeCopy();
                         cpy.Parent = parent;
                         parent.Children.Insert(parent.Children.IndexOf(node), cpy);
                     }
                     else
                     {
                         main.Clipboard.Parent = parent;
                         parent.Children.Insert(parent.Children.IndexOf(node), main.Clipboard);
                         main.Clipboard = null;
                     }
                 }
                 if (ImGui.MenuItem("After", node != Utf.Root))
                 {
                     if (main.ClipboardCopy)
                     {
                         var cpy = main.Clipboard.MakeCopy();
                         cpy.Parent = parent;
                         parent.Children.Insert(parent.Children.IndexOf(node) + 1, cpy);
                     }
                     else
                     {
                         main.Clipboard.Parent = parent;
                         parent.Children.Insert(parent.Children.IndexOf(node) + 1, main.Clipboard);
                         main.Clipboard = null;
                     }
                 }
                 if (ImGui.MenuItem("Into"))
                 {
                     if (node.Data == null)
                     {
                         if (node.Children == null)
                         {
                             node.Children = new List <LUtfNode>();
                         }
                         if (main.ClipboardCopy)
                         {
                             var cpy = main.Clipboard.MakeCopy();
                             cpy.Parent = node;
                             node.Children.Add(cpy);
                         }
                         else
                         {
                             main.Clipboard.Parent = node;
                             node.Children.Add(main.Clipboard);
                             main.Clipboard = null;
                         }
                     }
                     else
                     {
                         pasteInto = node;
                         Confirm("Adding children will delete this node's data. Continue?", () =>
                         {
                             pasteInto.Data     = null;
                             pasteInto.Children = new List <LUtfNode>();
                             if (main.ClipboardCopy)
                             {
                                 var cpy    = main.Clipboard.MakeCopy();
                                 cpy.Parent = pasteInto;
                                 pasteInto.Children.Add(cpy);
                             }
                             else
                             {
                                 main.Clipboard.Parent = pasteInto;
                                 pasteInto.Children.Add(main.Clipboard);
                                 main.Clipboard = null;
                             }
                         });
                     }
                 }
                 ImGui.EndMenu();
             }
         }
         else
         {
             Theme.IconMenuItem(Icons.Paste, "Paste", false);
         }
         ImGui.EndPopup();
     }
 }
Beispiel #9
0
 void ConstructContext(RigidModelPart con, bool mdlVisible)
 {
     if (ImGui.IsItemClicked(1))
     {
         ImGui.OpenPopup(con.Construct.ChildName + "_context");
     }
     if (ImGui.BeginPopupContextItem(con.Construct.ChildName + "_context"))
     {
         if (con.Mesh != null)
         {
             //Visibility of model (this is bad)
             bool visibleVar = mdlVisible;
             Theme.IconMenuToggle("Visible", "eye", Color4.White, ref visibleVar, true);
             if (visibleVar != mdlVisible)
             {
                 con.Active = visibleVar;
             }
         }
         if (Theme.BeginIconMenu("Change To", "change", Color4.White))
         {
             var cmp = (CmpFile)drawable;
             if (!(con.Construct is FixConstruct) && Theme.IconMenuItem("Fix", "fix", Color4.LightYellow, true))
             {
                 var fix = new FixConstruct(cmp.Constructs)
                 {
                     ParentName = con.Construct.ParentName,
                     ChildName  = con.Construct.ChildName,
                     Origin     = con.Construct.Origin,
                     Rotation   = con.Construct.Rotation
                 };
                 fix.Reset();
                 con.Construct = fix;
                 OnDirtyPart();
             }
             if (!(con.Construct is RevConstruct) && Theme.IconMenuItem("Rev", "rev", Color4.LightCoral, true))
             {
                 var rev = new RevConstruct()
                 {
                     ParentName = con.Construct.ParentName,
                     ChildName  = con.Construct.ChildName,
                     Origin     = con.Construct.Origin,
                     Rotation   = con.Construct.Rotation
                 };
                 con.Construct = rev;
                 OnDirtyPart();
             }
             if (!(con.Construct is PrisConstruct) && Theme.IconMenuItem("Pris", "pris", Color4.LightPink, true))
             {
                 var pris = new PrisConstruct()
                 {
                     ParentName = con.Construct.ParentName,
                     ChildName  = con.Construct.ChildName,
                     Origin     = con.Construct.Origin,
                     Rotation   = con.Construct.Rotation
                 };
                 con.Construct = pris;
                 OnDirtyPart();
             }
             if (!(con.Construct is SphereConstruct) && Theme.IconMenuItem("Sphere", "sphere", Color4.LightGreen, true))
             {
                 var sphere = new SphereConstruct()
                 {
                     ParentName = con.Construct.ParentName,
                     ChildName  = con.Construct.ChildName,
                     Origin     = con.Construct.Origin,
                     Rotation   = con.Construct.Rotation
                 };
                 con.Construct = sphere;
                 OnDirtyPart();
             }
             ImGui.EndMenu();
         }
         if (Theme.IconMenuItem("Edit", "edit", Color4.White, true))
         {
             AddPartEditor(con.Construct);
         }
         ImGui.EndPopup();
     }
 }
Beispiel #10
0
        protected override void Draw(double elapsed)
        {
            TimeStep = elapsed;
            Viewport.Replace(0, 0, Width, Height);
            RenderState.ClearColor = new Color4(0.2f, 0.2f, 0.2f, 1f);
            RenderState.ClearAll();
            guiHelper.NewFrame(elapsed);
            ImGui.PushFont(ImGuiHelper.Noto);
            ImGui.BeginMainMenuBar();
            if (ImGui.BeginMenu("File"))
            {
                if (Theme.IconMenuItem("New", "new", Color4.White, true))
                {
                    var t = new UtfTab(this, new EditableUtf(), "Untitled");
                    ActiveTab = t;
                    AddTab(t);
                }
                if (Theme.IconMenuItem("Open", "open", Color4.White, true))
                {
                    var f = FileDialog.Open(UtfFilters);
                    OpenFile(f);
                }
                if (ActiveTab == null)
                {
                    Theme.IconMenuItem("Save", "save", Color4.LightGray, false);
                }
                else
                {
                    if (Theme.IconMenuItem(string.Format("Save '{0}'", ActiveTab.DocumentName), "save", Color4.White, true))
                    {
                        var f = FileDialog.Save(UtfFilters);
                        if (f != null)
                        {
                            ActiveTab.DocumentName = System.IO.Path.GetFileName(f);
                            ActiveTab.UpdateTitle();
                            string errText = "";
                            if (!ActiveTab.Utf.Save(f, ref errText))
                            {
                                openError = true;
                                if (errorText == null)
                                {
                                    errorText = new TextBuffer();
                                }
                                errorText.SetText(errText);
                            }
                        }
                    }
                }
                if (Theme.IconMenuItem("Quit", "quit", Color4.White, true))
                {
                    Exit();
                }
                ImGui.EndMenu();
            }
            bool openLoading = false;

            if (ImGui.BeginMenu("View"))
            {
                Theme.IconMenuToggle("Log", "log", Color4.White, ref showLog, true);
                ImGui.EndMenu();
            }
            if (ImGui.BeginMenu("Tools"))
            {
                if (Theme.IconMenuItem("Options", "options", Color4.White, true))
                {
                    showOptions = true;
                }

                if (Theme.IconMenuItem("Resources", "resources", Color4.White, true))
                {
                    AddTab(new ResourcesTab(Resources, MissingResources, ReferencedMaterials, ReferencedTextures));
                }
                if (Theme.IconMenuItem("Import Collada", "import", Color4.White, true))
                {
                    string input;
                    if ((input = FileDialog.Open(ColladaFilters)) != null)
                    {
                        openLoading   = true;
                        finishLoading = false;
                        new Thread(() =>
                        {
                            List <ColladaObject> dae = null;
                            try
                            {
                                dae = ColladaSupport.Parse(input);
                                EnsureUIThread(() => FinishColladaLoad(dae, System.IO.Path.GetFileName(input)));
                            }
                            catch (Exception ex)
                            {
                                EnsureUIThread(() => ColladaError(ex));
                            }
                        }).Start();
                    }
                }
                ImGui.EndMenu();
            }
            if (ImGui.BeginMenu("Help"))
            {
                if (Theme.IconMenuItem("Topics", "help", Color4.White, true))
                {
                    Shell.OpenCommand("https://wiki.librelancer.net/lanceredit:lanceredit");
                }
                if (Theme.IconMenuItem("About", "about", Color4.White, true))
                {
                    openAbout = true;
                }
                ImGui.EndMenu();
            }
            if (openAbout)
            {
                ImGui.OpenPopup("About");
                openAbout = false;
            }
            if (openError)
            {
                ImGui.OpenPopup("Error");
                openError = false;
            }
            if (openLoading)
            {
                ImGui.OpenPopup("Processing");
            }
            bool pOpen = true;

            if (ImGui.BeginPopupModal("Error", ref pOpen, ImGuiWindowFlags.AlwaysAutoResize))
            {
                ImGui.Text("Error:");
                errorText.InputTextMultiline("##etext", new Vector2(430, 200), ImGuiInputTextFlags.ReadOnly);
                if (ImGui.Button("OK"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            pOpen = true;
            if (ImGui.BeginPopupModal("About", ref pOpen, ImGuiWindowFlags.AlwaysAutoResize))
            {
                ImGui.SameLine(ImGui.GetWindowWidth() / 2 - 64);
                Theme.Icon("reactor_128", Color4.White);
                CenterText(Version);
                CenterText("Callum McGing 2018-2019");
                ImGui.Separator();
                CenterText("Icons from Icons8: https://icons8.com/");
                CenterText("Icons from komorra: https://opengameart.org/content/kmr-editor-icon-set");
                ImGui.Separator();
                var btnW = ImGui.CalcTextSize("OK").X + ImGui.GetStyle().FramePadding.X * 2;
                ImGui.Dummy(Vector2.One);
                ImGui.SameLine(ImGui.GetWindowWidth() / 2 - (btnW / 2));
                if (ImGui.Button("OK"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            pOpen = true;
            if (ImGui.BeginPopupModal("Processing", ref pOpen, ImGuiWindowFlags.AlwaysAutoResize))
            {
                ImGuiExt.Spinner("##spinner", 10, 2, ImGuiNative.igGetColorU32(ImGuiCol.ButtonHovered, 1));
                ImGui.SameLine();
                ImGui.Text("Processing");
                if (finishLoading)
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            var menu_height = ImGui.GetWindowSize().Y;

            ImGui.EndMainMenuBar();
            var size = (Vector2)ImGui.GetIO().DisplaySize;

            size.Y -= menu_height;
            //Window
            MissingResources.Clear();
            ReferencedMaterials.Clear();
            ReferencedTextures.Clear();
            foreach (var tab in tabs)
            {
                ((EditorTab)tab).DetectResources(MissingResources, ReferencedMaterials, ReferencedTextures);
            }
            ImGui.SetNextWindowSize(new Vector2(size.X, size.Y - 25), ImGuiCond.Always);
            ImGui.SetNextWindowPos(new Vector2(0, menu_height), ImGuiCond.Always, Vector2.Zero);
            bool childopened = true;

            ImGui.Begin("tabwindow", ref childopened,
                        ImGuiWindowFlags.NoTitleBar |
                        ImGuiWindowFlags.NoSavedSettings |
                        ImGuiWindowFlags.NoBringToFrontOnFocus |
                        ImGuiWindowFlags.NoMove |
                        ImGuiWindowFlags.NoResize);
            TabHandler.TabLabels(tabs, ref selected);
            var totalH = ImGui.GetWindowHeight();

            if (showLog)
            {
                ImGuiExt.SplitterV(2f, ref h1, ref h2, 8, 8, -1);
                h1 = totalH - h2 - 24f;
                if (tabs.Count > 0)
                {
                    h1 -= 20f;
                }
                ImGui.BeginChild("###tabcontent" + (selected != null ? selected.Title : ""), new Vector2(-1, h1), false, ImGuiWindowFlags.None);
            }
            else
            {
                ImGui.BeginChild("###tabcontent" + (selected != null ? selected.Title : ""));
            }
            if (selected != null)
            {
                selected.Draw();
                ((EditorTab)selected).SetActiveTab(this);
            }
            else
            {
                ActiveTab = null;
            }
            ImGui.EndChild();
            TabHandler.DrawTabDrag(tabs);
            if (showLog)
            {
                ImGui.BeginChild("###log", new Vector2(-1, h2), false, ImGuiWindowFlags.None);
                ImGui.Text("Log");
                ImGui.SameLine(ImGui.GetWindowWidth() - 20);
                if (Theme.IconButton("closelog", "x", Color4.White))
                {
                    showLog = false;
                }
                logBuffer.InputTextMultiline("##logtext", new Vector2(-1, h2 - 24), ImGuiInputTextFlags.ReadOnly);
                ImGui.EndChild();
            }
            ImGui.End();
            //Status bar
            ImGui.SetNextWindowSize(new Vector2(size.X, 25f), ImGuiCond.Always);
            ImGui.SetNextWindowPos(new Vector2(0, size.Y - 6f), ImGuiCond.Always, Vector2.Zero);
            bool sbopened = true;

            ImGui.Begin("statusbar", ref sbopened,
                        ImGuiWindowFlags.NoTitleBar |
                        ImGuiWindowFlags.NoSavedSettings |
                        ImGuiWindowFlags.NoBringToFrontOnFocus |
                        ImGuiWindowFlags.NoMove |
                        ImGuiWindowFlags.NoResize);
            if (updateTime > 9)
            {
                updateTime = 0;
                frequency  = RenderFrequency;
            }
            else
            {
                updateTime++;
            }
            string activename = ActiveTab == null ? "None" : ActiveTab.DocumentName;
            string utfpath    = ActiveTab == null ? "None" : ActiveTab.GetUtfPath();

            ImGui.Text(string.Format("FPS: {0} | {1} Materials | {2} Textures | Active: {3} - {4}",
                                     (int)Math.Round(frequency),
                                     Resources.MaterialDictionary.Count,
                                     Resources.TextureDictionary.Count,
                                     activename,
                                     utfpath));
            ImGui.End();
            if (errorTimer > 0)
            {
                ImGuiExt.ToastText("An error has occurred\nCheck the log for details",
                                   new Color4(21, 21, 22, 128),
                                   Color4.Red);
            }
            if (showOptions)
            {
                ImGui.Begin("Options", ref showOptions, ImGuiWindowFlags.AlwaysAutoResize);
                var pastC = cFilter;
                ImGui.Combo("Texture Filter", ref cFilter, filters, filters.Length);
                if (cFilter != pastC)
                {
                    switch (cFilter)
                    {
                    case 0:
                        RenderState.PreferredFilterLevel = TextureFiltering.Linear;
                        break;

                    case 1:
                        RenderState.PreferredFilterLevel = TextureFiltering.Bilinear;
                        break;

                    case 2:
                        RenderState.PreferredFilterLevel = TextureFiltering.Trilinear;
                        break;

                    default:
                        RenderState.AnisotropyLevel      = anisotropyLevels[cFilter - 3];
                        RenderState.PreferredFilterLevel = TextureFiltering.Anisotropic;
                        break;
                    }
                }
                ImGui.End();
            }
            ImGui.PopFont();
            guiHelper.Render(RenderState);
            foreach (var tab in toAdd)
            {
                tabs.Add(tab);
                selected = tab;
            }
            toAdd.Clear();
        }
Beispiel #11
0
        protected override void Draw(double elapsed)
        {
            //Don't process all the imgui stuff when it isn't needed
            if (!loadingSpinnerActive && !guiHelper.DoRender(elapsed))
            {
                if (lastFrame != null)
                {
                    lastFrame.BlitToScreen();
                }
                WaitForEvent(); //Yield like a regular GUI program
                return;
            }
            TimeStep = elapsed;
            RenderContext.ReplaceViewport(0, 0, Width, Height);
            RenderContext.ClearColor = new Color4(0.2f, 0.2f, 0.2f, 1f);
            RenderContext.ClearAll();
            guiHelper.NewFrame(elapsed);
            ImGui.PushFont(ImGuiHelper.Noto);
            ImGui.BeginMainMenuBar();
            if (ImGui.BeginMenu("File"))
            {
                var lst = ImGui.GetWindowDrawList();
                if (Theme.IconMenuItem(Icons.File, "New", true))
                {
                    var t = new UtfTab(this, new EditableUtf(), "Untitled");
                    ActiveTab = t;
                    AddTab(t);
                }
                if (Theme.IconMenuItem(Icons.Open, "Open", true))
                {
                    var f = FileDialog.Open(UtfFilters);
                    OpenFile(f);
                }

                recentFiles.Menu();
                if (ActiveTab == null)
                {
                    Theme.IconMenuItem(Icons.Save, "Save", false);
                    Theme.IconMenuItem(Icons.Save, "Save As", false);
                }
                else
                {
                    if (Theme.IconMenuItem(Icons.Save, string.Format("Save '{0}'", ActiveTab.DocumentName), true))
                    {
                        Save();
                    }
                    if (Theme.IconMenuItem(Icons.Save, "Save As", true))
                    {
                        SaveAs();
                    }
                }
                if (Theme.IconMenuItem(Icons.Quit, "Quit", true))
                {
                    Exit();
                }
                ImGui.EndMenu();
            }
            if (ImGui.BeginMenu("View"))
            {
                Theme.IconMenuToggle(Icons.Log, "Log", ref showLog, true);
                ImGui.EndMenu();
            }
            if (ImGui.BeginMenu("Tools"))
            {
                if (Theme.IconMenuItem(Icons.Cog, "Options", true))
                {
                    options.Show();
                }

                if (Theme.IconMenuItem(Icons.Palette, "Resources", true))
                {
                    AddTab(new ResourcesTab(this, Resources, MissingResources, ReferencedMaterials, ReferencedTextures));
                }
                if (Theme.IconMenuItem(Icons.FileImport, "Import Model", true))
                {
                    string input;
                    if ((input = FileDialog.Open(ImportModelFilters)) != null)
                    {
                        StartLoadingSpinner();
                        new Thread(() =>
                        {
                            SimpleMesh.Model model = null;
                            try
                            {
                                using var stream = File.OpenRead(input);
                                model            = SimpleMesh.Model.FromStream(stream).AutoselectRoot(out _).ApplyRootTransforms(false).CalculateBounds();
                                foreach (var x in model.Geometries)
                                {
                                    if (x.Vertices.Length >= 65534)
                                    {
                                        throw new Exception("Too many vertices");
                                    }
                                    if (x.Indices.Length >= 65534)
                                    {
                                        throw new Exception("Too many indices");
                                    }
                                }
                                EnsureUIThread(() => FinishImporterLoad(model, System.IO.Path.GetFileName(input)));
                            }
                            catch (Exception ex)
                            {
                                EnsureUIThread(() => ImporterError(ex));
                            }
                        }).Start();
                    }
                }
                if (Theme.IconMenuItem(Icons.SprayCan, "Generate Icon", true))
                {
                    string input;
                    if ((input = FileDialog.Open(ImageFilter)) != null)
                    {
                        Make3dbDlg.Open(input);
                    }
                }
                if (Theme.IconMenuItem(Icons.BookOpen, "Infocard Browser", true))
                {
                    string input;
                    if ((input = FileDialog.Open(FreelancerIniFilter)) != null)
                    {
                        AddTab(new InfocardBrowserTab(input, this));
                    }
                }
                if (ImGui.MenuItem("Projectile Viewer"))
                {
                    if (ProjectileViewer.Create(this, out var pj))
                    {
                        tabs.Add(pj);
                    }
                }

                if (ImGui.MenuItem("ParamCurve Visualiser"))
                {
                    tabs.Add(new ParamCurveVis());
                }
                ImGui.EndMenu();
            }
            if (ImGui.BeginMenu("Window"))
            {
                if (ImGui.MenuItem("Close All Tabs", tabs.Count > 0))
                {
                    Confirm("Are you sure you want to close all tabs?", () =>
                    {
                        selected = null;
                        foreach (var t in tabs)
                        {
                            t.Dispose();
                        }
                        tabs.Clear();
                    });
                }
                ImGui.EndMenu();
            }
            if (ImGui.BeginMenu("Scripts"))
            {
                if (ImGui.MenuItem("Refresh"))
                {
                    LoadScripts();
                }
                ImGui.Separator();
                int k = 0;
                foreach (var sc in Scripts)
                {
                    var n = ImGuiExt.IDWithExtra(sc.Info.Name, k++);
                    if (ImGui.MenuItem(n))
                    {
                        RunScript(sc);
                    }
                }
                ImGui.EndMenu();
            }
            if (ImGui.BeginMenu("Help"))
            {
                if (Theme.IconMenuItem(Icons.Book, "Topics", true))
                {
                    var selfPath = Path.GetDirectoryName(typeof(MainWindow).Assembly.Location);
                    var helpFile = Path.Combine(selfPath, "Docs", "index.html");
                    Shell.OpenCommand(helpFile);
                }
                if (Theme.IconMenuItem(Icons.Info, "About", true))
                {
                    openAbout = true;
                }
                ImGui.EndMenu();
            }

            options.Draw();

            if (openAbout)
            {
                ImGui.OpenPopup("About");
                openAbout = false;
            }
            if (openError)
            {
                ImGui.OpenPopup("Error");
                openError = false;
            }

            if (openLoading)
            {
                ImGui.OpenPopup("Processing");
                openLoading = false;
            }

            for (int i = activeScripts.Count - 1; i >= 0; i--)
            {
                if (!activeScripts[i].Draw())
                {
                    activeScripts.RemoveAt(i);
                }
            }
            bool pOpen = true;

            if (ImGui.BeginPopupModal("Error", ref pOpen, ImGuiWindowFlags.AlwaysAutoResize))
            {
                ImGui.Text("Error:");
                errorText.InputTextMultiline("##etext", new Vector2(430, 200), ImGuiInputTextFlags.ReadOnly);
                if (ImGui.Button("OK"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            recentFiles.DrawErrors();
            pOpen = true;
            if (ImGui.BeginPopupModal("About", ref pOpen, ImGuiWindowFlags.AlwaysAutoResize))
            {
                ImGui.SameLine(ImGui.GetWindowWidth() / 2 - 64);
                ImGui.Image((IntPtr)logoTexture, new Vector2(128), new Vector2(0, 1), new Vector2(1, 0));
                CenterText(Version);
                CenterText("Callum McGing 2018-2022");
                ImGui.Separator();
                var btnW = ImGui.CalcTextSize("OK").X + ImGui.GetStyle().FramePadding.X * 2;
                ImGui.Dummy(Vector2.One);
                ImGui.SameLine(ImGui.GetWindowWidth() / 2 - (btnW / 2));
                if (ImGui.Button("OK"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            pOpen = true;
            if (ImGuiExt.BeginModalNoClose("Processing", ImGuiWindowFlags.AlwaysAutoResize))
            {
                ImGuiExt.Spinner("##spinner", 10, 2, ImGui.GetColorU32(ImGuiCol.ButtonHovered, 1));
                ImGui.SameLine();
                ImGui.Text("Processing");
                if (finishLoading)
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            //Confirmation
            if (doConfirm)
            {
                ImGui.OpenPopup("Confirm?##mainwindow");
                doConfirm = false;
            }
            pOpen = true;
            if (ImGui.BeginPopupModal("Confirm?##mainwindow", ref pOpen, ImGuiWindowFlags.AlwaysAutoResize))
            {
                ImGui.Text(confirmText);
                if (ImGui.Button("Yes"))
                {
                    confirmAction();
                    ImGui.CloseCurrentPopup();
                }
                ImGui.SameLine();
                if (ImGui.Button("No"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            var menu_height = ImGui.GetWindowSize().Y;

            ImGui.EndMainMenuBar();
            var size = ImGui.GetIO().DisplaySize;

            size.Y -= menu_height;
            //Window
            MissingResources.Clear();
            ReferencedMaterials.Clear();
            ReferencedTextures.Clear();
            foreach (var tab in tabs)
            {
                ((EditorTab)tab).DetectResources(MissingResources, ReferencedMaterials, ReferencedTextures);
            }
            ImGui.SetNextWindowSize(new Vector2(size.X, size.Y - (25 * ImGuiHelper.Scale)), ImGuiCond.Always);
            ImGui.SetNextWindowPos(new Vector2(0, menu_height), ImGuiCond.Always, Vector2.Zero);
            bool childopened = true;

            ImGui.Begin("tabwindow", ref childopened,
                        ImGuiWindowFlags.NoTitleBar |
                        ImGuiWindowFlags.NoSavedSettings |
                        ImGuiWindowFlags.NoBringToFrontOnFocus |
                        ImGuiWindowFlags.NoMove |
                        ImGuiWindowFlags.NoResize);
            TabHandler.TabLabels(tabs, ref selected);
            var totalH = ImGui.GetWindowHeight();

            if (showLog)
            {
                ImGuiExt.SplitterV(2f, ref h1, ref h2, 8, 8, -1);
                h1 = totalH - h2 - 24f * ImGuiHelper.Scale;
                if (tabs.Count > 0)
                {
                    h1 -= 20f * ImGuiHelper.Scale;
                }
                ImGui.BeginChild("###tabcontent" + (selected != null ? selected.RenderTitle : ""), new Vector2(-1, h1), false, ImGuiWindowFlags.None);
            }
            else
            {
                ImGui.BeginChild("###tabcontent" + (selected != null ? selected.RenderTitle : ""));
            }
            if (selected != null)
            {
                selected.Draw();
                ((EditorTab)selected).SetActiveTab(this);
            }
            else
            {
                ActiveTab = null;
            }
            ImGui.EndChild();
            if (showLog)
            {
                ImGui.BeginChild("###log", new Vector2(-1, h2), false, ImGuiWindowFlags.None);
                ImGui.Text("Log");
                ImGui.SameLine(ImGui.GetWindowWidth() - 30 * ImGuiHelper.Scale);
                ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, Vector2.Zero);
                if (ImGui.Button(Icons.X.ToString()))
                {
                    showLog = false;
                }
                ImGui.PopStyleVar();
                logBuffer.InputTextMultiline("##logtext", new Vector2(-1, h2 - 28 * ImGuiHelper.Scale), ImGuiInputTextFlags.ReadOnly);
                ImGui.EndChild();
            }
            ImGui.End();
            Make3dbDlg.Draw();
            //Status bar
            ImGui.SetNextWindowSize(new Vector2(size.X, 25f * ImGuiHelper.Scale), ImGuiCond.Always);
            ImGui.SetNextWindowPos(new Vector2(0, size.Y - 6f), ImGuiCond.Always, Vector2.Zero);
            bool sbopened = true;

            ImGui.Begin("statusbar", ref sbopened,
                        ImGuiWindowFlags.NoTitleBar |
                        ImGuiWindowFlags.NoSavedSettings |
                        ImGuiWindowFlags.NoBringToFrontOnFocus |
                        ImGuiWindowFlags.NoMove |
                        ImGuiWindowFlags.NoResize);
            if (updateTime > 9)
            {
                updateTime = 0;
                frequency  = RenderFrequency;
            }
            else
            {
                updateTime++;
            }
            string activename = ActiveTab == null ? "None" : ActiveTab.DocumentName;
            string utfpath    = ActiveTab == null ? "None" : ActiveTab.GetUtfPath();

            #if DEBUG
            const string statusFormat = "FPS: {0} | {1} Materials | {2} Textures | Active: {3} - {4}";
            #else
            const string statusFormat = "{1} Materials | {2} Textures | Active: {3} - {4}";
            #endif
            ImGui.Text(string.Format(statusFormat,
                                     (int)Math.Round(frequency),
                                     Resources.MaterialDictionary.Count,
                                     Resources.TextureDictionary.Count,
                                     activename,
                                     utfpath));
            ImGui.End();
            if (errorTimer > 0)
            {
                ImGuiExt.ToastText("An error has occurred\nCheck the log for details",
                                   new Color4(21, 21, 22, 128),
                                   Color4.Red);
            }
            ImGui.PopFont();
            if (lastFrame == null ||
                lastFrame.Width != Width ||
                lastFrame.Height != Height)
            {
                if (lastFrame != null)
                {
                    lastFrame.Dispose();
                }
                lastFrame = new RenderTarget2D(Width, Height);
            }
            RenderContext.RenderTarget = lastFrame;
            RenderContext.ClearColor   = new Color4(0.2f, 0.2f, 0.2f, 1f);
            RenderContext.ClearAll();
            guiHelper.Render(RenderContext);
            RenderContext.RenderTarget = null;
            lastFrame.BlitToScreen();
            foreach (var tab in toAdd)
            {
                tabs.Add(tab);
                selected = tab;
            }
            toAdd.Clear();
        }
Beispiel #12
0
        protected override void Draw(double elapsed)
        {
            EnableTextInput();
            Viewport.Replace(0, 0, Width, Height);
            RenderState.ClearColor = new Color4(0.2f, 0.2f, 0.2f, 1f);
            RenderState.ClearAll();
            guiHelper.NewFrame(elapsed);
            ImGui.PushFont(ImGuiHelper.Noto);
            ImGui.BeginMainMenuBar();
            if (ImGui.BeginMenu("File"))
            {
                if (Theme.IconMenuItem("New", "new", Color4.White, true))
                {
                    var t = new UtfTab(this, new EditableUtf(), "Untitled");
                    ActiveTab = t;
                    AddTab(t);
                }
                if (Theme.IconMenuItem("Open", "open", Color4.White, true))
                {
                    var f = FileDialog.Open();
                    if (f != null && DetectFileType.Detect(f) == FileType.Utf)
                    {
                        var t = new UtfTab(this, new EditableUtf(f), System.IO.Path.GetFileName(f));
                        ActiveTab = t;
                        AddTab(t);
                    }
                }
                if (ActiveTab == null)
                {
                    Theme.IconMenuItem("Save", "save", Color4.LightGray, false);
                }
                else
                {
                    if (Theme.IconMenuItem(string.Format("Save '{0}'", ActiveTab.Title), "save", Color4.White, true))
                    {
                        var f = FileDialog.Save();
                        if (f != null)
                        {
                            ActiveTab.Title = System.IO.Path.GetFileName(f);
                            ActiveTab.Utf.Save(f);
                        }
                    }
                }
                if (Theme.IconMenuItem("Quit", "quit", Color4.White, true))
                {
                    Exit();
                }
                ImGui.EndMenu();
            }
            if (ImGui.BeginMenu("Tools"))
            {
                if (ImGui.MenuItem("Resources"))
                {
                    tabs.Add(new ResourcesTab(Resources, MissingResources, ReferencedMaterials, ReferencedTextures));
                }
                ImGui.EndMenu();
            }
            if (ImGui.BeginMenu("Help"))
            {
                if (Theme.IconMenuItem("About", "about", Color4.White, true))
                {
                    openAbout = true;
                }
                ImGui.EndMenu();
            }
            if (openAbout)
            {
                ImGui.OpenPopup("About");
                openAbout = false;
            }
            if (ImGui.BeginPopupModal("About", WindowFlags.AlwaysAutoResize))
            {
                ImGui.Text("LancerEdit");
                ImGui.Text("Callum McGing 2018");
                ImGui.Separator();
                ImGui.Text("Icons from Icons8: https://icons8.com/");
                ImGui.Text("Icons from komorra: https://opengameart.org/content/kmr-editor-icon-set");
                ImGui.Separator();
                if (ImGui.Button("OK"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            var menu_height = ImGui.GetWindowSize().Y;

            ImGui.EndMainMenuBar();
            var size = (Vector2)ImGui.GetIO().DisplaySize;

            size.Y -= menu_height;
            //Window
            MissingResources.Clear();
            ReferencedMaterials.Clear();
            ReferencedTextures.Clear();
            foreach (var tab in tabs)
            {
                tab.DetectResources(MissingResources, ReferencedMaterials, ReferencedTextures);
            }
            ImGui.SetNextWindowSize(new Vector2(size.X, size.Y - 25), Condition.Always);
            ImGui.SetNextWindowPos(new Vector2(0, menu_height), Condition.Always, Vector2.Zero);
            bool childopened = true;

            ImGui.BeginWindow("tabwindow", ref childopened,
                              WindowFlags.NoTitleBar |
                              WindowFlags.NoSavedSettings |
                              WindowFlags.NoBringToFrontOnFocus |
                              WindowFlags.NoMove |
                              WindowFlags.NoResize);
            TabHandler.TabLabels(tabs, ref selected);
            ImGui.BeginChild("###tabcontent");
            if (selected != null)
            {
                selected.Draw();
                selected.SetActiveTab(this);
            }
            else
            {
                ActiveTab = null;
            }
            ImGui.EndChild();
            TabHandler.DrawTabDrag(tabs);
            ImGui.EndWindow();
            //Status bar
            ImGui.SetNextWindowSize(new Vector2(size.X, 25f), Condition.Always);
            ImGui.SetNextWindowPos(new Vector2(0, size.Y - 6f), Condition.Always, Vector2.Zero);
            bool sbopened = true;

            ImGui.BeginWindow("statusbar", ref sbopened,
                              WindowFlags.NoTitleBar |
                              WindowFlags.NoSavedSettings |
                              WindowFlags.NoBringToFrontOnFocus |
                              WindowFlags.NoMove |
                              WindowFlags.NoResize);
            if (updateTime > 9)
            {
                updateTime = 0;
                frequency  = RenderFrequency;
            }
            else
            {
                updateTime++;
            }
            string activename = ActiveTab == null ? "None" : ActiveTab.Title;
            string utfpath    = ActiveTab == null ? "None" : ActiveTab.GetUtfPath();

            ImGui.Text(string.Format("FPS: {0} | {1} Materials | {2} Textures | Active: {3} - {4}",
                                     (int)Math.Round(frequency),
                                     Resources.MaterialDictionary.Count,
                                     Resources.TextureDictionary.Count,
                                     activename,
                                     utfpath));
            ImGui.EndWindow();
            ImGui.PopFont();
            guiHelper.Render(RenderState);
            foreach (var tab in toAdd)
            {
                tabs.Add(tab);
                selected = tab;
            }
            toAdd.Clear();
        }
Beispiel #13
0
        protected override void Draw(double elapsed)
        {
            EnableTextInput();
            Viewport.Replace(0, 0, Width, Height);
            RenderState.ClearColor = new Color4(0.2f, 0.2f, 0.2f, 1f);
            RenderState.ClearAll();
            guiHelper.NewFrame(elapsed);
            ImGui.PushFont(ImGuiHelper.Noto);
            ImGui.BeginMainMenuBar();
            if (ImGui.BeginMenu("File"))
            {
                if (Theme.IconMenuItem("New", "new", Color4.White, true))
                {
                    var t = new UtfTab(this, new EditableUtf(), "Untitled");
                    ActiveTab = t;
                    AddTab(t);
                }
                if (Theme.IconMenuItem("Open", "open", Color4.White, true))
                {
                    var f = FileDialog.Open(UtfFilters);
                    if (f != null && DetectFileType.Detect(f) == FileType.Utf)
                    {
                        var t = new UtfTab(this, new EditableUtf(f), System.IO.Path.GetFileName(f));
                        ActiveTab = t;
                        AddTab(t);
                    }
                }
                if (ActiveTab == null)
                {
                    Theme.IconMenuItem("Save", "save", Color4.LightGray, false);
                }
                else
                {
                    if (Theme.IconMenuItem(string.Format("Save '{0}'", ActiveTab.DocumentName), "save", Color4.White, true))
                    {
                        var f = FileDialog.Save(UtfFilters);
                        if (f != null)
                        {
                            ActiveTab.DocumentName = System.IO.Path.GetFileName(f);
                            ActiveTab.UpdateTitle();
                            ActiveTab.Utf.Save(f);
                        }
                    }
                }
                if (Theme.IconMenuItem("Quit", "quit", Color4.White, true))
                {
                    Exit();
                }
                ImGui.EndMenu();
            }
            bool openerror = false;

            if (ImGui.BeginMenu("Tools"))
            {
                if (ImGui.MenuItem("Options"))
                {
                    showOptions = true;
                }
                if (ImGui.MenuItem("Log"))
                {
                    showLog = true;
                }
                if (ImGui.MenuItem("Resources"))
                {
                    AddTab(new ResourcesTab(Resources, MissingResources, ReferencedMaterials, ReferencedTextures));
                }
                if (ImGui.MenuItem("Import Collada"))
                {
                    string input;
                    if ((input = FileDialog.Open(ColladaFilters)) != null)
                    {
                        List <ColladaObject> dae = null;
                        try
                        {
                            dae = ColladaSupport.Parse(input);
                            AddTab(new ColladaTab(dae, System.IO.Path.GetFileName(input), this));
                        }
                        catch (Exception ex)
                        {
                            if (errorText != null)
                            {
                                errorText.Dispose();
                            }
                            var str = "Import Error:\n" + ex.Message + "\n" + ex.StackTrace;
                            errorText = new TextBuffer();
                            errorText.SetText(str);
                            openerror = true;
                        }
                    }
                }
                ImGui.EndMenu();
            }
            if (ImGui.BeginMenu("Help"))
            {
                if (Theme.IconMenuItem("About", "about", Color4.White, true))
                {
                    openAbout = true;
                }
                ImGui.EndMenu();
            }
            if (openAbout)
            {
                ImGui.OpenPopup("About");
                openAbout = false;
            }
            if (openerror)
            {
                ImGui.OpenPopup("Error");
            }
            if (ImGui.BeginPopupModal("Error", WindowFlags.AlwaysAutoResize))
            {
                ImGui.Text("Error:");
                ImGui.InputTextMultiline("##etext", errorText.Pointer, (uint)errorText.Size,
                                         new Vector2(430, 200), InputTextFlags.ReadOnly, errorText.Callback);
                if (ImGui.Button("OK"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            if (ImGui.BeginPopupModal("About", WindowFlags.AlwaysAutoResize))
            {
                ImGui.Text("LancerEdit");
                ImGui.Text("Callum McGing 2018");
                ImGui.Separator();
                ImGui.Text("Icons from Icons8: https://icons8.com/");
                ImGui.Text("Icons from komorra: https://opengameart.org/content/kmr-editor-icon-set");
                ImGui.Separator();
                if (ImGui.Button("OK"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            var menu_height = ImGui.GetWindowSize().Y;

            ImGui.EndMainMenuBar();
            var size = (Vector2)ImGui.GetIO().DisplaySize;

            size.Y -= menu_height;
            //Window
            MissingResources.Clear();
            ReferencedMaterials.Clear();
            ReferencedTextures.Clear();
            foreach (var tab in tabs)
            {
                tab.DetectResources(MissingResources, ReferencedMaterials, ReferencedTextures);
            }
            ImGui.SetNextWindowSize(new Vector2(size.X, size.Y - 25), Condition.Always);
            ImGui.SetNextWindowPos(new Vector2(0, menu_height), Condition.Always, Vector2.Zero);
            bool childopened = true;

            ImGui.BeginWindow("tabwindow", ref childopened,
                              WindowFlags.NoTitleBar |
                              WindowFlags.NoSavedSettings |
                              WindowFlags.NoBringToFrontOnFocus |
                              WindowFlags.NoMove |
                              WindowFlags.NoResize);
            TabHandler.TabLabels(tabs, ref selected);
            var totalH = ImGui.GetWindowHeight();

            if (showLog)
            {
                ImGuiExt.SplitterV(2f, ref h1, ref h2, 8, 8, -1);
                h1 = totalH - h2 - 24f;
                if (tabs.Count > 0)
                {
                    h1 -= 20f;
                }
                ImGui.BeginChild("###tabcontent" + (selected != null ? selected.Title : ""), new Vector2(-1, h1), false, WindowFlags.Default);
            }
            else
            {
                ImGui.BeginChild("###tabcontent" + (selected != null ? selected.Title : ""));
            }
            if (selected != null)
            {
                selected.Draw();
                selected.SetActiveTab(this);
            }
            else
            {
                ActiveTab = null;
            }
            ImGui.EndChild();
            TabHandler.DrawTabDrag(tabs);
            if (showLog)
            {
                ImGui.BeginChild("###log", new Vector2(-1, h2), false, WindowFlags.Default);
                ImGui.Text("Log");
                ImGui.SameLine(ImGui.GetWindowWidth() - 20);
                if (Theme.IconButton("closelog", "x", Color4.White))
                {
                    showLog = false;
                }
                ImGui.InputTextMultiline("##logtext", logBuffer.Pointer, 32768, new Vector2(-1, h2 - 24),
                                         InputTextFlags.ReadOnly, logBuffer.Callback);
                ImGui.EndChild();
            }
            ImGui.EndWindow();
            //Status bar
            ImGui.SetNextWindowSize(new Vector2(size.X, 25f), Condition.Always);
            ImGui.SetNextWindowPos(new Vector2(0, size.Y - 6f), Condition.Always, Vector2.Zero);
            bool sbopened = true;

            ImGui.BeginWindow("statusbar", ref sbopened,
                              WindowFlags.NoTitleBar |
                              WindowFlags.NoSavedSettings |
                              WindowFlags.NoBringToFrontOnFocus |
                              WindowFlags.NoMove |
                              WindowFlags.NoResize);
            if (updateTime > 9)
            {
                updateTime = 0;
                frequency  = RenderFrequency;
            }
            else
            {
                updateTime++;
            }
            string activename = ActiveTab == null ? "None" : ActiveTab.DocumentName;
            string utfpath    = ActiveTab == null ? "None" : ActiveTab.GetUtfPath();

            ImGui.Text(string.Format("FPS: {0} | {1} Materials | {2} Textures | Active: {3} - {4}",
                                     (int)Math.Round(frequency),
                                     Resources.MaterialDictionary.Count,
                                     Resources.TextureDictionary.Count,
                                     activename,
                                     utfpath));
            ImGui.EndWindow();
            if (showOptions)
            {
                ImGui.BeginWindow("Options", ref showOptions, WindowFlags.AlwaysAutoResize);
                var pastC = cFilter;
                ImGui.Combo("Texture Filter", ref cFilter, filters);
                if (cFilter != pastC)
                {
                    switch (cFilter)
                    {
                    case 0:
                        RenderState.PreferredFilterLevel = TextureFiltering.Linear;
                        break;

                    case 1:
                        RenderState.PreferredFilterLevel = TextureFiltering.Bilinear;
                        break;

                    case 2:
                        RenderState.PreferredFilterLevel = TextureFiltering.Trilinear;
                        break;

                    default:
                        RenderState.AnisotropyLevel      = anisotropyLevels[cFilter - 3];
                        RenderState.PreferredFilterLevel = TextureFiltering.Anisotropic;
                        break;
                    }
                }
                ImGui.EndWindow();
            }
            ImGui.PopFont();
            guiHelper.Render(RenderState);
            foreach (var tab in toAdd)
            {
                tabs.Add(tab);
                selected = tab;
            }
            toAdd.Clear();
        }
Beispiel #14
0
 void ConstructContext(RigidModelPart con, bool mdlVisible)
 {
     if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
     {
         ImGui.OpenPopup(con.Construct.ChildName + "_context");
     }
     if (ImGui.BeginPopupContextItem(con.Construct.ChildName + "_context"))
     {
         if (con.Mesh != null)
         {
             //Visibility of model (this is bad)
             bool visibleVar = mdlVisible;
             Theme.IconMenuToggle(Icons.Eye, "Visible", ref visibleVar, true);
             if (visibleVar != mdlVisible)
             {
                 con.Active = visibleVar;
             }
         }
         if (Theme.BeginIconMenu(Icons.Exchange, "Change To"))
         {
             var cmp = (CmpFile)drawable;
             if (!(con.Construct is FixConstruct) && Theme.IconMenuItem(Icons.Cube_LightYellow, "Fix", true))
             {
                 var fix = new FixConstruct(cmp.Constructs)
                 {
                     ParentName = con.Construct.ParentName,
                     ChildName  = con.Construct.ChildName,
                     Origin     = con.Construct.Origin,
                     Rotation   = con.Construct.Rotation
                 };
                 fix.Reset();
                 con.Construct = fix;
                 OnDirtyPart();
             }
             if (!(con.Construct is RevConstruct) && Theme.IconMenuItem(Icons.Rev_LightCoral, "Rev", true))
             {
                 var rev = new RevConstruct()
                 {
                     ParentName = con.Construct.ParentName,
                     ChildName  = con.Construct.ChildName,
                     Origin     = con.Construct.Origin,
                     Rotation   = con.Construct.Rotation
                 };
                 con.Construct = rev;
                 OnDirtyPart();
             }
             if (!(con.Construct is PrisConstruct) && Theme.IconMenuItem(Icons.Con_Pris, "Pris", true))
             {
                 var pris = new PrisConstruct()
                 {
                     ParentName = con.Construct.ParentName,
                     ChildName  = con.Construct.ChildName,
                     Origin     = con.Construct.Origin,
                     Rotation   = con.Construct.Rotation
                 };
                 con.Construct = pris;
                 OnDirtyPart();
             }
             if (!(con.Construct is SphereConstruct) && Theme.IconMenuItem(Icons.Con_Sph, "Sphere", true))
             {
                 var sphere = new SphereConstruct()
                 {
                     ParentName = con.Construct.ParentName,
                     ChildName  = con.Construct.ChildName,
                     Origin     = con.Construct.Origin,
                     Rotation   = con.Construct.Rotation
                 };
                 con.Construct = sphere;
                 OnDirtyPart();
             }
             ImGui.EndMenu();
         }
         if (Theme.IconMenuItem(Icons.Edit, "Edit", true))
         {
             AddPartEditor(con.Construct);
         }
         ImGui.EndPopup();
     }
 }
Beispiel #15
0
        protected override void Draw(double elapsed)
        {
            //Don't process all the imgui stuff when it isn't needed
            if (!loadingSpinnerActive && !guiHelper.DoRender(elapsed))
            {
                if (lastFrame != null)
                {
                    lastFrame.BlitToScreen();
                }
                WaitForEvent(); //Yield like a regular GUI program
                return;
            }
            TimeStep = elapsed;
            Viewport.Replace(0, 0, Width, Height);
            RenderState.ClearColor = new Color4(0.2f, 0.2f, 0.2f, 1f);
            RenderState.ClearAll();
            guiHelper.NewFrame(elapsed);
            ImGui.PushFont(ImGuiHelper.Noto);
            ImGui.BeginMainMenuBar();
            if (ImGui.BeginMenu("File"))
            {
                if (Theme.IconMenuItem("New", "new", Color4.White, true))
                {
                    var t = new UtfTab(this, new EditableUtf(), "Untitled");
                    ActiveTab = t;
                    AddTab(t);
                }
                if (Theme.IconMenuItem("Open", "open", Color4.White, true))
                {
                    var f = FileDialog.Open(UtfFilters);
                    OpenFile(f);
                }
                if (ActiveTab == null)
                {
                    Theme.IconMenuItem("Save", "save", Color4.LightGray, false);
                    Theme.IconMenuItem("Save As", "saveas", Color4.LightGray, false);
                }
                else
                {
                    if (Theme.IconMenuItem(string.Format("Save '{0}'", ActiveTab.DocumentName), "saveas", Color4.White, true))
                    {
                        Save();
                    }
                    if (Theme.IconMenuItem("Save As", "saveas", Color4.White, true))
                    {
                        SaveAs();
                    }
                }
                if (Theme.IconMenuItem("Quit", "quit", Color4.White, true))
                {
                    Exit();
                }
                ImGui.EndMenu();
            }
            if (ImGui.BeginMenu("View"))
            {
                Theme.IconMenuToggle("Log", "log", Color4.White, ref showLog, true);
                ImGui.EndMenu();
            }
            if (ImGui.BeginMenu("Tools"))
            {
                if (Theme.IconMenuItem("Options", "options", Color4.White, true))
                {
                    options.Show();
                }

                if (Theme.IconMenuItem("Resources", "resources", Color4.White, true))
                {
                    AddTab(new ResourcesTab(this, Resources, MissingResources, ReferencedMaterials, ReferencedTextures));
                }
                if (Theme.IconMenuItem("Import Collada", "import", Color4.White, true))
                {
                    string input;
                    if ((input = FileDialog.Open(ColladaFilters)) != null)
                    {
                        StartLoadingSpinner();
                        new Thread(() =>
                        {
                            List <ColladaObject> dae = null;
                            try
                            {
                                dae = ColladaSupport.Parse(input);
                                EnsureUIThread(() => FinishColladaLoad(dae, System.IO.Path.GetFileName(input)));
                            }
                            catch (Exception ex)
                            {
                                EnsureUIThread(() => ColladaError(ex));
                            }
                        }).Start();
                    }
                }
                if (Theme.IconMenuItem("Generate Icon", "genicon", Color4.White, true))
                {
                    string input;
                    if ((input = FileDialog.Open(ImageFilter)) != null)
                    {
                        gen3dbDlg.Open(input);
                    }
                }
                if (Theme.IconMenuItem("Infocard Browser", "browse", Color4.White, true))
                {
                    string input;
                    if ((input = FileDialog.Open(FreelancerIniFilter)) != null)
                    {
                        AddTab(new InfocardBrowserTab(input, this));
                    }
                }
                if (ImGui.MenuItem("Projectile Viewer"))
                {
                    if (ProjectileViewer.Create(this, out var pj))
                    {
                        tabs.Add(pj);
                    }
                }
                ImGui.EndMenu();
            }
            if (ImGui.BeginMenu("Help"))
            {
                if (Theme.IconMenuItem("Topics", "help", Color4.White, true))
                {
                    Shell.OpenCommand("https://wiki.librelancer.net/lanceredit:lanceredit");
                }
                if (Theme.IconMenuItem("About", "about", Color4.White, true))
                {
                    openAbout = true;
                }
                ImGui.EndMenu();
            }

            options.Draw();
            if (openAbout)
            {
                ImGui.OpenPopup("About");
                openAbout = false;
            }
            if (openError)
            {
                ImGui.OpenPopup("Error");
                openError = false;
            }

            if (openLoading)
            {
                ImGui.OpenPopup("Processing");
                openLoading = false;
            }
            bool pOpen = true;

            if (ImGui.BeginPopupModal("Error", ref pOpen, ImGuiWindowFlags.AlwaysAutoResize))
            {
                ImGui.Text("Error:");
                errorText.InputTextMultiline("##etext", new Vector2(430, 200), ImGuiInputTextFlags.ReadOnly);
                if (ImGui.Button("OK"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            pOpen = true;
            if (ImGui.BeginPopupModal("About", ref pOpen, ImGuiWindowFlags.AlwaysAutoResize))
            {
                ImGui.SameLine(ImGui.GetWindowWidth() / 2 - 64);
                Theme.Icon("reactor_128", Color4.White);
                CenterText(Version);
                CenterText("Callum McGing 2018-2020");
                ImGui.Separator();
                CenterText("Icons from Icons8: https://icons8.com/");
                CenterText("Icons from komorra: https://opengameart.org/content/kmr-editor-icon-set");
                ImGui.Separator();
                var btnW = ImGui.CalcTextSize("OK").X + ImGui.GetStyle().FramePadding.X * 2;
                ImGui.Dummy(Vector2.One);
                ImGui.SameLine(ImGui.GetWindowWidth() / 2 - (btnW / 2));
                if (ImGui.Button("OK"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            pOpen = true;
            if (ImGuiExt.BeginModalNoClose("Processing", ImGuiWindowFlags.AlwaysAutoResize))
            {
                ImGuiExt.Spinner("##spinner", 10, 2, ImGuiNative.igGetColorU32(ImGuiCol.ButtonHovered, 1));
                ImGui.SameLine();
                ImGui.Text("Processing");
                if (finishLoading)
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            //Confirmation
            if (doConfirm)
            {
                ImGui.OpenPopup("Confirm?##mainwindow");
                doConfirm = false;
            }
            pOpen = true;
            if (ImGui.BeginPopupModal("Confirm?##mainwindow", ref pOpen, ImGuiWindowFlags.AlwaysAutoResize))
            {
                ImGui.Text(confirmText);
                if (ImGui.Button("Yes"))
                {
                    confirmAction();
                    ImGui.CloseCurrentPopup();
                }
                ImGui.SameLine();
                if (ImGui.Button("No"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            var menu_height = ImGui.GetWindowSize().Y;

            ImGui.EndMainMenuBar();
            var size = ImGui.GetIO().DisplaySize;

            size.Y -= menu_height;
            //Window
            MissingResources.Clear();
            ReferencedMaterials.Clear();
            ReferencedTextures.Clear();
            foreach (var tab in tabs)
            {
                ((EditorTab)tab).DetectResources(MissingResources, ReferencedMaterials, ReferencedTextures);
            }
            ImGui.SetNextWindowSize(new Vector2(size.X, size.Y - 25), ImGuiCond.Always);
            ImGui.SetNextWindowPos(new Vector2(0, menu_height), ImGuiCond.Always, Vector2.Zero);
            bool childopened = true;

            ImGui.Begin("tabwindow", ref childopened,
                        ImGuiWindowFlags.NoTitleBar |
                        ImGuiWindowFlags.NoSavedSettings |
                        ImGuiWindowFlags.NoBringToFrontOnFocus |
                        ImGuiWindowFlags.NoMove |
                        ImGuiWindowFlags.NoResize);
            TabHandler.TabLabels(tabs, ref selected);
            var totalH = ImGui.GetWindowHeight();

            if (showLog)
            {
                ImGuiExt.SplitterV(2f, ref h1, ref h2, 8, 8, -1);
                h1 = totalH - h2 - 24f;
                if (tabs.Count > 0)
                {
                    h1 -= 20f;
                }
                ImGui.BeginChild("###tabcontent" + (selected != null ? selected.RenderTitle : ""), new Vector2(-1, h1), false, ImGuiWindowFlags.None);
            }
            else
            {
                ImGui.BeginChild("###tabcontent" + (selected != null ? selected.RenderTitle : ""));
            }
            if (selected != null)
            {
                selected.Draw();
                ((EditorTab)selected).SetActiveTab(this);
            }
            else
            {
                ActiveTab = null;
            }
            ImGui.EndChild();
            if (showLog)
            {
                ImGui.BeginChild("###log", new Vector2(-1, h2), false, ImGuiWindowFlags.None);
                ImGui.Text("Log");
                ImGui.SameLine(ImGui.GetWindowWidth() - 20);
                if (Theme.IconButton("closelog", "x", Color4.White))
                {
                    showLog = false;
                }
                logBuffer.InputTextMultiline("##logtext", new Vector2(-1, h2 - 24), ImGuiInputTextFlags.ReadOnly);
                ImGui.EndChild();
            }
            ImGui.End();
            gen3dbDlg.Draw();
            //Status bar
            ImGui.SetNextWindowSize(new Vector2(size.X, 25f), ImGuiCond.Always);
            ImGui.SetNextWindowPos(new Vector2(0, size.Y - 6f), ImGuiCond.Always, Vector2.Zero);
            bool sbopened = true;

            ImGui.Begin("statusbar", ref sbopened,
                        ImGuiWindowFlags.NoTitleBar |
                        ImGuiWindowFlags.NoSavedSettings |
                        ImGuiWindowFlags.NoBringToFrontOnFocus |
                        ImGuiWindowFlags.NoMove |
                        ImGuiWindowFlags.NoResize);
            if (updateTime > 9)
            {
                updateTime = 0;
                frequency  = RenderFrequency;
            }
            else
            {
                updateTime++;
            }
            string activename = ActiveTab == null ? "None" : ActiveTab.DocumentName;
            string utfpath    = ActiveTab == null ? "None" : ActiveTab.GetUtfPath();

            #if DEBUG
            const string statusFormat = "FPS: {0} | {1} Materials | {2} Textures | Active: {3} - {4}";
            #else
            const string statusFormat = "{1} Materials | {2} Textures | Active: {3} - {4}";
            #endif
            ImGui.Text(string.Format(statusFormat,
                                     (int)Math.Round(frequency),
                                     Resources.MaterialDictionary.Count,
                                     Resources.TextureDictionary.Count,
                                     activename,
                                     utfpath));
            ImGui.End();
            if (errorTimer > 0)
            {
                ImGuiExt.ToastText("An error has occurred\nCheck the log for details",
                                   new Color4(21, 21, 22, 128),
                                   Color4.Red);
            }
            ImGui.PopFont();
            if (lastFrame == null ||
                lastFrame.Width != Width ||
                lastFrame.Height != Height)
            {
                if (lastFrame != null)
                {
                    lastFrame.Dispose();
                }
                lastFrame = new RenderTarget2D(Width, Height);
            }
            RenderState.RenderTarget = lastFrame;
            RenderState.ClearColor   = new Color4(0.2f, 0.2f, 0.2f, 1f);
            RenderState.ClearAll();
            guiHelper.Render(RenderState);
            RenderState.RenderTarget = null;
            lastFrame.BlitToScreen();
            foreach (var tab in toAdd)
            {
                tabs.Add(tab);
                selected = tab;
            }
            toAdd.Clear();
        }
Beispiel #16
0
        void ConstructContext(ConstructNode con, bool mdlVisible)
        {
            if (ImGui.IsItemClicked(1))
            {
                ImGui.OpenPopup(con.Con.ChildName + "_context");
            }
            if (ImGui.BeginPopupContextItem(con.Con.ChildName + "_context"))
            {
                if (con.Model != null)
                {
                    //Visibility of model (this is bad)
                    bool visibleVar = mdlVisible;
                    Theme.IconMenuToggle("Visible", "eye", Color4.White, ref visibleVar, true);
                    if (visibleVar != mdlVisible)
                    {
                        if (visibleVar)
                        {
                            hiddenModels.Remove(con.Model);
                        }
                        else
                        {
                            hiddenModels.Add(con.Model);
                        }
                    }
                }

                if (Theme.BeginIconMenu("Change To", "change", Color4.White))
                {
                    var cmp = (CmpFile)drawable;
                    if (!(con.Con is FixConstruct) && Theme.IconMenuItem("Fix", "fix", Color4.LightYellow, true))
                    {
                        var fix = new FixConstruct(cmp.Constructs)
                        {
                            ParentName = con.Con.ParentName,
                            ChildName  = con.Con.ChildName,
                            Origin     = con.Con.Origin,
                            Rotation   = con.Con.Rotation
                        };
                        fix.Reset();
                        ReplaceConstruct(con, fix);
                        OnDirtyPart();
                    }
                    if (!(con.Con is RevConstruct) && Theme.IconMenuItem("Rev", "rev", Color4.LightCoral, true))
                    {
                        var rev = new RevConstruct(cmp.Constructs)
                        {
                            ParentName = con.Con.ParentName,
                            ChildName  = con.Con.ChildName,
                            Origin     = con.Con.Origin,
                            Rotation   = con.Con.Rotation
                        };
                        ReplaceConstruct(con, rev);
                        OnDirtyPart();
                    }
                    if (!(con.Con is PrisConstruct) && Theme.IconMenuItem("Pris", "pris", Color4.LightPink, true))
                    {
                        var pris = new PrisConstruct(cmp.Constructs)
                        {
                            ParentName = con.Con.ParentName,
                            ChildName  = con.Con.ChildName,
                            Origin     = con.Con.Origin,
                            Rotation   = con.Con.Rotation
                        };
                        ReplaceConstruct(con, pris);
                        OnDirtyPart();
                    }
                    if (!(con.Con is SphereConstruct) && Theme.IconMenuItem("Sphere", "sphere", Color4.LightGreen, true))
                    {
                        var sphere = new SphereConstruct(cmp.Constructs)
                        {
                            ParentName = con.Con.ParentName,
                            ChildName  = con.Con.ChildName,
                            Origin     = con.Con.Origin,
                            Rotation   = con.Con.Rotation
                        };
                        ReplaceConstruct(con, sphere);
                        OnDirtyPart();
                    }
                    ImGui.EndMenu();
                }
                if (Theme.IconMenuItem("Edit", "edit", Color4.White, true))
                {
                    AddPartEditor(con.Con);
                }
                ImGui.EndPopup();
            }
        }
Beispiel #17
0
        void NewHardpoint(PopupData data)
        {
            ImGui.Text("Name: ");
            ImGui.SameLine();
            newHpBuffer.InputText("##hpname", ImGuiInputTextFlags.None);
            ImGui.SameLine();
            if (ImGui.Button(".."))
            {
                ImGui.OpenPopup("names");
            }
            if (ImGui.BeginPopupContextItem("names"))
            {
                var infos = newIsFixed ? HardpointInformation.Fix : HardpointInformation.Rev;
                foreach (var item in infos)
                {
                    if (Theme.IconMenuItem(item.Name, item.Icon, item.Color, true))
                    {
                        switch (item.Autoname)
                        {
                        case HpNaming.None:
                            newHpBuffer.SetText(item.Name);
                            break;

                        case HpNaming.Number:
                            newHpBuffer.SetText(item.Name + GetHpNumbering(item.Name).ToString("00"));
                            break;

                        case HpNaming.Letter:
                            newHpBuffer.SetText(item.Name + GetHpLettering(item.Name));
                            break;
                        }
                    }
                }
                ImGui.EndPopup();
            }
            ImGui.Text("Type: " + (newIsFixed ? "Fixed" : "Revolute"));
            if (newErrorTimer > 0)
            {
                ImGui.TextColored(new Vector4(1, 0, 0, 1), "Hardpoint with that name already exists.");
            }
            if (ImGui.Button("Ok"))
            {
                var txt = newHpBuffer.GetText();
                if (txt.Length == 0)
                {
                    return;
                }
                if (gizmos.Any((x) => x.Definition.Name.Equals(txt, StringComparison.OrdinalIgnoreCase)))
                {
                    newErrorTimer = 6;
                }
                else
                {
                    HardpointDefinition def;
                    if (newIsFixed)
                    {
                        def = new FixedHardpointDefinition(txt);
                    }
                    else
                    {
                        def = new RevoluteHardpointDefinition(txt);
                    }
                    gizmos.Add(new HardpointGizmo(def, addConstruct));
                    addTo.Add(def);
                    ImGui.CloseCurrentPopup();
                }
            }
            ImGui.SameLine();
            if (ImGui.Button("Cancel"))
            {
                ImGui.CloseCurrentPopup();
            }
        }
Beispiel #18
0
 void ConstructContext(ConstructNode con)
 {
     if (ImGui.IsItemClicked(1))
     {
         ImGui.OpenPopup(con.Con.ChildName + "_context");
     }
     if (ImGui.BeginPopupContextItem(con.Con.ChildName + "_context"))
     {
         if (Theme.BeginIconMenu("Change To", "change", Color4.White))
         {
             var cmp = (CmpFile)drawable;
             if (!(con.Con is FixConstruct) && Theme.IconMenuItem("Fix", "fix", Color4.LightYellow, true))
             {
                 var fix = new FixConstruct(cmp.Constructs)
                 {
                     ParentName = con.Con.ParentName,
                     ChildName  = con.Con.ChildName,
                     Origin     = con.Con.Origin,
                     Rotation   = con.Con.Rotation
                 };
                 fix.Reset();
                 ReplaceConstruct(con, fix);
             }
             if (!(con.Con is RevConstruct) && Theme.IconMenuItem("Rev", "rev", Color4.LightCoral, true))
             {
                 var rev = new RevConstruct(cmp.Constructs)
                 {
                     ParentName = con.Con.ParentName,
                     ChildName  = con.Con.ChildName,
                     Origin     = con.Con.Origin,
                     Rotation   = con.Con.Rotation
                 };
                 ReplaceConstruct(con, rev);
             }
             if (!(con.Con is PrisConstruct) && Theme.IconMenuItem("Pris", "pris", Color4.LightPink, true))
             {
                 var pris = new PrisConstruct(cmp.Constructs)
                 {
                     ParentName = con.Con.ParentName,
                     ChildName  = con.Con.ChildName,
                     Origin     = con.Con.Origin,
                     Rotation   = con.Con.Rotation
                 };
                 ReplaceConstruct(con, pris);
             }
             if (!(con.Con is SphereConstruct) && Theme.IconMenuItem("Sphere", "sphere", Color4.LightGreen, true))
             {
                 var sphere = new SphereConstruct(cmp.Constructs)
                 {
                     ParentName = con.Con.ParentName,
                     ChildName  = con.Con.ChildName,
                     Origin     = con.Con.Origin,
                     Rotation   = con.Con.Rotation
                 };
                 ReplaceConstruct(con, sphere);
             }
             ImGui.EndMenu();
         }
         if (Theme.IconMenuItem("Edit", "edit", Color4.White, true))
         {
             AddPartEditor(con.Con);
         }
         ImGui.EndPopup();
     }
 }