예제 #1
0
        private static void UpdateGameInfo(string line, GameInfo gameInfo)
        {
            var keyValue = line.Split(':');
            var key = keyValue[0].Trim();
            var value = keyValue[1].Trim();

            switch (key)
            {
                case "TITLE":
                    gameInfo.Title = value;
                    break;
                case "ALSO KNOWN AS":
                    gameInfo.AlsoKnownAs = value;
                    break;
                case "YEAR":
                    gameInfo.Year = value;
                    break;
                case "COMPANY":
                    gameInfo.Company = value;
                    break;
                case "PUBLISHER":
                    gameInfo.Publisher = value;
                    break;
                case "PUBLICATION":
                    gameInfo.Publication = value;
                    break;
                case "CRACKER":
                    gameInfo.Cracker = value;
                    break;
                case "DEVELOPER":
                    gameInfo.Developer = value;
                    break;
                case "AUTHOR":
                    gameInfo.Author = value;
                    break;
                case "DESIGNER":
                    gameInfo.Designer = value;
                    break;
                case "ARTIST":
                    gameInfo.Artist = value;
                    break;
                case "LANGUAGE":
                    gameInfo.Language = value;
                    break;
                case "MEMORY REQUIRED":
                    gameInfo.MemoryRequired = value;
                    break;
                case "TYPE":
                    gameInfo.Type = value;
                    break;
                case "SUBTYPE":
                    gameInfo.SubType = value;
                    break;
                case "TITLE SCREEN":
                    gameInfo.TitleScreen = value;
                    break;
                case "CHEAT MODE":
                    gameInfo.CheatMode = value;
                    break;
                case "PROTECTED":
                    gameInfo.Protected = value;
                    break;
                case "PROBLEMS":
                    gameInfo.Problems = value;
                    break;
                case "RUN COMMAND":
                    gameInfo.RunCmd = value;
                    break;
                case "UPLOADED":
                    gameInfo.Uploaded = value;
                    break;
                case "COMMENTS":
                    gameInfo.Comments = value;
                    break;
            }
        }
예제 #2
0
        private static Dictionary<string, GameInfo> GenerateGameInfoList(bool excludeAlreadyDownload = true)
        {
            var gameInfoList = new Dictionary<string, GameInfo>();

            if (!File.Exists(CpcIndexFileDestPath))
            {
                Log(string.Format("Index file does not exist unable to create download list: {0}", CpcIndexFileDestPath));
                return gameInfoList;
            }

            using (var sr = File.OpenText(CpcIndexFileDestPath))
            {
                var line = String.Empty;
                var resourcePath = string.Empty;
                var resourceFileName = string.Empty;
                var readingGameInfo = false;
                GameInfo gameInfo = null;

                while ((line = sr.ReadLine()) != null)
                {
                    if (!readingGameInfo && line.Contains("/cpc/games/"))
                    {
                        resourcePath = line;
                        resourceFileName = Path.GetFileName(resourcePath);
                        var destFile = Path.Combine(RomsDestPath, resourceFileName);

                        if (excludeAlreadyDownload)
                        {
                            if (File.Exists(destFile) && new FileInfo(destFile).Length > 0)
                                continue;
                        }

                        readingGameInfo = true;
                        gameInfo = new GameInfo { ResourcePath = resourcePath };
                        continue;
                    }

                    if (readingGameInfo && line.Contains("----------"))
                    {
                        readingGameInfo = false;
                        gameInfoList.Add(resourceFileName, gameInfo);
                        continue;
                    }

                    if (readingGameInfo)
                        UpdateGameInfo(line, gameInfo);
                }
            }

            return gameInfoList;
        }