private void createButton_Click(object sender, RoutedEventArgs e) { FolderBrowser2 directoryFolderBrowser = new FolderBrowser2(); directoryFolderBrowser.ShowDialog(null); if (directoryFolderBrowser.DirectoryPath != null) { enableUI(); currentDirectory = directoryFolderBrowser.DirectoryPath; presetName = System.IO.Path.GetFileName(directoryFolderBrowser.DirectoryPath); presetBox.Text = presetName; DirectoryInfo customDir = new DirectoryInfo(currentDirectory); FileInfo[] files = customDir.GetFiles() .Where(f => Constants.SupportedFileTypes.Contains(f.Extension.ToLower())) .ToArray(); orderFilenamesForListView(files, customTracksList); /*foreach (var customMusicFile in Directory.GetFiles(currentDirectory, "*.*", SearchOption.TopDirectoryOnly).Where(s => s.EndsWith(".ogg") || s.EndsWith(".wav") || s.EndsWith(".mp3"))) * { * ListViewItem thisItem = new ListViewItem(); * thisItem.Content = System.IO.Path.GetFileName(customMusicFile); * thisItem.Tag = System.IO.Path.GetFullPath(customMusicFile); * customTracksList.Items.Add(thisItem); * }*/ } }
//We use the loadButton_Click event to open a new folder browser to allow the user to load a save and set up the UI for the loaded save private void loadButton_Click(object sender, RoutedEventArgs e) { FolderBrowser2 directoryFolderBrowser = new FolderBrowser2(); directoryFolderBrowser.ShowDialog(null); if (File.Exists(directoryFolderBrowser.DirectoryPath + "//file0")) { SAVE.SAVEFile saveFile = SAVE.SAVEFile.LoadSaveFile(directoryFolderBrowser.DirectoryPath); loadSAVE(saveFile); thisINI = INI.ReadINI(saveFile); loadINI(); Routes.GameRoutes closestRoute = SAVE.SAVEFile.GetClosestRoute(saveFile); if (closestRoute == Routes.GameRoutes.Genocide) { genocideRadio.IsChecked = true; } else if (closestRoute >= Routes.GameRoutes.TruePacifistDate) { pacifistRadio.IsChecked = true; routeCombo.SelectedItem = Routes.GetEnumDescription(SAVE.SAVEFile.GetClosestRoute(thisSave)); } else { neutralRadio.IsChecked = true; routeCombo.SelectedItem = Routes.GetEnumDescription(SAVE.SAVEFile.GetClosestRoute(thisSave)); } MXA2SE.play_sound(soundEngine, "Assets//Sounds//fileLoaded.wav"); } else { Dictionary <Characters, string> messageDict = new Dictionary <Characters, string>() { { Characters.Alphys, "S-s-sorry, that folder doesn't contain a valid Undertale save file." }, { Characters.Asgore, "Human, I'm sorry, but folder doesn't contain a valid Undertale save file." }, { Characters.Asriel, "I'm really sorry, I tried, but couldn't find a valid Undertale save file in that folder." }, { Characters.Flowey, "YOU. IDIOT! That folder doesn't contain a valid Undertale save file!" }, { Characters.Papyrus, "NYOO HOO HOO. I, THE GREAT PAPYRUS, HAVE FAILED TO FIND A VALID SAVE FILE IN THAT FOLDER." }, { Characters.Sans, "heyo, pal. try again. i couldn't find an Undertale save file in that folder." }, { Characters.Toriel, "My child, I am sorry, but I was unable to find a valid Undertale save file in that folder." }, { Characters.Undyne, "HEY, PUNK! I CAN'T FIND AN UNDERTALE SAVE FILE IN THAT FOLDER!" }, { Characters.None, "The folder specified does not contain a valid Undertale save file!" } }; UTMessageBox.Show(messageDict, Constants.CharacterReactions.Negative, MessageBoxButton.OK); } }
private void newButton_Click(object sender, RoutedEventArgs e) { FolderBrowser2 directoryFolderBrowser = new FolderBrowser2(); directoryFolderBrowser.ShowDialog(null); if (directoryFolderBrowser.DirectoryPath != null) { ResetUI(); presetNameBox.Text = "New Preset"; musicPreset = new MusicPreset(directoryFolderBrowser.DirectoryPath); musicPreset.presetName = presetNameBox.Text; PopulateCustomTracks(directoryFolderBrowser.DirectoryPath); saveButton.IsEnabled = true; } }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { FolderBrowser2 browser = new FolderBrowser2(); if (value != null) { browser.DirectoryPath = string.Format("{0}", value); } if (browser.ShowDialog(null) == DialogResult.OK) { return(browser.DirectoryPath); } return(value); }
//loadPreset loads -- -_- public void loadPreset() { currentDirectory = ""; presetName = ""; FolderBrowser2 directoryFolderBrowser = new FolderBrowser2(); directoryFolderBrowser.ShowDialog(null); if (directoryFolderBrowser.DirectoryPath != null) { currentDirectory = directoryFolderBrowser.DirectoryPath; //If we've gone in 1 folder too deep past preset.xml (so either the Named or Original folder) if (System.IO.Path.GetFileName(currentDirectory) == "Named" || System.IO.Path.GetFileName(currentDirectory) == "Original") { currentDirectory = System.IO.Path.GetFullPath(System.IO.Path.Combine(currentDirectory, @"..\")); //Take Named/Original off currentDirectory } if (!File.Exists(currentDirectory + "\\preset.xml")) { MessageBox.Show("Invalid folder - preset.xml not found! Please ensure your selected folder contains a valid preset!", "Error!", MessageBoxButton.OK, MessageBoxImage.Error); } else { enableUI(); string presetName = getCustomFilesForPreset(); presetBox.Text = presetName; tagForThisPreset(presetName); } currentDirectory += "//Original//"; } else { MessageBox.Show("Please ensure you select a folder!", "Error!", MessageBoxButton.OK, MessageBoxImage.Error); } }
//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); } }