//
// SelectArtLayer::init from 0x10017c3d8 to 0x10017ccd0 (2296 bytes)
//
// 1 xrefs:
// > SelectArtLayer::create @ 0x10017c0b4
//
// 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
//
bool __fastcall SelectArtLayer::init(SelectArtLayer *a1, SelectArtType a2, int a3)
{
_BOOL4 v6; // w0
__int64 v7; // x21
const char *v8; // x22
int v9; // w28
cocos2d::CCDirector *v10; // x0
cocos2d::CCLayer *v11; // x0
cocos2d::extension::CCScale9Sprite *v12; // x23
SelectArtType m_type; // w8
float v14; // s0
float v15; // s8
__n128 v16; // q0
__n128 v17; // q1
cocos2d::CCLabelBMFont *v18; // x22
__n128 v19; // q0
__n128 v20; // q1
__int64 v21; // x0
SelectArtType v22; // w8
float v23; // s9
cocos2d::CCArray *v24; // x0
__int64 v25; // x0
__int64 v26; // x22
cocos2d::CCMenu *v27; // x0
__n128 v28; // q0
SelectArtType v29; // w8
__n128 v30; // q1
float v31; // s2
float v32; // s3
int v33; // w9
float v34; // s11
unsigned int v35; // w20
cocos2d::CCMenu *m_buttonMenu; // x23
unsigned int v37; // w23
float v38; // s13
SelectArtType v39; // w8
cocos2d::CCString *v40; // x0
const char *CString; // x0
ObjectToolbox *v42; // x27
int v43; // w0
cocos2d::CCSprite *v44; // x27
CCMenuItemSpriteExtra *v45; // x27
__n128 v46; // q0
__n128 v47; // q1
double v48; // d0
ButtonSprite *v49; // x0
CCMenuItemSpriteExtra *v50; // x21
__n128 v51; // q0
cocos2d::CCMenu *v52; // x22
__n128 v53; // q1
__int64 v54; // x0
cocos2d::CCArray *v55; // x0
cocos2d::CCLabelBMFont *v56; // x21
__n128 v57; // q0
__n128 v58; // q1
ButtonSprite *v59; // x25
CCMenuItemSpriteExtra *v60; // x26
__n128 v61; // q0
cocos2d::CCMenu *v62; // x25
float32x2_t *v63; // x27
__n128 v64; // q0
__n128 v65; // q1
ButtonSprite *v66; // x25
CCMenuItemSpriteExtra *v67; // x26
__n128 v68; // q0
cocos2d::CCMenu *v69; // x25
float32x2_t *v70; // x27
__n128 v71; // q0
__n128 v72; // q1
ButtonSprite *v73; // x23
CCMenuItemSpriteExtra *v74; // x22
__n128 v75; // q0
cocos2d::CCMenu *v76; // x23
float32x2_t *v77; // x21
__n128 v78; // q1
__n128 v79; // q0
double v80; // d0
double v81; // d1
bool v83; // [xsp+Ch] [xbp-C4h]
float32x2_t v84; // [xsp+10h] [xbp-C0h] BYREF
float32x2_t v85; // [xsp+18h] [xbp-B8h] BYREF
float32x2_t v86; // [xsp+20h] [xbp-B0h] BYREF
float32x2_t v87[2]; // [xsp+28h] [xbp-A8h] BYREF
float v88; // [xsp+38h] [xbp-98h]
float v89; // [xsp+3Ch] [xbp-94h]
cocos2d::CCPoint v90; // 0:kr08_8.8
cocos2d::CCPoint v91; // 0:kr10_8.8
cocos2d::CCPoint v92; // 0:kr18_8.8
cocos2d::CCPoint v93; // 0:kr20_8.8
cocos2d::CCPoint v94; // 0:kr28_8.8
cocos2d::SEL_MenuHandler v95; // 0:x3.16
cocos2d::SEL_MenuHandler v96; // 0:x3.16
cocos2d::SEL_MenuHandler v97; // 0:x3.16
cocos2d::SEL_MenuHandler v98; // 0:x3.16
cocos2d::SEL_MenuHandler v99; // 0:x3.16
cocos2d::CCRect v100; // 0:s0.4,4:s1.4,8:s2.4,12:s3.4
v87[0].i32[0] = -1778384896;
v6 = cocos2d::CCLayerColor::initWithColor(a1, (const cocos2d::ccColor4B *)v87);
if ( !v6 )
return v6;
v83 = v6;
FLAlertLayer::incrementForcePrio(a1);
a1->m_type = a2;
if ( a3 != -1 )
a1->m_art = a3;
if ( a2 == Middleground )
{
v7 = 0;
v8 = "Select Middleground";
v9 = 4;
}
else if ( a2 == Ground )
{
v7 = 1;
if ( a1->m_art <= 0 )
a1->m_art = 1;
v8 = "Select Ground";
v9 = 23;
}
else if ( a2 )
{
v7 = 0;
v8 = "Select Type";
v9 = 12;
}
else
{
v7 = 1;
if ( a1->m_art <= 0 )
a1->m_art = 1;
v8 = "Select Background";
v9 = 60;
}
((void (__fastcall *)(SelectArtLayer *, __int64))a1->setTouchEnabled)(a1, 1);
((void (__fastcall *)(SelectArtLayer *, __int64))a1->setKeypadEnabled)(a1, 1);
v10 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v10);
v11 = cocos2d::CCLayer::create();
a1->m_mainLayer = v11;
((void (__fastcall *)(SelectArtLayer *, cocos2d::CCLayer *))a1->addChild)(a1, v11);
sub_100022990((float *)v87, 0.0, 0.0, 80.0, 80.0);
v12 = cocos2d::extension::CCScale9Sprite::create("GJ_square01.png", v100);
m_type = a1->m_type;
v14 = 240.0;
if ( m_type == Ground )
v14 = 260.0;
if ( m_type )
v15 = v14;
else
v15 = 300.0;
sub_100022988((float *)v87, 360.0, v15);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, float32x2_t *))v12->setContentSize)(v12, v87);
v16 = ((__n128 (__fastcall *)(cocos2d::CCLayer *, cocos2d::extension::CCScale9Sprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v12,
0xFFFFFFFFLL);
v16.n128_f32[0] = v88 * 0.5;
v17.n128_f32[0] = v89 * 0.5;
sub_100022980(v16, v17, v87);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, float32x2_t *))v12->setPosition)(v12, v87);
v18 = cocos2d::CCLabelBMFont::create_1(v8, "bigFont.fnt");
v19.n128_f32[0] = v88 * 0.5;
v20.n128_f32[0] = (float)((float)(v15 * 0.5) + (float)(v89 * 0.5)) + -20.0;
sub_100022980(v19, v20, v87);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float32x2_t *))v18->setPosition)(v18, v87);
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCLabelBMFont *))a1->m_mainLayer->addChild)(a1->m_mainLayer, v18);
v21 = ((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *, float))v18->setScale)(v18, 0.8);
v22 = a1->m_type;
if ( v22 )
v23 = flt_100638E20[v22 == Ground];
else
v23 = 0.6;
v24 = (cocos2d::CCArray *)sub_10024A15C(v21);
a1->m_artSprites = v24;
cocos2d::CCObject::retain(v24);
v26 = sub_10024A15C(v25);
v27 = cocos2d::CCMenu::create();
a1->m_buttonMenu = v27;
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCMenu *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v27,
10);
v29 = a1->m_type;
v30.n128_u32[0] = 1117126656;
v31 = 25.0;
v32 = 45.0;
if ( v29 == Ground )
{
v31 = 40.0;
v32 = 40.0;
v33 = 8;
}
else
{
v33 = 7;
}
if ( v29 )
{
v30.n128_f32[0] = v31;
v34 = v32;
}
else
{
v34 = 35.0;
}
if ( v29 )
v35 = v33;
else
v35 = 10;
m_buttonMenu = a1->m_buttonMenu;
v28.n128_f32[0] = v88 * 0.5;
v30.n128_f32[0] = v30.n128_f32[0] + (float)((float)(v34 * 0.5) + (float)(v89 * 0.5));
sub_100022980(v28, v30, &v86);
v90 = cocos2d::CCNode::convertToNodeSpace(m_buttonMenu, (const cocos2d::CCPoint *)&v86);
*(float *)&v80 = v90.x;
*(float *)&v81 = v90.y;
v37 = 0;
v38 = vcvts_n_f32_s32(-v35, 1u);
do
{
v39 = a1->m_type;
switch ( v39 )
{
case Middleground:
v40 = (cocos2d::CCString *)sub_100268F4C("mgIcon_%02d_001.png", v80, v81);
goto LABEL_39;
case Ground:
v40 = (cocos2d::CCString *)sub_100268F4C("gIcon_%02d_001.png", v80, v81);
goto LABEL_39;
case Background:
v40 = (cocos2d::CCString *)sub_100268F4C("bgIcon_%02d_001.png", v80, v81);
LABEL_39:
CString = cocos2d::CCString::getCString(v40);
goto LABEL_41;
}
v42 = ObjectToolbox::sharedState();
v43 = EditorUI::smartTypeForKey(v7);
CString = ObjectToolbox::intKeyToFrame(v42, v43);
LABEL_41:
v44 = cocos2d::CCSprite::createWithSpriteFrameName(CString);
sub_10024A2D0(a1->m_artSprites, v44);
((void (__fastcall *)(cocos2d::CCSprite *, float))v44->setScale)(v44, v23);
v95.ptr = (void (__cdecl *)(cocos2d::CCObject *))SelectArtLayer::selectArt;
v95.adj = 0;
v45 = CCMenuItemSpriteExtra::create(v44, nullptr, a1, v95);
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64))v45->setTag)(v45, v7);
((void (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild)(a1->m_buttonMenu, v45);
v46 = sub_10024A2D0(v26, v45);
v46.n128_f32[0] = (float)(v34 * 0.5) + (float)((float)(v34 * (float)(v37 % v35)) + (float)(v38 * v34));
v47.n128_f32[0] = (float)-v34 * (float)(v37 / v35);
sub_100022980(v46, v47, &v85);
*(float32x2_t *)&v48 = sub_1000229DC(v87, &v85, &v86);
((void (__fastcall *)(CCMenuItemSpriteExtra *, float32x2_t *, double))v45->setPosition)(v45, &v86, v48);
v7 = (unsigned int)(v7 + 1);
++v37;
}
while ( v9 != (_DWORD)v7 );
a1->m_joystickConnected = -1;
sub_10024A45C(v26);
v49 = ButtonSprite::create_1("OK", 40, 0, 0.8, 1, "goldFont.fnt", "GJ_button_01.png", 30.0);
v96.ptr = (void (__cdecl *)(cocos2d::CCObject *))SelectArtLayer::onClose;
v96.adj = 0;
v50 = CCMenuItemSpriteExtra::create(v49, nullptr, a1, v96);
v51 = ((__n128 (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild)(
a1->m_buttonMenu,
v50);
v52 = a1->m_buttonMenu;
v51.n128_f32[0] = v88 * 0.5;
v53.n128_f32[0] = (float)((float)(v89 * 0.5) - (float)(v15 * 0.5)) + 25.0;
sub_100022980(v51, v53, &v85);
v91 = cocos2d::CCNode::convertToNodeSpace(v52, (const cocos2d::CCPoint *)&v85);
((void (__fastcall *)(CCMenuItemSpriteExtra *, float32x2_t *, float, float))v50->setPosition)(v50, &v86, v91.x, v91.y);
SelectArtLayer::selectArt(a1, nullptr);
if ( a1->m_type == Ground )
{
v55 = (cocos2d::CCArray *)sub_10024A15C(v54);
a1->m_lineSprites = v55;
cocos2d::CCObject::retain(v55);
v56 = cocos2d::CCLabelBMFont::create_1("Line", "goldFont.fnt");
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float))v56->setScale)(v56, 0.7);
v57 = ((__n128 (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCLabelBMFont *))a1->m_mainLayer->addChild)(
a1->m_mainLayer,
v56);
v57.n128_f32[0] = (float)(v88 * 0.5) + 130.0;
v58.n128_f32[0] = (float)(v89 * 0.5) + -45.0;
sub_100022980(v57, v58, &v86);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float32x2_t *))v56->setPosition)(v56, &v86);
v59 = ButtonSprite::create_1("1", 20, 0, 0.4, 1, "bigFont.fnt", "GJ_button_04.png", 20.0);
v97.ptr = (void (__cdecl *)(cocos2d::CCObject *))SelectArtLayer::onSelectCustom;
v97.adj = 0;
v60 = CCMenuItemSpriteExtra::create(v59, nullptr, a1, v97);
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64))v60->setTag)(v60, 1);
((void (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild)(a1->m_buttonMenu, v60);
v61 = sub_10024A2D0(a1->m_lineSprites, v59);
v62 = a1->m_buttonMenu;
v63 = (float32x2_t *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *, __n128))v56->getPosition)(v56, v61);
v64.n128_u32[0] = -23.0;
v65.n128_u32[0] = -25.0;
sub_100022980(v64, v65, &v84);
sub_1000229DC(v63, &v84, &v85);
v92 = cocos2d::CCNode::convertToNodeSpace(v62, (const cocos2d::CCPoint *)&v85);
((void (__fastcall *)(CCMenuItemSpriteExtra *, float32x2_t *, float, float))v60->setPosition)(
v60,
&v86,
v92.x,
v92.y);
v66 = ButtonSprite::create_1("2", 20, 0, 0.4, 1, "bigFont.fnt", "GJ_button_04.png", 20.0);
v98.ptr = (void (__cdecl *)(cocos2d::CCObject *))SelectArtLayer::onSelectCustom;
v98.adj = 0;
v67 = CCMenuItemSpriteExtra::create(v66, nullptr, a1, v98);
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64))v67->setTag)(v67, 2);
((void (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild)(a1->m_buttonMenu, v67);
v68 = sub_10024A2D0(a1->m_lineSprites, v66);
v69 = a1->m_buttonMenu;
v70 = (float32x2_t *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *, __n128))v56->getPosition)(v56, v68);
v71.n128_u32[0] = 23.0;
v72.n128_u32[0] = -25.0;
sub_100022980(v71, v72, &v84);
sub_1000229DC(v70, &v84, &v85);
v93 = cocos2d::CCNode::convertToNodeSpace(v69, (const cocos2d::CCPoint *)&v85);
((void (__fastcall *)(CCMenuItemSpriteExtra *, float32x2_t *, float, float))v67->setPosition)(
v67,
&v86,
v93.x,
v93.y);
v73 = ButtonSprite::create_1("3", 20, 0, 0.4, 1, "bigFont.fnt", "GJ_button_04.png", 20.0);
v99.ptr = (void (__cdecl *)(cocos2d::CCObject *))SelectArtLayer::onSelectCustom;
v99.adj = 0;
v74 = CCMenuItemSpriteExtra::create(v73, nullptr, a1, v99);
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64))v74->setTag)(v74, 3);
((void (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild)(a1->m_buttonMenu, v74);
v75 = sub_10024A2D0(a1->m_lineSprites, v73);
v76 = a1->m_buttonMenu;
v77 = (float32x2_t *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *, __n128))v56->getPosition)(v56, v75);
v78.n128_u32[0] = -1035468800;
v79.n128_u32[0] = -23.0;
sub_100022980(v79, v78, &v84);
sub_1000229DC(v77, &v84, &v85);
v94 = cocos2d::CCNode::convertToNodeSpace(v76, (const cocos2d::CCPoint *)&v85);
((void (__fastcall *)(CCMenuItemSpriteExtra *, float32x2_t *, float, float))v74->setPosition)(
v74,
&v86,
v94.x,
v94.y);
}
a1->m_noElasticity = 1;
LOBYTE(v6) = v83;
return v6;
}