void PickObject(PopupData data) { ImGui.Combo("Object", ref dumpindex, dumpoptions); if (ImGui.Button("Ok")) { var output = FileDialog.Save(); if (output != null) { if (dumpindex == 0) { DumpStatus(DumpObject.DumpObj(dumpcmp, output)); } else { var mdl = dumpcmp.Models[dumpoptions[dumpindex]]; DumpStatus(DumpObject.DumpObj(mdl, output)); } ImGui.CloseCurrentPopup(); } } ImGui.SameLine(); if (ImGui.Button("Cancel")) { ImGui.CloseCurrentPopup(); } }
public override bool Draw() { //Child Window var size = ImGui.GetWindowSize(); ImGui.BeginChild("##utfchild", new Vector2(size.X - 15, size.Y - 50), false, 0); //Layout if (selectedNode != null) { ImGui.Columns(2, "NodeColumns", true); } //Headers ImGui.Separator(); ImGui.Text("Nodes"); if (selectedNode != null) { ImGui.NextColumn(); ImGui.Text("Node Information"); ImGui.NextColumn(); } ImGui.Separator(); //Tree ImGui.BeginChild("##scroll", false, 0); var flags = selectedNode == Utf.Root ? TreeNodeFlags.Selected | tflags : tflags; var isOpen = ImGui.TreeNodeEx("/", flags); if (ImGuiNative.igIsItemClicked(0)) { selectedNode = Utf.Root; } ImGui.PushID("/##ROOT"); DoNodeMenu("/##ROOT", Utf.Root, null); ImGui.PopID(); if (isOpen) { for (int i = 0; i < Utf.Root.Children.Count; i++) { DoNode(Utf.Root.Children[i], Utf.Root, i); } ImGui.TreePop(); } ImGui.EndChild(); //End Tree if (selectedNode != null) { //Node preview ImGui.NextColumn(); NodeInformation(); } //Action Bar ImGui.EndChild(); ImGui.Separator(); if (ImGui.Button("Actions")) { ImGui.OpenPopup("actions"); } if (ImGui.BeginPopup("actions")) { if (ImGui.MenuItem("View Model")) { IDrawable drawable = null; try { drawable = LibreLancer.Utf.UtfLoader.GetDrawable(Utf.Export(), main.Resources); drawable.Initialize(main.Resources); } catch (Exception) { ErrorPopup("Could not open as model"); drawable = null; } if (drawable != null) { main.AddTab(new ModelViewer("Model Viewer (" + DocumentName + ")", DocumentName, drawable, main, this)); } } if (ImGui.MenuItem("Dump Model")) { LibreLancer.Utf.Cmp.ModelFile model = null; LibreLancer.Utf.Cmp.CmpFile cmp = null; try { var drawable = LibreLancer.Utf.UtfLoader.GetDrawable(Utf.Export(), main.Resources); model = (drawable as LibreLancer.Utf.Cmp.ModelFile); cmp = (drawable as LibreLancer.Utf.Cmp.CmpFile); } catch (Exception) { ErrorPopup("Could not open as model"); model = null; } if (model != null) { var output = FileDialog.Save(); if (output != null) { DumpStatus(DumpObject.DumpObj(model, output)); } } if (cmp != null) { dumpcmp = cmp; DoPickObject(); } } if (ImGui.MenuItem("View Ale")) { AleFile ale = null; try { ale = new AleFile(Utf.Export()); } catch (Exception) { ErrorPopup("Could not open as ale"); ale = null; } if (ale != null) { main.AddTab(new AleViewer("Ale Viewer (" + Title + ")", Title, ale, main)); } } if (ImGui.MenuItem("Refresh Resources")) { main.Resources.RemoveResourcesForId(Unique.ToString()); main.Resources.AddResources(Utf.Export(), Unique.ToString()); } ImGui.EndPopup(); } Popups(); return(open); }