protected override void OnStart()
        {
            _gameDataRepository.Start();

            // Initialize data in a in memory repository
            using (var writeContext = _gameDataRepository.BeginWrite())
            {
                InitTeamAndPlayerData(writeContext);
                InitGameSchedule(writeContext);
            }

            // Load all games and start the clock
            var allGames = _gameDataRepository.GetAll <Game>();


            foreach (var game in allGames)
            {
                var activeGame = new GameMetadata(game);

                _games.Add(activeGame);
            }

            //
            _clock.AccelerationFactor = 2m;
            _clock.Start();

            //
            _startableThread.Start();
        }
 private void ValidateGameDate(GameMetadata metadata)
 {
     Assert.IsNotNull(metadata.ReleaseDate);
     Assert.IsTrue(metadata.Developers.Count() > 0 && !string.IsNullOrEmpty(metadata.Developers.First().ToString()));
     Assert.IsTrue(metadata.Publishers.Count() > 0 && !string.IsNullOrEmpty(metadata.Publishers.First().ToString()));
     Assert.IsTrue(metadata.Genres.Count() > 0 && !string.IsNullOrEmpty(metadata.Genres.First().ToString()));
 }
Пример #3
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  = Twitch.GetUninstallRecord(game.GameId);

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

            if (!string.IsNullOrEmpty(program.DisplayIcon) && File.Exists(program.DisplayIcon))
            {
                var iconPath = program.DisplayIcon;
                var iconFile = Path.GetFileName(iconPath);
                if (iconPath.EndsWith("ico", StringComparison.OrdinalIgnoreCase))
                {
                    var data = File.ReadAllBytes(iconPath);
                    metadata.Icon = new MetadataFile(iconFile, data);
                }
                else
                {
                    var exeIcon = IconExtension.ExtractIconFromExe(iconPath, true);
                    if (exeIcon != null)
                    {
                        var iconName = Guid.NewGuid() + ".png";
                        metadata.Icon = new MetadataFile(iconName, exeIcon.ToByteArray(System.Drawing.Imaging.ImageFormat.Png));
                    }
                }
            }

            game.Name = StringExtensions.NormalizeGameName(program.DisplayName);
            return(metadata);
        }
Пример #5
0
    public Task <GameMetadata> Load(string GUID)
    {
        Debug.Log("Reading metadata file... " + GUID);
        StreamReader metadataReader = File.OpenText(Application.persistentDataPath
                                                    + $"/Saves/{GUID}/metadata.json");
        string jsonMetadata = metadataReader.ReadToEnd();

        Debug.Log("Read JSON file");
        metadataReader.Close();
        Debug.Log(jsonMetadata);
        GameMetadata gameMetadata = JsonConvert.DeserializeObject <GameMetadata>(jsonMetadata);

        Debug.Log("JSON Deserialized");
        Debug.Log("Metadata read and loaded as game metadata");

        Debug.Log("Copying game metadata");
        this.GUID = gameMetadata.GUID;
        SaveName  = gameMetadata.SaveName;
        Days      = gameMetadata.Days;
        Weather   = gameMetadata.Weather;
        LastVisit = gameMetadata.LastVisit;
        Debug.Log("Game metadata copied!");

        return(Task.FromResult(this));
    }
Пример #6
0
        public void ProcessClose()
        {
            if (null != Callback && Accepted)
            {
                GameMetadata metadata = new GameMetadata();

                foreach (ObservableGameMetadataTag tag in StandardTags)
                {
                    try
                    {
                        metadata.SetTag(tag.Key, tag.Value);
                    }
                    catch (Exception)
                    {
                        metadata.SetTag(tag.Key, _originalMetadata.GetTag(tag.Key));
                    }
                }

                foreach (ObservableGameMetadataTag tag in OptionalTags)
                {
                    try
                    {
                        metadata.SetTag(tag.Key, tag.Value);
                    }
                    catch (Exception)
                    {
                        metadata.SetTag(tag.Key, _originalMetadata.GetTag(tag.Key));
                    }
                }

                Callback(metadata);
            }
        }
    public void Setup()
    {
        if (_ins != null)
        {
            Debug.LogError($"Multiple {this.GetType()} were instantiated");
            return;
        }
        _ins = this;

        this.datas = new List <GameMetadata>();
        // read file
        string content = File.ReadAllText($"Assets/{this.filename}");

        // iterate array of metadata
        foreach (JObject item in JArray.Parse(content).ToArray())
        {
            GameMetadata newData = new GameMetadata();
            newData.id     = Convert.ToInt32(item["ID"].Value <string>());
            newData.name   = item["Name"].Value <string>();
            newData.type   = Convert.ToInt32(item["Type"].Value <string>());
            newData.values = new List <string>();
            for (int i = 1; i <= 5; i++)
            {
                newData.values.Add(item[$"Value{i}"].Value <string>());
            }
            this.datas.Add(newData);
        }
    }
        public GameMetadata UpdateGameWithMetadata(Game game)
        {
            var metadata = new GameMetadata();
            var product  = BattleNetGames.GetAppDefinition(game.GameId);

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

            if (string.IsNullOrEmpty(product.IconUrl))
            {
                return(metadata);
            }

            game.Name = product.Name;
            var icon     = HttpDownloader.DownloadData(product.IconUrl);
            var iconFile = Path.GetFileName(product.IconUrl);

            metadata.Icon = new MetadataFile(iconFile, icon);
            var cover     = HttpDownloader.DownloadData(product.CoverUrl);
            var coverFile = Path.GetFileName(product.CoverUrl);

            metadata.Image           = new MetadataFile(coverFile, cover);
            game.BackgroundImage     = product.BackgroundUrl;
            metadata.BackgroundImage = product.BackgroundUrl;
            game.Links = new ObservableCollection <Link>(product.Links);
            return(metadata);
        }
 private void ValidateGameDate(GameMetadata metadata)
 {
     Assert.IsNotNull(metadata.GameInfo.ReleaseDate);
     Assert.IsTrue(metadata.GameInfo.Developers.Count > 0 && !string.IsNullOrEmpty(metadata.GameInfo.Developers[0]));
     Assert.IsTrue(metadata.GameInfo.Publishers.Count > 0 && !string.IsNullOrEmpty(metadata.GameInfo.Publishers[0]));
     Assert.IsTrue(metadata.GameInfo.Genres.Count > 0 && !string.IsNullOrEmpty(metadata.GameInfo.Genres[0]));
 }
        public void PreviewGameData(GameMetadata metadata)
        {
            ShowCheckBoxes = true;

            var diffItems = GetDisplayDiffFields(EditingGame, metadata);

            if (diffItems.HasItems())
            {
                var comp = new MetadataComparisonViewModel(
                    database,
                    new MetadataComparisonWindowFactory(),
                    dialogs,
                    resources,
                    EditingGame,
                    metadata,
                    diffItems);

                if (comp.OpenView() == true)
                {
                    LoadNewMetadata(comp.ResultMetadata);
                }
            }
            else
            {
                LoadNewMetadata(metadata);
            }
        }
Пример #11
0
        public override GameMetadata GetMetadata(Game game)
        {
            var gameInfo = new GameInfo
            {
                Links = new List <Link>()
            };

            var metadata = new GameMetadata()
            {
                GameInfo = gameInfo
            };

            gameInfo.Links.Add(new Link("PCGamingWiki", @"http://pcgamingwiki.com/w/index.php?search=" + game.Name));

            var program = Twitch.GetUninstallRecord(game.GameId);

            if (program != null)
            {
                gameInfo.Name = StringExtensions.NormalizeGameName(program.DisplayName);
                if (!string.IsNullOrEmpty(program.DisplayIcon) && File.Exists(program.DisplayIcon))
                {
                    var iconPath = program.DisplayIcon;
                    if (iconPath.EndsWith("ico", StringComparison.OrdinalIgnoreCase))
                    {
                        metadata.Icon = new MetadataFile(program.DisplayIcon);
                    }
                    else
                    {
                        var exeIcon = IconExtension.ExtractIconFromExe(iconPath, true);
                        if (exeIcon != null)
                        {
                            var iconName = Guid.NewGuid() + ".png";
                            metadata.Icon = new MetadataFile(iconName, exeIcon.ToByteArray(System.Drawing.Imaging.ImageFormat.Png));
                        }
                    }
                }
            }

            if (entitlements?.Any() == true)
            {
                var entitlement = entitlements.FirstOrDefault(a => a.product.id == game.GameId);
                if (entitlement != null)
                {
                    if (entitlement.product.productDetail?.iconUrl != null)
                    {
                        metadata.CoverImage = new MetadataFile(entitlement.product.productDetail.iconUrl);
                    }

                    // Ignore Getting Over It background, which is set if the publisher didn't assigned any
                    // https://github.com/JosefNemec/Playnite/issues/1376
                    var backgroundUrl = entitlement.product.productDetail?.details?.backgroundUrl2;
                    if (!backgroundUrl.IsNullOrEmpty() && backgroundUrl != "https://images-na.ssl-images-amazon.com/images/I/A1VAra5JJvL.jpg")
                    {
                        metadata.BackgroundImage = new MetadataFile(entitlement.product.productDetail.details.backgroundUrl2);
                    }
                }
            }

            return(metadata);
        }
Пример #12
0
        public void overrideGameProperties(GameMetadata gameMetadata)
        {
            var game = PlayniteApi.Database.Games.Where(g => g.PluginId == Id).Where(g => g.GameId == gameMetadata.GameId).FirstOrDefault();

            if (game != null)
            {
                var updateGame = false;
                if (settings.Settings.UpdateUserScoreOnLibUpdate == true && gameMetadata.UserScore != 0 && gameMetadata.UserScore != game.UserScore)
                {
                    game.UserScore = gameMetadata.UserScore;
                    updateGame     = true;
                }

                ////TODO Completion Status matching
                //if (settings.UpdateCompletionStatusOnLibUpdate == true && gameMetadata.CompletionStatus != game.CompletionStatus)
                //{
                //    game.CompletionStatus = gameMetadata.CompletionStatus;
                //    updateGame = true;
                //}

                if (settings.Settings.UpdateProgressOnLibUpdate == true && gameMetadata.Version != game.Version)
                {
                    game.Version = gameMetadata.Version;
                    updateGame   = true;
                }

                if (updateGame == true)
                {
                    PlayniteApi.Database.Games.Update(game);
                }
            }
        }
 public ChallengeGenerationWorkflow(ChallengeGenerator challengeGenerator, BggApiService bggApiService, GameMetadata metadata, ScgOptions options)
 {
     _challengeGenerator = challengeGenerator;
     _bggApiService      = bggApiService;
     _metadata           = metadata;
     _options            = options;
 }
Пример #14
0
        public override GameMetadata GetMetadata(Game game)
        {
            var program = Programs.GetUnistallProgramsList().FirstOrDefault(a => a.RegistryKeyName == "Uplay Install " + game.GameId);

            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);
        }
Пример #15
0
    public static async Task ConvertDirectory()
    {
        Debug.Log("Finding saves to be converted in the saves directory");

        // VERSION 0
        string[] gameDataPaths = Directory.GetFiles(Application.persistentDataPath + "/Saves", "*dat");
        foreach (string path in gameDataPaths)
        {
            Debug.Log("Converting " + path);
            await Convert(path, 0);
        }

        // VERSION 1
        string[] directoryPaths = Directory.GetDirectories(Application.persistentDataPath + "/Saves");
        foreach (string path in directoryPaths)
        {
            Debug.Log("Testing " + path);

            StreamReader streamReader = File.OpenText(path + "/metadata.json");
            GameMetadata metadata     = JsonConvert.DeserializeObject <GameMetadata>(streamReader.ReadToEnd());
            streamReader.Close();

            if (metadata.SaveVersion == 1)
            {
                await Convert(metadata.GUID, 1);
            }
        }

        // VERSION 2+ WILL BE CONVERTED ON LOAD
    }
        private async Task UpsertBetIfValid(ParticipantBetCommand command, Guid userId)
        {
            GameMetadata gameMetadata = await _gameMetadataCommandRepository.GetAsync(command.GameId);

            if (gameMetadata.StartDate < DateTimeOffset.UtcNow)
            {
                throw new ValidationException("Must no bet for a game which is already running.");
            }

            Bet bet = await _repository.GetByGameIdAndUserIdAsync(command.GameId, userId);

            if (bet != null)
            {
                if (bet.ActualResultPresent)
                {
                    throw new ValidationException("A bet which has an actual result can not be changed anymore.");
                }

                await _repository.UpdateAsync(bet.Id, b => SetValues(b, command, userId));
            }
            else
            {
                await _repository.AddAsync(b => SetValues(b, command, userId));
            }
        }
Пример #17
0
        public GameMetadata UpdateGameWithMetadata(Game game)
        {
            var metadata = new GameMetadata();
            var product  = BattleNetProducts.FirstOrDefault(a => a.ProductId == game.ProviderId);

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

            if (string.IsNullOrEmpty(product.IconUrl))
            {
                return(metadata);
            }

            game.Name = product.Name;
            var icon     = Web.DownloadData(product.IconUrl);
            var iconFile = Path.GetFileName(product.IconUrl);

            metadata.Icon = new Database.FileDefinition($"images/battlenet/{game.ProviderId}/{iconFile}", iconFile, icon);
            var cover     = Web.DownloadData(product.CoverUrl);
            var coverFile = Path.GetFileName(product.CoverUrl);

            metadata.Image           = new Database.FileDefinition($"images/battlenet/{game.ProviderId}/{coverFile}", coverFile, cover);
            game.BackgroundImage     = product.BackgroundUrl;
            metadata.BackgroundImage = product.BackgroundUrl;
            game.Links = new ObservableCollection <Link>(product.Links);
            return(metadata);
        }
Пример #18
0
        public static GameMetadata ExpandGame(this GameMetadata game)
        {
            var g = game.GetClone();

            g.InstallDirectory             = g.StringExpand(g.InstallDirectory);
            g.Roms.ForEach(rom => rom.Path = g.StringExpand(rom.Path));
            return(g);
        }
Пример #19
0
        public GameMetadataViewModel(GameMetadata metadata = null, Action <GameMetadata> callback = null)
        {
            _originalMetadata = null != metadata?metadata.Clone() : new GameMetadata();

            LoadTags();

            Callback = callback;
        }
Пример #20
0
        public override GameMetadata GetMetadata(Game game)
        {
            var resources = library.PlayniteApi.Resources;
            var storeData = DownloadGameMetadata(game);

            if (storeData.GameDetails == null)
            {
                logger.Warn($"Could not gather metadata for game {game.GameId}");
                return(null);
            }

            var gameInfo = new GameInfo
            {
                Name        = StringExtensions.NormalizeGameName(storeData.GameDetails.title),
                Description = storeData.GameDetails.description.full,
                Links       = new List <Link>()
            };

            var metadata = new GameMetadata()
            {
                GameInfo        = gameInfo,
                Icon            = storeData.Icon,
                CoverImage      = storeData.CoverImage,
                BackgroundImage = storeData.BackgroundImage
            };

            if (!string.IsNullOrEmpty(storeData.GameDetails.links.forum))
            {
                gameInfo.Links.Add(new Link(resources.GetString("LOCCommonLinksForum"), storeData.GameDetails.links.forum));
            }
            ;

            if (!string.IsNullOrEmpty(storeData.GameDetails.links.product_card))
            {
                gameInfo.Links.Add(new Link(resources.GetString("LOCCommonLinksStorePage"), storeData.GameDetails.links.product_card));
            }
            ;

            gameInfo.Links.Add(new Link("PCGamingWiki", @"http://pcgamingwiki.com/w/index.php?search=" + storeData.GameDetails.title));

            if (storeData.StoreDetails != null)
            {
                gameInfo.Genres     = storeData.StoreDetails.genres?.Select(a => a.name).ToList();
                gameInfo.Tags       = storeData.StoreDetails.tags?.Select(a => a.name).ToList();
                gameInfo.Developers = storeData.StoreDetails.developers.Select(a => a.name).ToList();
                gameInfo.Publishers = new List <string>()
                {
                    storeData.StoreDetails.publisher
                };
                var cultInfo = new CultureInfo("en-US", false).TextInfo;
                if (gameInfo.ReleaseDate == null && storeData.StoreDetails.globalReleaseDate != null)
                {
                    gameInfo.ReleaseDate = storeData.StoreDetails.globalReleaseDate;
                }
            }

            return(metadata);
        }
Пример #21
0
        public override GameMetadata GetMetadata(Game game)
        {
            var gameInfo = new GameInfo
            {
                Links = new List <Link>()
            };

            var metadata = new GameMetadata()
            {
                GameInfo = gameInfo
            };

            gameInfo.Links.Add(new Link("PCGamingWiki", @"http://pcgamingwiki.com/w/index.php?search=" + game.Name));

            var program = Twitch.GetUninstallRecord(game.GameId);

            if (program != null)
            {
                gameInfo.Name = StringExtensions.NormalizeGameName(program.DisplayName);
                if (!string.IsNullOrEmpty(program.DisplayIcon) && File.Exists(program.DisplayIcon))
                {
                    var iconPath = program.DisplayIcon;
                    if (iconPath.EndsWith("ico", StringComparison.OrdinalIgnoreCase))
                    {
                        metadata.Icon = new MetadataFile(program.DisplayIcon);
                    }
                    else
                    {
                        var exeIcon = IconExtension.ExtractIconFromExe(iconPath, true);
                        if (exeIcon != null)
                        {
                            var iconName = Guid.NewGuid() + ".png";
                            metadata.Icon = new MetadataFile(iconName, exeIcon.ToByteArray(System.Drawing.Imaging.ImageFormat.Png));
                        }
                    }
                }
            }

            if (entitlements?.Any() == true)
            {
                var entitlement = entitlements.FirstOrDefault(a => a.product.id == game.GameId);
                if (entitlement != null)
                {
                    if (entitlement.product.productDetail?.iconUrl != null)
                    {
                        metadata.CoverImage = new MetadataFile(entitlement.product.productDetail.iconUrl);
                    }

                    if (entitlement.product.productDetail?.details?.backgroundUrl2 != null)
                    {
                        metadata.BackgroundImage = new MetadataFile(entitlement.product.productDetail.details.backgroundUrl2);
                    }
                }
            }

            return(metadata);
        }
Пример #22
0
        public void DownloadPluginData(MetadataPlugin plugin)
        {
            var res = dialogs.ActivateGlobalProgress((args) =>
            {
                var provider = plugin.GetMetadataProvider(new MetadataRequestOptions(EditingGame, false));
                if (provider != null)
                {
                    try
                    {
                        var fieldArgs = new GetMetadataFieldArgs {
                            CancelToken = args.CancelToken
                        };
                        var metadata = new GameMetadata
                        {
                            Name            = provider.GetName(fieldArgs),
                            Genres          = provider.GetGenres(fieldArgs)?.Where(a => a != null).ToHashSet(),
                            ReleaseDate     = provider.GetReleaseDate(fieldArgs),
                            Developers      = provider.GetDevelopers(fieldArgs)?.Where(a => a != null).ToHashSet(),
                            Publishers      = provider.GetPublishers(fieldArgs)?.Where(a => a != null).ToHashSet(),
                            Tags            = provider.GetTags(fieldArgs)?.Where(a => a != null).ToHashSet(),
                            Features        = provider.GetFeatures(fieldArgs)?.Where(a => a != null).ToHashSet(),
                            Description     = provider.GetDescription(fieldArgs),
                            Links           = provider.GetLinks(fieldArgs)?.Where(a => a != null).ToList(),
                            CriticScore     = provider.GetCriticScore(fieldArgs),
                            CommunityScore  = provider.GetCommunityScore(fieldArgs),
                            AgeRatings      = provider.GetAgeRatings(fieldArgs)?.Where(a => a != null).ToHashSet(),
                            Series          = provider.GetSeries(fieldArgs)?.Where(a => a != null).ToHashSet(),
                            Regions         = provider.GetRegions(fieldArgs)?.Where(a => a != null).ToHashSet(),
                            Platforms       = provider.GetPlatforms(fieldArgs)?.Where(a => a != null).ToHashSet(),
                            Icon            = provider.GetIcon(fieldArgs),
                            CoverImage      = provider.GetCoverImage(fieldArgs),
                            BackgroundImage = provider.GetBackgroundImage(fieldArgs)
                        };

                        Application.Current.Dispatcher.Invoke(() => PreviewGameData(ConvertGameInfo(metadata)));
                    }
                    finally
                    {
                        provider.Dispose();
                    }
                }
            }, new GlobalProgressOptions(LOC.DownloadingLabel)
            {
                IsIndeterminate = true,
                Cancelable      = true
            });

            if (res.Error != null)
            {
                logger.Error(res.Error, string.Format("Failed to download metadata, {0}, {1}", Game.PluginId, Game.GameId));
                dialogs.ShowMessage(
                    string.Format(resources.GetString("LOCMetadataDownloadError"), res.Error.Message),
                    resources.GetString("LOCDownloadError"),
                    MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Пример #23
0
        public Task <IEnumerable <ISearchItem <string> > > GetItemsTask(string query, IReadOnlyList <Candidate> addedItems)
        {
            if (string.IsNullOrWhiteSpace(query))
            {
                return(null);
            }

            var metadataArgs = new GetMetadataFieldArgs();

            return(Task.Run(() =>
            {
                var game = new Game(query);
                var gameMetadata = new GameMetadata();
                var requestOptions = new MetadataRequestOptions(game, true);

                List <ISearchItem <string> > items = new List <ISearchItem <string> >();

                using (var provider = metadataPlugin.GetMetadataProvider(requestOptions))
                {
                    var item = new CommandItem();
                    var fields = provider.AvailableFields;

                    if (fields.Contains(MetadataField.Icon))
                    {
                        gameMetadata.Icon = provider.GetIcon(new GetMetadataFieldArgs());
                    }
                    if (fields.Contains(MetadataField.Platform))
                    {
                        gameMetadata.Platforms = provider.GetPlatforms(new GetMetadataFieldArgs()).ToHashSet();
                    }
                    if (fields.Contains(MetadataField.Genres))
                    {
                        gameMetadata.Genres = provider.GetGenres(new GetMetadataFieldArgs()).ToHashSet();
                    }
                    if (fields.Contains(MetadataField.Name) && provider.GetName(new GetMetadataFieldArgs()) is string name)
                    {
                        gameMetadata.Name = name;
                        var tempGame = SearchPlugin.Instance.PlayniteApi.Database.ImportGame(gameMetadata);
                        items.Add(new GameSearchItem(tempGame));
                        if (SearchPlugin.Instance.PlayniteApi.Database.Games.Remove(tempGame.Id))
                        {
                        }
                        else
                        {
                        }
                    }
                }

                return items.AsEnumerable();
            }, metadataArgs.CancelToken));
        }
    // Start is called before the first frame update
    void Start()
    {
        GameMetadata data = GameMetadataParser.ins.datas[this.metaId];

        Debug.Assert(data.type == 1);
        this.hp   = Convert.ToInt32(data.values[0]);
        this.goal = Convert.ToInt32(data.values[3]);

        NotificationCenter.ins.RegisterHandler("fix", OnFixEvent, this.uuid);
        NotificationCenter.ins.RegisterHandler("damage", OnDamageEvent, this.uuid);
        NotificationCenter.ins.RegisterHandler("end_game", OnEndGameEvent);

        this.AfterSpawn();
        this.spriteRenderer = GetComponent <SpriteRenderer>();
    }
        public override GameMetadata GetMetadata(Game game)
        {
            var gameInfo = new GameInfo
            {
                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
            };

            var prod = productInfo?.FirstOrDefault(a => a.uplay_id.ToString() == game.GameId);

            if (prod != null)
            {
                if (!prod.root.icon_image.IsNullOrEmpty())
                {
                    metadata.Icon = new MetadataFile(prod.root.icon_image);
                }

                if (!prod.root.thumb_image.IsNullOrEmpty())
                {
                    metadata.CoverImage = new MetadataFile(prod.root.thumb_image);
                }

                if (!prod.root.background_image.IsNullOrEmpty())
                {
                    metadata.BackgroundImage = new MetadataFile(prod.root.background_image);
                }
            }
            else
            {
                var program = Programs.GetUnistallProgramsList().FirstOrDefault(a => a.RegistryKeyName == "Uplay Install " + game.GameId);
                if (program != null)
                {
                    if (!string.IsNullOrEmpty(program.DisplayIcon) && File.Exists(program.DisplayIcon))
                    {
                        metadata.Icon = new MetadataFile(program.DisplayIcon);
                    }
                }
            }

            return(metadata);
        }
Пример #26
0
        public override GameMetadata GetMetadata(Game game)
        {
            var gameInfo = new GameInfo
            {
                Links = new List <Link>()
            };

            var metadata = new GameMetadata()
            {
                GameInfo = gameInfo
            };

            gameInfo.Links.Add(new Link("PCGamingWiki", @"http://pcgamingwiki.com/w/index.php?search=" + game.Name));

            var program = AmazonGames.GetUninstallRecord(game.GameId);

            if (program != null)
            {
                gameInfo.Name = StringExtensions.NormalizeGameName(program.DisplayName);
                if (!string.IsNullOrEmpty(program.DisplayIcon) && File.Exists(program.DisplayIcon))
                {
                    var iconPath = program.DisplayIcon;
                    if (iconPath.EndsWith("ico", StringComparison.OrdinalIgnoreCase))
                    {
                        metadata.Icon = new MetadataFile(program.DisplayIcon);
                    }
                    else
                    {
                        using (var ms = new MemoryStream())
                        {
                            if (IconExtractor.ExtractMainIconFromFile(iconPath, ms))
                            {
                                var iconName = Guid.NewGuid() + ".ico";
                                metadata.Icon = new MetadataFile(iconName, ms.ToArray());
                            }
                        }
                    }
                }
            }

            return(metadata);
        }
 private void GetData()
 {
     if (options.IsBackgroundDownload)
     {
         throw new NotImplementedException();
     }
     else
     {
         var item = plugin.PlayniteApi.Dialogs.ChooseItemWithSearch(null, (a) => plugin.SearchMetadata(a), options.GameData.Name);
         if (item == null)
         {
             gameData = new GameMetadata();
         }
         else
         {
             var searchItem = item as WikipediaSearchItem;
             gameData = plugin.ParseGamePage(plugin.GetPage(searchItem.Title));
         }
     }
 }
        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);
        }
Пример #29
0
        public GameMetadata UpdateGameWithMetadata(Game game)
        {
            var metadata = new GameMetadata();
            var program  = Programs.GetUnistallProgramsList().FirstOrDefault(a => a.RegistryKeyName == "Uplay Install " + game.GameId);

            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($"images/uplay/{game.GameId}/{iconFile}", iconFile, data);
            }

            game.Name = StringExtensions.NormalizeGameName(program.DisplayName);
            return(metadata);
        }
Пример #30
0
        public GameMetadata UpdateGameWithMetadata(IGame game)
        {
            var metadata = new GameMetadata();
            var program  = Programs.GetUnistallProgramsList().FirstOrDefault(a => a.RegistryKeyName == "Uplay Install " + game.ProviderId);

            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 Database.FileDefinition($"images/uplay/{game.ProviderId}/{iconFile}", iconFile, data);
            }

            game.Name = program.DisplayName;
            game.IsProviderDataUpdated = true;
            return(metadata);
        }