@@ -165,6 +165,8 @@ class DetailedAudioPreviewPopup : public geode::Popup<SongInfoObject*, CustomSon
165
165
CCSize m_widgetSize;
166
166
CCSize m_barSize;
167
167
CustomSongWidget* m_parentWidget = nullptr ;
168
+ CCMenuItemSpriteExtra* m_playButton = nullptr ;
169
+ bool m_isAlreadyChosenSong = false ;
168
170
169
171
EventListener<SampleInfo::SampleTask> m_sampleTaskListener;
170
172
@@ -175,8 +177,10 @@ class DetailedAudioPreviewPopup : public geode::Popup<SongInfoObject*, CustomSon
175
177
m_parentWidget = parent;
176
178
177
179
if (auto * editor = LevelEditorLayer::get ()) {
178
- if (editor->m_level ->m_songID == m_songID)
180
+ if (editor->m_level ->m_songID == m_songID) {
179
181
m_startOffset = editor->m_levelSettings ->m_songOffset ;
182
+ m_isAlreadyChosenSong = true ;
183
+ }
180
184
}
181
185
182
186
auto winSize = CCDirector::sharedDirector ()->getWinSize ();
@@ -271,11 +275,12 @@ class DetailedAudioPreviewPopup : public geode::Popup<SongInfoObject*, CustomSon
271
275
->setAutoGrowAxis (1 .f )
272
276
->setGap (0 .f )
273
277
)
274
- .child (Build<CCSprite>:: createSpriteName ( " GJ_undoBtn_001 .png" )
278
+ .child (Build ( CircleButtonSprite::createWithSprite ( " back .png" _spr, 1 . f , CircleBaseColor::Green, CircleBaseSize::Small) )
275
279
.intoMenuItem (this , menu_selector (DetailedAudioPreviewPopup::onGoToStartOffset))
276
280
)
277
- .child (Build<CCSprite>::createSpriteName (" GJ_playMusicBtn_001 .png" )
281
+ .child (Build<CCSprite>::createSpriteName (" GJ_pauseBtn_001 .png" )
278
282
.intoMenuItem (this , menu_selector (DetailedAudioPreviewPopup::onPlay))
283
+ .store (m_playButton)
279
284
)
280
285
.updateLayout ()
281
286
)
@@ -474,11 +479,15 @@ class DetailedAudioPreviewPopup : public geode::Popup<SongInfoObject*, CustomSon
474
479
void onPlay (CCObject*) {
475
480
auto path = MusicDownloadManager::sharedState ()->pathForSong (m_songID);
476
481
auto * engine = FMODAudioEngine::sharedEngine ();
482
+ const char * sprite;
477
483
if (engine->isMusicPlaying (0 )) {
478
484
engine->pauseMusic (0 );
485
+ sprite = " GJ_playMusicBtn_001.png" ;
479
486
} else {
480
487
engine->playMusic (path, false , 0 .f , 0 );
488
+ sprite = " GJ_pauseBtn_001.png" ;
481
489
}
490
+ m_playButton->setNormalImage (CCSprite::createWithSpriteFrameName (sprite));
482
491
}
483
492
484
493
void onGoToStartOffset (CCObject*) {
@@ -496,6 +505,14 @@ class DetailedAudioPreviewPopup : public geode::Popup<SongInfoObject*, CustomSon
496
505
this ->onClose (nullptr );
497
506
}
498
507
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
+
499
516
void textChanged (CCTextInputNode* input) override {
500
517
// try to parse it, ignore if it fails
501
518
auto str = input->getString ();
0 commit comments