private void InitImportMovieOption()
        {
            ImportProgressVisibility = Visibility.Hidden;
            ImportProgressValue      = 0;
            ImportStatusMessage      = "";
            ImportButtonIsEnabled    = false;

            if (!string.IsNullOrEmpty(Sys.Settings.FF7Exe) & File.Exists(Sys.Settings.FF7Exe))
            {
                ImportButtonIsEnabled = !GameConverter.AllMovieFilesExist(Sys.Settings.MovieFolder);

                Dictionary <string, string[]> missingMovies = GameConverter.GetMissingMovieFiles(Sys.Settings.MovieFolder);

                if (missingMovies.Count > 0)
                {
                    List <string> discsToInsert = GetDiscsToInsertForMissingMovies(missingMovies);

                    ImportStatusMessage = string.Format(ResourceHelper.Get(StringKey.InsertAndClickImport), discsToInsert[0]);
                }
                else
                {
                    ImportStatusMessage = ResourceHelper.Get(StringKey.AllMovieFilesAlreadyImported);
                }
            }
            else
            {
                ImportStatusMessage = ResourceHelper.Get(StringKey.Ff7ExeNotFoundYouMayNeedToConfigure);
            }
        }
Example #2
0
        public async Task ConvertFromPGN_Should_SetGameProperties()
        {
            string pgn = @"
            [Event ""My Event""]
            [Site ""My Chessmeters.com""]
            [Round ""My Final""]
            [White ""User 1""]
            [Black ""User 2""]
            [WhiteElo ""1138""]
            [BlackElo ""1196""]
            [ECO ""B23""]
            [TimeControl ""1800""]
            [EndTime ""13:38:38 PDT""]
            [Termination ""claudiuoprea won by checkmate""]
            
            1. e4 c5 2. f4 { B21 Sicilian Defense: McDonnell Attack } d5 3. e5 { Black resigns. } 0-1            
            ";

            var gameConverter = new GameConverter();
            var games         = await gameConverter.ConvertFromPGN(pgn);

            var game = games.First();

            Assert.Equal("My Event", game.Event);
            Assert.Equal("My Chessmeters.com", game.Site);
            Assert.Equal("My Final", game.Round);
            Assert.Equal("User 1", game.White);
            Assert.Equal("User 2", game.Black);
            Assert.Equal <short?>(1138, game.WhiteElo);
            Assert.Equal <short?>(1196, game.BlackElo);
            Assert.Equal("B23", game.Eco);
            Assert.Equal("1800", game.TimeControl);
            Assert.Equal("13:38:38", game.EndTime.ToString());
            Assert.Equal("claudiuoprea won by checkmate", game.Termination);
        }
Example #3
0
        public async Task Post([FromBody] GameDTO game)
        {
            GameEntity entity = GameConverter.ToEntity(game);

            this.context.Games.Add(entity);
            await this.context.SaveChangesAsync();
        }
Example #4
0
        public void ShouldConvertToViewmodel()
        {
            var utctime = new DateTime(2018, 5, 30, 9, 24, 37);
            var entity  = new Game
            {
                Id            = 77,
                AwayTeam      = "Awayteam",
                HomeTeam      = "Hometeam",
                Date          = utctime,
                Round         = RoundType.First,
                FulltimeScore = "3-4",
                HalftimeScore = "1-2"
            };

            var convertor       = new GameConverter();
            var viewModelObject = convertor.ToEditModel(entity);

            Assert.AreEqual(viewModelObject.Id, entity.Id);
            Assert.AreEqual(viewModelObject.HomeTeam, entity.HomeTeam);
            Assert.AreEqual(viewModelObject.AwayTeam, entity.AwayTeam);
            Assert.AreEqual(viewModelObject.Round, entity.Round);
            Assert.AreEqual(viewModelObject.HalftimeScore, entity.HalftimeScore);
            Assert.AreEqual(viewModelObject.FulltimeScore, entity.FulltimeScore);

            // Date should be converted from UTC to localtime
            // localtime is in CEST so +2 hours
            Assert.AreEqual(viewModelObject.Date, new DateTime(2018, 5, 30, 11, 24, 37));
        }
Example #5
0
        public void ShouldConvertToEntity()
        {
            var localtime       = new DateTime(2018, 5, 30, 9, 24, 37);
            var viewModelObject = new GameEditModel
            {
                AwayTeam      = "Awayteam",
                HomeTeam      = "Hometeam",
                Date          = localtime,
                Round         = RoundType.First,
                FulltimeScore = "3-4",
                HalftimeScore = "1-2"
            };

            var convertor = new GameConverter();
            var entity    = convertor.ToEntity(viewModelObject, 2);

            Assert.AreEqual(viewModelObject.HomeTeam, entity.HomeTeam);
            Assert.AreEqual(viewModelObject.AwayTeam, entity.AwayTeam);
            Assert.AreEqual(viewModelObject.Round, entity.Round);
            Assert.AreEqual(viewModelObject.HalftimeScore, entity.HalftimeScore);
            Assert.AreEqual(viewModelObject.FulltimeScore, entity.FulltimeScore);

            // Date should be converted from local time to UTC
            // localtime is in CEST so -2 hours
            Assert.AreEqual(entity.Date, new DateTime(2018, 5, 30, 7, 24, 37));
        }
Example #6
0
        public void TestConversionToGame()
        {
            string time = DateTime.UtcNow.ToString();

            string[] values = new string[]
            {
                "Player",
                "Opponent",
                "Stage",
                "Win",
                time
            };

            ListViewItem item = new ListViewItem(values);

            Game game1 = new Game()
            {
                player    = "Player",
                opponent  = "Opponent",
                stage     = "Stage",
                result    = Result.Win,
                timeStamp = time
            };

            Game game2 = GameConverter.ItemToGame(item);

            Assert.AreEqual(game1, game2);
        }
Example #7
0
        // History panel

        private void PopulateHistoryListview()
        {
            foreach (Game g in history.games)
            {
                ListViewItem item = GameConverter.GameToItem(g);
                historyList.Items.Add(item);
            }
        }
Example #8
0
        private void btnFf7Exe_Click(object sender, RoutedEventArgs e)
        {
            string initialDir = "";

            if (File.Exists(ViewModel.FF7ExePathInput))
            {
                initialDir = Path.GetDirectoryName(ViewModel.FF7ExePathInput);
            }

            string exePath = FileDialogHelper.BrowseForFile("*.exe|*.exe", ResourceHelper.Get(StringKey.SelectFf7Exe), initialDir);

            if (!string.IsNullOrEmpty(exePath))
            {
                FileInfo fileSelected = new FileInfo(exePath);
                if (fileSelected.Name.Equals("ff7_en.exe", System.StringComparison.InvariantCultureIgnoreCase) || fileSelected.Name.Equals("FF7_Launcher.exe", System.StringComparison.InvariantCultureIgnoreCase))
                {
                    // User selected the exe's for Steam release so we try to auto copy the 1.02 patched exe and select it for them
                    string targetPathToFf7Exe  = Path.Combine(fileSelected.DirectoryName, "ff7.exe");
                    string copyOrSelectMessage = ResourceHelper.Get(StringKey.Selected);

                    if (!File.Exists(targetPathToFf7Exe))
                    {
                        // use game converter to copy files over
                        var gc = new GameConverter(fileSelected.DirectoryName);
                        if (!gc.CopyFF7ExeToGame())
                        {
                            MessageDialogWindow.Show(ResourceHelper.Get(StringKey.ThisExeIsUsedForSteamReleaseFailedToCopyExe),
                                                     ResourceHelper.Get(StringKey.ErrorIncorrectExe),
                                                     MessageBoxButton.OK,
                                                     MessageBoxImage.Error);
                            return;
                        }

                        copyOrSelectMessage = ResourceHelper.Get(StringKey.CopiedAndSelected);
                    }

                    ViewModel.FF7ExePathInput = targetPathToFf7Exe;

                    MessageDialogWindow.Show(string.Format(ResourceHelper.Get(StringKey.ThisExeIsUsedForSteamReleaseCopiedSelectedForYou), copyOrSelectMessage),
                                             ResourceHelper.Get(StringKey.ErrorIncorrectExe),
                                             MessageBoxButton.OK,
                                             MessageBoxImage.Warning);

                    return;
                }

                if (fileSelected.Name.Equals("FF7Config.exe", System.StringComparison.InvariantCultureIgnoreCase))
                {
                    MessageDialogWindow.Show(ResourceHelper.Get(StringKey.ThisExeIsUsedForConfiguringFf7Settings),
                                             ResourceHelper.Get(StringKey.ErrorIncorrectExe),
                                             MessageBoxButton.OK,
                                             MessageBoxImage.Error);
                    return;
                }

                ViewModel.FF7ExePathInput = exePath;
            }
        }
Example #9
0
        protected override void OnFormClosing(FormClosingEventArgs e)
        {
            history.games = new List <Game>();
            foreach (ListViewItem i in historyList.Items)
            {
                history.games.Add(GameConverter.ItemToGame(i));
            }

            history.Save();
            base.OnFormClosing(e);
        }
Example #10
0
        public async Task ConvertFromPGN_Should_GetOneGameFromPGN()
        {
            string pgn = "1. e4 c5 2. f4 { B21 Sicilian Defense: McDonnell Attack } d5 3. e5 { Black resigns. } 0-1";
            int    expected_games_count = 1;

            var gameConverter = new GameConverter();
            var games         = await gameConverter.ConvertFromPGN(pgn);

            Assert.Equal(games.Count(), expected_games_count);
            AssertGame(games.First(), "0-1", "e2e4 c7c5 f2f4 d7d5 e4e5");
        }
Example #11
0
 public Game GetByTableId(int tableId)
 {
     if (tableId == 0)
     {
         throw new ArgumentException();
     }
     else
     {
         Game game = GameConverter.ConvertFromGameModelToGame(gameCtrl.GetByTableId(tableId));
         return(game);
     }
 }
Example #12
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            AddDialog dialog = new AddDialog();

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                ListViewItem item = GameConverter.GameToItem(dialog.ReturnValue);
                historyList.Items.Add(item);

                PopulateStatisticListView();
            }
        }
Example #13
0
        public async Task ConvertFromPGN_Should_NotSetGameEmptyPropertie()
        {
            string pgn = @"[Event ""?""] [Site ""?""] [Round ""?""] [White ""?""] [Black ""?""] 1. e4 c5 2. f4 { B21 Sicilian Defense: McDonnell Attack } d5 3. e5 { Black resigns. } 0-1";

            var gameConverter = new GameConverter();
            var games         = await gameConverter.ConvertFromPGN(pgn);

            var game = games.First();

            Assert.Null(game.Event);
            Assert.Null(game.Site);
            Assert.Null(game.Round);
            Assert.Null(game.White);
            Assert.Null(game.Black);
        }
        private void InitImportMovieOption()
        {
            ImportProgressVisibility = Visibility.Hidden;
            ImportProgressValue      = 0;
            ImportStatusMessage      = "";
            ImportButtonIsEnabled    = !GameConverter.AllMovieFilesExist(Sys.Settings.MovieFolder);

            Dictionary <string, string[]> missingMovies = GameConverter.GetMissingMovieFiles(Sys.Settings.MovieFolder);

            if (missingMovies.Count > 0)
            {
                List <string> discsToInsert = GetDiscsToInsertForMissingMovies(missingMovies);

                ImportStatusMessage = $"Insert {discsToInsert[0]} and click 'Import'.";
            }
        }
Example #15
0
        public void TestConversion()
        {
            Game game1 = new Game()
            {
                player    = "Player",
                opponent  = "Opponent",
                stage     = "Stage",
                result    = Result.Win,
                timeStamp = DateTime.UtcNow.ToString()
            };

            ListViewItem item  = GameConverter.GameToItem(game1);
            Game         game2 = GameConverter.ItemToGame(item);

            Assert.AreEqual(game1, game2);
        }
        public async Task Schedule_Should_ParsePGNAndScheduleReport()
        {
            using var context = new ChessMetersContext(options, new OperationalStoreOptionsMigrations());

            var engineProcess          = new EngineProcess();
            var stockfishEngine        = new StockfishEngine(engineProcess);
            var engineAnalyzeEvaluator = new EngineEvaluationBuilder(stockfishEngine, context);
            var gameAnalyzer           = new TreeMovesBuilder(context, engineAnalyzeEvaluator);

            var gameConverter = new GameConverter();

            var reportGenerator = new ReportGenerator(gameAnalyzer, null, context);
            var reportId        = await context.Reports.Select(x => x.Id).FirstAsync();

            var report = await reportGenerator.Schedule(reportId, EngineConsts.defaultAnalyzeDepth);

            Assert.NotNull(report);
        }
Example #17
0
        public void TestConversionToListViewItem()
        {
            Game game = new Game
            {
                player    = "Player",
                opponent  = "Opponent",
                stage     = "Stage",
                result    = Result.Win,
                timeStamp = DateTime.UtcNow.ToString()
            };

            ListViewItem item = GameConverter.GameToItem(game);

            Assert.AreEqual(item.SubItems[0].Text, game.player);
            Assert.AreEqual(item.SubItems[1].Text, game.opponent);
            Assert.AreEqual(item.SubItems[2].Text, game.stage);
            Assert.AreEqual(item.SubItems[3].Text, game.result.ToString());
            Assert.AreEqual(item.SubItems[4].Text, game.timeStamp);
        }
Example #18
0
        private void EditButton_Click(object sender, EventArgs e)
        {
            if (historyList.SelectedItems.Count <= 0)
            {
                return;
            }

            Game       g      = GameConverter.ItemToGame(historyList.SelectedItems[0]);
            EditDialog dialog = new EditDialog(g);

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                int index = historyList.SelectedIndices[0];

                ListViewItem item = GameConverter.GameToItem(dialog.ReturnValue);
                historyList.Items.Remove(historyList.SelectedItems[0]);
                historyList.Items.Insert(index, item);

                PopulateStatisticListView();
            }
        }
        public Game StartGame(GameTable gameTable)
        {
            Game game = null;

            GameModel gameModel = gameDB.GetByTableId(gameTable.Id);

            if (gameModel != null)
            {
                game = GameConverter.ConvertFromGameModelToGame(gameModel);
            }
            if (game == null)
            {
                foreach (CGUser user in gameTable.Users)
                {
                    userManagement.DeleteHand(user);
                    user.cards.Clear();
                }
                gameTable.Deck = ShuffleDeck(gameTable.Deck);
                DealCards(gameTable.Deck, gameTable.Users);
                game = new Game(gameTable);
                CreateGame(game);
            }
            return(game);
        }
        private void btnFf7Exe_Click(object sender, RoutedEventArgs e)
        {
            string initialDir = "";

            if (File.Exists(ViewModel.FF7ExePathInput))
            {
                initialDir = Path.GetDirectoryName(ViewModel.FF7ExePathInput);
            }

            string exePath = FileDialogHelper.BrowseForFile("exe file (*.exe)|*.exe", "Select FF7.exe", initialDir);

            if (!string.IsNullOrEmpty(exePath))
            {
                FileInfo fileSelected = new FileInfo(exePath);
                if (fileSelected.Name.Equals("ff7_en.exe", System.StringComparison.InvariantCultureIgnoreCase) || fileSelected.Name.Equals("FF7_Launcher.exe", System.StringComparison.InvariantCultureIgnoreCase))
                {
                    // User selected the exe's for Steam release so we try to auto copy the 1.02 patched exe and select it for them
                    string targetPathToFf7Exe  = Path.Combine(fileSelected.DirectoryName, "ff7.exe");
                    string copyOrSelectMessage = "selected";

                    if (!File.Exists(targetPathToFf7Exe))
                    {
                        // use game converter to copy files over
                        var gc = new GameConverter(new ConversionSettings()
                        {
                            InstallPath = fileSelected.DirectoryName
                        });
                        if (!gc.CopyFF7ExeToGame())
                        {
                            MessageDialogWindow.Show("This exe is used for the Steam release of FF7, which 7th Heaven does not support. The 1.02 patch ff7.exe failed to copy and could not be auto selected for you.",
                                                     "Error - Incorrect Exe",
                                                     MessageBoxButton.OK,
                                                     MessageBoxImage.Error);
                            return;
                        }

                        copyOrSelectMessage = "copied and selected";
                    }

                    ViewModel.FF7ExePathInput = targetPathToFf7Exe;

                    MessageDialogWindow.Show($"This exe is used for the Steam release of FF7, which 7th Heaven does not support. The 1.02 patch ff7.exe was {copyOrSelectMessage} for you to ensure 7th Heaven works.",
                                             "Warning - Incorrect Exe",
                                             MessageBoxButton.OK,
                                             MessageBoxImage.Warning);

                    return;
                }

                if (fileSelected.Name.Equals("FF7Config.exe", System.StringComparison.InvariantCultureIgnoreCase))
                {
                    MessageDialogWindow.Show("This exe is used for configuring FF7 settings and is not the correct game exe. Please select a different FF7 EXE file.",
                                             "Error - Incorrect Exe",
                                             MessageBoxButton.OK,
                                             MessageBoxImage.Error);
                    return;
                }

                ViewModel.FF7ExePathInput = exePath;
            }
        }
        internal void ImportMissingMovies()
        {
            string warningMessage         = string.Format(ResourceHelper.Get(StringKey.ImportMissingMoviesWarningMessage), Sys.Settings.MovieFolder);
            MessageDialogViewModel result = MessageDialogWindow.Show(warningMessage, ResourceHelper.Get(StringKey.Warning), MessageBoxButton.YesNo, MessageBoxImage.Warning);

            if (result.Result == MessageBoxResult.No)
            {
                return;
            }

            ImportButtonIsEnabled    = false;
            ImportProgressVisibility = Visibility.Visible;

            bool cancelProcess = false;
            int  totalFiles    = 0;
            int  filesCopied   = 0;

            Task importTask = Task.Factory.StartNew(() =>
            {
                Dictionary <string, string[]> missingMovies = GameConverter.GetMissingMovieFiles(Sys.Settings.MovieFolder);
                List <string> discsToInsert = GetDiscsToInsertForMissingMovies(missingMovies);

                totalFiles = missingMovies.Count;

                foreach (string disc in discsToInsert)
                {
                    List <string> driveLetters;

                    do
                    {
                        SetImportStatus($"{ResourceHelper.Get(StringKey.LookingFor)} {disc} ...");
                        driveLetters = GameLauncher.GetDriveLetters(disc);

                        if (driveLetters.Count == 0)
                        {
                            SetImportStatus(string.Format(ResourceHelper.Get(StringKey.InsertToContinue), disc));

                            App.Current.Dispatcher.Invoke(() =>
                            {
                                string discNotFoundMessage = string.Format(ResourceHelper.Get(StringKey.PleaseInsertToContinueCopying), disc);
                                MessageDialogViewModel insertDiscResult = MessageDialogWindow.Show(discNotFoundMessage, ResourceHelper.Get(StringKey.InsertDisc), MessageBoxButton.OKCancel, MessageBoxImage.Warning);

                                cancelProcess = (insertDiscResult.Result == MessageBoxResult.Cancel);
                            });
                        }

                        if (cancelProcess)
                        {
                            return;
                        }
                    } while (driveLetters.Count == 0);

                    SetImportStatus($"{string.Format(ResourceHelper.Get(StringKey.FoundDiscAt), disc)} {string.Join("  ", driveLetters)} ...");

                    // loop over missing files on the found disc and copy to data/movies destination
                    foreach (string movieFile in missingMovies.Where(kv => kv.Value.Any(s => s.Equals(disc, StringComparison.InvariantCultureIgnoreCase)))
                             .Select(kv => kv.Key))
                    {
                        foreach (string drive in driveLetters)
                        {
                            string fullTargetPath = Path.Combine(Sys.Settings.MovieFolder, movieFile);
                            string sourceFilePath = Path.Combine(drive, "ff7", "movies", movieFile);

                            if (File.Exists(sourceFilePath))
                            {
                                if (File.Exists(fullTargetPath))
                                {
                                    SetImportStatus($"{ResourceHelper.Get(StringKey.Overwriting)} {movieFile} ...");
                                }
                                else
                                {
                                    SetImportStatus($"{ResourceHelper.Get(StringKey.Copying)} {movieFile} ...");
                                }

                                File.Copy(sourceFilePath, fullTargetPath, true);
                                filesCopied++;
                                UpdateImportProgress(filesCopied, totalFiles);
                                break;
                            }
                            else
                            {
                                SetImportStatus(string.Format(ResourceHelper.Get(StringKey.FailedToFindAt), movieFile, sourceFilePath));
                            }
                        }
                    }
                }
            });

            importTask.ContinueWith((taskResult) =>
            {
                if (taskResult.IsFaulted)
                {
                    Logger.Error(taskResult.Exception);
                    SetImportStatus($"{ResourceHelper.Get(StringKey.AnErrorOccurredCopyingMovies)}: {taskResult.Exception.GetBaseException().Message}");
                }
                else if (cancelProcess)
                {
                    InitImportMovieOption();
                }
                else
                {
                    if (filesCopied == totalFiles)
                    {
                        SetImportStatus(ResourceHelper.Get(StringKey.SuccessfullyCopiedMovies));
                    }
                    else
                    {
                        SetImportStatus(ResourceHelper.Get(StringKey.FinishedCopyingMoviesSomeFailed));
                    }

                    ImportButtonIsEnabled    = !GameConverter.AllMovieFilesExist(Sys.Settings.MovieFolder);
                    ImportProgressValue      = 0;
                    ImportProgressVisibility = Visibility.Hidden;
                }
            });
        }
        public static void AutoDetectSystemPaths(Settings settings)
        {
            if (string.IsNullOrEmpty(settings.FF7Exe) || !File.Exists(settings.FF7Exe))
            {
                Logger.Info("FF7 Exe path is empty or ff7.exe is missing. Auto detecting paths ...");

                string     registry_path = @"HKEY_LOCAL_MACHINE\SOFTWARE\Square Soft, Inc.\Final Fantasy VII";
                string     ff7           = null;
                FF7Version foundVersion  = FF7Version.Unknown;

                try
                {
                    // first try to detect 1998 game or a "converted" game from the old 7H game converter
                    ff7          = (string)Registry.GetValue(registry_path, "AppPath", null);
                    foundVersion = !string.IsNullOrWhiteSpace(ff7) ? FF7Version.Original98 : FF7Version.Unknown;

                    if (!Directory.Exists(ff7))
                    {
                        Logger.Warn($"Deleting invalid 'AppPath' registry key since path does not exist: {ff7}");
                        RegistryHelper.DeleteValueFromKey(registry_path, "AppPath");   // delete old paths set
                        RegistryHelper.DeleteValueFromKey(registry_path, "DataPath");  // delete old paths set
                        RegistryHelper.DeleteValueFromKey(registry_path, "MoviePath"); // delete old paths set
                        foundVersion = FF7Version.Unknown;                             // set back to Unknown to check other registry keys
                    }


                    if (foundVersion == FF7Version.Unknown)
                    {
                        // next check Steam registry keys and then Re-Release registry keys for installation path
                        ff7          = GameConverter.GetInstallLocation(FF7Version.Steam);
                        foundVersion = !string.IsNullOrWhiteSpace(ff7) ? FF7Version.Steam : FF7Version.Unknown;


                        if (foundVersion == FF7Version.Unknown)
                        {
                            ff7          = GameConverter.GetInstallLocation(FF7Version.ReRelease);
                            foundVersion = !string.IsNullOrWhiteSpace(ff7) ? FF7Version.ReRelease : FF7Version.Unknown;
                        }
                    }

                    string versionStr = foundVersion == FF7Version.Original98 ? $"{foundVersion.ToString()} (or Game Converted)" : foundVersion.ToString();

                    Logger.Info($"FF7Version Detected: {versionStr} with installation path: {ff7}");

                    if (!Directory.Exists(ff7))
                    {
                        Logger.Warn("Found installation path does not exist. Ignoring...");
                        return;
                    }
                }
                catch
                {
                    // could fail if game not installed
                }

                if (foundVersion != FF7Version.Unknown)
                {
                    settings.SetPathsFromInstallationPath(ff7);

                    // copy ff7.exe to install path if not found since Steam & Re-Release installation does not provide a ff7.exe
                    if (!File.Exists(settings.FF7Exe) && Path.GetFileName(settings.FF7Exe).Equals("ff7.exe", StringComparison.InvariantCultureIgnoreCase))
                    {
                        Logger.Info($"Copying ff7.exe from {Sys.PathToPatchedExeFolder} to {settings.FF7Exe}");

                        try
                        {
                            File.Copy(Path.Combine(Sys.PathToPatchedExeFolder, "ff7.exe"), settings.FF7Exe, true);
                            Logger.Info($"\tcopied succesfully.");
                        }
                        catch (Exception ex)
                        {
                            Logger.Error(ex);
                        }
                    }
                }
                else
                {
                    Logger.Warn("Auto detect paths failed - could not get ff7.exe path from Windows Registry.");
                }
            }
        }
        internal void ImportMissingMovies()
        {
            string warningMessage         = $"This will copy missing movie files from your game discs to your movie path in 'General Settings'.\n\nThis process will overwrite any movie files already in {Sys.Settings.MovieFolder}.\n\nDo you want to proceed?";
            MessageDialogViewModel result = MessageDialogWindow.Show(warningMessage, "Import Warning", MessageBoxButton.YesNo, MessageBoxImage.Warning);

            if (result.Result == MessageBoxResult.No)
            {
                return;
            }

            ImportButtonIsEnabled    = false;
            ImportProgressVisibility = Visibility.Visible;

            bool cancelProcess = false;
            int  totalFiles    = 0;
            int  filesCopied   = 0;

            Task importTask = Task.Factory.StartNew(() =>
            {
                Dictionary <string, string[]> missingMovies = GameConverter.GetMissingMovieFiles(Sys.Settings.MovieFolder);
                List <string> discsToInsert = GetDiscsToInsertForMissingMovies(missingMovies);

                totalFiles = missingMovies.Count;

                foreach (string disc in discsToInsert)
                {
                    List <string> driveLetters;

                    do
                    {
                        SetImportStatus($"Looking for {disc} ...");
                        driveLetters = GameLauncher.GetDriveLetters(disc);

                        if (driveLetters.Count == 0)
                        {
                            SetImportStatus($"Insert {disc} to continue.");

                            App.Current.Dispatcher.Invoke(() =>
                            {
                                string discNotFoundMessage = $"Please insert {disc} to continue copying missing movie files.\n\nClick 'Cancel' to stop the process.";
                                MessageDialogViewModel insertDiscResult = MessageDialogWindow.Show(discNotFoundMessage, "Insert Disc", MessageBoxButton.OKCancel, MessageBoxImage.Warning);

                                cancelProcess = (insertDiscResult.Result == MessageBoxResult.Cancel);
                            });
                        }

                        if (cancelProcess)
                        {
                            return;
                        }
                    } while (driveLetters.Count == 0);

                    SetImportStatus($"Found {disc} at {string.Join("  ", driveLetters)} ...");

                    // loop over missing files on the found disc and copy to data/movies destination
                    foreach (string movieFile in missingMovies.Where(kv => kv.Value.Any(s => s.Equals(disc, StringComparison.InvariantCultureIgnoreCase)))
                             .Select(kv => kv.Key))
                    {
                        foreach (string drive in driveLetters)
                        {
                            string fullTargetPath = Path.Combine(Sys.Settings.MovieFolder, movieFile);
                            string sourceFilePath = Path.Combine(drive, "ff7", "movies", movieFile);

                            if (File.Exists(sourceFilePath))
                            {
                                if (File.Exists(fullTargetPath))
                                {
                                    SetImportStatus($"Overwriting {movieFile} ...");
                                }
                                else
                                {
                                    SetImportStatus($"Copying {movieFile} ...");
                                }

                                File.Copy(sourceFilePath, fullTargetPath, true);
                                filesCopied++;
                                UpdateImportProgress(filesCopied, totalFiles);
                                break;
                            }
                            else
                            {
                                SetImportStatus($"Failed to find {movieFile} at {sourceFilePath}");
                            }
                        }
                    }
                }
            });

            importTask.ContinueWith((taskResult) =>
            {
                if (taskResult.IsFaulted)
                {
                    Logger.Error(taskResult.Exception);
                    SetImportStatus($"An error occurred while copying movies: {taskResult.Exception.GetBaseException().Message}");
                }
                else if (cancelProcess)
                {
                    InitImportMovieOption();
                }
                else
                {
                    if (filesCopied == totalFiles)
                    {
                        SetImportStatus("Successfully copied movies.");
                    }
                    else
                    {
                        SetImportStatus("Finished copying movies. Some movies failed to copy. Check app log for details.");
                    }

                    ImportButtonIsEnabled    = !GameConverter.AllMovieFilesExist(Sys.Settings.MovieFolder);
                    ImportProgressValue      = 0;
                    ImportProgressVisibility = Visibility.Hidden;
                }
            });
        }