Skip to content

Commit c98a47e

Browse files
committed
rename methods
1 parent 5c2ffaf commit c98a47e

File tree

9 files changed

+34
-17
lines changed

9 files changed

+34
-17
lines changed

src/EditorPauseLayer.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ class $modify(MenuLoopEPLHook, EditorPauseLayer) {
4545
Utils::removeCardRemotely();
4646

4747
if (Utils::getBool("playlistMode")) {
48-
Utils::playlistModePLAndEPL();
49-
Utils::playlistModeNewSong();
48+
Utils::constantShuffleModePLAndEPL();
49+
Utils::constantShuffleModeNewSong();
5050
}
5151
}
5252
void FLAlert_Clicked(FLAlertLayer* p0, bool btnTwo) {
@@ -94,8 +94,8 @@ class $modify(MenuLoopEPLHook, EditorPauseLayer) {
9494
Utils::removeCardRemotely();
9595

9696
if (Utils::getBool("playlistMode")) {
97-
Utils::playlistModePLAndEPL();
98-
Utils::playlistModeNewSong();
97+
Utils::constantShuffleModePLAndEPL();
98+
Utils::constantShuffleModeNewSong();
9999
}
100100
}
101101
#endif

src/PlayLayer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ class $modify(MenuLoopPLHook, PlayLayer) {
1616
Utils::removeCardRemotely();
1717

1818
if (Utils::getBool("playlistMode")) {
19-
Utils::playlistModePLAndEPL();
20-
Utils::playlistModeNewSong();
19+
Utils::constantShuffleModePLAndEPL();
20+
Utils::constantShuffleModeNewSong();
2121
}
2222
}
2323
};

src/SongControl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ namespace SongControl {
5151
Utils::newCardAndDisplayNameFromCurrentSong();
5252
}
5353
if (!Utils::getBool("playlistMode")) Utils::setNewSong();
54-
else Utils::playlistModeNewSong();
54+
else Utils::constantShuffleModeNewSong();
5555
Utils::newCardAndDisplayNameFromCurrentSong();
5656
}
5757
void favoriteSong(SongManager& songManager) {
@@ -118,7 +118,7 @@ namespace SongControl {
118118
}
119119

120120
if (!Utils::getBool("playlistMode")) Utils::setNewSong();
121-
else Utils::playlistModeNewSong();
121+
else Utils::constantShuffleModeNewSong();
122122

123123
if (!Utils::getBool("enableNotification")) return;
124124

src/SongManager.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,15 @@ bool SongManager::getConstantShuffleMode() const {
8383
return m_constantShuffleMode;
8484
}
8585

86+
void SongManager::setPlaylistFileName() {
87+
m_playlistName = geode::utils::string::replace(Utils::toNormalizedString(geode::Mod::get()->getSettingValue<std::filesystem::path>("playlistFile").filename()), ".txt", "");
88+
}
89+
90+
std::string SongManager::getPlaylistFileName() {
91+
return m_playlistName;
92+
}
93+
94+
8695
void SongManager::update(float dt) const {
8796
// split for readability
8897
if (VANILLA_GD_MENU_LOOP_DISABLED || !m_constantShuffleMode) return;
@@ -97,7 +106,7 @@ void SongManager::update(float dt) const {
97106
#endif
98107
geode::log::info("song is probably finished. Switching songs.");
99108
Utils::removeCard();
100-
Utils::playlistModeNewSong();
109+
Utils::constantShuffleModeNewSong();
101110
Utils::newCardAndDisplayNameFromCurrentSong();
102111
}
103112

src/SongManager.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ class SongManager {
3232
bool isOriginalMenuLoop() const;
3333
void setConstantShuffleMode();
3434
bool getConstantShuffleMode() const;
35+
void setPlaylistFileName();
36+
std::string getPlaylistFileName();
3537
std::string getCurrentSong();
3638
void setCurrentSong(const std::string&);
3739
void setCurrentSongToSavedSong();
@@ -74,6 +76,7 @@ class SongManager {
7476
std::string m_previousSong = "";
7577
std::string m_overrideSong = "";
7678
std::string m_displayName = "";
79+
std::string m_playlistName = "";
7780
bool m_isMenuLoop;
7881
bool m_constantShuffleMode;
7982
bool m_calledOnce = false;

src/Utils.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void Utils::removeCard() {
5858
}
5959

6060
void Utils::setNewSong() {
61-
if (Utils::getBool("playlistMode")) return Utils::playlistModeNewSong();
61+
if (Utils::getBool("playlistMode")) return Utils::constantShuffleModeNewSong();
6262
FMODAudioEngine::sharedEngine()->m_backgroundMusicChannel->stop();
6363
SongManager& songManager = SongManager::get();
6464
const std::string& songToBeStored = songManager.getCurrentSong();
@@ -69,7 +69,7 @@ void Utils::setNewSong() {
6969
GameManager::sharedState()->playMenuMusic();
7070
}
7171

72-
void Utils::playlistModeNewSong(const bool fromGJBGL) {
72+
void Utils::constantShuffleModeNewSong(const bool fromGJBGL) {
7373
if (VANILLA_GD_MENU_LOOP_DISABLED) return;
7474
if (!Utils::getBool("playlistMode")) return Utils::setNewSong();
7575
geode::log::info("attempting to hijack menuloop channel to use Constant Shuffle Mode");
@@ -202,8 +202,8 @@ std::string Utils::getFormattedNGMLSongName(SongInfoObject* songInfo) {
202202
return fmt::format("{}", songInfo->m_songName);
203203
}
204204

205-
void Utils::playlistModePLAndEPL() {
206-
if (Utils::getBool("playlistMode") && GJBaseGameLayer::get()) return Utils::playlistModeNewSong(true);
205+
void Utils::constantShuffleModePLAndEPL() {
206+
if (Utils::getBool("playlistMode") && GJBaseGameLayer::get()) return Utils::constantShuffleModeNewSong(true);
207207
}
208208

209209
void Utils::copyCurrentSongName() {
@@ -290,6 +290,7 @@ void Utils::populateVector(const bool customSongs, const std::filesystem::path&
290290

291291
// impl playlist files
292292
const std::filesystem::path playlistFile = geode::Mod::get()->getSettingValue<std::filesystem::path>("playlistFile");
293+
songManager.setPlaylistFileName();
293294
if (geode::Mod::get()->getSettingValue<bool>("loadPlaylistFile") && std::filesystem::exists(playlistFile) && playlistFile.extension() == ".txt") {
294295
bool isPlaylistEmpty = true;
295296
std::ifstream playlistFileStream(playlistFile);

src/Utils.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ class Utils {
1111
static cocos2d::CCNode* findCard();
1212
static cocos2d::CCNode* findCardRemotely();
1313
static void setNewSong();
14-
static void playlistModeNewSong(const bool fromGJBGL = false);
14+
static void constantShuffleModeNewSong(const bool fromGJBGL = false);
1515
static void newNotification(const std::string& notifString, const bool checkSetting = false);
1616
static std::string composedNotifString(std::string notifString, const std::string& middle, const std::string& suffix);
1717
static void newCardAndDisplayNameFromCurrentSong();
1818
static std::string getFormattedNGMLSongName(SongInfoObject* songInfo);
19-
static void playlistModePLAndEPL();
19+
static void constantShuffleModePLAndEPL();
2020
static void copyCurrentSongName();
2121
static void loadFromPlaylistFile(const std::filesystem::path& playlistFile);
2222
static void populateVector(const bool customSongs, const std::filesystem::path& path = "", std::vector<std::string> textFileBlacklist = {}, std::vector<std::string> textFileFavorites = {});

src/ui/SongControlMenu.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,5 +168,9 @@ void SongControlMenu::updateCurrentLabel() {
168168
if (songManager.isOverride()) this->m_headerLabl->setString("Current Song (Custom Override):");
169169
else if (songManager.getConstantShuffleMode()) this->m_headerLabl->setString("Current Song (Constant Shuffle Mode):");
170170
else this->m_headerLabl->setString("Current Song:");
171+
if (!songManager.getPlaylistIsEmpty()) {
172+
const std::string& newHeaderString = geode::utils::string::replace(this->m_headerLabl->getString(), "Song", fmt::format("Song from {}", songManager.getPlaylistFileName()));
173+
this->m_headerLabl->setString(newHeaderString.c_str());
174+
}
171175
this->m_headerLabl->limitLabelWidth(this->m_mainLayer->getContentSize().width * .95f * .95f, 1.0f, .0001f);
172176
}

src/ui/SongListLayer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ void SongListLayer::showLayer(const bool instant) {
106106
CCNode* titleLabel = m_listLayer->getChildByID("title");
107107
if (!titleLabel) return;
108108

109-
const SongManager& songManager = SongManager::get();
109+
SongManager& songManager = SongManager::get();
110110

111-
const std::string& playlistFileName = songManager.getPlaylistIsEmpty() ? "None" : geode::utils::string::replace(Utils::toNormalizedString(geode::Mod::get()->getSettingValue<std::filesystem::path>("playlistFile").filename()), ".txt", "");
111+
const std::string& playlistFileName = songManager.getPlaylistIsEmpty() ? "None" : songManager.getPlaylistFileName();
112112
cocos2d::CCLabelBMFont* currentPlaylistLabel = cocos2d::CCLabelBMFont::create(fmt::format("Playlist: {}", playlistFileName).c_str(), "bigFont.fnt");
113113
currentPlaylistLabel->setPosition({83.5f, 0.f});
114114
currentPlaylistLabel->limitLabelWidth(279.f * .45f, 1.f, .0001f);

0 commit comments

Comments
 (0)