コード例 #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);
        }
コード例 #2
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);
 }
コード例 #3
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);
 }
コード例 #4
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);
 }
コード例 #5
0
ファイル: UtfTab.cs プロジェクト: Regenhardt/Librelancer
 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();
     }
 }
コード例 #6
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();
     }
 }
コード例 #7
0
ファイル: ModelViewer.cs プロジェクト: Hal47/Librelancer
        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();
            }
        }
コード例 #8
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();
     }
 }
コード例 #9
0
ファイル: ModelViewer.cs プロジェクト: lyzardiar/Librelancer
 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();
     }
 }