//
// SelectArtLayer::init from 0x1403222a0 to 0x140322ee9 (3145 bytes)
//
// 2 xrefs:
// > SelectArtLayer::create @ 0x14032225e
// > ??> @ 0x1406d4cdc
//
// 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=6
bool SelectArtLayer::init(SelectArtLayer *a1, SelectArtType a2, int a3)
{
bool result; // al
_BOOL8 v7; // rdx
__int64 v8; // rcx
__int64 v9; // rax
cocos2d::CCTouchDispatcher *v10; // rax
SelectArtType *p_m_type; // rbx
const char *v12; // rdi
int v13; // r13d
SelectArtType *v14; // r14
_BOOL8 v15; // rdx
__int64 v16; // rcx
cocos2d::CCDirector *v17; // rax
cocos2d::CCLayer *v18; // rax
struct cocos2d::CCRect *v19; // rax
struct cocos2d::extension::CCScale9Sprite *v20; // r12
SelectArtType v21; // edx
int v22; // ecx
float v23; // xmm8_4
SelectArtType *v24; // r15
cocos2d::extension::CCScale9Sprite_vtbl *v25; // rbx
const cocos2d::CCSize *v26; // rax
float v27; // xmm0_4
cocos2d::extension::CCScale9Sprite_vtbl *v28; // rbx
const cocos2d::CCPoint *v29; // rax
struct cocos2d::CCLabelBMFont *v30; // rdi
cocos2d::CCLabelBMFont_vtbl *v31; // rbx
const cocos2d::CCPoint *v32; // rax
__int64 v33; // rcx
SelectArtType *v34; // r12
cocos2d::CCArray *v35; // rax
__int64 v36; // rcx
__int64 v37; // rcx
cocos2d::CCMenu *v38; // rax
int v39; // ebx
float v40; // xmm6_4
float v41; // xmm0_4
int v42; // r15d
int v43; // r14d
float v44; // xmm9_4
SelectArtType v45; // eax
cocos2d::CCString *v46; // rax
const char *CString; // rax
cocos2d::CCString *v48; // rax
cocos2d::CCString *v49; // rax
ObjectToolbox *v50; // rax
struct cocos2d::CCSprite *v51; // rbx
CCMenuItemSpriteExtra *v52; // rdi
float v53; // xmm0_4
ButtonSprite *v54; // rbx
CCMenuItemSpriteExtra *v55; // rdi
float v56; // xmm0_4
CCMenuItemSpriteExtra_vtbl *v57; // rbx
struct cocos2d::CCPoint v58; // rax
BOOL v59; // edi
unsigned int i; // ebx
__int64 v61; // rcx
int *p_m_unknown2; // rcx
void (__fastcall *v63)(int *, int *); // r8
int *v64; // rdx
cocos2d::CCArray *v65; // rax
struct cocos2d::CCLabelBMFont *v66; // r14
float v67; // xmm0_4
cocos2d::CCLabelBMFont_vtbl *v68; // rbx
double v69; // xmm0_8
const cocos2d::CCPoint *v70; // rax
ButtonSprite *v71; // rbx
cocos2d::CCArray **p_m_lineSprites; // r15
CCMenuItemSpriteExtra *v73; // rdi
__int64 v74; // rax
double v75; // xmm0_8
CCMenuItemSpriteExtra_vtbl *v76; // rbx
struct cocos2d::CCPoint v77; // rax
ButtonSprite *v78; // rbx
cocos2d::CCArray **v79; // r12
CCMenuItemSpriteExtra *v80; // rdi
__int64 v81; // rax
double v82; // xmm0_8
CCMenuItemSpriteExtra_vtbl *v83; // rbx
struct cocos2d::CCPoint v84; // rax
ButtonSprite *v85; // rbx
CCMenuItemSpriteExtra *v86; // rdi
__int64 v87; // rax
CCMenuItemSpriteExtra_vtbl *v88; // rbx
struct cocos2d::CCPoint v89; // rax
int v90; // [rsp+58h] [rbp-B0h] BYREF
float v91; // [rsp+60h] [rbp-A8h]
cocos2d::CCSize v92; // [rsp+68h] [rbp-A0h] BYREF
CCMenuItemSpriteExtra *v93; // [rsp+70h] [rbp-98h] BYREF
cocos2d::CCArray *v94; // [rsp+78h] [rbp-90h]
cocos2d::CCRect v95; // [rsp+80h] [rbp-88h] BYREF
struct cocos2d::CCPoint v96[19]; // [rsp+90h] [rbp-78h] BYREF
ButtonSprite *v97; // [rsp+170h] [rbp+68h] BYREF
LODWORD(v97) = -1778384896;
result = cocos2d::CCLayerColor::initWithColor(a1, (const struct cocos2d::_ccColor4B *)&v97);
if ( !result )
return result;
if ( !a1->m_forcePrioRegistered )
{
a1->m_forcePrioRegistered = 1;
v9 = cocos2d::CCDirector::sharedDirector(v8);
v10 = (cocos2d::CCTouchDispatcher *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v9 + 144LL))(v9);
cocos2d::CCTouchDispatcher::registerForcePrio(v10, a1, 2);
}
p_m_type = &a1->m_type;
a1->m_type = a2;
LODWORD(v97) = 1;
if ( a3 != -1 )
{
a1->m_art = a3;
p_m_type = &a1->m_type;
}
if ( a2 == Background )
{
v12 = "Select Background";
v13 = 59;
if ( a1->m_art < 1 )
a1->m_art = 1;
goto LABEL_15;
}
if ( a2 != Ground )
{
LODWORD(v97) = 0;
if ( a2 == Middleground )
{
v12 = "Select Middleground";
v13 = 3;
}
else
{
v12 = "Select Type";
v13 = 11;
}
LABEL_15:
v14 = p_m_type;
goto LABEL_16;
}
v12 = "Select Ground";
v13 = 22;
v14 = p_m_type;
if ( a1->m_art < 1 )
{
a1->m_art = 1;
v14 = &a1->m_type;
}
LABEL_16:
LOBYTE(v7) = 1;
a1->setTouchEnabled(a1, v7);
LOBYTE(v15) = 1;
a1->setKeypadEnabled(a1, v15);
v17 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v16);
cocos2d::CCDirector::getWinSize(v17);
v18 = (cocos2d::CCLayer *)cocos2d::CCLayer::create();
a1->m_mainLayer = v18;
a1->addChild_1(a1, v18);
cocos2d::CCRect::CCRect(&v95, 0.0, 0.0, 80.0, 80.0);
v20 = cocos2d::extension::CCScale9Sprite::create("GJ_square01.png", v19);
v21 = *p_m_type;
v22 = 240;
if ( *p_m_type == Background )
v22 = 300;
v23 = (float)v22;
v24 = v14;
if ( v21 )
{
if ( v21 == Ground )
{
v23 = 260.0;
v24 = &a1->m_type;
}
}
else
{
v23 = 300.0;
}
v25 = v20->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCSize::CCSize(&v92, 360.0, v23);
v25->setContentSize(v20, v26);
v27 = ((float (__fastcall *)(cocos2d::CCLayer *, struct cocos2d::extension::CCScale9Sprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v20,
0xFFFFFFFFLL);
v28 = v20->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(v27, v91 * 0.5);
v28->setPosition_0(v20, v29);
v30 = cocos2d::CCLabelBMFont::create(v12, (const char *)&qword_14052A4D8);
v31 = v30->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(v23 * 0.5, v91 * 0.5);
v31->setPosition_0(v30, v32);
a1->m_mainLayer->addChild_1(a1->m_mainLayer, v30);
((void (__fastcall *)(struct cocos2d::CCLabelBMFont *))v30->setScale_0)(v30);
v34 = v14;
if ( *v14 == Ground )
v34 = v24;
v35 = (cocos2d::CCArray *)cocos2d::CCArray::create(v33);
a1->m_artSprites = v35;
cocos2d::CCObject::retain(v35);
v94 = (cocos2d::CCArray *)cocos2d::CCArray::create(v36);
v38 = (cocos2d::CCMenu *)cocos2d::CCMenu::create(v37);
a1->m_buttonMenu = v38;
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v38, 10);
v39 = 7;
v90 = 7;
v40 = 45.0;
v41 = 25.0;
if ( *v14 == Background )
{
v39 = 10;
v40 = 35.0;
v41 = 75.0;
LABEL_28:
v90 = v39;
goto LABEL_29;
}
if ( *v14 == Ground )
{
v39 = 8;
v40 = 40.0;
v41 = 40.0;
goto LABEL_28;
}
LABEL_29:
cocos2d::CCPoint::CCPoint(v41, v91 * 0.5);
cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, v96);
v42 = (int)v97;
v43 = (int)v97;
v44 = (float)((float)v39 * 0.5) * v40;
do
{
v45 = *v34;
if ( *v34 )
{
if ( v45 == Ground )
{
v48 = cocos2d::CCString::createWithFormat("gIcon_%02d_001.png", v43);
CString = cocos2d::CCString::getCString(v48);
}
else if ( v45 == Middleground )
{
v49 = cocos2d::CCString::createWithFormat("mgIcon_%02d_001.png", v43);
CString = cocos2d::CCString::getCString(v49);
}
else
{
LODWORD(v97) = EditorUI::smartTypeForKey(v43);
v50 = ObjectToolbox::sharedState();
CString = (const char *)sub_1401D0660((__int64 *)&v50->m_allKeys, (int *)&v97);
if ( *((_QWORD *)CString + 3) > 0xFu )
CString = *(const char **)CString;
}
}
else
{
v46 = cocos2d::CCString::createWithFormat("bgIcon_%02d_001.png", v43);
CString = cocos2d::CCString::getCString(v46);
}
v51 = cocos2d::CCSprite::createWithSpriteFrameName(CString);
cocos2d::CCArray::addObject(a1->m_artSprites, v51);
((void (__fastcall *)(struct cocos2d::CCSprite *))v51->setScale_0)(v51);
v93 = (CCMenuItemSpriteExtra *)operator new(0x208u);
v52 = CCMenuItemSpriteExtra::CCMenuItemSpriteExtra(v93);
if ( v52 )
{
if ( CCMenuItemSpriteExtra::init(v52, v51, nullptr, a1, (cocos2d::SEL_MenuHandler *)SelectArtLayer::selectArt) )
{
cocos2d::CCObject::autorelease(v52);
goto LABEL_43;
}
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64))v52->~CCMenuItemSpriteExtra)(v52, 1);
}
v52 = nullptr;
LABEL_43:
v52->setTag(v52, v43);
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, v52);
cocos2d::CCArray::addObject(v94, v52);
v53 = floorf((float)((v43 - v42) / v90)) * (float)-v40;
cocos2d::CCPoint::CCPoint(v53, (float)((float)((float)((v43 - v42) % v90) * v40) - v44) + (float)(v40 * 0.5));
cocos2d::CCPoint::operator+(v96, &v92);
v52->setPosition_0(v52, (const cocos2d::CCPoint *)&v92);
++v43;
}
while ( v43 <= v13 );
a1->m_joystickConnected = -1;
cocos2d::CCArray::removeAllObjects(v94);
v97 = (ButtonSprite *)operator new(0x2C0u);
v54 = ButtonSprite::ButtonSprite(v97);
if ( v54 )
{
if ( ButtonSprite::init_1(v54, "OK", 40, 0, 0.80000001, 1, "goldFont.fnt", "GJ_button_01.png", 30.0) )
{
cocos2d::CCObject::autorelease(v54);
}
else
{
((void (__fastcall *)(ButtonSprite *, __int64))v54->~ButtonSprite)(v54, 1);
v54 = nullptr;
}
}
v97 = (ButtonSprite *)operator new(0x208u);
v55 = CCMenuItemSpriteExtra::CCMenuItemSpriteExtra((CCMenuItemSpriteExtra *)v97);
if ( v55 )
{
if ( CCMenuItemSpriteExtra::init(v55, v54, nullptr, a1, (cocos2d::SEL_MenuHandler *)SelectArtLayer::onClose) )
{
cocos2d::CCObject::autorelease(v55);
goto LABEL_53;
}
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64))v55->~CCMenuItemSpriteExtra)(v55, 1);
}
v55 = nullptr;
LABEL_53:
v56 = ((float (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild_1)(
a1->m_buttonMenu,
v55);
v57 = v55->cocos2d::CCMenuItemSprite::cocos2d::CCMenuItem::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(v56, v91 * 0.5);
v58 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, &v95.origin);
((void (__fastcall *)(CCMenuItemSpriteExtra *, struct cocos2d::CCPoint))v57->setPosition_0)(v55, v58);
v59 = a1->m_type < (unsigned int)Middleground;
for ( i = 0; i < cocos2d::CCArray::count(a1->m_artSprites); ++i )
{
p_m_unknown2 = &cocos2d::CCArray::objectAtIndex(a1->m_artSprites, i)[5].m_unknown2;
v63 = **(void (__fastcall ***)(int *, int *))p_m_unknown2;
if ( a1->m_art == i + v59 )
{
v64 = (int *)&unk_140529B78;
}
else
{
LOWORD(v97) = 32125;
memset(&v90, 125, 3);
v64 = &v90;
}
v63(p_m_unknown2, v64);
}
if ( a1->m_type == Ground )
{
v65 = (cocos2d::CCArray *)cocos2d::CCArray::create(v61);
a1->m_lineSprites = v65;
cocos2d::CCObject::retain(v65);
v66 = cocos2d::CCLabelBMFont::create("Line", "goldFont.fnt");
((void (__fastcall *)(struct cocos2d::CCLabelBMFont *))v66->setScale_0)(v66);
v67 = ((float (__fastcall *)(cocos2d::CCLayer *, struct cocos2d::CCLabelBMFont *))a1->m_mainLayer->addChild_1)(
a1->m_mainLayer,
v66);
v68 = v66->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v69 = cocos2d::CCPoint::CCPoint(v67, (float)(v91 * 0.5) + 130.0);
v68->setPosition_0(v66, v70);
v97 = (ButtonSprite *)operator new(0x2C0u);
v71 = ButtonSprite::ButtonSprite(v97);
p_m_lineSprites = &a1->m_lineSprites;
if ( v71 )
{
if ( ButtonSprite::init_1(
v71,
(const char *)&word_140531EA4,
20,
0,
0.40000001,
1,
(const char *)&qword_14052A4D8,
"GJ_button_04.png",
20.0) )
{
cocos2d::CCObject::autorelease(v71);
}
else
{
((void (__fastcall *)(ButtonSprite *, __int64))v71->~ButtonSprite)(v71, 1);
v71 = nullptr;
}
p_m_lineSprites = &a1->m_lineSprites;
}
v73 = CCMenuItemSpriteExtra::create(v71, nullptr, a1, (cocos2d::SEL_MenuHandler *)SelectArtLayer::onSelectCustom);
v73->setTag(v73, 1);
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, v73);
cocos2d::CCArray::addObject(a1->m_lineSprites, v71);
cocos2d::CCPoint::CCPoint(*(float *)&v69, -23.0);
v74 = (__int64)v66->getPosition_0(v66);
v75 = cocos2d::CCPoint::operator+(v74, &v97);
v76 = v73->cocos2d::CCMenuItemSprite::cocos2d::CCMenuItem::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v77 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, (const struct cocos2d::CCPoint *)&v93);
((void (__fastcall *)(CCMenuItemSpriteExtra *, struct cocos2d::CCPoint))v76->setPosition_0)(v73, v77);
v97 = (ButtonSprite *)operator new(0x2C0u);
v78 = ButtonSprite::ButtonSprite(v97);
v79 = p_m_lineSprites;
if ( v78 )
{
if ( ButtonSprite::init_1(
v78,
(const char *)&word_140531EA0,
20,
0,
0.40000001,
1,
(const char *)&qword_14052A4D8,
"GJ_button_04.png",
20.0) )
{
cocos2d::CCObject::autorelease(v78);
}
else
{
((void (__fastcall *)(ButtonSprite *, __int64))v78->~ButtonSprite)(v78, 1);
v78 = nullptr;
v79 = &a1->m_lineSprites;
}
}
v80 = CCMenuItemSpriteExtra::create(v78, nullptr, a1, (cocos2d::SEL_MenuHandler *)SelectArtLayer::onSelectCustom);
v80->setTag(v80, 2);
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, v80);
cocos2d::CCArray::addObject(*p_m_lineSprites, v78);
cocos2d::CCPoint::CCPoint(*(float *)&v75, 23.0);
v81 = (__int64)v66->getPosition_0(v66);
v82 = cocos2d::CCPoint::operator+(v81, &v97);
v83 = v80->cocos2d::CCMenuItemSprite::cocos2d::CCMenuItem::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v84 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, (const struct cocos2d::CCPoint *)&v93);
((void (__fastcall *)(CCMenuItemSpriteExtra *, struct cocos2d::CCPoint))v83->setPosition_0)(v80, v84);
v97 = (ButtonSprite *)operator new(0x2C0u);
v85 = ButtonSprite::ButtonSprite(v97);
if ( v85 )
{
if ( ButtonSprite::init_1(
v85,
(const char *)&word_140531E9C,
20,
0,
0.40000001,
1,
(const char *)&qword_14052A4D8,
"GJ_button_04.png",
20.0) )
{
cocos2d::CCObject::autorelease(v85);
}
else
{
((void (__fastcall *)(ButtonSprite *, __int64))v85->~ButtonSprite)(v85, 1);
v85 = nullptr;
}
}
v86 = CCMenuItemSpriteExtra::create(v85, nullptr, a1, (cocos2d::SEL_MenuHandler *)SelectArtLayer::onSelectCustom);
v86->setTag(v86, 3);
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, v86);
cocos2d::CCArray::addObject(*v79, v85);
cocos2d::CCPoint::CCPoint(*(float *)&v82, -23.0);
v87 = (__int64)v66->getPosition_0(v66);
cocos2d::CCPoint::operator+(v87, &v97);
v88 = v86->cocos2d::CCMenuItemSprite::cocos2d::CCMenuItem::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v89 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, (const struct cocos2d::CCPoint *)&v93);
((void (__fastcall *)(CCMenuItemSpriteExtra *, struct cocos2d::CCPoint))v88->setPosition_0)(v86, v89);
}
a1->m_noElasticity = 1;
return 1;
}