Skip to content

Commit 62ca05d

Browse files
committed
remove support for adding resource songs
1 parent f32bbc7 commit 62ca05d

File tree

5 files changed

+39
-1
lines changed

5 files changed

+39
-1
lines changed

src/SongControl.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,25 @@ namespace SongControl {
171171
)->show();
172172
}
173173

174+
const std::filesystem::path& songAsPath = Utils::toProblematicString(songManager.getCurrentSong());
175+
if (const geode::Result<int> result = geode::utils::numFromString<int>(geode::utils::string::replace(songAsPath.filename(), songAsPath.extension(), "")); result.isOk()) {
176+
const int songID = result.unwrapOr(-1);
177+
MusicDownloadManager* mdm = MusicDownloadManager::sharedState();
178+
if (SongInfoObject* songInfoObject = mdm->getSongInfoObject(songID); songInfoObject && mdm->isResourceSong(songID)) {
179+
songManager.incrementTowerRepeatCount();
180+
int repeats = songManager.getTowerRepeatCount();
181+
std::string displayString = fmt::format("{} can't be in a playlist!", songInfoObject->m_songName);
182+
if (repeats > 1) displayString += fmt::format(" Touch grass {} times instead.", repeats);
183+
else displayString += "It's a resource song!";
184+
return geode::Notification::create(
185+
displayString,
186+
geode::NotificationIcon::Error, 5.f
187+
)->show();
188+
}
189+
}
190+
191+
songManager.resetTowerRepeatCount();
192+
174193
const std::filesystem::path playlistFilePath = geode::Mod::get()->getSettingValue<std::filesystem::path>("playlistFile");
175194
if (playlistFilePath.string().empty() || playlistFilePath.extension() != ".txt" || !Utils::notFavoritesNorBlacklist(playlistFilePath)) {
176195
return geode::Notification::create(

src/SongManager.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,4 +242,16 @@ void SongManager::setCurrentSongDisplayName(const std::string& displayName) {
242242

243243
std::string SongManager::getCurrentSongDisplayName() {
244244
return m_displayName;
245-
}
245+
}
246+
247+
void SongManager::incrementTowerRepeatCount() {
248+
m_towerRepeatCount = m_towerRepeatCount + 1;
249+
}
250+
251+
void SongManager::resetTowerRepeatCount() {
252+
m_towerRepeatCount = 0;
253+
}
254+
255+
int SongManager::getTowerRepeatCount() const {
256+
return m_towerRepeatCount;
257+
}

src/SongManager.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ class SongManager {
6666
bool songSizeIsBad() const;
6767
void setCurrentSongDisplayName(const std::string& displayName);
6868
std::string getCurrentSongDisplayName();
69+
void incrementTowerRepeatCount();
70+
void resetTowerRepeatCount();
71+
int getTowerRepeatCount() const;
6972

7073
private:
7174
SongManager();
@@ -86,4 +89,5 @@ class SongManager {
8689
bool m_playlistIsEmpty = false;
8790
std::vector<std::string> m_blacklist;
8891
std::vector<std::string> m_favorites;
92+
int m_towerRepeatCount;
8993
};

src/ui/SongControlMenu.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ void SongControlMenu::onSettingsButton(CCObject*) {
199199
}
200200
void SongControlMenu::updateCurrentLabel() {
201201
SongManager& songManager = SongManager::get();
202+
songManager.resetTowerRepeatCount();
202203
const std::string& currentSong = songManager.getCurrentSongDisplayName();
203204
if (!this->m_smallLabel || !this->m_smallLabel->getParent() || this->m_smallLabel->getParent() != this->b) {
204205
this->m_smallLabel = cocos2d::CCLabelBMFont::create(currentSong.c_str(), "chatFont.fnt");

src/ui/SongListLayer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ bool SongListLayer::setup(const std::string&) {
178178
this->m_closeBtn->setID("close-button"_spr);
179179
this->m_buttonMenu->setID("close-menu"_spr);
180180

181+
songManager.resetTowerRepeatCount();
182+
181183
return true;
182184
}
183185

0 commit comments

Comments
 (0)