filter beatsaber maps by name

This commit is contained in:
mrbesen 2021-06-14 11:46:13 +02:00
parent 3bce6bdfd9
commit 9340eb92f4
Signed by: MrBesen
GPG Key ID: 596B2350DCD67504
2 changed files with 6 additions and 2 deletions

View File

@ -12,6 +12,6 @@ std::string findBeatsaberInstallation();
// when gamepath is empty, findBeatsaberInstallation is used to get a Path
// from the installation folder as many mas as possible are loaded
std::list<std::shared_ptr<BeatMap>> loadMapsfromInstallation(std::string gamePath = "");
std::list<std::shared_ptr<BeatMap>> loadMapsfromInstallation(const std::string& filter = "", std::string gamePath = "");
}

View File

@ -74,7 +74,7 @@ std::string findBeatsaberInstallation() {
return ""; //not found
}
std::list<std::shared_ptr<BeatMap>> loadMapsfromInstallation(std::string gamePath) {
std::list<std::shared_ptr<BeatMap>> loadMapsfromInstallation(const std::string& filter, std::string gamePath) {
if(gamePath.empty()) {
gamePath = findBeatsaberInstallation();
}
@ -85,6 +85,10 @@ std::list<std::shared_ptr<BeatMap>> loadMapsfromInstallation(std::string gamePat
for(const auto& i : std::filesystem::directory_iterator(path / "Beat Saber_Data/CustomLevels")) {
if(i.exists()) {
std::string name = i.path().filename();
if(name.find(filter) == std::string::npos) continue;
if(i.is_directory()) {
//try to load
auto map = BeatMap::loadFromFolder(i.path().string());