예제 #1
0
        public static void SortAndCreatePkgs()
        {
            Dictionary <int, List <Game> > dic = new Dictionary <int, List <Game> >();

            foreach (string location in Directory.GetDirectories(INPUT_LOCATION))
            {
                Game g = new GameFolder(location, ref dic);
                g.FindId();
            }

            foreach (string location in Directory.GetFiles(RAP_LOCATION))
            {
                Game g = new GameRap(location, ref dic);
                g.FindId();
            }

            foreach (KeyValuePair <int, List <Game> > v in dic)
            {
                DirectoryInfo di = Sorter.DRY_RUN? new DirectoryInfo(OUTPUT_LOCATION + "\\" + v.Key) : Directory.CreateDirectory(OUTPUT_LOCATION + "\\" + v.Key);
                foreach (Game g in v.Value)
                {
                    g.CopyTo(di.FullName + '\\' + g.Name);
                }
            }


            foreach (KeyValuePair <int, List <Game> > v in dic)
            {
                v.Value.ForEach((Game g) => g.WaitForCopy());
            }


            foreach (KeyValuePair <int, List <Game> > v in dic)
            {
                foreach (Game g in v.Value)
                {
                    if (g is GameFolder gf)
                    {
                        gf.EnsureFolderStructureIsCorrect();
                        gf.CreatePackages();
                    }
                }
            }

            foreach (KeyValuePair <int, List <Game> > v in dic)
            {
                foreach (Game g in v.Value)
                {
                    GameFolder gf = g as GameFolder;
                    gf?.WaitForPkgGen();
                    gf?.DeletePkgMaker();
                }
            }

            foreach (KeyValuePair <int, List <Game> > v in dic)
            {
                List <GameRap>          raps  = new List <GameRap>();
                LinkedList <GameFolder> games = new LinkedList <GameFolder>();
                foreach (Game g in v.Value)
                {
                    if (g is GameFolder gf)
                    {
                        games.AddLast(gf);
                    }
                    else if (g is GameRap gr)
                    {
                        raps.Add(gr);
                    }
                }

                foreach (GameFolder gf in games)
                {
                    gf.FormatPackages(raps);
                    gf.OutputPkg();
                }
            }
        }
예제 #2
0
        public void FormatPackages(IList <GameRap> raps)
        {
            string[] pkgs = Directory.GetFiles(CopyFolder, "*.pkg");

            if (pkgs.Length == 2)
            {
                string pkgFile = "";
                switch (gt)
                {
                case GameType.Game:
                    if (Directory.Exists(CopyFolder + '\\' + "BLUS" + id_) && !Sorter.DRY_RUN)
                    {
                        Directory.Delete(CopyFolder + '\\' + "BLUS" + id_);
                    }
                    pkgFile = pkgs.FirstOrDefault(x => x.Contains("PATCH"));
                    if (pkgFile != null && File.Exists(pkgFile) && !Sorter.DRY_RUN)
                    {
                        File.Delete(pkgFile);
                    }
                    pkgFile = pkgs.FirstOrDefault(x => x.Contains("GAME"));
                    GameRap rap = null;
                    if (raps.Count > 1)
                    {
                        while (rap == null)
                        {
                            Log.Instance.LogLine("Please Select Correct rap");
                            for (int i = 0; i < raps.Count; i++)
                            {
                                Log.Instance.LogLine(i + ":" + raps[i].Name);
                            }

                            if (!int.TryParse(Console.ReadLine(), out int result))
                            {
                                continue;
                            }

                            if (result >= 0 && result < raps.Count)
                            {
                                rap = raps[result];
                            }
                        }
                    }
                    else if (raps.Count == 1)
                    {
                        rap = raps.First();
                    }

                    if (rap != null && pkgFile != null && !Sorter.DRY_RUN)
                    {
                        File.Move(pkgFile, CopyFolder + "\\" + rap.Name + ".pkg");
                    }
                    else if (rap == null)
                    {
                        Log.Instance.LogLine("No Rap File Included for " + CopyFolder);
                    }

                    break;

                case GameType.Patch:
                    if (Directory.Exists(CopyFolder + '\\' + "NPUB" + id_) && !Sorter.DRY_RUN)
                    {
                        Directory.Delete(CopyFolder + '\\' + "NPUB" + id_);
                    }
                    pkgFile = pkgs.FirstOrDefault(x => x.Contains("GAME"));
                    if (pkgFile != null && File.Exists(pkgFile) && !Sorter.DRY_RUN)
                    {
                        File.Delete(pkgFile);
                    }
                    break;

                case GameType.None:
                    break;
                }
            }
            else
            {
                Log.Instance.LogLine("There was an issue generating pkgs for " + CopyFolder);
            }
        }