Example #1
0
        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);
                    }
                }
            }
        }