Exemple #1
0
        public void PropEditorParamRow(PARAM.Row row)
        {
            IReadOnlyList <PARAM.Cell> cells = new List <PARAM.Cell>();

            cells = row.Cells;
            ImGui.Columns(2);
            ImGui.Separator();
            int id = 0;

            // This should be rewritten somehow it's super ugly
            ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(0.8f, 0.8f, 0.8f, 1.0f));
            var nameProp = row.GetType().GetProperty("Name");
            var idProp   = row.GetType().GetProperty("ID");

            PropEditorPropInfoRow(row, nameProp, "Name", ref id);
            PropEditorPropInfoRow(row, idProp, "ID", ref id);
            ImGui.PopStyleColor();

            ParamMetaData meta = ParamMetaData.Get(row.Def);

            if (meta != null && meta.AlternateOrder != null && ParamEditorScreen.AllowFieldReorderPreference)
            {
                foreach (var field in meta.AlternateOrder)
                {
                    if (field.Equals("-"))
                    {
                        ImGui.Separator();
                        continue;
                    }
                    if (row[field] == null)
                    {
                        continue;
                    }
                    PropEditorPropCellRow(row[field], ref id);
                }
                foreach (var cell in cells)
                {
                    if (!meta.AlternateOrder.Contains(cell.Def.InternalName))
                    {
                        PropEditorPropCellRow(cell, ref id);
                    }
                }
            }
            else
            {
                foreach (var cell in cells)
                {
                    PropEditorPropCellRow(cell, ref id);
                }
            }
            ImGui.Columns(1);
        }
Exemple #2
0
        public void PropEditorParamRow(PARAM.Row row)
        {
            IReadOnlyList <PARAM.Cell> cells = new List <PARAM.Cell>();

            cells = row.Cells;
            ImGui.Columns(2);
            ImGui.Separator();
            int id = 0;

            // This should be rewritten somehow it's super ugly
            ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(0.8f, 0.8f, 0.8f, 1.0f));
            var nameProp = row.GetType().GetProperty("Name");
            var idProp   = row.GetType().GetProperty("ID");

            PropEditorPropInfoRow(row, nameProp, "Name", ref id, null);
            PropEditorPropInfoRow(row, idProp, "ID", ref id, null);
            ImGui.PopStyleColor();

            foreach (var cell in cells)
            {
                PropEditorPropCellRow(cell, ref id, null);
            }
            ImGui.Columns(1);
        }
Exemple #3
0
 public static MassEditResult PerformSingleMassEdit(string csvString, ActionManager actionManager, string param, string field, bool useSpace)
 {
     try
     {
         PARAM p = ParamBank.Params[param];
         if (p == null)
         {
             return(new MassEditResult(MassEditResultType.PARSEERROR, "No Param selected"));
         }
         string[]            csvLines    = csvString.Split('\n');
         int                 changeCount = 0;
         List <EditorAction> actions     = new List <EditorAction>();
         foreach (string csvLine in csvLines)
         {
             if (csvLine.Trim().Equals(""))
             {
                 continue;
             }
             string[] csvs = csvLine.Split(useSpace ? ' ' : ',', 2, StringSplitOptions.RemoveEmptyEntries);
             if (csvs.Length != 2)
             {
                 return(new MassEditResult(MassEditResultType.PARSEERROR, "CSV has wrong number of values"));
             }
             int       id    = int.Parse(csvs[0]);
             string    value = csvs[1];
             PARAM.Row row   = p[id];
             if (row == null)
             {
                 return(new MassEditResult(MassEditResultType.OPERATIONERROR, $@"Could not locate row {id}"));
             }
             if (field.Equals("Name"))
             {
                 if (row.Name == null || !row.Name.Equals(value))
                 {
                     actions.Add(new PropertiesChangedAction(row.GetType().GetProperty("Name"), -1, row, value));
                 }
             }
             else
             {
                 PARAM.Cell cell = row[field];
                 if (cell == null)
                 {
                     return(new MassEditResult(MassEditResultType.OPERATIONERROR, $@"Could not locate field {field}"));
                 }
                 // Array types are unhandled
                 if (cell.Value.GetType().IsArray)
                 {
                     continue;
                 }
                 object newval = PerformOperation(cell, "=", value);
                 if (newval == null)
                 {
                     return(new MassEditResult(MassEditResultType.OPERATIONERROR, $@"Could not assign {value} to field {cell.Def.InternalName}"));
                 }
                 if (!cell.Value.Equals(newval))
                 {
                     actions.Add(new PropertiesChangedAction(cell.GetType().GetProperty("Value"), -1, cell, newval));
                 }
             }
         }
         changeCount = actions.Count;
         if (changeCount != 0)
         {
             actionManager.ExecuteAction(new CompoundAction(actions));
         }
         return(new MassEditResult(MassEditResultType.SUCCESS, $@"{changeCount} rows affected"));
     }
     catch
     {
         return(new MassEditResult(MassEditResultType.PARSEERROR, "Unable to parse CSV into correct data types"));
     }
 }
        public void PropEditorParamRow(PARAM.Row row, PARAM.Row vrow, ref string propSearchString)
        {
            ParamMetaData meta = ParamMetaData.Get(row.Def);

            ImGui.Columns(2);
            ImGui.Separator();
            int id = 0;

            if (propSearchString != null)
            {
                ImGui.InputText("Search...", ref propSearchString, 255);
            }
            Regex propSearchRx = null;

            try
            {
                propSearchRx = new Regex(propSearchString.ToLower());
            }
            catch
            {
            }
            ImGui.NextColumn();
            ImGui.NextColumn();

            // This should be rewritten somehow it's super ugly
            ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(0.8f, 0.8f, 0.8f, 1.0f));
            var nameProp = row.GetType().GetProperty("Name");
            var idProp   = row.GetType().GetProperty("ID");

            PropEditorPropInfoRow(row, nameProp, "Name", ref id, propSearchRx);
            PropEditorPropInfoRow(row, idProp, "ID", ref id, propSearchRx);
            ImGui.PopStyleColor();

            List <string> fieldOrder = meta != null && meta.AlternateOrder != null && ParamEditorScreen.AllowFieldReorderPreference ? meta.AlternateOrder : new List <string>();

            foreach (PARAMDEF.Field field in row.Def.Fields)
            {
                if (!fieldOrder.Contains(field.InternalName))
                {
                    fieldOrder.Add(field.InternalName);
                }
            }
            foreach (var field in fieldOrder)
            {
                if (field.Equals("-"))
                {
                    ImGui.Separator();
                    continue;
                }
                if (row[field] == null)
                {
                    continue;
                }
                List <PARAM.Cell> matches  = row.Cells.Where(cell => cell.Def.InternalName == field).ToList();
                List <PARAM.Cell> vmatches = vrow == null ? null : vrow.Cells.Where(cell => cell.Def.InternalName == field).ToList();
                for (int i = 0; i < matches.Count; i++)
                {
                    PropEditorPropCellRow(matches[i], vrow == null ? null : vmatches[i], ref id, propSearchRx);
                }
            }
            ImGui.Columns(1);
        }
Exemple #5
0
        public void PropEditorParamRow(PARAM.Row row)
        {
            IReadOnlyList <PARAM.Cell> cells = new List <PARAM.Cell>();

            cells = row.Cells;
            ImGui.Columns(2);
            ImGui.Separator();
            int id = 0;

            // This should be rewritten somehow it's super ugly
            var    nameProp = row.GetType().GetProperty("Name");
            var    idProp   = row.GetType().GetProperty("ID");
            object oval     = nameProp.GetValue(row);
            object nval     = null;

            ImGui.PushID(id);
            ImGui.AlignTextToFramePadding();
            ImGui.Text("Name");
            ImGui.NextColumn();
            ImGui.SetNextItemWidth(-1);
            bool ch = PropertyRow(nameProp.PropertyType, oval, out nval);
            bool cm = ImGui.IsItemDeactivatedAfterEdit();

            ChangeProperty(nameProp, null, row, nval, ch, cm, false);
            ImGui.NextColumn();
            ImGui.PopID();
            id++;

            oval = idProp.GetValue(row);
            nval = null;
            ImGui.PushID(id);
            ImGui.AlignTextToFramePadding();
            ImGui.Text("ID");
            ImGui.NextColumn();
            ImGui.SetNextItemWidth(-1);
            ch = PropertyRow(idProp.PropertyType, oval, out nval);
            cm = ImGui.IsItemDeactivatedAfterEdit();
            ChangeProperty(idProp, null, row, nval, ch, cm, false);
            ImGui.NextColumn();
            ImGui.PopID();
            id++;

            foreach (var cell in cells)
            {
                ImGui.PushID(id);
                ImGui.AlignTextToFramePadding();
                ImGui.Text(cell.Def.InternalName);
                ImGui.NextColumn();
                ImGui.SetNextItemWidth(-1);
                //ImGui.AlignTextToFramePadding();
                var    typ                = cell.Value.GetType();
                var    oldval             = cell.Value;
                bool   shouldUpdateVisual = false;
                bool   changed            = false;
                object newval             = null;

                changed = PropertyRow(typ, oldval, out newval, null, cell.Def.InternalName);
                bool committed = ImGui.IsItemDeactivatedAfterEdit();
                ChangeProperty(cell.GetType().GetProperty("Value"), null, cell, newval, changed, committed, shouldUpdateVisual);

                ImGui.NextColumn();
                ImGui.PopID();
                id++;
            }
            ImGui.Columns(1);
        }