From 49538b6e2d6a8dcfcede4c0ca408eceb8bb941af Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Sat, 15 Apr 2023 20:02:59 +0300 Subject: [PATCH] Handle case of user selecting "Data" folder of H3 install After all, we do ask user to select location of Heroes III data... --- launcher/firstLaunch/firstlaunch_moc.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/launcher/firstLaunch/firstlaunch_moc.cpp b/launcher/firstLaunch/firstlaunch_moc.cpp index 52aebfe1b..4f371cc54 100644 --- a/launcher/firstLaunch/firstlaunch_moc.cpp +++ b/launcher/firstLaunch/firstlaunch_moc.cpp @@ -264,6 +264,18 @@ void FirstLaunchView::copyHeroesData() if(!sourceRoot.exists()) return; + if (sourceRoot.dirName().compare("data", Qt::CaseInsensitive) == 0) + { + // We got Data folder. Possibly user selected "Data" folder of Heroes III install. Check whether valid data might exist 1 level above + + QStringList dirData = sourceRoot.entryList({"data"}, QDir::Filter::Dirs); + if (dirData.empty()) + { + // This is "Data" folder without any "Data" folders inside. Try to check for data 1 level above + sourceRoot.cdUp(); + } + } + QStringList dirData = sourceRoot.entryList({"data"}, QDir::Filter::Dirs); QStringList dirMaps = sourceRoot.entryList({"maps"}, QDir::Filter::Dirs); QStringList dirMp3 = sourceRoot.entryList({"mp3"}, QDir::Filter::Dirs);