Esempio n. 1
0
        // ----------------------------------------------------------
        public Defs ReadDefs(Options aOptions)
        {
            // top element
            var defs = new Defs();

            defs.rootDef = new Def();

            // load defs
            var doc = new XmlDocument();

            doc.Load(aOptions.defsFile);

            // read items table
            ReadItems(doc.GetElementsByTagName("items").Item(0) as XmlElement, defs.items);
            // proces elements recursively
            var spriterElement = doc.GetElementsByTagName("spriter").Item(0) as XmlElement;

            ReadSpriterDefs(spriterElement.GetElementsByTagName("element").Item(0) as XmlElement, defs.rootDef, defs.items);

            // output json file with defs
            var jsonDefsString   = JsonConvert.SerializeObject(defs.rootDef, Newtonsoft.Json.Formatting.Indented);
            var jsonDefsFileName = Path.GetFileNameWithoutExtension(aOptions.defsFile) + ".json";

            using (StreamWriter sw = new StreamWriter(jsonDefsFileName)) {
                sw.Write(jsonDefsString);
            }

            // return top def
            return(defs);
        }
Esempio n. 2
0
        // ----------------------------------------------------------
        public Defs ReadDefs(Options aOptions)
        {
            // top element
            var defs = new Defs();
            defs.rootDef = new Def();

            // load defs
            var doc = new XmlDocument();
            doc.Load(aOptions.defsFile);

            // read items table
            ReadItems(doc.GetElementsByTagName("items").Item(0) as XmlElement, defs.items);
            // proces elements recursively
            var spriterElement = doc.GetElementsByTagName("spriter").Item(0) as XmlElement;
            ReadSpriterDefs(spriterElement.GetElementsByTagName("element").Item(0) as XmlElement, defs.rootDef, defs.items);

            // output json file with defs
            var jsonDefsString = JsonConvert.SerializeObject(defs.rootDef, Newtonsoft.Json.Formatting.Indented);
            var jsonDefsFileName = Path.GetFileNameWithoutExtension(aOptions.defsFile) + ".json";
            using (StreamWriter sw = new StreamWriter(jsonDefsFileName)) {
                sw.Write(jsonDefsString);
            }

            // return top def
            return defs;
        }