Exemplo n.º 1
0
        unsafe void NodeInformation()
        {
            ImGui.BeginChild("##scrollnode");
            ImGui.Text("Name: " + selectedNode.Name);
            if (selectedNode.Children != null)
            {
                ImGui.Text(selectedNode.Children.Count + " children");
                if (selectedNode != Utf.Root)
                {
                    ImGui.Separator();
                    ImGui.Text("Actions:");
                    if (ImGui.Button("Add Data"))
                    {
                        Confirm("Adding data will delete this node's children. Continue?", () =>
                        {
                            selectedNode.Children = null;
                            selectedNode.Data     = new byte[0];
                        });
                    }
                    if (ImGui.Button("Import Data"))
                    {
                        ImGui.OpenPopup("importactions");
                    }
                    if (ImGui.BeginPopup("importactions"))
                    {
                        if (ImGui.MenuItem("File"))
                        {
                            Confirm("Importing data will delete this node's children. Continue?", () =>
                            {
                                string path;
                                if ((path = FileDialog.Open()) != null)
                                {
                                    selectedNode.Children = null;
                                    selectedNode.Data     = File.ReadAllBytes(path);
                                }
                            });
                        }
                        if (ImGui.MenuItem("Texture"))
                        {
                            Confirm("Importing data will delete this node's children. Continue?", () =>
                            {
                                ImportTexture();
                            });
                        }
                        ImGui.EndPopup();
                    }

                    if (selectedNode.Name.StartsWith("joint map", StringComparison.OrdinalIgnoreCase))
                    {
                        if (ImGui.Button("View Joint Map"))
                        {
                            JointMapView jmv;
                            if ((jmv = JointMapView.Create(selectedNode)) != null)
                            {
                                jointViews.Add(jmv);
                            }
                        }
                        ;
                    }

                    if (selectedNode.Name.StartsWith("object map", StringComparison.OrdinalIgnoreCase))
                    {
                        if (ImGui.Button("View Object Map"))
                        {
                            JointMapView jmv;
                            if ((jmv = JointMapView.Create(selectedNode)) != null)
                            {
                                jointViews.Add(jmv);
                            }
                        }
                        ;
                    }
                }
            }
            else if (selectedNode.Data != null)
            {
                ImGui.Text(string.Format("Size: {0}", LibreLancer.DebugDrawing.SizeSuffix(selectedNode.Data.Length)));
                ImGui.Separator();
                if (selectedNode.Data.Length > 0)
                {
                    ImGui.Text("Previews:");
                    //String Preview
                    ImGui.Text("String:");
                    ImGui.SameLine();
                    ImGui.InputText("##strpreview", selectedNode.Data, (uint)Math.Min(selectedNode.Data.Length, 32), ImGuiInputTextFlags.ReadOnly, DummyCallback);
                    //Float Preview
                    ImGui.Text("Float:");
                    fixed(byte *ptr = selectedNode.Data)
                    {
                        for (int i = 0; i < 4 && (i < selectedNode.Data.Length / 4); i++)
                        {
                            ImGui.SameLine();
                            ImGui.Text(((float *)ptr)[i].ToString());
                        }
                    }

                    //Int Preview
                    ImGui.Text("Int:");
                    fixed(byte *ptr = selectedNode.Data)
                    {
                        for (int i = 0; i < 4 && (i < selectedNode.Data.Length / 4); i++)
                        {
                            ImGui.SameLine();
                            ImGui.Text(((int *)ptr)[i].ToString());
                        }
                    }
                }
                else
                {
                    ImGui.Text("Empty Data");
                }
                ImGui.Separator();
                ImGui.Text("Actions:");
                if (ImGui.Button("Edit"))
                {
                    ImGui.OpenPopup("editactions");
                }
                if (ImGui.BeginPopup("editactions"))
                {
                    if (ImGui.MenuItem("String Editor"))
                    {
                        if (selectedNode.Data.Length > 255)
                        {
                            popups.OpenPopup("Confirm?##stringedit");
                        }
                        else
                        {
                            text.SetBytes(selectedNode.Data, selectedNode.Data.Length);
                            popups.OpenPopup("String Editor");
                        }
                    }
                    if (ImGui.MenuItem("Hex Editor"))
                    {
                        hexdata = new byte[selectedNode.Data.Length];
                        selectedNode.Data.CopyTo(hexdata, 0);
                        mem = new MemoryEditor();
                        popups.OpenPopup("Hex Editor");
                    }
                    if (ImGui.MenuItem("Float Editor"))
                    {
                        floats = new float[selectedNode.Data.Length / 4];
                        for (int i = 0; i < selectedNode.Data.Length / 4; i++)
                        {
                            floats[i] = BitConverter.ToSingle(selectedNode.Data, i * 4);
                        }
                        floatEditor = true;
                    }
                    if (ImGui.MenuItem("Int Editor"))
                    {
                        ints = new int[selectedNode.Data.Length / 4];
                        for (int i = 0; i < selectedNode.Data.Length / 4; i++)
                        {
                            ints[i] = BitConverter.ToInt32(selectedNode.Data, i * 4);
                        }
                        intEditor = true;
                    }
                    if (ImGui.MenuItem("Color Picker"))
                    {
                        var len = selectedNode.Data.Length / 4;
                        if (len < 3)
                        {
                            pickcolor4 = true;
                            color4     = Color4.Black;
                        }
                        else if (len == 3)
                        {
                            pickcolor4 = false;
                            color3     = new Vector3(
                                BitConverter.ToSingle(selectedNode.Data, 0),
                                BitConverter.ToSingle(selectedNode.Data, 4),
                                BitConverter.ToSingle(selectedNode.Data, 8));
                        }
                        else if (len > 3)
                        {
                            pickcolor4 = true;
                            color4     = new Vector4(
                                BitConverter.ToSingle(selectedNode.Data, 0),
                                BitConverter.ToSingle(selectedNode.Data, 4),
                                BitConverter.ToSingle(selectedNode.Data, 8),
                                BitConverter.ToSingle(selectedNode.Data, 12));
                        }
                        popups.OpenPopup("Color Picker");
                    }
                    ImGui.EndPopup();
                }
                ImGui.NextColumn();
                if (ImGui.Button("Texture Viewer"))
                {
                    Texture tex = null;
                    try
                    {
                        using (var stream = new MemoryStream(selectedNode.Data))
                        {
                            tex = LibreLancer.ImageLib.Generic.FromStream(stream);
                        }
                        var title = string.Format("{0} ({1})", selectedNode.Name, Title);
                        if (tex is Texture2D tex2d)
                        {
                            var tab = new TextureViewer(title, tex2d, null);
                            main.AddTab(tab);
                        }
                        else if (tex is TextureCube texcube)
                        {
                            var tab = new CubemapViewer(title, texcube, main);
                            main.AddTab(tab);
                        }
                    }
                    catch (Exception ex)
                    {
                        #if DEBUG
                        throw;
                        #else
                        ErrorPopup("Node data couldn't be opened as texture:\n" + ex.Message);
                        #endif
                    }
                }
                if (ImGui.Button("Play Audio"))
                {
                    var data = main.Audio.AllocateData();
                    using (var stream = new MemoryStream(selectedNode.Data))
                    {
                        main.Audio.PlayStream(stream);
                    }
                }
                if (ImGui.Button("Import Data"))
                {
                    ImGui.OpenPopup("importactions");
                }
                if (ImGui.BeginPopup("importactions"))
                {
                    if (ImGui.MenuItem("File"))
                    {
                        string path;
                        if ((path = FileDialog.Open()) != null)
                        {
                            selectedNode.Data = File.ReadAllBytes(path);
                        }
                    }
                    if (ImGui.MenuItem("Texture"))
                    {
                        ImportTexture();
                    }
                    ImGui.EndPopup();
                }
                if (ImGui.Button("Export Data"))
                {
                    if (selectedNode.Name.ToLowerInvariant() == "vmeshdata")
                    {
                        ImGui.OpenPopup("exportactions");
                    }
                    else
                    {
                        string path;
                        if ((path = FileDialog.Save()) != null)
                        {
                            File.WriteAllBytes(path, selectedNode.Data);
                        }
                    }
                }
                if (ImGui.BeginPopup("exportactions"))
                {
                    if (ImGui.MenuItem("Raw"))
                    {
                        string path;
                        if ((path = FileDialog.Save()) != null)
                        {
                            File.WriteAllBytes(path, selectedNode.Data);
                        }
                    }
                    if (ImGui.MenuItem("VMeshData"))
                    {
                        string path;
                        if ((path = FileDialog.Save()) != null)
                        {
                            LibreLancer.Utf.Vms.VMeshData dat = null;
                            try
                            {
                                dat = new LibreLancer.Utf.Vms.VMeshData(new ArraySegment <byte>(selectedNode.Data), new EmptyLib(), "");
                            }
                            catch (Exception ex)
                            {
                                ErrorPopup(string.Format("Not a valid VMeshData node\n{0}\n{1}", ex.Message, ex.StackTrace));
                            }
                            if (dat != null)
                            {
                                DumpObject.DumpVmeshData(path, dat);
                            }
                        }
                    }
                    ImGui.EndPopup();
                }
            }
            else
            {
                ImGui.Text("Empty");
                ImGui.Separator();
                ImGui.Text("Actions:");
                if (ImGui.Button("Add Data"))
                {
                    selectedNode.Data = new byte[0];
                }
                if (ImGui.Button("Import Data"))
                {
                    ImGui.OpenPopup("importactions");
                }
                if (ImGui.BeginPopup("importactions"))
                {
                    if (ImGui.MenuItem("File"))
                    {
                        string path;
                        if ((path = FileDialog.Open()) != null)
                        {
                            selectedNode.Data = File.ReadAllBytes(path);
                        }
                    }
                    if (ImGui.MenuItem("Texture"))
                    {
                        ImportTexture();
                    }
                    ImGui.EndPopup();
                }
            }

            var removeJmv = new List <JointMapView>();
            foreach (var jm in jointViews)
            {
                if (!jm.Draw())
                {
                    removeJmv.Add(jm);
                }
            }
            foreach (var jmv in removeJmv)
            {
                jointViews.Remove(jmv);
            }
            ImGui.EndChild();
        }
Exemplo n.º 2
0
        void DoModel(RigidModelPart part)
        {
            //Hardpoints
            bool open = ImGui.TreeNode(ImGuiExt.Pad("Hardpoints"));
            var  act  = NewHpMenu(part.Path);

            switch (act)
            {
            case ContextActions.NewFixed:
            case ContextActions.NewRevolute:
                newIsFixed = act == ContextActions.NewFixed;
                addTo      = part;
                newHpBuffer.Clear();
                popups.OpenPopup("New Hardpoint");
                break;
            }
            Theme.RenderTreeIcon("Hardpoints", "hardpoint", Color4.CornflowerBlue);
            if (open)
            {
                List <Action> addActions = new List <Action>();
                foreach (var hp in part.Hardpoints)
                {
                    if (doFilter)
                    {
                        if (hp.Name.IndexOf(currentFilter, StringComparison.OrdinalIgnoreCase) == -1)
                        {
                            continue;
                        }
                    }
                    HardpointGizmo gz = null;
                    foreach (var gizmo in gizmos)
                    {
                        if (gizmo.Hardpoint == hp)
                        {
                            gz = gizmo;
                            break;
                        }
                    }
                    if (hp.Definition is RevoluteHardpointDefinition)
                    {
                        Theme.Icon("rev", Color4.LightSeaGreen);
                    }
                    else
                    {
                        Theme.Icon("fix", Color4.Purple);
                    }
                    ImGui.SameLine();
                    if (Theme.IconButton("visible$" + hp.Name, "eye", gz.Enabled ? Color4.White : Color4.Gray))
                    {
                        gz.Enabled = !gz.Enabled;
                    }
                    ImGui.SameLine();
                    ImGui.Selectable(ImGuiExt.IDSafe(hp.Name));
                    var action = EditDeleteHpMenu(part.Path + hp.Name);
                    if (action == ContextActions.Delete)
                    {
                        hpDelete     = hp;
                        hpDeleteFrom = part.Hardpoints;
                        popups.OpenPopup("Confirm Delete");
                    }
                    if (action == ContextActions.Edit)
                    {
                        hpEditing = hp;
                    }
                    if (action == ContextActions.MirrorX)
                    {
                        var newHp = MakeDuplicate(GetDupName(hp.Name), hp);
                        //do mirroring
                        newHp.Definition.Position.X   = -newHp.Definition.Position.X;
                        newHp.Definition.Orientation *= new Matrix4x4(
                            -1, 0, 0, 0,
                            0, 1, 0, 0,
                            0, 0, 1, 0,
                            0, 0, 0, 1
                            );
                        //add
                        addActions.Add(() =>
                        {
                            part.Hardpoints.Add(newHp);
                            gizmos.Add(new HardpointGizmo(newHp, gz.Parent));
                            OnDirtyHp();
                        });
                    }
                    if (action == ContextActions.MirrorY)
                    {
                        var newHp = MakeDuplicate(GetDupName(hp.Name), hp);
                        //do mirroring
                        newHp.Definition.Position.Y   = -newHp.Definition.Position.Y;
                        newHp.Definition.Orientation *= new Matrix4x4(
                            1, 0, 0, 0,
                            0, -1, 0, 0,
                            0, 0, 1, 0,
                            0, 0, 0, 1
                            );
                        //add
                        addActions.Add(() =>
                        {
                            part.Hardpoints.Add(newHp);
                            gizmos.Add(new HardpointGizmo(newHp, gz.Parent));
                            OnDirtyHp();
                        });
                    }
                    if (action == ContextActions.MirrorZ)
                    {
                        var newHp = MakeDuplicate(GetDupName(hp.Name), hp);
                        //do mirroring
                        newHp.Definition.Position.Z   = -newHp.Definition.Position.Z;
                        newHp.Definition.Orientation *= new Matrix4x4(
                            1, 0, 0, 0,
                            0, 1, 0, 0,
                            0, 0, -1, 0,
                            0, 0, 0, 1
                            );
                        //add
                        addActions.Add(() =>
                        {
                            part.Hardpoints.Add(newHp);
                            gizmos.Add(new HardpointGizmo(newHp, gz.Parent));
                            OnDirtyHp();
                        });
                    }
                }
                foreach (var action in addActions)
                {
                    action();
                }
                ImGui.TreePop();
            }
        }
Exemplo n.º 3
0
        void DoModel(RigidModelPart part)
        {
            //Hardpoints
            bool open = Theme.IconTreeNode(Icons.Hardpoints, "Hardpoints");
            var  act  = NewHpMenu(part.Path);

            switch (act)
            {
            case ContextActions.NewFixed:
            case ContextActions.NewRevolute:
                newIsFixed = act == ContextActions.NewFixed;
                addTo      = part;
                newHpBuffer.Clear();
                popups.OpenPopup("New Hardpoint");
                break;
            }
            if (open)
            {
                List <Action> addActions = new List <Action>();
                foreach (var hp in part.Hardpoints)
                {
                    if (doFilter)
                    {
                        if (hp.Name.IndexOf(currentFilter, StringComparison.OrdinalIgnoreCase) == -1)
                        {
                            continue;
                        }
                    }
                    HardpointGizmo gz = null;
                    foreach (var gizmo in gizmos)
                    {
                        if (gizmo.Hardpoint == hp)
                        {
                            gz = gizmo;
                            break;
                        }
                    }

                    if (gz == null)
                    {
                        throw new Exception("gizmo for hp not exist");
                    }
                    if (hp.Definition is RevoluteHardpointDefinition)
                    {
                        ImGui.Text(Icons.Rev_LightSeaGreen.ToString());
                    }
                    else
                    {
                        ImGui.Text(Icons.Cube_Purple.ToString());
                    }
                    ImGui.SameLine();
                    ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, new Vector2(0));
                    ImGui.PushID("visible$" + hp.Name);
                    var push = !gz.Enabled;
                    if (push)
                    {
                        ImGui.PushStyleColor(ImGuiCol.Text, (uint)Color4.Gray.ToAbgr());
                    }
                    if (ImGui.Button(Icons.Eye.ToString()))
                    {
                        gz.Enabled = !gz.Enabled;
                    }
                    if (push)
                    {
                        ImGui.PopStyleColor();
                    }
                    ImGui.PopID();
                    ImGui.PopStyleVar(1);
                    ImGui.SameLine();
                    ImGui.Selectable(ImGuiExt.IDSafe(hp.Name));
                    var action = EditDeleteHpMenu(part.Path + hp.Name);
                    if (action == ContextActions.Delete)
                    {
                        hpDelete     = hp;
                        hpDeleteFrom = part.Hardpoints;
                        popups.OpenPopup("Confirm Delete");
                    }
                    if (action == ContextActions.Edit)
                    {
                        hpEditing = hp;
                    }
                    if (action == ContextActions.MirrorX)
                    {
                        var newHp = MakeDuplicate(GetDupName(hp.Name), hp);
                        //do mirroring
                        newHp.Definition.Position.X   = -newHp.Definition.Position.X;
                        newHp.Definition.Orientation *= new Matrix4x4(
                            -1, 0, 0, 0,
                            0, 1, 0, 0,
                            0, 0, 1, 0,
                            0, 0, 0, 1
                            );
                        //add
                        addActions.Add(() =>
                        {
                            part.Hardpoints.Add(newHp);
                            gizmos.Add(new HardpointGizmo(newHp, gz.Parent));
                            OnDirtyHp();
                        });
                    }
                    if (action == ContextActions.MirrorY)
                    {
                        var newHp = MakeDuplicate(GetDupName(hp.Name), hp);
                        //do mirroring
                        newHp.Definition.Position.Y   = -newHp.Definition.Position.Y;
                        newHp.Definition.Orientation *= new Matrix4x4(
                            1, 0, 0, 0,
                            0, -1, 0, 0,
                            0, 0, 1, 0,
                            0, 0, 0, 1
                            );
                        //add
                        addActions.Add(() =>
                        {
                            part.Hardpoints.Add(newHp);
                            gizmos.Add(new HardpointGizmo(newHp, gz.Parent));
                            OnDirtyHp();
                        });
                    }
                    if (action == ContextActions.MirrorZ)
                    {
                        var newHp = MakeDuplicate(GetDupName(hp.Name), hp);
                        //do mirroring
                        newHp.Definition.Position.Z   = -newHp.Definition.Position.Z;
                        newHp.Definition.Orientation *= new Matrix4x4(
                            1, 0, 0, 0,
                            0, 1, 0, 0,
                            0, 0, -1, 0,
                            0, 0, 0, 1
                            );
                        //add
                        addActions.Add(() =>
                        {
                            part.Hardpoints.Add(newHp);
                            gizmos.Add(new HardpointGizmo(newHp, gz.Parent));
                            OnDirtyHp();
                        });
                    }
                }
                foreach (var action in addActions)
                {
                    action();
                }
                ImGui.TreePop();
            }
        }
Exemplo n.º 4
0
        void DoModel(ModelFile mdl, AbstractConstruct con)
        {
            //Hardpoints
            bool open = ImGui.TreeNode(ImGuiExt.Pad("Hardpoints"));
            var  act  = NewHpMenu(mdl.Path);

            switch (act)
            {
            case ContextActions.NewFixed:
            case ContextActions.NewRevolute:
                newIsFixed   = act == ContextActions.NewFixed;
                addTo        = mdl.Hardpoints;
                addConstruct = con;
                newHpBuffer.Clear();
                popups.OpenPopup("New Hardpoint");
                break;
            }
            Theme.RenderTreeIcon("Hardpoints", "hardpoint", Color4.CornflowerBlue);
            if (open)
            {
                foreach (var hp in mdl.Hardpoints)
                {
                    if (doFilter)
                    {
                        if (hp.Name.IndexOf(currentFilter, StringComparison.OrdinalIgnoreCase) == -1)
                        {
                            continue;
                        }
                    }
                    HardpointGizmo gz = null;
                    foreach (var gizmo in gizmos)
                    {
                        if (gizmo.Definition == hp)
                        {
                            gz = gizmo;
                            break;
                        }
                    }
                    if (hp is RevoluteHardpointDefinition)
                    {
                        Theme.Icon("rev", Color4.LightSeaGreen);
                    }
                    else
                    {
                        Theme.Icon("fix", Color4.Purple);
                    }
                    ImGui.SameLine();
                    if (Theme.IconButton("visible$" + hp.Name, "eye", gz.Enabled ? Color4.White : Color4.Gray))
                    {
                        gz.Enabled = !gz.Enabled;
                    }
                    ImGui.SameLine();
                    ImGui.Selectable(hp.Name);
                    var action = EditDeleteHpMenu(mdl.Path + hp.Name);
                    if (action == ContextActions.Delete)
                    {
                        hpDelete     = hp;
                        hpDeleteFrom = mdl.Hardpoints;
                        popups.OpenPopup("Confirm Delete");
                    }
                    if (action == ContextActions.Edit)
                    {
                        hpEditing = hp;
                    }
                }
                ImGui.TreePop();
            }
        }
Exemplo n.º 5
0
        unsafe void NodeInformation()
        {
            ImGui.BeginChild("##scrollnode", false, 0);
            ImGui.Text("Name: " + selectedNode.Name);
            if (selectedNode.Children != null)
            {
                ImGui.Text(selectedNode.Children.Count + " children");
                if (selectedNode != Utf.Root)
                {
                    ImGui.Separator();
                    ImGui.Text("Actions:");
                    if (ImGui.Button("Add Data"))
                    {
                        Confirm("Adding data will delete this node's children. Continue?", () =>
                        {
                            selectedNode.Children = null;
                            selectedNode.Data     = new byte[0];
                        });
                    }
                    if (ImGui.Button("Import Data"))
                    {
                        ImGui.OpenPopup("importactions");
                    }
                    if (ImGui.BeginPopup("importactions"))
                    {
                        if (ImGui.MenuItem("File"))
                        {
                            Confirm("Importing data will delete this node's children. Continue?", () =>
                            {
                                string path;
                                if ((path = FileDialog.Open()) != null)
                                {
                                    selectedNode.Children = null;
                                    selectedNode.Data     = File.ReadAllBytes(path);
                                }
                            });
                        }
                        if (ImGui.MenuItem("Texture"))
                        {
                            Confirm("Importing data will delete this node's children. Continue?", () =>
                            {
                                ImportTexture();
                            });
                        }
                        ImGui.EndPopup();
                    }
                }
            }
            else if (selectedNode.Data != null)
            {
                ImGui.Text(string.Format("Size: {0}", LibreLancer.DebugDrawing.SizeSuffix(selectedNode.Data.Length)));
                ImGui.Separator();
                if (selectedNode.Data.Length > 0)
                {
                    ImGui.Text("Previews:");
                    //String Preview
                    ImGui.Text("String:");
                    ImGui.SameLine();
                    ImGui.InputText("", selectedNode.Data, (uint)Math.Min(selectedNode.Data.Length, 32), InputTextFlags.ReadOnly, DummyCallback);
                    //Float Preview
                    ImGui.Text("Float:");
                    fixed(byte *ptr = selectedNode.Data)
                    {
                        for (int i = 0; i < 4 && (i < selectedNode.Data.Length / 4); i++)
                        {
                            ImGui.SameLine();
                            ImGui.Text(((float *)ptr)[i].ToString());
                        }
                    }

                    //Int Preview
                    ImGui.Text("Int:");
                    fixed(byte *ptr = selectedNode.Data)
                    {
                        for (int i = 0; i < 4 && (i < selectedNode.Data.Length / 4); i++)
                        {
                            ImGui.SameLine();
                            ImGui.Text(((int *)ptr)[i].ToString());
                        }
                    }
                }
                else
                {
                    ImGui.Text("Empty Data");
                }
                ImGui.Separator();
                ImGui.Text("Actions:");
                if (ImGui.Button("Edit"))
                {
                    ImGui.OpenPopup("editactions");
                }
                if (ImGui.BeginPopup("editactions"))
                {
                    if (ImGui.MenuItem("String Editor"))
                    {
                        if (selectedNode.Data.Length > 255)
                        {
                            popups.OpenPopup("Confirm?##stringedit");
                        }
                        else
                        {
                            text.SetBytes(selectedNode.Data, selectedNode.Data.Length);
                            popups.OpenPopup("String Editor");
                        }
                    }
                    if (ImGui.MenuItem("Hex Editor"))
                    {
                        hexdata = new byte[selectedNode.Data.Length];
                        selectedNode.Data.CopyTo(hexdata, 0);
                        mem = new MemoryEditor();
                        popups.OpenPopup("Hex Editor");
                    }
                    if (ImGui.MenuItem("Float Editor"))
                    {
                        floats = new float[selectedNode.Data.Length / 4];
                        for (int i = 0; i < selectedNode.Data.Length / 4; i++)
                        {
                            floats[i] = BitConverter.ToSingle(selectedNode.Data, i * 4);
                        }
                        floatEditor = true;
                    }
                    if (ImGui.MenuItem("Int Editor"))
                    {
                        ints = new int[selectedNode.Data.Length / 4];
                        for (int i = 0; i < selectedNode.Data.Length / 4; i++)
                        {
                            ints[i] = BitConverter.ToInt32(selectedNode.Data, i * 4);
                        }
                        intEditor = true;
                    }
                    if (ImGui.MenuItem("Color Picker"))
                    {
                        var len = selectedNode.Data.Length / 4;
                        if (len < 3)
                        {
                            pickcolor4 = true;
                            color4     = new System.Numerics.Vector4(0, 0, 0, 1);
                        }
                        else if (len == 3)
                        {
                            pickcolor4 = false;
                            color3     = new System.Numerics.Vector3(
                                BitConverter.ToSingle(selectedNode.Data, 0),
                                BitConverter.ToSingle(selectedNode.Data, 4),
                                BitConverter.ToSingle(selectedNode.Data, 8));
                        }
                        else if (len > 3)
                        {
                            pickcolor4 = true;
                            color4     = new System.Numerics.Vector4(
                                BitConverter.ToSingle(selectedNode.Data, 0),
                                BitConverter.ToSingle(selectedNode.Data, 4),
                                BitConverter.ToSingle(selectedNode.Data, 8),
                                BitConverter.ToSingle(selectedNode.Data, 12));
                        }
                        popups.OpenPopup("Color Picker");
                    }
                    ImGui.EndPopup();
                }
                ImGui.NextColumn();
                if (ImGui.Button("Texture Viewer"))
                {
                    Texture2D tex = null;
                    try
                    {
                        using (var stream = new MemoryStream(selectedNode.Data))
                        {
                            tex = LibreLancer.ImageLib.Generic.FromStream(stream);
                        }
                        var title = string.Format("{0} ({1})", selectedNode.Name, Title);
                        var tab   = new TextureViewer(title, tex);
                        main.AddTab(tab);
                    }
                    catch (Exception)
                    {
                        ErrorPopup("Node data couldn't be opened as texture");
                    }
                }
                if (ImGui.Button("Play Audio"))
                {
                    var data = main.Audio.AllocateData();
                    using (var stream = new MemoryStream(selectedNode.Data))
                    {
                        main.Audio.PlaySound(stream);
                    }
                }
                if (ImGui.Button("Import Data"))
                {
                    ImGui.OpenPopup("importactions");
                }
                if (ImGui.BeginPopup("importactions"))
                {
                    if (ImGui.MenuItem("File"))
                    {
                        string path;
                        if ((path = FileDialog.Open()) != null)
                        {
                            selectedNode.Data = File.ReadAllBytes(path);
                        }
                    }
                    if (ImGui.MenuItem("Texture"))
                    {
                        ImportTexture();
                    }
                    ImGui.EndPopup();
                }
                if (ImGui.Button("Export Data"))
                {
                    if (selectedNode.Name.ToLowerInvariant() == "vmeshdata")
                    {
                        ImGui.OpenPopup("exportactions");
                    }
                    else
                    {
                        string path;
                        if ((path = FileDialog.Save()) != null)
                        {
                            File.WriteAllBytes(path, selectedNode.Data);
                        }
                    }
                }
                if (ImGui.BeginPopup("exportactions"))
                {
                    if (ImGui.MenuItem("Raw"))
                    {
                        string path;
                        if ((path = FileDialog.Save()) != null)
                        {
                            File.WriteAllBytes(path, selectedNode.Data);
                        }
                    }
                    if (ImGui.MenuItem("VMeshData"))
                    {
                        string path;
                        if ((path = FileDialog.Save()) != null)
                        {
                            LibreLancer.Utf.Vms.VMeshData dat = null;
                            try
                            {
                                dat = new LibreLancer.Utf.Vms.VMeshData(selectedNode.Data, new EmptyLib(), "");
                            }
                            catch (Exception ex)
                            {
                                ErrorPopup(string.Format("Not a valid VMeshData node\n{0}\n{1}", ex.Message, ex.StackTrace));
                            }
                            if (dat != null)
                            {
                                DumpObject.DumpVmeshData(path, dat);
                            }
                        }
                    }
                    ImGui.EndPopup();
                }
            }
            else
            {
                ImGui.Text("Empty");
                ImGui.Separator();
                ImGui.Text("Actions:");
                if (ImGui.Button("Add Data"))
                {
                    selectedNode.Data = new byte[0];
                }
                if (ImGui.Button("Import Data"))
                {
                    ImGui.OpenPopup("importactions");
                }
                if (ImGui.BeginPopup("importactions"))
                {
                    if (ImGui.MenuItem("File"))
                    {
                        string path;
                        if ((path = FileDialog.Open()) != null)
                        {
                            selectedNode.Data = File.ReadAllBytes(path);
                        }
                    }
                    if (ImGui.MenuItem("Texture"))
                    {
                        ImportTexture();
                    }
                    ImGui.EndPopup();
                }
            }
            ImGui.EndChild();
        }