From 9340eb92f4b024f1d51d672e3ec4f6d5d2d53e02 Mon Sep 17 00:00:00 2001 From: mrbesen Date: Mon, 14 Jun 2021 11:46:13 +0200 Subject: [PATCH] filter beatsaber maps by name --- include/beatsaber/beatsaber.h | 2 +- src/beatsaber.cpp | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/beatsaber/beatsaber.h b/include/beatsaber/beatsaber.h index 50960e0..29dd63f 100644 --- a/include/beatsaber/beatsaber.h +++ b/include/beatsaber/beatsaber.h @@ -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> loadMapsfromInstallation(std::string gamePath = ""); +std::list> loadMapsfromInstallation(const std::string& filter = "", std::string gamePath = ""); } \ No newline at end of file diff --git a/src/beatsaber.cpp b/src/beatsaber.cpp index 19044ef..f28c937 100644 --- a/src/beatsaber.cpp +++ b/src/beatsaber.cpp @@ -74,7 +74,7 @@ std::string findBeatsaberInstallation() { return ""; //not found } -std::list> loadMapsfromInstallation(std::string gamePath) { +std::list> loadMapsfromInstallation(const std::string& filter, std::string gamePath) { if(gamePath.empty()) { gamePath = findBeatsaberInstallation(); } @@ -85,6 +85,10 @@ std::list> 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());