Archived
1
0
Fork 0
forked from Mirror/Ryujinx

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
This commit is contained in:
Sera 2020-07-04 00:57:03 +02:00 committed by GitHub
parent 5644780e6e
commit 8b8039e8b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -289,11 +289,34 @@ namespace Ryujinx.Ui
} }
else 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) 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(); fileChooser.Dispose();
@ -413,4 +436,4 @@ namespace Ryujinx.Ui
Dispose(); Dispose();
} }
} }
} }