Beispiel #1
0
        public List <GameInfo> GetInstalledGames()
        {
            var games = new List <GameInfo>();

            foreach (var program in Bethesda.GetBethesdaInstallEntried())
            {
                var installDir = program.Path.Trim('"');
                if (!Directory.Exists(installDir))
                {
                    continue;
                }

                var match   = Regex.Match(program.UninstallString, @"uninstall\/(\d+)");
                var gameId  = match.Groups[1].Value;
                var newGame = new GameInfo()
                {
                    GameId           = gameId,
                    Source           = "Bethesda",
                    InstallDirectory = installDir,
                    PlayAction       = GetGamePlayTask(gameId),
                    Name             = program.DisplayName.RemoveTrademarks(),
                    IsInstalled      = true,
                    Platform         = "PC"
                };

                games.Add(newGame);
            }

            return(games);
        }
Beispiel #2
0
        public override GameMetadata GetMetadata(Game game)
        {
            var program = Bethesda.GetBethesdaInstallEntried().FirstOrDefault(a => a.UninstallString?.Contains($"uninstall/{game.GameId}") == true);
            if (program == null)
            {
                return null;
            }

            var gameInfo = new GameInfo
            {
                Name = StringExtensions.NormalizeGameName(program.DisplayName),
                Links = new List<Link>(),
            };

            gameInfo.Links.Add(new Link("PCGamingWiki", @"http://pcgamingwiki.com/w/index.php?search=" + gameInfo.Name));
            var metadata = new GameMetadata()
            {
                GameInfo = gameInfo
            };

            if (!string.IsNullOrEmpty(program.DisplayIcon) && File.Exists(program.DisplayIcon))
            {
                metadata.Icon = new MetadataFile(program.DisplayIcon);
            }

            return metadata;
        }
        public GameMetadata UpdateGameWithMetadata(Game game)
        {
            var metadata = new GameMetadata();
            var program  = Bethesda.GetBethesdaInstallEntried().FirstOrDefault(a => a.UninstallString?.Contains($"uninstall/{game.GameId}") == true);

            if (program == null)
            {
                return(metadata);
            }

            if (!string.IsNullOrEmpty(program.DisplayIcon) && File.Exists(program.DisplayIcon))
            {
                var iconPath = program.DisplayIcon;
                var iconFile = Path.GetFileName(iconPath);
                var data     = File.ReadAllBytes(iconPath);
                metadata.Icon = new MetadataFile(iconFile, data);
            }

            game.Name = StringExtensions.NormalizeGameName(program.DisplayName);
            return(metadata);
        }