Beispiel #1
0
        /// <summary>
        /// Récupère la liste des machines - Get the list of machines
        /// </summary>
        /// todo: put a possibility to get file manually
        private void FillListMachines()
        {
            // Show new controls
            lbSystems.Visible = lboxMachines.Visible = true;
            lbGames.Visible   = lvGames.Visible = true;

            string xmlLMachines = Path.Combine(_lbPath, Properties.Settings.Default.fPlatforms);

            Console.WriteLine(xmlLMachines);
            XML_Functions xf = new XML_Functions();

            if (xf.ReadFile(xmlLMachines))
            {
                List <string> lm = new List <string>()
                {
                    Lang.SelectASystem
                };
                xf.ListMachine(lm);

                lboxMachines.DataSource = lm;
            }
            else
            {
                //30/10/2020

                /*
                 * Properties.Settings.Default.LBPath = null;
                 * Properties.Settings.Default.Save();*/
                //30/10/2020
                _lbPath = null;
                // LaunchBoxPath.Text = null;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Récupère la liste des jeux - Get the list of games
        /// </summary>
        private void FillListGames()
        {
            _xfGames = new XML_Functions();

            lvGames.Items.Clear();

            if (_xfGames.ReadFile(_XmlFPlatform))
            {
                _GameList = _xfGames.ListGames();

                // var lgSorted = lg.OrderBy(x => x.FileName).ToList();

                //foreach (ShortGame sg in lgSorted)
                //{
                //    ListViewItem lvi = new ListViewItem(sg.Title);

                //    lvi.Tag = sg.ID;
                //    lvi.SubItems.Add(sg.Region);
                //    lvi.SubItems.Add(sg.FileName);

                //    lvGames.Items.Add(lvi);
                //}

                foreach (var sGame in _GameList.Values.OrderBy(x => x.Title))
                {
                    ListViewItem lvi = new ListViewItem(sGame.Title);

                    lvi.Tag = sGame;
                    lvi.SubItems.Add(sGame.Region);
                    lvi.SubItems.Add(sGame.FileName);

                    lvGames.Items.Add(lvi);
                }
            }
            else
            {
            }

            lvGames.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
            // lvGames.Columns[1].Width = 0;
        }
Beispiel #3
0
        /// <summary>
        /// ...
        /// Créer un fichier xml après collection des données dans le fichier xml de launchbox si activé
        /// </summary>
        /// <param name="xFile">believe... xml file </param>
        /// <param name="GameFile">Game file (exploitable)</param>
        internal int Initialize(string xFile, ShortGame sGame)
        {
            // Verif
            if (string.IsNullOrEmpty(ID))
            {
                throw new Exception("Id property: null");
            }

            if (string.IsNullOrEmpty(_SystemName))
            {
                throw new Exception();
            }

            _WFolder = Properties.Settings.Default.OutPPath;

            // Chemin du dossier temporaire du system
            _SystemPath = Path.Combine(_WFolder, _SystemName);
            _GamePath   = Path.Combine(_SystemPath, $"{sGame.ExploitableFileName}");           // New Working Folder
            string logFile = Path.Combine(_WFolder, $"{_SystemName} - {sGame.ExploitableFileName}.log");


            // Todo peut être déclencher un event sur le stop pour couper net ?
            var folderRes = OPFolders.SVerif(_GamePath, "Initialize", Dcs_Buttons.NoPass | Dcs_Buttons.NoRename, (string message) => ITrace.WriteLine(message, true));

            if (folderRes == EDestDecision.Stop)
            {
                //
                ITrace.WriteLine("[Initialize] GoodBye !");
                if (_IScreen != null)
                {
                    _IScreen.Close();
                }

                ITrace.RemoveListener(_IScreen);

                return(200);
            }

            #region System d'affichage
            string prefix = "PackMe";
            //window
            if (Settings.Default.opLogWindow)
            {
                _IScreen        = new InfoScreen();
                _IScreen.Prefix = prefix;
                _IScreen.Show();
                _Loggers.Add(_IScreen);
            }

            // file
            if (Settings.Default.opLogFile)
            {
                InfoToFile iLog = new InfoToFile(logFile, true);
                iLog.Prefix = prefix;
                _Loggers.Add(iLog);
            }

            // debug
            if (Debugger.IsAttached)
            {
                InfoToConsole iConsole = new InfoToConsole();
                iConsole.Prefix = prefix;
                _Loggers.Add(iConsole);
            }

            ITrace.AddListeners(_Loggers);


            ITrace.WriteLine("===== Report of errors: =====");
            ITrace.WriteLine($"[Initialize] ID:\t'{ID}'");
            ITrace.WriteLine($"[Initialize] {Lang.SystemSelected}: '{_SystemName}'");
            ITrace.WriteLine($"[Initialize] {Lang.GameSelected}: '{sGame.Title}' - Rom: '{sGame.ExploitableFileName}'");


            #endregion

            /*
             * BackgroundWorker bw = new BackgroundWorker();
             * bw.DoWork += new DoWorkEventHandler(BwWork); // PackMe.Initialize(_XmlFPlatform);
             * bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(BWRunWorkerCompleted);
             * bw.RunWorkerAsync();
             */

            // Lecture du fichier platform
            XML_Functions xmlPlatform = new XML_Functions();
            xmlPlatform.ReadFile(Path.Combine(Properties.Settings.Default.LBPath, Properties.Settings.Default.fPlatforms));

            _ZePlatform = xmlPlatform.ScrapPlatform(_SystemName);

            // Reconstruct PlatformFolder Path
            foreach (PlatformFolder plfmFolder in _ZePlatform.PlatformFolders)
            {
                plfmFolder.FolderPath = ReconstructPath(plfmFolder.FolderPath);
            }

            // Lecture du fichier des jeux
            _XFunctions = new XML_Functions();
            _XFunctions.ReadFile(xFile);

            // Get Main infos
            _zBackGame = _XFunctions.ScrapBackupGame(ID);
            _ZeGame    = (GameInfo)_zBackGame;

            #region 2020

            // Creation of System folder and working assign
            ITrace.WriteLine($"[Run] {Lang.CreationFolder}: '{_SystemName}'");
            Directory.CreateDirectory(_SystemName);
            Directory.SetCurrentDirectory(_SystemPath);

            // Creation of Game folder
            ITrace.WriteLine($"[Run] {Lang.CreationFolder}: '{_GamePath}'");
            Directory.CreateDirectory(_GamePath);
            #endregion


            #region Original Backup Game
            if (Settings.Default.opOBGame)
            {
                MakeXML.Backup_Game(_GamePath, _zBackGame, "TBGame");
            }
            else
            {
                ITrace.WriteLine("[Run] Original Backup Game disabled");
            }
            #endregion

            _LBoxDI = new DirectoryInfo(Settings.Default.LBPath);

            // Set active Directory to Root
            Directory.SetCurrentDirectory(_WFolder);

            #region Paths reconstruction

            _zBackGame.ApplicationPath = ReconstructPath(_zBackGame.ApplicationPath);
            _zBackGame.ManualPath      = ReconstructPath(_zBackGame.ManualPath);
            _zBackGame.MusicPath       = ReconstructPath(_zBackGame.MusicPath);
            _zBackGame.VideoPath       = ReconstructPath(_zBackGame.VideoPath);
            #endregion


            return(0);
        }