/// <summary>
        /// After selecting game, we load the localization file.
        /// Deppends on the gameType selected.
        /// There are two Localization files from ffg, one for D2E and one for MoM
        /// </summary>
        private void loadLocalization()
        {
            // After content import, we load the localization file
            if (LocalizationRead.selectDictionary("ffg") == null)
            {
                DictionaryI18n ffgDict           = new DictionaryI18n();
                var            localizationFiles = Directory.GetFiles(ContentData.ImportPath() + "/text", "Localization_*.txt");
                foreach (string file in localizationFiles)
                {
                    ffgDict.AddDataFromFile(file);
                }
                LocalizationRead.AddDictionary("ffg", ffgDict);

                // CoSH used for Dunwich Horror data
                DictionaryI18n cshDict = new DictionaryI18n();
                foreach (string file in Directory.GetFiles(ContentData.ImportPath() + "/text", "SCENARIO_CULT_OF_SENTINEL_HILL_MAD22_*.txt"))
                {
                    cshDict.AddDataFromFile(file);
                }
                LocalizationRead.AddDictionary("csh", cshDict);

                var game = Game.Get();
                foreach (var packInfo in game.config.GetPackLanguages(game.gameType.TypeName())
                         .Where(kv => !string.IsNullOrWhiteSpace(kv.Value)))
                {
                    LocalizationRead.SetGroupTranslationLanguage(packInfo.Key, packInfo.Value);
                }
            }
        }
Exemple #2
0
    // generic constructor gets common things
    public GenericData(string name_ini, Dictionary <string, string> content, string path, string type, List <string> sets)
    {
        sectionName = name_ini;
        this.sets   = sets ?? new List <string>();

        // Has the name been specified?
        if (content.ContainsKey("name"))
        {
            name = new StringKey(content["name"]);
        }
        else
        {
            name = new StringKey(null, name_ini.Substring(type.Length));
        }

        priority = 0;
        if (content.ContainsKey("priority"))
        {
            int.TryParse(content["priority"], out priority);
        }

        if (content.ContainsKey("traits"))
        {
            traits = content["traits"].Split(" ".ToCharArray());
        }
        else // No traits is a valid condition
        {
            traits = new string[0];
        }

        // If image specified it is relative to the path of the ini file
        // absolute paths are not supported
        // resolve optional images like image, image2, image3 and so on
        int count = 0;

        while (true)
        {
            string key = "image" + (count > 0 ? (count + 1).ToString() : "");
            if (!content.ContainsKey(key))
            {
                image = ""; // No image is a valid condition
                break;
            }
            if (content[key].StartsWith("{import}"))
            {
                image = Path.Combine(ContentData.ImportPath(), content[key].Substring(9));
            }
            else
            {
                image = Path.Combine(path, content[key]);
            }
            if (ContentData.ResolveTextureFile(image) != null)
            {
                break;
            }
            count++;
        }
    }
Exemple #3
0
 public AudioData(string name, Dictionary <string, string> content, string path) : base(name, content, path, type)
 {
     if (content.ContainsKey("file"))
     {
         if (content["file"].IndexOf("{import}") == 0)
         {
             file = ContentData.ImportPath() + content["file"].Substring(8);
         }
         else
         {
             file = path + "/" + content["file"];
         }
     }
 }
Exemple #4
0
 public AudioData(string name, Dictionary <string, string> content, string path, List <string> sets) : base(name, content, path, type, sets)
 {
     if (content.ContainsKey("file"))
     {
         if (content["file"].IndexOf("{import}") == 0)
         {
             file = ContentData.ImportPath() + content["file"].Substring(8);
         }
         else
         {
             file = path + Path.DirectorySeparatorChar + content["file"];
         }
     }
 }
Exemple #5
0
    // generic constructor gets common things
    public GenericData(string name_ini, Dictionary <string, string> content, string path, string type)
    {
        sectionName = name_ini;
        sets        = new List <string>();

        // Has the name been specified?
        if (content.ContainsKey("name"))
        {
            name = new StringKey(content["name"]);
        }
        else
        {
            name = new StringKey(null, name_ini.Substring(type.Length));
        }

        priority = 0;
        if (content.ContainsKey("priority"))
        {
            int.TryParse(content["priority"], out priority);
        }

        if (content.ContainsKey("traits"))
        {
            traits = content["traits"].Split(" ".ToCharArray());
        }
        else // No traits is a valid condition
        {
            traits = new string[0];
        }

        // If image specified it is relative to the path of the ini file
        // absolute paths are not supported
        if (content.ContainsKey("image"))
        {
            if (content["image"].IndexOf("{import}") == 0)
            {
                image = ContentData.ImportPath() + content["image"].Substring(8);
            }
            else
            {
                image = path + "/" + content["image"];
            }
        }
        else // No image is a valid condition
        {
            image = "";
        }
    }
Exemple #6
0
 public MonsterData(string name, Dictionary <string, string> content, string path) : base(name, content, path, type)
 {
     // Get usage info
     if (content.ContainsKey("info"))
     {
         info = new StringKey(content["info"]);
     }
     if (content.ContainsKey("imageplace"))
     {
         if (content["imageplace"].IndexOf("{import}") == 0)
         {
             imagePlace = ContentData.ImportPath() + content["imageplace"].Substring(8);
         }
         else
         {
             imagePlace = path + "/" + content["imageplace"];
         }
     }
     else // No image is a valid condition
     {
         imagePlace = image;
     }
     activations = new string[0];
     if (content.ContainsKey("activation"))
     {
         activations = content["activation"].Split(' ');
     }
     if (content.ContainsKey("health"))
     {
         float.TryParse(content["health"], out healthBase);
     }
     if (content.ContainsKey("healthperhero"))
     {
         float.TryParse(content["healthperhero"], out healthPerHero);
     }
     if (content.ContainsKey("horror"))
     {
         int.TryParse(content["horror"], out horror);
     }
     if (content.ContainsKey("awareness"))
     {
         int.TryParse(content["awareness"], out awareness);
     }
 }
        /// <summary>
        /// After selecting game, we load the localization file.
        /// Deppends on the gameType selected.
        /// There are two Localization files from ffg, one for D2E and one for MoM
        /// </summary>
        private void loadLocalization()
        {
            // After content import, we load the localization file
            if (LocalizationRead.selectDictionary("ffg") == null)
            {
                // FFG default language is always English
                LocalizationRead.AddDictionary("ffg", new DictionaryI18n(
                                                   System.IO.File.ReadAllLines(ContentData.ImportPath() + "/text/Localization.txt"),
                                                   DictionaryI18n.DEFAULT_LANG,
                                                   Game.Get().currentLang));

                // Hack for Dunwich Horror
                if (System.IO.File.Exists(ContentData.ImportPath() + "/text/SCENARIO_CULT_OF_SENTINEL_HILL_MAD22.txt"))
                {
                    LocalizationRead.selectDictionary("ffg").Add(new DictionaryI18n(System.IO.File.ReadAllLines(ContentData.ImportPath() + "/text/SCENARIO_CULT_OF_SENTINEL_HILL_MAD22.txt"),
                                                                                    DictionaryI18n.DEFAULT_LANG, Game.Get().currentLang));
                }
            }
        }
Exemple #8
0
        /// <summary>
        /// After selecting game, we load the localization file.
        /// Deppends on the gameType selected.
        /// There are two Localization files from ffg, one for D2E and one for MoM
        /// </summary>
        private void loadLocalization()
        {
            // After content import, we load the localization file
            if (LocalizationRead.selectDictionary("ffg") == null)
            {
                DictionaryI18n ffgDict = new DictionaryI18n();
                foreach (string file in Directory.GetFiles(ContentData.ImportPath() + "/text", "Localization_*.txt"))
                {
                    ffgDict.AddDataFromFile(file);
                }
                LocalizationRead.AddDictionary("ffg", ffgDict);

                // CoSH used for Dunwich Horror data
                DictionaryI18n cshDict = new DictionaryI18n();
                foreach (string file in Directory.GetFiles(ContentData.ImportPath() + "/text", "SCENARIO_CULT_OF_SENTINEL_HILL_MAD22_*.txt"))
                {
                    cshDict.AddDataFromFile(file);
                }
                LocalizationRead.AddDictionary("csh", cshDict);
            }
        }
Exemple #9
0
    // Read a content pack for list of files and meta data
    public void PopulatePackList(string path)
    {
        // All packs must have a content_pack.ini, otherwise ignore
        if (File.Exists(path + "/content_pack.ini"))
        {
            ContentPack pack = new ContentPack();

            // Get all data from the file
            IniData d = IniRead.ReadFromIni(path + "/content_pack.ini");
            // Todo: better error handling
            if (d == null)
            {
                ValkyrieDebug.Log("Failed to get any data out of " + path + "/content_pack.ini!");
                Application.Quit();
            }

            pack.name = d.Get("ContentPack", "name");
            if (pack.name.Equals(""))
            {
                ValkyrieDebug.Log("Failed to get name data out of " + path + "/content_pack.ini!");
                Application.Quit();
            }

            // id can be empty/missing
            pack.id = d.Get("ContentPack", "id");

            // If this is invalid we will just handle it later, not fatal
            if (d.Get("ContentPack", "image").IndexOf("{import}") == 0)
            {
                pack.image = ContentData.ImportPath() + d.Get("ContentPack", "image").Substring(8);
            }
            else
            {
                pack.image = path + "/" + d.Get("ContentPack", "image");
            }

            // Black description isn't fatal
            pack.description = d.Get("ContentPack", "description");

            // Some packs have a type
            pack.type = d.Get("ContentPack", "type");

            // Get cloned packs
            string cloneString = d.Get("ContentPack", "clone");
            pack.clone = new List <string>();
            foreach (string s in cloneString.Split(" ".ToCharArray(), System.StringSplitOptions.RemoveEmptyEntries))
            {
                pack.clone.Add(s);
            }

            // Get all the other ini files in the pack
            List <string> files = new List <string>();
            // content_pack file is included
            files.Add(path + "/content_pack.ini");

            // No extra files is valid
            if (d.Get("ContentPackData") != null)
            {
                foreach (string file in d.Get("ContentPackData").Keys)
                {
                    files.Add(path + "/" + file);
                }
            }
            // Save list of files
            pack.iniFiles = files;

            // Get all the other ini files in the pack
            Dictionary <string, List <string> > dictFiles = new Dictionary <string, List <string> >();
            // No extra files is valid
            if (d.Get("LanguageData") != null)
            {
                foreach (string s in d.Get("LanguageData").Keys)
                {
                    int    firstSpace = s.IndexOf(' ');
                    string id         = s.Substring(0, firstSpace);
                    string file       = s.Substring(firstSpace + 1);
                    if (!dictFiles.ContainsKey(id))
                    {
                        dictFiles.Add(id, new List <string>());
                    }
                    dictFiles[id].Add(path + "/" + file);
                }
            }
            // Save list of files
            pack.localizationFiles = dictFiles;

            // Add content pack
            allPacks.Add(pack);

            // We finish without actually loading the content, this is done later (content optional)
        }
    }