//
// CustomSongLayer::init from 0x1400c2c20 to 0x1400c389e (3198 bytes)
//
// 2 xrefs:
// > SongSelectNode::showCustomSongSelect @ 0x1400c7c92
// > ??> @ 0x1406c8028
//
// 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=2
bool CustomSongLayer::init(CustomSongLayer *a1, CustomSongDelegate *a2)
{
__int64 v4; // rax
cocos2d::CCTouchDispatcher *v5; // rax
bool result; // al
_BOOL8 v7; // rdx
_BOOL8 v8; // rdx
__int64 v9; // rcx
cocos2d::CCDirector *v10; // rax
cocos2d::CCLayer *v11; // rax
struct cocos2d::CCRect *v12; // rax
struct cocos2d::extension::CCScale9Sprite *v13; // rdi
__int64 v14; // rdx
cocos2d::extension::CCScale9Sprite_vtbl *v15; // rbx
const cocos2d::CCSize *v16; // rax
cocos2d::extension::CCScale9Sprite_vtbl *v17; // rbx
const cocos2d::CCPoint *v18; // rax
struct cocos2d::CCLabelBMFont *v19; // rdi
cocos2d::CCLabelBMFont_vtbl *v20; // rbx
const cocos2d::CCPoint *v21; // rax
struct cocos2d::CCSprite *v22; // rax
CCMenuItemSpriteExtra *v23; // rax
cocos2d::CCMenu *v24; // rax
cocos2d::CCMenu_vtbl *v25; // rbx
const cocos2d::CCPoint *v26; // rax
struct cocos2d::CCSprite *v27; // rax
cocos2d::CCNode *v28; // r14
cocos2d::CCNode_vtbl *v29; // rbx
struct cocos2d::CCPoint v30; // rax
struct cocos2d::CCSprite *v31; // rbx
cocos2d::CCNode *v32; // rdi
cocos2d::CCNode_vtbl *v33; // rbx
struct cocos2d::CCPoint v34; // rax
struct cocos2d::CCSprite *v35; // rbx
cocos2d::CCNode *v36; // rdi
cocos2d::CCNode_vtbl *v37; // rbx
struct cocos2d::CCPoint v38; // rax
struct cocos2d::CCSprite *v39; // rbx
cocos2d::CCNode *v40; // rdi
cocos2d::CCNode_vtbl *v41; // rbx
struct cocos2d::CCPoint v42; // rax
CustomSongDelegate *m_songDelegate; // rcx
struct cocos2d::CCSprite *v44; // rax
CCMenuItemSpriteExtra *v45; // rdi
CCMenuItemSpriteExtra_vtbl *v46; // rbx
struct cocos2d::CCPoint v47; // rax
CustomSongDelegate *v48; // rcx
struct cocos2d::CCSprite *v49; // rbx
cocos2d::CCNode *v50; // rdi
cocos2d::CCNode_vtbl *v51; // rbx
struct cocos2d::CCPoint v52; // rax
struct cocos2d::CCRect *v53; // rax
struct cocos2d::extension::CCScale9Sprite *v54; // rbx
__int64 v55; // rdx
struct cocos2d::CCRect *v56; // rax
struct cocos2d::extension::CCScale9Sprite *v57; // rbx
__int64 v58; // rdx
const char *v59; // r9
CCTextInputNode *v60; // rax
cocos2d::CCTextFieldTTF *m_textField; // rbx
cocos2d::CCTextFieldTTF_vtbl *v62; // rdi
const cocos2d::CCPoint *v63; // rax
cocos2d::CCLabelBMFont *m_textLabel; // rbx
cocos2d::CCLabelBMFont_vtbl *v65; // rdi
const cocos2d::CCPoint *v66; // rax
CCTextInputNode *m_songIDInput; // rcx
CCTextInputNode *v68; // rcx
std::string *p_m_allowedChars; // rcx
CCTextInputNode *v70; // rcx
CCTextInputNode *v71; // rcx
ButtonSprite *v72; // rbx
CCMenuItemSpriteExtra *v73; // rdi
CCMenuItemSpriteExtra_vtbl *v74; // rbx
struct cocos2d::CCPoint v75; // rax
SongInfoObject *v76; // rbx
int v77; // eax
CustomSongWidget *v78; // rax
CustomSongWidget_vtbl *v79; // rbx
const cocos2d::CCPoint *v80; // rax
int v81; // [rsp+28h] [rbp-E0h]
cocos2d::CCPoint v82; // [rsp+58h] [rbp-B0h] BYREF
cocos2d::CCSize v83; // [rsp+60h] [rbp-A8h] BYREF
_QWORD Src[4]; // [rsp+68h] [rbp-A0h] BYREF
cocos2d::CCPoint v85; // [rsp+88h] [rbp-80h] BYREF
cocos2d::CCSize v86; // [rsp+90h] [rbp-78h] BYREF
cocos2d::CCRect v87; // [rsp+98h] [rbp-70h] BYREF
cocos2d::CCRect v88[8]; // [rsp+A8h] [rbp-60h] BYREF
ButtonSprite *v89; // [rsp+158h] [rbp+50h] BYREF
float v90; // [rsp+168h] [rbp+60h]
float v91; // [rsp+16Ch] [rbp+64h]
cocos2d::CCPoint v92; // [rsp+170h] [rbp+68h] BYREF
if ( !a1->m_forcePrioRegistered )
{
a1->m_forcePrioRegistered = 1;
v4 = cocos2d::CCDirector::sharedDirector(a1);
v5 = (cocos2d::CCTouchDispatcher *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v4 + 144LL))(v4);
cocos2d::CCTouchDispatcher::registerForcePrio(v5, a1, 2);
}
LODWORD(v89) = -1778384896;
result = cocos2d::CCLayerColor::initWithColor(a1, (const struct cocos2d::_ccColor4B *)&v89);
if ( result )
{
a1->m_songDelegate = a2;
LOBYTE(v7) = 1;
a1->setTouchEnabled(a1, v7);
LOBYTE(v8) = 1;
a1->setKeypadEnabled(a1, v8);
v10 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v9);
cocos2d::CCDirector::getWinSize(v10);
v11 = (cocos2d::CCLayer *)cocos2d::CCLayer::create();
a1->m_mainLayer = v11;
a1->addChild_1(a1, v11);
cocos2d::CCRect::CCRect(&v87, 0.0, 0.0, 40.0, 40.0);
v13 = cocos2d::extension::CCScale9Sprite::create("GJ_button_05.png", v12);
LOBYTE(v14) = -1;
v13->setOpacity(&v13->cocos2d::CCRGBAProtocol, v14);
v15 = v13->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v89, 440.0, 290.0);
v15->setContentSize(v13, v16);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v13, -1);
v17 = v13->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v89, v90 * 0.5, v91 * 0.5);
v17->setPosition_0(v13, v18);
a1->m_joystickConnected = -1;
v19 = cocos2d::CCLabelBMFont::create("Custom Song Selection", "goldFont.fnt");
((void (__fastcall *)(struct cocos2d::CCLabelBMFont *))v19->setScale_0)(v19);
a1->m_mainLayer->addChild_1(a1->m_mainLayer, v19);
v20 = v19->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v89, v90 * 0.5, (float)((float)(v91 * 0.5) + 145.0) - 22.0);
v20->setPosition_0(v19, v21);
v22 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_closeBtn_001.png");
v23 = CCMenuItemSpriteExtra::create(v22, nullptr, a1, (cocos2d::SEL_MenuHandler *)CustomSongLayer::onClose);
HIDWORD(v23->m_pfnSelector.adj) = 1070386381;
v24 = cocos2d::CCMenu::create(v23, 0);
a1->m_buttonMenu = v24;
v25 = v24->cocos2d::CCLayerRGBA::cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)&v89,
(float)((float)(v90 * 0.5) - 220.0) + 10.0,
(float)((float)(v91 * 0.5) + 145.0) - 10.0);
v25->setPosition_0(a1->m_buttonMenu, v26);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, a1->m_buttonMenu, 10);
v27 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_savedSongsBtn_001.png");
v28 = CCMenuItemSpriteExtra::create(v27, nullptr, a1, (cocos2d::SEL_MenuHandler *)CustomSongLayer::onSongBrowser);
v28[1].m_unknown5 = 1067030938;
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, v28);
v29 = v28->__vftable;
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)&v89,
(float)((float)(v90 * 0.5) + 220.0) - 24.0,
(float)((float)((float)(v91 * 0.5) - 145.0) + 24.0) + 2.0);
v30 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, &v82);
((void (__fastcall *)(cocos2d::CCNode *, struct cocos2d::CCPoint))v29->setPosition_0)(v28, v30);
v31 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_ncsLibraryBtn_001.png");
((void (__fastcall *)(struct cocos2d::CCSprite *))v31->setScale_0)(v31);
v32 = CCMenuItemSpriteExtra::create(v31, nullptr, a1, (cocos2d::SEL_MenuHandler *)CustomSongLayer::onNCSBrowser);
v32[1].m_unknown5 = 1067030938;
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, v32);
v33 = v32->__vftable;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v89, (float)(v90 * 0.5) + 105.0, (float)(v91 * 0.5) + 55.0);
v34 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, &v82);
((void (__fastcall *)(cocos2d::CCNode *, struct cocos2d::CCPoint))v33->setPosition_0)(v32, v34);
v35 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_musicLibraryBtn_001.png");
((void (__fastcall *)(struct cocos2d::CCSprite *))v35->setScale_0)(v35);
v36 = CCMenuItemSpriteExtra::create(v35, nullptr, a1, (cocos2d::SEL_MenuHandler *)CustomSongLayer::onMusicBrowser);
v36[1].m_unknown5 = 1067030938;
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, v36);
v37 = v36->__vftable;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v89, v90 * 0.5, (float)(v91 * 0.5) + 55.0);
v38 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, &v82);
((void (__fastcall *)(cocos2d::CCNode *, struct cocos2d::CCPoint))v37->setPosition_0)(v36, v38);
v39 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_ngBtn_001.png");
((void (__fastcall *)(struct cocos2d::CCSprite *))v39->setScale_0)(v39);
v40 = CCMenuItemSpriteExtra::create(
v39,
nullptr,
a1,
(cocos2d::SEL_MenuHandler *)CustomSongLayer::onNewgroundsBrowser);
v40[1].m_unknown5 = 1067030938;
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, v40);
v41 = v40->__vftable;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v89, (float)(v90 * 0.5) - 105.0, (float)(v91 * 0.5) + 55.0);
v42 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, &v82);
((void (__fastcall *)(cocos2d::CCNode *, struct cocos2d::CCPoint))v41->setPosition_0)(v40, v42);
m_songDelegate = a1->m_songDelegate;
if ( m_songDelegate && m_songDelegate->getLevelSettings(m_songDelegate) )
{
v44 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_createLinesBtn_001.png");
v45 = CCMenuItemSpriteExtra::create(v44, nullptr, a1, (cocos2d::SEL_MenuHandler *)CustomSongLayer::onCreateLines);
v28[1].m_unknown5 = 1067030938;
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, v45);
v46 = v45->cocos2d::CCMenuItemSprite::cocos2d::CCMenuItem::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)&v89,
(float)((float)(v90 * 0.5) - 220.0) + 24.0,
(float)((float)((float)(v91 * 0.5) - 145.0) + 24.0) + 2.0);
v47 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, &v82);
((void (__fastcall *)(CCMenuItemSpriteExtra *, struct cocos2d::CCPoint))v46->setPosition_0)(v45, v47);
}
v48 = a1->m_songDelegate;
if ( v48 && v48->getLevelSettings(v48) )
{
v49 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_optionsBtn02_001.png");
((void (__fastcall *)(struct cocos2d::CCSprite *))v49->setScale_0)(v49);
v50 = CCMenuItemSpriteExtra::create(v49, nullptr, a1, (cocos2d::SEL_MenuHandler *)CustomSongLayer::onOptions);
v50[1].m_unknown5 = 0x40000000;
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, v50);
v51 = v50->__vftable;
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)&v89,
(float)((float)(v90 * 0.5) + 220.0) - 27.0,
(float)((float)(v91 * 0.5) + 145.0) - 27.0);
v52 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, &v82);
((void (__fastcall *)(cocos2d::CCNode *, struct cocos2d::CCPoint))v51->setPosition_0)(v50, v52);
}
cocos2d::CCRect::CCRect(v88, 0.0, 0.0, 40.0, 40.0);
cocos2d::CCPoint::CCPoint(&v92, (float)(v90 * 0.5) - 42.0, (float)(v91 * 0.5) - 20.0);
v53 = (struct cocos2d::CCRect *)cocos2d::CCRect::CCRect(&v87, v88);
v54 = cocos2d::extension::CCScale9Sprite::create("square02_small.png", v53);
LOBYTE(v55) = 100;
v54->setOpacity(&v54->cocos2d::CCRGBAProtocol, v55);
cocos2d::CCSize::CCSize(&v83, 210.0, 35.0);
v54->setContentSize(v54, &v83);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v54, -1);
v54->setPosition_0(v54, &v92);
v56 = (struct cocos2d::CCRect *)cocos2d::CCRect::CCRect(&v87, v88);
v57 = cocos2d::extension::CCScale9Sprite::create("square02_small.png", v56);
LOBYTE(v58) = 40;
v57->setOpacity(&v57->cocos2d::CCRGBAProtocol, v58);
cocos2d::CCPoint::CCPoint(&v85, 7.0, 6.0);
cocos2d::CCSize::CCSize(&v86, v83.width - v85.x, v83.height - v85.y);
v57->setContentSize(v57, &v86);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v57, 0);
v57->setPosition_0(v57, &v92);
v60 = CCTextInputNode::create(210.0, 50.0, "Enter song ID", v59, v81, (const char *)&qword_14052A4D8);
a1->m_songIDInput = v60;
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v60, 20);
a1->m_songIDInput->m_delegate = &a1->TextInputDelegate;
cocos2d::CCPoint::CCPoint(&v82, -95.0, 0.0);
cocos2d::CCPoint::operator+(&v92, &v89);
a1->m_songIDInput->setPosition_0(a1->m_songIDInput, (const cocos2d::CCPoint *)&v89);
m_textField = a1->m_songIDInput->m_textField;
v62 = m_textField->cocos2d::CCLabelTTF::cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v89, 0.0, 0.5);
v62->setAnchorPoint(m_textField, v63);
m_textLabel = a1->m_songIDInput->m_textLabel;
v65 = m_textLabel->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v89, 0.0, 0.5);
v65->setAnchorPoint(m_textLabel, v66);
m_songIDInput = a1->m_songIDInput;
m_songIDInput->m_maxLabelScale = 0.69999999;
CCTextInputNode::refreshLabel(m_songIDInput);
v68 = a1->m_songIDInput;
v68->m_maxLabelWidth = 210.0;
CCTextInputNode::refreshLabel(v68);
a1->m_songIDInput->m_textField->setVisible(a1->m_songIDInput->m_textField, 0);
a1->m_songIDInput->m_maxLabelLength = 15;
Src[2] = 11;
Src[3] = 15;
Src[0] = 0x3736353433323130LL;
Src[1] = 2963768;
v89 = (ButtonSprite *)Src;
p_m_allowedChars = &a1->m_songIDInput->m_allowedChars;
if ( p_m_allowedChars != (std::string *)Src )
sub_14003CCE0((void **)p_m_allowedChars, Src, 0xBu);
sub_14003A830((__int64)Src);
LOWORD(v89) = -21896;
v70 = a1->m_songIDInput;
*(_WORD *)&v70->m_placeholderColor.r = -21896;
v70->m_placeholderColor.b = -16;
CCTextInputNode::refreshLabel(v70);
v71 = a1->m_songIDInput;
v71->m_placeholderScale = 0.5;
CCTextInputNode::refreshLabel(v71);
v89 = (ButtonSprite *)operator new(0x2C0u);
v72 = ButtonSprite::ButtonSprite(v89);
if ( v72 )
{
if ( ButtonSprite::init_1(v72, "Search", 50, 0, 0.80000001, 1, "goldFont.fnt", "GJ_button_04.png", 35.0) )
{
cocos2d::CCObject::autorelease(v72);
}
else
{
((void (__fastcall *)(ButtonSprite *, __int64))v72->~ButtonSprite)(v72, 1);
v72 = nullptr;
}
}
v73 = CCMenuItemSpriteExtra::create(v72, nullptr, a1, (cocos2d::SEL_MenuHandler *)CustomSongLayer::onSearch);
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, v73);
cocos2d::CCPoint::CCPoint(&v82, 155.0, 0.0);
cocos2d::CCPoint::operator+(&v92, &v89);
v74 = v73->cocos2d::CCMenuItemSprite::cocos2d::CCMenuItem::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v75 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, &v87.origin);
((void (__fastcall *)(CCMenuItemSpriteExtra *, struct cocos2d::CCPoint))v74->setPosition_0)(v73, v75);
v76 = nullptr;
v77 = a1->m_songDelegate->getActiveSongID(a1->m_songDelegate);
if ( v77 )
v76 = SongInfoObject::create_1(v77);
v78 = CustomSongWidget::create(v76, a1->m_songDelegate, 1, 1, 1, 0, 0, 0, 0);
a1->m_songWidget = v78;
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v78, 2);
v79 = a1->m_songWidget->__vftable;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v89, v90 * 0.5, (float)((float)(v91 * 0.5) - 145.0) + 50.0);
v79->setPosition_0(a1->m_songWidget, v80);
CustomSongWidget::getSongInfoIfUnloaded(a1->m_songWidget);
return 1;
}
return result;
}