Exemplo n.º 1
0
 private void menuPlayDebugLog_Click(object sender, RoutedEventArgs e)
 {
     if (MessageDialogWindow.Show(ResourceHelper.Get(StringKey.AreYouSureYouWantToPlayDebugWarning), ResourceHelper.Get(StringKey.Warning), MessageBoxButton.YesNo, MessageBoxImage.Warning).Result == MessageBoxResult.Yes)
     {
         ViewModel.LaunchGame(variableDump: false, debugLogging: true);
     }
 }
Exemplo n.º 2
0
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (ViewModel.CatalogMods.DownloadList.Count > 0)
            {
                var result = MessageDialogWindow.Show("Are you sure you want to exit? You have downloads pending.", "Confirm Exit", MessageBoxButton.YesNo, MessageBoxImage.Warning);

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

            Sys.Settings.MainWindow = new SavedWindow()
            {
                X     = (int)System.Windows.Application.Current.MainWindow.Left,
                Y     = (int)System.Windows.Application.Current.MainWindow.Top,
                W     = (int)ActualWidth,
                H     = (int)ActualHeight,
                State = WindowState
            };

            Sys.Settings.UserColumnSettings.MyModsColumns = ctrlMyMods.GetColumnSettings();
            ctrlCatalog.SaveUsersColumnSettings();

            ViewModel.CleanUp();
        }
Exemplo n.º 3
0
        internal void TurnOnPs4Service()
        {
            if (IsPs4SupportChecked)
            {
                if (!DS4ControllerService.IsScpDriverInstalled())
                {
                    // user must install the driver first before using ds4. prompt user driver will silently install then turn on
                    var messageResult = MessageDialogWindow.Show("The SCP Virtual Bus Driver is not installed. It is required to enable PS4 controller support.\n\nDo you want to install the driver?", "Missing Required Driver", MessageBoxButton.YesNo, MessageBoxImage.Question);

                    if (messageResult.Result == MessageBoxResult.No)
                    {
                        IsPs4SupportChecked = false; // uncheck this since user does not have driver installed so it can't be supported
                        return;
                    }

                    InstallDriverAsync().ContinueWith((result) =>
                    {
                        if (IsPs4SupportChecked && DS4ControllerService.IsScpDriverInstalled())
                        {
                            DS4ControllerService.Instance.StartService();
                        }
                    });
                    return;
                }

                // just turn on service if driver installed
                DS4ControllerService.Instance.StartService();
            }
        }
Exemplo n.º 4
0
 private void menuPlayDebugLog_Click(object sender, RoutedEventArgs e)
 {
     if (MessageDialogWindow.Show(_warningMessage, "Warning", MessageBoxButton.YesNo, MessageBoxImage.Warning).Result == MessageBoxResult.Yes)
     {
         ViewModel.LaunchGame(variableDump: false, debugLogging: true);
     }
 }
Exemplo n.º 5
0
        internal bool Validate(bool showErrorMsg = true)
        {
            string errorMsg = "";
            bool   isValid  = true;

            if (string.IsNullOrEmpty(PathToSourceFolder))
            {
                errorMsg = "Path to source folder is required";
                isValid  = false;
            }
            else if (string.IsNullOrEmpty(PathToOutputFile))
            {
                errorMsg = "Path to output iro file is required";
                isValid  = false;
            }
            else if (CompressionSelectedIndex < 0)
            {
                errorMsg = "Select a compression option";
                isValid  = false;
            }

            if (!isValid && showErrorMsg)
            {
                Logger.Warn($"invalid pack iro options: {errorMsg}");
                MessageDialogWindow.Show(errorMsg, "Missing Required Input", MessageBoxButton.OK, MessageBoxImage.Warning);
            }

            return(isValid);
        }
Exemplo n.º 6
0
        internal bool SaveSettings()
        {
            try
            {
                Sys.Settings.ProgramsToLaunchPrior = GetUpdatedProgramsToRun();

                Sys.Settings.GameLaunchSettings.AutoMountGameDisc   = AutoMountChecked;
                Sys.Settings.GameLaunchSettings.AutoUnmountGameDisc = AutoUnmountChecked;
                Sys.Settings.GameLaunchSettings.AutoUpdateDiscPath  = AutoUpdatePathChecked;
                Sys.Settings.GameLaunchSettings.MountingOption      = SelectedMountOptionAsEnum;
                Sys.Settings.GameLaunchSettings.ShowLauncherWindow  = IsShowLauncherChecked;

                Sys.Settings.GameLaunchSettings.DisableReunionOnLaunch = true; // always have this set to true

                Sys.Settings.GameLaunchSettings.SelectedSoundDevice      = SoundDeviceGuids[SelectedSoundDevice];
                Sys.Settings.GameLaunchSettings.SelectedMidiData         = MidiDataFormats[SelectedMidiData];
                Sys.Settings.GameLaunchSettings.ReverseSpeakers          = IsReverseSpeakersChecked;
                Sys.Settings.GameLaunchSettings.LogarithmicVolumeControl = IsLogVolumeChecked;
                SetVolumesInRegistry();
                SetMidiDeviceInRegistry();

                Sys.Settings.GameLaunchSettings.WorkaroundErrorCode5 = DoWorkaroundErrorCode5;

                Sys.SaveSettings();

                Sys.Message(new WMessage(ResourceHelper.Get(StringKey.GameLauncherSettingsUpdated)));
                return(true);
            }
            catch (Exception e)
            {
                MessageDialogWindow.Show(ResourceHelper.Get(StringKey.FailedToSaveLaunchSettings), e.Message, ResourceHelper.Get(StringKey.Error), MessageBoxButton.OK, MessageBoxImage.Error);
                Logger.Error(e);
                return(false);
            }
        }
Exemplo n.º 7
0
        internal bool Validate(bool showErrorMsg = true)
        {
            string errorMsg = "";
            bool   isValid  = true;

            if (string.IsNullOrEmpty(PathToSourceFolder))
            {
                errorMsg = ResourceHelper.Get(StringKey.PathToSourceFolderIsRequired);
                isValid  = false;
            }
            else if (string.IsNullOrEmpty(PathToOutputFile))
            {
                errorMsg = ResourceHelper.Get(StringKey.PathToOutputIroFileIsRequired);
                isValid  = false;
            }
            else if (CompressionSelectedIndex < 0)
            {
                errorMsg = ResourceHelper.Get(StringKey.SelectCompressionOption);
                isValid  = false;
            }

            if (!isValid && showErrorMsg)
            {
                Logger.Warn($"{ResourceHelper.Get(StringKey.InvalidPackIroOptions)}: {errorMsg}");
                MessageDialogWindow.Show(errorMsg, ResourceHelper.Get(StringKey.MissingRequiredInput), MessageBoxButton.OK, MessageBoxImage.Warning);
            }

            return(isValid);
        }
Exemplo n.º 8
0
        private bool TryBatchImport()
        {
            if (string.IsNullOrWhiteSpace(PathToBatchFolderInput))
            {
                MessageDialogWindow.Show("Enter a path to a folder containing .iro files and/or mod folders.", "Validation Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }

            if (!Directory.Exists(PathToBatchFolderInput))
            {
                MessageDialogWindow.Show("Directory does not exist.", "Validation Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }

            ModImporter importer = null;

            try
            {
                importer = new ModImporter();
                importer.ImportProgressChanged += Importer_ImportProgressChanged;

                int modImportCount = 0;

                foreach (string iro in Directory.GetFiles(PathToBatchFolderInput, "*.iro"))
                {
                    string modName = ModImporter.ParseNameFromFileOrFolder(Path.GetFileNameWithoutExtension(iro));
                    importer.Import(iro, modName, true, false);
                    modImportCount++;
                }

                foreach (string dir in Directory.GetDirectories(PathToBatchFolderInput))
                {
                    string modName = ModImporter.ParseNameFromFileOrFolder(Path.GetFileNameWithoutExtension(dir));
                    importer.Import(dir, modName, false, false);
                    modImportCount++;
                }

                Sys.Message(new WMessage($"Successfully imported {modImportCount} mod(s)!", true));
                return(true);
            }
            catch (DuplicateModException de)
            {
                Logger.Error(de);
                MessageDialogWindow.Show($"Can not import mod(s). {de.Message}", "Import Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }
            catch (Exception e)
            {
                Logger.Error(e);
                MessageDialogWindow.Show("Failed to import mod(s). The error has been logged.", "Import Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }
            finally
            {
                importer.ImportProgressChanged -= Importer_ImportProgressChanged;
            }
        }
Exemplo n.º 9
0
        private bool TryBatchImport()
        {
            if (string.IsNullOrWhiteSpace(PathToBatchFolderInput))
            {
                MessageDialogWindow.Show(ResourceHelper.Get(StringKey.EnterPathToFolderContainingIroFilesOrModFolders), ResourceHelper.Get(StringKey.ValidationError), MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }

            if (!Directory.Exists(PathToBatchFolderInput))
            {
                MessageDialogWindow.Show(ResourceHelper.Get(StringKey.DirectoryDoesNotExist), ResourceHelper.Get(StringKey.ValidationError), MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }

            ModImporter importer = null;

            try
            {
                importer = new ModImporter();
                importer.ImportProgressChanged += Importer_ImportProgressChanged;

                int modImportCount = 0;

                foreach (string iro in Directory.GetFiles(PathToBatchFolderInput, "*.iro"))
                {
                    string modName = ModImporter.ParseNameFromFileOrFolder(Path.GetFileNameWithoutExtension(iro));
                    importer.Import(iro, modName, true, false);
                    modImportCount++;
                }

                foreach (string dir in Directory.GetDirectories(PathToBatchFolderInput))
                {
                    string modName = ModImporter.ParseNameFromFileOrFolder(Path.GetFileNameWithoutExtension(dir));
                    importer.Import(dir, modName, false, false);
                    modImportCount++;
                }

                Sys.Message(new WMessage($"{ResourceHelper.Get(StringKey.SuccessfullyImported)} {modImportCount} mod(s)!", true));
                return(true);
            }
            catch (DuplicateModException de)
            {
                Logger.Error(de);
                MessageDialogWindow.Show($"{ResourceHelper.Get(StringKey.CanNotImportMod)}(s). {de.Message}", ResourceHelper.Get(StringKey.ImportError), MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }
            catch (Exception e)
            {
                Logger.Error(e);
                MessageDialogWindow.Show(ResourceHelper.Get(StringKey.FailedToImportModTheErrorHasBeenLogged), ResourceHelper.Get(StringKey.ImportError), MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }
            finally
            {
                importer.ImportProgressChanged -= Importer_ImportProgressChanged;
            }
        }
Exemplo n.º 10
0
        private void btnBrowseImage_Click(object sender, RoutedEventArgs e)
        {
            string pathToFile = FileDialogHelper.BrowseForFile("*.png,*.jpg,*.jpeg|*.png;*.jpg;*.jpeg", "Select image to use");


            if (!string.IsNullOrEmpty(pathToFile))
            {
                ViewModel.PreviewImageInput = System.IO.Path.GetFileName(pathToFile);
                MessageDialogWindow.Show($"Make sure to copy {ViewModel.PreviewImageInput} to the root folder of your mod so the preview image loads correctly.", "Info", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
        private void btnBrowseImage_Click(object sender, RoutedEventArgs e)
        {
            string pathToFile = FileDialogHelper.BrowseForFile("*.png,*.jpg,*.jpeg|*.png;*.jpg;*.jpeg", ResourceHelper.Get(StringKey.SelectImageToUse));


            if (!string.IsNullOrEmpty(pathToFile))
            {
                ViewModel.PreviewImageInput = System.IO.Path.GetFileName(pathToFile);
                MessageDialogWindow.Show(string.Format(ResourceHelper.Get(StringKey.MakeSureToCopyToTheRootFolder), ViewModel.PreviewImageInput), ResourceHelper.Get(StringKey.Info), MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
Exemplo n.º 12
0
 private void MenuItem_Click(object sender, RoutedEventArgs e)
 {
     if (SelectedSoundUC == null)
     {
         return;
     }
     if (MessageDialogWindow.Show(this, "Delete " + SelectedSoundUC.Tag.ToString(), "Delete sound", MessageBoxButton.YesNoCancel) == MessageBoxResult.Yes)
     {
         DeleteSound();
     }
 }
Exemplo n.º 13
0
        private void ShowInternal(MessageType messageType, string text, IEnumerable <string> detail, bool withCancel = false)
        {
            MessageDialogWindow window = new MessageDialogWindow();

            window.Caption            = _title;
            window.MessageType        = messageType;
            window.Text               = text;
            window.Detail             = detail;
            window.QuestionWithCancel = withCancel;
            window.ShowMessageWindow();
            _result = window.Result;
        }
Exemplo n.º 14
0
        /// <summary>
        /// Shows warning message dialog to user if <see cref="SelectedRenderer"/> is not set to "Custom 7H Game Driver"
        /// </summary>
        private void ShowWarningMessageAboutRenderer()
        {
            if (!HasLoaded)
            {
                // prevent warning from showing when loading settings
                return;
            }

            if (!SelectedRenderer.Equals("Custom 7H Game Driver", StringComparison.InvariantCultureIgnoreCase))
            {
                MessageDialogWindow.Show("Choosing any other option besides 'Custom 7H Game Driver' will cause mods installed with 7H not to work anymore!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
Exemplo n.º 15
0
        public void CheckForUpdates(Updater.GitHub.Releases.Channel channel)
        {
            try
            {
                _currentAppVersion = FileVersionInfo.GetVersionInfo(
                    Path.Combine(Sys._7HFolder, $"{App.GetAppName()}.exe")
                    );
            }
            catch (FileNotFoundException e)
            {
                _currentAppVersion = null;
                Sys.Message(new WMessage()
                {
                    Text = $"Could not get application version ", LoggedException = e
                });
            }

            if (_currentAppVersion != null)
            {
                Updater.GitHub.NewReleaseVersionInfo releaseVersioninfo = Updater.GitHub.Releases.isNewerVersion(new Version(GetCurrentAppVersion()), channel);
                if (releaseVersioninfo.isNewer)
                {
                    if (MessageDialogWindow.Show(
                            string.Format(ResourceHelper.Get(StringKey.AppUpdateIsAvailableMessage), $"{App.GetAppName()} - {App.GetAppVersion()}", releaseVersioninfo.version.ToString(), releaseVersioninfo.changeLog),
                            ResourceHelper.Get(StringKey.NewVersionAvailable),
                            System.Windows.MessageBoxButton.YesNo,
                            System.Windows.MessageBoxImage.Question
                            ).Result == System.Windows.MessageBoxResult.Yes)
                    {
                        Sys.Message(new WMessage()
                        {
                            Text = "Sarting updater application"
                        });
                        ProcessStartInfo startInfo = new ProcessStartInfo();
                        startInfo.UseShellExecute  = false;
                        startInfo.WorkingDirectory = Environment.CurrentDirectory;
                        startInfo.FileName         = "updater.exe";
                        startInfo.Arguments        = "\"" + System.AppDomain.CurrentDomain.BaseDirectory + "\\\" v" +
                                                     String.Format("{0}.{1}.{2}", releaseVersioninfo.version.Major, releaseVersioninfo.version.Minor, releaseVersioninfo.version.Build);
                        Process proc = Process.Start(startInfo);
                        IntPtr  hWnd = proc.MainWindowHandle;
                        if (hWnd != IntPtr.Zero)
                        {
                            SetForegroundWindow(hWnd);
                            ShowWindow(hWnd, int.Parse("9"));
                        }
                        App.ShutdownApp();
                    }
                }
            }
        }
Exemplo n.º 16
0
        public void DownloadAndExtractLatestVersion(FFNxUpdateChannelOptions channel)
        {
            DownloadItem download = new DownloadItem()
            {
                Links = new List <string>()
                {
                    LocationUtil.FormatHttpUrl(GetUpdateChannel(channel))
                },
                SaveFilePath = GetUpdateInfoPath(),
                Category     = DownloadCategory.AppUpdate,
                ItemName     = $"Fetching the latest FFNx version using channel {Sys.Settings.FFNxUpdateChannel.ToString()}..."
            };

            download.IProc = new Install.InstallProcedureCallback(e =>
            {
                bool success = (e.Error == null && e.Cancelled == false);

                if (success)
                {
                    try
                    {
                        StreamReader file = File.OpenText(download.SaveFilePath);
                        dynamic release   = JValue.Parse(file.ReadToEnd());
                        file.Close();
                        File.Delete(download.SaveFilePath);

                        Version newVersion = new Version(GetUpdateVersion(release.name.Value));
                        DownloadAndExtract(GetUpdateReleaseUrl(release.assets), newVersion.ToString());
                    }
                    catch (Exception)
                    {
                        MessageDialogWindow.Show("Something went wrong while checking for FFNx updates. Please try again later.", "Error", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
                        Sys.Message(new WMessage()
                        {
                            Text = $"Could not parse the FFNx release json at {GetUpdateChannel(channel)}", LoggedException = e.Error
                        });
                    }
                }
                else
                {
                    MessageDialogWindow.Show("Something went wrong while checking for FFNx updates. Please try again later.", "Error", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
                    Sys.Message(new WMessage()
                    {
                        Text = $"Could not fetch for FFNx updates at {GetUpdateChannel(channel)}", LoggedException = e.Error
                    });
                }
            });

            Sys.Downloads.AddToDownloadQueue(download);
        }
        internal void BeginExtract()
        {
            if (string.IsNullOrWhiteSpace(PathToFlevelFile))
            {
                MessageDialogWindow.Show(ResourceHelper.Get(StringKey.PathToFlevelRequired), ResourceHelper.Get(StringKey.MissingPath), MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            if (string.IsNullOrWhiteSpace(PathToOutputFolder))
            {
                MessageDialogWindow.Show(ResourceHelper.Get(StringKey.PathToOutputFolderRequired), ResourceHelper.Get(StringKey.MissingPath), MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            if (GetSelectedChunks()?.Count == 0)
            {
                MessageDialogWindow.Show(ResourceHelper.Get(StringKey.SelectTheSectionsToExtract), ResourceHelper.Get(StringKey.MissingPath), MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            if (!File.Exists(PathToFlevelFile))
            {
                MessageDialogWindow.Show(ResourceHelper.Get(StringKey.FlevelFileDoesNotExistAtGivenPath), ResourceHelper.Get(StringKey.MissingPath), MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            if (!Directory.Exists(PathToOutputFolder))
            {
                MessageDialogWindow.Show(ResourceHelper.Get(StringKey.OutputFolderDoesNotExist), ResourceHelper.Get(StringKey.MissingPath), MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }


            Task t = ExtractFlevelAsync();

            t.ContinueWith((taskResult) =>
            {
                string message = ResourceHelper.Get(StringKey.Complete);

                if (taskResult.IsFaulted)
                {
                    Logger.Error(taskResult.Exception?.GetBaseException());
                    message = ResourceHelper.Get(StringKey.FailedToExtractTheErrorHasBeenLogged);
                }

                MessageDialogWindow.Show(message, ResourceHelper.Get(StringKey.ExtractComplete));
                ProgressValue = 0;
            });
        }
Exemplo n.º 18
0
        internal void BeginExtract()
        {
            if (string.IsNullOrWhiteSpace(PathToFlevelFile))
            {
                MessageDialogWindow.Show("Path to Flevel required.", "Missing path", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            if (string.IsNullOrWhiteSpace(PathToOutputFolder))
            {
                MessageDialogWindow.Show("Path to output folder required.", "Missing path", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            if (GetSelectedChunks()?.Count == 0)
            {
                MessageDialogWindow.Show("Select the sections to extract.", "Missing path", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            if (!File.Exists(PathToFlevelFile))
            {
                MessageDialogWindow.Show("Flevel file does not exist at given path.", "Missing path", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            if (!Directory.Exists(PathToOutputFolder))
            {
                MessageDialogWindow.Show("Output folder does not exist.", "Missing path", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }


            Task t = ExtractFlevelAsync();

            t.ContinueWith((taskResult) =>
            {
                string message = "Complete!";

                if (taskResult.IsFaulted)
                {
                    Logger.Error(taskResult.Exception?.GetBaseException());
                    message = "Failed to extract. the error has been logged";
                }

                MessageDialogWindow.Show(message, "Extract Complete.");
                ProgressValue = 0;
            });
        }
Exemplo n.º 19
0
        private void PlayPause()
        {
            try
            {
                if (SelectedSoundUC == null)
                {
                    return;
                }

                if (CurrentSound != SelectedSoundUC.Tag.ToString() &&
                    waveOutDevice.PlaybackState == PlaybackState.Playing)
                {
                    threadSliderPosition.Suspend();
                    waveOutDevice.Dispose();
                    audioFileReader.Dispose();
                    playButtonSymbol.Data = PauseChevron;
                    ttbbPlayPause.Icon    = System.Drawing.Icon.FromHandle(Properties.Resources.PauseIcon.GetHicon());
                    StartNewSound();
                    return;
                }

                if (waveOutDevice.PlaybackState == PlaybackState.Playing)
                {
                    waveOutDevice.Pause();
                    threadSliderPosition.Suspend();
                    playButtonSymbol.Data = PlayChevron;
                    ttbbPlayPause.Icon    = System.Drawing.Icon.FromHandle(Properties.Resources.PlayIcon.GetHicon());
                    return;
                }

                if (waveOutDevice.PlaybackState == PlaybackState.Paused &&
                    audioFileReader.FileName == SelectedSoundUC.Tag.ToString())
                {
                    playButtonSymbol.Data = PauseChevron;
                    ttbbPlayPause.Icon    = System.Drawing.Icon.FromHandle(Properties.Resources.PauseIcon.GetHicon());
                    waveOutDevice.Play();
                    threadSliderPosition.Resume();
                    return;
                }

                playButtonSymbol.Data = PauseChevron;
                StartNewSound();
            }
            catch (Exception ex)
            {
                MessageDialogWindow.Show(this, ex.Message, "Error", MessageBoxButton.OK);
            }
        }
Exemplo n.º 20
0
        private void btnUninstall_Click(object sender, RoutedEventArgs e)
        {
            if (!IsModSelected())
            {
                return;
            }

            InstalledModViewModel selected = (lstMods.SelectedItem as InstalledModViewModel);

            MessageDialogWindow messageDialog = new MessageDialogWindow(ResourceHelper.Get(StringKey.UninstallWarning), $"{ResourceHelper.Get(StringKey.AreYouSureYouWantToDelete)} {selected.Name}?", MessageBoxButton.YesNo, MessageBoxImage.Warning);

            messageDialog.ShowDialog();

            if (messageDialog.ViewModel.Result == MessageBoxResult.Yes)
            {
                ViewModel.UninstallMod(selected);
            }
        }
Exemplo n.º 21
0
        private void btnUninstall_Click(object sender, RoutedEventArgs e)
        {
            if (!IsModSelected())
            {
                return;
            }

            InstalledModViewModel selected = (lstMods.SelectedItem as InstalledModViewModel);

            MessageDialogWindow messageDialog = new MessageDialogWindow("Uninstall Warning", $"Are you sure you want to delete {selected.Name}?", MessageBoxButton.YesNo, MessageBoxImage.Warning);

            messageDialog.ShowDialog();

            if (messageDialog.ViewModel.Result == MessageBoxResult.Yes)
            {
                ViewModel.UninstallMod(selected);
            }
        }
Exemplo n.º 22
0
        private bool TryImportFromFolder()
        {
            if (string.IsNullOrWhiteSpace(PathToModFolderInput))
            {
                MessageDialogWindow.Show(ResourceHelper.Get(StringKey.EnterPathToFolderContainingModFiles), ResourceHelper.Get(StringKey.ValidationError), MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }

            if (!Directory.Exists(PathToModFolderInput))
            {
                MessageDialogWindow.Show(ResourceHelper.Get(StringKey.DirectoryDoesNotExist), ResourceHelper.Get(StringKey.ValidationError), MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }

            ModImporter importer = null;

            try
            {
                string folderName = new DirectoryInfo(PathToModFolderInput).Name;

                importer = new ModImporter();
                importer.ImportProgressChanged += Importer_ImportProgressChanged;
                importer.Import(PathToModFolderInput, ModImporter.ParseNameFromFileOrFolder(folderName), false, false);

                Sys.Message(new WMessage($"{ResourceHelper.Get(StringKey.SuccessfullyImported)} {folderName}!", true));
                return(true);
            }
            catch (DuplicateModException de)
            {
                Logger.Error(de);
                MessageDialogWindow.Show($"{ResourceHelper.Get(StringKey.CanNotImportMod)} {de.Message}", ResourceHelper.Get(StringKey.ImportError), MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }
            catch (Exception e)
            {
                Logger.Error(e);
                MessageDialogWindow.Show(ResourceHelper.Get(StringKey.FailedToImportModTheErrorHasBeenLogged), ResourceHelper.Get(StringKey.ImportError), MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }
            finally
            {
                importer.ImportProgressChanged -= Importer_ImportProgressChanged;
            }
        }
Exemplo n.º 23
0
        private bool TryImportFromFolder()
        {
            if (string.IsNullOrWhiteSpace(PathToModFolderInput))
            {
                MessageDialogWindow.Show("Enter a path to a folder containing mod files.", "Validation Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }

            if (!Directory.Exists(PathToModFolderInput))
            {
                MessageDialogWindow.Show("Directory does not exist.", "Validation Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }

            ModImporter importer = null;

            try
            {
                string folderName = new DirectoryInfo(PathToModFolderInput).Name;

                importer = new ModImporter();
                importer.ImportProgressChanged += Importer_ImportProgressChanged;
                importer.Import(PathToModFolderInput, ModImporter.ParseNameFromFileOrFolder(folderName), false, false);

                Sys.Message(new WMessage($"Successfully imported {folderName}!", true));
                return(true);
            }
            catch (DuplicateModException de)
            {
                Logger.Error(de);
                MessageDialogWindow.Show($"Can not import mod. {de.Message}", "Import Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }
            catch (Exception e)
            {
                Logger.Error(e);
                MessageDialogWindow.Show("Failed to import mod. The error has been logged.", "Import Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }
            finally
            {
                importer.ImportProgressChanged -= Importer_ImportProgressChanged;
            }
        }
Exemplo n.º 24
0
        private bool TryImportFromIroArchive()
        {
            if (string.IsNullOrWhiteSpace(PathToIroArchiveInput))
            {
                MessageDialogWindow.Show("Enter a path to an .iro file.", "Validation Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }

            if (!File.Exists(PathToIroArchiveInput))
            {
                MessageDialogWindow.Show(".iro file does not exist.", "Validation Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }

            ModImporter importer = null;

            try
            {
                string fileName = Path.GetFileNameWithoutExtension(PathToIroArchiveInput);

                importer = new ModImporter();
                importer.ImportProgressChanged += Importer_ImportProgressChanged;
                importer.Import(PathToIroArchiveInput, ModImporter.ParseNameFromFileOrFolder(fileName), true, false);

                Sys.Message(new WMessage($"Successfully imported {fileName}!"));
                return(true);
            }
            catch (DuplicateModException de)
            {
                Logger.Error(de);
                MessageDialogWindow.Show($"Can not import mod. {de.Message}", "Import Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }
            catch (Exception e)
            {
                Logger.Error(e);
                MessageDialogWindow.Show("Failed to import mod. The error has been logged.", "Import Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }
            finally
            {
                importer.ImportProgressChanged -= Importer_ImportProgressChanged;
            }
        }
Exemplo n.º 25
0
        /// <summary>
        /// Run ScpDriver.exe on background task to install driver. Shows message and turns off ps4 controller support if fails.
        /// </summary>
        /// <returns></returns>
        private Task InstallDriverAsync()
        {
            IsInstallingDriver = true;
            return(Task.Factory.StartNew(() =>
            {
                ProcessStartInfo startInfo = new ProcessStartInfo(Sys.PathToScpDriverExe, "si")
                {
                    Verb = "runas",
                    WorkingDirectory = Sys.PathToVBusDriver // ensure the working directory is where the .exe is located
                };
                Process.Start(startInfo);

                // wait for the .exe driver install to finish
                while (Process.GetProcessesByName("ScpDriver").Length > 0)
                {
                    Thread.Sleep(100);
                }

                // check for installation by looking at log file
                bool installSuccess = false;

                if (File.Exists(Path.Combine(Sys.PathToVBusDriver, "ScpDriver.log")))
                {
                    string logContents = File.ReadAllText(Path.Combine(Sys.PathToVBusDriver, "ScpDriver.log"));
                    installSuccess = logContents.Contains("Install Succeeded");
                }

                // show message to user if issues with install or detecting
                if (installSuccess && !DS4ControllerService.IsScpDriverInstalled())
                {
                    MessageDialogWindow.Show("The SCP driver finished installing but could not be detected yet. Wait 5-10 seconds and try again (you may need to reboot for Windows to notice the driver.)", "Driver Installed", MessageBoxButton.OK, MessageBoxImage.Warning);
                    IsPs4SupportChecked = false; // uncheck so user can toggle back on in a few seconds
                }
                else if (!installSuccess)
                {
                    MessageDialogWindow.Show("The SCP driver failed to install.", "Install Failed", MessageBoxButton.OK, MessageBoxImage.Warning);
                    IsPs4SupportChecked = false; // uncheck so user can toggle back on in a few seconds to try again
                }

                IsInstallingDriver = false;
            }));
        }
Exemplo n.º 26
0
        private void StartUpdate(string sourcePath)
        {
            string fileName = Path.Combine(Sys.PathToTempFolder, "update.bat");

            System.IO.File.WriteAllText(
                fileName,
                $@"@echo off
@echo Waiting for 7th Heaven to be closed, please wait...
@taskkill /IM ""7th Heaven.exe"" /F >NUL 2>NUL
@timeout /t 5 /nobreak
@robocopy ""{sourcePath}"" ""{Sys._7HFolder}"" /S /MOV >NUL 2>NUL
@echo Waiting for the update to take place, please wait...
@timeout /t 5 /nobreak
@rmdir /s /q ""{sourcePath}""
@start """" /d ""{Sys._7HFolder}"" ""{Path.Combine(Sys._7HFolder, "7th Heaven.exe")}""
@del ""{fileName}""
"
                );

            // Execute temp batch script with admin privileges
            ProcessStartInfo startInfo = new ProcessStartInfo();

            startInfo.FileName        = fileName;
            startInfo.Verb            = "runas";
            startInfo.UseShellExecute = true;
            startInfo.CreateNoWindow  = false;
            try
            {
                // Launch process, wait and then save exit code
                using (Process temp = Process.Start(startInfo))
                {
                    temp.WaitForExit();
                }
            }
            catch (Exception e) {
                MessageDialogWindow.Show("Something went wrong while trying to update 7th Heaven. See the error log for more details.", "Error", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
                Sys.Message(new WMessage()
                {
                    Text = $"Error while trying to update 7thHeaven", LoggedException = e
                });
            }
        }
Exemplo n.º 27
0
        private void ShowWarningMessageAbouReunion()
        {
            if (!HasLoaded)
            {
                // prevent warning from showing when loading settings
                return;
            }

            if (GameLauncher.IsReunionModInstalled() && !DisableReunionChecked)
            {
                string warningMsg = "Reunion R06 and newer, even when disabled in Options.ini, forces a custom game driver to load when you run FF7. This conflicts with 7th Heaven's game driver, breaks your graphics settings, and you will experience problems.\n\nIf you wish to play Reunion, do so using a compatible modded version built for 7th Heaven.\n\nAre you sure?";
                var    result     = MessageDialogWindow.Show(warningMsg, "You should leave this setting ON!", MessageBoxButton.YesNo, MessageBoxImage.Warning);

                if (result.Result == MessageBoxResult.No)
                {
                    // re-enable option as user selected 'No' in warning message so reverting option
                    DisableReunionChecked = true;
                }
            }
        }
Exemplo n.º 28
0
        /// <summary>
        /// Adds or Edits program to run and closes programs popup
        /// </summary>
        internal bool SaveProgramToRun()
        {
            if (!File.Exists(NewProgramPathText))
            {
                MessageDialogWindow.Show(ResourceHelper.Get(StringKey.ProgramToRunNotFound), ResourceHelper.Get(StringKey.Error), MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }

            if (!ProgramList.Any(s => s.ProgramPath == NewProgramPathText))
            {
                ProgramList.Add(new ProgramToRunViewModel(NewProgramPathText, NewProgramArgsText));
            }
            else
            {
                ProgramToRunViewModel toEdit = ProgramList.FirstOrDefault(s => s.ProgramPath == NewProgramPathText);
                toEdit.ProgramArguments = NewProgramArgsText;
            }

            CloseProgramPopup();
            return(true);
        }
Exemplo n.º 29
0
        public static string InputNewProfileName(string prompt = null, string title = null)
        {
            if (string.IsNullOrWhiteSpace(prompt))
            {
                prompt = "Enter new profile name:";
            }

            if (string.IsNullOrWhiteSpace(title))
            {
                title = "New Profile";
            }

            string profileName = null;
            bool   isValid     = false;

            do
            {
                isValid = true;
                InputTextWindow inputBox     = new InputTextWindow(title, prompt);
                bool?           dialogResult = inputBox.ShowDialog();

                if (!dialogResult.GetValueOrDefault(false))
                {
                    return(null);
                }

                profileName = inputBox.ViewModel.TextInput;

                if (string.IsNullOrEmpty(profileName))
                {
                    isValid = false;
                    MessageDialogWindow.Show("Profile Name is empty.", "Profile Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            } while (!isValid);

            return(profileName);
        }
        public static string InputNewProfileName(string prompt = null, string title = null)
        {
            if (string.IsNullOrWhiteSpace(prompt))
            {
                prompt = ResourceHelper.Get(StringKey.EnterProfileName);
            }

            if (string.IsNullOrWhiteSpace(title))
            {
                title = ResourceHelper.Get(StringKey.NewProfile);
            }

            string profileName = null;
            bool   isValid     = false;

            do
            {
                isValid = true;
                InputTextWindow inputBox     = new InputTextWindow(title, prompt);
                bool?           dialogResult = inputBox.ShowDialog();

                if (!dialogResult.GetValueOrDefault(false))
                {
                    return(null);
                }

                profileName = inputBox.ViewModel.TextInput;

                if (string.IsNullOrEmpty(profileName))
                {
                    isValid = false;
                    MessageDialogWindow.Show(ResourceHelper.Get(StringKey.ProfileNameIsEmpty), ResourceHelper.Get(StringKey.ProfileError), MessageBoxButton.OK, MessageBoxImage.Error);
                }
            } while (!isValid);

            return(profileName);
        }