Esempio n. 1
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;
            }
        }
Esempio n. 2
0
        private bool IsProfileSelected()
        {
            if (lstProfiles.SelectedItem == null)
            {
                MessageDialogWindow.Show("Select a Profile first.", "No Profile Selected", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return(false);
            }

            return(true);
        }
        private bool IsProfileSelected()
        {
            if (lstProfiles.SelectedItem == null)
            {
                MessageDialogWindow.Show(ResourceHelper.Get(StringKey.SelectProfileToContinue), ResourceHelper.Get(StringKey.NoProfileSelected), MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return(false);
            }

            return(true);
        }
Esempio n. 4
0
        private void DeleteProfile_Click(object sender, RoutedEventArgs e)
        {
            if (!IsProfileSelected())
            {
                return;
            }

            string selected = (string)lstProfiles.SelectedItem;

            if (MessageDialogWindow.Show($"Are you sure you want to delete the selected profile ({selected})?", "Delete Warning", MessageBoxButton.YesNo, MessageBoxImage.Warning).Result == MessageBoxResult.Yes)
            {
                ViewModel.DeleteProfile(selected);
            }
        }
        private void DeleteProfile_Click(object sender, RoutedEventArgs e)
        {
            if (!IsProfileSelected())
            {
                return;
            }

            string selected = (string)lstProfiles.SelectedItem;

            if (MessageDialogWindow.Show($"{ResourceHelper.Get(StringKey.AreYouSureYouWantToDeleteSelectedProfile)} ({selected})?", ResourceHelper.Get(StringKey.Warning), MessageBoxButton.YesNo, MessageBoxImage.Warning).Result == MessageBoxResult.Yes)
            {
                ViewModel.DeleteProfile(selected);
            }
        }
Esempio n. 6
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                foreach (GLSettingViewModel item in ViewModels)
                {
                    item.Save(_settings);
                }

                File.WriteAllLines(_file, _settings.GetOutput());

                Sys.Message(new WMessage("Game Driver settings saved!"));
                this.Close();
            }
            catch (UnauthorizedAccessException)
            {
                MessageDialogWindow.Show("Could not write to 7H_GameDriver.cfg file. Check that it is not set to read only, and that FF7 is installed in a folder you have full write access to.", "Save Error", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                SetStatusMessage("Unknown error while saving. error has been logged.");
            }
        }
Esempio n. 7
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                foreach (GLSettingViewModel item in ViewModels)
                {
                    item.Save(_settings);
                }

                File.WriteAllLines(_file, _settings.GetOutput());

                Sys.Message(new WMessage(ResourceHelper.Get(StringKey.GameDriverSettingsSaved)));
                this.Close();
            }
            catch (UnauthorizedAccessException)
            {
                MessageDialogWindow.Show(ResourceHelper.Get(StringKey.CouldNotWriteTo7HGameDriverCfg), ResourceHelper.Get(StringKey.SaveError), MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                SetStatusMessage(ResourceHelper.Get(StringKey.UnknownErrorWhileSaving));
            }
        }
Esempio n. 8
0
        public void Init(string cfgSpec, string cfgFile)
        {
            _file = cfgFile;

            try
            {
                _spec = Util.Deserialize <Iros._7th.Workshop.ConfigSettings.ConfigSpec>(cfgSpec);
            }
            catch (Exception e)
            {
                Logger.Error(e);
                MessageDialogWindow.Show("Failed to read the required spec xml file to display settings. The window mus close.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                this.Close();
                return;
            }

            if (!File.Exists(_file))
            {
                // copy default .cfg file if missing
                File.Copy(Path.Combine(Sys.PathToGameDriverFolder, "7H_GameDriver.cfg"), _file, true);
            }

            _settings = new Iros._7th.Workshop.ConfigSettings.Settings(File.ReadAllLines(_file));
            _settings.SetMissingDefaults(_spec.Settings);

            Dictionary <string, int> tabOrders = new Dictionary <string, int>()
            {
                { "Graphics", 0 },
                { "Rendering", 1 },
                { "Advanced", 3 }
            };

            foreach (var items in _spec.Settings.GroupBy(s => s.Group)
                     .Select(g => new { settingGroup = g, SortOrder = tabOrders[g.Key] })
                     .OrderBy(g => g.SortOrder)
                     .Select(g => g.settingGroup))
            {
                TabItem tab = new TabItem()
                {
                    Header = items.Key,
                };

                StackPanel stackPanel = new StackPanel()
                {
                    Margin = new Thickness(0, 5, 0, 0)
                };

                ScrollViewer scrollViewer = new ScrollViewer()
                {
                    VerticalScrollBarVisibility = ScrollBarVisibility.Auto
                };

                foreach (Iros._7th.Workshop.ConfigSettings.Setting setting in items)
                {
                    GLSettingViewModel settingViewModel = new GLSettingViewModel(setting, _settings);

                    ContentControl settingControl = new ContentControl();
                    settingControl.DataContext = settingViewModel;
                    settingControl.MouseEnter += SettingControl_MouseEnter;

                    ViewModels.Add(settingViewModel);
                    stackPanel.Children.Add(settingControl);
                }

                if (items.Key == "Advanced")
                {
                    // add clear texture cache button
                    btnClearTextureCache = new Button()
                    {
                        Content             = "Clear Texture Cache",
                        ToolTip             = $"Will delete everything under {Path.Combine(Sys.Settings.AaliFolder, "cache")}",
                        HorizontalAlignment = HorizontalAlignment.Left,
                        VerticalAlignment   = VerticalAlignment.Top,
                        Margin = new Thickness(5, 0, 0, 0)
                    };
                    btnClearTextureCache.Click += BtnClearTextureCache_Click;

                    stackPanel.Children.Add(btnClearTextureCache);
                }


                scrollViewer.Content = stackPanel;
                tab.Content          = scrollViewer;
                tabCtrlMain.Items.Add(tab);
            }
        }
Esempio n. 9
0
        public bool Init(string cfgSpec, string cfgFile)
        {
            _file = cfgFile;

            try
            {
                _spec = Util.Deserialize <Iros._7th.Workshop.ConfigSettings.ConfigSpec>(cfgSpec);
            }
            catch (Exception e)
            {
                Logger.Error(e);
                MessageDialogWindow.Show(ResourceHelper.Get(StringKey.FailedToReadRequiredSpecXmlFile), ResourceHelper.Get(StringKey.Error), MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }

            if (!File.Exists(_file))
            {
                // copy default .cfg file if missing
                File.Copy(Path.Combine(Sys.PathToGameDriverFolder, "FFNx.cfg"), _file, true);
            }

            _settings = new Iros._7th.Workshop.ConfigSettings.Settings(File.ReadAllLines(_file));
            _settings.SetMissingDefaults(_spec.Settings);

            Dictionary <string, int> tabOrders = new Dictionary <string, int>()
            {
                { ResourceHelper.Get(StringKey.Graphics), 0 },
                { ResourceHelper.Get(StringKey.Cheats), 1 },
                { ResourceHelper.Get(StringKey.Advanced), 2 }
            };

            foreach (var items in _spec.Settings.GroupBy(s => s.Group)
                     .Select(g => new { settingGroup = g, SortOrder = tabOrders[g.Key] })
                     .OrderBy(g => g.SortOrder)
                     .Select(g => g.settingGroup))
            {
                TabItem tab = new TabItem()
                {
                    Header = items.Key,
                };

                StackPanel stackPanel = new StackPanel()
                {
                    Margin = new Thickness(0, 5, 0, 0)
                };

                ScrollViewer scrollViewer = new ScrollViewer()
                {
                    VerticalScrollBarVisibility = ScrollBarVisibility.Auto
                };

                foreach (Iros._7th.Workshop.ConfigSettings.Setting setting in items)
                {
                    GLSettingViewModel settingViewModel = new GLSettingViewModel(setting, _settings);

                    ContentControl settingControl = new ContentControl();
                    settingControl.DataContext = settingViewModel;
                    settingControl.MouseEnter += SettingControl_MouseEnter;

                    ViewModels.Add(settingViewModel);
                    stackPanel.Children.Add(settingControl);
                }

                if (items.Key == ResourceHelper.Get(StringKey.Advanced))
                {
                    // add clear texture cache button
                    btnClearTextureCache = new Button()
                    {
                        Content             = ResourceHelper.Get(StringKey.ClearTextureCache),
                        ToolTip             = $"{ResourceHelper.Get(StringKey.WillDeleteEverythingUnder)} {Path.Combine(Sys.Settings.AaliFolder, "cache")}",
                        HorizontalAlignment = HorizontalAlignment.Left,
                        VerticalAlignment   = VerticalAlignment.Top,
                        Margin = new Thickness(5, 0, 0, 0)
                    };
                    btnClearTextureCache.Click += BtnClearTextureCache_Click;

                    stackPanel.Children.Add(btnClearTextureCache);
                }


                scrollViewer.Content = stackPanel;
                tab.Content          = scrollViewer;
                tabCtrlMain.Items.Add(tab);
            }

            return(true);
        }
Esempio n. 10
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 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;
            }
        }