Ejemplo n.º 1
0
 private void PropertyRowVirtualRefContextItems(string vref, object searchValue)
 {
     // Add Goto statements
     foreach (var param in ParamBank.Params)
     {
         PARAMDEF.Field foundfield = null;
         foreach (PARAMDEF.Field f in param.Value.AppliedParamdef.Fields)
         {
             if (FieldMetaData.Get(f).VirtualRef != null && FieldMetaData.Get(f).VirtualRef.Equals(vref))
             {
                 foundfield = f;
                 break;
             }
         }
         if (foundfield == null)
         {
             continue;
         }
         if (ImGui.Selectable($@"Go to first in {param.Key}"))
         {
             Console.WriteLine($@"{foundfield.InternalName} - {searchValue}");
             Console.WriteLine($@"{param.Key}");
             foreach (PARAM.Row row in param.Value.Rows)
             {
                 Console.WriteLine($@"{row.ID} - {row[foundfield.InternalName].Value}");
                 if (row[foundfield.InternalName].Value.ToString().Equals(searchValue.ToString()))
                 {
                     EditorCommandQueue.AddCommand($@"param/select/-1/{param.Key}/{row.ID}");
                     Console.WriteLine($@"param/select/-1/{param.Key}/{row.ID}");
                     break;
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
        public static List <PARAM.Row> GetMatchingParamRowsByPropRef(PARAM param, string rowfield, string namerx, bool lenient, bool failureAllOrNone)
        {
            List <PARAM.Row> rlist = new List <PARAM.Row>();

            try
            {
                Regex rownamerx = lenient ? new Regex(namerx.ToLower()) : new Regex($@"^{namerx}$");
                foreach (PARAM.Row row in param.Rows)
                {
                    PARAM.Cell c = row[rowfield.Replace(@"\s", " ")];
                    if (c == null)
                    {
                        continue;
                    }
                    int val = (int)c.Value;
                    foreach (string rt in FieldMetaData.Get(c.Def).RefTypes)
                    {
                        if (!ParamBank.Params.ContainsKey(rt))
                        {
                            continue;
                        }
                        PARAM.Row r = ParamBank.Params[rt][val];
                        if (r == null)
                        {
                            continue;
                        }
                        string nameToMatch = r.Name == null ? "" : r.Name;
                        if (r != null && rownamerx.Match(lenient ? nameToMatch.ToLower() : nameToMatch).Success)
                        {
                            rlist.Add(row);
                            break;
                        }
                    }
                }
                return(rlist);
            }
            catch
            {
                return(failureAllOrNone ? param.Rows : rlist);
            }
        }
Ejemplo n.º 3
0
        public static object PerformOperation(PARAM.Cell cell, string op, string opparam)
        {
            try
            {
                if (op.Equals("ref"))
                {
                    if (cell.Value.GetType() == typeof(int))
                    {
                        foreach (string reftype in FieldMetaData.Get(cell.Def).RefTypes)
                        {
                            PARAM p = ParamBank.Params[reftype];
                            if (p == null)
                            {
                                continue;
                            }
                            foreach (PARAM.Row r in p.Rows)
                            {
                                if (r.Name == null)
                                {
                                    continue;
                                }
                                if (r.Name.Equals(opparam))
                                {
                                    return((int)r.ID);
                                }
                            }
                        }
                    }
                }
                if (op.Equals("="))
                {
                    if (cell.Value.GetType() == typeof(bool))
                    {
                        return(bool.Parse(opparam));
                    }
                    else if (cell.Value.GetType() == typeof(string))
                    {
                        return(opparam);
                    }
                }

                if (cell.Value.GetType() == typeof(long))
                {
                    return(PerformBasicOperation <long>(cell, op, double.Parse(opparam)));
                }
                if (cell.Value.GetType() == typeof(ulong))
                {
                    return(PerformBasicOperation <ulong>(cell, op, double.Parse(opparam)));
                }
                else if (cell.Value.GetType() == typeof(int))
                {
                    return(PerformBasicOperation <int>(cell, op, double.Parse(opparam)));
                }
                else if (cell.Value.GetType() == typeof(uint))
                {
                    return(PerformBasicOperation <uint>(cell, op, double.Parse(opparam)));
                }
                else if (cell.Value.GetType() == typeof(short))
                {
                    return(PerformBasicOperation <short>(cell, op, double.Parse(opparam)));
                }
                else if (cell.Value.GetType() == typeof(ushort))
                {
                    return(PerformBasicOperation <ushort>(cell, op, double.Parse(opparam)));
                }
                else if (cell.Value.GetType() == typeof(sbyte))
                {
                    return(PerformBasicOperation <sbyte>(cell, op, double.Parse(opparam)));
                }
                else if (cell.Value.GetType() == typeof(byte))
                {
                    return(PerformBasicOperation <byte>(cell, op, double.Parse(opparam)));
                }
                else if (cell.Value.GetType() == typeof(float))
                {
                    return(PerformBasicOperation <float>(cell, op, double.Parse(opparam)));
                }
                else if (cell.Value.GetType() == typeof(double))
                {
                    return(PerformBasicOperation <double>(cell, op, double.Parse(opparam)));
                }
            }
            catch
            {
            }
            return(null);
        }
Ejemplo n.º 4
0
 private void PropEditorPropCellRow(PARAM.Cell cell, PARAM.Cell vcell, ref int id, Regex propSearchRx)
 {
     PropEditorPropRow(cell.Value, vcell == null?null:vcell.Value, ref id, cell.Def.InternalName, FieldMetaData.Get(cell.Def), cell.Value.GetType(), cell.GetType().GetProperty("Value"), cell, null, propSearchRx);
 }