From 8b8039e8b9a3d57c3238a3e3c7b56c769ff18d1d Mon Sep 17 00:00:00 2001 From: Sera <62521228+SeraUX@users.noreply.github.com> Date: Sat, 4 Jul 2020 00:57:03 +0200 Subject: [PATCH] SettingsWindow: Add the ability to add multiple game directories at once (#1314) * SettingsWindow: Add the ability to choose multiple game directories in one go * Adressed emmauss's suggestion * Simplified the check for duplicate game directories As per Xpl0itr's and emmauss's suggestion, I simplified the loop that checks if the selected game directories are already added. * Fixed a nit --- Ryujinx/Ui/SettingsWindow.cs | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/Ryujinx/Ui/SettingsWindow.cs b/Ryujinx/Ui/SettingsWindow.cs index 42764a7da..6e681fffc 100644 --- a/Ryujinx/Ui/SettingsWindow.cs +++ b/Ryujinx/Ui/SettingsWindow.cs @@ -289,11 +289,34 @@ namespace Ryujinx.Ui } else { - FileChooserDialog fileChooser = new FileChooserDialog("Choose the game directory to add to the list", this, FileChooserAction.SelectFolder, "Cancel", ResponseType.Cancel, "Add", ResponseType.Accept); + FileChooserDialog fileChooser = new FileChooserDialog("Choose the game directory to add to the list", this, FileChooserAction.SelectFolder, "Cancel", ResponseType.Cancel, "Add", ResponseType.Accept) + { + SelectMultiple = true + }; if (fileChooser.Run() == (int)ResponseType.Accept) { - _gameDirsBoxStore.AppendValues(fileChooser.Filename); + foreach (string directory in fileChooser.Filenames) + { + bool directoryAdded = false; + + if (_gameDirsBoxStore.GetIterFirst(out TreeIter treeIter)) + { + do + { + if (directory.Equals((string)_gameDirsBoxStore.GetValue(treeIter, 0))) + { + directoryAdded = true; + break; + } + } while(_gameDirsBoxStore.IterNext(ref treeIter)); + } + + if (!directoryAdded) + { + _gameDirsBoxStore.AppendValues(directory); + } + } } fileChooser.Dispose(); @@ -413,4 +436,4 @@ namespace Ryujinx.Ui Dispose(); } } -} \ No newline at end of file +}