コード例 #1
0
        private void Worker_AddCodex(FileInfo file, JArray items)
        {
            try
            {
                JObject item    = JObject.Parse(File.ReadAllText(file.FullName));
                JObject newItem = new JObject();

                newItem["path"]     = GetAssetPath(file.FullName, worker_basePath);
                newItem["fileName"] = file.Name;

                // Set item name
                string name = ItemReader.GetCodexName(item);
                newItem["name"] = name;
                if (string.IsNullOrEmpty(name))
                {
                    Console.WriteLine("Codex file {0} has no IDw.", file.FullName);
                    return;
                }

                // Set item description. Use item name if no description is set.
                string shortDescription = ItemReader.GetCodexTitle(item);
                if (string.IsNullOrEmpty(shortDescription))
                {
                    shortDescription = name;
                }
                newItem["shortdescription"] = shortDescription;

                // Set category
                newItem["category"] = "codex";

                // Set icon
                newItem["icon"] = ItemReader.GetIcon(item, true);

                // Set rarity.
                string rarity = ItemReader.GetCodexRarity(item);
                if (rarity != null)
                {
                    newItem["rarity"] = rarity;
                }

                // Set race
                string race = ItemReader.GetSpecies(item);
                if (race != null)
                {
                    newItem["race"] = race;
                }

                // Add the item.
                items.Add(newItem);
            }
            catch
            {
                // Skip file.
                Console.WriteLine("Couldn't parse file {0}.", file.FullName);
            }
        }
コード例 #2
0
        private void Worker_AddItem(FileInfo file, JArray items)
        {
            try
            {
                JObject item    = JObject.Parse(File.ReadAllText(file.FullName));
                JObject newItem = new JObject();

                newItem["path"]     = GetAssetPath(file.FullName, worker_basePath);
                newItem["fileName"] = file.Name;

                // Set item name
                string name = ItemReader.GetItemName(item);
                newItem["name"] = name;

                if (string.IsNullOrEmpty(name))
                {
                    Console.WriteLine("File {0} has no item name.", file.FullName);
                    return;
                }

                // Set item description. Use item name if no description is set.
                string shortDescription = ItemReader.GetShortDescription(item);
                if (string.IsNullOrEmpty(shortDescription))
                {
                    shortDescription = name;
                }
                newItem["shortdescription"] = shortDescription;

                // Set category
                string category = ItemReader.GetCategory(file.Extension, item);
                newItem["category"] = category;

                // Set icon
                newItem["icon"] = ItemReader.GetIcon(item, true);

                // Set rarity.
                string rarity = ItemReader.GetRarity(item);
                if (rarity != null)
                {
                    newItem["rarity"] = rarity;
                }

                // Set race
                string race = ItemReader.GetRace(item);
                if (race != null)
                {
                    newItem["race"] = race;
                }

                string directives = ItemReader.GetDirectives(item);
                if (!string.IsNullOrEmpty(directives))
                {
                    newItem["directives"] = directives;
                }

                items.Add(newItem);
            }
            catch
            {
                // Skip file.
                Console.WriteLine("Couldn't parse file {0}.", file.FullName);
            }
        }