diff --git a/src/MenuLayer.cpp b/src/MenuLayer.cpp index 64f28f0..2ba9e48 100644 --- a/src/MenuLayer.cpp +++ b/src/MenuLayer.cpp @@ -125,7 +125,7 @@ class $modify(MenuLayerMLHook, MenuLayer) { if (!useCustomSongs) toWriteToFile = toWriteToFile.append(fmt::format(" # Song: {} by {}", songName, songArtist)); auto test = utils::file::readString(m_fields->blacklistFile); if (test.isErr()) return log::info("error reading blacklist file!"); - auto result = geode::utils::file::writeString(m_fields->blacklistFile, test.unwrap().append(fmt::format("{}", toWriteToFile))); + auto result = geode::utils::file::writeString(m_fields->blacklistFile, test.unwrap().append(fmt::format("{}\n", toWriteToFile))); if (result.isErr()) return log::info("error blacklisting song {}", currentSong); m_fields->songManager.clearSongs(); Utils::populateVector(useCustomSongs); diff --git a/src/SongManager.cpp b/src/SongManager.cpp index 78f2ffd..f4d75e1 100644 --- a/src/SongManager.cpp +++ b/src/SongManager.cpp @@ -71,3 +71,11 @@ void SongManager::setCalledOnce(bool value) { bool SongManager::getCalledOnce() { return m_calledOnce; } + +void SongManager::addToBlacklist(std::string song = SongManager::get().getCurrentSong()) { + m_blacklist.push_back(song); +} + +std::vector SongManager::getBlacklist() { + return m_blacklist; +} \ No newline at end of file diff --git a/src/SongManager.hpp b/src/SongManager.hpp index 29343d8..2a96815 100644 --- a/src/SongManager.hpp +++ b/src/SongManager.hpp @@ -18,6 +18,8 @@ class SongManager { void update(float); bool getCalledOnce(); void setCalledOnce(bool); + void addToBlacklist(std::string); + std::vector getBlacklist(); private: SongManager(); @@ -26,4 +28,5 @@ class SongManager { std::string m_currentSong; bool m_isMenuLoop; bool m_calledOnce = false; + std::vector m_blacklist; }; diff --git a/src/Utils.cpp b/src/Utils.cpp index ba4d6f1..5dfba1f 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -217,12 +217,13 @@ void Utils::populateVector(bool customSongs) { */ std::vector blacklist {}; + std::vector otherBlacklist = SongManager::get().getBlacklist(); if (auto blacklistPath = std::filesystem::exists(configDir / R"(blacklist.txt)")) { std::ifstream blacklistFile((configDir / R"(blacklist.txt)")); std::string blacklistString; while (std::getline(blacklistFile, blacklistString)) { - if (blacklistString.starts_with('#')) continue; + if (blacklistString.starts_with('#') || blacklistString.empty()) continue; blacklist.push_back(blacklistString); geode::log::info("{}", blacklistString); } @@ -236,7 +237,7 @@ void Utils::populateVector(bool customSongs) { const auto& filePath = file.path(); auto filePathString = filePath.string(); - if (!Utils::isSupportedExtension(filePathString) || std::ranges::find(blacklist, filePathString) != blacklist.end() || std::ranges::find(blacklist, filePath.filename().string()) != blacklist.end()) continue; + if (!Utils::isSupportedExtension(filePathString) || std::ranges::find(blacklist, filePathString) != blacklist.end() || std::ranges::find(otherBlacklist, filePathString) != otherBlacklist.end()) continue; geode::log::debug("Adding custom song: {}", filePath.filename().string()); SongManager::get().addSong(filePathString); @@ -261,7 +262,7 @@ void Utils::populateVector(bool customSongs) { std::string songPath = downloadManager->pathForSong(song->m_songID); - if (!Utils::isSupportedExtension(songPath) || std::ranges::find(blacklist, songPath) != blacklist.end()) continue; + if (!Utils::isSupportedExtension(songPath) || std::ranges::find(blacklist, songPath) != blacklist.end() || std::ranges::find(otherBlacklist, songPath) != otherBlacklist.end()) continue; geode::log::debug("Adding Newgrounds/Music Library song: {}", songPath); SongManager::get().addSong(songPath);