//browseButton_Click event allows the user to browse for an designate a new Undertale install directory private async void browseButton_Click(object sender, RoutedEventArgs e) { FolderBrowser2 directoryFolderBrowser = new FolderBrowser2(); directoryFolderBrowser.ShowDialog((System.Windows.Forms.IWin32Window) this.Owner); if (File.Exists(directoryFolderBrowser.DirectoryPath + "//UNDERTALE.exe")) { WaitingWindow waitWindow = new WaitingWindow("Backing Up", "Backing up game files, please wait. This may take some time."); waitWindow.Owner = this; Hide(); waitWindow.Show(); await Task.Run(() => FileOperations.backupFilesFromGameDirectory(directoryFolderBrowser.DirectoryPath)); waitWindow.Close(); Show(); browseButton.IsEnabled = false; saveEditorButton.IsEnabled = true; musicEditorButton.IsEnabled = true; optionsButton.IsEnabled = true; savesCombo.IsEnabled = true; presetsCombo.IsEnabled = true; debugCheck.IsEnabled = true; launchButton.IsEnabled = true; populateSavesCombo(); populatePresetsCombo(); try { string gameVersion = FileVersionInfo.GetVersionInfo(directoryFolderBrowser.DirectoryPath + "//UNDERTALE.exe").ProductVersion; gameVersion = gameVersion.Replace(" ", String.Empty); //Remove any spaces at the end of the version XML.WriteGamePath(directoryFolderBrowser.DirectoryPath); directoryBlock.Text = "Path: " + XML.GetGamePath(); directoryBlock.ToolTip = XML.GetGamePath(); if (FileOperations.disableDogcheck(gameVersion, directoryFolderBrowser.DirectoryPath + "//data.win")) //We disable dogcheck at the game directory { versionBlock.Text = "Game Version: " + gameVersion + ", Dog Check DISABLED."; } else { this.Close(); } } catch (Exception ex) { MessageBox.Show("Unable to verify game version. This could indicate the Undertale.exe file is invalid or corrupt. Please try again and ensure the selected directory is correct. If the issue persists, please redownload the game. The exception is: " + ex, "Invalid Game Version!", MessageBoxButton.OK, MessageBoxImage.Error); } } else if (directoryFolderBrowser.DirectoryPath != null) { Dictionary <Characters, string> messageDict = new Dictionary <Characters, string>() { { Characters.Alphys, "I'm real s-s-sorry, but I c-c-couldn't find the Undertale.exe in that folder." }, { Characters.Asgore, "I'm greatly sorry human, but I was unable to find the Undertale.exe in that folder." }, { Characters.Asriel, "I'm so sorry, but I can't find the Undertale.exe in that folder." }, { Characters.Flowey, "YOU. IDIOT. I can't find the Undertale.exe in that folder!" }, { Characters.Papyrus, "NYOO HOO HOO. I AM SORRY, BUT I'VE FAILED TO FIND THE UNDERTALE.EXE IN THAT FOLDER." }, { Characters.Sans, "c'mon pal, help me out here. i can't find the undertale.exe in that folder." }, { Characters.Toriel, "I'm afraid that I was unable to locate the Undertale.exe in that folder, my child." }, { Characters.Undyne, "HEY, COME ON PUNK! I can't find the Undertale.exe in that folder." }, { Characters.None, "Cannot locate Undertale.exe in the folder specified. Please navigate to a valid Undertale installation folder." } }; UTMessageBox.Show(messageDict, Constants.CharacterReactions.Negative, MessageBoxButton.OK); } }
private async void saveButton_Click(object sender, RoutedEventArgs e) { bool shouldWrite = false; musicPreset.presetName = presetNameBox.Text; if (!Directory.Exists(Constants.PresetsPath + musicPreset.presetName)) { Directory.CreateDirectory(Constants.PresetsPath + musicPreset.presetName + "\\Original"); Directory.CreateDirectory(Constants.PresetsPath + musicPreset.presetName + "\\Named"); shouldWrite = true; } else { Dictionary <Characters, string> messageDict = new Dictionary <Characters, string>() { { Characters.Alphys, "Hey! So, preset \"" + musicPreset.presetName + "\" already exists. Would you like me to overwrite it?" }, { Characters.Asgore, "Well human, the preset \"" + musicPreset.presetName + "\" already exists. Shall I overwrite it?" }, { Characters.Asriel, "Sorry, but the preset \"" + musicPreset.presetName + "\" already exists. Do you want me to overwrite it? It's no trouble, really!" }, { Characters.Flowey, "YOU. IDIOT! The preset \"" + musicPreset.presetName + "\" already exists. Of course, I've got to do all the work - do you want me to overwrite it?" }, { Characters.Papyrus, "NYEH, SORRY HUMAN. THE PRESET \"" + musicPreset.presetName + "\" ALREADY EXISTS. WOULD YOU LIKE ME TO ASSIST YOU AND OVERWRITE IT?" }, { Characters.Sans, "yo, buddy. the preset \"" + musicPreset.presetName + "\" already exists. i'm normally quite lazy, but i'll make an exception this time. want me to overwrite it?" }, { Characters.Toriel, "My child, I apologize, but the preset \"" + musicPreset.presetName + "\" already exists. Would you like me to overwrite it for you?" }, { Characters.Undyne, "OH COME ON. The preset \"" + musicPreset.presetName + "\" already exists. Want me to overwrite it?" }, { Characters.None, "Preset \"" + musicPreset.presetName + "\" already exists! Do you want to overwrite?" } }; MessageBoxResult res = UTMessageBox.Show(messageDict, Constants.CharacterReactions.Negative, MessageBoxButton.YesNo); if (res == MessageBoxResult.Yes) { shouldWrite = true; } } if (shouldWrite) { string[] gameTracks = new string[Constants.GameTracksCount]; string[] customTracks = new string[Constants.GameTracksCount]; for (int i = 0; i < Constants.GameTracksCount; i++) { ListViewItem thisGameItem = (ListViewItem)gameTracksList.Items[i]; gameTracks[i] = IDs.GameTracks.GetTrackFilename(thisGameItem.ToolTip.ToString()); if (thisGameItem.Tag.ToString() == "-1") { customTracks[i] = "Default"; } else { ListViewItem thisCustomItem = (ListViewItem)customTracksList.Items[Convert.ToInt16(thisGameItem.Tag)]; //We set the custom game track to the content of the item in customTracksList at the index present in the game track's tag customTracks[i] = thisCustomItem.ToolTip.ToString(); } } WaitingWindow waitWindow = new WaitingWindow("Converting Audio", "Converting audio for preset, please wait.This may take some time."); waitWindow.Owner = this; waitWindow.Show(); await Task.Run(() => musicPreset.Write(gameTracks, customTracks)); waitWindow.Close(); ((MainWindow)this.Owner).populatePresetsCombo(); Dictionary <Characters, string> messageDict = new Dictionary <Characters, string>() { { Characters.Alphys, "Alright, sure! The \"" + musicPreset.presetName + "\" preset has been saved successfully!" }, { Characters.Asgore, "Of course human! I've made the \"" + musicPreset.presetName + "\" preset successfully!" }, { Characters.Asriel, "No problem, glad to help! I've made the \"" + musicPreset.presetName + "\" preset successfully" }, { Characters.Flowey, "Fine. I've made the stupid \"" + musicPreset.presetName + "\" preset successfully. Now go find something better to do." }, { Characters.Papyrus, "OF COURSE FRIEND, I'VE CREATED THE \"" + musicPreset.presetName + "\" PRESET SUCCESSFULLY. NYEH HEH HEH!" }, { Characters.Sans, "sure thing kiddo. the \"" + musicPreset.presetName + "\" preset has been made successfully." }, { Characters.Toriel, "No problem dear. I have created the \"" + musicPreset.presetName + "\" preset for you successfully." }, { Characters.Undyne, "Yeah, sure thing punk! The \"" + musicPreset.presetName + "\" preset has been created successfully! FUHUHUH!" }, { Characters.None, "Preset \"" + musicPreset.presetName + "\" saved successsfully!" } }; UTMessageBox.Show(messageDict, Constants.CharacterReactions.Positive, MessageBoxButton.OK); Close(); } }