private void MetroWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e) { //TODO: Use e.Cancel, asking user if they wanna save changes and all that //Even if the user decides not to save the params, always save the config: PARAMDATA.SaveConfig(); }
private async void MetroWindow_Loaded(object sender, RoutedEventArgs e) { PARAMDATA.LoadConfig(); if (!string.IsNullOrWhiteSpace(PARAMDATA.Config?.InterrootPath) && CheckInterrotDirValid(PARAMDATA.Config?.InterrootPath)) { await PARAMDATA.LoadParamsInOtherThread(SetLoadingMode); } else { if (MessageBox.Show("If you are using non-remastered Dark Souls: Prepare to Die Edition, your installation " + "MUST be unpacked by UnpackDarkSoulsForModding by HotPocketRemix.\n\n" + @"Please navigate to your 'DARKSOULS.exe' or 'DarkSoulsRemastered.exe' file." + "\n\nOnce the inital setup is performed, the path will be saved." + "\nYou may press cancel to continue without selecting the path but the GUI will " + "be blank until you go to 'File -> Select Dark Souls Directory...'", "Initial Setup", MessageBoxButton.OKCancel, MessageBoxImage.Information) == MessageBoxResult.OK) { await BrowseForInterrootDialog(SetLoadingMode); } } MainTabs.Items.Refresh(); //RANDOM_DEBUG_TESTING(); }
private void MenuPatchParamDefs_Click(object sender, RoutedEventArgs e) { if (PARAMDATA.Config.IsRemaster) { MessageBox.Show("This option only works on Dark Souls: Prepare to Die Edition.", "Not Supported", MessageBoxButton.OK, MessageBoxImage.Hand); return; } if (MessageBox.Show("This modification, which works only on PTDE, not the remaster, will replace the Japanese display names of the variables" + " in the ParamDefs with their internal variable names, which are in English. " + "\nThese display names are used in the Dark Souls debug menu's '[PARAM MAN]' submenu. " + "\nNo more blindly adjusting Japanese-named variables." + "\n\nThis would modify the './paramdef/paramdef.paramdefbnd' file only. " + "\nA backup ('./paramdef/paramdef.paramdefbnd.bak') will be created before the modification is made." + "\n\nProceed with modification?", "Apply Modification?", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { if (!File.Exists(PARAMDATA.Config.ParamDefBndPath + ".bak")) { File.Copy(PARAMDATA.Config.ParamDefBndPath, PARAMDATA.Config.ParamDefBndPath + ".bak"); } try { PARAMDATA.ApplyParamDefEnglishPatch(); MessageBox.Show("Modification applied successfully."); } catch (Exception ex) { if (File.Exists(PARAMDATA.Config.ParamDefBndPath + ".bak")) { File.Copy(PARAMDATA.Config.ParamDefBndPath + ".bak", PARAMDATA.Config.ParamDefBndPath, true); MessageBox.Show("An error occurred while modifying the file (shown below). " + "The file has been restored to a backup of its original state." + "\n\n" + ex.Message); } else { DataFile.SaveToFile(PARAMDATA.PARAMDEFBND, PARAMDATA.Config.ParamDefBndPath, null); MessageBox.Show("An error occurred while modifying the file (shown below). " + "The backup of the file's original state could not be retrieved. " + "The file has been replaced with the default vanilla file." + "\n\n" + ex.Message); } } } }
private async Task BrowseForInterrootDialog(Action <bool> setIsLoading) { var browseDialog = new OpenFileDialog() { AddExtension = false, CheckFileExists = true, CheckPathExists = true, Multiselect = false, FileName = "DARKSOULS.exe", Filter = "Executable Files (*.EXE)|*.EXE", ShowReadOnly = false, Title = "Choose your DARKSOULS.exe or DarkSoulsRemastered.exe file...", ValidateNames = true }; if ((browseDialog.ShowDialog() ?? false) == true) { var interrootDir = new FileInfo(browseDialog.FileName).DirectoryName; if (CheckInterrotDirValid(interrootDir)) { PARAMDATA.Config.InterrootPath = interrootDir; PARAMDATA.SaveConfig(); await PARAMDATA.LoadParamsInOtherThread(setIsLoading); } else { var sb = new StringBuilder(); sb.AppendLine(@"Directory of EXE chosen did not include the following directories/files which are required:"); sb.AppendLine(@" - '.\param\DrawParam\'"); sb.AppendLine(@" - '.\param\GameParam\'"); sb.AppendLine(@" - '.\paramdef\'"); if (CheckIfUdsfmIsProbablyNotInstalled(interrootDir)) { sb.AppendLine(); sb.AppendLine(); sb.AppendLine("Warning: This installation does not appear to be unpacked with " + "UnpackDarkSoulsForModding because it meets one or more of the " + "criteria below:"); sb.AppendLine(@" - '.\unpackDS-backup' does not exist."); sb.AppendLine(@" - '.\dvdbnd0.bdt' exists."); sb.AppendLine(@" - '.\dvdbnd1.bdt' exists."); sb.AppendLine(@" - '.\dvdbnd2.bdt' exists."); sb.AppendLine(@" - '.\dvdbnd3.bdt' exists."); sb.AppendLine(@" - '.\dvdbnd0.bhd5' exists."); sb.AppendLine(@" - '.\dvdbnd1.bhd5' exists."); sb.AppendLine(@" - '.\dvdbnd2.bhd5' exists."); sb.AppendLine(@" - '.\dvdbnd3.bhd5' exists."); } MessageBox.Show( sb.ToString(), "Invalid Directory", MessageBoxButton.OK, MessageBoxImage.Error); } } }
private async void MenuRestoreBackups_Click(object sender, RoutedEventArgs e) { await PARAMDATA.RestoreBackupsInOtherThread(SetLoadingMode); }
private async void CmdSave_Executed(object sender, ExecutedRoutedEventArgs e) { await PARAMDATA.SaveInOtherThread(SetSavingMode); }