Exemplo n.º 1
0
        public string exportArray(FlatBase.GJDB database, FlatBase.ArrayStructure AS)
        {
            string toreturn = "";

            foreach (ObjectStructure o in AS.REFS)
            {
                if (o.FIELDS.Count == 1)
                {
                    if (o.FIELDS[0] is int)
                    {
                        toreturn += o.FIELDS[0].ToString() + ",";
                    }
                    else if (o.FIELDS[0] is OReference)
                    {
                        toreturn += "{" + saveReference(database, (o.FIELDS[0] as OReference)) + "},";
                    }
                    else if (o.FIELDS[0] is FlatBase.Misc.TupleStructure)
                    {
                        toreturn += o.FIELDS[0].ToString() + ",";
                    }
                    else
                    {
                        toreturn += "\"" + o.FIELDS[0].ToString() + "\",";
                    }
                }
            }

            return(toreturn);
        }
Exemplo n.º 2
0
        public static ObjectStructure loadManifest(string catName, ObjectStructure parent = null, ObjectStructure ovrrd = null, bool readOverride = false)
        {
            string[] s       = new string[1];
            int      offsetC = 0;

            if (!readOverride)
            {
                s = File.ReadAllLines("config/" + catName + ".txt");
            }
            else
            {
                s = catName.Split('\n');
            }


            ObjectStructure nost = new ObjectStructure();

            if (ovrrd != null)
            {
                nost = ovrrd;
            }

            int c = 0;

            for (int i = 0; i < s.Count(); i++)
            {
                if (s[i].Count() <= 0)
                {
                    continue;
                }

                if (s[i][0] == '#')
                {
                    continue;
                }

                string clipped = s[i].Split(' ')[1];

                if (s[i][0] == 'I')
                {
                    ObjectStructure ret = loadManifest(clipped, parent, nost);
                    offsetC += ret.FIELDS.Count;
                    continue;
                }

                if (s[i][0] == '!')
                {
                    nost.weightpools.Add(clipped, new Misc.weightpool());
                    Console.WriteLine(clipped + " weightpool");
                    continue;
                }

                if (s[i][0] == 'b')
                {
                    nost.FIELDS.Add(false);
                }

                if (s[i][0] == 'h')
                {
                    nost.FIELDS.Add(new ObjectHeader(clipped));
                }

                if (s[i][0] == 'i')
                {
                    nost.FIELDS.Add(0);
                }

                if (s[i][0] == 'f')
                {
                    nost.FIELDS.Add(0.0f);
                }

                if (s[i][0] == 'C')
                {
                    nost.FIELDS.Add(new Color());
                }

                if (s[i][0] == 'c')
                {
                    nost.FIELDS.Add(new Misc.CodeStructure());
                }

                if (s[i][0] == 'S')
                {
                    nost.FIELDS.Add(new Misc.FilePathStructure());
                }

                if (s[i][0] == 's')
                {
                    nost.FIELDS.Add("New Entry");
                    if (s[i][1] == 'N')
                    {
                        nost.setOverride(offsetC + c);
                    }
                }

                if (s[i][0] == 'm')
                {
                    Console.WriteLine("M");
                }

                if (s[i][0] == 'W')
                {
                    if (parent == null)
                    {
                        nost.FIELDS.Add(new Misc.WeightedGroup(nost.weightpools[clipped]));
                    }
                    else
                    {
                        nost.FIELDS.Add(new Misc.WeightedGroup(parent.weightpools[clipped]));
                    }
                }

                if (s[i][0] == 'E')
                {
                    nost.FIELDS.Add(new EnumField(clipped));
                }

                if (s[i][0] == 'l')
                {
                    nost.FIELDS.Add(new TagField(clipped));
                }

                if (s[i][0] == 'r')
                {
                    OReferenceList orl = new OReferenceList();
                    clipped = s[i].Split(' ')[2];
                    orl.setRA(Int32.Parse(clipped));
                    nost.FIELDS.Add(orl);
                }

                if (s[i][0] == 'R')
                {
                    OReference or = new OReference();
                    clipped = s[i].Split(' ')[2];
                    or.setRA(Int32.Parse(clipped));
                    nost.FIELDS.Add(or);
                }

                if (s[i][0] == 'G')
                {
                    intArray iA = new intArray(100);
                    nost.FIELDS.Add(iA);
                }

                if (s[i][0] == 'A')
                {
                    string eVAL = s[i].Remove(0, 1);



                    ArrayStructure aStruct = new ArrayStructure(eVAL, nost);
                    nost.FIELDS.Add(aStruct);
                }

                if (s[i][0] == 'T')
                {
                    List <ObjectStructure> dummytuple = new List <ObjectStructure>();
                    bool skipped = false;
                    foreach (string TT in s[i].Split(' '))
                    {
                        if (!skipped)
                        {
                            skipped = true;
                            continue;
                        }
                        ObjectStructure os = loadManifest(TT, parent);
                        Console.WriteLine(os.FIELDS.Count + " fields in tuple");
                        dummytuple.Add(os);
                    }

                    nost.FIELDS.Add(new Misc.TupleStructure(dummytuple));
                }

                nost.fieldexportnames.Add(clipped);
                c++;
            }

            return(nost);
        }