//
// SetupSongTriggerPopup::init from 0x14045c950 to 0x14045d591 (3137 bytes)
//
// 2 xrefs:
// > SetupSongTriggerPopup::create @ 0x14045c905
// > ??> @ 0x1406dac88
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
// Hidden C++ exception states: #wind=5
bool SetupSongTriggerPopup::init(SetupSongTriggerPopup *a1, EffectGameObject *a2, cocos2d::CCArray *a3)
{
bool result; // al
_QWORD *v5; // r8
_OWORD *v6; // rcx
const char *v7; // rax
__int64 v8; // rdx
__int64 v9; // rcx
cocos2d::CCDirector *v10; // rax
double ToggleValueControl; // xmm0_8
cocos2d::CCPoint v12; // rax
cocos2d::CCPoint v13; // rbx
float v14; // xmm0_4
SongSelectNode *v15; // rax
struct cocos2d::CCArray *m_selectSongObjects; // rbx
cocos2d::CCArray *GroupContainer; // rax
struct cocos2d::CCArray *m_changeSongObjects; // rbx
cocos2d::CCArray *v19; // rax
double v20; // xmm0_8
int v21; // edx
struct cocos2d::CCSprite *v22; // rbx
CCMenuItemSpriteExtra *v23; // rdi
float v24; // xmm0_4
CCMenuItemSpriteExtra_vtbl *v25; // rbx
struct cocos2d::CCPoint v26; // rax
cocos2d::CCArray *PageContainer; // rax
struct cocos2d::CCSprite *v28; // rbx
CCMenuItemSpriteExtra *v29; // rdi
float v30; // xmm0_4
CCMenuItemSpriteExtra_vtbl *v31; // rbx
struct cocos2d::CCPoint v32; // rax
cocos2d::CCArray *v33; // rax
MusicDownloadManager *v34; // rax
int v35; // r8d
int m_selectedSongID; // ebx
MusicDownloadManager *v37; // rax
__int128 *v38; // rdi
__int64 v39; // rbx
__int64 v40; // rax
int v41; // edx
FMODAudioEngine *v42; // rcx
signed int MusicLengthMS; // eax
float v44; // xmm6_4
struct cocos2d::CCFloat *v45; // rax
struct cocos2d::CCFloat *v46; // rax
float v47; // xmm0_4
_BOOL8 v48; // r8
__int64 v49; // [rsp+80h] [rbp-88h]
__int64 v50; // [rsp+80h] [rbp-88h]
__int128 v51; // [rsp+88h] [rbp-80h] BYREF
__int64 v52; // [rsp+98h] [rbp-70h]
__int64 v53; // [rsp+A0h] [rbp-68h]
FMODAudioEngine *v54; // [rsp+A8h] [rbp-60h] BYREF
__int128 *v55; // [rsp+B0h] [rbp-58h]
__int128 v56; // [rsp+B8h] [rbp-50h] BYREF
__int64 v57; // [rsp+C8h] [rbp-40h]
__int64 v58; // [rsp+D0h] [rbp-38h]
float v59; // [rsp+D8h] [rbp-30h]
_BYTE v60[8]; // [rsp+E0h] [rbp-28h] BYREF
_BYTE v61[96]; // [rsp+E8h] [rbp-20h] BYREF
FMODAudioEngine *v62; // [rsp+180h] [rbp+78h] BYREF
result = SetupTriggerPopup::init(a1, a2, a3, 440.0, 300.0, 1);
if ( result )
{
a1->m_disableTextDelegate = 1;
a1->determineStartValues(a1);
v52 = 12;
v53 = 15;
strcpy((char *)&v51, "Song Trigger");
BYTE13(v51) = 0;
HIWORD(v51) = 0;
SetupTriggerPopup::addTitle(a1, &v51);
v62 = (FMODAudioEngine *)&v51;
v51 = 0;
v52 = 0;
v53 = 15;
v5 = sub_14003AA10(0x1E0u);
*(_QWORD *)&v51 = v5;
v52 = 472;
v53 = 479;
v6 = v5;
v7 = "Lets you start a specified song.\n"
"A single track can be active in each Channel at a time.\n"
"Start, End, FadeIn, and FadeOut are in milliseconds.\n"
"Prep is used to ensure exact sync to a specified time as there may be some delay loading it normally. U"
"se this option on a trigger to prepare the song before you want it to start, and then use Load Prep whe"
"n you want it to start. Note that only one Prep can be active at a time per channel.";
v8 = 3;
do
{
*v6 = *(_OWORD *)v7;
v6[1] = *((_OWORD *)v7 + 1);
v6[2] = *((_OWORD *)v7 + 2);
v6[3] = *((_OWORD *)v7 + 3);
v6[4] = *((_OWORD *)v7 + 4);
v6[5] = *((_OWORD *)v7 + 5);
v6[6] = *((_OWORD *)v7 + 6);
v6 += 8;
*(v6 - 1) = *((_OWORD *)v7 + 7);
v7 += 128;
--v8;
}
while ( v8 );
*v6 = *(_OWORD *)v7;
v6[1] = *((_OWORD *)v7 + 1);
v6[2] = *((_OWORD *)v7 + 2);
v6[3] = *((_OWORD *)v7 + 3);
v6[4] = *((_OWORD *)v7 + 4);
*((_QWORD *)v6 + 10) = *((_QWORD *)v7 + 10);
*((_BYTE *)v5 + 472) = 0;
v56 = 0;
v57 = 4;
v58 = 15;
strcpy((char *)&v56, "Help");
SetupTriggerPopup::addHelpButton(a1, &v56, &v51);
v56 = 0;
v57 = 2;
v58 = 15;
strcpy((char *)&v56, "OK");
SetupTriggerPopup::addCloseButton(a1, &v56);
SetupTriggerPopup::createMultiTriggerItemsDefaultHorizontal(a1);
v10 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v9);
cocos2d::CCDirector::getWinSize(v10);
cocos2d::CCPoint::CCPoint(0.0, v59 * 0.5);
v54 = (FMODAudioEngine *)&v56;
v56 = 0;
v57 = 4;
v58 = 15;
strcpy((char *)&v56, "Prep");
cocos2d::CCPoint::CCPoint(0.0, (float)(a1->m_width * 0.5) - 130.0);
cocos2d::CCPoint::operator+(v61, &v62);
SetupTriggerPopup::createToggleValueControl(
(_DWORD)a1,
399,
(unsigned int)&v56,
(unsigned int)&v62,
0,
0,
0,
1065353216);
v55 = &v51;
*((_QWORD *)&v51 + 1) = 112;
v52 = 9;
v53 = 15;
*(_QWORD *)&v51 = 0x6572500A64616F4CLL;
cocos2d::CCPoint::CCPoint(1.6634149e22, (float)(a1->m_width * 0.5) - 60.0);
cocos2d::CCPoint::operator+(v61, &v62);
ToggleValueControl = SetupTriggerPopup::createToggleValueControl(
(_DWORD)a1,
400,
(unsigned int)&v51,
(unsigned int)&v62,
0,
0,
2,
1065353216);
cocos2d::CCPoint::CCPoint(*(float *)&ToggleValueControl, v59 * 0.5);
v13 = v12;
v14 = a1->getValue(a1, 392);
v15 = SongSelectNode::create((int)v14, 1, nullptr, Custom, v13, a1->m_mainLayer, a1->m_buttonMenu, 1);
a1->m_selectNode = v15;
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v15, 5);
a1->m_selectNode->m_songWidget->m_playbackDelegate = &a1->SongPlaybackDelegate;
SetupSongTriggerPopup::updateLength(a1);
m_selectSongObjects = a1->m_selectNode->m_selectSongObjects;
GroupContainer = SetupTriggerPopup::getGroupContainer(a1, 1);
cocos2d::CCArray::addObjectsFromArray(GroupContainer, m_selectSongObjects);
m_changeSongObjects = a1->m_selectNode->m_changeSongObjects;
v19 = SetupTriggerPopup::getGroupContainer(a1, 1);
cocos2d::CCArray::addObjectsFromArray(v19, m_changeSongObjects);
v20 = cocos2d::CCPoint::CCPoint(v14, v59 * 0.5);
v55 = &v51;
v52 = 7;
v53 = 15;
v51 = 0x3A656D756C6F56uLL;
cocos2d::CCPoint::CCPoint(*(float *)&v20, -91.0);
cocos2d::CCPoint::operator+(v60, &v62);
SetupTriggerPopup::createValueControlAdvanced(
(_DWORD)a1,
406,
(unsigned int)&v51,
(unsigned int)&v62,
1059481190,
0,
1,
6,
0,
0,
0x40000000,
0,
0,
1,
2,
0);
v55 = &v51;
v51 = 0;
v52 = 6;
v53 = 15;
strcpy((char *)&v51, "Speed:");
cocos2d::CCPoint::CCPoint(0.0, 91.0);
cocos2d::CCPoint::operator+(v60, &v62);
LOBYTE(v49) = 0;
SetupTriggerPopup::createValueControlAdvanced(
(_DWORD)a1,
404,
(unsigned int)&v51,
(unsigned int)&v62,
1059481190,
0,
2,
6,
0,
-1052770304,
1094713344,
0,
0,
1,
2,
v49);
LODWORD(v62) = 404;
*(_BYTE *)sub_1400CDBF0((__int64 *)&a1->m_shouldLimitValues, (int *)&v62) = 1;
LODWORD(v62) = 406;
*(_BYTE *)sub_1400CDBF0((__int64 *)&a1->m_shouldLimitValues, (int *)&v62) = 1;
v55 = &v56;
v56 = 0;
v57 = 4;
v58 = 15;
strcpy((char *)&v56, "Loop");
cocos2d::CCPoint::CCPoint(0.0, 38.0);
cocos2d::CCPoint::operator+(v60, &v62);
SetupTriggerPopup::createToggleValueControl(
(_DWORD)a1,
413,
(unsigned int)&v56,
(unsigned int)&v62,
0,
0,
0,
1065353216);
v55 = &v51;
*((_QWORD *)&v51 + 1) = 29797;
v52 = 10;
v53 = 15;
*(_QWORD *)&v51 = 0x7365520A746E6F44LL;
cocos2d::CCPoint::CCPoint(7.5562951e31, 118.0);
cocos2d::CCPoint::operator+(v60, &v62);
SetupTriggerPopup::createToggleValueControl(
(_DWORD)a1,
595,
(unsigned int)&v51,
(unsigned int)&v62,
0,
0,
0,
1065353216);
v55 = &v56;
v57 = 8;
v58 = 15;
v56 = 0x3A6C656E6E616843uLL;
cocos2d::CCPoint::CCPoint(0.0, -108.0);
cocos2d::CCPoint::operator+(v60, &v62);
LOBYTE(v50) = 0;
SetupTriggerPopup::createValueControlAdvanced(
(_DWORD)a1,
432,
(unsigned int)&v56,
(unsigned int)&v62,
1059481190,
1,
3,
10,
1,
0,
1082130432,
0,
2,
0,
2,
v50);
LODWORD(v62) = 432;
*(_BYTE *)sub_1400CDBF0((__int64 *)&a1->m_shouldLimitValues, (int *)&v62) = 1;
SetupAudioTriggerPopup::addTimeControls(a1, v21, -25.0);
v22 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_pauseEditorBtn_001.png");
((void (__fastcall *)(struct cocos2d::CCSprite *))v22->setScale_0)(v22);
v23 = CCMenuItemSpriteExtra::create(
v22,
nullptr,
a1,
(cocos2d::SEL_MenuHandler *)SetupSongTriggerPopup::onSavePlaybackPos);
v23->setTag(v23, 0);
v24 = ((float (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild_1)(
a1->m_buttonMenu,
v23);
cocos2d::CCPoint::CCPoint(v24, -185.0);
cocos2d::CCPoint::operator+(v61, &v62);
v25 = v23->cocos2d::CCMenuItemSprite::cocos2d::CCMenuItem::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v26 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, (const struct cocos2d::CCPoint *)&v54);
((void (__fastcall *)(CCMenuItemSpriteExtra *, struct cocos2d::CCPoint))v25->setPosition_0)(v23, v26);
PageContainer = SetupTriggerPopup::getPageContainer(a1, 1);
cocos2d::CCArray::addObject(PageContainer, v23);
v28 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_pauseEditorBtn_001.png");
((void (__fastcall *)(struct cocos2d::CCSprite *))v28->setScale_0)(v28);
v29 = CCMenuItemSpriteExtra::create(
v28,
nullptr,
a1,
(cocos2d::SEL_MenuHandler *)SetupSongTriggerPopup::onSavePlaybackPos);
v29->setTag(v29, 1);
v30 = ((float (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild_1)(
a1->m_buttonMenu,
v29);
cocos2d::CCPoint::CCPoint(v30, -185.0);
cocos2d::CCPoint::operator+(v61, &v62);
v31 = v29->cocos2d::CCMenuItemSprite::cocos2d::CCMenuItem::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v32 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, (const struct cocos2d::CCPoint *)&v54);
((void (__fastcall *)(CCMenuItemSpriteExtra *, struct cocos2d::CCPoint))v31->setPosition_0)(v29, v32);
v33 = SetupTriggerPopup::getPageContainer(a1, 1);
cocos2d::CCArray::addObject(v33, v29);
v34 = MusicDownloadManager::sharedState();
MusicDownloadManager::addMusicDownloadDelegate(v34, &a1->MusicDownloadDelegate);
m_selectedSongID = a1->m_selectNode->m_selectedSongID;
if ( m_selectedSongID > 0 )
{
v62 = (FMODAudioEngine *)&v56;
v37 = MusicDownloadManager::sharedState();
v38 = (__int128 *)MusicDownloadManager::pathForSong((__int64)v37, &v56, m_selectedSongID);
v55 = v38;
v39 = qword_1406C2E88;
if ( !qword_1406C2E88 )
{
v54 = (FMODAudioEngine *)operator new(0x888u);
qword_1406C2E88 = (__int64)FMODAudioEngine::FMODAudioEngine(v54);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2E88 + 72LL))(qword_1406C2E88);
v39 = qword_1406C2E88;
}
v40 = sub_14003BDB0((__int64)&v51, (__int64)v38);
FMODAudioEngine::loadMusic(v39, v40, 1.0, 0.0, 1.0, 0, 0, 0, 0);
sub_14003A830((__int64)v38);
v42 = (FMODAudioEngine *)qword_1406C2E88;
if ( !qword_1406C2E88 )
{
v62 = (FMODAudioEngine *)operator new(0x888u);
qword_1406C2E88 = (__int64)FMODAudioEngine::FMODAudioEngine(v62);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2E88 + 72LL))(qword_1406C2E88);
v42 = (FMODAudioEngine *)qword_1406C2E88;
}
MusicLengthMS = FMODAudioEngine::getMusicLengthMS(v42, v41);
if ( MusicLengthMS )
{
v44 = (float)MusicLengthMS;
v45 = cocos2d::CCFloat::create((float)MusicLengthMS);
cocos2d::CCDictionary::setObject(a1->m_maxSliderValues, v45, 408);
v46 = cocos2d::CCFloat::create(v44);
cocos2d::CCDictionary::setObject(a1->m_maxSliderValues, v46, 410);
SetupTriggerPopup::updateSlider(a1, 408);
SetupTriggerPopup::updateSlider(a1, 410);
}
}
SetupTriggerPopup::createPageButtons(a1, (float)(a1->m_width * 0.5) + 15.0, v35);
if ( a1->getValue(a1, 400) == 0.0 )
{
v47 = a1->getValue(a1, 427);
SetupTriggerPopup::goToPage(a1, (int)v47, 0);
}
else
{
SetupTriggerPopup::goToPage(a1, 0, 1);
LOBYTE(v48) = 1;
a1->toggleGroup(a1, 2, v48);
}
a1->updateDefaultTriggerValues(a1);
a1->m_disableTextDelegate = 0;
return 1;
}
return result;
}