Ejemplo n.º 1
0
        public static void ExportTags(this FurniCache cache)
        {
            var dict = new Dictionary <string, HashSet <string> >();

            foreach (var node in cache.Furniture.Values.SelectMany(v => v.Descendants()).ToList())
            {
                if (!dict.ContainsKey(node.Name.LocalName))
                {
                    dict[node.Name.LocalName] = new HashSet <string>();
                }

                foreach (var attribute in node.Attributes().Select(a => a.Name))
                {
                    dict[node.Name.LocalName].Add(attribute.LocalName);
                }
            }

            using var streamWriter = new StreamWriter(Path.Join(cache.Output, "TagsAndAttributesList.txt"));
            foreach (var(node, attributes) in dict.OrderBy(kvp => kvp.Key))
            {
                streamWriter.WriteLine(node);
                foreach (var attribute in attributes.OrderBy(d => d))
                {
                    streamWriter.WriteLine($"\t{attribute}");
                }
            }
        }
Ejemplo n.º 2
0
 public static void ExportStateCount(this FurniCache cache)
 {
     using var streamWriter = new StreamWriter(Path.Join(cache.Output, "FurnitureStateCount.txt"));
     foreach (var(name, doc) in cache.Furniture.Where(kvp => kvp.Value.Descendants().Any(node => node.Name.LocalName.Contains("states"))))
     {
         var states = doc.Descendants().FirstOrDefault(d => d.Name.LocalName.Equals("states"));
         if (states != null)
         {
             streamWriter.WriteLine($"{name} => {states.Descendants("state").Count()}");
         }
     }
 }
Ejemplo n.º 3
0
 public static void ExportHeights(this FurniCache cache)
 {
     using var streamWriter = new StreamWriter(Path.Join(cache.Output, "FurnitureHeights.txt"));
     foreach (var(name, doc) in cache.Furniture.Where(kvp => kvp.Value.Descendants().Any(node => node.Name.LocalName.Contains("height"))))
     {
         var height = doc.Descendants().FirstOrDefault(d => d.Name.LocalName.Equals("height"));
         if (height != null)
         {
             streamWriter.WriteLine($"{name} => {height.Value}");
         }
     }
 }
Ejemplo n.º 4
0
 public static void ExportDrinks(this FurniCache cache)
 {
     using var streamWriter = new StreamWriter(Path.Join(cache.Output, "VendingMachineIds.txt"));
     foreach (var(name, doc) in cache.Furniture.Where(kvp => kvp.Value.Descendants().Any(node => node.Name.LocalName.Contains("drinks"))))
     {
         var drinks = doc.Descendants().Where(d => d.Name.LocalName.Equals("drink")).ToList();
         if (drinks.Any())
         {
             streamWriter.WriteLine($"{name} => {string.Join("\t", drinks.Select(drink => drink.Attributes().First(a => a.Name.LocalName.Equals("id")).Value).OrderBy(d => d).ToList())}");
         }
     }
 }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            Console.WriteLine("Furni XML Parser Tool");
            Console.WriteLine("By The General @ http://arcturus.pw");
            Console.WriteLine("Download @ https://github.com/80O/FurniData");

            if (!args.Any() || args.Any(arg => arg.Contains("help")))
            {
                DisplayHelp();
                return;
            }

            var xmlsLocation = "Data/";

            if (args.Any(arg => arg.StartsWith("--xmls=")))
            {
                xmlsLocation = args.First(arg => arg.StartsWith("--xmls=")).Split("=")[1];
            }

            var outputLocation = ".";

            if (args.Any(arg => arg.StartsWith("--out=")))
            {
                outputLocation = args.First(arg => arg.StartsWith("--out=")).Split("=")[1];
            }

            if (!Directory.Exists(xmlsLocation))
            {
                Console.Error.WriteLine($"Path {xmlsLocation} not a valid path to data directory.");
                return;
            }

            if (!Directory.Exists(outputLocation) &&
                !Directory.CreateDirectory(outputLocation).Exists)
            {
                Console.Error.WriteLine($"Failed to create missing output directory {new DirectoryInfo(outputLocation).FullName}");
                return;
            }

            var furniCache = new FurniCache {
                XmlLocation = xmlsLocation, Output = outputLocation
            };

            furniCache.Load();

            Console.WriteLine($"Loaded {furniCache.Furniture.Count} furniture!");

            var all = args.Any(arg => arg.StartsWith("--all"));

            var exportTags = all || args.Any(arg => arg.Equals("--tags"));

            if (exportTags)
            {
                Console.WriteLine("Exporting Unique Tags");
                furniCache.ExportTags();
            }

            var exportDrinks = all || args.Any(arg => arg.Equals("--drinks"));

            if (exportDrinks)
            {
                Console.WriteLine("Exporting Drink Ids");
                furniCache.ExportDrinks();
            }

            var exportStateCount = all || args.Any(arg => arg.Equals("--states"));

            if (exportStateCount)
            {
                Console.WriteLine("Exporting Furniture State Count");
                furniCache.ExportStateCount();
            }

            var exportHeights = all || args.Any(arg => arg.Equals("--heights"));

            if (exportHeights)
            {
                Console.WriteLine("Exporting Furniture Height");
                furniCache.ExportHeights();
            }

            Console.WriteLine("Done! See you again :)");
        }