コード例 #1
0
 void upgradeDiscs(Game parent)
 {
     SQLData discData = sqlClient.Execute("select * from GameDiscs where gameid=" + parent.Id);
     foreach (SQLDataRow sqlRow in discData.Rows)
     {
         GameDisc disc = new GameDisc();
         disc.Path = decode(sqlRow.fields[3]);
         disc.Number = int.Parse(sqlRow.fields[4]);
         disc.LaunchFile = decode(sqlRow.fields[5]);
         parent.Discs.Add(disc);
     }
 }
コード例 #2
0
        static bool showDiscSelect(ref GameDisc selectedDisc, List<GameDisc> discs, int windowID)
        {
            GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
            if (dlg != null)
            {
                dlg.Reset();
                dlg.SetHeading(Translator.Instance.discselect);

                int selectedLabel = 0;
                for (int x = 0; x < discs.Count; x++ )
                {
                    GameDisc disc = discs[x];
                    dlg.Add(new GUIListItem(disc.Name));
                    if (disc.Id == selectedDisc.Id)
                        selectedLabel = x;
                }

                dlg.SelectedLabel = selectedLabel;
                dlg.DoModal(windowID);
                selectedLabel = dlg.SelectedLabel;
                if (selectedLabel > -1)
                {
                    selectedDisc = discs[selectedLabel];
                    return true;
                }
            }
            return false;
        }
コード例 #3
0
        List<Game> upgradeGames(SQLData gameData)
        {
            int currentGame = 1;
            int totalGames = gameData.Rows.Count;
            List<Game> games = new List<Game>();
            foreach (SQLDataRow sqlRow in gameData.Rows)
            {
                setProgress("{0}/{1} - Parsing Games", currentGame, totalGames);
                currentGame++;
                currentItem++;

                Emulator parent;
                if (!emuLookup.TryGetValue(int.Parse(sqlRow.fields[2], culture), out parent))
                    continue;

                Game game = new Game();
                game.ParentEmulator = parent;
                game.Id = int.Parse(sqlRow.fields[0]);
                game.Title = decode(sqlRow.fields[3]);
                game.Grade = int.Parse(sqlRow.fields[4]);
                game.PlayCount = int.Parse(sqlRow.fields[5]);
                game.Year = int.Parse(sqlRow.fields[6]);
                game.Latestplay = DateTime.Parse(sqlRow.fields[7], culture);
                game.Description = decode(sqlRow.fields[8]);
                game.Genre = decode(sqlRow.fields[9]);
                game.Developer = decode(sqlRow.fields[10]);
                game.Favourite = bool.Parse(sqlRow.fields[12]);
                game.InfoChecked = bool.Parse(sqlRow.fields[15]);
                game.VideoPreview = decode(sqlRow.fields[17]);

                if (parent.IsPc())
                {
                    upgradeProfiles(game);
                    if (game.GameProfiles.Count < 1)
                    {
                        EmulatorProfile profile = new EmulatorProfile(true);
                        profile.Arguments = decode(sqlRow.fields[19]);
                        profile.SuspendMP = true;
                        game.GameProfiles.Add(profile);
                    }
                }

                int selectedProfileId = int.Parse(sqlRow.fields[14]);
                foreach (EmulatorProfile profile in game.EmulatorProfiles)
                {
                    if (profile.Id == selectedProfileId)
                    {
                        game.CurrentProfile = profile;
                        break;
                    }
                }

                upgradeDiscs(game);
                if (game.Discs.Count < 1)
                {
                    GameDisc disc = new GameDisc();
                    disc.Number = 1;
                    disc.Path = decode(sqlRow.fields[1]);
                    disc.LaunchFile = decode(sqlRow.fields[13]);
                    game.Discs.Add(disc);
                    game.CurrentDisc = disc;
                }
                else
                {
                    int discNum = int.Parse(sqlRow.fields[18]);
                    foreach (GameDisc disc in game.Discs)
                    {
                        if (discNum == disc.Number)
                        {
                            game.CurrentDisc = disc;
                            break;
                        }
                    }
                }
                games.Add(game);
            }
            return games;
        }
コード例 #4
0
ファイル: TheAvengersImport.cs プロジェクト: feyris-tan/azusa
        public void Run(DirectoryInfo indir, Shelf outShelf)
        {
            if (!indir.Exists)
            {
                MessageBox.Show(String.Format("{0} existiert nicht.", indir.FullName));
                return;
            }

            Game game = new Game();

            game.GameDiscs = new List <GameDisc>();
            game.Name      = String.Format("Batch-Import {0}", DateTime.Now.ToString());

            FileInfo[]      fileInfos = indir.GetFiles();
            List <FileInfo> ibgFiles  = new List <FileInfo>();

            foreach (FileInfo fileInfo in fileInfos)
            {
                string   extension = fileInfo.Extension.ToLowerInvariant();
                string   name      = Path.GetFileNameWithoutExtension(fileInfo.Name);
                GameDisc gameDisc;
                switch (extension)
                {
                case ".iso":        //yes
                    gameDisc         = game.GetDiscByName(name);
                    gameDisc.BinFile = fileInfo;
                    break;

                case ".dvd":        //yes
                    gameDisc            = game.GetDiscByName(name);
                    gameDisc.CueFile    = fileInfo;
                    gameDisc.CueContent = File.ReadAllText(fileInfo.FullName);
                    break;

                case ".md5":        //yes
                    gameDisc            = game.GetDiscByName(name);
                    gameDisc.Md5File    = fileInfo;
                    gameDisc.Md5Content = File.ReadAllText(fileInfo.FullName);
                    break;

                case ".mds":        //yes
                    gameDisc            = game.GetDiscByName(name);
                    gameDisc.MdsFile    = fileInfo;
                    gameDisc.MdsContent = File.ReadAllBytes(fileInfo.FullName);
                    break;

                case ".ibg":        //eyes
                    ibgFiles.Add(fileInfo);
                    break;

                default:
                    MessageBox.Show(String.Format("Don't know about {0}...", extension));
                    return;
                }
            }

            foreach (FileInfo ibgInfo in ibgFiles)
            {
                long     lookFor  = ibgInfo.LastWriteTime.ToUnixMinute();
                GameDisc gameDisc = game.GetByUnixMinute(lookFor);
                gameDisc.IbgContent = File.ReadAllText(ibgInfo.FullName);
            }

            game.GameDiscs.Sort(new OrderByIsoDate());

            for (int i = 0; i < game.GameDiscs.Count; i++)
            {
                game.GameDiscs[i].Name = String.Format("Disc {0}", i + 1);
            }

            int     productId = ProductService.CreateProduct(game.Name, outShelf);
            Product product   = ProductService.GetProduct(productId);

            product.Complete   = true;
            product.Consistent = true;
            product.NSFW       = false;
            ProductService.UpdateProduct(product);

            foreach (GameDisc gameDisc in game.GameDiscs)
            {
                int   mediaId = MediaService.CreateMedia(product, gameDisc.Name);
                Media media   = MediaService.GetSpecificMedia(mediaId);
                media.ChecksumContent  = gameDisc.Md5Content;
                media.CueSheetContent  = gameDisc.CueContent;
                media.GraphDataContent = gameDisc.IbgContent;
                media.MdsContent       = gameDisc.MdsContent;
                media.MediaTypeId      = 1;
                media.isSealed         = false;

                MediaService.UpdateMedia(media);

                Stream binStream = gameDisc.BinFile.OpenRead();
                media.SetFilesystemMetadata(binStream);
                binStream.Close();
            }

            Console.WriteLine("Great!");
        }
コード例 #5
0
        private void newDiscButton_Click(object sender, EventArgs e)
        {
            if (selectedGame == null)
                return;

            string filter = selectedGame.ParentEmulator.Filter;
            string filterStr = string.Format("{0} rom ({1}) | {2}|All files (*.*) | *.*", selectedGame.ParentEmulator.Title, filter.Replace(";", ", "), filter);

            using (OpenFileDialog dlg = MP1Utils.OpenFileDialog("Select file", filterStr, System.IO.Path.GetDirectoryName(selectedGame.CurrentDisc.Path)))
            {
                dlg.Multiselect = true;
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    foreach (string filename in dlg.FileNames)
                    {
                        GameDisc newDisc = new GameDisc(filename);
                        int index = discBindingSource.Add(newDisc);
                        newDisc.Number = index + 1;
                    }
                    saveDiscs = true;
                }
            }
        }
コード例 #6
0
 void checkDiscExists(GameDisc disc, List<GameDisc> missingDiscs, HashSet<string> drivesToIgnore)
 {
     string path = disc.Path;
     string drive = Path.GetPathRoot(path);
     if (!drivesToIgnore.Contains(drive))
     {
         //if path root is missing assume file is on disconnected
         //removable/network drive and don't delete
         if (!Directory.Exists(drive))
             drivesToIgnore.Add(drive);
         else if (!File.Exists(path))
             missingDiscs.Add(disc);
     }
 }
コード例 #7
0
        void mergeSelectedRows()
        {
            if (importGridView.SelectedRows.Count < 2)
                return;

            RomMatch romMatch = importGridView.SelectedRows[importGridView.SelectedRows.Count - 1].DataBoundItem as RomMatch;
            if (romMatch == null)
                return;
            Game game = romMatch.Game;
            if (game == null)
                return;

            List<Game> removeGames = new List<Game>();
            for (int x = importGridView.SelectedRows.Count - 2; x > -1; x--)
            {
                RomMatch match = importGridView.SelectedRows[x].DataBoundItem as RomMatch;
                if (match == null || match.Game == null || match.Game.Discs.Count > 1)
                    continue;

                GameDisc disc = match.Game.CurrentDisc;
                GameDisc newDisc = new GameDisc(disc.Path, disc.LaunchFile) { Number = game.Discs.Count + 1 };
                game.Discs.Add(newDisc);
                removeGames.Add(match.Game);
            }
            lock (EmulatorsCore.Database.SyncRoot)
            {
                EmulatorsCore.Database.ExecuteTransaction(removeGames, removeGame =>
                {
                    importer.Remove(removeGame.Id);
                    removeGame.Delete();
                });
            }

            romMatch.ResetDisplayInfo();
        }