/// <summary> /// Adds the video details as a new 'Additional App' to the given game. /// </summary> /// <param name="game">The game entry.</param> /// <returns>The Additional App entry.</returns> public IAdditionalApplication AddVideoToGame(IGame game) { var app = game.AddNewAdditionalApplication(); app.Name = TitleWithPrefix; app.ApplicationPath = VlcUtilities.GetVlcExecutablePath(); app.CommandLine = GetVlcCmdArguments(); return(app); }
public Result Process(IProgress <ProcessProgress> progress = null) { Result result = new Result(); IDataManager dm = PluginHelper.DataManager; IPlatform platform = dm.GetPlatformByName(Platform); IGame[] games = platform.GetAllGames(true, true); List <IGame> clones = new List <IGame>(); List <IGame> parents = new List <IGame>(); Dictionary <IGame, XmlNode> lb2niMap = new Dictionary <IGame, XmlNode>(); Dictionary <XmlNode, IGame> ni2lbMap = new Dictionary <XmlNode, IGame>(); ProcessProgress state = new ProcessProgress() { TotalGames = games.Length }; Report(progress, state); foreach (IGame game in games) { string path = game.ApplicationPath; string name = Path.GetFileNameWithoutExtension(path); state.CurrentGame = path; try { string md5 = RomIOHelper.GetMD5(path); XmlNode niGame = Md5ToNoIntroMap[md5] ?? NameToNoIntroMap[name]; if (niGame == null) { result.Skipped.Add(Tuple.Create(path, $"md5 ({md5}) doesn't match any entry")); continue; } if (niGame.Attributes["cloneof"] != null) { clones.Add(game); } else { parents.Add(game); } lb2niMap.Add(game, niGame); ni2lbMap.Add(niGame, game); } catch (Exception e) { result.Skipped.Add(Tuple.Create(path, e.Message)); } state.ProcessedGames++; Report(progress, state); } state.GamesScanFinished = true; state.TotalClones = clones.Count; state.CurrentGame = ""; Report(progress, state); foreach (IGame clone in clones) { string path = clone.ApplicationPath; state.CurrentGame = path; dm.TryRemoveGame(clone); string parentName = lb2niMap[clone].Attributes["cloneof"].Value; string cloneName = lb2niMap[clone].Attributes["name"].Value; IGame parent = ni2lbMap[NameToNoIntroMap[parentName]]; IAdditionalApplication additionalApplication = parent.AddNewAdditionalApplication(); additionalApplication.ApplicationPath = clone.ApplicationPath; additionalApplication.Name = $@"Play {cloneName}"; state.ProcessedClones++; Report(progress, state); } state.CloneProcessFinished = true; Report(progress, state); dm.Save(); return(result); }