//
// SongOptionsLayer::init from 0x1400c45a0 to 0x1400c4fb1 (2577 bytes)
//
// 2 xrefs:
// > CustomSongLayer::onOptions @ 0x1400c3948
// > ??> @ 0x1406c80f4
//
// 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=3
bool SongOptionsLayer::init(SongOptionsLayer *a1, CustomSongDelegate *a2)
{
bool result; // al
__int64 v5; // rcx
cocos2d::CCDirector *v6; // rax
struct cocos2d::CCRect *v7; // rax
struct cocos2d::extension::CCScale9Sprite *v8; // rdi
cocos2d::extension::CCScale9Sprite_vtbl *v9; // rbx
const cocos2d::CCSize *v10; // rax
size_t v11; // rsi
cocos2d::extension::CCScale9Sprite_vtbl *v12; // rbx
const cocos2d::CCPoint *v13; // rax
struct cocos2d::CCLabelBMFont *v14; // rdi
cocos2d::CCLabelBMFont_vtbl *v15; // rbx
const cocos2d::CCPoint *v16; // rax
__int64 v17; // rcx
cocos2d::CCMenu *v18; // rax
float *v19; // rax
float *v20; // rbx
struct cocos2d::CCPoint v21; // rax
float *v22; // rax
float *v23; // rax
struct cocos2d::CCSprite *v24; // rax
cocos2d::CCNode *v25; // rdi
cocos2d::CCNode_vtbl *v26; // rbx
struct cocos2d::CCPoint v27; // rax
struct cocos2d::CCSprite *v28; // rax
cocos2d::CCNode *v29; // rdi
cocos2d::CCNode_vtbl *v30; // rbx
struct cocos2d::CCPoint v31; // rax
struct cocos2d::CCLabelBMFont *v32; // rbx
struct cocos2d::CCRect *v33; // rax
struct cocos2d::extension::CCScale9Sprite *v34; // rbx
__int64 v35; // rdx
const char *v36; // r9
CCTextInputNode *v37; // rax
CCTextInputNode *m_offsetInput; // rcx
CCTextInputNode *v39; // rcx
std::string *p_m_allowedChars; // rcx
CCTextInputNode *v41; // rcx
CCTextInputNode *v42; // rcx
LevelSettingsObject *v43; // rax
cocos2d::CCString *v44; // rax
const char *CString; // rax
struct cocos2d::CCSprite *v46; // rax
CCMenuItemSpriteExtra *v47; // rax
CCMenuItemSpriteExtra_vtbl *v48; // rbx
struct cocos2d::CCPoint v49; // rax
int v50; // [rsp+20h] [rbp-E0h]
cocos2d::CCRect *v51; // [rsp+80h] [rbp-80h] BYREF
__int128 *v52; // [rsp+88h] [rbp-78h] BYREF
__int128 v53; // [rsp+90h] [rbp-70h] BYREF
__int64 v54; // [rsp+A0h] [rbp-60h]
__int64 v55; // [rsp+A8h] [rbp-58h]
cocos2d::CCRect v56; // [rsp+B0h] [rbp-50h] BYREF
__int64 v57; // [rsp+C0h] [rbp-40h]
__int64 v58; // [rsp+C8h] [rbp-38h]
cocos2d::CCPoint v59; // [rsp+D0h] [rbp-30h] BYREF
cocos2d::CCPoint v60; // [rsp+D8h] [rbp-28h] BYREF
char Src[12]; // [rsp+E0h] [rbp-20h] BYREF
int v62; // [rsp+ECh] [rbp-14h]
__int64 v63; // [rsp+F0h] [rbp-10h]
__int64 v64; // [rsp+F8h] [rbp-8h]
cocos2d::CCPoint v65; // [rsp+100h] [rbp+0h] BYREF
cocos2d::CCSize v66; // [rsp+108h] [rbp+8h] BYREF
cocos2d::CCRect v67[7]; // [rsp+110h] [rbp+10h] BYREF
float v68; // [rsp+1C0h] [rbp+C0h]
float v69; // [rsp+1C4h] [rbp+C4h]
cocos2d::CCPoint v70; // [rsp+1C8h] [rbp+C8h] BYREF
result = FLAlertLayer::init_1(a1, 75);
if ( result )
{
a1->m_delegate = a2;
v6 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v5);
cocos2d::CCDirector::getWinSize(v6);
cocos2d::CCRect::CCRect(&v56, 0.0, 0.0, 80.0, 80.0);
v8 = cocos2d::extension::CCScale9Sprite::create("GJ_square01.png", v7);
v9 = v8->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v51, 360.0, 220.0);
v9->setContentSize(v8, v10);
v11 = -1;
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v8, -1);
v12 = v8->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v51, v68 * 0.5, v69 * 0.5);
v12->setPosition_0(v8, v13);
v14 = cocos2d::CCLabelBMFont::create("Settings", (const char *)&qword_14052A4D8);
v15 = v14->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v51, v68 * 0.5, (float)((float)(v69 * 0.5) + 110.0) - 20.0);
v15->setPosition_0(v14, v16);
a1->m_mainLayer->addChild_1(a1->m_mainLayer, v14);
v18 = (cocos2d::CCMenu *)cocos2d::CCMenu::create(v17);
a1->m_buttonMenu = v18;
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v18, 10);
cocos2d::CCPoint::CCPoint(&v59, (float)(v68 * 0.5) - 140.0, (float)(v69 * 0.5) - 40.0);
cocos2d::CCPoint::CCPoint(&v65, (float)(v68 * 0.5) + 30.0, v59.y);
v51 = &v56;
v56.size = 0;
v57 = 7;
v58 = 15;
v56.origin = (cocos2d::CCPoint)0x6E692065646146LL;
LOBYTE(v14) = a1->m_delegate->getLevelSettings(a1->m_delegate)->m_fadeIn;
cocos2d::CCPoint::CCPoint(&v60, 8.0, 0.0);
v20 = v19;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v52, &v59);
GameToolbox::createToggleButton(
(const char *)&v56,
(cocos2d::SEL_MenuHandler *)SongOptionsLayer::onFadeIn,
(bool)v14,
a1->m_buttonMenu,
v21,
a1,
a1->m_mainLayer,
0.80000001,
0.60000002,
150.0,
v20,
(const char *)&qword_14052A4D8,
0,
0,
nullptr);
v52 = &v53;
v54 = 8;
v55 = 15;
v53 = 0x74756F2065646146uLL;
cocos2d::CCPoint::CCPoint(&v60, 0.0, 0.0);
cocos2d::CCPoint::operator+(&v65, &v51);
LOBYTE(v20) = a1->m_delegate->getLevelSettings(a1->m_delegate)->m_fadeOut;
cocos2d::CCPoint::CCPoint(&v56.origin, 8.0, 0.0);
GameToolbox::createToggleButton(
(const char *)&v53,
(cocos2d::SEL_MenuHandler *)SongOptionsLayer::onFadeOut,
(bool)v20,
a1->m_buttonMenu,
(struct cocos2d::CCPoint)&v51,
a1,
a1->m_mainLayer,
0.80000001,
0.60000002,
150.0,
v22,
(const char *)&qword_14052A4D8,
0,
0,
nullptr);
v56.origin = (cocos2d::CCPoint)&v53;
*((_QWORD *)&v53 + 1) = 29797;
v54 = 10;
v55 = 15;
*(_QWORD *)&v53 = 0x73655220746E6F44LL;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v52, 0.0, -40.0);
cocos2d::CCPoint::operator+(&v59, &v51);
LOBYTE(v20) = a1->m_delegate->getLevelSettings(a1->m_delegate)->m_dontReset;
cocos2d::CCPoint::CCPoint(&v60, 8.0, 0.0);
GameToolbox::createToggleButton(
(const char *)&v53,
(cocos2d::SEL_MenuHandler *)SongOptionsLayer::onSongPersistent,
(bool)v20,
a1->m_buttonMenu,
(struct cocos2d::CCPoint)&v51,
a1,
a1->m_mainLayer,
0.80000001,
0.60000002,
150.0,
v23,
(const char *)&qword_14052A4D8,
0,
0,
nullptr);
v24 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_closeBtn_001.png");
v25 = CCMenuItemSpriteExtra::create(v24, nullptr, a1, (cocos2d::SEL_MenuHandler *)SongOptionsLayer::onClose);
v25[1].m_unknown5 = 1069547520;
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, v25);
v26 = v25->__vftable;
cocos2d::CCPoint::CCPoint(
&v56.origin,
(float)((float)(v68 * 0.5) - 180.0) + 5.0,
(float)((float)(v69 * 0.5) + 110.0) - 5.0);
v27 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, (const struct cocos2d::CCPoint *)&v52);
((void (__fastcall *)(cocos2d::CCNode *, struct cocos2d::CCPoint))v26->setPosition_0)(v25, v27);
v28 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_infoIcon_001.png");
v29 = CCMenuItemSpriteExtra::create(v28, nullptr, a1, (cocos2d::SEL_MenuHandler *)SongOptionsLayer::onInfo);
v29[1].m_unknown5 = 0x40000000;
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, v29);
v30 = v29->__vftable;
cocos2d::CCPoint::CCPoint(
&v56.origin,
(float)((float)(v68 * 0.5) + 180.0) - 17.0,
(float)((float)(v69 * 0.5) + 110.0) - 17.0);
v31 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, (const struct cocos2d::CCPoint *)&v52);
((void (__fastcall *)(cocos2d::CCNode *, struct cocos2d::CCPoint))v30->setPosition_0)(v29, v31);
cocos2d::CCPoint::CCPoint(&v70, v68 * 0.5, (float)(v69 * 0.5) + 25.0);
v32 = cocos2d::CCLabelBMFont::create("Start Offset", (const char *)&qword_14052A4D8);
((void (__fastcall *)(struct cocos2d::CCLabelBMFont *))v32->setScale_0)(v32);
cocos2d::CCPoint::CCPoint(&v56.origin, 0.0, 25.0);
cocos2d::CCPoint::operator+(&v70, &v51);
v32->setPosition_0(v32, (const cocos2d::CCPoint *)&v51);
a1->m_mainLayer->addChild_1(a1->m_mainLayer, v32);
cocos2d::CCRect::CCRect(v67, 0.0, 0.0, 40.0, 40.0);
v33 = (struct cocos2d::CCRect *)cocos2d::CCRect::CCRect(&v56, v67);
v34 = cocos2d::extension::CCScale9Sprite::create("square02_small.png", v33);
LOBYTE(v35) = 100;
v34->setOpacity(&v34->cocos2d::CCRGBAProtocol, v35);
cocos2d::CCSize::CCSize(&v66, 100.0, 30.0);
v34->setContentSize(v34, &v66);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v34, -1);
v34->setPosition_0(v34, &v70);
v37 = CCTextInputNode::create(100.0, 50.0, "Seconds", v36, v50, (const char *)&qword_14052A4D8);
a1->m_offsetInput = v37;
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v37, 20);
a1->m_offsetInput->setPosition_0(a1->m_offsetInput, &v70);
m_offsetInput = a1->m_offsetInput;
m_offsetInput->m_maxLabelScale = 0.69999999;
CCTextInputNode::refreshLabel(m_offsetInput);
v39 = a1->m_offsetInput;
v39->m_maxLabelWidth = 200.0;
CCTextInputNode::refreshLabel(v39);
a1->m_offsetInput->m_textField->setVisible(a1->m_offsetInput->m_textField, 0);
a1->m_offsetInput->m_maxLabelLength = 5;
v62 = 0;
v63 = 11;
v64 = 15;
strcpy(Src, "0123456789.");
v56.origin = (cocos2d::CCPoint)Src;
p_m_allowedChars = &a1->m_offsetInput->m_allowedChars;
if ( p_m_allowedChars != (std::string *)Src )
sub_14003CCE0((void **)p_m_allowedChars, Src, 0xBu);
sub_14003A830((__int64)Src);
v41 = a1->m_offsetInput;
*(_WORD *)&v41->m_placeholderColor.r = -21896;
v41->m_placeholderColor.b = -16;
CCTextInputNode::refreshLabel(v41);
v42 = a1->m_offsetInput;
v42->m_placeholderScale = 0.5;
CCTextInputNode::refreshLabel(v42);
if ( a1->m_delegate->getLevelSettings(a1->m_delegate)->m_songOffset > 0.0 )
{
v43 = a1->m_delegate->getLevelSettings(a1->m_delegate);
v44 = cocos2d::CCString::createWithFormat("%0.1f", v43->m_songOffset);
CString = cocos2d::CCString::getCString(v44);
v53 = 0;
v54 = 0;
v55 = 0;
do
++v11;
while ( CString[v11] );
sub_14003A930(&v53, CString, v11);
CCTextInputNode::setString((__int64)a1->m_offsetInput, &v53);
}
v46 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_playMusicBtn_001.png");
v47 = CCMenuItemSpriteExtra::create(v46, nullptr, a1, (cocos2d::SEL_MenuHandler *)SongOptionsLayer::onPlayback);
a1->m_playbackButton = v47;
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, v47);
v48 = a1->m_playbackButton->__vftable;
cocos2d::CCPoint::CCPoint(&v56.origin, (float)(v68 * 0.5) + 100.0, v70.y);
v49 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, (const struct cocos2d::CCPoint *)&v52);
((void (__fastcall *)(CCMenuItemSpriteExtra *, struct cocos2d::CCPoint))v48->setPosition_0)(
a1->m_playbackButton,
v49);
return 1;
}
return result;
}