Ejemplo n.º 1
0
        public void MemoryView(RenderWindow window)
        {
            bool wopen = true;

            string[] ramsel = { "RAM", "VRAM" };

            ImGuiWindowFlags wflags = ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoCollapse;

            if (ImGui.Begin(ramsel[index], ref wopen, wflags))
            {
                ImGui.Combo("Memory Selection", ref index, ramsel, ramsel.Length);
                ImGui.SetWindowPos(new ImVec2(972, 25));
                ImGui.SetWindowSize(new ImVec2(430, window.Size.Y - 35));

                if (index == 0)
                {
                    mem.Draw(ramsel[index], c.mapper.ram, c.mapper.ram.Length);
                }
                else
                {
                    mem.Draw(ramsel[index], c.mapper.vram, c.mapper.vram.Length);
                }
                ImGui.End();
            }
        }
Ejemplo n.º 2
0
        public static void Render(FMAT material)
        {
            var renderer = material.MaterialAsset as SharcFBRenderer;

            if (renderer.GLShaderInfo == null)
            {
                return;
            }

            if (ImGui.BeginCombo("Stage", selectedStage))
            {
                if (ImGui.Selectable("Vertex"))
                {
                    selectedStage = "Vertex";
                }
                if (ImGui.Selectable("Pixel"))
                {
                    selectedStage = "Pixel";
                }
                ImGui.EndCombo();
            }

            ImGui.BeginTabBar("menu_shader1");
            if (ImguiCustomWidgets.BeginTab("menu_shader1", $"Shader Code"))
            {
                LoadShaderStageCode(material);
                ImGui.EndTabItem();
            }
            if (ImguiCustomWidgets.BeginTab("menu_shader1", "Shader Info"))
            {
                if (ImGui.BeginChild("ShaderInfoC"))
                {
                    LoadShaderInfo(material);
                }
                ImGui.EndChild();
                ImGui.EndTabItem();
            }
            if (ImguiCustomWidgets.BeginTab("menu_shader1", "GX2 Shader Data"))
            {
                var shader  = material.MaterialAsset as SharcFBRenderer;
                var program = shader.ShaderModel;

                if (selectedStage == "Vertex")
                {
                    var gx2Shader = program.GetRawVertexShader(shader.BinaryIndex).ToArray();
                    MemoryEditor.Draw(gx2Shader, gx2Shader.Length);
                }
                if (selectedStage == "Pixel")
                {
                    var gx2Shader = program.GetRawPixelShader(shader.BinaryIndex).ToArray();
                    MemoryEditor.Draw(gx2Shader, gx2Shader.Length);
                }
                ImGui.EndTabItem();
            }
        }
Ejemplo n.º 3
0
        public unsafe override void ImGuiLayout()
        {
            // 1. Show a simple window
            // Tip: if we don't call ImGui.Begin()/ImGui.End() the widgets appears in a window automatically called "Debug"
            {
                var io = ImGui.GetIO();
                ImGui.BeginWindow("Debug");
                ImGui.Text("Hello, world!");
                ImGui.SliderFloat("float", ref f, 0.0f, 1.0f, null, 1f);
                ImGui.ColorEdit3("clear color", ref clear_color, ColorEditFlags.Default);
                if (ImGui.Button("Test Window"))
                {
                    show_test_window = !show_test_window;
                }
                if (ImGui.Button("Another Window"))
                {
                    show_another_window = !show_another_window;
                }
                ImGui.Text(string.Format("Application average {0:F3} ms/frame ({1:F1} FPS)", ImGui.GetIO().DeltaTime, 1f / ImGui.GetIO().DeltaTime));
                //ImGui.InputText("Text Input 1", _TextInputBuffers[0], _TextInputBuffers[0].Length,InputTextFlags.Default,new TextEditCallback();
                //ImGui.InputText("Text Input 2", _TextInputBuffers[1].Buffer, _TextInputBuffers[1].Length);
                if (ImGui.Button("Open File"))
                {
                    show_file_dialog = !show_file_dialog;
                }
                ImGui.EndWindow();
            }

            // 2. Show another simple window, this time using an explicit Begin/End pair
            if (show_another_window)
            {
                ImGui.SetNextWindowSize(new System.Numerics.Vector2(200, 100), Condition.FirstUseEver);
                ImGui.BeginChild("Another Window", show_another_window);
                ImGui.Text("Hello");
                ImGui.EndChild();
            }

            // 3. Show the ImGui test window. Most of the sample code is in ImGui.ShowTestWindow()
            if (show_test_window)
            {
                ImGui.SetNextWindowPos(new System.Numerics.Vector2(650, 20), Condition.FirstUseEver, new System.Numerics.Vector2(0, 0));
                ImGuiNative.igShowDemoWindow(ref show_test_window);
            }

            // 4. Show the memory editor and file dialog, just as an example.
            _MemoryEditor.Draw("Memory editor", _MemoryEditorData, _MemoryEditorData.Length);
            if (show_file_dialog)
            {
                string start = _Dialog.LastDirectory;
                _Dialog.ChooseFileDialog(true, _Dialog.LastDirectory, null, "Choose File", new System.Numerics.Vector2(500, 500), new System.Numerics.Vector2(50, 50), 1f);

                /* if (!string.IsNullOrEmpty(_Dialog.ChosenPath))
                 *   _TextInputBuffers[0].StringValue = _Dialog.ChosenPath;*/
            }
        }
Ejemplo n.º 4
0
        void HexEditor(PopupData data)
        {
            ImGui.PushFont(ImGuiHelper.Default);
            int res;

            if ((res = mem.Draw("Hex", hexdata, hexdata.Length, 0)) != 0)
            {
                if (res == 1)
                {
                    selectedNode.Data = hexdata;
                }
                ImGui.CloseCurrentPopup();
            }
            ImGui.PopFont();
        }
Ejemplo n.º 5
0
        unsafe void Popups()
        {
            //StringEditor
            if (stringConfirm)
            {
                ImGui.OpenPopup("Confirm?##stringedit" + Unique);
                stringConfirm = false;
            }
            if (ImGui.BeginPopupModal("Confirm?##stringedit" + Unique, WindowFlags.AlwaysAutoResize))
            {
                ImGui.Text("Data is >255 bytes, string will be truncated. Continue?");
                if (ImGui.Button("Yes"))
                {
                    text.SetBytes(selectedNode.Data, 255);
                    stringEditor = true;
                    ImGui.CloseCurrentPopup();
                }
                ImGui.SameLine();
                if (ImGui.Button("No"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            if (stringEditor)
            {
                ImGui.OpenPopup("String Editor##" + Unique);
                stringEditor = false;
            }
            if (ImGui.BeginPopupModal("String Editor##" + Unique, WindowFlags.AlwaysAutoResize))
            {
                ImGui.Text("String: ");
                ImGui.SameLine();
                ImGui.InputText("", text.Pointer, 255, InputTextFlags.Default, text.Callback);
                if (ImGui.Button("Ok"))
                {
                    selectedNode.Data = text.GetByteArray();
                    ImGui.CloseCurrentPopup();
                }
                ImGui.SameLine();
                if (ImGui.Button("Cancel"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            //Hex Editor
            if (hexEditor)
            {
                ImGui.OpenPopup("HexEditor##" + Unique);
                hexEditor = false;
            }
            if (ImGui.BeginPopupModal("HexEditor##" + Unique))
            {
                ImGui.PushFont(ImGuiHelper.Default);
                int res;
                if ((res = mem.Draw("Hex", hexdata, hexdata.Length, 0)) != 0)
                {
                    if (res == 1)
                    {
                        selectedNode.Data = hexdata;
                    }
                    ImGui.CloseCurrentPopup();
                }
                ImGui.PopFont();
                ImGui.EndPopup();
            }
            //Color Picker
            if (colorPicker)
            {
                ImGui.OpenPopup("Color Picker##" + Unique);
                colorPicker = false;
            }
            if (ImGui.BeginPopupModal("Color Picker##" + Unique, WindowFlags.AlwaysAutoResize))
            {
                bool old4 = pickcolor4;
                ImGui.Checkbox("Alpha?", ref pickcolor4);
                if (old4 != pickcolor4)
                {
                    if (old4 == false)
                    {
                        color4 = new System.Numerics.Vector4(color3.X, color3.Y, color3.Z, 1);
                    }
                    if (old4 == true)
                    {
                        color3 = new System.Numerics.Vector3(color4.X, color4.Y, color4.Z);
                    }
                }
                ImGui.Separator();
                if (pickcolor4)
                {
                    ImGui.ColorPicker4("Color", ref color4, ColorEditFlags.AlphaPreview | ColorEditFlags.AlphaBar);
                }
                else
                {
                    ImGui.ColorPicker3("Color", ref color3);
                }
                ImGui.Separator();
                if (ImGui.Button("Ok"))
                {
                    ImGui.CloseCurrentPopup();
                    if (pickcolor4)
                    {
                        var bytes = new byte[16];
                        fixed(byte *ptr = bytes)
                        {
                            var f = (System.Numerics.Vector4 *)ptr;

                            f[0] = color4;
                        }

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

                            f[0] = color3;
                        }

                        selectedNode.Data = bytes;
                    }
                }
                ImGui.SameLine();
                if (ImGui.Button("Cancel"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            //Float Editor
            if (floatEditor)
            {
                ImGui.OpenPopup("Float Editor##" + Unique);
                floatEditor = false;
            }
            DataEditors.FloatEditor("Float Editor##" + Unique, ref floats, selectedNode);
            if (intEditor)
            {
                ImGui.OpenPopup("Int Editor##" + Unique);
                intEditor = false;
            }
            DataEditors.IntEditor("Int Editor##" + Unique, ref ints, ref intHex, selectedNode);
            //Rename dialog
            if (doRename)
            {
                ImGui.OpenPopup("Rename##" + Unique);
                doRename = false;
            }
            if (ImGui.BeginPopupModal("Rename##" + Unique, WindowFlags.AlwaysAutoResize))
            {
                ImGui.Text("Name: ");
                ImGui.SameLine();
                ImGui.InputText("", text.Pointer, text.Size, InputTextFlags.Default, text.Callback);
                if (ImGui.Button("Ok"))
                {
                    var n = text.GetText().Trim();
                    if (n.Length == 0)
                    {
                        ErrorPopup("Node name cannot be empty");
                    }
                    else
                    {
                        renameNode.Name = text.GetText();
                    }
                    ImGui.CloseCurrentPopup();
                }
                ImGui.SameLine();
                if (ImGui.Button("Cancel"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            //Error
            if (doError)
            {
                ImGui.OpenPopup("Error##" + Unique);
                doError = false;
            }
            if (ImGui.BeginPopupModal("Error##" + Unique, WindowFlags.AlwaysAutoResize))
            {
                ImGui.Text(errorText);
                if (ImGui.Button("Ok"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            //Add
            if (doAdd)
            {
                ImGui.OpenPopup("New Node##" + Unique);
                doAdd = false;
            }
            if (ImGui.BeginPopupModal("New Node##" + Unique, WindowFlags.AlwaysAutoResize))
            {
                ImGui.Text("Name: ");
                ImGui.SameLine();
                ImGui.InputText("", text.Pointer, text.Size, InputTextFlags.Default, text.Callback);
                if (ImGui.Button("Ok"))
                {
                    var node = new LUtfNode()
                    {
                        Name = text.GetText().Trim(), Parent = addParent ?? addNode
                    };
                    if (node.Name.Length == 0)
                    {
                        ErrorPopup("Node name cannot be empty");
                    }
                    else
                    {
                        if (addParent != null)
                        {
                            addParent.Children.Insert(addParent.Children.IndexOf(addNode) + addOffset, node);
                        }
                        else
                        {
                            addNode.Data = null;
                            if (addNode.Children == null)
                            {
                                addNode.Children = new List <LUtfNode>();
                            }
                            addNode.Children.Add(node);
                        }
                        selectedNode = node;
                    }
                    ImGui.CloseCurrentPopup();
                }
                ImGui.SameLine();
                if (ImGui.Button("Cancel"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            //Confirmation
            if (doConfirm)
            {
                ImGui.OpenPopup("Confirm?##generic" + Unique);
                doConfirm = false;
            }
            if (ImGui.BeginPopupModal("Confirm?##generic" + Unique, WindowFlags.AlwaysAutoResize))
            {
                ImGui.Text(confirmText);
                if (ImGui.Button("Yes"))
                {
                    confirmAction();
                    ImGui.CloseCurrentPopup();
                }
                ImGui.SameLine();
                if (ImGui.Button("No"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
        }
Ejemplo n.º 6
0
        static unsafe void SubmitUI()
        {
            // Demo code adapted from the official Dear ImGui demo program:

            // 1. Show a simple window.
            // Tip: if we don't call ImGui.BeginWindow()/ImGui.EndWindow() the widgets automatically appears in a window called "Debug".
            {
                ImGui.Text("Hello, world!");                                        // Display some text (you can use a format string too)
                ImGui.SliderFloat("float", ref _f, 0, 1, _f.ToString("0.000"));     // Edit 1 float using a slider from 0.0f to 1.0f
                // ImGui.ColorEdit3("clear color", ref _clearColor);                // Edit 3 floats representing a color

                ImGui.Text($"Mouse position: {ImGui.GetMousePos()}");

                ImGui.Checkbox("Demo Window", ref _showDemoWindow);                 // Edit bools storing our windows open/close state
                ImGui.Checkbox("Another Window", ref _showAnotherWindow);
                ImGui.Checkbox("Memory Editor", ref _showMemoryEditor);
                if (ImGui.Button("Button"))                                         // Buttons return true when clicked (NB: most widgets return true when edited/activated)
                {
                    _counter++;
                }
                ImGui.SameLine(0, -1);
                ImGui.Text($"counter = {_counter}");

                ImGui.DragInt("Draggable Int", ref _dragInt);

                float framerate = ImGui.GetIO().Framerate;
                ImGui.Text($"Application average {1000.0f / framerate:0.##} ms/frame ({framerate:0.#} FPS)");
            }

            // 2. Show another simple window. In most cases you will use an explicit Begin/End pair to name your windows.
            if (_showAnotherWindow)
            {
                ImGui.Begin("Another Window", ref _showAnotherWindow);
                ImGui.Text("Hello from another window!");
                if (ImGui.Button("Close Me"))
                {
                    _showAnotherWindow = false;
                }
                ImGui.End();
            }

            // 3. Show the ImGui demo window. Most of the sample code is in ImGui.ShowDemoWindow(). Read its code to learn more about Dear ImGui!
            if (_showDemoWindow)
            {
                // Normally user code doesn't need/want to call this because positions are saved in .ini file anyway.
                // Here we just want to make the demo initial state a bit more friendly!
                ImGui.SetNextWindowPos(new Vector2(650, 20), ImGuiCond.FirstUseEver);
                ImGui.ShowDemoWindow(ref _showDemoWindow);
            }

            if (ImGui.TreeNode("Tabs"))
            {
                if (ImGui.TreeNode("Basic"))
                {
                    ImGuiTabBarFlags tab_bar_flags = ImGuiTabBarFlags.None;
                    if (ImGui.BeginTabBar("MyTabBar", tab_bar_flags))
                    {
                        if (ImGui.BeginTabItem("Avocado"))
                        {
                            ImGui.Text("This is the Avocado tab!\nblah blah blah blah blah");
                            ImGui.EndTabItem();
                        }
                        if (ImGui.BeginTabItem("Broccoli"))
                        {
                            ImGui.Text("This is the Broccoli tab!\nblah blah blah blah blah");
                            ImGui.EndTabItem();
                        }
                        if (ImGui.BeginTabItem("Cucumber"))
                        {
                            ImGui.Text("This is the Cucumber tab!\nblah blah blah blah blah");
                            ImGui.EndTabItem();
                        }
                        ImGui.EndTabBar();
                    }
                    ImGui.Separator();
                    ImGui.TreePop();
                }

                if (ImGui.TreeNode("Advanced & Close Button"))
                {
                    // Expose a couple of the available flags. In most cases you may just call BeginTabBar() with no flags (0).
                    ImGui.CheckboxFlags("ImGuiTabBarFlags_Reorderable", ref s_tab_bar_flags, (uint)ImGuiTabBarFlags.Reorderable);
                    ImGui.CheckboxFlags("ImGuiTabBarFlags_AutoSelectNewTabs", ref s_tab_bar_flags, (uint)ImGuiTabBarFlags.AutoSelectNewTabs);
                    ImGui.CheckboxFlags("ImGuiTabBarFlags_NoCloseWithMiddleMouseButton", ref s_tab_bar_flags, (uint)ImGuiTabBarFlags.NoCloseWithMiddleMouseButton);

                    if ((s_tab_bar_flags & (uint)ImGuiTabBarFlags.FittingPolicyMask) == 0)
                    {
                        s_tab_bar_flags |= (uint)ImGuiTabBarFlags.FittingPolicyDefault;
                    }
                    if (ImGui.CheckboxFlags("ImGuiTabBarFlags_FittingPolicyResizeDown", ref s_tab_bar_flags, (uint)ImGuiTabBarFlags.FittingPolicyResizeDown))
                    {
                        s_tab_bar_flags &= ~((uint)ImGuiTabBarFlags.FittingPolicyMask ^ (uint)ImGuiTabBarFlags.FittingPolicyResizeDown);
                    }
                    if (ImGui.CheckboxFlags("ImGuiTabBarFlags_FittingPolicyScroll", ref s_tab_bar_flags, (uint)ImGuiTabBarFlags.FittingPolicyScroll))
                    {
                        s_tab_bar_flags &= ~((uint)ImGuiTabBarFlags.FittingPolicyMask ^ (uint)ImGuiTabBarFlags.FittingPolicyScroll);
                    }

                    // Tab Bar
                    string[] names = { "Artichoke", "Beetroot", "Celery", "Daikon" };

                    for (int n = 0; n < s_opened.Length; n++)
                    {
                        if (n > 0)
                        {
                            ImGui.SameLine();
                        }
                        ImGui.Checkbox(names[n], ref s_opened[n]);
                    }

                    // Passing a bool* to BeginTabItem() is similar to passing one to Begin(): the underlying bool will be set to false when the tab is closed.
                    if (ImGui.BeginTabBar("MyTabBar", (ImGuiTabBarFlags)s_tab_bar_flags))
                    {
                        for (int n = 0; n < s_opened.Length; n++)
                        {
                            if (s_opened[n] && ImGui.BeginTabItem(names[n], ref s_opened[n]))
                            {
                                ImGui.Text($"This is the {names[n]} tab!");
                                if ((n & 1) != 0)
                                {
                                    ImGui.Text("I am an odd tab.");
                                }
                                ImGui.EndTabItem();
                            }
                        }
                        ImGui.EndTabBar();
                    }
                    ImGui.Separator();
                    ImGui.TreePop();
                }
                ImGui.TreePop();
            }

            ImGuiIOPtr io = ImGui.GetIO();

            SetThing(out io.DeltaTime, 2f);

            if (_showMemoryEditor)
            {
                _memoryEditor.Draw("Memory Editor", _memoryEditorData, _memoryEditorData.Length);
            }
        }
Ejemplo n.º 7
0
 void Popups()
 {
     //Hex Editor
     if (hexEditor)
     {
         ImGui.OpenPopup("HexEditor");
         hexEditor = false;
     }
     if (ImGui.BeginPopupModal("HexEditor"))
     {
         ImGui.PushFont(ImGuiHelper.Default);
         int res;
         if ((res = mem.Draw("Hex", hexdata, hexdata.Length, 0)) != 0)
         {
             if (res == 1)
             {
                 selectedNode.Data = hexdata;
             }
             ImGui.CloseCurrentPopup();
         }
         ImGui.PopFont();
         ImGui.EndPopup();
     }
     //Rename dialog
     if (doRename)
     {
         ImGui.OpenPopup("Rename");
         doRename = false;
     }
     if (ImGui.BeginPopupModal("Rename", WindowFlags.AlwaysAutoResize))
     {
         ImGui.Text("Name: ");
         ImGui.SameLine();
         ImGui.InputText("", text.Pointer, text.Size, InputTextFlags.Default, text.Callback);
         if (ImGui.Button("Ok"))
         {
             renameNode.Name = text.GetText();
             ImGui.CloseCurrentPopup();
         }
         ImGui.SameLine();
         if (ImGui.Button("Cancel"))
         {
             ImGui.CloseCurrentPopup();
         }
         ImGui.EndPopup();
     }
     //Delete dialog
     if (doDelete)
     {
         ImGui.OpenPopup("Delete");
         doDelete = false;
     }
     if (ImGui.BeginPopupModal("Delete", WindowFlags.AlwaysAutoResize))
     {
         ImGui.Text("Are you sure you want to delete: '" + deleteNode.Name + "'?");
         if (ImGui.Button("Ok"))
         {
             deleteParent.Children.Remove(deleteNode);
             ImGui.CloseCurrentPopup();
         }
         ImGui.SameLine();
         if (ImGui.Button("Cancel"))
         {
             ImGui.CloseCurrentPopup();
         }
         ImGui.EndPopup();
     }
 }
Ejemplo n.º 8
0
        unsafe void Popups()
        {
            //Hex Editor
            if (hexEditor)
            {
                ImGui.OpenPopup("HexEditor##" + Unique);
                hexEditor = false;
            }
            if (ImGui.BeginPopupModal("HexEditor##" + Unique))
            {
                ImGui.PushFont(ImGuiHelper.Default);
                int res;
                if ((res = mem.Draw("Hex", hexdata, hexdata.Length, 0)) != 0)
                {
                    if (res == 1)
                    {
                        selectedNode.Data = hexdata;
                    }
                    ImGui.CloseCurrentPopup();
                }
                ImGui.PopFont();
                ImGui.EndPopup();
            }
            //Color Picker
            if (colorPicker)
            {
                ImGui.OpenPopup("Color Picker##" + Unique);
                colorPicker = false;
            }
            if (ImGui.BeginPopupModal("Color Picker##" + Unique, WindowFlags.AlwaysAutoResize))
            {
                bool old4 = pickcolor4;
                ImGui.Checkbox("Alpha?", ref pickcolor4);
                if (old4 != pickcolor4)
                {
                    if (old4 == false)
                    {
                        color4 = new System.Numerics.Vector4(color3.X, color3.Y, color3.Z, 1);
                    }
                    if (old4 == true)
                    {
                        color3 = new System.Numerics.Vector3(color4.X, color4.Y, color4.Z);
                    }
                }
                ImGui.Separator();
                if (pickcolor4)
                {
                    ImGui.ColorPicker4("Color", ref color4, ColorEditFlags.AlphaPreview | ColorEditFlags.AlphaBar);
                }
                else
                {
                    ImGui.ColorPicker3("Color", ref color3);
                }
                ImGui.Separator();
                if (ImGui.Button("Ok"))
                {
                    ImGui.CloseCurrentPopup();
                    if (pickcolor4)
                    {
                        var bytes = new byte[16];
                        fixed(byte *ptr = bytes)
                        {
                            var f = (System.Numerics.Vector4 *)ptr;

                            f[0] = color4;
                        }

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

                            f[0] = color3;
                        }

                        selectedNode.Data = bytes;
                    }
                }
                ImGui.SameLine();
                if (ImGui.Button("Cancel"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            //Float Editor
            if (floatEditor)
            {
                ImGui.OpenPopup("Float Editor##" + Unique);
                floatEditor = false;
            }
            DataEditors.FloatEditor("Float Editor##" + Unique, ref floats, selectedNode);
            if (intEditor)
            {
                ImGui.OpenPopup("Int Editor##" + Unique);
                intEditor = false;
            }
            DataEditors.IntEditor("Int Editor##" + Unique, ref ints, ref intHex, selectedNode);
            //Rename dialog
            if (doRename)
            {
                ImGui.OpenPopup("Rename##" + Unique);
                doRename = false;
            }
            if (ImGui.BeginPopupModal("Rename##" + Unique, WindowFlags.AlwaysAutoResize))
            {
                ImGui.Text("Name: ");
                ImGui.SameLine();
                ImGui.InputText("", text.Pointer, text.Size, InputTextFlags.Default, text.Callback);
                if (ImGui.Button("Ok"))
                {
                    renameNode.Name = text.GetText();
                    ImGui.CloseCurrentPopup();
                }
                ImGui.SameLine();
                if (ImGui.Button("Cancel"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            //Delete dialog
            if (doDelete)
            {
                ImGui.OpenPopup("Delete##" + Unique);
                doDelete = false;
            }
            if (ImGui.BeginPopupModal("Delete##" + Unique, WindowFlags.AlwaysAutoResize))
            {
                ImGui.Text("Are you sure you want to delete: '" + deleteNode.Name + "'?");
                if (ImGui.Button("Ok"))
                {
                    deleteParent.Children.Remove(deleteNode);
                    ImGui.CloseCurrentPopup();
                }
                ImGui.SameLine();
                if (ImGui.Button("Cancel"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            //Error
            if (doError)
            {
                ImGui.OpenPopup("Error##" + Unique);
                doError = false;
            }
            if (ImGui.BeginPopupModal("Error##" + Unique, WindowFlags.AlwaysAutoResize))
            {
                ImGui.Text(errorText);
                if (ImGui.Button("Ok"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
        }
Ejemplo n.º 9
0
        public static void Render(FMAT material)
        {
            var renderer = material.MaterialAsset as BfshaRenderer;

            if (ImGui.BeginCombo("Stage", selectedStage))
            {
                if (ImGui.Selectable("Vertex"))
                {
                    selectedStage = "Vertex";
                }
                if (ImGui.Selectable("Pixel"))
                {
                    selectedStage = "Pixel";
                }
                ImGui.EndCombo();
            }

            ImGui.BeginTabBar("menu_shader1");
            if (ImguiCustomWidgets.BeginTab("menu_shader1", $"Shader Code"))
            {
                if (renderer.GLShaderInfo != null)
                {
                    LoadShaderStageCode(material);
                }
                ImGui.EndTabItem();
            }
            if (ImguiCustomWidgets.BeginTab("menu_shader1", "Shader Info"))
            {
                if (ImGui.BeginChild("ShaderInfoC"))
                {
                    LoadShaderInfo(material);
                }
                ImGui.EndChild();
                ImGui.EndTabItem();
            }

            if (renderer.GLShaderInfo != null)
            {
                if (ImguiCustomWidgets.BeginTab("menu_shader1", "Shader Constants"))
                {
                    if (selectedStage == "Vertex")
                    {
                        var constants = renderer.GLShaderInfo.VertexConstants;
                        if (constants != null)
                        {
                            MemoryEditor.Draw(constants, constants.Length);
                        }
                    }
                    if (selectedStage == "Pixel")
                    {
                        var constants = renderer.GLShaderInfo.PixelConstants;
                        if (constants != null)
                        {
                            MemoryEditor.Draw(constants, constants.Length);
                        }
                    }
                    ImGui.EndTabItem();
                }
            }

            ImGui.EndTabBar();
        }