示例#1
0
        private static void LoadedFilesForMod()
        {
            List <DebugMenuOption> list = new List <DebugMenuOption>();

            foreach (ModContentPack item in LoadedModManager.RunningModsListForReading)
            {
                ModContentPack mod = item;
                list.Add(new DebugMenuOption(mod.Name, DebugMenuOptionMode.Action, delegate
                {
                    ModMetaData metaData = ModLister.GetModWithIdentifier(mod.PackageId);
                    if (metaData.loadFolders != null && metaData.loadFolders.DefinedVersions().Count != 0)
                    {
                        Find.WindowStack.Add(new Dialog_DebugOptionListLister(from ver in metaData.loadFolders.DefinedVersions()
                                                                              select new DebugMenuOption(ver, DebugMenuOptionMode.Action, delegate
                        {
                            ShowTable((from f in metaData.loadFolders.FoldersForVersion(ver)
                                       select Path.Combine(mod.RootDir, f.folderName)).Reverse().ToList());
                        })));
                    }
                    else
                    {
                        ShowTable(null);
                    }
                }));
                void ShowTable(List <string> loadFolders)
                {
                    List <Pair <string, string> > list2 = new List <Pair <string, string> >();

                    list2.AddRange(from f in DirectXmlLoader.XmlAssetsInModFolder(mod, "Defs/", loadFolders)
                                   select new Pair <string, string>(f.FullFilePath, "-"));
                    list2.AddRange(from f in DirectXmlLoader.XmlAssetsInModFolder(mod, "Patches/", loadFolders)
                                   select new Pair <string, string>(f.FullFilePath, "-"));
                    list2.AddRange(from f in ModContentPack.GetAllFilesForMod(mod, GenFilePaths.ContentPath <Texture2D>(), ModContentLoader <Texture2D> .IsAcceptableExtension, loadFolders)
                                   select new Pair <string, string>(f.Value.FullName, f.Key));
                    list2.AddRange(from f in ModContentPack.GetAllFilesForMod(mod, GenFilePaths.ContentPath <AudioClip>(), ModContentLoader <AudioClip> .IsAcceptableExtension, loadFolders)
                                   select new Pair <string, string>(f.Value.FullName, f.Key));
                    list2.AddRange(from f in ModContentPack.GetAllFilesForMod(mod, GenFilePaths.ContentPath <string>(), ModContentLoader <string> .IsAcceptableExtension, loadFolders)
                                   select new Pair <string, string>(f.Value.FullName, f.Key));
                    list2.AddRange(from f in ModContentPack.GetAllFilesForModPreserveOrder(mod, "Assemblies/", (string e) => e.ToLower() == ".dll", loadFolders)
                                   select new Pair <string, string>(f.Item2.FullName, f.Item1));
                    DebugTables.MakeTablesDialog(list2, new List <TableDataGetter <Pair <string, string> > >
                    {
                        new TableDataGetter <Pair <string, string> >("full path", (Pair <string, string> f) => f.First),
                        new TableDataGetter <Pair <string, string> >("internal path", (Pair <string, string> f) => f.Second)
                    }.ToArray());
                }
            }
            Find.WindowStack.Add(new Dialog_DebugOptionListLister(list));
        }
示例#2
0
 public void ReloadAll()
 {
     if (!globalResolverIsSet)
     {
         ResolveEventHandler @object = (object obj, ResolveEventArgs args) => Assembly.GetExecutingAssembly();
         AppDomain.CurrentDomain.AssemblyResolve += @object.Invoke;
         globalResolverIsSet = true;
     }
     foreach (FileInfo item in from f in ModContentPack.GetAllFilesForModPreserveOrder(mod, "Assemblies/", (string e) => e.ToLower() == ".dll")
              select f.Item2)
     {
         Assembly assembly = null;
         try
         {
             byte[]   rawAssembly = File.ReadAllBytes(item.FullName);
             FileInfo fileInfo    = new FileInfo(Path.Combine(item.DirectoryName, Path.GetFileNameWithoutExtension(item.FullName)) + ".pdb");
             if (fileInfo.Exists)
             {
                 byte[] rawSymbolStore = File.ReadAllBytes(fileInfo.FullName);
                 assembly = AppDomain.CurrentDomain.Load(rawAssembly, rawSymbolStore);
             }
             else
             {
                 assembly = AppDomain.CurrentDomain.Load(rawAssembly);
             }
         }
         catch (Exception ex)
         {
             Log.Error("Exception loading " + item.Name + ": " + ex.ToString());
             return;
         }
         if (!(assembly == null) && AssemblyIsUsable(assembly))
         {
             loadedAssemblies.Add(assembly);
         }
     }
 }