|
5 | 5 | using namespace geode::prelude; |
6 | 6 |
|
7 | 7 | class $modify(MenuLoopGMHook, GameManager) { |
8 | | - static void onModify(auto& self) { |
9 | | - (void) self.setHookPriority("GameManger::getMenuMusicFile", -3999); |
10 | | - (void) self.setHookPriority("GameManger::playMenuMusic", -3999); |
11 | | - (void) self.setHookPriority("GameManger::fadeInMenuMusic", -3999); |
12 | | - } |
13 | 8 | gd::string getMenuMusicFile() { |
14 | 9 | return SongManager::get().getCurrentSong(); |
15 | 10 | } |
16 | | - void playMenuMusic() { |
17 | | - // manual reconstruction |
18 | | - FMODAudioEngine* fmod = FMODAudioEngine::get(); |
19 | | - if (VANILLA_GD_MENU_LOOP_DISABLED) return fmod->stopAllMusic(true); |
20 | | - if (!fmod->isMusicPlaying(GameManager::get()->getMenuMusicFile(), 0)) fmod->playMusic(GameManager::get()->getMenuMusicFile(), true, 0, 0); |
21 | | - } |
22 | 11 | void fadeInMenuMusic() { |
23 | 12 | // code taken verbatim from colon. i've had two too many toddlers nagging me to add this feature to the mod now so here we are |
24 | 13 | FMODAudioEngine* fmod = FMODAudioEngine::get(); |
25 | | - if (VANILLA_GD_MENU_LOOP_DISABLED) return fmod->stopAllMusic(true); |
26 | | - |
27 | 14 | SongManager& songManager = SongManager::get(); |
28 | | - |
| 15 | + const auto oldTrack = fmod->getActiveMusic(0); |
| 16 | + GameManager::fadeInMenuMusic(); |
29 | 17 | // ensure compat with colon |
30 | 18 | const geode::Mod* colon = songManager.getColonMenuLoopStartTime(); |
31 | | - if (colon && colon->getSettingValue<bool>("enable")) return GameManager::fadeInMenuMusic(); |
32 | | - |
33 | | - // manual function reconstruction |
34 | | - const auto oldTrack = fmod->getActiveMusic(0); |
35 | | - if (!fmod->isMusicPlaying(GameManager::get()->getMenuMusicFile(), 0)) fmod->playMusic(GameManager::get()->getMenuMusicFile(), true, 1, 0); |
36 | | - |
37 | | - if (!songManager.getShouldRestoreMenuLoopPoint() || oldTrack == fmod->getActiveMusic(0)) return; |
| 19 | + if (colon && colon->getSettingValue<bool>("enable")) return; |
| 20 | + if (!songManager.getShouldRestoreMenuLoopPoint()) return; |
| 21 | + if (oldTrack == fmod->getActiveMusic(0)) return; |
38 | 22 | songManager.restoreLastMenuLoopPosition(); |
39 | 23 | songManager.setShouldRestoreMenuLoopPoint(false); |
40 | 24 | } |
|
0 commit comments