internal bool MakeDPG(string gamePath, ArchiveMode mode, string archiveLink) { GamePaths gpX = null; // Lecture des fichiers if (File.Exists(Path.Combine(gamePath, "DPGame.json"))) { HeTrace.WriteLine("DPG Found"); gpX = GamePaths.ReadFromJson(Path.Combine(gamePath, "DPGame.json")); } else if (File.Exists(Path.Combine(gamePath, "EBGame.xml"))) { HeTrace.WriteLine("DPG Missing, work with EBGame"); gpX = GetMainsInfo(gamePath, "EBGame.xml"); } else if (File.Exists(Path.Combine(gamePath, "TBGame.xml"))) { HeTrace.WriteLine("DPG Missing, work with TBGame"); gpX = GetMainsInfo(gamePath, "TBGame.xml"); } else if (File.Exists(Path.Combine(gamePath, "NBGame.xml"))) { HeTrace.WriteLine("DPG Missing, work with NBGame"); gpX = GetMainsInfo(gamePath, "NBGame.xml"); } if (gpX == null) { throw new Exception("Impossible to continue, no data file available"); } GameDataCont gpC = (GameDataCont)gpX; GameDataCompletion(gpC, mode, archiveLink); if (gpC.Applications.Count <= 0) { throw new Exception("No game to inject"); } // Affichage IHMStatic.ShowDPG(gpC, gpX, gamePath); // Sauvegarde gpX.WriteToJson(Path.Combine(gamePath, "DPGame.json")); HeTrace.WriteLine("DPG Done"); return(true); }
public GameDataCont InjectGame(string gamePath) { HeTrace.WriteLine("Dpg Step"); string dpgFile = Path.Combine(gamePath, "DPGame.json"); // Check if DPG file exists if (!File.Exists(dpgFile)) { DPGMakerCore dpgMaker = new DPGMakerCore(); dpgMaker.MakeDPG_Folder(gamePath); } GamePaths gpX = GamePaths.ReadFromJson(dpgFile); HeTrace.WriteLine($"Platform Step for '{gpX.Platform}'"); string platformsFile = Path.Combine(Config.HLaunchBoxPath, Config.PlatformsFile); bool CheckIfInjectionNeeded = !XML_Custom.TestPresence(platformsFile, Tag.Platform, Tag.Name, gpX.Platform); if (CheckIfInjectionNeeded) { HeTrace.WriteLine($"Backup of platforms file"); // Backup du fichier de la plateforme; BackupFile(platformsFile, _BackupFolder); string newPFile = IHMStatic.GetAFile(Config.LastTargetPath, $"Platform '{gpX.Platform}' doesn't exist. Select the xml file to inject for this platform", "xml"); if (string.IsNullOrEmpty(newPFile)) { throw new Exception("File for injection is not filled"); } // Vérification que c'est la bonne plateforme if (!XML_Custom.TestPresence(newPFile, Tag.Platform, Tag.Name, gpX.Platform)) { throw new Exception("File doesn't contain the good platform"); } HeTrace.WriteLine($"Injecting {gpX.Platform} in platforms file for {gpX.Platform}"); InjectPlatform(gpX.Platform, newPFile); } ContPlatFolders zePlatform = XML_Platforms.GetPlatformPaths(platformsFile, gpX.Platform); HeTrace.WriteLine("Preparing files"); // Préparation des fichiers GameDataCont gdC = PrepareGDC(gamePath, gpX); // Manipulation des fichiers AssignTargets(gdC, gamePath, zePlatform); // --- Lecture de la plateforme string machineXMLFile = Path.Combine(Config.HLaunchBoxPath, Config.PlatformsFolder, $"{gpX.Platform}.xml"); if (!File.Exists(machineXMLFile)) { XML_Games.NewPlatform(machineXMLFile); } // Backup platform file BackupFile(machineXMLFile, _BackupFolder); HeTrace.WriteLine($"Backup of '{machineXMLFile}'"); InjectInXMLFile(gamePath, gdC, machineXMLFile, zePlatform.FolderPath); HeTrace.WriteLine($"Game injected: {gdC.Title}"); return(gdC); }