private void LoadMapInBackgroundAndContinueWith(Action <Task> continuationTask)
        {
            if (SessionPath.IsSessionPathValid() == false)
            {
                System.Windows.MessageBox.Show("You have selected an incorrect path to Session. Make sure the directory you choose has the folders 'Engine' and 'SessionGame'.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (EzPzPatcher.IsGamePatched() == false && UnpackUtils.IsSessionUnpacked() == false)
            {
                MessageBoxResult result = System.Windows.MessageBox.Show("Session has not been patched yet. Click 'Patch With EzPz' to patch the game.", "Notice!", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }



            if (EzPzPatcher.IsGamePatched() == false && ViewModel.IsSessionUnpacked())
            {
                if (ViewModel.IsOriginalMapFilesBackedUp() == false)
                {
                    System.Windows.MessageBox.Show("The original Session game map files have not been backed up yet. Click OK to backup the files then click 'Load Map' again.",
                                                   "Notice!",
                                                   MessageBoxButton.OK,
                                                   MessageBoxImage.Information);

                    ViewModel.BackupOriginalMapFiles();
                    return;
                }
            }

            if (lstMaps.SelectedItem == null)
            {
                System.Windows.MessageBox.Show("Select a map to load first!",
                                               "Notice!",
                                               MessageBoxButton.OK,
                                               MessageBoxImage.Information);
                return;
            }


            MapListItem selectedItem = lstMaps.SelectedItem as MapListItem;

            if (selectedItem.IsValid == false)
            {
                System.Windows.MessageBox.Show("This map is missing the required Game Mode Override 'PBP_InGameSessionGameMode'.\n\nAdd a Game Mode to your map in UE4: '/Content/Data/PBP_InGameSessionGameMode.uasset'.\nThen reload the list of available maps.",
                                               "Error!",
                                               MessageBoxButton.OK,
                                               MessageBoxImage.Error);
                return;
            }

            ViewModel.UserMessage          = $"Loading {selectedItem.MapName} ...";
            ViewModel.InputControlsEnabled = false;

            Task t = Task.Run(() => ViewModel.LoadSelectedMap(selectedItem));

            t.ContinueWith(continuationTask);
        }
        private void BtnImportMap_Click(object sender, RoutedEventArgs e)
        {
            if (EzPzPatcher.IsGamePatched() == false && UnpackUtils.IsSessionUnpacked() == false)
            {
                MessageBoxResult result = System.Windows.MessageBox.Show("Session has not been patched yet. Click 'Patch With EzPz' to patch the game.", "Notice!", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            importContextMenu.IsOpen = true;
        }
        private void BtnApplySettings_Click(object sender, RoutedEventArgs e)
        {
            if (ViewModel.InputControlsEnabled == false)
            {
                return;
            }

            if (EzPzPatcher.IsGamePatched() == false && UnpackUtils.IsSessionUnpacked() == false)
            {
                MessageBoxResult result = System.Windows.MessageBox.Show("Session has not been patched yet. Click 'Patch With EzPz' to patch the game.", "Notice!", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            if (GameSettingsManager.DoesObjectPlacementFileExist() == false)
            {
                MessageBoxResult promptResult = System.Windows.MessageBox.Show("The required file is missing and must be extracted before object count can be modified.\n\nClick 'Yes' to extract the file (UnrealPak and crypto.json will be downloaded if it is not installed locally).",
                                                                               "Warning - Cannot Modify Object Count!",
                                                                               MessageBoxButton.YesNo,
                                                                               MessageBoxImage.Information,
                                                                               MessageBoxResult.Yes);

                if (promptResult == MessageBoxResult.Yes)
                {
                    ViewModel.StartPatching(skipPatching: true, skipUnpacking: false, unrealPathFromRegistry: RegistryHelper.GetPathToUnrealEngine());
                    return;
                }
            }


            bool didSet = ViewModel.UpdateGameSettings();


            if (didSet)
            {
                ViewModel.UserMessage = "Game settings updated!";

                if (SessionPath.IsSessionRunning())
                {
                    ViewModel.UserMessage += " Restart the game for changes to take effect.";
                }
            }
        }