예제 #1
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 = Emulators2Settings.OpenFileDialog("Select file", filterStr, System.IO.Path.GetDirectoryName(selectedGame.Path)))
            {
                dlg.Multiselect = true;
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    foreach (string filename in dlg.FileNames)
                    {
                        GameDisc newDisc = new GameDisc(selectedGame);
                        newDisc.Path = filename;
                        int index = discBindingSource.Add(newDisc);
                        newDisc.Number = index + 1;
                    }
                    saveDiscs = true;
                }
            }
        }
예제 #2
0
        void updateDiscs()
        {
            if (!saveDiscs)
            {
                return;
            }

            if (discBindingSource.Count > 0)
            {
                lock (DB.Instance.SyncRoot)
                {
                    DB.Instance.ExecuteWithoutLock("BEGIN");
                    for (int x = 0; x < discBindingSource.Count; x++)
                    {
                        GameDisc disc = discBindingSource[x] as GameDisc;
                        if (disc == null)
                        {
                            continue;
                        }

                        disc.Number = x + 1;
                        disc.Save();
                    }
                    DB.Instance.ExecuteWithoutLock("COMMIT");
                }
            }
            saveDiscs = false;
        }
예제 #3
0
        static bool showDiscSelect(ref int 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.Number == selectedDisc)
                    {
                        selectedLabel = x;
                    }
                }

                dlg.SelectedLabel = selectedLabel;
                dlg.DoModal(windowID);

                if (dlg.SelectedId > 0)
                {
                    selectedDisc = dlg.SelectedId;
                    return(true);
                }
            }
            return(false);
        }
예제 #4
0
        private void delDiscButton_Click(object sender, EventArgs e)
        {
            if (discGridView.SelectedRows.Count < 1)
            {
                return;
            }

            if (MessageBox.Show("Are you sure you want to delete the selected discs\r\nand add them to the ignored files list?", "Delete discs?", MessageBoxButtons.YesNo) != DialogResult.Yes)
            {
                return;
            }

            List <GameDisc> discs       = new List <GameDisc>();
            List <int>      indices     = new List <int>();
            bool            currentDisc = false;

            for (int x = 0; x < discGridView.SelectedRows.Count; x++)
            {
                DataGridViewRow row = discGridView.SelectedRows[x];
                if (!currentDisc)
                {
                    currentDisc = ((GameDisc)row.DataBoundItem).Selected;
                }
                indices.Add(row.Index);
            }

            int selectedIndex = indices.Count > 0 ? indices[0] : 0;

            DB.Instance.ExecuteTransaction(indices, index =>
            {
                GameDisc disc = discGridView.Rows[index].DataBoundItem as GameDisc;
                if (disc != null)
                {
                    Options.Instance.AddIgnoreFile(disc.Path);
                    disc.Delete();
                }
                discBindingSource.RemoveAt(index);
            });

            if (discBindingSource.Count > 0)
            {
                updateDiscNumbers();
                if (selectedIndex > discBindingSource.Count - 1)
                {
                    selectedIndex = discBindingSource.Count - 1;
                }

                DataGridViewRow row = discGridView.Rows[selectedIndex];
                row.Selected = true;
                if (currentDisc)
                {
                    ((GameDisc)row.DataBoundItem).Selected = true;
                }
            }

            saveDiscs = true;
        }
예제 #5
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 <GameDisc> discs       = game.GetDiscs();
            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.GetDiscs().Count > 1)
                {
                    continue;
                }

                GameDisc disc = new GameDisc(game)
                {
                    Path = match.Game.Path, LaunchFile = match.Game.LaunchFile, Number = discs.Count + 1
                };
                discs.Add(disc);
                removeGames.Add(match.Game);
            }
            lock (DB.Instance.SyncRoot)
            {
                DB.Instance.ExecuteTransaction(removeGames, removeGame =>
                {
                    importer.Remove(removeGame.GameID);
                    removeGame.Delete();
                });

                DB.Instance.ExecuteTransaction(discs, disc => disc.Save());
            }

            romMatch.ResetDisplayInfo();
        }
예제 #6
0
        void unMergeSelectedRow()
        {
            if (importGridView.SelectedRows.Count != 1)
            {
                return;
            }

            DataGridViewRow selectedRow = importGridView.SelectedRows[0];
            RomMatch        romMatch    = selectedRow.DataBoundItem as RomMatch;

            if (romMatch == null)
            {
                return;
            }
            List <GameDisc> discs = romMatch.Game.GetDiscs();

            if (discs.Count < 2)
            {
                return;
            }
            romMatch.ResetDisplayInfo();
            romMatch.Game.CurrentDiscNum = 1;
            romMatch.Game.SaveGamePlayInfo();
            List <Game> newGames = new List <Game>();

            for (int x = 0; x < discs.Count; x++)
            {
                GameDisc disc = discs[x];
                disc.Delete();
                if (x > 0)
                {
                    Game newGame = new Game(disc.Path, romMatch.Game.ParentEmulator)
                    {
                        LaunchFile = disc.LaunchFile
                    };
                    newGame.Save();
                    newGames.Add(newGame);
                    importerBindingSource.Insert(selectedRow.Index + x, new RomMatch(newGame)
                    {
                        BindingSourceIndex = romMatch.BindingSourceIndex + x
                    });
                }
            }
            importer.AddGames(newGames);
        }
예제 #7
0
        public List <GameDisc> GetDiscs()
        {
            List <GameDisc> discs = new List <GameDisc>();

            foreach (SQLite.NET.SQLiteResultSet.Row row in DB.Instance.Execute("SELECT * FROM {0} WHERE gameid={1} ORDER BY discnumber", GameDisc.TABLE_NAME, gameid).Rows)
            {
                GameDisc disc = GameDisc.CreateGameDisc(row);
                if (disc != null)
                {
                    discs.Add(disc);
                }
            }
            if (discs.Count < 1)
            {
                discs.Add(new GameDisc(this)
                {
                    Path = path, LaunchFile = launchFile
                });
            }
            return(discs);
        }