//
// GJColorSetupLayer::init from 0x140256090 to 0x1402568e1 (2129 bytes)
//
// 2 xrefs:
// > GJColorSetupLayer::create @ 0x140256041
// > ??> @ 0x1406cf954
//
// 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 GJColorSetupLayer::init(GJColorSetupLayer *a1, LevelSettingsObject *a2)
{
bool result; // al
__int64 v5; // rcx
cocos2d::CCDirector *v6; // rax
struct cocos2d::CCRect *v7; // rax
struct cocos2d::extension::CCScale9Sprite *v8; // rdi
__int64 v9; // rdx
cocos2d::extension::CCScale9Sprite_vtbl *v10; // rbx
const cocos2d::CCSize *v11; // rax
float v12; // xmm0_4
cocos2d::extension::CCScale9Sprite_vtbl *v13; // rbx
const cocos2d::CCPoint *v14; // rax
__int64 v15; // rcx
cocos2d::CCDictionary *v16; // rax
__int64 v17; // rcx
cocos2d::CCDictionary *v18; // rax
__int64 v19; // rcx
cocos2d::CCArray *v20; // rax
__int64 v21; // rcx
cocos2d::CCArray *v22; // rax
__int64 v23; // rcx
cocos2d::CCMenu *v24; // rax
struct cocos2d::CCLabelBMFont *v25; // rdi
float v26; // xmm0_4
cocos2d::CCLabelBMFont_vtbl *v27; // rbx
const cocos2d::CCPoint *v28; // rax
double v29; // xmm0_8
int v30; // r15d
struct cocos2d::CCLabelBMFont *v31; // r14
float v32; // xmm0_4
ColorChannelSprite *v33; // rbx
CCMenuItemSpriteExtra *v34; // rax
cocos2d::CCObject *v35; // rdi
float v36; // xmm0_4
__int64 v37; // rax
cocos2d::CCObject_vtbl *v38; // rbx
struct cocos2d::CCPoint v39; // rax
struct cocos2d::CCSprite *v40; // rdi
CCMenuItemSpriteExtra *v41; // rax
CCMenuItemSpriteExtra *v42; // rbx
float v43; // xmm0_4
cocos2d::CCSprite *v44; // rdi
CCMenuItemSpriteExtra *v45; // rax
CCMenuItemSpriteExtra *v46; // rbx
float v47; // xmm0_4
ButtonSprite *v48; // rbx
CCMenuItemSpriteExtra *v49; // rdi
float v50; // xmm0_4
CCMenuItemSpriteExtra_vtbl *v51; // rbx
struct cocos2d::CCPoint v52; // rax
_BOOL8 v53; // rdx
_BOOL8 v54; // rdx
char v55[8]; // [rsp+58h] [rbp-69h] BYREF
cocos2d::CCPoint v56; // [rsp+60h] [rbp-61h] BYREF
cocos2d::CCSize v57; // [rsp+68h] [rbp-59h] BYREF
CCMenuItemSpriteExtra *v58; // [rsp+78h] [rbp-49h]
struct cocos2d::CCPoint v59; // [rsp+80h] [rbp-41h] BYREF
cocos2d::CCRect v60[6]; // [rsp+88h] [rbp-39h] BYREF
float v61; // [rsp+138h] [rbp+77h]
struct cocos2d::CCPoint v62; // [rsp+140h] [rbp+7Fh] BYREF
result = FLAlertLayer::init_1(a1, 150);
if ( result )
{
a1->m_noElasticity = 1;
a1->m_settingsObject = a2;
cocos2d::CCObject::retain(a2);
v6 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v5);
cocos2d::CCDirector::getWinSize(v6);
cocos2d::CCRect::CCRect(v60, 0.0, 0.0, 80.0, 80.0);
v8 = cocos2d::extension::CCScale9Sprite::create("GJ_square01.png", v7);
LOBYTE(v9) = -1;
v8->setOpacity(&v8->cocos2d::CCRGBAProtocol, v9);
v10 = v8->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCSize::CCSize(&v57, 450.0, 300.0);
v10->setContentSize(v8, v11);
v12 = ((float (__fastcall *)(cocos2d::CCLayer *, struct cocos2d::extension::CCScale9Sprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v8,
4294967294LL);
v13 = v8->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(v12, v61 * 0.5);
v13->setPosition_0(v8, v14);
v16 = (cocos2d::CCDictionary *)cocos2d::CCDictionary::create(v15);
a1->m_unk290 = v16;
cocos2d::CCObject::retain(v16);
v18 = (cocos2d::CCDictionary *)cocos2d::CCDictionary::create(v17);
a1->m_unk298 = v18;
cocos2d::CCObject::retain(v18);
v20 = (cocos2d::CCArray *)cocos2d::CCArray::create(v19);
a1->m_colorLabels = v20;
cocos2d::CCObject::retain(v20);
v22 = (cocos2d::CCArray *)cocos2d::CCArray::create(v21);
a1->m_colorSprites = v22;
cocos2d::CCObject::retain(v22);
a1->m_colorsPerPage = 24;
a1->m_totalPages = 42;
v24 = (cocos2d::CCMenu *)cocos2d::CCMenu::create(v23);
a1->m_buttonMenu = v24;
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v24, 10);
v25 = cocos2d::CCLabelBMFont::create("Select Custom Color:", "goldFont.fnt");
((void (__fastcall *)(struct cocos2d::CCLabelBMFont *))v25->setScale_0)(v25);
v26 = ((float (__fastcall *)(cocos2d::CCLayer *, struct cocos2d::CCLabelBMFont *))a1->m_mainLayer->addChild_1)(
a1->m_mainLayer,
v25);
v27 = v25->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(v26, v61 * 0.5);
v27->setPosition_0(v25, v28);
v29 = cocos2d::CCPoint::CCPoint(v61 * 0.5, (float)(v61 * 0.5) - 132.5);
v30 = 1;
if ( a1->m_colorsPerPage >= 1 )
{
while ( 1 )
{
v31 = cocos2d::CCLabelBMFont::create(" ", (const char *)&qword_14052A4D8);
((void (__fastcall *)(struct cocos2d::CCLabelBMFont *))v31->setScale_0)(v31);
a1->m_mainLayer->addChild_1(a1->m_mainLayer, v31);
cocos2d::CCArray::addObject(a1->m_colorLabels, v31);
v32 = floorf((float)((v30 - 1) / 6));
cocos2d::CCPoint::CCPoint(v32, (float)((v30 - 1) % 6) * 53.0);
cocos2d::CCPoint::operator+(v55, &v56);
v31->setPosition_0(v31, &v56);
v33 = ColorChannelSprite::create();
((void (__fastcall *)(ColorChannelSprite *))v33->setScale_0)(v33);
v33->setColor(&v33->cocos2d::CCRGBAProtocol, (const cocos2d::ccColor3B *)&unk_140529A9C);
cocos2d::CCArray::addObject(a1->m_colorSprites, v33);
v58 = (CCMenuItemSpriteExtra *)operator new(0x208u);
v34 = CCMenuItemSpriteExtra::CCMenuItemSpriteExtra(v58);
v35 = v34;
if ( !v34 )
goto LABEL_7;
if ( !CCMenuItemSpriteExtra::init(v34, v33, nullptr, a1, (cocos2d::SEL_MenuHandler *)GJColorSetupLayer::onColor) )
break;
cocos2d::CCObject::autorelease(v35);
LABEL_8:
v36 = ((float (__fastcall *)(cocos2d::CCMenu *, cocos2d::CCObject *))a1->m_buttonMenu->addChild_1)(
a1->m_buttonMenu,
v35);
cocos2d::CCPoint::CCPoint(v36, 0.0);
v37 = (__int64)v31->getPosition_0(v31);
v29 = cocos2d::CCPoint::operator+(v37, &v57);
v38 = v35->__vftable;
v39 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, &v60[0].origin);
((void (__fastcall *)(cocos2d::CCObject *, struct cocos2d::CCPoint))v38[2].encodeWithCoder)(v35, v39);
v35->setTag(v35, v30++);
if ( v30 > a1->m_colorsPerPage )
goto LABEL_9;
}
((void (__fastcall *)(cocos2d::CCObject *, __int64))v35->~CCObject)(v35, 1);
LABEL_7:
v35 = nullptr;
goto LABEL_8;
}
LABEL_9:
GJColorSetupLayer::updateSpriteColors(a1);
cocos2d::CCPoint::CCPoint(*(float *)&v29, v61 * 0.5);
cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, &v62);
v40 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_01_001.png");
((void (__fastcall *)(struct cocos2d::CCSprite *))v40->setScale_0)(v40);
v60[0].origin = (cocos2d::CCPoint)operator new(0x208u);
v41 = CCMenuItemSpriteExtra::CCMenuItemSpriteExtra(*(CCMenuItemSpriteExtra **)&v60[0].origin);
v42 = v41;
if ( v41 )
{
if ( CCMenuItemSpriteExtra::init(v41, v40, nullptr, a1, (cocos2d::SEL_MenuHandler *)GJColorSetupLayer::onPage) )
{
cocos2d::CCObject::autorelease(v42);
goto LABEL_14;
}
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64))v42->~CCMenuItemSpriteExtra)(v42, 1);
}
v42 = nullptr;
LABEL_14:
a1->m_prevButton = v42;
v43 = ((float (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild_1)(
a1->m_buttonMenu,
v42);
cocos2d::CCPoint::CCPoint(v43, -190.0);
cocos2d::CCPoint::operator+(&v62, &v57);
a1->m_prevButton->setPosition_0(a1->m_prevButton, (const cocos2d::CCPoint *)&v57);
HIDWORD(a1->m_prevButton->m_pfnSelector.adj) = 0x40000000;
a1->m_prevButton->setTag(a1->m_prevButton, 1);
v44 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_01_001.png");
((void (__fastcall *)(cocos2d::CCSprite *))v44->setScale_0)(v44);
cocos2d::CCSprite::setFlipX(v44, 1);
v60[0].origin = (cocos2d::CCPoint)operator new(0x208u);
v45 = CCMenuItemSpriteExtra::CCMenuItemSpriteExtra(*(CCMenuItemSpriteExtra **)&v60[0].origin);
v46 = v45;
if ( v45 )
{
if ( CCMenuItemSpriteExtra::init(v45, v44, nullptr, a1, (cocos2d::SEL_MenuHandler *)GJColorSetupLayer::onPage) )
{
cocos2d::CCObject::autorelease(v46);
goto LABEL_19;
}
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64))v46->~CCMenuItemSpriteExtra)(v46, 1);
}
v46 = nullptr;
LABEL_19:
a1->m_nextButton = v46;
v47 = ((float (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild_1)(
a1->m_buttonMenu,
v46);
cocos2d::CCPoint::CCPoint(v47, 190.0);
cocos2d::CCPoint::operator+(&v62, &v57);
a1->m_nextButton->setPosition_0(a1->m_nextButton, (const cocos2d::CCPoint *)&v57);
HIDWORD(a1->m_nextButton->m_pfnSelector.adj) = 0x40000000;
a1->m_nextButton->setTag(a1->m_nextButton, 0);
v60[0].origin = (cocos2d::CCPoint)operator new(0x2C0u);
v48 = ButtonSprite::ButtonSprite(*(ButtonSprite **)&v60[0].origin);
if ( v48 )
{
if ( ButtonSprite::init_1(v48, "OK", 40, 0, 0.80000001, 1, "goldFont.fnt", "GJ_button_01.png", 30.0) )
{
cocos2d::CCObject::autorelease(v48);
}
else
{
((void (__fastcall *)(ButtonSprite *, __int64))v48->~ButtonSprite)(v48, 1);
v48 = nullptr;
}
}
v60[0].origin = (cocos2d::CCPoint)operator new(0x208u);
v49 = CCMenuItemSpriteExtra::CCMenuItemSpriteExtra(*(CCMenuItemSpriteExtra **)&v60[0].origin);
if ( v49 )
{
if ( CCMenuItemSpriteExtra::init(v49, v48, nullptr, a1, (cocos2d::SEL_MenuHandler *)GJColorSetupLayer::onClose) )
{
cocos2d::CCObject::autorelease(v49);
LABEL_28:
v50 = ((float (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild_1)(
a1->m_buttonMenu,
v49);
v51 = v49->cocos2d::CCMenuItemSprite::cocos2d::CCMenuItem::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(v50, v61 * 0.5);
v52 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, &v59);
((void (__fastcall *)(CCMenuItemSpriteExtra *, struct cocos2d::CCPoint))v51->setPosition_0)(v49, v52);
LODWORD(v51) = a1->m_settingsObject->m_colorPage;
a1->m_page = (int)v51;
LOBYTE(v53) = (_DWORD)v51 != 0;
a1->m_prevButton->setVisible(a1->m_prevButton, v53);
LOBYTE(v54) = (_DWORD)v51 != a1->m_totalPages - 1;
a1->m_nextButton->setVisible(a1->m_nextButton, v54);
a1->m_settingsObject->m_colorPage = (int)v51;
GJColorSetupLayer::updateSpriteColors(a1);
return 1;
}
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64))v49->~CCMenuItemSpriteExtra)(v49, 1);
}
v49 = nullptr;
goto LABEL_28;
}
return result;
}