private void GetGame(List <GenericItemOption> gameList, string caption) { var item = plugin.PlayniteApi.Dialogs.ChooseItemWithSearch(gameList, (a) => { try { return(new List <GenericItemOption>(services.getGameListSGDB(a).Select(game => new GenericItemOption(game.name, game.id.ToString())))); } catch { var sgdbException = new Exception("Service failure."); throw sgdbException; } }, options.GameData.Name, caption); searchSelection = item; }
// Override additional methods based on supported metadata fields. public override MetadataFile GetCoverImage() { if (options.IsBackgroundDownload) { if (options.GameData.Source != null) { return(new MetadataFile(services.getCoverImageUrl(options.GameData.Name, options.GameData.Source.ToString().ToLower(), options.GameData.GameId))); } else { return(new MetadataFile(services.getCoverImageUrl(options.GameData.Name))); } } else { var gameList = new List <GenericItemOption>(services.getGameListSGDB(options.GameData.Name).Select(game => new GenericItemOption(game.name, game.id.ToString()))); GetGame(gameList, "Cover"); if (searchSelection != null) { var covers = services.getCoverImages(searchSelection.Name); var selection = GetCoverManually(covers); if (selection == null || selection.Path == "nopath") { return(base.GetCoverImage()); } else { return(new MetadataFile(selection.Path)); } } else { return(base.GetCoverImage()); } } }