コード例 #1
0
 public static void InitAllMetadata()
 {
     foreach (ModContentPack runningMod in LoadedModManager.RunningMods)
     {
         HashSet <string> hashSet = new HashSet <string>();
         foreach (string item2 in runningMod.foldersToLoadDescendingOrder)
         {
             string text = Path.Combine(item2, "Languages");
             if (new DirectoryInfo(text).Exists)
             {
                 foreach (VirtualDirectory directory in AbstractFilesystem.GetDirectories(text, "*", SearchOption.TopDirectoryOnly))
                 {
                     if (!directory.FullPath.StartsWith(text))
                     {
                         Log.Error("Failed to get a relative path for a file: " + directory.FullPath + ", located in " + text);
                     }
                     else
                     {
                         string item = directory.FullPath.Substring(text.Length);
                         if (!hashSet.Contains(item))
                         {
                             InitLanguageMetadataFrom(directory);
                             hashSet.Add(item);
                         }
                     }
                 }
             }
         }
     }
     languages.SortBy((LoadedLanguage l) => l.folderName);
     defaultLanguage = languages.FirstOrDefault((LoadedLanguage la) => la.folderName == DefaultLangFolderName);
     activeLanguage  = languages.FirstOrDefault((LoadedLanguage la) => la.folderName == Prefs.LangFolderName);
     if (activeLanguage == null)
     {
         Prefs.LangFolderName = DefaultLangFolderName;
         activeLanguage       = languages.FirstOrDefault((LoadedLanguage la) => la.folderName == Prefs.LangFolderName);
     }
     if (activeLanguage == null || defaultLanguage == null)
     {
         Log.Error("No default language found!");
         defaultLanguage = languages[0];
         activeLanguage  = languages[0];
     }
     activeLanguage.LoadMetadata();
 }
コード例 #2
0
 public void LoadMetadata()
 {
     if (info != null && infoIsRealMetadata)
     {
         return;
     }
     infoIsRealMetadata = true;
     foreach (ModContentPack runningMod in LoadedModManager.RunningMods)
     {
         foreach (string item in runningMod.foldersToLoadDescendingOrder)
         {
             string text = Path.Combine(item, "Languages");
             if (!new DirectoryInfo(text).Exists)
             {
                 continue;
             }
             foreach (VirtualDirectory directory in AbstractFilesystem.GetDirectories(text, "*", SearchOption.TopDirectoryOnly))
             {
                 if (directory.Name == folderName || directory.Name == legacyFolderName)
                 {
                     info = DirectXmlLoader.ItemFromXmlFile <LanguageInfo>(directory, "LanguageInfo.xml", resolveCrossRefs: false);
                     if (info.friendlyNameNative.NullOrEmpty() && directory.FileExists("FriendlyName.txt"))
                     {
                         info.friendlyNameNative = directory.ReadAllText("FriendlyName.txt");
                     }
                     if (info.friendlyNameNative.NullOrEmpty())
                     {
                         info.friendlyNameNative = folderName;
                     }
                     if (info.friendlyNameEnglish.NullOrEmpty())
                     {
                         info.friendlyNameEnglish = folderName;
                     }
                     return;
                 }
             }
         }
     }
 }