public string GetValue()
 {
     if (Argument.Type == ScriptArgumentType.Integer)
     {
         return(IntegerValue.ToString());
     }
     if (Argument.Type == ScriptArgumentType.Boolean)
     {
         return(BooleanValue.ToString());
     }
     if (Argument.Type == ScriptArgumentType.Dropdown)
     {
         return(Argument.Options[IntegerValue]);
     }
     if (Argument.Type == ScriptArgumentType.FileArray)
     {
         return(string.Join("\n", StringArray));
     }
     return(InputText.GetText().Trim());
 }
Exemple #2
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();
            }
        }
Exemple #3
0
        void HierarchyPanel()
        {
            if (!(drawable is DF.DfmFile) && !(drawable is SphFile))
            {
                //Sur
                if (ImGui.Button("Open Sur"))
                {
                    var file = FileDialog.Open(SurFilters);
                    surname = System.IO.Path.GetFileName(file);
                    LibreLancer.Physics.Sur.SurFile sur;
                    try
                    {
                        using (var f = System.IO.File.OpenRead(file))
                        {
                            sur = new LibreLancer.Physics.Sur.SurFile(f);
                        }
                    }
                    catch (Exception)
                    {
                        sur = null;
                    }
                    if (sur != null)
                    {
                        ProcessSur(sur);
                    }
                }
                if (surs != null)
                {
                    ImGui.Separator();
                    ImGui.Text("Sur: " + surname);
                    ImGui.Checkbox("Show Hull", ref surShowHull);
                    ImGui.Checkbox("Show Hardpoints", ref surShowHps);
                    ImGui.Separator();
                }
            }
            if (ImGuiExt.Button("Apply Hardpoints", _isDirtyHp))
            {
                if (drawable is ModelFile)
                {
                    hprefs.Nodes[0].HardpointsToNodes(vmsModel.Root.Hardpoints);
                }
                else if (drawable is CmpFile)
                {
                    foreach (var mdl in vmsModel.AllParts)
                    {
                        var node = hprefs.Nodes.First((x) => x.Name == mdl.Path);
                        node.HardpointsToNodes(mdl.Hardpoints);
                    }
                }
                if (_isDirtyHp)
                {
                    _isDirtyHp = false;
                    parent.DirtyCountHp--;
                }
                popups.OpenPopup("Apply Complete");
            }
            if (vmsModel.AllParts.Length > 1 && ImGuiExt.Button("Apply Parts", _isDirtyPart))
            {
                WriteConstructs();
                if (_isDirtyPart)
                {
                    _isDirtyPart = false;
                    parent.DirtyCountPart--;
                }
                popups.OpenPopup("Apply Complete##Parts");
            }
            if (ImGuiExt.ToggleButton("Filter", doFilter))
            {
                doFilter = !doFilter;
            }
            if (doFilter)
            {
                ImGui.InputText("##filter", filterText.Pointer, (uint)filterText.Size, ImGuiInputTextFlags.None, filterText.Callback);
                currentFilter = filterText.GetText();
            }
            else
            {
                currentFilter = null;
            }

            ImGui.Separator();
            if (selectedNode != null)
            {
                ImGui.Text(selectedNode.Construct.ChildName);
                ImGui.Text(selectedNode.Construct.GetType().Name);
                ImGui.Text("Origin: " + selectedNode.Construct.Origin.ToString());
                var euler = selectedNode.Construct.Rotation.GetEuler();
                ImGui.Text(string.Format("Rotation: (Pitch {0:0.000}, Yaw {1:0.000}, Roll {2:0.000})",
                                         MathHelper.RadiansToDegrees(euler.X),
                                         MathHelper.RadiansToDegrees(euler.Y),
                                         MathHelper.RadiansToDegrees(euler.Z)));
                ImGui.Separator();
            }

            if (!vmsModel.Root.Active)
            {
                var col = ImGui.GetStyle().Colors[(int)ImGuiCol.TextDisabled];
                ImGui.PushStyleColor(ImGuiCol.Text, col);
            }
            if (ImGui.TreeNodeEx(ImGuiExt.Pad("Root"), ImGuiTreeNodeFlags.DefaultOpen))
            {
                if (!vmsModel.Root.Active)
                {
                    ImGui.PopStyleColor();
                }
                RootModelContext(vmsModel.Root.Active);
                Theme.RenderTreeIcon("Root", "tree", Color4.DarkGreen);
                if (vmsModel.Root.Children != null)
                {
                    foreach (var n in vmsModel.Root.Children)
                    {
                        DoConstructNode(n);
                    }
                }

                DoModel(vmsModel.Root);
                //if (!(drawable is SphFile)) DoModel(rootModel, null);
                ImGui.TreePop();
            }
            else
            {
                if (!vmsModel.Root.Active)
                {
                    ImGui.PopStyleColor();
                }
                RootModelContext(vmsModel.Root.Active);
                Theme.RenderTreeIcon("Root", "tree", Color4.DarkGreen);
            }
        }
        void SearchWindow()
        {
            ImGui.Text(isSearchInfocards ? "Search Infocards" : "Search Strings");
            searchBuffer.InputText("##searchtext", ImGuiInputTextFlags.None, 200);
            ImGui.Checkbox("Case Sensitive", ref searchCaseSensitive);
            ImGui.Checkbox("Match Whole World", ref searchWholeWord);
            if (ImGui.Button("Go"))
            {
                var str = searchBuffer.GetText();
                if (!string.IsNullOrWhiteSpace(str))
                {
                    resultTitle = ImGuiExt.IDSafe($"Results for '{str}'");
                    dialogState = 1;
                    Regex r;
                    var   regOptions = searchCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase;
                    if (searchWholeWord)
                    {
                        r = new Regex($"\\b{Regex.Escape(str)}\\b", regOptions);
                    }
                    else
                    {
                        r = new Regex(Regex.Escape(str), regOptions);
                    }

                    if (isSearchInfocards)
                    {
                        AsyncManager.RunTask(() =>
                        {
                            var results    = new List <int>();
                            var resStrings = new List <string>();
                            foreach (var kv in manager.AllXml)
                            {
                                if (r.IsMatch(kv.Value))
                                {
                                    results.Add(kv.Key);
                                    resStrings.Add(kv.Value);
                                }
                            }
                            searchResults        = results.ToArray();
                            searchStrings        = resStrings.ToArray();
                            searchStringPreviews = new string[searchStrings.Length];
                            dialogState          = 2;
                        });
                    }
                    else
                    {
                        AsyncManager.RunTask(() =>
                        {
                            var results    = new List <int>();
                            var resStrings = new List <string>();
                            foreach (var kv in manager.AllStrings)
                            {
                                if (r.IsMatch(kv.Value))
                                {
                                    results.Add(kv.Key);
                                    resStrings.Add(kv.Value);
                                }
                            }
                            searchResults = results.ToArray();
                            searchStrings = resStrings.ToArray();
                            dialogState   = 2;
                        });
                    }
                }
            }
            ImGui.SameLine();
            if (ImGui.Button("Cancel"))
            {
                ImGui.CloseCurrentPopup();
            }
        }
        bool Finish(out EditableUtf result)
        {
            result = null;
            var utf = new EditableUtf();
            //Vanity
            var expv = new LUtfNode()
            {
                Name = "Exporter Version", Parent = utf.Root
            };

            expv.Data = System.Text.Encoding.UTF8.GetBytes(EXPORTER_VERSION);
            utf.Root.Children.Add(expv);
            //Apply Material names
            foreach (var mdl in output)
            {
                ApplyMatNames(mdl);
            }
            //Actual stuff
            if (output.Count == 1)
            {
                var modelName = modelNameBuffer.GetText();
                if (string.IsNullOrEmpty(modelName))
                {
                    modelName = modelNameDefault;
                }
                if (output[0].Children.Count == 0)
                {
                    Export3DB(modelName, utf.Root, output[0]);
                }
                else
                {
                    var suffix = (new Random().Next()) + ".3db";
                    var vmslib = new LUtfNode()
                    {
                        Name = "VMeshLibrary", Parent = utf.Root, Children = new List <LUtfNode>()
                    };
                    utf.Root.Children.Add(vmslib);
                    var cmpnd = new LUtfNode()
                    {
                        Name = "Cmpnd", Parent = utf.Root, Children = new List <LUtfNode>()
                    };
                    utf.Root.Children.Add(cmpnd);
                    ExportModels(modelName, utf.Root, suffix, vmslib, output[0]);
                    int            cmpndIndex = 1;
                    FixConstructor fix        = new FixConstructor();
                    cmpnd.Children.Add(CmpndNode(cmpnd, "Root", output[0].Name + suffix, "Root", 0));
                    foreach (var child in output[0].Children)
                    {
                        ProcessConstruct("Root", child, cmpnd, fix, suffix, ref cmpndIndex);
                    }
                    var cons = new LUtfNode()
                    {
                        Name = "Cons", Parent = cmpnd, Children = new List <LUtfNode>()
                    };
                    var trs = new LUtfNode()
                    {
                        Name = "Fix", Parent = cons, Data = fix.GetData()
                    };
                    cons.Children.Add(trs);
                    cmpnd.Children.Add(cons);
                }
                if (generateMaterials)
                {
                    List <string> materials = new List <string>();
                    foreach (var mdl in output)
                    {
                        IterateMaterials(materials, mdl);
                    }
                    var mats = new LUtfNode()
                    {
                        Name = "material library", Parent = utf.Root
                    };
                    mats.Children = new List <LUtfNode>();
                    int i = 0;
                    foreach (var mat in materials)
                    {
                        mats.Children.Add(DefaultMaterialNode(mats, mat, i++));
                    }
                    var txms = new LUtfNode()
                    {
                        Name = "texture library", Parent = utf.Root
                    };
                    txms.Children = new List <LUtfNode>();
                    foreach (var mat in materials)
                    {
                        txms.Children.Add(DefaultTextureNode(txms, mat));
                    }
                    utf.Root.Children.Add(mats);
                    utf.Root.Children.Add(txms);
                }
                result = utf;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #6
0
        unsafe void Popups()
        {
            //StringEditor
            if (stringConfirm)
            {
                ImGui.OpenPopup("Confirm?##stringedit" + Unique);
                stringConfirm = false;
            }
            if (ImGui.BeginPopupModal("Confirm?##stringedit" + Unique, WindowFlags.AlwaysAutoResize))
            {
                ImGui.Text("Data is >255 bytes, string will be truncated. Continue?");
                if (ImGui.Button("Yes"))
                {
                    text.SetBytes(selectedNode.Data, 255);
                    stringEditor = true;
                    ImGui.CloseCurrentPopup();
                }
                ImGui.SameLine();
                if (ImGui.Button("No"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            if (stringEditor)
            {
                ImGui.OpenPopup("String Editor##" + Unique);
                stringEditor = false;
            }
            if (ImGui.BeginPopupModal("String Editor##" + Unique, WindowFlags.AlwaysAutoResize))
            {
                ImGui.Text("String: ");
                ImGui.SameLine();
                ImGui.InputText("", text.Pointer, 255, InputTextFlags.Default, text.Callback);
                if (ImGui.Button("Ok"))
                {
                    selectedNode.Data = text.GetByteArray();
                    ImGui.CloseCurrentPopup();
                }
                ImGui.SameLine();
                if (ImGui.Button("Cancel"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            //Hex Editor
            if (hexEditor)
            {
                ImGui.OpenPopup("HexEditor##" + Unique);
                hexEditor = false;
            }
            if (ImGui.BeginPopupModal("HexEditor##" + Unique))
            {
                ImGui.PushFont(ImGuiHelper.Default);
                int res;
                if ((res = mem.Draw("Hex", hexdata, hexdata.Length, 0)) != 0)
                {
                    if (res == 1)
                    {
                        selectedNode.Data = hexdata;
                    }
                    ImGui.CloseCurrentPopup();
                }
                ImGui.PopFont();
                ImGui.EndPopup();
            }
            //Color Picker
            if (colorPicker)
            {
                ImGui.OpenPopup("Color Picker##" + Unique);
                colorPicker = false;
            }
            if (ImGui.BeginPopupModal("Color Picker##" + Unique, WindowFlags.AlwaysAutoResize))
            {
                bool old4 = pickcolor4;
                ImGui.Checkbox("Alpha?", ref pickcolor4);
                if (old4 != pickcolor4)
                {
                    if (old4 == false)
                    {
                        color4 = new System.Numerics.Vector4(color3.X, color3.Y, color3.Z, 1);
                    }
                    if (old4 == true)
                    {
                        color3 = new System.Numerics.Vector3(color4.X, color4.Y, color4.Z);
                    }
                }
                ImGui.Separator();
                if (pickcolor4)
                {
                    ImGui.ColorPicker4("Color", ref color4, ColorEditFlags.AlphaPreview | ColorEditFlags.AlphaBar);
                }
                else
                {
                    ImGui.ColorPicker3("Color", ref color3);
                }
                ImGui.Separator();
                if (ImGui.Button("Ok"))
                {
                    ImGui.CloseCurrentPopup();
                    if (pickcolor4)
                    {
                        var bytes = new byte[16];
                        fixed(byte *ptr = bytes)
                        {
                            var f = (System.Numerics.Vector4 *)ptr;

                            f[0] = color4;
                        }

                        selectedNode.Data = bytes;
                    }
                    else
                    {
                        var bytes = new byte[12];
                        fixed(byte *ptr = bytes)
                        {
                            var f = (System.Numerics.Vector3 *)ptr;

                            f[0] = color3;
                        }

                        selectedNode.Data = bytes;
                    }
                }
                ImGui.SameLine();
                if (ImGui.Button("Cancel"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            //Float Editor
            if (floatEditor)
            {
                ImGui.OpenPopup("Float Editor##" + Unique);
                floatEditor = false;
            }
            DataEditors.FloatEditor("Float Editor##" + Unique, ref floats, selectedNode);
            if (intEditor)
            {
                ImGui.OpenPopup("Int Editor##" + Unique);
                intEditor = false;
            }
            DataEditors.IntEditor("Int Editor##" + Unique, ref ints, ref intHex, selectedNode);
            //Rename dialog
            if (doRename)
            {
                ImGui.OpenPopup("Rename##" + Unique);
                doRename = false;
            }
            if (ImGui.BeginPopupModal("Rename##" + Unique, WindowFlags.AlwaysAutoResize))
            {
                ImGui.Text("Name: ");
                ImGui.SameLine();
                ImGui.InputText("", text.Pointer, text.Size, InputTextFlags.Default, text.Callback);
                if (ImGui.Button("Ok"))
                {
                    var n = text.GetText().Trim();
                    if (n.Length == 0)
                    {
                        ErrorPopup("Node name cannot be empty");
                    }
                    else
                    {
                        renameNode.Name = text.GetText();
                    }
                    ImGui.CloseCurrentPopup();
                }
                ImGui.SameLine();
                if (ImGui.Button("Cancel"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            //Error
            if (doError)
            {
                ImGui.OpenPopup("Error##" + Unique);
                doError = false;
            }
            if (ImGui.BeginPopupModal("Error##" + Unique, WindowFlags.AlwaysAutoResize))
            {
                ImGui.Text(errorText);
                if (ImGui.Button("Ok"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            //Add
            if (doAdd)
            {
                ImGui.OpenPopup("New Node##" + Unique);
                doAdd = false;
            }
            if (ImGui.BeginPopupModal("New Node##" + Unique, WindowFlags.AlwaysAutoResize))
            {
                ImGui.Text("Name: ");
                ImGui.SameLine();
                ImGui.InputText("", text.Pointer, text.Size, InputTextFlags.Default, text.Callback);
                if (ImGui.Button("Ok"))
                {
                    var node = new LUtfNode()
                    {
                        Name = text.GetText().Trim(), Parent = addParent ?? addNode
                    };
                    if (node.Name.Length == 0)
                    {
                        ErrorPopup("Node name cannot be empty");
                    }
                    else
                    {
                        if (addParent != null)
                        {
                            addParent.Children.Insert(addParent.Children.IndexOf(addNode) + addOffset, node);
                        }
                        else
                        {
                            addNode.Data = null;
                            if (addNode.Children == null)
                            {
                                addNode.Children = new List <LUtfNode>();
                            }
                            addNode.Children.Add(node);
                        }
                        selectedNode = node;
                    }
                    ImGui.CloseCurrentPopup();
                }
                ImGui.SameLine();
                if (ImGui.Button("Cancel"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            //Confirmation
            if (doConfirm)
            {
                ImGui.OpenPopup("Confirm?##generic" + Unique);
                doConfirm = false;
            }
            if (ImGui.BeginPopupModal("Confirm?##generic" + Unique, WindowFlags.AlwaysAutoResize))
            {
                ImGui.Text(confirmText);
                if (ImGui.Button("Yes"))
                {
                    confirmAction();
                    ImGui.CloseCurrentPopup();
                }
                ImGui.SameLine();
                if (ImGui.Button("No"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
        }
Exemple #7
0
 void Popups()
 {
     //Hex Editor
     if (hexEditor)
     {
         ImGui.OpenPopup("HexEditor");
         hexEditor = false;
     }
     if (ImGui.BeginPopupModal("HexEditor"))
     {
         ImGui.PushFont(ImGuiHelper.Default);
         int res;
         if ((res = mem.Draw("Hex", hexdata, hexdata.Length, 0)) != 0)
         {
             if (res == 1)
             {
                 selectedNode.Data = hexdata;
             }
             ImGui.CloseCurrentPopup();
         }
         ImGui.PopFont();
         ImGui.EndPopup();
     }
     //Rename dialog
     if (doRename)
     {
         ImGui.OpenPopup("Rename");
         doRename = false;
     }
     if (ImGui.BeginPopupModal("Rename", WindowFlags.AlwaysAutoResize))
     {
         ImGui.Text("Name: ");
         ImGui.SameLine();
         ImGui.InputText("", text.Pointer, text.Size, InputTextFlags.Default, text.Callback);
         if (ImGui.Button("Ok"))
         {
             renameNode.Name = text.GetText();
             ImGui.CloseCurrentPopup();
         }
         ImGui.SameLine();
         if (ImGui.Button("Cancel"))
         {
             ImGui.CloseCurrentPopup();
         }
         ImGui.EndPopup();
     }
     //Delete dialog
     if (doDelete)
     {
         ImGui.OpenPopup("Delete");
         doDelete = false;
     }
     if (ImGui.BeginPopupModal("Delete", WindowFlags.AlwaysAutoResize))
     {
         ImGui.Text("Are you sure you want to delete: '" + deleteNode.Name + "'?");
         if (ImGui.Button("Ok"))
         {
             deleteParent.Children.Remove(deleteNode);
             ImGui.CloseCurrentPopup();
         }
         ImGui.SameLine();
         if (ImGui.Button("Cancel"))
         {
             ImGui.CloseCurrentPopup();
         }
         ImGui.EndPopup();
     }
 }
Exemple #8
0
        unsafe void Popups()
        {
            //Hex Editor
            if (hexEditor)
            {
                ImGui.OpenPopup("HexEditor##" + Unique);
                hexEditor = false;
            }
            if (ImGui.BeginPopupModal("HexEditor##" + Unique))
            {
                ImGui.PushFont(ImGuiHelper.Default);
                int res;
                if ((res = mem.Draw("Hex", hexdata, hexdata.Length, 0)) != 0)
                {
                    if (res == 1)
                    {
                        selectedNode.Data = hexdata;
                    }
                    ImGui.CloseCurrentPopup();
                }
                ImGui.PopFont();
                ImGui.EndPopup();
            }
            //Color Picker
            if (colorPicker)
            {
                ImGui.OpenPopup("Color Picker##" + Unique);
                colorPicker = false;
            }
            if (ImGui.BeginPopupModal("Color Picker##" + Unique, WindowFlags.AlwaysAutoResize))
            {
                bool old4 = pickcolor4;
                ImGui.Checkbox("Alpha?", ref pickcolor4);
                if (old4 != pickcolor4)
                {
                    if (old4 == false)
                    {
                        color4 = new System.Numerics.Vector4(color3.X, color3.Y, color3.Z, 1);
                    }
                    if (old4 == true)
                    {
                        color3 = new System.Numerics.Vector3(color4.X, color4.Y, color4.Z);
                    }
                }
                ImGui.Separator();
                if (pickcolor4)
                {
                    ImGui.ColorPicker4("Color", ref color4, ColorEditFlags.AlphaPreview | ColorEditFlags.AlphaBar);
                }
                else
                {
                    ImGui.ColorPicker3("Color", ref color3);
                }
                ImGui.Separator();
                if (ImGui.Button("Ok"))
                {
                    ImGui.CloseCurrentPopup();
                    if (pickcolor4)
                    {
                        var bytes = new byte[16];
                        fixed(byte *ptr = bytes)
                        {
                            var f = (System.Numerics.Vector4 *)ptr;

                            f[0] = color4;
                        }

                        selectedNode.Data = bytes;
                    }
                    else
                    {
                        var bytes = new byte[12];
                        fixed(byte *ptr = bytes)
                        {
                            var f = (System.Numerics.Vector3 *)ptr;

                            f[0] = color3;
                        }

                        selectedNode.Data = bytes;
                    }
                }
                ImGui.SameLine();
                if (ImGui.Button("Cancel"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            //Float Editor
            if (floatEditor)
            {
                ImGui.OpenPopup("Float Editor##" + Unique);
                floatEditor = false;
            }
            DataEditors.FloatEditor("Float Editor##" + Unique, ref floats, selectedNode);
            if (intEditor)
            {
                ImGui.OpenPopup("Int Editor##" + Unique);
                intEditor = false;
            }
            DataEditors.IntEditor("Int Editor##" + Unique, ref ints, ref intHex, selectedNode);
            //Rename dialog
            if (doRename)
            {
                ImGui.OpenPopup("Rename##" + Unique);
                doRename = false;
            }
            if (ImGui.BeginPopupModal("Rename##" + Unique, WindowFlags.AlwaysAutoResize))
            {
                ImGui.Text("Name: ");
                ImGui.SameLine();
                ImGui.InputText("", text.Pointer, text.Size, InputTextFlags.Default, text.Callback);
                if (ImGui.Button("Ok"))
                {
                    renameNode.Name = text.GetText();
                    ImGui.CloseCurrentPopup();
                }
                ImGui.SameLine();
                if (ImGui.Button("Cancel"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            //Delete dialog
            if (doDelete)
            {
                ImGui.OpenPopup("Delete##" + Unique);
                doDelete = false;
            }
            if (ImGui.BeginPopupModal("Delete##" + Unique, WindowFlags.AlwaysAutoResize))
            {
                ImGui.Text("Are you sure you want to delete: '" + deleteNode.Name + "'?");
                if (ImGui.Button("Ok"))
                {
                    deleteParent.Children.Remove(deleteNode);
                    ImGui.CloseCurrentPopup();
                }
                ImGui.SameLine();
                if (ImGui.Button("Cancel"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            //Error
            if (doError)
            {
                ImGui.OpenPopup("Error##" + Unique);
                doError = false;
            }
            if (ImGui.BeginPopupModal("Error##" + Unique, WindowFlags.AlwaysAutoResize))
            {
                ImGui.Text(errorText);
                if (ImGui.Button("Ok"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
        }
Exemple #9
0
        void HierachyPanel()
        {
            if (!(drawable is DF.DfmFile) && !(drawable is SphFile))
            {
                //Sur
                if (ImGui.Button("Open Sur"))
                {
                    var file = FileDialog.Open(SurFilters);
                    surname = System.IO.Path.GetFileName(file);
                    LibreLancer.Physics.Sur.SurFile sur;
                    try
                    {
                        using (var f = System.IO.File.OpenRead(file))
                        {
                            sur = new LibreLancer.Physics.Sur.SurFile(f);
                        }
                    }
                    catch (Exception)
                    {
                        sur = null;
                    }
                    if (sur != null)
                    {
                        ProcessSur(sur);
                    }
                }
                if (surs != null)
                {
                    ImGui.Separator();
                    ImGui.Text("Sur: " + surname);
                    ImGui.Checkbox("Show Hull", ref surShowHull);
                    ImGui.Checkbox("Show Hardpoints", ref surShowHps);
                    ImGui.Separator();
                }
            }
            if (ImGui.Button("Apply Hardpoints"))
            {
                if (drawable is CmpFile)
                {
                    var cmp = (CmpFile)drawable;
                    foreach (var kv in cmp.Models)
                    {
                        var node = hprefs.Nodes.Where((x) => x.Name == kv.Key).First();
                        node.HardpointsToNodes(kv.Value.Hardpoints);
                    }
                }
                else if (drawable is ModelFile)
                {
                    hprefs.Nodes[0].HardpointsToNodes(((ModelFile)drawable).Hardpoints);
                }
                popups.OpenPopup("Apply Complete");
            }
            if ((drawable is CmpFile) && ((CmpFile)drawable).Parts.Count > 1 && ImGui.Button("Apply Parts"))
            {
                WriteConstructs();
                popups.OpenPopup("Apply Complete##Parts");
            }
            if (ImGuiExt.ToggleButton("Filter", doFilter))
            {
                doFilter = !doFilter;
            }
            if (doFilter)
            {
                ImGui.InputText("##filter", filterText.Pointer, (uint)filterText.Size, ImGuiInputTextFlags.None, filterText.Callback);
                currentFilter = filterText.GetText();
            }
            else
            {
                currentFilter = null;
            }

            ImGui.Separator();
            if (selectedNode != null)
            {
                ImGui.Text(selectedNode.Con.ChildName);
                ImGui.Text(selectedNode.Con.GetType().Name);
                ImGui.Text("Origin: " + selectedNode.Con.Origin.ToString());
                var euler = selectedNode.Con.Rotation.GetEuler();
                ImGui.Text(string.Format("Rotation: (Pitch {0:0.000}, Yaw {1:0.000}, Roll {2:0.000})",
                                         MathHelper.RadiansToDegrees(euler.X),
                                         MathHelper.RadiansToDegrees(euler.Y),
                                         MathHelper.RadiansToDegrees(euler.Z)));
                ImGui.Separator();
            }
            if (ImGui.TreeNodeEx(ImGuiExt.Pad("Root"), ImGuiTreeNodeFlags.DefaultOpen))
            {
                Theme.RenderTreeIcon("Root", "tree", Color4.DarkGreen);
                foreach (var n in cons)
                {
                    DoConstructNode(n);
                }
                if (!(drawable is SphFile))
                {
                    DoModel(rootModel, null);
                }
                ImGui.TreePop();
            }
            else
            {
                Theme.RenderTreeIcon("Root", "tree", Color4.DarkGreen);
            }
        }