bool drawEffectChooserPopup()
        {
            var createdEffect = false;

            if (ImGui.BeginPopup("effect-chooser"))
            {
                foreach (var subclassType in InspectorCache.getAllEffectSubclassTypes())
                {
                    if (ImGui.Selectable(subclassType.Name))
                    {
                        // create the Effect, remove the existing EffectInspector and create a new one
                        var effect   = Activator.CreateInstance(subclassType) as Effect;
                        var material = getValue <Material>();
                        material.effect = effect;

                        for (var i = _inspectors.Count - 1; i >= 0; i--)
                        {
                            if (_inspectors[i].GetType() == typeof(EffectInspector))
                            {
                                _inspectors.RemoveAt(i);
                            }
                        }

                        var inspector = new EffectInspector();
                        inspector.setTarget(material, ReflectionUtils.getFieldInfo(material, "effect"));
                        inspector.initialize();
                        _inspectors.Add(inspector);

                        createdEffect = true;
                    }
                }
                ImGui.EndPopup();
            }
            return(createdEffect);
        }
 public void ShortcutPopups()
 {
     if (ImGui.BeginPopup("ctrlVPopup"))
     {
         ImGui.InputText("Offset", ref _currentCtrlVInput, 20);
         long offset = 0;
         try
         {
             offset = int.Parse(_currentCtrlVInput);
         }
         catch
         {
             ImGui.EndPopup();
             return;
         }
         if (ImGui.Selectable("Submit"))
         {
             List <PARAM.Row> rowsToInsert = new List <PARAM.Row>();
             if (!_selection.rowSelectionExists())
             {
                 foreach (PARAM.Row r in _clipboardRows)
                 {
                     PARAM.Row newrow = new PARAM.Row(r);// more cloning
                     newrow.ID = r.ID + offset;
                     rowsToInsert.Add(newrow);
                 }
             }
             EditorActionManager.ExecuteAction(new AddParamsAction(ParamBank.Params[_clipboardParam], "legacystring", rowsToInsert, false));
         }
         ImGui.EndPopup();
     }
 }
예제 #3
0
        private void RenderTree()
        {
            if (ImGui.BeginChild("Scene"))
            {
                for (int i = 0; i < currentSceneEntities.Count; i++)
                {
                    RecursivelyRender(currentSceneEntities[i]);
                }

                if (!ImGui.IsAnyItemHovered() && ImGui.IsWindowHovered(ImGuiHoveredFlags.ChildWindows))
                {
                    if (ImGui.IsMouseClicked(ImGuiMouseButton.Right))
                    {
                        ImGui.OpenPopup("Entity Menu");
                    }

                    if (ImGui.IsMouseClicked(ImGuiMouseButton.Left))
                    {
                        SelectedEntity = null;
                    }
                }

                if (ImGui.BeginPopup("Entity Menu"))
                {
                    if (ImGui.MenuItem("New Entity"))
                    {
                        _ = new Entity("New Entity");
                    }

                    ImGui.EndPopup();
                }

                ImGui.EndChild();
            }
        }
예제 #4
0
        public static void DropdownButton(string id, ref int selected, IReadOnlyList <DropdownOption> options)
        {
            ImGui.PushID(id);
            bool   clicked  = false;
            string text     = $"{options[selected].Icon}  {options[selected].Name}  ";
            var    textSize = ImGui.CalcTextSize(text);
            var    cpos     = ImGuiNative.igGetCursorPosX();
            var    cposY    = ImGuiNative.igGetCursorPosY();

            clicked = ImGui.Button($"{options[selected].Icon}  {options[selected].Name}  ");
            var style = ImGui.GetStyle();
            var tPos  = new Vector2(cpos, cposY) + new Vector2(textSize.X + style.FramePadding.X, textSize.Y);

            Theme.TinyTriangle(tPos.X, tPos.Y);
            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.Icon, opt.Name, true))
                    {
                        selected = i;
                    }
                }
                ImGui.EndPopup();
            }
            ImGui.PopID();
        }
예제 #5
0
파일: Tool.cs 프로젝트: 0000duck/MiniRTS
        private void ChangeTool(Type type, Property property)
        {
            ImGui.OpenPopup("Tool Picker");
            if (ImGui.BeginPopup("Tool Picker"))
            {
                var allTools = this.ToolSelector.GetAllTools(type);
                var bestTool = this.ToolSelector.GetBestTool(type, this.changingState);

                var index = Array.IndexOf(allTools.Tools, bestTool);
                if (ImGui.Combo("Tools", ref index, allTools.Names, allTools.Names.Length))
                {
                    this.changingState.Name = allTools.Tools[index].Name;
                }

                ImGui.Separator();
                this.changingState = bestTool.Configure(this.changingState);
                ImGui.Separator();

                if (ImGui.Button("Save"))
                {
                    this.LinkedTools.Link(property, this.changingState);
                    this.Deactivate();
                }
                ImGui.SameLine();
                if (ImGui.Button("Cancel"))
                {
                    this.Deactivate();
                }

                ImGui.EndPopup();
            }
        }
예제 #6
0
        public override bool Show(uint dockSpaceId)
        {
            //Initialize debug window
            ImGui.SetNextWindowSize(new System.Numerics.Vector2(450, 200));
            if (!ImGui.Begin("Debug", ref _isVisible))
            {
                ImGui.End();
                return(false);
            }

            // Adds options to popup menu
            if (ImGui.BeginPopup("Options"))
            {
                ImGui.Checkbox("Auto-scroll", ref _autoScroll);
                ImGui.EndPopup();
            }

            // Main window
            if (ImGui.Button("Options"))
            {
                ImGui.OpenPopup("Options");
            }

            ImGui.SameLine();
            var clear = ImGui.Button("Clear");

            ImGui.SameLine();
            var copy = ImGui.Button("Copy");

            ImGui.Separator();

            // Creates child component with scrolling
            ImGui.BeginChild("ScrollBox", new System.Numerics.Vector2(0, 0), true,
                             ImGuiWindowFlags.HorizontalScrollbar);
            if (clear)
            {
                Clear();
            }

            if (copy)
            {
                ImGui.LogToClipboard();
            }

            foreach (var line in _debugListBuffer)
            {
                ImGui.TextUnformatted(line);
            }


            if (AutoScroll && ImGui.GetScrollY() >= ImGui.GetScrollMaxY())
            {
                ImGui.SetScrollHereY(1.0f);
            }

            ImGui.EndChild();
            ImGui.End();
            return(true);
        }
예제 #7
0
        public void Draw()
        {
            if (ImGui.BeginPopup(m_PopupID, ImGuiWindowFlags.AlwaysAutoResize))
            {
                DrawList();

                ImGui.EndPopup();
            }
        }
예제 #8
0
        public bool Draw()
        {
            ImGui.SetNextWindowSize(new Vector2(500, 400), ImGuiCond.FirstUseEver);

            var isOpen = true;

            if (!ImGui.Begin("Dalamud LOG", ref isOpen, ImGuiWindowFlags.NoCollapse))
            {
                ImGui.End();
                return(false);
            }

            // Options menu
            if (ImGui.BeginPopup("Options"))
            {
                ImGui.Checkbox("Auto-scroll", ref this.autoScroll);
                ImGui.EndPopup();
            }

            // Main window
            if (ImGui.Button("Options"))
            {
                ImGui.OpenPopup("Options");
            }
            ImGui.SameLine();
            var clear = ImGui.Button("Clear");

            ImGui.SameLine();
            var copy = ImGui.Button("Copy");

            ImGui.BeginChild("scrolling", new Vector2(0, 0), false, ImGuiWindowFlags.HorizontalScrollbar);

            if (clear)
            {
                Clear();
            }
            if (copy)
            {
                ImGui.LogToClipboard();
            }

            ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(0, 0));

            ImGui.TextUnformatted(this.logText);

            ImGui.PopStyleVar();

            if (this.autoScroll && ImGui.GetScrollY() >= ImGui.GetScrollMaxY())
            {
                ImGui.SetScrollHereY(1.0f);
            }

            ImGui.EndChild();
            ImGui.End();

            return(isOpen);
        }
예제 #9
0
        private void ItemCreatePopup(List <Shortcut> shortcuts)
        {
            if (ImGui.BeginPopup("addItem"))
            {
                _sh ??= new Shortcut();
                ItemBaseUI(_sh, false);

                if (ImGui.Button("Create"))
                {
                    shortcuts.Add(_sh);
                    config.Save();
                    _sh = null;
                    ImGui.CloseCurrentPopup();
                }
                ImGui.SameLine();
                if (ImGui.Button("Import"))
                {
                    try
                    {
                        shortcuts.Add(plugin.ImportShortcut(ImGui.GetClipboardText()));
                        config.Save();
                        ImGui.CloseCurrentPopup();
                    }
                    catch (Exception e) // Try as a bar instead
                    {
                        try
                        {
                            var bar = plugin.ImportBar(ImGui.GetClipboardText());
                            foreach (var sh in bar.ShortcutList)
                            {
                                shortcuts.Add(sh);
                            }
                            config.Save();
                            ImGui.CloseCurrentPopup();
                        }
                        catch (Exception e2)
                        {
                            PluginLog.LogError("Invalid import string!");
                            PluginLog.LogError($"{e.GetType()}\n{e.Message}");
                            PluginLog.LogError($"{e2.GetType()}\n{e2.Message}");
                        }
                    }
                }
                if (ImGui.IsItemHovered())
                {
                    ImGui.SetTooltip("Import a shortcut from the clipboard,\n" +
                                     "or import all of another bar's shortcuts.");
                }

                ClampWindowPos();

                ImGui.EndPopup();
            }
        }
예제 #10
0
 public void MassEditPopups()
 {
     // Popup size relies on magic numbers. Multiline maxlength is also arbitrary.
     if (ImGui.BeginPopup("massEditMenuRegex"))
     {
         ImGui.Text("selection: FIELD: ((=|+|-|*|/) VALUE | ref ROW);");
         ImGui.Text("param PARAM: (id VALUE | name ROW | prop FIELD VALUE | propref FIELD ROW): FIELD: ((=|+|-|*|/) VALUE | ref ROW);");
         ImGui.InputTextMultiline("MEditRegexInput", ref _currentMEditRegexInput, 65536, new Vector2(1024, 256));
         if (ImGui.Selectable("Submit", false, ImGuiSelectableFlags.DontClosePopups))
         {
             MassEditResult r = MassParamEditRegex.PerformMassEdit(_currentMEditRegexInput, EditorActionManager, _selection.getActiveParam(), _selection.getSelectedRows());
             if (r.Type == MassEditResultType.SUCCESS)
             {
                 _lastMEditRegexInput    = _currentMEditRegexInput;
                 _currentMEditRegexInput = "";
             }
             _mEditRegexResult = r.Information;
         }
         ImGui.Text(_mEditRegexResult);
         ImGui.InputTextMultiline("MEditRegexOutput", ref _lastMEditRegexInput, 65536, new Vector2(1024, 256), ImGuiInputTextFlags.ReadOnly);
         ImGui.EndPopup();
     }
     else if (ImGui.BeginPopup("massEditMenuCSVExport"))
     {
         ImGui.InputTextMultiline("MEditOutput", ref _currentMEditCSVOutput, 65536, new Vector2(1024, 256), ImGuiInputTextFlags.ReadOnly);
         ImGui.EndPopup();
     }
     else if (ImGui.BeginPopup("massEditMenuCSVImport"))
     {
         ImGui.InputTextMultiline("MEditRegexInput", ref _currentMEditCSVInput, 256 * 65536, new Vector2(1024, 256));
         if (ImGui.Selectable("Submit", false, ImGuiSelectableFlags.DontClosePopups))
         {
             MassEditResult r = MassParamEditCSV.PerformMassEdit(_currentMEditCSVInput, EditorActionManager, _selection.getActiveParam());
             if (r.Type == MassEditResultType.SUCCESS)
             {
                 _lastMEditRegexInput    = _currentMEditRegexInput;
                 _currentMEditRegexInput = "";
             }
             _mEditCSVResult = r.Information;
         }
         ImGui.Text(_mEditCSVResult);
         ImGui.EndPopup();
     }
     else
     {
         _isMEditPopupOpen      = false;
         _currentMEditCSVOutput = "";
     }
 }
예제 #11
0
            private void DrawModAddPopup()
            {
                if (!ImGui.BeginPopup(LabelAddModPopup))
                {
                    return;
                }

                using var raii = ImGuiRaii.DeferredEnd(ImGui.EndPopup);

                if (_modAddKeyboardFocus)
                {
                    ImGui.SetKeyboardFocusHere();
                    _modAddKeyboardFocus = false;
                }

                var newName = "";

                if (ImGui.InputTextWithHint("##AddMod", "New Mod Name...", ref newName, 64, ImGuiInputTextFlags.EnterReturnsTrue))
                {
                    try
                    {
                        var newDir = TexToolsImport.CreateModFolder(new DirectoryInfo(Penumbra.Config !.ModDirectory),
                                                                    newName);
                        var modMeta = new ModMeta
                        {
                            Author      = "Unknown",
                            Name        = newName.Replace('/', '\\'),
                            Description = string.Empty,
                        };

                        var metaFile = new FileInfo(Path.Combine(newDir.FullName, "meta.json"));
                        modMeta.SaveToFile(metaFile);
                        _modManager.AddMod(newDir);
                        ModFileSystem.InvokeChange();
                        SelectModOnUpdate(newDir.Name);
                    }
                    catch (Exception e)
                    {
                        PluginLog.Error($"Could not create directory for new Mod {newName}:\n{e}");
                    }

                    ImGui.CloseCurrentPopup();
                }

                if (ImGui.IsKeyPressed(ImGui.GetKeyIndex(ImGuiKey.Escape)))
                {
                    ImGui.CloseCurrentPopup();
                }
            }
예제 #12
0
        private static void IconButtonDemo()
        {
            ImGui.Text("Click on the icon to use as a button.");
            ImGui.SameLine();
            if (ImGuiComponents.IconButton(1, FontAwesomeIcon.Carrot))
            {
                ImGui.OpenPopup("IconButtonDemoPopup");
            }

            if (ImGui.BeginPopup("IconButtonDemoPopup"))
            {
                ImGui.Text("You clicked!");
                ImGui.EndPopup();
            }
        }
예제 #13
0
        public void DrawTypeDict()
        {
            if (ImGui.BeginPopup(m_ID, ImGuiWindowFlags.AlwaysAutoResize))
            {
                ImGui.InputTextWithHint("##seach text", "seach", ref m_InputText, 20);
                int i = 0;
                foreach (var pair in m_StringTypeDict)
                {
                    if (ImGui.Selectable(pair.Key) && m_Handler != null)
                    {
                        m_Handler(pair.Key, i);
                        ++i;
                    }
                }
                //DrawList();

                ImGui.EndPopup();
            }
        }
예제 #14
0
 void DrawMethodMenu(string name, MethodInfo method, object instance = null)
 {
     if (ImGui.BeginPopup(name))
     {
         if (ImGui.Button("Call"))
         {
             if (CanInvoke(method, instance))
             {
                 MethodInvokeWindow.GetInstance().Show(method, method.GetParameters(), instance);
             }
             else
             {
                 ImGui.CloseCurrentPopup();
             }
         }
         ImGui.Button("Hook");
         ImGui.EndPopup();
     }
 }
 public void ShortcutPopups()
 {
     if (ImGui.BeginPopup("ctrlVPopup"))
     {
         long offset = 0;
         try
         {
             ImGui.InputText("Row", ref _currentCtrlVValue, 20);
             if (ImGui.IsItemEdited())
             {
                 offset = (long)ulong.Parse(_currentCtrlVValue) - _clipboardBaseRow;
                 _currentCtrlVOffset = offset.ToString();
             }
             ImGui.InputText("Offset", ref _currentCtrlVOffset, 20);
             if (ImGui.IsItemEdited())
             {
                 offset             = long.Parse(_currentCtrlVOffset);
                 _currentCtrlVValue = (_clipboardBaseRow + offset).ToString();
             }
             // Recheck that this is valid
             offset = (long)ulong.Parse(_currentCtrlVValue);
             offset = long.Parse(_currentCtrlVOffset);
         }
         catch
         {
             ImGui.EndPopup();
             return;
         }
         if (ImGui.Selectable("Submit"))
         {
             List <PARAM.Row> rowsToInsert = new List <PARAM.Row>();
             foreach (PARAM.Row r in _clipboardRows)
             {
                 PARAM.Row newrow = new PARAM.Row(r);// more cloning
                 newrow.ID = r.ID + offset;
                 rowsToInsert.Add(newrow);
             }
             EditorActionManager.ExecuteAction(new AddParamsAction(ParamBank.Params[_clipboardParam], "legacystring", rowsToInsert, false));
         }
         ImGui.EndPopup();
     }
 }
        static bool EditColor(string label, string id, object obj, string properyName)
        {
            var input      = obj.GetType().GetProperty(properyName);
            var inputValue = (STColor)input.GetValue(obj);
            var color      = new Vector4(inputValue.R, inputValue.G, inputValue.B, inputValue.A);

            ImGui.Columns(2);

            var flags = ImGuiColorEditFlags.HDR;

            if (ImGui.ColorButton($"colorBtn{id}", color, flags, new Vector2(200, 22)))
            {
                ImGui.OpenPopup($"colorPicker{id}");
            }

            ImGui.NextColumn();
            ImGui.Text(label);

            ImGui.Columns(1);

            bool edited = false;

            if (ImGui.BeginPopup($"colorPicker{id}"))
            {
                if (ImGui.ColorPicker4("##picker", ref color, flags
                                       | ImGuiColorEditFlags.Float | ImGuiColorEditFlags.DisplayRGB
                                       | ImGuiColorEditFlags.DisplayHex | ImGuiColorEditFlags.DisplayHSV))
                {
                    input.SetValue(obj, new STColor()
                    {
                        R = color.X,
                        G = color.Y,
                        B = color.Z,
                        A = color.W,
                    });
                    edited = true;
                }
                ImGui.EndPopup();
            }
            return(edited);
        }
예제 #17
0
        public override void OnGUIInspector(object userData)
        {
            Camera camera = userData as Camera;

            if (camera == null)
            {
                return;
            }

            base.OnGUIInspector(userData);

            if (ImGui.CollapsingHeader("Camera##Inspector", treeNodeFlags))
            {
                float   r = 0, g = 0, b = 0, a = 0;;
                Vector4 color = ImGui.ColorConvertU32ToFloat4(camera.clearColor);
                a = color.X;
                b = color.Y;
                g = color.Z;
                r = color.W;
                Vector4 color4 = Vector4.Zero;
                color4.X = r;
                color4.Y = g;
                color4.Z = b;
                color4.W = a;
                ImGui.ColorEdit4("Background", ref color4); ImGui.SameLine();
                if (ImGui.Button("↙##Inspector##Camera##PickColor"))
                {
                    ImGui.OpenPopup("PickColor##RightMenu##Inspector##Camera");
                }
                if (ImGui.BeginPopup("PickColor##RightMenu##Inspector##Camera"))
                {
                    ImGui.ColorPicker4("PickColor##Inspector##Camera#", ref color4);
                    ImGui.EndPopup();
                }
                color.W           = color4.X;
                color.Z           = color4.Y;
                color.Y           = color4.Z;
                color.X           = color4.W;
                camera.clearColor = ImGui.ColorConvertFloat4ToU32(color4);
            }
        }
예제 #18
0
        private static bool DrawDeleteButton(FontAwesomeIcon buttonLabel, Vector2?buttonSize = null,
                                             string?tooltipText = null)
        {
            ImGui.PushStyleColor(ImGuiCol.Button, Vector4.Zero);
            ImGui.PushFont(UiBuilder.IconFont);
            var isButtonPressed = buttonSize is null
                ? ImGui.Button(buttonLabel.ToIconString())
                : ImGui.Button(buttonLabel.ToIconString(), buttonSize.Value);

            ImGui.PopFont();
            ImGui.PopStyleColor();
            if (isButtonPressed)
            {
                ImGui.OpenPopup("Sure?");
            }
            if (tooltipText is not null && ImGui.IsItemHovered())
            {
                ImGui.BeginTooltip();
                ImGui.Text(tooltipText);
                ImGui.EndTooltip();
            }

            if (!ImGui.BeginPopup("Sure?"))
            {
                return(false);
            }
            var consent = false;

            ImGui.Text("Really delete?");
            if (ImGui.Button("Yes"))
            {
                consent = true;
                ImGui.CloseCurrentPopup();
            }

            ImGui.EndPopup();
            return(consent);
        }