-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix music on cancel + close button for popup
- Loading branch information
Showing
21 changed files
with
241 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include "EditLevelLayer.hpp" | ||
#include "hooks/FMODAudioEngine.hpp" | ||
|
||
using namespace geode::prelude; | ||
using namespace persistenceAPI; | ||
|
||
unsigned long long s_editLevelLayerDelegate1 = 0; | ||
unsigned long long s_editLevelLayerDelegate2 = 0; | ||
|
||
// overrides | ||
|
||
void PSEditLevelLayer::onPlay(cocos2d::CCObject* i_sender) { | ||
// stupid way of not letting it unregister the keyboard delegates | ||
s_editLevelLayerDelegate1 = reinterpret_cast<unsigned long long>(&m_bTouchEnabled)-3*sizeof(void*); | ||
s_editLevelLayerDelegate2 = reinterpret_cast<unsigned long long>(&m_bTouchEnabled)-2*sizeof(void*); | ||
|
||
PSFMODAudioEngine* l_audioEngine = static_cast<PSFMODAudioEngine*>(FMODAudioEngine::get()); | ||
l_audioEngine->m_fields->m_disableLoadMusic = true; | ||
l_audioEngine->backupMusic(); | ||
|
||
EditLevelLayer::onPlay(i_sender); | ||
|
||
l_audioEngine->restoreMusic(); | ||
// m_disableLoadMusic gets set to false before running PlayLayer::setupHasCompleted | ||
|
||
s_editLevelLayerDelegate1 = 0; | ||
s_editLevelLayerDelegate2 = 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#pragma once | ||
#include <Geode/Geode.hpp> | ||
#include <Geode/modify/EditLevelLayer.hpp> | ||
#include <sabe.persistenceapi/include/PersistenceAPI.hpp> | ||
|
||
extern unsigned long long s_editLevelLayerDelegate1; | ||
extern unsigned long long s_editLevelLayerDelegate2; | ||
|
||
class $modify(PSEditLevelLayer, EditLevelLayer) { | ||
public: | ||
// overrides | ||
|
||
$override | ||
void onPlay(cocos2d::CCObject* i_sender); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#include "FMODAudioEngine.hpp" | ||
#include "Geode/binding/FMODAudioEngine.hpp" | ||
|
||
using namespace geode::prelude; | ||
using namespace persistenceAPI; | ||
|
||
unsigned long long s_FMODAudioEngineDelegate1 = 0; | ||
unsigned long long s_FMODAudioEngineDelegate2 = 0; | ||
|
||
// overrides | ||
|
||
void PSFMODAudioEngine::fadeOutMusic(float i_time, int i_channel) { | ||
if (m_fields->m_disableFadeOutMusic) { | ||
return; | ||
} | ||
FMODAudioEngine::fadeOutMusic(i_time, i_channel); | ||
} | ||
|
||
void PSFMODAudioEngine::loadMusic(gd::string i_path, float i_speed, float i_p2, float i_volume, bool i_shouldLoop, int i_p5, int i_p6) { | ||
if (m_fields->m_disableLoadMusic) { | ||
return; | ||
} | ||
FMODAudioEngine::loadMusic(i_path, i_speed, i_p2, i_volume, i_shouldLoop, i_p5, i_p6); | ||
} | ||
|
||
// custom methods | ||
|
||
void PSFMODAudioEngine::backupMusic() { | ||
m_fields->m_backgroundMusicChannelBackup = m_backgroundMusicChannel; | ||
m_backgroundMusicChannel = nullptr; | ||
for (int i = 0; i < m_audioState.m_unkMapIntFloat7.size(); i++) { | ||
m_fields->m_unkMapIntFloat7Backup[i] = m_audioState.m_unkMapIntFloat7[i]; | ||
} | ||
for (int i = 0; i < m_audioState.m_unkMapIntFloat8.size(); i++) { | ||
m_fields->m_unkMapIntFloat8Backup[i] = m_audioState.m_unkMapIntFloat8[i]; | ||
} | ||
for (int i = 0; i < m_audioState.m_unkMapIntFloat9.size(); i++) { | ||
m_fields->m_unkMapIntFloat9Backup[i] = m_audioState.m_unkMapIntFloat9[i]; | ||
} | ||
} | ||
|
||
void PSFMODAudioEngine::restoreMusic() { | ||
m_backgroundMusicChannel = m_fields->m_backgroundMusicChannelBackup; | ||
m_fields->m_backgroundMusicChannelBackup = nullptr; | ||
for (int i = 0; i < m_fields->m_unkMapIntFloat7Backup.size(); i++) { | ||
m_audioState.m_unkMapIntFloat7[i] = m_fields->m_unkMapIntFloat7Backup[i]; | ||
} | ||
for (int i = 0; i < m_fields->m_unkMapIntFloat8Backup.size(); i++) { | ||
m_audioState.m_unkMapIntFloat8[i] = m_fields->m_unkMapIntFloat8Backup[i]; | ||
} | ||
for (int i = 0; i < m_fields->m_unkMapIntFloat9Backup.size(); i++) { | ||
m_audioState.m_unkMapIntFloat9[i] = m_fields->m_unkMapIntFloat9Backup[i]; | ||
} | ||
m_fields->m_unkMapIntFloat7Backup.clear(); | ||
m_fields->m_unkMapIntFloat8Backup.clear(); | ||
m_fields->m_unkMapIntFloat9Backup.clear(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#pragma once | ||
#include "Geode/modify/Modify.hpp" | ||
#include <Geode/Geode.hpp> | ||
#include <Geode/modify/FMODAudioEngine.hpp> | ||
#include <sabe.persistenceapi/include/PersistenceAPI.hpp> | ||
|
||
class $modify(PSFMODAudioEngine, FMODAudioEngine) { | ||
public: | ||
struct Fields { | ||
bool m_disableFadeOutMusic; | ||
bool m_disableLoadMusic; | ||
FMOD::Channel* m_backgroundMusicChannelBackup; | ||
gd::unordered_map<int,float> m_unkMapIntFloat7Backup; | ||
gd::unordered_map<int,float> m_unkMapIntFloat8Backup; | ||
gd::unordered_map<int,float> m_unkMapIntFloat9Backup; | ||
}; | ||
|
||
// overrides | ||
|
||
$override | ||
void fadeOutMusic(float i_time, int i_channel); | ||
|
||
$override | ||
void loadMusic(gd::string i_path, float i_speed, float i_p2, float i_volume, bool i_shouldLoop, int i_p5, int i_p6); | ||
|
||
// custom methods | ||
|
||
void backupMusic(); | ||
|
||
void restoreMusic(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include "LevelAreaInnerLayer.hpp" | ||
#include "hooks/FMODAudioEngine.hpp" | ||
|
||
using namespace geode::prelude; | ||
using namespace persistenceAPI; | ||
|
||
// overrides | ||
|
||
void PSLevelAreaInnerLayer::onDoor(cocos2d::CCObject* i_sender) { | ||
PSFMODAudioEngine* l_audioEngine = static_cast<PSFMODAudioEngine*>(FMODAudioEngine::get()); | ||
l_audioEngine->m_fields->m_disableFadeOutMusic = true; | ||
l_audioEngine->m_fields->m_disableLoadMusic = true; | ||
|
||
LevelAreaInnerLayer::onDoor(i_sender); | ||
|
||
l_audioEngine->m_fields->m_disableFadeOutMusic = false; | ||
// m_disableLoadMusic gets set to false before running PlayLayer::setupHasCompleted or when cancelling level load | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#pragma once | ||
#include <Geode/Geode.hpp> | ||
#include <Geode/modify/LevelAreaInnerLayer.hpp> | ||
#include <sabe.persistenceapi/include/PersistenceAPI.hpp> | ||
|
||
class $modify(PSLevelAreaInnerLayer, LevelAreaInnerLayer) { | ||
public: | ||
// overrides | ||
|
||
$override | ||
void onDoor(cocos2d::CCObject* i_sender); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.