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 = "";
     }
 }
        public void OnGUI(string[] initcmd)
        {
            if (!_isMEditPopupOpen && !_isShortcutPopupOpen && !_isSearchBarActive)// Are shortcuts active? Presently just checks for massEdit popup.
            {
                // Keyboard shortcuts
                if (EditorActionManager.CanUndo() && InputTracker.GetControlShortcut(Key.Z))
                {
                    EditorActionManager.UndoAction();
                }
                if (EditorActionManager.CanRedo() && InputTracker.GetControlShortcut(Key.Y))
                {
                    EditorActionManager.RedoAction();
                }
                if (InputTracker.GetControlShortcut(Key.C))
                {
                    _clipboardParam = _selection.getActiveParam();
                    _clipboardRows.Clear();
                    foreach (PARAM.Row r in _selection.getSelectedRows())
                    {
                        _clipboardRows.Add(new PARAM.Row(r));// make a clone
                    }
                }
                if (_selection.paramSelectionExists() && _clipboardParam == _selection.getActiveParam() && InputTracker.GetControlShortcut(Key.V))
                {
                    ImGui.OpenPopup("ctrlVPopup");
                }
                if (InputTracker.GetControlShortcut(Key.D))
                {
                    if (_selection.rowSelectionExists())
                    {
                        var act = new AddParamsAction(ParamBank.Params[_selection.getActiveParam()], _selection.getActiveParam(), new List <PARAM.Row>()
                        {
                            _selection.getActiveRow()
                        }, true);
                        EditorActionManager.ExecuteAction(act);
                    }
                }
                if (InputTracker.GetKeyDown(Key.Delete))
                {
                    if (_selection.rowSelectionExists())
                    {
                        var act = new DeleteParamsAction(ParamBank.Params[_selection.getActiveParam()], new List <PARAM.Row>()
                        {
                            _selection.getActiveRow()
                        });
                        EditorActionManager.ExecuteAction(act);
                        _selection.SetActiveRow(null);
                    }
                }
            }

            ShortcutPopups();

            if (ParamBank.Params == null)
            {
                if (ParamBank.IsLoading)
                {
                    ImGui.Text("Loading...");
                }
                return;
            }

            bool doFocus = false;

            // Parse select commands
            if (initcmd != null && initcmd[0] == "select")
            {
                if (initcmd.Length > 1 && ParamBank.Params.ContainsKey(initcmd[1]))
                {
                    doFocus = true;
                    _selection.setActiveParam(initcmd[1]);
                    if (initcmd.Length > 2)
                    {
                        _selection.SetActiveRow(null);
                        var p = ParamBank.Params[_selection.getActiveParam()];
                        int id;
                        var parsed = int.TryParse(initcmd[2], out id);
                        if (parsed)
                        {
                            var r = p.Rows.FirstOrDefault(r => r.ID == id);
                            if (r != null)
                            {
                                _selection.SetActiveRow(r);
                            }
                        }
                    }
                }
            }

            ImGui.Columns(3);
            ImGui.BeginChild("params");
            foreach (var param in ParamBank.Params)
            {
                if (ImGui.Selectable(param.Key, param.Key == _selection.getActiveParam()))
                {
                    _selection.setActiveParam(param.Key);
                    //_selection.SetActiveRow(null);
                }
                if (doFocus && param.Key == _selection.getActiveParam())
                {
                    ImGui.SetScrollHereY();
                }
            }
            ImGui.EndChild();
            ImGui.NextColumn();
            if (!_selection.paramSelectionExists())
            {
                ImGui.BeginChild("rowsNONE");
                ImGui.Text("Select a param to see rows");
            }
            else
            {
                if (FeatureFlags.EnableEnhancedParamEditor)
                {
                    ImGui.Text("id VALUE | name ROW | prop FIELD VALUE | propref FIELD ROW");
                    ImGui.InputText("Search rows...", ref _selection.getCurrentSearchString(), 256);
                    if (ImGui.IsItemActive())
                    {
                        _isSearchBarActive = true;
                    }
                    else
                    {
                        _isSearchBarActive = false;
                    }
                }
                ImGui.BeginChild("rows" + _selection.getActiveParam());
                IParamDecorator decorator = null;
                if (_decorators.ContainsKey(_selection.getActiveParam()))
                {
                    decorator = _decorators[_selection.getActiveParam()];
                }

                PARAM            para = ParamBank.Params[_selection.getActiveParam()];
                List <PARAM.Row> p;
                if (FeatureFlags.EnableEnhancedParamEditor)
                {
                    Match m = new Regex(MassParamEditRegex.rowfilterRx).Match(_selection.getCurrentSearchString());
                    if (!m.Success)
                    {
                        p = para.Rows;
                    }
                    else
                    {
                        p = MassParamEditRegex.GetMatchingParamRows(para, m, true, true);
                    }
                }
                else
                {
                    p = para.Rows;
                }

                foreach (var r in p)
                {
                    if (ImGui.Selectable($@"{r.ID} {r.Name}", _selection.getSelectedRows().Contains(r)))
                    {
                        if (InputTracker.GetKey(Key.LControl))
                        {
                            _selection.toggleRowInSelection(r);
                        }
                        else
                        {
                            if (InputTracker.GetKey(Key.LShift))
                            {
                                _selection.cleanSelectedRows();
                                int start = p.IndexOf(_selection.getActiveRow());
                                int end   = p.IndexOf(r);
                                if (start != end)
                                {
                                    foreach (var r2 in p.GetRange(start < end ? start : end, Math.Abs(end - start)))
                                    {
                                        _selection.addRowToSelection(r2);
                                    }
                                }
                                _selection.addRowToSelection(r);
                            }
                            else
                            {
                                _selection.SetActiveRow(r);
                            }
                        }
                    }
                    if (decorator != null)
                    {
                        decorator.DecorateContextMenu(r);
                        decorator.DecorateParam(r);
                    }
                    if (doFocus && _selection.getActiveRow() == r)
                    {
                        ImGui.SetScrollHereY();
                    }
                }
            }
            ImGui.EndChild();
            ImGui.NextColumn();
            if (!_selection.rowSelectionExists())
            {
                ImGui.BeginChild("columnsNONE");
                ImGui.Text("Select a row to see properties");
            }
            else
            {
                ImGui.BeginChild("columns" + _selection.getActiveParam());
                _propEditor.PropEditorParamRow(_selection.getActiveRow());
            }
            ImGui.EndChild();
        }
Beispiel #3
0
        public void ParamView(bool doFocus)
        {
            ImGui.Columns(3);
            ImGui.BeginChild("params");
            float scrollTo = 0f;

            foreach (var param in ParamBank.Params)
            {
                if (ImGui.Selectable(param.Key, param.Key == _selection.getActiveParam()))
                {
                    //_selection.setActiveParam(param.Key);
                    EditorCommandQueue.AddCommand($@"param/view/{_viewIndex}/{param.Key}");
                }
                if (doFocus && param.Key == _selection.getActiveParam())
                {
                    scrollTo = ImGui.GetCursorPosY();
                }
            }
            if (doFocus)
            {
                ImGui.SetScrollFromPosY(scrollTo - ImGui.GetScrollY());
            }
            ImGui.EndChild();
            ImGui.NextColumn();
            string activeParam = _selection.getActiveParam();

            if (!_selection.paramSelectionExists())
            {
                ImGui.BeginChild("rowsNONE");
                ImGui.Text("Select a param to see rows");
            }
            else
            {
                PARAM         para       = ParamBank.Params[activeParam];
                HashSet <int> dirtyCache = ParamBank.DirtyParamCache[activeParam];
                ImGui.Text("id VALUE | name ROW | prop FIELD VALUE | propref FIELD ROW");
                UIHints.AddImGuiHintButton("MassEditHint", ref UIHints.SearchBarHint);
                ImGui.InputText("Search rows...", ref _selection.getCurrentRowSearchString(), 256);
                if (ImGui.IsItemActive())
                {
                    _paramEditor._isSearchBarActive = true;
                }
                else
                {
                    _paramEditor._isSearchBarActive = false;
                }
                ImGui.BeginChild("rows" + activeParam);
                IParamDecorator decorator = null;
                if (_paramEditor._decorators.ContainsKey(activeParam))
                {
                    decorator = _paramEditor._decorators[activeParam];
                }
                List <PARAM.Row> p;
                Match            m = ROWFILTERMATCHER.Match(_selection.getCurrentRowSearchString());
                if (!m.Success)
                {
                    p = para.Rows;
                }
                else
                {
                    p = MassParamEditRegex.GetMatchingParamRows(para, m, true, true);
                }

                scrollTo = 0;
                foreach (var r in p)
                {
                    if (dirtyCache != null && dirtyCache.Contains(r.ID))
                    {
                        ImGui.PushStyleColor(ImGuiCol.Text, DIRTYCOLOUR);
                    }
                    else
                    {
                        ImGui.PushStyleColor(ImGuiCol.Text, CLEANCOLOUR);
                    }
                    if (ImGui.Selectable($@"{r.ID} {Utils.ImGuiEscape(r.Name, "")}", _selection.getSelectedRows().Contains(r)))
                    {
                        if (InputTracker.GetKey(Key.LControl))
                        {
                            _selection.toggleRowInSelection(r);
                        }
                        else
                        {
                            if (InputTracker.GetKey(Key.LShift) && _selection.getActiveRow() != null)
                            {
                                _selection.cleanSelectedRows();
                                int start = p.IndexOf(_selection.getActiveRow());
                                int end   = p.IndexOf(r);
                                if (start != end)
                                {
                                    foreach (var r2 in p.GetRange(start < end ? start : end, Math.Abs(end - start)))
                                    {
                                        _selection.addRowToSelection(r2);
                                    }
                                }
                                _selection.addRowToSelection(r);
                            }
                            else
                            {
                                //_selection.SetActiveRow(r);
                                EditorCommandQueue.AddCommand($@"param/view/{_viewIndex}/{activeParam}/{r.ID}");
                            }
                        }
                    }
                    ImGui.PopStyleColor();
                    if (decorator != null)
                    {
                        decorator.DecorateContextMenu(r);
                        decorator.DecorateParam(r);
                    }
                    if (doFocus && _selection.getActiveRow() == r)
                    {
                        scrollTo = ImGui.GetCursorPosY();
                    }
                }
                if (doFocus)
                {
                    ImGui.SetScrollFromPosY(scrollTo - ImGui.GetScrollY());
                }
            }
            PARAM.Row activeRow = _selection.getActiveRow();
            ImGui.EndChild();
            ImGui.NextColumn();
            if (activeRow == null)
            {
                ImGui.BeginChild("columnsNONE");
                ImGui.Text("Select a row to see properties");
            }
            else
            {
                ImGui.BeginChild("columns" + activeParam);
                _propEditor.PropEditorParamRow(activeRow, ParamBank.VanillaParams != null ? ParamBank.VanillaParams[activeParam][activeRow.ID] : null, ref _selection.getCurrentPropSearchString());
            }
            ImGui.EndChild();
        }
Beispiel #4
0
        public void OnGUI(string[] initcmd)
        {
            if (!_isMEditPopupOpen && !_isShortcutPopupOpen && !_isSearchBarActive)// Are shortcuts active? Presently just checks for massEdit popup.
            {
                // Keyboard shortcuts
                if (EditorActionManager.CanUndo() && InputTracker.GetControlShortcut(Key.Z))
                {
                    EditorActionManager.UndoAction();
                    TaskManager.Run("PB:RefreshDirtyCache", false, true, () => ParamBank.refreshParamDirtyCache());
                }
                if (EditorActionManager.CanRedo() && InputTracker.GetControlShortcut(Key.Y))
                {
                    EditorActionManager.RedoAction();
                    TaskManager.Run("PB:RefreshDirtyCache", false, true, () => ParamBank.refreshParamDirtyCache());
                }
                if (!ImGui.IsAnyItemActive() && _activeView._selection.paramSelectionExists() && InputTracker.GetControlShortcut(Key.A))
                {
                    _clipboardParam = _activeView._selection.getActiveParam();
                    Match m = new Regex(MassParamEditRegex.rowfilterRx).Match(_activeView._selection.getCurrentRowSearchString());
                    if (!m.Success)
                    {
                        foreach (PARAM.Row row in ParamBank.Params[_activeView._selection.getActiveParam()].Rows)
                        {
                            _activeView._selection.addRowToSelection(row);
                        }
                    }
                    else
                    {
                        foreach (PARAM.Row row in MassParamEditRegex.GetMatchingParamRows(ParamBank.Params[_activeView._selection.getActiveParam()], m, true, true))
                        {
                            _activeView._selection.addRowToSelection(row);
                        }
                    }
                }
                if (!ImGui.IsAnyItemActive() && _activeView._selection.rowSelectionExists() && InputTracker.GetControlShortcut(Key.C))
                {
                    CopySelectionToClipboard();
                }
                if (_clipboardRows.Count > 00 && _clipboardParam == _activeView._selection.getActiveParam() && !ImGui.IsAnyItemActive() && InputTracker.GetControlShortcut(Key.V))
                {
                    ImGui.OpenPopup("ctrlVPopup");
                }
                if (!ImGui.IsAnyItemActive() && InputTracker.GetKeyDown(Key.Delete))
                {
                    if (_activeView._selection.rowSelectionExists())
                    {
                        var act = new DeleteParamsAction(ParamBank.Params[_activeView._selection.getActiveParam()], _activeView._selection.getSelectedRows());
                        EditorActionManager.ExecuteAction(act);
                        _activeView._selection.SetActiveRow(null, true);
                    }
                }
            }

            if (InputTracker.GetKey(Key.F5) && _projectSettings != null && _projectSettings.GameType == GameType.DarkSoulsIII && ParamBank.IsLoadingParams == false)
            {
                ParamReloader.ReloadMemoryParamsDS3();
            }

            if (ParamBank.Params == null)
            {
                if (ParamBank.IsLoadingParams)
                {
                    ImGui.Text("Loading...");
                }
                return;
            }

            // Parse commands
            bool doFocus = false;

            // Parse select commands
            if (initcmd != null)
            {
                if (initcmd[0] == "select" || initcmd[0] == "view")
                {
                    if (initcmd.Length > 2 && ParamBank.Params.ContainsKey(initcmd[2]))
                    {
                        doFocus = initcmd[0] == "select";
                        if (_activeView._selection.getActiveRow() != null && !ParamBank.IsLoadingVParams)
                        {
                            ParamBank.refreshParamRowDirtyCache(_activeView._selection.getActiveRow(), ParamBank.VanillaParams[_activeView._selection.getActiveParam()], ParamBank.DirtyParamCache[_activeView._selection.getActiveParam()]);
                        }

                        ParamEditorView viewToMofidy = _activeView;
                        if (initcmd[1].Equals("new"))
                        {
                            viewToMofidy = AddView();
                        }
                        else
                        {
                            int  cmdIndex = -1;
                            bool parsable = int.TryParse(initcmd[1], out cmdIndex);
                            if (parsable && cmdIndex >= 0 && cmdIndex < _views.Count)
                            {
                                viewToMofidy = _views[cmdIndex];
                            }
                        }
                        _activeView = viewToMofidy;

                        viewToMofidy._selection.setActiveParam(initcmd[2]);
                        if (initcmd.Length > 3)
                        {
                            viewToMofidy._selection.SetActiveRow(null, doFocus);
                            var p = ParamBank.Params[viewToMofidy._selection.getActiveParam()];
                            int id;
                            var parsed = int.TryParse(initcmd[3], out id);
                            if (parsed)
                            {
                                var r = p.Rows.FirstOrDefault(r => r.ID == id);
                                if (r != null)
                                {
                                    viewToMofidy._selection.SetActiveRow(r, doFocus);
                                }
                            }
                        }
                        if (_activeView._selection.getActiveRow() != null && !ParamBank.IsLoadingVParams)
                        {
                            ParamBank.refreshParamRowDirtyCache(_activeView._selection.getActiveRow(), ParamBank.VanillaParams[_activeView._selection.getActiveParam()], ParamBank.DirtyParamCache[_activeView._selection.getActiveParam()]);
                        }
                    }
                }
                else if (initcmd[0] == "search")
                {
                    if (initcmd.Length > 1)
                    {
                        _activeView._selection.getCurrentRowSearchString() = initcmd[1];
                    }
                }
                else if (initcmd[0] == "menu" && initcmd.Length > 1)
                {
                    if (initcmd[1] == "ctrlVPopup")
                    {
                        ImGui.OpenPopup("ctrlVPopup");
                    }
                    else if (initcmd[1] == "massEditRegex")
                    {
                        _currentMEditRegexInput = initcmd.Length > 2 ? initcmd[2] : _currentMEditRegexInput;
                        OpenMassEditPopup("massEditMenuRegex");
                    }
                    else if (initcmd[1] == "massEditCSVExport")
                    {
                        _activeView._selection.sortSelection();
                        if (_activeView._selection.rowSelectionExists())
                        {
                            _currentMEditCSVOutput = MassParamEditCSV.GenerateCSV(_activeView._selection.getSelectedRows());
                        }
                        OpenMassEditPopup("massEditMenuCSVExport");
                    }
                    else if (initcmd[1] == "massEditCSVImport")
                    {
                        OpenMassEditPopup("massEditMenuCSVImport");
                    }
                    else if (initcmd[1] == "massEditSingleCSVExport" && initcmd.Length > 2)
                    {
                        _activeView._selection.sortSelection();
                        _currentMEditSingleCSVField = initcmd[2];
                        if (_activeView._selection.rowSelectionExists())
                        {
                            _currentMEditCSVOutput = MassParamEditCSV.GenerateSingleCSV(_activeView._selection.getSelectedRows(), _currentMEditSingleCSVField);
                        }
                        OpenMassEditPopup("massEditMenuSingleCSVExport");
                    }
                    else if (initcmd[1] == "massEditSingleCSVImport" && initcmd.Length > 2)
                    {
                        _currentMEditSingleCSVField = initcmd[2];
                        OpenMassEditPopup("massEditMenuSingleCSVImport");
                    }
                }
            }

            ShortcutPopups();
            MassEditPopups();

            if (CountViews() == 1)
            {
                _activeView.ParamView(doFocus);
            }
            else
            {
                ImGui.DockSpace(ImGui.GetID("DockSpace_ParamEditorViews"));
                foreach (ParamEditorView view in _views)
                {
                    if (view == null)
                    {
                        continue;
                    }
                    string name = view._selection.getActiveRow() != null?view._selection.getActiveRow().Name : null;

                    string toDisplay = (view == _activeView ? "**" : "") + (name == null || name.Trim().Equals("") ? "Param Editor View" : Utils.ImGuiEscape(name, "null")) + (view == _activeView ? "**" : "");
                    ImGui.SetNextWindowSize(new Vector2(1280.0f, 720.0f), ImGuiCond.Once);
                    ImGui.SetNextWindowDockID(ImGui.GetID("DockSpace_ParamEditorViews"), ImGuiCond.Once);
                    ImGui.Begin($@"{toDisplay}###ParamEditorView##{view._viewIndex}");
                    if (ImGui.IsItemClicked(ImGuiMouseButton.Left))
                    {
                        _activeView = view;
                    }
                    if (ImGui.BeginPopupContextItem())
                    {
                        if (ImGui.MenuItem("Close View"))
                        {
                            RemoveView(view);
                            ImGui.EndMenu();
                            break; //avoid concurrent modification
                        }
                        ImGui.EndMenu();
                    }
                    view.ParamView(doFocus && view == _activeView);
                    ImGui.End();
                }
            }
        }
Beispiel #5
0
        public void MassEditPopups()
        {
            // Popup size relies on magic numbers. Multiline maxlength is also arbitrary.
            if (ImGui.BeginPopup("massEditMenuRegex"))
            {
                ImGui.Text("param PARAM: id VALUE: FIELD: = VALUE;");
                UIHints.AddImGuiHintButton("MassEditHint", ref UIHints.MassEditHint);
                ImGui.InputTextMultiline("MEditRegexInput", ref _currentMEditRegexInput, 65536, new Vector2(1024, ImGui.GetTextLineHeightWithSpacing() * 4));
                if (ImGui.BeginCombo("###", ""))
                {
                    string target = _currentMEditRegexInput.Split('\n').LastOrDefault();
                    foreach (string option in MassParamEditRegex.GetRegexAutocomplete(target, _activeView._selection.getActiveParam()))
                    {
                        if (ImGui.Selectable(target + option))
                        {
                            _currentMEditRegexInput = _currentMEditRegexInput + option;
                        }
                    }
                    ImGui.EndCombo();
                }

                if (ImGui.Selectable("Submit", false, ImGuiSelectableFlags.DontClosePopups))
                {
                    _activeView._selection.sortSelection();
                    MassEditResult r = MassParamEditRegex.PerformMassEdit(_currentMEditRegexInput, EditorActionManager, _activeView._selection.getActiveParam(), _activeView._selection.getSelectedRows());
                    if (r.Type == MassEditResultType.SUCCESS)
                    {
                        _lastMEditRegexInput    = _currentMEditRegexInput;
                        _currentMEditRegexInput = "";
                        TaskManager.Run("PB:RefreshDirtyCache", false, true, () => ParamBank.refreshParamDirtyCache());
                    }
                    _mEditRegexResult = r.Information;
                }
                ImGui.Text(_mEditRegexResult);
                ImGui.InputTextMultiline("MEditRegexOutput", ref _lastMEditRegexInput, 65536, new Vector2(1024, ImGui.GetTextLineHeightWithSpacing() * 4), ImGuiInputTextFlags.ReadOnly);
                ImGui.EndPopup();
            }
            else if (ImGui.BeginPopup("massEditMenuCSVExport"))
            {
                ImGui.InputTextMultiline("MEditOutput", ref _currentMEditCSVOutput, 65536, new Vector2(1024, ImGui.GetTextLineHeightWithSpacing() * 4), ImGuiInputTextFlags.ReadOnly);
                ImGui.EndPopup();
            }
            else if (ImGui.BeginPopup("massEditMenuSingleCSVExport"))
            {
                ImGui.Text(_currentMEditSingleCSVField);
                ImGui.InputTextMultiline("MEditOutput", ref _currentMEditCSVOutput, 65536, new Vector2(1024, ImGui.GetTextLineHeightWithSpacing() * 4), ImGuiInputTextFlags.ReadOnly);
                ImGui.EndPopup();
            }
            else if (ImGui.BeginPopup("massEditMenuCSVImport"))
            {
                ImGui.InputTextMultiline("MEditRegexInput", ref _currentMEditCSVInput, 256 * 65536, new Vector2(1024, ImGui.GetTextLineHeightWithSpacing() * 4));
                ImGui.Checkbox("Append new rows instead of ID based insertion (this will create out-of-order IDs)", ref _mEditCSVAppendOnly);
                if (_mEditCSVAppendOnly)
                {
                    ImGui.Checkbox("Replace existing rows instead of updating them (they will be moved to the end)", ref _mEditCSVReplaceRows);
                }
                if (ImGui.Selectable("Submit", false, ImGuiSelectableFlags.DontClosePopups))
                {
                    MassEditResult r = MassParamEditCSV.PerformMassEdit(_currentMEditCSVInput, EditorActionManager, _activeView._selection.getActiveParam(), _mEditCSVAppendOnly, _mEditCSVAppendOnly && _mEditCSVReplaceRows);
                    if (r.Type == MassEditResultType.SUCCESS)
                    {
                        TaskManager.Run("PB:RefreshDirtyCache", false, true, () => ParamBank.refreshParamDirtyCache());
                    }
                    _mEditCSVResult = r.Information;
                }
                ImGui.Text(_mEditCSVResult);
                ImGui.EndPopup();
            }
            else if (ImGui.BeginPopup("massEditMenuSingleCSVImport"))
            {
                ImGui.Text(_currentMEditSingleCSVField);
                ImGui.Checkbox("Space separator", ref _currentMEditSingleCSVSpaces);
                ImGui.InputTextMultiline("MEditRegexInput", ref _currentMEditCSVInput, 256 * 65536, new Vector2(1024, ImGui.GetTextLineHeightWithSpacing() * 4));
                if (ImGui.Selectable("Submit", false, ImGuiSelectableFlags.DontClosePopups))
                {
                    MassEditResult r = MassParamEditCSV.PerformSingleMassEdit(_currentMEditCSVInput, EditorActionManager, _activeView._selection.getActiveParam(), _currentMEditSingleCSVField, _currentMEditSingleCSVSpaces);
                    _mEditCSVResult = r.Information;
                }
                ImGui.Text(_mEditCSVResult);
                ImGui.EndPopup();
            }
            else
            {
                _isMEditPopupOpen      = false;
                _currentMEditCSVOutput = "";
            }
        }
        public void ParamView(bool doFocus)
        {
            ImGui.Columns(3);
            ImGui.BeginChild("params");
            float scrollTo = 0f;

            foreach (var param in ParamBank.Params)
            {
                if (ImGui.Selectable(param.Key, param.Key == _selection.getActiveParam()))
                {
                    _selection.setActiveParam(param.Key);
                    //_selection.SetActiveRow(null);
                }
                if (doFocus && param.Key == _selection.getActiveParam())
                {
                    scrollTo = ImGui.GetCursorPosY();
                }
            }
            if (doFocus)
            {
                ImGui.SetScrollFromPosY(scrollTo - ImGui.GetScrollY());
            }
            ImGui.EndChild();
            ImGui.NextColumn();
            if (!_selection.paramSelectionExists())
            {
                ImGui.BeginChild("rowsNONE");
                ImGui.Text("Select a param to see rows");
            }
            else
            {
                ImGui.Text("id VALUE | name ROW | prop FIELD VALUE | propref FIELD ROW");
                UIHints.AddImGuiHintButton("MassEditHint", ref UIHints.SearchBarHint);
                ImGui.InputText("Search rows...", ref _selection.getCurrentSearchString(), 256);
                if (ImGui.IsItemActive())
                {
                    _paramEditor._isSearchBarActive = true;
                }
                else
                {
                    _paramEditor._isSearchBarActive = false;
                }
                ImGui.BeginChild("rows" + _selection.getActiveParam());
                IParamDecorator decorator = null;
                if (_paramEditor._decorators.ContainsKey(_selection.getActiveParam()))
                {
                    decorator = _paramEditor._decorators[_selection.getActiveParam()];
                }

                PARAM            para = ParamBank.Params[_selection.getActiveParam()];
                List <PARAM.Row> p;
                Match            m = new Regex(MassParamEditRegex.rowfilterRx).Match(_selection.getCurrentSearchString());
                if (!m.Success)
                {
                    p = para.Rows;
                }
                else
                {
                    p = MassParamEditRegex.GetMatchingParamRows(para, m, true, true);
                }

                scrollTo = 0;
                foreach (var r in p)
                {
                    if (ImGui.Selectable($@"{r.ID} {r.Name}", _selection.getSelectedRows().Contains(r)))
                    {
                        if (InputTracker.GetKey(Key.LControl))
                        {
                            _selection.toggleRowInSelection(r);
                        }
                        else
                        {
                            if (InputTracker.GetKey(Key.LShift))
                            {
                                _selection.cleanSelectedRows();
                                int start = p.IndexOf(_selection.getActiveRow());
                                int end   = p.IndexOf(r);
                                if (start != end)
                                {
                                    foreach (var r2 in p.GetRange(start < end ? start : end, Math.Abs(end - start)))
                                    {
                                        _selection.addRowToSelection(r2);
                                    }
                                }
                                _selection.addRowToSelection(r);
                            }
                            else
                            {
                                _selection.SetActiveRow(r);
                            }
                        }
                    }
                    if (decorator != null)
                    {
                        decorator.DecorateContextMenu(r);
                        decorator.DecorateParam(r);
                    }
                    if (doFocus && _selection.getActiveRow() == r)
                    {
                        scrollTo = ImGui.GetCursorPosY();
                    }
                }
                if (doFocus)
                {
                    ImGui.SetScrollFromPosY(scrollTo - ImGui.GetScrollY());
                }
            }
            ImGui.EndChild();
            ImGui.NextColumn();
            if (!_selection.rowSelectionExists())
            {
                ImGui.BeginChild("columnsNONE");
                ImGui.Text("Select a row to see properties");
            }
            else
            {
                ImGui.BeginChild("columns" + _selection.getActiveParam());
                _propEditor.PropEditorParamRow(_selection.getActiveRow());
            }
            ImGui.EndChild();
        }
 public void MassEditPopups()
 {
     // Popup size relies on magic numbers. Multiline maxlength is also arbitrary.
     if (ImGui.BeginPopup("massEditMenuRegex"))
     {
         ImGui.Text("param PARAM: id VALUE: FIELD: = VALUE;");
         UIHints.AddImGuiHintButton("MassEditHint", ref UIHints.MassEditHint);
         ImGui.InputTextMultiline("MEditRegexInput", ref _currentMEditRegexInput, 65536, new Vector2(1024, 256));
         if (ImGui.Selectable("Submit", false, ImGuiSelectableFlags.DontClosePopups))
         {
             MassEditResult r = MassParamEditRegex.PerformMassEdit(_currentMEditRegexInput, EditorActionManager, _activeView._selection.getActiveParam(), _activeView._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("massEditMenuSingleCSVExport"))
     {
         ImGui.Text(_currentMEditSingleCSVField);
         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, _activeView._selection.getActiveParam());
             _mEditCSVResult = r.Information;
         }
         ImGui.Text(_mEditCSVResult);
         ImGui.EndPopup();
     }
     else if (ImGui.BeginPopup("massEditMenuSingleCSVImport"))
     {
         ImGui.Text(_currentMEditSingleCSVField);
         ImGui.InputTextMultiline("MEditRegexInput", ref _currentMEditCSVInput, 256 * 65536, new Vector2(1024, 256));
         if (ImGui.Selectable("Submit", false, ImGuiSelectableFlags.DontClosePopups))
         {
             MassEditResult r = MassParamEditCSV.PerformSingleMassEdit(_currentMEditCSVInput, EditorActionManager, _activeView._selection.getActiveParam(), _currentMEditSingleCSVField, false);
             _mEditCSVResult = r.Information;
         }
         ImGui.Text(_mEditCSVResult);
         ImGui.EndPopup();
     }
     else
     {
         _isMEditPopupOpen      = false;
         _currentMEditCSVOutput = "";
     }
 }