public override void DrawEditorMenu()
        {
            bool openMEditRegex     = false;
            bool openMEditCSVExport = false;
            bool openMEditCSVImport = false;

            // Menu Options
            if (ImGui.BeginMenu("Edit"))
            {
                if (ImGui.MenuItem("Undo", "CTRL+Z", false, EditorActionManager.CanUndo()))
                {
                    EditorActionManager.UndoAction();
                }
                if (ImGui.MenuItem("Redo", "Ctrl+Y", false, EditorActionManager.CanRedo()))
                {
                    EditorActionManager.RedoAction();
                }
                if (ImGui.MenuItem("Delete", "Delete", false, _selection.rowSelectionExists()))
                {
                    if (_selection.rowSelectionExists())
                    {
                        var act = new DeleteParamsAction(ParamBank.Params[_selection.getActiveParam()], new List <PARAM.Row>()
                        {
                            _selection.getActiveRow()
                        });
                        EditorActionManager.ExecuteAction(act);
                        _selection.SetActiveRow(null);
                    }
                }
                if (ImGui.MenuItem("Duplicate", "Ctrl+D", false, _selection.rowSelectionExists()))
                {
                    if (_selection.rowSelectionExists())
                    {
                        var act = new AddParamsAction(ParamBank.Params[_selection.getActiveParam()], _selection.getActiveParam(), new List <PARAM.Row>()
                        {
                            _selection.getActiveRow()
                        }, true);
                        EditorActionManager.ExecuteAction(act);
                    }
                }
                if (FeatureFlags.EnableEnhancedParamEditor)
                {
                    if (ImGui.MenuItem("Mass Edit", null, false, true))
                    {
                        openMEditRegex = true;
                    }
                    if (ImGui.MenuItem("Export CSV (Slow!)", null, false, _selection.paramSelectionExists()))
                    {
                        openMEditCSVExport = true;
                    }
                    if (ImGui.MenuItem("Import CSV", null, false, _selection.paramSelectionExists()))
                    {
                        openMEditCSVImport = true;
                    }
                }
                ImGui.EndMenu();
            }
            // Menu Popups -- imgui scoping
            if (openMEditRegex)
            {
                ImGui.OpenPopup("massEditMenuRegex");
                _isMEditPopupOpen = true;
            }
            if (openMEditCSVExport)
            {
                if (_selection.paramSelectionExists())
                {
                    _currentMEditCSVOutput = MassParamEditCSV.GenerateCSV(ParamBank.Params[_selection.getActiveParam()]);
                }
                ImGui.OpenPopup("massEditMenuCSVExport");
                _isMEditPopupOpen = true;
            }
            if (openMEditCSVImport)
            {
                ImGui.OpenPopup("massEditMenuCSVImport");
                _isMEditPopupOpen = true;
            }
            MassEditPopups();
        }
예제 #2
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();
                }
            }
        }