/// <summary>
        ///     Initializes a new instance of the <see cref="ColumnConfiguration"/>
        ///     class.
        /// </summary>
        /// <param name="metadata">
        ///     The metadata about the column.
        /// </param>
        /// <param name="hints">
        ///     Optional hints about displaying this column in the UI. This parameter
        ///     may be <c>null</c>. If this parameter is <c>null</c>, then
        ///     <see cref="UIHints.Default"/> will be used for this instance.
        /// </param>
        /// <exception cref="System.ArgumentNullException">
        ///     <paramref name="metadata"/> is <c>null</c>.
        /// </exception>
        public ColumnConfiguration(ColumnMetadata metadata, UIHints hints)
        {
            Guard.NotNull(metadata, nameof(metadata));

            this.Metadata     = metadata;
            this.DisplayHints = hints ?? UIHints.Default();
        }
示例#2
0
    // Use this for initialization
    void Start()
    {
        ToggleRestartButton(false);
        if (uiHints == null)
        {
            uiHints = FindObjectOfType <UIHints>();
        }
        if (Application.isMobilePlatform)
        {
            ToggleMobileControls(true);
        }

        //TODO move to more suitable class
        GameManager.Instance.AudioController.StartGameMusic();
    }
示例#3
0
        private void PropEditorPropRow(object oldval, object vanillaval, ref int id, string internalName, FieldMetaData cellMeta, Type propType, PropertyInfo proprow, PARAM.Cell nullableCell, PARAM.Row nullableRow, Regex propSearchRx)
        {
            List <string> RefTypes   = cellMeta == null ? null : cellMeta.RefTypes;
            string        VirtualRef = cellMeta == null ? null : cellMeta.VirtualRef;
            ParamEnum     Enum       = cellMeta == null ? null : cellMeta.EnumType;
            string        Wiki       = cellMeta == null ? null : cellMeta.Wiki;
            bool          IsBool     = cellMeta == null ? false : cellMeta.IsBool;
            string        AltName    = cellMeta == null ? null : cellMeta.AltName;

            if (propSearchRx != null)
            {
                if (!propSearchRx.IsMatch(internalName.ToLower()) && !(AltName != null && propSearchRx.IsMatch(AltName.ToLower())))
                {
                    return;
                }
            }

            object newval = null;

            ImGui.PushID(id);
            ImGui.AlignTextToFramePadding();
            PropertyRowName(ref internalName, cellMeta);
            PropertyRowNameContextMenu(internalName, cellMeta);
            if (Wiki != null)
            {
                if (UIHints.AddImGuiHintButton(internalName, ref Wiki))
                {
                    cellMeta.Wiki = Wiki;
                }
            }

            ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(1.0f, 1.0f, 0.0f, 1.0f));
            if (ParamEditorScreen.HideReferenceRowsPreference == false && RefTypes != null)
            {
                ImGui.TextUnformatted($@"  <{String.Join(',', RefTypes)}>");
            }
            if (ParamEditorScreen.HideEnumsPreference == false && Enum != null)
            {
                ImGui.TextUnformatted($@"  {Enum.name}");
            }
            ImGui.PopStyleColor();

            //PropertyRowMetaDefContextMenu();
            ImGui.NextColumn();
            ImGui.SetNextItemWidth(-1);
            bool changed = false;

            if (vanillaval != null && !oldval.Equals(vanillaval))
            {
                ImGui.PushStyleColor(ImGuiCol.FrameBg, new Vector4(0.2f, 0.22f, 0.2f, 1f));
            }

            bool matchDefault = nullableCell != null && nullableCell.Def.Default.Equals(oldval);

            if (matchDefault)
            {
                ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(0.75f, 0.75f, 0.75f, 1.0f));
            }
            else if ((ParamEditorScreen.HideReferenceRowsPreference == false && RefTypes != null) || (ParamEditorScreen.HideEnumsPreference == false && Enum != null) || VirtualRef != null)
            {
                ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(1.0f, 0.5f, 1.0f, 1.0f));
            }

            changed = PropertyRow(propType, oldval, out newval, IsBool);
            bool committed = ImGui.IsItemDeactivatedAfterEdit();

            if ((ParamEditorScreen.HideReferenceRowsPreference == false && RefTypes != null) || (ParamEditorScreen.HideEnumsPreference == false && Enum != null) || VirtualRef != null || matchDefault)
            {
                ImGui.PopStyleColor();
            }
            PropertyRowValueContextMenu(internalName, VirtualRef, oldval);

            if (ParamEditorScreen.HideReferenceRowsPreference == false && RefTypes != null)
            {
                PropertyRowRefs(RefTypes, oldval);
            }
            if (ParamEditorScreen.HideEnumsPreference == false && Enum != null)
            {
                ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(1.0f, 0.5f, 0.5f, 1.0f));
                ImGui.TextUnformatted(Enum.values.GetValueOrDefault(oldval.ToString(), "Not Enumerated"));
                ImGui.PopStyleColor();
            }
            if ((ParamEditorScreen.HideReferenceRowsPreference == false || ParamEditorScreen.HideEnumsPreference == false) && PropertyRowMetaValueContextMenu(oldval, ref newval, RefTypes, Enum))
            {
                changed   = true;
                committed = true;
            }

            UpdateProperty(proprow, nullableCell != null ? (object)nullableCell : nullableRow, newval, changed, committed);
            if (vanillaval != null && !oldval.Equals(vanillaval))
            {
                ImGui.PopStyleColor();
            }
            ImGui.NextColumn();
            ImGui.PopID();
            id++;
        }
示例#4
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();
        }
示例#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 = "";
     }
 }