public override bool Draw() { if (ImGuiExt.BeginDock(Title + "##" + Unique, ref open, 0)) { var renderWidth = Math.Max(120, (int)ImGui.GetWindowWidth() - 5); var renderHeight = Math.Max(120, (int)ImGui.GetWindowHeight() - 40); //Generate render target if (rh != renderHeight || rw != renderWidth) { if (renderTarget != null) { ImGuiHelper.DeregisterTexture(renderTarget); renderTarget.Dispose(); } renderTarget = new RenderTarget2D(renderWidth, renderHeight); rid = ImGuiHelper.RegisterTexture(renderTarget); rw = renderWidth; rh = renderHeight; } DrawGL(renderWidth, renderHeight); //Draw Image ImGui.Image((IntPtr)rid, new Vector2(renderWidth, renderHeight), Vector2.Zero, Vector2.One, Vector4.One, Vector4.One); } ImGuiExt.EndDock(); return(open); }
public override bool Draw() { if (ImGuiExt.BeginDock(Title + "##" + Unique, ref open, 0)) { /*if (HasChild(Utf.Root, "ALEffectLib") && * HasChild(Utf.Root, "AlchemyNodeLibrary")) * { * if (ImGui.Button("Open ALE")) * { * * } * } */ //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("/"); DoNodeMenu("/", Utf.Root, null); ImGui.PopID(); if (isOpen) { int i = 0; foreach (var node in Utf.Root.Children) { DoNode(node, Utf.Root, i++); } ImGui.TreePop(); } ImGui.EndChild(); //End Tree if (selectedNode != null) { //Node preview ImGui.NextColumn(); NodeInformation(); } } ImGuiExt.EndDock(); Popups(); return(open); }
public override bool Draw() { if (ImGuiExt.BeginDock(Title + "##" + Unique, ref open, 0)) { ImGui.Text("Zoom: "); ImGui.SameLine(); ImGui.SliderFloat("", ref zoom, 10, 800, "%.0f%%", 1); ImGui.SameLine(); ImGui.Checkbox("Checkerboard", ref checkerboard); ImGui.Separator(); var w = ImGui.GetContentRegionAvailableWidth(); zoom = (int)zoom; var scale = zoom / 100; var sz = new Vector2(tex.Width, tex.Height) * scale; ImGuiNative.igSetNextWindowContentSize(new Vector2(sz.X, 0)); ImGui.BeginChild("##scroll", false, WindowFlags.HorizontalScrollbar); var pos = ImGui.GetCursorScreenPos(); var windowH = ImGui.GetWindowHeight(); var windowW = ImGui.GetWindowWidth(); if (checkerboard) { unsafe { var lst = ImGuiNative.igGetWindowDrawList(); ImGuiNative.ImDrawList_AddImage(lst, (void *)ImGuiHelper.CheckerboardId, pos, new Vector2(pos.X + windowW, pos.Y + windowH), new Vector2(0, 0), new Vector2(windowW / 16, windowH / 16), uint.MaxValue); } } if (sz.Y < windowH) //Centre { ImGui.Dummy(5, (windowH / 2) - (sz.Y / 2)); } if (sz.X < w) { ImGui.Dummy((w / 2) - (sz.X / 2), 5); ImGui.SameLine(); } ImGui.Image((IntPtr)tid, sz, Vector2.Zero, new Vector2(1, 1), new Vector4(1, 1, 1, 1), new Vector4(0, 0, 0, 0)); ImGui.EndChild(); } ImGuiExt.EndDock(); return(open); }
public override bool Draw() { if (ImGuiExt.BeginDock("Resources###" + Unique, ref open, WindowFlags.HorizontalScrollbar)) { if (res.TextureDictionary.Count + res.MaterialDictionary.Count > 0) { ImGui.Text("Loaded:"); var tcolor = (Vector4)ImGui.GetStyle().GetColor(ColorTarget.Text); foreach (var t in res.TextureDictionary) { var col = new Vector4(0.6f, 0.6f, 0.6f, 1f); foreach (var tex in referencedTex) { if (t.Key.Equals(tex, StringComparison.InvariantCultureIgnoreCase)) { col = tcolor; break; } } ImGui.Text("Texture: " + t.Key, col); } foreach (var m in res.MaterialDictionary) { var col = referencedMats.Contains(m.Key) ? tcolor : new Vector4(0.6f, 0.6f, 0.6f, 1f); ImGui.Text(string.Format("Material: {0} (0x{1:X})", m.Value.Name, m.Key), col); } } else { ImGui.Text("Loaded: None"); } if (missing.Count > 0) { ImGui.Separator(); ImGui.Text("Missing:"); foreach (var ln in missing) { ImGui.Text(string.Format("{0} (Ref {1})", ln.Missing, ln.Reference), new Vector4(1, 0, 0, 1)); } } } ImGuiExt.EndDock(); return(open); }
public override bool Draw() { if (ImGuiExt.BeginDock(Title + "###" + Unique, ref open, 0)) { ImGui.Text("View Mode:"); ImGui.SameLine(); ImGui.Combo("##modes", ref viewMode, viewModes); ImGui.SameLine(); ImGui.Checkbox("Wireframe", ref doWireframe); var renderWidth = Math.Max(120, (int)ImGui.GetWindowWidth() - 15); var renderHeight = Math.Max(120, (int)ImGui.GetWindowHeight() - 70); //Generate render target if (rh != renderHeight || rw != renderWidth) { if (renderTarget != null) { ImGuiHelper.DeregisterTexture(renderTarget); renderTarget.Dispose(); } renderTarget = new RenderTarget2D(renderWidth, renderHeight); rid = ImGuiHelper.RegisterTexture(renderTarget); rw = renderWidth; rh = renderHeight; } DrawGL(renderWidth, renderHeight); //Draw Image //ImGui.Image((IntPtr)rid, new Vector2(renderWidth, renderHeight), Vector2.Zero, Vector2.One, Vector4.One, Vector4.One); ImGui.ImageButton((IntPtr)rid, new Vector2(renderWidth, renderHeight), Vector2.Zero, Vector2.One, 0, Vector4.One, Vector4.One); if (ImGui.IsItemHovered(HoveredFlags.Default)) { if (ImGui.IsMouseDragging(0, 1f)) { var delta = (Vector2)ImGui.GetMouseDragDelta(0, 1f); rotation -= (delta / 64); ImGui.ResetMouseDragDelta(0); } } } ImGuiExt.EndDock(); return(open); }
public override bool Draw() { if (ImGuiExt.BeginDock(Title + "###" + Unique, ref open, 0)) { //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; SelectedChanged(); } 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 (" + Title + ")", Title, drawable, main.RenderState, main.Viewport, main.Commands, main.Resources)); } } 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(); } } ImGuiExt.EndDock(); Popups(); return(open); }
public override bool Draw() { if (ImGuiExt.BeginDock(Title + "###" + Unique, ref open, 0)) { //Fx management lastEffect = currentEffect; ImGui.Text("Effect:"); ImGui.SameLine(); ImGui.Combo("##effect", ref currentEffect, effectNames); if (currentEffect != lastEffect) { SetupRender(currentEffect); } ImGui.SameLine(); ImGui.Button("+"); ImGui.SameLine(); ImGui.Button("-"); ImGui.Separator(); //Layout ImGui.Columns(2, "##alecolumns", true); ImGui.Text("Viewport"); ImGui.NextColumn(); ImGui.Text("Hierachy"); ImGui.Separator(); ImGui.NextColumn(); ImGui.BeginChild("##renderchild"); //Viewport Rendering var renderWidth = Math.Max(120, (int)ImGui.GetWindowWidth() - 15); var renderHeight = Math.Max(120, (int)ImGui.GetWindowHeight() - 70); //Generate render target if (rh != renderHeight || rw != renderWidth) { if (renderTarget != null) { ImGuiHelper.DeregisterTexture(renderTarget); renderTarget.Dispose(); } renderTarget = new RenderTarget2D(renderWidth, renderHeight); rid = ImGuiHelper.RegisterTexture(renderTarget); rw = renderWidth; rh = renderHeight; } DrawGL(renderWidth, renderHeight); //Display + Camera controls ImGui.ImageButton((IntPtr)rid, new Vector2(renderWidth, renderHeight), Vector2.Zero, Vector2.One, 0, Vector4.One, Vector4.One); if (ImGui.IsItemHovered(HoveredFlags.Default)) { if (ImGui.IsMouseDragging(0, 1f)) { var delta = (Vector2)ImGui.GetMouseDragDelta(0, 1f); rotation -= (delta / 64); ImGui.ResetMouseDragDelta(0); } float wheel = ImGui.GetIO().MouseWheel; if (ImGui.GetIO().ShiftPressed) { zoom -= wheel * 15; } else { zoom -= wheel * 45; } } //Action Bar if (ImGui.Button("Actions")) { ImGui.OpenPopup("actions"); } if (ImGui.BeginPopup("actions")) { if (ImGui.MenuItem("Open Node Library")) { } ImGui.EndPopup(); } ImGui.SameLine(); if (ImGui.Button("Reset")) { instance.Reset(); } ImGui.SameLine(); ImGui.Text(string.Format("T: {0:0.000}", instance.GlobalTime)); //Node Hierachy Tab ImGui.EndChild(); ImGui.NextColumn(); ImGui.BeginChild("##nodesdisplay", false); if (selectedReference != null) { NodeOptions(); ImGui.Separator(); } ImGui.BeginChild("##nodescroll", false); NodeHierachy(); ImGui.EndChild(); ImGui.EndChild(); } ImGuiExt.EndDock(); return(open); }