@@ -165,6 +165,8 @@ class DetailedAudioPreviewPopup : public geode::Popup<SongInfoObject*, CustomSon
165165 CCSize m_widgetSize;
166166 CCSize m_barSize;
167167 CustomSongWidget* m_parentWidget = nullptr ;
168+ CCMenuItemSpriteExtra* m_playButton = nullptr ;
169+ bool m_isAlreadyChosenSong = false ;
168170
169171 EventListener<SampleInfo::SampleTask> m_sampleTaskListener;
170172
@@ -175,8 +177,10 @@ class DetailedAudioPreviewPopup : public geode::Popup<SongInfoObject*, CustomSon
175177 m_parentWidget = parent;
176178
177179 if (auto * editor = LevelEditorLayer::get ()) {
178- if (editor->m_level ->m_songID == m_songID)
180+ if (editor->m_level ->m_songID == m_songID) {
179181 m_startOffset = editor->m_levelSettings ->m_songOffset ;
182+ m_isAlreadyChosenSong = true ;
183+ }
180184 }
181185
182186 auto winSize = CCDirector::sharedDirector ()->getWinSize ();
@@ -271,11 +275,12 @@ class DetailedAudioPreviewPopup : public geode::Popup<SongInfoObject*, CustomSon
271275 ->setAutoGrowAxis (1 .f )
272276 ->setGap (0 .f )
273277 )
274- .child (Build<CCSprite>:: createSpriteName ( " GJ_undoBtn_001 .png" )
278+ .child (Build ( CircleButtonSprite::createWithSprite ( " back .png" _spr, 1 . f , CircleBaseColor::Green, CircleBaseSize::Small) )
275279 .intoMenuItem (this , menu_selector (DetailedAudioPreviewPopup::onGoToStartOffset))
276280 )
277- .child (Build<CCSprite>::createSpriteName (" GJ_playMusicBtn_001 .png" )
281+ .child (Build<CCSprite>::createSpriteName (" GJ_pauseBtn_001 .png" )
278282 .intoMenuItem (this , menu_selector (DetailedAudioPreviewPopup::onPlay))
283+ .store (m_playButton)
279284 )
280285 .updateLayout ()
281286 )
@@ -474,11 +479,15 @@ class DetailedAudioPreviewPopup : public geode::Popup<SongInfoObject*, CustomSon
474479 void onPlay (CCObject*) {
475480 auto path = MusicDownloadManager::sharedState ()->pathForSong (m_songID);
476481 auto * engine = FMODAudioEngine::sharedEngine ();
482+ const char * sprite;
477483 if (engine->isMusicPlaying (0 )) {
478484 engine->pauseMusic (0 );
485+ sprite = " GJ_playMusicBtn_001.png" ;
479486 } else {
480487 engine->playMusic (path, false , 0 .f , 0 );
488+ sprite = " GJ_pauseBtn_001.png" ;
481489 }
490+ m_playButton->setNormalImage (CCSprite::createWithSpriteFrameName (sprite));
482491 }
483492
484493 void onGoToStartOffset (CCObject*) {
@@ -496,6 +505,14 @@ class DetailedAudioPreviewPopup : public geode::Popup<SongInfoObject*, CustomSon
496505 this ->onClose (nullptr );
497506 }
498507
508+ void onClose (CCObject* obj) override {
509+ if (auto * editor = LevelEditorLayer::get (); editor && m_isAlreadyChosenSong) {
510+ editor->m_levelSettings ->m_songOffset = m_startOffset;
511+ }
512+
513+ Popup::onClose (obj);
514+ }
515+
499516 void textChanged (CCTextInputNode* input) override {
500517 // try to parse it, ignore if it fails
501518 auto str = input->getString ();
0 commit comments