コード例 #1
0
ファイル: ColladaTab.cs プロジェクト: sodomon2/Librelancer
 void FLTree(OutModel mdl, ref int i)
 {
     var flags = ImGuiTreeNodeFlags.OpenOnDoubleClick |
                                  ImGuiTreeNodeFlags.DefaultOpen |
                                  ImGuiTreeNodeFlags.OpenOnArrow;
     if (mdl == selected) flags |= ImGuiTreeNodeFlags.Selected;
     var open = ImGui.TreeNodeEx(ImGuiExt.Pad(mdl.Name + "##" + i++), flags);
     if(ImGui.IsItemClicked(0)) {
         selected = mdl;
     }
     ImGui.SameLine();
     Theme.RenderTreeIcon(mdl.Name,"fix", Color4.LightPink);
     if(open)
     {
         if(ImGui.TreeNode("LODs")) {
             for (int j = 0; j < mdl.LODs.Count; j++)
                 ImGui.Selectable(string.Format("{0}: {1}", j, mdl.LODs[j].Name));
             ImGui.TreePop();
         }
         foreach (var child in mdl.Children)
             FLTree(child, ref i);
         ImGui.TreePop();
     }
     i += 500;
 }
コード例 #2
0
ファイル: ColladaTab.cs プロジェクト: TRBlount/Librelancer
        void FLTree(OutModel mdl, ref int i)
        {
            var flags = TreeNodeFlags.OpenOnDoubleClick |
                        TreeNodeFlags.DefaultOpen |
                        TreeNodeFlags.OpenOnArrow;
            //if (obj == selected) flags |= TreeNodeFlags.Selected;
            var open = ImGui.TreeNodeEx(ImGuiExt.Pad(mdl.Name + "##" + i++), flags);

            //if (ImGuiNative.igIsItemClicked(0))
            //selected = obj;
            //ColladaContextMenu();
            Theme.RenderTreeIcon(mdl.Name, "fix", Color4.White);
            if (open)
            {
                if (ImGui.TreeNode("LODs"))
                {
                    for (int j = 0; j < mdl.LODs.Count; j++)
                    {
                        ImGui.Selectable(string.Format("{0}: {1}", j, mdl.LODs[j].Name));
                    }
                    ImGui.TreePop();
                }
                foreach (var child in mdl.Children)
                {
                    FLTree(child, ref i);
                }
                ImGui.TreePop();
            }
            i += 500;
        }
コード例 #3
0
 void SearchDialog()
 {
     if (doOpenSearch)
     {
         ImGui.OpenPopup(ImGuiExt.IDWithExtra("Search", Unique));
         doOpenSearch      = false;
         searchDlgOpen     = true;
         searchResultsOpen = false;
     }
     if (searchResultsOpen)
     {
         SearchResults();
     }
     if (ImGui.BeginPopupModal(ImGuiExt.IDWithExtra("Search", Unique), ref searchDlgOpen, ImGuiWindowFlags.AlwaysAutoResize))
     {
         if (dialogState == 0)
         {
             SearchWindow();
         }
         else if (dialogState == 1)
         {
             SearchStatus();
         }
         else
         {
             searchResultsOpen = true;
             ImGui.CloseCurrentPopup();
         }
         ImGui.EndPopup();
     }
 }
コード例 #4
0
 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);
 }
コード例 #5
0
 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);
 }
コード例 #6
0
        void AnimationPanel()
        {
            var anm = ((CmpFile)drawable).Animation;
            int j   = 0;

            foreach (var sc in anm.Scripts)
            {
                var popup = $"{sc.Key}$Popup{j}";
                if (ImGui.Button(ImGuiExt.IDWithExtra(sc.Key, j++)))
                {
                    animator.StartAnimation(sc.Key, false);
                }
                if (ImGui.IsItemClicked(1))
                {
                    ImGui.OpenPopup(popup);
                }
                if (ImGui.BeginPopupContextItem(popup))
                {
                    if (ImGui.MenuItem("Copy Nickname"))
                    {
                        _window.SetClipboardText(sc.Key);
                    }
                    ImGui.EndPopup();
                }
            }
            ImGui.Separator();
            if (ImGui.Button("Reset"))
            {
                animator.ResetAnimations();
            }
        }
コード例 #7
0
ファイル: ModelViewer.cs プロジェクト: lyzardiar/Librelancer
        void DoConstructNode(ConstructNode cn)
        {
            var n      = string.Format("{0} ({1})", cn.Con.ChildName, ConType(cn.Con));
            var tflags = ImGuiTreeNodeFlags.OpenOnArrow | ImGuiTreeNodeFlags.OpenOnDoubleClick;

            if (selectedNode == cn)
            {
                tflags |= ImGuiTreeNodeFlags.Selected;
            }
            var icon  = "fix";
            var color = Color4.LightYellow;

            if (cn.Con is PrisConstruct)
            {
                icon  = "pris";
                color = Color4.LightPink;
            }
            if (cn.Con is SphereConstruct)
            {
                icon  = "sphere";
                color = Color4.LightGreen;
            }
            if (cn.Con is RevConstruct)
            {
                icon  = "rev";
                color = Color4.LightCoral;
            }
            if (ImGui.TreeNodeEx(ImGuiExt.Pad(n), tflags))
            {
                if (ImGui.IsItemClicked(0))
                {
                    selectedNode = cn;
                }
                ConstructContext(cn);
                Theme.RenderTreeIcon(n, icon, color);
                foreach (var child in cn.Nodes)
                {
                    DoConstructNode(child);
                }
                if (cn.Camera != null)
                {
                    DoCamera(cn.Camera, cn.Con);
                }
                else
                {
                    DoModel(cn.Model, cn.Con);
                }
                ImGui.TreePop();
            }
            else
            {
                if (ImGui.IsItemClicked(0))
                {
                    selectedNode = cn;
                }
                ConstructContext(cn);
                Theme.RenderTreeIcon(n, icon, color);
            }
        }
コード例 #8
0
ファイル: ColladaTab.cs プロジェクト: TRBlount/Librelancer
        void ColladaPane()
        {
            var totalH = ImGui.GetWindowHeight();

            ImGuiExt.SplitterV(2f, ref collada_h1, ref collada_h2, 8, 8, -1);
            collada_h1 = totalH - collada_h2 - 6f;
            ImGui.BeginChild("1", new Vector2(-1, collada_h1), false, WindowFlags.Default);
            ImGui.Separator();
            if (ImGui.TreeNode("Scene/"))
            {
                int i = 0;
                foreach (var obj in objs)
                {
                    ColladaTree(obj, ref i);
                }
                ImGui.TreePop();
            }
            CheckSelected();
            ImGui.EndChild();
            ImGui.BeginChild("2", new Vector2(-1, collada_h2), false, WindowFlags.Default);
            //Preview+Properties
            if (selected == null)
            {
                ImGui.Text("No node selected");
            }
            else
            {
                if (selected.Geometry != null)
                {
                    if (ImGuiExt.ToggleButton("Preview", colladaPreview))
                    {
                        colladaPreview = true;
                    }
                    ImGui.SameLine();
                    if (ImGuiExt.ToggleButton("Details", !colladaPreview))
                    {
                        colladaPreview = false;
                    }
                    ImGui.Separator();
                    if (colladaPreview)
                    {
                        ImGui.BeginChild("##colladapreview");
                        Render();
                        ImGui.EndChild();
                    }
                    else
                    {
                        ColladaDetails();
                    }
                }
                else
                {
                    ColladaDetails();
                }
            }
            //
            ImGui.EndChild();
        }
コード例 #9
0
        public ImGuiHelper(Game game)
        {
            this.game                = game;
            game.Keyboard.KeyDown   += Keyboard_KeyDown;
            game.Keyboard.KeyUp     += Keyboard_KeyUp;
            game.Keyboard.TextInput += Keyboard_TextInput;
            SetKeyMappings();
            var io = ImGui.GetIO();

            unsafe
            {
                io.GetNativePointer()->IniFilename = IntPtr.Zero;
            }
            Default = io.FontAtlas.AddDefaultFont();
            using (var stream = typeof(ImGuiHelper).Assembly.GetManifestResourceStream("LancerEdit.UILib.Roboto-Medium.ttf"))
            {
                var ttf = new byte[stream.Length];
                stream.Read(ttf, 0, ttf.Length);
                ttfPtr = Marshal.AllocHGlobal(ttf.Length);
                Marshal.Copy(ttf, 0, ttfPtr, ttf.Length);
                Noto = io.FontAtlas.AddFontFromMemoryTTF(ttfPtr, ttf.Length, 15);
            }
            using (var stream = typeof(ImGuiHelper).Assembly.GetManifestResourceStream("LancerEdit.UILib.checkerboard.png"))
            {
                checkerboard   = LibreLancer.ImageLib.Generic.FromStream(stream);
                CheckerboardId = RegisterTexture(checkerboard);
            }
            using (var stream = typeof(ImGuiHelper).Assembly.GetManifestResourceStream("LancerEdit.UILib.circle.png"))
            {
                circle   = LibreLancer.ImageLib.Generic.FromStream(stream);
                CircleId = RegisterTexture(circle);
            }
            unsafe
            {
                ImGuiExt.BuildFontAtlas((IntPtr)ImGuiNative.igGetIO()->FontAtlas);
            }
            FontTextureData texData = io.FontAtlas.GetTexDataAsAlpha8();

            fontTexture = new Texture2D(texData.Width, texData.Height, false, SurfaceFormat.R8);
            var bytes = new byte[texData.Width * texData.Height * texData.BytesPerPixel];

            unsafe
            {
                Marshal.Copy((IntPtr)texData.Pixels, bytes, 0, texData.Width * texData.Height * texData.BytesPerPixel);
            }
            fontTexture.SetData(bytes);
            fontTexture.SetFiltering(TextureFiltering.Linear);
            io.FontAtlas.SetTexID(FONT_TEXTURE_ID);
            io.FontAtlas.ClearTexData();
            textShader  = new Shader(vertex_source, text_fragment_source);
            colorShader = new Shader(vertex_source, color_fragment_source);
            dot         = new Texture2D(1, 1, false, SurfaceFormat.Color);
            var c = new Color4b[] { Color4b.White };

            dot.SetData(c);
            Theme.Apply();
        }
コード例 #10
0
ファイル: UtfTab.cs プロジェクト: Regenhardt/Librelancer
        void DoNode(LUtfNode node, LUtfNode parent, int idx)
        {
            string id = ImGuiExt.IDWithExtra(node.Name, parent.Name + idx);

            if (node.Children != null)
            {
                var flags  = selectedNode == node ? ImGuiTreeNodeFlags.Selected | tflags : tflags;
                var isOpen = ImGui.TreeNodeEx(id, flags);
                if (ImGui.IsItemClicked(0))
                {
                    selectedNode = node;
                }
                if (node.ResolvedName != null)
                {
                    ImGui.SameLine();
                    ImGui.TextDisabled("(" + ImGuiExt.IDSafe(node.ResolvedName) + ")");
                }
                ImGui.PushID(id);
                DoNodeMenu(id, node, parent);
                ImGui.PopID();
                //int i = 0;
                if (isOpen)
                {
                    for (int i = 0; i < node.Children.Count; i++)
                    {
                        DoNode(node.Children[i], node, (idx * 1024) + i);
                    }
                    ImGui.TreePop();
                }
            }
            else
            {
                if (node.Data != null)
                {
                    ImGui.Bullet();
                }
                else
                {
                    ImGui.Text($"  {Icons.BulletEmpty}");
                    ImGui.SameLine();
                }
                bool selected = selectedNode == node;
                if (ImGui.Selectable(id, ref selected))
                {
                    selectedNode = node;
                }
                if (node.ResolvedName != null)
                {
                    ImGui.SameLine();
                    ImGui.TextDisabled("(" + ImGuiExt.IDSafe(node.ResolvedName) + ")");
                }
                DoNodeMenu(id, node, parent);
            }
        }
コード例 #11
0
ファイル: ColladaTab.cs プロジェクト: youndoldman/Librelancer
        void FLPane()
        {
            var totalH = ImGui.GetWindowHeight();

            ImGuiExt.SplitterV(2f, ref fl_h1, ref fl_h2, 8, 8, -1);
            fl_h1 = totalH - fl_h2 - 6f;
            ImGui.BeginChild("1", new Vector2(-1, fl_h1), false, ImGuiWindowFlags.None);
            ImGui.Separator();
            //3DB list
            if (ImGui.TreeNodeEx("Model/"))
            {
                int i = 0;
                foreach (var mdl in output)
                {
                    FLTree(mdl, ref i);
                }
            }
            ImGui.EndChild();
            ImGui.BeginChild("2", new Vector2(-1, fl_h2), false, ImGuiWindowFlags.None);
            if (ImGuiExt.ToggleButton("Options", curTab == 0))
            {
                curTab = 0;
            }
            ImGui.SameLine();
            if (ImGuiExt.ToggleButton("Materials", curTab == 1))
            {
                curTab = 1;
            }
            ImGui.Separator();
            switch (curTab)
            {
            case 0:     //OPTIONS
                ImGui.AlignTextToFramePadding();
                ImGui.Text("Model Name:");
                ImGui.SameLine();
                modelNameBuffer.InputText("##mdlname", ImGuiInputTextFlags.None);
                ImGui.Checkbox("Generate Materials", ref generateMaterials);
                break;

            case 1:     //MATERIALS
                if (selected == null)
                {
                    ImGui.Text("No object selected");
                }
                else
                {
                    MatNameEdit();
                }
                break;
            }
            ImGui.EndChild();
        }
コード例 #12
0
 void DoModel(ModelFile mdl)
 {
     if (mdl.Hardpoints.Count > 0)
     {
         if (ImGui.TreeNode(ImGuiExt.Pad("Hardpoints")))
         {
             Theme.RenderTreeIcon("Hardpoints", "hardpoint", Color4.CornflowerBlue);
             foreach (var hp in mdl.Hardpoints)
             {
                 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.Text(hp.Name);
             }
             ImGui.TreePop();
         }
         else
         {
             Theme.RenderTreeIcon("Hardpoints", "hardpoint", Color4.CornflowerBlue);
         }
     }
     else
     {
         Theme.Icon("hardpoint", Color4.CornflowerBlue);
         ImGui.SameLine();
         ImGui.Text("Hardpoints");
     }
 }
コード例 #13
0
        public override void Draw()
        {
            ImGui.BeginTabBar("##tabs");
            int idx = typeIndex;

            ImGui.Combo("Type", ref typeIndex, typeNames, typeNames.Length);
            if (idx != typeIndex)
            {
                RecreateCurve();
            }
            if (ImGui.BeginTabItem("Points"))
            {
                ImGui.InputFloat4("Point", ref p);
                if (ImGui.Button("Add"))
                {
                    points.Add(p);
                    p = Vector4.Zero;
                    RecreateCurve();
                }

                ImGui.SameLine();
                if (ImGui.Button("Clear"))
                {
                    points.Clear();
                    RecreateCurve();
                }
                var height = ImGui.GetWindowHeight() - 110;
                ImGui.BeginChild("##points", new Vector2(-1, height), true);
                int ik = 0;
                foreach (var p in points)
                {
                    ImGui.Selectable(ImGuiExt.IDWithExtra(p.ToString(), ik++));
                }
                ImGui.EndChild();


                ImGui.EndTabItem();
            }

            if (ImGui.BeginTabItem("Graph"))
            {
                var gWidth  = ImGui.GetWindowContentRegionWidth() - 40;
                var gHeight = ImGui.GetWindowHeight() - 60;
                ImGui.PlotLines("##graph", ref values[0], values.Length, 0, "", scaleMin, scaleMax, new Vector2(gWidth, gHeight));
                ImGui.EndTabItem();
            }
            ImGui.EndTabBar();
        }
コード例 #14
0
ファイル: TextureViewer.cs プロジェクト: Giperion/Librelancer
 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);
 }
コード例 #15
0
 void SearchResults()
 {
     ImGui.Begin(ImGuiExt.IDWithExtra("Search", Unique), ref searchResultsOpen, ImGuiWindowFlags.AlwaysAutoResize);
     ImGui.Text(resultTitle);
     ImGui.BeginChild("##results", new Vector2(200, 200), true);
     for (int i = 0; i < searchResults.Length; i++)
     {
         if (ImGui.Selectable(searchResults[i].ToString()))
         {
             id = searchResults[i];
             if (isSearchInfocards)
             {
                 GotoInfocard();
             }
             else
             {
                 GotoString();
             }
             ImGui.CloseCurrentPopup();
         }
         if (ImGui.IsItemHovered())
         {
             if (isSearchInfocards)
             {
                 if (searchStringPreviews[i] == null)
                 {
                     try
                     {
                         searchStringPreviews[i] =
                             EllipseIfNeeded(RDLParse.Parse(searchStrings[i], fonts).ExtractText());
                     }
                     catch (Exception)
                     {
                         searchStringPreviews[i] = EllipseIfNeeded(searchStrings[i]);
                     }
                 }
                 ImGui.SetTooltip(searchStringPreviews[i]);
             }
             else
             {
                 ImGui.SetTooltip(EllipseIfNeeded(searchStrings[i]));
             }
         }
     }
     ImGui.EndChild();
     ImGui.End();
 }
コード例 #16
0
        void DoNode(NodeReference reference, int idx, Vector4 enabled, Vector4 disabled)
        {
            var    col   = instance.NodeEnabled(reference) ? enabled : disabled;
            string label = null;

            if (reference.IsAttachmentNode)
            {
                label = string.Format("Attachment##{0}", idx);
            }
            else
            {
                label = string.Format("{0}##{1}", reference.Node.NodeName, idx);
            }
            ImGui.PushStyleColor(ImGuiCol.Text, col);
            string icon;
            Color4 color;

            NodeIcon(reference.Node, out icon, out color);
            if (reference.Children.Count > 0)
            {
                if (ImGui.TreeNodeEx(ImGuiExt.Pad(label), ImGuiTreeNodeFlags.OpenOnDoubleClick | ImGuiTreeNodeFlags.OpenOnArrow))
                {
                    Theme.RenderTreeIcon(label.Split('#')[0], icon, color);
                    int j = 0;
                    foreach (var child in reference.Children)
                    {
                        DoNode(child, j++, enabled, disabled);
                    }
                    ImGui.TreePop();
                }
                else
                {
                    Theme.RenderTreeIcon(label.Split('#')[0], icon, color);
                }
            }
            else
            {
                Theme.Icon(icon, color);
                ImGui.SameLine();

                if (ImGui.Selectable(label, selectedReference == reference))
                {
                    selectedReference = reference;
                }
            }
            ImGui.PopStyleColor();
        }
コード例 #17
0
 void HierachyPanel()
 {
     if (!(drawable is SphFile))
     {
         ImGui.Text("Level of Detail");
         ImGui.Checkbox("Use Distance", ref useDistance);
         if (useDistance)
         {
             ImGui.SliderFloat("Distance", ref levelDistance, 0, maxDistance, "%f", 1);
         }
         else
         {
             ImGui.Combo("Level", ref level, levels);
         }
         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"), TreeNodeFlags.DefaultOpen))
     {
         Theme.RenderTreeIcon("Root", "tree", Color4.DarkGreen);
         foreach (var n in cons)
         {
             DoConstructNode(n);
         }
         if (!(drawable is SphFile))
         {
             DoModel(rootModel);
         }
         ImGui.TreePop();
     }
     else
     {
         Theme.RenderTreeIcon("Root", "tree", Color4.DarkGreen);
     }
 }
コード例 #18
0
        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);
        }
コード例 #19
0
        void AnimationPanel()
        {
            var anm = ((CmpFile)drawable).Animation;
            int j   = 0;

            foreach (var sc in anm.Scripts)
            {
                if (ImGui.Button(ImGuiExt.IDWithExtra(sc.Key, j++)))
                {
                    animator.StartAnimation(sc.Key, false);
                }
            }
            ImGui.Separator();
            if (ImGui.Button("Reset"))
            {
                animator.ResetAnimations();
            }
        }
コード例 #20
0
 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);
 }
コード例 #21
0
ファイル: UtfTab.cs プロジェクト: fenzy/Librelancer
        void DoNode(LUtfNode node, LUtfNode parent, int idx)
        {
            string id = ImGuiExt.IDWithExtra(node.Name, parent.Name + idx);

            if (node.Children != null)
            {
                var flags  = selectedNode == node ? ImGuiTreeNodeFlags.Selected | tflags : tflags;
                var isOpen = ImGui.TreeNodeEx(id, flags);
                if (ImGui.IsItemClicked(0))
                {
                    selectedNode = node;
                }
                ImGui.PushID(id);
                DoNodeMenu(id, node, parent);
                ImGui.PopID();
                //int i = 0;
                if (isOpen)
                {
                    for (int i = 0; i < node.Children.Count; i++)
                    {
                        DoNode(node.Children[i], node, (idx * 1024) + i);
                    }
                    ImGui.TreePop();
                }
            }
            else
            {
                if (node.Data != null)
                {
                    ImGui.Bullet();
                }
                else
                {
                    Theme.Icon("node_empty", Color4.White);
                    ImGui.SameLine();
                }
                bool selected = selectedNode == node;
                if (ImGui.Selectable(id, ref selected))
                {
                    selectedNode = node;
                }
                DoNodeMenu(id, node, parent);
            }
        }
コード例 #22
0
ファイル: ColladaTab.cs プロジェクト: TRBlount/Librelancer
        void ColladaTree(ColladaObject obj, ref int i)
        {
            string tree_icon = "dummy";

            if (obj.Geometry != null)
            {
                tree_icon = "fix";
            }
            if (obj.Children.Count > 0)
            {
                var flags = TreeNodeFlags.OpenOnDoubleClick |
                            TreeNodeFlags.DefaultOpen |
                            TreeNodeFlags.OpenOnArrow;
                if (obj == selected)
                {
                    flags |= TreeNodeFlags.Selected;
                }
                var open = ImGui.TreeNodeEx(ImGuiExt.Pad(obj.Name + "##" + i++), flags);
                if (ImGuiNative.igIsItemClicked(0))
                {
                    selected = obj;
                }
                ColladaContextMenu();
                Theme.RenderTreeIcon(obj.Name, tree_icon, Color4.White);
                if (open)
                {
                    foreach (var child in obj.Children)
                    {
                        ColladaTree(child, ref i);
                    }
                    ImGui.TreePop();
                }
                i += 500;
            }
            else
            {
                if (ImGui.Selectable(ImGuiExt.Pad(obj.Name + "##" + i++), obj == selected))
                {
                    selected = obj;
                }
                ColladaContextMenu();
                Theme.RenderTreeIcon(obj.Name, tree_icon, Color4.White);
            }
        }
コード例 #23
0
        public static void DropdownButton(string id, ref int selected, IReadOnlyList <DropdownOption> options)
        {
            ImGui.PushID(id);
            bool         clicked = false;
            const string PADDING = "       ";
            string       text    = PADDING + ImGuiExt.IDSafe(options[selected].Name) + "   ";
            var          w       = ImGui.CalcTextSize(text).X;

            clicked = ImGui.Button(text);
            ImGui.SameLine();
            var cpos  = ImGuiNative.igGetCursorPosX();
            var cposY = ImGuiNative.igGetCursorPosY();

            Theme.TinyTriangle(cpos - 15, cposY + 15);
            ImGuiNative.igSetCursorPosX(cpos - w - 13);
            ImGuiNative.igSetCursorPosY(cposY + 2);
            Theme.Icon(options[selected].Icon, Color4.White);
            ImGui.SameLine();
            ImGuiNative.igSetCursorPosY(cposY);
            ImGui.SetCursorPosX(cpos - 6);
            ImGui.Dummy(Vector2.Zero);
            if (clicked)
            {
                ImGui.OpenPopup(id + "#popup");
            }
            if (ImGui.BeginPopup(id + "#popup"))
            {
                ImGui.MenuItem(id, false);
                for (int i = 0; i < options.Count; i++)
                {
                    var opt = options[i];
                    if (Theme.IconMenuItem(opt.Name, opt.Icon, Color4.White, true))
                    {
                        selected = i;
                    }
                }
                ImGui.EndPopup();
            }
            ImGui.PopID();
        }
コード例 #24
0
ファイル: AleViewer.cs プロジェクト: Regenhardt/Librelancer
        void DoNode(NodeReference reference, int idx, Vector4 enabled, Vector4 disabled)
        {
            var    col   = instance.NodeEnabled(reference) ? enabled : disabled;
            string label = null;

            if (reference.IsAttachmentNode)
            {
                label = string.Format("Attachment##{0}", idx);
            }
            else
            {
                label = ImGuiExt.IDWithExtra(reference.Node.NodeName, idx);
            }
            ImGui.PushStyleColor(ImGuiCol.Text, col);
            char icon;

            NodeIcon(reference.Node, out icon);
            if (reference.Children.Count > 0)
            {
                if (Theme.IconTreeNode(icon, label, ImGuiTreeNodeFlags.OpenOnDoubleClick | ImGuiTreeNodeFlags.OpenOnArrow))
                {
                    int j = 0;
                    foreach (var child in reference.Children)
                    {
                        DoNode(child, j++, enabled, disabled);
                    }
                    ImGui.TreePop();
                }
            }
            else
            {
                if (ImGui.Selectable($"{icon}  {label}", selectedReference == reference))
                {
                    selectedReference = reference;
                }
            }
            ImGui.PopStyleColor();
        }
コード例 #25
0
ファイル: ColladaTab.cs プロジェクト: TRBlount/Librelancer
        void FLPane()
        {
            var totalH = ImGui.GetWindowHeight();

            ImGuiExt.SplitterV(2f, ref fl_h1, ref fl_h2, 8, 8, -1);
            fl_h1 = totalH - fl_h2 - 6f;
            ImGui.BeginChild("1", new Vector2(-1, fl_h1), false, WindowFlags.Default);
            ImGui.Separator();
            //3DB list
            if (ImGui.TreeNodeEx("Model/"))
            {
                int i = 0;
                foreach (var mdl in output)
                {
                    FLTree(mdl, ref i);
                }
            }
            ImGui.EndChild();
            ImGui.BeginChild("2", new Vector2(-1, fl_h2), false, WindowFlags.Default);
            if (ImGuiExt.ToggleButton("Preview", flPreview))
            {
                flPreview = true;
            }
            ImGui.SameLine();
            if (ImGuiExt.ToggleButton("Details", !flPreview))
            {
                flPreview = false;
            }
            ImGui.Separator();
            if (flPreview)
            {
            }
            else
            {
            }
            ImGui.EndChild();
        }
コード例 #26
0
        void InfocardXmlDialog()
        {
            if (doOpenXml)
            {
                ImGui.OpenPopup(ImGuiExt.IDWithExtra("Xml", Unique));
                doOpenXml  = false;
                xmlDlgOpen = true;
            }

            if (ImGui.BeginPopupModal(ImGuiExt.IDWithExtra("Xml", Unique), ref xmlDlgOpen,
                                      ImGuiWindowFlags.AlwaysAutoResize))
            {
                if (ImGui.Button("Copy To Clipboard"))
                {
                    win.SetClipboardText(currentXml);
                }

                ImGui.PushFont(ImGuiHelper.SystemMonospace);
                ImGui.InputTextMultiline("##xml", ref currentXml, UInt32.MaxValue, new Vector2(400),
                                         ImGuiInputTextFlags.ReadOnly);
                ImGui.PopFont();
                ImGui.EndPopup();
            }
        }
コード例 #27
0
        protected override void Draw(double elapsed)
        {
            //Don't process all the imgui stuff when it isn't needed
            if (!loadingSpinnerActive && !guiHelper.DoRender(elapsed))
            {
                if (lastFrame != null)
                {
                    lastFrame.BlitToScreen();
                }
                WaitForEvent(); //Yield like a regular GUI program
                return;
            }
            TimeStep = elapsed;
            Viewport.Replace(0, 0, Width, Height);
            RenderState.ClearColor = new Color4(0.2f, 0.2f, 0.2f, 1f);
            RenderState.ClearAll();
            guiHelper.NewFrame(elapsed);
            ImGui.PushFont(ImGuiHelper.Noto);
            ImGui.BeginMainMenuBar();
            if (ImGui.BeginMenu("File"))
            {
                if (Theme.IconMenuItem("New", "new", Color4.White, true))
                {
                    var t = new UtfTab(this, new EditableUtf(), "Untitled");
                    ActiveTab = t;
                    AddTab(t);
                }
                if (Theme.IconMenuItem("Open", "open", Color4.White, true))
                {
                    var f = FileDialog.Open(UtfFilters);
                    OpenFile(f);
                }
                if (ActiveTab == null)
                {
                    Theme.IconMenuItem("Save", "save", Color4.LightGray, false);
                    Theme.IconMenuItem("Save As", "saveas", Color4.LightGray, false);
                }
                else
                {
                    if (Theme.IconMenuItem(string.Format("Save '{0}'", ActiveTab.DocumentName), "saveas", Color4.White, true))
                    {
                        Save();
                    }
                    if (Theme.IconMenuItem("Save As", "saveas", Color4.White, true))
                    {
                        SaveAs();
                    }
                }
                if (Theme.IconMenuItem("Quit", "quit", Color4.White, true))
                {
                    Exit();
                }
                ImGui.EndMenu();
            }
            if (ImGui.BeginMenu("View"))
            {
                Theme.IconMenuToggle("Log", "log", Color4.White, ref showLog, true);
                ImGui.EndMenu();
            }
            if (ImGui.BeginMenu("Tools"))
            {
                if (Theme.IconMenuItem("Options", "options", Color4.White, true))
                {
                    options.Show();
                }

                if (Theme.IconMenuItem("Resources", "resources", Color4.White, true))
                {
                    AddTab(new ResourcesTab(this, Resources, MissingResources, ReferencedMaterials, ReferencedTextures));
                }
                if (Theme.IconMenuItem("Import Collada", "import", Color4.White, true))
                {
                    string input;
                    if ((input = FileDialog.Open(ColladaFilters)) != null)
                    {
                        StartLoadingSpinner();
                        new Thread(() =>
                        {
                            List <ColladaObject> dae = null;
                            try
                            {
                                dae = ColladaSupport.Parse(input);
                                EnsureUIThread(() => FinishColladaLoad(dae, System.IO.Path.GetFileName(input)));
                            }
                            catch (Exception ex)
                            {
                                EnsureUIThread(() => ColladaError(ex));
                            }
                        }).Start();
                    }
                }
                if (Theme.IconMenuItem("Generate Icon", "genicon", Color4.White, true))
                {
                    string input;
                    if ((input = FileDialog.Open(ImageFilter)) != null)
                    {
                        gen3dbDlg.Open(input);
                    }
                }
                if (Theme.IconMenuItem("Infocard Browser", "browse", Color4.White, true))
                {
                    string input;
                    if ((input = FileDialog.Open(FreelancerIniFilter)) != null)
                    {
                        AddTab(new InfocardBrowserTab(input, this));
                    }
                }
                if (ImGui.MenuItem("Projectile Viewer"))
                {
                    if (ProjectileViewer.Create(this, out var pj))
                    {
                        tabs.Add(pj);
                    }
                }
                ImGui.EndMenu();
            }
            if (ImGui.BeginMenu("Help"))
            {
                if (Theme.IconMenuItem("Topics", "help", Color4.White, true))
                {
                    Shell.OpenCommand("https://wiki.librelancer.net/lanceredit:lanceredit");
                }
                if (Theme.IconMenuItem("About", "about", Color4.White, true))
                {
                    openAbout = true;
                }
                ImGui.EndMenu();
            }

            options.Draw();
            if (openAbout)
            {
                ImGui.OpenPopup("About");
                openAbout = false;
            }
            if (openError)
            {
                ImGui.OpenPopup("Error");
                openError = false;
            }

            if (openLoading)
            {
                ImGui.OpenPopup("Processing");
                openLoading = false;
            }
            bool pOpen = true;

            if (ImGui.BeginPopupModal("Error", ref pOpen, ImGuiWindowFlags.AlwaysAutoResize))
            {
                ImGui.Text("Error:");
                errorText.InputTextMultiline("##etext", new Vector2(430, 200), ImGuiInputTextFlags.ReadOnly);
                if (ImGui.Button("OK"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            pOpen = true;
            if (ImGui.BeginPopupModal("About", ref pOpen, ImGuiWindowFlags.AlwaysAutoResize))
            {
                ImGui.SameLine(ImGui.GetWindowWidth() / 2 - 64);
                Theme.Icon("reactor_128", Color4.White);
                CenterText(Version);
                CenterText("Callum McGing 2018-2020");
                ImGui.Separator();
                CenterText("Icons from Icons8: https://icons8.com/");
                CenterText("Icons from komorra: https://opengameart.org/content/kmr-editor-icon-set");
                ImGui.Separator();
                var btnW = ImGui.CalcTextSize("OK").X + ImGui.GetStyle().FramePadding.X * 2;
                ImGui.Dummy(Vector2.One);
                ImGui.SameLine(ImGui.GetWindowWidth() / 2 - (btnW / 2));
                if (ImGui.Button("OK"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            pOpen = true;
            if (ImGuiExt.BeginModalNoClose("Processing", ImGuiWindowFlags.AlwaysAutoResize))
            {
                ImGuiExt.Spinner("##spinner", 10, 2, ImGuiNative.igGetColorU32(ImGuiCol.ButtonHovered, 1));
                ImGui.SameLine();
                ImGui.Text("Processing");
                if (finishLoading)
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            //Confirmation
            if (doConfirm)
            {
                ImGui.OpenPopup("Confirm?##mainwindow");
                doConfirm = false;
            }
            pOpen = true;
            if (ImGui.BeginPopupModal("Confirm?##mainwindow", ref pOpen, ImGuiWindowFlags.AlwaysAutoResize))
            {
                ImGui.Text(confirmText);
                if (ImGui.Button("Yes"))
                {
                    confirmAction();
                    ImGui.CloseCurrentPopup();
                }
                ImGui.SameLine();
                if (ImGui.Button("No"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            var menu_height = ImGui.GetWindowSize().Y;

            ImGui.EndMainMenuBar();
            var size = ImGui.GetIO().DisplaySize;

            size.Y -= menu_height;
            //Window
            MissingResources.Clear();
            ReferencedMaterials.Clear();
            ReferencedTextures.Clear();
            foreach (var tab in tabs)
            {
                ((EditorTab)tab).DetectResources(MissingResources, ReferencedMaterials, ReferencedTextures);
            }
            ImGui.SetNextWindowSize(new Vector2(size.X, size.Y - 25), ImGuiCond.Always);
            ImGui.SetNextWindowPos(new Vector2(0, menu_height), ImGuiCond.Always, Vector2.Zero);
            bool childopened = true;

            ImGui.Begin("tabwindow", ref childopened,
                        ImGuiWindowFlags.NoTitleBar |
                        ImGuiWindowFlags.NoSavedSettings |
                        ImGuiWindowFlags.NoBringToFrontOnFocus |
                        ImGuiWindowFlags.NoMove |
                        ImGuiWindowFlags.NoResize);
            TabHandler.TabLabels(tabs, ref selected);
            var totalH = ImGui.GetWindowHeight();

            if (showLog)
            {
                ImGuiExt.SplitterV(2f, ref h1, ref h2, 8, 8, -1);
                h1 = totalH - h2 - 24f;
                if (tabs.Count > 0)
                {
                    h1 -= 20f;
                }
                ImGui.BeginChild("###tabcontent" + (selected != null ? selected.RenderTitle : ""), new Vector2(-1, h1), false, ImGuiWindowFlags.None);
            }
            else
            {
                ImGui.BeginChild("###tabcontent" + (selected != null ? selected.RenderTitle : ""));
            }
            if (selected != null)
            {
                selected.Draw();
                ((EditorTab)selected).SetActiveTab(this);
            }
            else
            {
                ActiveTab = null;
            }
            ImGui.EndChild();
            if (showLog)
            {
                ImGui.BeginChild("###log", new Vector2(-1, h2), false, ImGuiWindowFlags.None);
                ImGui.Text("Log");
                ImGui.SameLine(ImGui.GetWindowWidth() - 20);
                if (Theme.IconButton("closelog", "x", Color4.White))
                {
                    showLog = false;
                }
                logBuffer.InputTextMultiline("##logtext", new Vector2(-1, h2 - 24), ImGuiInputTextFlags.ReadOnly);
                ImGui.EndChild();
            }
            ImGui.End();
            gen3dbDlg.Draw();
            //Status bar
            ImGui.SetNextWindowSize(new Vector2(size.X, 25f), ImGuiCond.Always);
            ImGui.SetNextWindowPos(new Vector2(0, size.Y - 6f), ImGuiCond.Always, Vector2.Zero);
            bool sbopened = true;

            ImGui.Begin("statusbar", ref sbopened,
                        ImGuiWindowFlags.NoTitleBar |
                        ImGuiWindowFlags.NoSavedSettings |
                        ImGuiWindowFlags.NoBringToFrontOnFocus |
                        ImGuiWindowFlags.NoMove |
                        ImGuiWindowFlags.NoResize);
            if (updateTime > 9)
            {
                updateTime = 0;
                frequency  = RenderFrequency;
            }
            else
            {
                updateTime++;
            }
            string activename = ActiveTab == null ? "None" : ActiveTab.DocumentName;
            string utfpath    = ActiveTab == null ? "None" : ActiveTab.GetUtfPath();

            #if DEBUG
            const string statusFormat = "FPS: {0} | {1} Materials | {2} Textures | Active: {3} - {4}";
            #else
            const string statusFormat = "{1} Materials | {2} Textures | Active: {3} - {4}";
            #endif
            ImGui.Text(string.Format(statusFormat,
                                     (int)Math.Round(frequency),
                                     Resources.MaterialDictionary.Count,
                                     Resources.TextureDictionary.Count,
                                     activename,
                                     utfpath));
            ImGui.End();
            if (errorTimer > 0)
            {
                ImGuiExt.ToastText("An error has occurred\nCheck the log for details",
                                   new Color4(21, 21, 22, 128),
                                   Color4.Red);
            }
            ImGui.PopFont();
            if (lastFrame == null ||
                lastFrame.Width != Width ||
                lastFrame.Height != Height)
            {
                if (lastFrame != null)
                {
                    lastFrame.Dispose();
                }
                lastFrame = new RenderTarget2D(Width, Height);
            }
            RenderState.RenderTarget = lastFrame;
            RenderState.ClearColor   = new Color4(0.2f, 0.2f, 0.2f, 1f);
            RenderState.ClearAll();
            guiHelper.Render(RenderState);
            RenderState.RenderTarget = null;
            lastFrame.BlitToScreen();
            foreach (var tab in toAdd)
            {
                tabs.Add(tab);
                selected = tab;
            }
            toAdd.Clear();
        }
コード例 #28
0
        public override void Draw()
        {
            ImGui.Columns(2, "cols", true);
            //strings vs infocards
            if (ImGuiExt.ToggleButton("Strings", showStrings))
            {
                showStrings = true;
            }
            ImGui.SameLine();
            if (ImGuiExt.ToggleButton("Infocards", !showStrings))
            {
                showStrings = false;
            }
            ImGui.SameLine();
            ImGui.PushItemWidth(140);
            ImGui.InputInt("##id", ref id, 0, 0);
            ImGui.PopItemWidth();
            ImGui.SameLine();
            int gotoItem = -1;

            if (ImGui.Button("Go"))
            {
                if (showStrings)
                {
                    for (int i = 0; i < stringsIds.Length; i++)
                    {
                        if (id == stringsIds[i])
                        {
                            gotoItem      = i;
                            currentString = i;
                            txt.SetText(manager.GetStringResource(stringsIds[i]));
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < infocardsIds.Length; i++)
                    {
                        if (id == infocardsIds[i])
                        {
                            gotoItem        = i;
                            currentInfocard = i;
                            if (display == null)
                            {
                                display = new InfocardControl(win, RDLParse.Parse(manager.GetXmlResource(infocardsIds[currentInfocard]), win.Fonts), 100);
                            }
                            else
                            {
                                display.SetInfocard(RDLParse.Parse(manager.GetXmlResource(infocardsIds[currentInfocard]), win.Fonts));
                            }
                        }
                    }
                }
            }
            ImGui.Separator();
            //list
            ImGui.BeginChild("##list");
            if (showStrings)
            {
                if (gotoItem == -1)
                {
                    stringClipper.Begin(stringsIds.Length);
                    while (stringClipper.Step())
                    {
                        for (int i = stringClipper.DisplayStart; i < stringClipper.DisplayEnd; i++)
                        {
                            if (ImGui.Selectable(stringsIds[i] + "##" + i, currentString == i))
                            {
                                currentString = i;
                                txt.SetText(manager.GetStringResource(stringsIds[i]));
                            }
                        }
                    }
                    stringClipper.End();
                }
                else
                {
                    for (int i = 0; i < stringsIds.Length; i++)
                    {
                        ImGui.Selectable(stringsIds[i] + "##" + i, currentString == i);
                        if (currentString == i)
                        {
                            ImGui.SetScrollHere();
                        }
                    }
                }
            }
            else
            {
                if (gotoItem == -1)
                {
                    infocardClipper.Begin(infocardsIds.Length);
                    while (infocardClipper.Step())
                    {
                        for (int i = infocardClipper.DisplayStart; i < infocardClipper.DisplayEnd; i++)
                        {
                            if (ImGui.Selectable(infocardsIds[i] + "##" + i, currentInfocard == i))
                            {
                                currentInfocard = i;
                                if (display == null)
                                {
                                    display = new InfocardControl(win, RDLParse.Parse(manager.GetXmlResource(infocardsIds[currentInfocard]), win.Fonts), 100);
                                }
                                else
                                {
                                    display.SetInfocard(RDLParse.Parse(manager.GetXmlResource(infocardsIds[currentInfocard]), win.Fonts));
                                }
                            }
                        }
                    }
                    infocardClipper.End();
                }
                else
                {
                    for (int i = 0; i < infocardsIds.Length; i++)
                    {
                        ImGui.Selectable(infocardsIds[i] + "##" + i, currentInfocard == i);
                        if (currentInfocard == i)
                        {
                            ImGui.SetScrollHere();
                        }
                    }
                }
            }
            ImGui.EndChild();
            ImGui.NextColumn();
            //Display
            if (showStrings)
            {
                if (currentString != -1)
                {
                    ImGui.Text(stringsIds[currentString].ToString());
                    txt.InputTextMultiline("##txt", new Vector2(-1, ImGui.GetWindowHeight() - 70), ImGuiInputTextFlags.ReadOnly);
                }
            }
            else
            {
                if (currentInfocard != -1)
                {
                    ImGui.Text(infocardsIds[currentInfocard].ToString());
                    ImGui.BeginChild("##display");
                    display.Draw(ImGui.GetWindowWidth() - 15);
                    ImGui.EndChild();
                }
            }
        }
コード例 #29
0
        void TexImportDialog(PopupData data)
        {
            if (teximportprev == null)
            { //processing
                ImGuiExt.Spinner("##spinner", 10, 2, ImGuiNative.igGetColorU32(ImGuiCol.ButtonHovered, 1));
                ImGui.SameLine();
                ImGui.Text("Processing...");
                if (!texImportWaiting)
                {
                    if (texImportChildren != null)
                    {
                        selectedNode.Data = null;
                        foreach (var c in texImportChildren)
                        {
                            c.Parent = selectedNode;
                        }
                        selectedNode.Children = texImportChildren;
                    }
                    else
                    {
                        selectedNode.Children = null;
                        selectedNode.Data     = texImportData;
                    }
                    texImportData     = null;
                    texImportChildren = null;
                    ImGui.CloseCurrentPopup();
                }
            }
            else
            {
                data.NoClose = false;
                ImGui.Image((IntPtr)teximportid, new Vector2(64, 64),
                            new Vector2(0, 1), new Vector2(1, 0), Vector4.One, Vector4.Zero);
                ImGui.Text(string.Format("Dimensions: {0}x{1}", teximportprev.Width, teximportprev.Height));
                ImGui.Combo("Format", ref compressOption, texOptions, texOptions.Length);
                ImGui.Combo("Mipmaps", ref mipmapOption, mipmapOptions, mipmapOptions.Length);
                ImGui.Checkbox("Flip Vertically", ref texFlip);
                ImGui.Checkbox("High Quality (slow)", ref compressSlow);
                if (ImGui.Button("Import"))
                {
                    ImGuiHelper.DeregisterTexture(teximportprev);
                    teximportprev.Dispose();
                    teximportprev    = null;
                    texImportWaiting = true;
                    data.NoClose     = true;
                    new System.Threading.Thread(() =>
                    {
                        var format = DDSFormat.Uncompressed;
                        switch (compressOption)
                        {
                        case 1:
                            format = DDSFormat.DXT1;
                            break;

                        case 2:
                            format = DDSFormat.DXT1a;
                            break;

                        case 3:
                            format = DDSFormat.DXT3;
                            break;

                        case 4:
                            format = DDSFormat.DXT5;
                            break;
                        }
                        var mipm = MipmapMethod.None;
                        switch (mipmapOption)
                        {
                        case 1:
                            mipm = MipmapMethod.Box;
                            break;

                        case 2:
                            mipm = MipmapMethod.Tent;
                            break;

                        case 3:
                            mipm = MipmapMethod.Lanczos4;
                            break;

                        case 4:
                            mipm = MipmapMethod.Mitchell;
                            break;

                        case 5:
                            mipm = MipmapMethod.Kaiser;
                            break;
                        }
                        if (mipm == MipmapMethod.None && format == DDSFormat.Uncompressed)
                        {
                            texImportData = TextureImport.TGANoMipmap(teximportpath, texFlip);
                        }
                        else if (format == DDSFormat.Uncompressed)
                        {
                            texImportChildren = TextureImport.TGAMipmaps(teximportpath, mipm, texFlip);
                        }
                        else
                        {
                            texImportData = TextureImport.CreateDDS(teximportpath, format, mipm, compressSlow, texFlip);
                        }
                        texImportWaiting = false;
                    }).Start();
                }
                ImGui.SameLine();
                if (ImGui.Button("Cancel"))
                {
                    ImGuiHelper.DeregisterTexture(teximportprev);
                    teximportprev.Dispose();
                    teximportprev = null;
                    ImGui.CloseCurrentPopup();
                }
            }
        }
コード例 #30
0
 void SearchStatus()
 {
     ImGuiExt.Spinner("##spinner", 10, 2, ImGuiNative.igGetColorU32(ImGuiCol.ButtonHovered, 1));
     ImGui.SameLine();
     ImGui.Text("Searching");
 }