public static void InjectPlatform() { HeTrace.WriteLine("Platform injection..."); string backupFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Common.BackUp); string platformsFile = Path.Combine(Config.HLaunchBoxPath, Config.PlatformsFile); string newPFile = IHMStatic.GetAFile(Config.LastTargetPath, LanguageManager.Instance.Lang.S_XmlPlatform, "xml"); if (string.IsNullOrEmpty(newPFile)) { HeTrace.WriteLine("Platform file is null !"); return; } HeTrace.WriteLine($"Platform selected is '{newPFile}'"); using (XML_Platforms srcPlatform = new XML_Platforms(newPFile)) using (XML_Platforms lbPlatformes = new XML_Platforms(platformsFile)) { string machineName = srcPlatform.Root.Element(Tag.Platform).Element(Tag.Name)?.Value; var samePlats = from platform in lbPlatformes.Root.Elements(Tag.Platform) where ((string)platform.Element(Tag.Name).Value).Equals(machineName, StringComparison.OrdinalIgnoreCase) select platform; bool?write = true; // On demande pour REMPLACER la machine si elle existe déjà if (samePlats.Count() > 0) { write &= IHMStatic.AskDxMBox( "Platform is Already present, replace it ?", "Question", E_DxButtons.Yes | E_DxButtons.No, machineName); } if (write == false) { return; } // Backup du fichier de la plateforme; Tool.BackupFile(platformsFile, backupFolder); // On efface si nécessaire. lbPlatformes.RemoveElemByChild(Tag.Platform, Tag.Name, machineName); lbPlatformes.RemoveElemByChild(Tag.PlatformFolder, Tag.Platform, machineName); lbPlatformes.Save(platformsFile); // Injection de la plateforme lbPlatformes.InjectPlatform(srcPlatform.Root.Element(Tag.Platform)); // Injection des dossiers lbPlatformes.InjectPlatFolders(srcPlatform.Root.Elements(Tag.PlatformFolder)); // Sauvegarde lbPlatformes.Save(platformsFile); } HeTrace.WriteLine("Platform injection, done"); }
/// <summary> /// /// </summary> /// <param name="timeSleep"></param> /// <returns></returns> public object Run(int timeSleep = 10) { foreach (var zeGame in _SelectedGames) { HeTrace.WriteLine($"[Main] PackMe for '{zeGame.Title}' | '{zeGame.Id}'"); // Système de log par jeu if (Config.UseLogFile) { MeSimpleLog gameLog = new MeSimpleLog(Path.Combine(_WFolder, $"{_ZePlatform.Name} - {zeGame.ExploitableFileName}.log")) { }; gameLog.AddCaller(this); HeTrace.AddLogger("game", gameLog); } try { PackMe(zeGame); } catch (Exception exc) { HeTrace.WriteLine(exc.Message, this); HeTrace.WriteLine(exc.StackTrace, this); SafeBoxes.Dispatch_Mbox(this, exc.Message, "Error", E_DxButtons.Ok); } finally { HeTrace.RemoveLogger("game"); } } return(null); }
/// <summary> /// Création de la structure de base /// </summary> /// <param name="root"></param> /// <returns></returns> private Folder MakeStructure(string root) { if (!root.Contains(_WFolder)) { throw new Exception($"[CreateFolders] Erreur la chaine '{root}' ne contient pas '{_WFolder}'"); } //ITrace.WriteLine(prefix: false); HeTrace.WriteLine("[MakeStructure] Creation of the tree", this); Folder tree = new Folder("Root", root); // Creation lvl 1 CreateHFolders(tree, Common.Games, Common.CheatCodes, Common.Images, Common.Manuals, Common.Musics, Common.Videos); // Back to system menu to unlock game folder. Directory.SetCurrentDirectory(_SystemPath); return(tree); }
// --- public override bool ExportGames(ICollection <DataRep> games) { bool result = false; try { MeEmit mee = new MeEmit() { ByPass = true, }; mee.SignalWrite += (x, y) => this.SetStatus(x, new StateArg(y, false)); mee.SignalWriteLine += (x, y) => this.SetStatus(x, new StateArg(y, false)); HeTrace.AddMessenger("Mee", mee); foreach (var game in games) { //string tmpPath = Path.Combine(Path.GetTempPath(), Path.GetFileNameWithoutExtension(game.Name)); ExportGame(game.CurrentPath); } result = true; } catch (Exception exc) { HeTrace.WriteLine(exc.Message); HeTrace.WriteLine(exc.StackTrace); result = false; } finally { HeTrace.RemoveMessenger("Mee"); } return(result); }
public W_Common() { #if DEBUG MeDebug md = new MeDebug { ByPass = true, }; HeTrace.AddMessenger("Debug", md); #endif // Tracing MeSimpleLog log = new MeSimpleLog(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Common.Logs, $"{DateTime.Now.ToFileTime()}.log")) { LogLevel = 1, FuncPrefix = EPrefix.Horodating, ByPass = true, }; log.AddCaller(this); HeTrace.AddLogger("C_LBDPG", log); InitializeComponent(); DataContext = this; }
/// <summary> /// Appliquer les changements de la simulation dans les fichiers de configuration de launchbox. /// </summary> /// <returns></returns> internal bool Apply() { HeTrace.WriteLine(@"Process start ..."); // Envnew /* * Assignation des properties settings ? * Todo réfléchir car je ne sauve pas au fur et à mesure mais en même temps ça m'évite * avec une sauvegarde systématique d'oublier éventuellement ce que je voulais faire */ // Dematriochka Dematriochka(); // Sauvegarde previousFolderPath = PlatformObject.Folder; PlatformObject.Folder = //[0].OldRelatPath; // Assignation du chemin path des games à la plateforme PlatformObject.Folder = PlatformPaths.ApplicationPath.RelatPath; // Assignation du chemin path des games à la plateforme if (!Global.DebugMode) { PluginHelper.DataManager.Save(); DxMBox.ShowDial(SPRLang.Paths_Modified); } // Régénération panneau de gauche HeTrace.WriteLine(@"Process finish ..."); // Envnew return(true); }
internal bool InjectGamesFo(ICollection <DataRep> games) { bool result = false; try { MeEmit mee = new MeEmit() { ByPass = true, }; mee.SignalWrite += (x, y) => this.SetStatus(x, new StateArg(y, false)); mee.SignalWriteLine += (x, y) => this.SetStatus(x, new StateArg(y, false)); HeTrace.AddMessenger("Mee", mee); foreach (var game in games) { InjectGame(game.CurrentPath); } result = true; } catch (Exception exc) { HeTrace.WriteLine(exc.Message); HeTrace.WriteLine(exc.StackTrace); result = false; } finally { HeTrace.RemoveMessenger("Mee"); } return(result); }
/// <summary> /// Récupère tous les fichiers en fonction du LBGame, ainsi que des dossiers de la plateforme /// </summary> /// <param name="lbGame"></param> /// <param name="gpX"></param> private void GetFiles(LBGame lbGame, GameDataCont gdC) { HeTrace.WriteLine($"[GetFiles]", this); var possibilities = GetBasicPossibilities(lbGame.Id, lbGame.Title); // Jeu principal + Clones gdC.SetApplications = GetFilesForGames(lbGame); // CheatCodes if (!string.IsNullOrEmpty(Config.HCCodesPath)) { gdC.SetSCheatCodes = GetFilesByPredict(possibilities, Path.Combine(Config.HCCodesPath, _ZePlatform.Name), "CheatCodes"); } // Manuels gdC.SetDefaultManual = GetFileForSpecifics(lbGame.ManualPath, Common.Config.HLaunchBoxPath); gdC.AddSManuals = GetMoreFiles("Manual", possibilities); // Musics gdC.SetDefaultMusic = GetFileForSpecifics(lbGame.MusicPath, Common.Config.HLaunchBoxPath); gdC.AddSMusics = GetMoreFiles("Music", possibilities); // Videos gdC.SetDefaultVideo = GetFileForSpecifics(lbGame.VideoPath, Common.Config.HLaunchBoxPath); gdC.SetDefaultThemeVideo = GetFileForSpecifics(lbGame.ThemeVideoPath, Common.Config.HLaunchBoxPath); gdC.AddSVideos = GetMoreFiles("Video", possibilities); //GetMoreFiles(toSearch, gpX.CompVideos, "Video", gpX.VideoPath, gpX.ThemeVideoPath); // Images gdC.Images = GetImagesFiles(lbGame, possibilities); }
/// <summary> /// Vérification du chemin entré /// </summary> internal bool VerifPath(string pathD, string propertyName) { HeTrace.WriteLine(@"Folder verification"); // Envnew RemoveError(propertyName); bool result = true; string error = string.Empty; if (string.IsNullOrEmpty(pathD)) { error = "Value can't be null"; result = false; } else if (!Directory.Exists(pathD)) { error = "Directory doesn't exist"; result = false; } /* * todo * Properties.Settings.Default.LastKPath = _NewRoot = this.tbMainPath.Text; * Properties.Settings.Default.Save(); */ if (!result) { AddError(propertyName, error); // On notifie car ce n'est pas déclenché en cas d'update de la propriété } ErrorsChanged?.Invoke(this, new DataErrorsChangedEventArgs(propertyName)); return(result); }
protected bool CopyFiles(GameDataCont gdC) { var files = new List <DataTrans>(); files.AddRange(gdC.Applications); files.AddRange(gdC.Manuals); files.AddRange(gdC.Musics); files.AddRange(gdC.Videos); CopyFExt copyObj = new CopyFExt(); copyObj.AskToUser += IHMStatic.Ask4_FileConflict2; copyObj.UpdateStatus += (x, y) => HeTrace.WriteLine(y.Message); copyObj.UpdateStatusT += (x, y) => HeTrace.WriteLine(y.Message); bool resultat = false; SafeBoxes.LaunchDouble(copyObj, () => resultat = copyObj.CopyN(files), "Copy files"); if (!resultat) { return(false); } SafeBoxes.LaunchDouble(copyObj, () => resultat = copyObj.CopyN(gdC.Images), "Copy Images files"); return(resultat); }
/// <summary> /// List Platforms, create an item for each /// </summary> /// <remarks> /// Raz before /// </remarks> private ObservableCollection <IPlatform> ListPlatform() { HeTrace.WriteLine("List platforms", this); IPlatform[] platforms = PluginHelper.DataManager.GetAllPlatforms(); // Remise à zéro ObservableCollection <IPlatform> tmp = new ObservableCollection <IPlatform>(); // ObservableCollection<IPlatform> tmp = new ObservableCollection<IPlatform>(); foreach (IPlatform platform in platforms) { //MessageBox.Show(platform.Name); /* ListViewItem lvi = new ListViewItem(platform.Name); * lvi.SubItems.Add(platform.Folder); * lvPlatforms.Items.Add(lvi);*/ //dicPlatforms.Add(platform.Name, platform); tmp.Add(platform); HeTrace.WriteLine($"{platform.Name} ajouté", 10); } HeTrace.WriteLine("ListPlatform achieved", 10); return(tmp); }
internal void PrepareApply() { HeTrace.WriteLine($"--- Prepare Apply ---"); TaskLauncher tl = new TaskLauncher() { AutoCloseWindow = true, ProgressIHM = new Splash() { Model = new EphemProgress(Core), }, MethodToRun = () => Core.ApplyChanges(), }; if (tl.Launch(Core) == true) { DxMBox.ShowDial(SPRLang.Paths_Modified); } else { DxMBox.ShowDial("Error"); } ActiveSimulate = true; ActiveApply = false; }
/// <summary> /// Check if directory structure match with real structure /// </summary> /// <param name="root"></param> /// <returns></returns> private bool?CheckDirectoryStructure(string root) { HeTrace.WriteLine("Check directory structure"); // Vérification des dossiers; string gameF = Path.Combine(root, Config.Games); bool gameDirOk = Directory.Exists(gameF); if (!gameDirOk) { gameF = SafeBoxes.SelectFolder(gameF, "Game folder doesn't match, select folder"); if (!gameF.StartsWith(root)) { return(false); } gameDirOk = Directory.Exists(gameF); if (!gameDirOk) { return(false); } Config.Games = Path.GetFileName(gameF); Config.Save(); } bool cheatCDirOk = Directory.Exists(Path.Combine(root, Config.CheatCodes)); bool imageDirOk = Directory.Exists(Path.Combine(root, Config.Images)); bool manualDirOk = Directory.Exists(Path.Combine(root, Config.Manuals)); bool musicDirOk = Directory.Exists(Path.Combine(root, Config.Musics)); bool videoDirOk = Directory.Exists(Path.Combine(root, Config.Videos)); bool isOk = true; isOk &= gameDirOk; isOk &= cheatCDirOk; isOk &= imageDirOk; isOk &= manualDirOk; isOk &= musicDirOk; isOk &= videoDirOk; bool?res = true; if (!isOk) { res = SafeBoxes.ShowStatus("Structure seems to have directories missing or different, continue ? ", "Warning", new Dictionary <string, bool?>() { { "Games", gameDirOk }, { "Cheats", cheatCDirOk }, { "Images", imageDirOk }, { "Manuals", manualDirOk }, { "Musics", musicDirOk }, { "Videos", videoDirOk } }, "#FF60DC32", "#FFFF2323" ); } // IHMStatic.AskDxMBox("Structure seems to have directories missing or different, continue ? ", "Warning", E_DxButtons.Yes | E_DxButtons.No, "If you continue, files into folders will not been copied"); return(res); }
internal bool MakeDPG_Comp(IEnumerable <DataRep> archives) { // Check de LaunchBox if (!File.Exists(Path.Combine(Config.HLaunchBoxPath, Config.PlatformsFile))) { DxTBoxCore.Box_MBox.DxMBox.ShowDial("Wrong LaunchBoxPath"); return(false); } try { // prérequis ? Doit être zip, 7zip foreach (DataRep zF in archives) { ArchiveMode mode = ArchiveMode.None; string gamePath = Path.Combine(Config.HWorkingFolder, Path.GetFileNameWithoutExtension(zF.Name)); string fileExt = Path.GetExtension(zF.CurrentPath).TrimStart('.'); // Création du dossier de destination Directory.CreateDirectory(gamePath); // Détection du mode if (fileExt.Equals("zip", StringComparison.OrdinalIgnoreCase)) { mode = ArchiveMode.Zip; } if (fileExt.Equals("7zip", StringComparison.OrdinalIgnoreCase) || fileExt.Equals("7z", StringComparison.OrdinalIgnoreCase)) { mode = ArchiveMode.SevenZip; } else { RejectedDatas.Enqueue(zF); // pas sur que ça serve } // if (mode == ArchiveMode.Zip) { DPGZipCore(zF, gamePath); } else if (mode == ArchiveMode.SevenZip) { DPG7ZipCore(zF, gamePath); } MakeDPG(gamePath, mode, zF.CurrentPath); } return(true); } catch (Exception exc) { HeTrace.WriteLine(exc.Message); return(false); } finally { } }
/// <summary> /// Initialization with a platform (edition) /// </summary> /// <param name="platform"></param> /// <returns></returns> public void InitializeEdition(string platformName) { if (string.IsNullOrEmpty(platformName)) { throw new NullReferenceException("Object Plateform is null !"); } if (Global.DebugMode) { HeTrace.WriteLine("Debug Mode Activé"); PlatformObject = DebugPoint.FakePlatforms.First(x => x.Name.Equals(platformName)); } else { PlatformObject = PluginHelper.DataManager.GetPlatformByName(platformName); HeTrace.WriteLine("Plugin Mode Activé"); } // Messenger Mev = new MeVerbose() { ByPass = true, LogLevel = Global.Config.VerbLvl, }; HeTrace.AddMessenger("Verbose", Mev); // on récupère le dernier dossier visité ChosenFolder = Properties.Settings.Default.LastKPath; HeTrace.WriteLine("Initialisation"); HeTrace.WriteLine($@"LaunchBox main path: {Global.LaunchBoxPath}"); HeTrace.WriteLine($"Identified System: {PlatformObject.Name}"); // Initialization of paths this.InitializePaths(); // Detection du nom du dossier system (vérifié le 29/04/2021) if (string.IsNullOrEmpty(PlatformObject.Folder)) { SystemFolderName = PlatformObject.Name; } else { // On prend le dernier dossier SystemFolderName = PlatformObject.Folder.Substring(PlatformObject.Folder.LastIndexOf(@"\") + 1); } HeTrace.WriteLine($"Identified Folder System: {SystemFolderName}"); // Initialisation des folders name GamesFName = Default.AppsFolder; ImagesFName = Default.ImagesFolder; ManualsFName = Default.ManualsFolder; MusicsFName = Default.MusicsFolder; VideosFName = Default.VideosFolder; }
internal void RAZ_DPaths() { HeTrace.WriteLine("Reset new Paths"); // Envnew foreach (C_PathsDouble c in PlatformPaths) { c.Raz_NewPaths(); } }
private void Simulate_CanExecute(object sender, CanExecuteRoutedEventArgs e) { if (Model != null) { HeTrace.WriteLine($"Simulate_CanExecute: {Model.ActiveSimulate} | {Model.Core.HasErrors} "); e.CanExecute = Model.ActiveSimulate && !Model.Core.HasErrors; } }
public App() { try { //if (!Directory.Exists(Common.LangFolder)) Directory.CreateDirectory(Common.Logs); // Tracing MeSimpleLog log = new MeSimpleLog(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Common.Logs, $"{DateTime.Now.ToFileTime()}.log")) { LogLevel = 1, FuncPrefix = EPrefix.Horodating, ByPass = true, }; log.AddCaller(this); HeTrace.AddLogger("PackMyGame", log); /* * // Mise à jour des paramètres en cas de changement de version * if (PS.Default.UpgradeRequired) * { * PS.Default.Upgrade(); * PS.Default.U-pgradeRequired = false; * PS.Default.Save(); * }*/ // --- Configuration string configFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config.json"); Config = null; if (!File.Exists(configFile)) { Config = Cont.Configuration.MakeDefault(); Config.Save(); } else { Config = Cont.Configuration.ReadConfig(); } // Réécriture si le numéro de version diffère if (Config.Version == null || !Common.Config.Version.Equals(Common.ConfigVersion)) { Config.Update(); Config.Save(); } // --- Languages LanguageManager.Init(); LanguageManager.Instance.ChangeLanguage(Config.Language); } catch (Exception exc) { DxTBoxCore.Box_MBox.DxMBox.ShowDial($"{exc.Message}", "Error", optMessage: exc.StackTrace); HeTrace.WriteLine(exc.Message); HeTrace.WriteLine(exc.StackTrace); } }
/// <summary> /// /// </summary> /// <param name="platform"></param> /// <param name="previousPlatformState">Etat précédent, si disponible</param> public GamePathsModel(IPlatform selectedPlatform, string previousPlatformName = null) { if (selectedPlatform == null) { throw new NullReferenceException("Object Plateform is null !"); } Core.UpdateStatus += (x, y) => HeTrace.WriteLine(y.Message); Core.SelectedPlatform = selectedPlatform; SelectedPlatform = selectedPlatform; Core.PlatformName = SelectedPlatform.Name; Core.ChosenMode = GamePathMode.None; if (Global.DebugMode) { DebugResources.Set_GamesPaths(selectedPlatform.Name); } // Core.AddAppPaths = Properties.Settings.Default.cgpAddApp; // Messenger Mev = new MeVerbose() { ByPass = true, LogLevel = Global.Config.VerbLvl, }; HeTrace.AddMessenger("Verbose", Mev); HeTrace.WriteLine("Initialisation"); // NewLine HeTrace.WriteLine($"[CGamePaths] [InitializeEdition] Initialisation"); HeTrace.WriteLine($@"LaunchBox main path: {Global.LaunchBoxPath}"); // NewLine HeTrace.WriteLine($@"Platform '{Core.PlatformName}' selected"); // NewLine // --- Initialisation de la plateforme actuelle Core.InitializePlatform(); // --- Récupération des jeux (Async) PrepareInitializeGames(); // --- Initialisation des champs grâce à l'ancienne plateforme if (!string.IsNullOrEmpty(previousPlatformName)) { Core.PlatformToReplace = previousPlatformName; } else { Core.PlatformToReplace = FindBadPlatform(); } // ToReplace = Platform_Tools.GetRoot_ByFolder(PreviousPlatform.Folder); }
public DPGMakerCore() { MeEmit mee = new MeEmit() { ByPass = true, }; mee.SignalWrite += (x, y) => this.SetStatus(x, new StateArg(y, false)); mee.SignalWriteLine += (x, y) => this.SetStatus(x, new StateArg(y, false)); HeTrace.AddMessenger("Mee", mee); }
/// <summary> /// Create Horizontal arborescence /// </summary> /// <param name="tree"></param> /// <param name="folders"></param> private void CreateHFolders(Folder tree, params string[] folders) { foreach (string folderName in folders) { string folderPath = Path.Combine(tree.Path, folderName); HeTrace.WriteLine($"\t[CreateHFolders] Creation of '{folderPath}'", this); Folder tmp = new Folder(folderName, folderPath); tree.Children.Add(folderName, tmp); // Création Directory.CreateDirectory(folderPath); } }
/// <summary> /// Fait les vérifications nécessaires avant de renvoyer le lien d'un fichier entré dans la db /// </summary> /// <param name="dbGamePath"></param> /// <returns> /// Vérifie et retourne le fichier sélectionné /// </returns> internal static string GetFileForSpecifics(string dbGamePath, string baseApp) { // Si le fichier indiqué dans le fichier du jeu existe if (!string.IsNullOrEmpty(dbGamePath)) { HeTrace.WriteLine($"\t[{nameof(GetFileForSpecifics)}]"); string linkFile = Path.GetFullPath(dbGamePath, baseApp); if (File.Exists(linkFile)) { return(linkFile); } } return(null); }
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 void InjectPlatform(string platform, string newPFile) { string platformsFile = Path.Combine(Config.HLaunchBoxPath, Config.PlatformsFile); using (XML_Platforms xPlat = new XML_Platforms(platformsFile)) { // Injection en mode true verbatim if (xPlat.InjectPlatformExt(newPFile)) { HeTrace.WriteLine($"Platform {platform} injected"); xPlat.Save(platformsFile); } } }
/// <summary> /// /// </summary> /// <remarks> /// /// </remarks> internal void Initialize() { // if (!Global.DebugMode) { Platforms = ListPlatform(); } else if (Global.DebugMode) { //HeTrace.GetMessenger("Debug").AddCaller(this, "PlatformLists >>>"); Platforms = DebugPoint.FakePlatforms; } HeTrace.WriteLine("Platforms initialized", this); }
public void OnSelected() { Directory.SetCurrentDirectory(Global.LaunchBoxPath); Global.InitializeConfig(); //return; try { /*TextWriterTraceListener textWriter = new TextWriterTraceListener(@".././Logs/SappPasRoot.log"); * //Ajout bit à bit de deux options de sortie * textWriter.TraceOutputOptions = TraceOptions.Callstack | TraceOptions.ProcessId | TraceOptions.Timestamp; * * Trace.Listeners.Add(textWriter); * Trace.AutoFlush = true; * Trace.WriteLine($"\n {new string('=', 10)} Initialization {new string('=', 10)}");*/ MeSimpleLog meSL = new MeSimpleLog(Path.Combine(Global.LaunchBoxRoot, Sett.Default.LogFolder, Sett.Default.LogFile)) { //Prefix LogLevel = Global.Config.LogLvl, ByPass = true, FuncPrefix = EPrefix.Prefixing | EPrefix.Horodating }; HeTrace.AddLogger("Logger", meSL); HeTrace.WriteLine("Init ok", callerName: "Logger"); HeTrace.WriteLine($"LaunchBox Path: {Global.LaunchBoxPath}"); HeTrace.WriteLine($"LaunchBox Root (found): {Global.LaunchBoxRoot}"); //PluginHelper. .LaunchBoxMainForm.FormClosing += new FormClosingEventHandler(Fermeture); // 2020/30/10 verif W_PlateformsList sp = new W_PlateformsList(); sp.ShowDialog(); // 2020/30/10 verif } catch (Exception e) { MessageBox.Show(e.ToString()); // Trace.WriteLine(e); using (StreamWriter file = new StreamWriter(@".././Logs/#err.txt")) { file.WriteLine(e); } } HeTrace.RemoveLogger("Logger"); }
/* * internal void NewFindPivot() * { * for (int i = 0; i < ExtPlatformGames.Count; i++) * { * C_Game game = ExtPlatformGames[i]; * * // Gestion d'éventuelle erreur * if (game.ApplicationPath == null) * continue; * * // On passe les jeux déjà ok * if (game.ApplicationPath.RelatPath.Contains(PlatformRelatPath)) * continue; * * string[] arr = game.ApplicationPath.RelatPath.Split(@"\"); * * // Test avec le nom de plateforme * if (arr.Contains(PlatformToReplace)) * { * HeTrace.WriteLine($"[Pivot] OldObject choice"); * var posPlatName = Array.LastIndexOf(arr, SelectedPlatform.Name); * ToReplace = String.Join(@"\", arr, 0, posPlatName + 1); * return; * } * * // Test pour essayer via le nom du système * if (arr.Contains(SelectedPlatform.Name)) * { * HeTrace.WriteLine($"[Pivot] ObjectPlatfotme choice"); * var posPlatName = Array.LastIndexOf(arr, SelectedPlatform.Name); * // Détermination de la position du nom de la plateforme * * ToReplace = String.Join(@"\", arr, 0, posPlatName + 1); * * return; * } * * // Voir si dossier null * // On récupère le nom du dernier dossier de la plateforme * string lastDir = Path.GetFileName(SelectedPlatform.Folder); * if (!string.IsNullOrEmpty(SelectedPlatform.Folder) && game.ApplicationPath.RelatPath.Contains(lastDir)) * { * HeTrace.WriteLine($"[Pivot] Last folder from platform choice"); * var posPlatName = Array.LastIndexOf(arr, lastDir); * ToReplace = String.Join(@"\", arr, 0, posPlatName - 1); // +1 Pour prendre aussi le dernier dossier * * return; * * } * * ToReplace = SelectedPlatform.Folder; * HeTrace.WriteLine($"[Pivot] No predict"); * } * } * * /// <summary> * /// * /// <summary> * /// <remarks> * /// La prédiction est trop difficile, car il y a trop d'incertitudes. * /// Remplacé par une vérification si le premier jeu à modifier contiendrait le nom du système pour déterminer la chaine à remplacer * /// Si ce n'est pas le cas on ne mettra rien, il y a une boite pour choisir à la main le dossier * /// </remarks> * [Obsolete] * internal void FindPivot() * { * // Mise en place du système pivot/tail, on donne un mot, on conservera ce qu'il y a après * * // Récupération du premier qui n'a pas le bon chemin (pour travailler dessus) * //C_Game chosenGame = null; * for (int i = 0; i < ExtPlatformGames.Count; i++) * { * C_Game game = ExtPlatformGames[i]; * * // Gestion d'éventuelle erreur * if (game.ApplicationPath == null) * continue; * * // On passe les jeux déjà ok * if (game.ApplicationPath.RelatPath.Contains(PlatformRelatPath)) * continue; * * string[] arr = game.ApplicationPath.RelatPath.Split(@"\"); * * // Test pour essayer via le nom du système * if (arr.Contains(SelectedPlatform.Name)) * { * HeTrace.WriteLine($"[Pivot] ObjectPlatfotme choice"); * var posPlatName = Array.IndexOf(arr, SelectedPlatform.Name); * // Détermination de la position du nom de la plateforme * * ToReplace = String.Join(@"\", arr, 0, posPlatName + 1); * * return; * } * * // Voir si dossier null * // On récupère le nom du dernier dossier de la plateforme * string lastDir = Path.GetFileName(SelectedPlatform.Folder); * if (!string.IsNullOrEmpty(SelectedPlatform.Folder) && game.ApplicationPath.RelatPath.Contains(lastDir)) * { * HeTrace.WriteLine($"[Pivot] Last folder from platform choice"); * var posPlatName = Array.IndexOf(arr, lastDir); * ToReplace = String.Join(@"\", arr, 0, posPlatName + 1); // +1 Pour prendre aussi le dernier dossier * return; * * } * * // Dernier cas on prend le premier application path qui ne correspond pas * ToReplace = Path.GetDirectoryName(game.ApplicationPath.RelatPath); * HeTrace.WriteLine("[Pivot] Last choice - Edit is strongly recommended"); * return; * } * * ToReplace = SelectedPlatform.Folder; * HeTrace.WriteLine($"[Pivot] No predict"); * }*/ #endregion private void PrepareInitializeGames() { TaskLauncher tl = new TaskLauncher() { AutoCloseWindow = true, ProgressIHM = new Splash() { Model = new EphemProgress(Core), }, MethodToRun = () => Core.InitializeGames() }; tl.Launch(Core); HeTrace.RemoveMessenger("mee"); }
internal bool InjectGamesFi(ICollection <DataRep> games) { ProgressTotal = games.Count(); try { MeEmit mee = new MeEmit() { ByPass = true, }; mee.SignalWrite += (x, y) => this.SetStatus(x, new StateArg(y, false)); mee.SignalWriteLine += (x, y) => this.SetStatus(x, new StateArg(y, true)); HeTrace.AddMessenger("Mee", mee); List <DataRep> folders = new List <DataRep>(); // Extraction des données foreach (DataRep game in games) { string tmpPath = Path.Combine(Config.HWorkingFolder, Path.GetFileNameWithoutExtension(game.Name)); game.DestPath = tmpPath; // extraction ExtractDataFiles(game, tmpPath); folders.Add(new DataRep(tmpPath)); } // Exportation foreach (DataRep game in games) { InjectGame(game.DestPath); } return(true); } catch (Exception exc) { HeTrace.WriteLine(exc.Message); HeTrace.WriteLine(exc.StackTrace); return(false); } finally { HeTrace.RemoveMessenger("Mee"); } }
/// <summary> /// Copy from folder, inject /// </summary> /// <param name="gamePath"></param> private void ExportGame(string gamePath) { if (CheckDirectoryStructure(gamePath) != true) { return; } var gdC = InjectGame(gamePath); // Copie des fichiers (on s'appuie sur les dossiers de la plateforme) if (CopyFiles(gdC) == false) { return; } HeTrace.WriteLine($"Game exported: {gdC.Title}"); }
/// <summary> /// Fonction de copie avec affichage de la progression /// </summary> /// <param name="fileSrc">File source</param> /// <param name="destFile">File to destination</param> /// <param name="overWrite">Ecrasement du fichier de destination</param> internal static bool Copy(string fileSrc, string destFile, bool overWrite = false) { HeTrace.Write($"[CopyFiles] Copy of the file '{Path.GetFileName(fileSrc)}': "); try { File.Copy(fileSrc, destFile, overWrite); HeTrace.EndLine("Successful"); return(true); } catch (IOException e) { HeTrace.EndLine("Error"); HeTrace.WriteLine(e.Message); return(false); } }