Skip to content

Commit

Permalink
ughhHHh
Browse files Browse the repository at this point in the history
Signed-off-by: Erymanthus[#5074] | (u/)RayDeeUx <[email protected]>
  • Loading branch information
RayDeeUx committed Aug 15, 2024
1 parent f190f14 commit 8204944
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 58 deletions.
38 changes: 0 additions & 38 deletions src/CCDirector.cpp

This file was deleted.

7 changes: 3 additions & 4 deletions src/MenuLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ class $modify(MenuLoopMLHook, MenuLayer) {
if (!MenuLayer::init())
return false;

if (auto card = getChildByIDRecursive("now-playing"_spr))
card->removeMeAndCleanup();
Utils::removeCard();

if (Utils::getBool("enableNotification"))
MenuLoopMLHook::generateNotifcation();
Expand All @@ -31,7 +30,7 @@ class $modify(MenuLoopMLHook, MenuLayer) {

std::string notifString;
auto prefix = Mod::get()->getSettingValue<std::string>("customPrefix");
if (!prefix.empty())
if (!prefix.empty() || prefix != "[Empty]")
notifString = fmt::format("{}: ", prefix);

if (Utils::getBool("useCustomSongs")) {
Expand Down Expand Up @@ -101,7 +100,7 @@ class $modify(MenuLoopMLHook, MenuLayer) {
}

void onShuffleBtn(CCObject *sender) {
Utils::removeCurrentNotif();
Utils::removeCard();

Utils::setNewSong();

Expand Down
16 changes: 7 additions & 9 deletions src/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,13 @@ bool Utils::getBool(std::string setting) {
return geode::Mod::get()->getSettingValue<bool>(setting);
}

void Utils::removeCurrentNotif() {
if (auto card = cocos2d::CCDirector::get()->getRunningScene()->getChildByIDRecursive("now-playing"_spr)) {
cocos2d::CCAction* fadeOutSequence = cocos2d::CCSequence::create(
cocos2d::CCFadeOut::create(geode::Mod::get()->getSettingValue<double>("notificationTime") / 2),
cocos2d::CCDelayTime::create(.125f),
cocos2d::CCCallFunc::create(card, callfunc_selector(Utils::removeCard)),
nullptr
);
card->runAction(fadeOutSequence);
void Utils::keepCardAcrossScenes() {
if (const auto gm = GameManager::get()) {
if (const auto menuLayer = gm->m_menuLayer) {
if (const auto card = menuLayer->getChildByIDRecursive("now-playing"_spr)) {
geode::SceneManager::get()->keepAcrossScenes(card);
}
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Utils {
static int stoi(std::string);
static bool isSupportedExtension(std::string);
static bool getBool(std::string);
static void removeCurrentNotif();
static cocos2d::SEL_CallFunc removeCard();
static void keepCardAcrossScenes();
static void removeCard();
static void setNewSong();
};
20 changes: 15 additions & 5 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "SongManager.hpp"
#include "Utils.hpp"
#include <Geode/loader/SettingEvent.hpp>
#include <Geode/loader/Dirs.hpp>

using namespace geode::prelude;

Expand All @@ -12,6 +11,7 @@ void populateVector(bool customSongs) {
/*
if custom songs are enabled search for files in the config dir
if not, just use the newgrounds songs
--elnex
*/
if (customSongs) {
for (auto file : std::filesystem::directory_iterator(configDir)) {
Expand All @@ -28,10 +28,16 @@ void populateVector(bool customSongs) {
} else {
auto downloadManager = MusicDownloadManager::sharedState();

// for every downloaded song push it to the m_songs vector
// for every downloaded song push it to the m_songs vector --elnex
/*
getDownloadedSongs() function call binding for macOS found
from ninXout (ARM) and hiimjustin000 (Intel + verification)
remarks:
- getDownloadedSongs() grabs both music library and newgrounds
songs lol.
- only reason it didn't work was because file support was limited to `.mp3`.
--raydeeux
*/
CCArrayExt<SongInfoObject *> songs = downloadManager->getDownloadedSongs();
for (auto song : songs) {
Expand All @@ -41,10 +47,12 @@ void populateVector(bool customSongs) {

if (!Utils::isSupportedExtension(songPath)) continue;

log::debug("Adding Newgrounds song: {}", songPath);
log::debug("Adding Newgrounds/Music Library song: {}", songPath);
songManager.addSong(songPath);
}
// same thing as NG but for music library as well --ninXout
// SPOILER: IT DOESN'T WORK CROSSPLATFORM (android specifically)! --raydeeux
/*
std::filesystem::path musicLibrarySongs = dirs::getGeodeDir().parent_path() / "Resources" / "songs";
if (!std::filesystem::exists(musicLibrarySongs)) return;
for (const std::filesystem::path& dirEntry : std::filesystem::recursive_directory_iterator(musicLibrarySongs)) {
Expand All @@ -57,6 +65,7 @@ void populateVector(bool customSongs) {
log::debug("Adding Music Library song: {}", songPath);
songManager.addSong(songPath);
}
*/
}
}

Expand All @@ -72,16 +81,17 @@ void populateVector(bool customSongs) {

$execute {
listenForSettingChanges<bool>("useCustomSongs", [](bool value) {
// make sure m_songs is empty, we don't want to make a mess here
// make sure m_songs is empty, we don't want to make a mess here --elnexreal
songManager.clearSongs();

/*
for every custom song file, push its path to m_songs
if they're ng songs also push the path bc we're going to use getPathForSong
--elnexreal
*/
populateVector(value);

// change the song when you click apply, stoi will not like custom names.
// change the song when you click apply, stoi will not like custom names. --elnexreal

Utils::setNewSong();
});
Expand Down

0 comments on commit 8204944

Please sign in to comment.