Skip to content

Commit

Permalink
bugs?
Browse files Browse the repository at this point in the history
  • Loading branch information
RayDeeUx committed Sep 28, 2024
1 parent dd6e86b commit cbb1da2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/MenuLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ 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, fmt::format("{}\n{}", test.unwrap(), 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);
if (!useCustomSongs) Utils::makeNewCard(fmt::format("Blacklisted {} by {} ({})!", songName, songArtist, songID));
else Utils::makeNewCard(fmt::format("Blacklisted {})!", currentSong));
else Utils::makeNewCard(fmt::format("Blacklisted {})!", Utils::currentCustomSong()));
m_fields->songManager.clearSongs();
Utils::populateVector(useCustomSongs);
if (!Utils::getBool("playlistMode")) Utils::setNewSong();
Expand Down
12 changes: 9 additions & 3 deletions src/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,17 +226,17 @@ void Utils::populateVector(bool customSongs) {
blacklist.push_back(blacklistString);
geode::log::info("{}", blacklistString);
}
geode::log::info("Finished storing oldDNBMessages.");
geode::log::info("Finished storing blacklist. size: {}", blacklist.size());
}

if (customSongs) {
for (auto file : std::filesystem::directory_iterator(configDir)) {
if (!std::filesystem::exists(file)) continue;

auto filePath = file.path();
const auto& filePath = file.path();
auto filePathString = filePath.string();

if (!Utils::isSupportedExtension(filePathString) || std::ranges::find(blacklist, filePathString) != blacklist.end()) continue;
if (!Utils::isSupportedExtension(filePathString) || std::ranges::find(blacklist, filePathString) != blacklist.end() || std::ranges::find(blacklist, filePath.filename().string()) != blacklist.end()) continue;

geode::log::debug("Adding custom song: {}", filePath.filename().string());
SongManager::get().addSong(filePathString);
Expand Down Expand Up @@ -321,4 +321,10 @@ int Utils::getSongID() {
const auto songInfo = Utils::getSongInfoObject();
if (!songInfo) return -1;
return songInfo->m_songID;
}

std::string Utils::currentCustomSong() {
if (!Utils::getBool("useCustomSongs")) return Utils::getSongName();
if (SongManager::get().isOriginalMenuLoop()) return "";
return std::filesystem::path(SongManager::get().getCurrentSong()).filename().string();
}
1 change: 1 addition & 0 deletions src/Utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ class Utils {
static std::string getSongName();
static std::string getSongArtist();
static int getSongID();
static std::string currentCustomSong();
};

0 comments on commit cbb1da2

Please sign in to comment.