Beispiel #1
0
 private static void ValidateCollection(AssetCollection collection)
 {
     Version[] versions = collection.Files.Select(t => t.Version).Distinct().ToArray();
     if (versions.Count() > 1)
     {
         Logger.Instance.Log(LogType.Warning, LogCategory.Import, $"Asset collection has (possibly) incompatible with each assets file versions. Here they are:");
         foreach (Version version in versions)
         {
             Logger.Instance.Log(LogType.Warning, LogCategory.Import, version.ToString());
         }
     }
 }
Beispiel #2
0
        public static void Main(string[] args)
        {
            Logger.Instance                = ConsoleLogger.Instance;
            Config.IsAdvancedLog           = true;
            Config.IsGenerateGUIDByContent = false;
            Config.IsExportDependencies    = false;

            if (args.Length == 0)
            {
                Console.WriteLine("No arguments");
                Console.ReadKey();
                return;
            }
            foreach (string arg in args)
            {
                if (!FileMultiStream.Exists(arg))
                {
                    Console.WriteLine(FileMultiStream.IsMultiFile(arg) ?
                                      $"File {arg} doen't has all parts for combining" :
                                      $"File {arg} doesn't exist", arg);
                    Console.ReadKey();
                    return;
                }
            }

#if !DEBUG_PROGRAM
            try
#endif
            {
                AssetCollection collection = new AssetCollection();
                LoadFiles(collection, args);

                LoadDependencies(collection, args);
                ValidateCollection(collection);

                string name       = Path.GetFileNameWithoutExtension(args.First());
                string exportPath = ".\\Ripped\\" + name;
                if (Directory.Exists(exportPath))
                {
                    Directory.Delete(exportPath, true);
                }
                collection.Exporter.Export(exportPath, FetchExportObjects(collection));

                Logger.Instance.Log(LogType.Info, LogCategory.General, "Finished");
            }
#if !DEBUG_PROGRAM
            catch (Exception ex)
            {
                Logger.Instance.Log(LogType.Error, LogCategory.General, ex.ToString());
            }
#endif
            Console.ReadKey();
        }
Beispiel #3
0
        private static void LoadDependency(AssetCollection collection, IReadOnlyCollection <string> directories, string fileName)
        {
            foreach (string loadName in FetchNameVariants(fileName))
            {
                bool found = TryLoadDependency(collection, directories, fileName, loadName);
                if (found)
                {
                    return;
                }
            }

            Logger.Instance.Log(LogType.Warning, LogCategory.Import, $"Dependency '{fileName}' wasn't found");
        }
Beispiel #4
0
        private static void LoadFiles(AssetCollection collection, IEnumerable <string> filePathes)
        {
            List <string> processed = new List <string>();

            foreach (string path in filePathes)
            {
                string filePath = FileMultiStream.GetFilePath(path);
                if (processed.Contains(filePath))
                {
                    continue;
                }

                string fileName = FileMultiStream.GetFileName(path);
                using (Stream stream = FileMultiStream.OpenRead(path))
                {
                    collection.Read(stream, filePath, fileName);
                }
                processed.Add(filePath);
            }
        }
Beispiel #5
0
 public static IEnumerable <Object> FetchExportObjects(AssetCollection collection)
 {
     //yield break;
     return(collection.FetchAssets());
 }