@@ -3,6 +3,7 @@ bool is_muted = false;
33#include " ../includes.h"
44#include < Geode/modify/EditorUI.hpp>
55#include < Geode/modify/PlayLayer.hpp>
6+ #include < Geode/modify/PauseLayer.hpp>
67#include " ../Settings/CustomSettings.hpp"
78#ifdef GEODE_IS_WINDOWS
89#include < commdlg.h>
@@ -161,7 +162,7 @@ void toggleSpotifyMute(bool automatic = false, bool muted = false) {
161162bool isApplicationRunning (const std::string& appName) {
162163 // Construct the osascript command
163164 std::string script = " osascript -e 'tell application \" System Events\" to (name of processes) contains \" " + appName + " \" '" ;
164-
165+
165166 // Open a pipe to execute the command and capture its output
166167 FILE* pipe = popen (script.c_str (), " r" );
167168 if (!pipe) {
@@ -225,14 +226,14 @@ void toggleSpotifyMute(bool automatic = false, bool muted = false) {
225226 // nothing because im not sure!
226227}
227228#endif
228- #ifdef GEODE_IS_DESKTOP
229+ #ifdef GEODE_IS_DESKTOP
229230class $modify(PlayLayer) {
230231 bool init (GJGameLevel* level, bool p1, bool p2) {
231232 if (!PlayLayer::init (level, p1, p2)) return false ;
232233 if (!Mod::get ()->getSettingValue <bool >(" inLevelsSpotify" )) return true ;
233234 // auto gm = FMODAudioEngine::sharedEngine();
234235 // if (gm->m_backgroundMusicVolume > 0.0f) {
235- // uncomment when fmod gets these fields
236+ // uncomment when fmod gets these fields
236237 if (1 .0F > 0 .0F ) {
237238 toggleSpotifyMute (true , true );
238239 }
@@ -247,6 +248,19 @@ class $modify(PlayLayer) {
247248 }
248249};
249250
251+ class $modify(PauseLayer) {
252+ // onEdit is called when the editor button is clicked, but goEdit is what actually does the transition to the editor
253+ // from the pause menu, so it makes more sense to make sure muting only happens on transition
254+ void goEdit () {
255+ PauseLayer::goEdit ();
256+ if (!Mod::get ()->getSettingValue <bool >(" inLevelsSpotify" )) return ;
257+ // if (gm->m_backgroundMusicVolume > 0.0f) {
258+ if (1 > 0 .0F ) { // temp until someone adds fields
259+ toggleSpotifyMute ();
260+ }
261+ }
262+ };
263+
250264class $modify(EditorUI) {
251265 void onPlaytest (CCObject* sender) {
252266 EditorUI::onPlaytest (sender);
@@ -264,6 +278,14 @@ class $modify(EditorUI) {
264278 toggleSpotifyMute (true , false );
265279 }
266280 }
281+ void playtestStopped () {
282+ EditorUI::playtestStopped ();
283+ if (!Mod::get ()->getSettingValue <bool >(" inEditorSpotify" )) return ;
284+
285+ if (is_muted) {
286+ toggleSpotifyMute (true , false );
287+ }
288+ }
267289 void onPlayback (CCObject* sender) {
268290 EditorUI::onPlayback (sender);
269291 if (!Mod::get ()->getSettingValue <bool >(" inEditorSpotify" )) return ;
0 commit comments