GUI: When dropping file, use parent directory for detection

The detection was done on the dropped path, so it worked when
dropping a directory, but not a file. Now we can drop a file
and it will run the detection on the parent directory.
This commit is contained in:
Thierry Crozat 2022-06-05 18:54:46 +01:00
parent ad32b8b23e
commit cc29c8efc7

View file

@ -544,7 +544,12 @@ void LauncherDialog::handleKeyUp(Common::KeyState state) {
void LauncherDialog::handleOtherEvent(const Common::Event &evt) {
Dialog::handleOtherEvent(evt);
if (evt.type == Common::EVENT_DROP_FILE) {
doGameDetection(evt.path);
// If the path is a file, take the parent directory for the detection
Common::String path = evt.path;
Common::FSNode node(path);
if (!node.isDirectory())
path = node.getParent().getPath();
doGameDetection(path);
}
}