//
// SelectArtLayer::init from 0x14045b500 to 0x14045c0a3 (2979 bytes)
//
// 2 xrefs:
// > SelectArtLayer::create @ 0x14045b4bc
// > ??> @ 0x140927ce0
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:32:32 +0000
//
// Hidden C++ exception states: #wind=6
bool __fastcall SelectArtLayer::init(__int64 a1, int a2, int a3)
{
bool result; // al
__int64 v7; // rdx
int *v8; // rbx
const char *v9; // rdi
int v10; // r13d
int *v11; // r14
__int64 v12; // rdx
__int64 v13; // rcx
__int64 v14; // rax
__int64 v15; // rax
__int64 v16; // rax
__int64 *v17; // r12
int v18; // edx
int v19; // ecx
float v20; // xmm9_4
int *v21; // r15
__int64 v22; // rbx
__int64 v23; // rax
__int64 v24; // rbx
__int64 v25; // rax
struct cocos2d::CCLabelBMFont *v26; // rdi
__int64 v27; // rbx
__int64 v28; // rax
__int64 v29; // rcx
int *v30; // r12
cocos2d::CCObject *v31; // rax
__int64 v32; // rcx
__int64 v33; // rcx
__int64 v34; // rax
int v35; // edi
float v36; // xmm6_4
float v37; // xmm0_4
__int64 v38; // rbx
__int64 v39; // rax
int v40; // r15d
int v41; // r14d
float v42; // xmm10_4
int v43; // eax
cocos2d::CCString *v44; // rax
const char *CString; // rax
cocos2d::CCString *v46; // rax
cocos2d::CCString *v47; // rax
__int64 v48; // rcx
__int64 v49; // rax
struct cocos2d::CCObject *v50; // rbx
cocos2d::CCObject *v51; // rdi
float v52; // xmm0_4
__int64 v53; // rax
cocos2d::CCObject *v54; // rbx
cocos2d::CCObject *v55; // r14
__int64 v56; // rdi
__int64 v57; // rbx
__int64 v58; // rax
__int64 v59; // rax
__int64 v60; // rcx
cocos2d::CCObject *v61; // rax
struct cocos2d::CCLabelBMFont *v62; // r14
__int64 v63; // rbx
__int64 v64; // rax
cocos2d::CCObject *v65; // rbx
cocos2d::CCArray **v66; // r15
cocos2d::CCObject *v67; // rdi
__int64 v68; // rax
__int64 v69; // rbx
__int64 v70; // rax
__int64 v71; // rbx
__int64 v72; // rax
cocos2d::CCObject *v73; // rbx
cocos2d::CCArray **v74; // r12
cocos2d::CCObject *v75; // rdi
__int64 v76; // rax
__int64 v77; // rbx
__int64 v78; // rax
__int64 v79; // rbx
__int64 v80; // rax
cocos2d::CCObject *v81; // rbx
cocos2d::CCObject *v82; // rdi
__int64 v83; // rax
__int64 v84; // rbx
__int64 v85; // rax
__int64 v86; // rbx
__int64 v87; // rax
int v88; // [rsp+58h] [rbp-B0h]
float v89; // [rsp+60h] [rbp-A8h] BYREF
float v90; // [rsp+64h] [rbp-A4h]
cocos2d::CCArray *v91; // [rsp+68h] [rbp-A0h]
_BYTE v92[8]; // [rsp+70h] [rbp-98h] BYREF
__int64 v93; // [rsp+78h] [rbp-90h] BYREF
void *v94; // [rsp+80h] [rbp-88h] BYREF
_BYTE v95[144]; // [rsp+88h] [rbp-80h] BYREF
void *v96; // [rsp+160h] [rbp+58h] BYREF
LODWORD(v96) = -1778384896;
result = cocos2d::CCLayerColor::initWithColor((cocos2d::CCLayerColor *)a1, (const struct cocos2d::_ccColor4B *)&v96);
if ( !result )
return result;
FLAlertLayer::incrementForcePrio((struct cocos2d::CCObject *)a1);
v8 = (int *)(a1 + 688);
*(_DWORD *)(a1 + 688) = a2;
LODWORD(v96) = 1;
if ( a3 != -1 )
{
*(_DWORD *)(a1 + 680) = a3;
v8 = (int *)(a1 + 688);
}
if ( !a2 )
{
v9 = "Select Background";
v10 = 59;
if ( *(int *)(a1 + 680) < 1 )
*(_DWORD *)(a1 + 680) = 1;
goto LABEL_13;
}
if ( a2 != 1 )
{
LODWORD(v96) = 0;
if ( a2 == 2 )
{
v9 = "Select Middleground";
v10 = 3;
}
else
{
v9 = "Select Type";
v10 = 11;
}
LABEL_13:
v11 = v8;
goto LABEL_14;
}
v9 = "Select Ground";
v10 = 22;
v11 = v8;
if ( *(int *)(a1 + 680) < 1 )
{
*(_DWORD *)(a1 + 680) = 1;
v11 = (int *)(a1 + 688);
}
LABEL_14:
LOBYTE(v7) = 1;
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 920LL))(a1, v7);
LOBYTE(v12) = 1;
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 992LL))(a1, v12);
v14 = cocos2d::CCDirector::sharedDirector(v13);
cocos2d::CCDirector::getWinSize(v14, &v89);
v15 = cocos2d::CCLayer::create();
*(_QWORD *)(a1 + 584) = v15;
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 464LL))(a1, v15);
cocos2d::CCRect::CCRect((cocos2d::CCRect *)v95, 0.0, 0.0, 80.0, 80.0);
v17 = (__int64 *)cocos2d::extension::CCScale9Sprite::create("GJ_square01.png", v16);
v18 = *v8;
v19 = 240;
if ( !*v8 )
v19 = 300;
v20 = (float)v19;
v21 = v11;
if ( v18 )
{
if ( v18 == 1 )
{
v20 = 260.0;
v21 = (int *)(a1 + 688);
}
}
else
{
v20 = 300.0;
}
v22 = *v17;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v93, 360.0, v20);
(*(void (__fastcall **)(__int64 *, __int64))(v22 + 312))(v17, v23);
(*(void (__fastcall **)(_QWORD, __int64 *, __int64))(**(_QWORD **)(a1 + 584) + 456LL))(
*(_QWORD *)(a1 + 584),
v17,
0xFFFFFFFFLL);
v24 = *v17;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v93, v89 * 0.5, v90 * 0.5);
(*(void (__fastcall **)(__int64 *, __int64))(v24 + 184))(v17, v25);
v26 = cocos2d::CCLabelBMFont::create(v9, (const char *)&qword_140704F78);
v27 = *(_QWORD *)v26;
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)&v93,
v89 * 0.5,
(float)((float)(v90 * 0.5) + (float)(v20 * 0.5)) - 20.0);
(*(void (__fastcall **)(struct cocos2d::CCLabelBMFont *, __int64))(v27 + 184))(v26, v28);
(*(void (__fastcall **)(_QWORD, struct cocos2d::CCLabelBMFont *))(**(_QWORD **)(a1 + 584) + 464LL))(
*(_QWORD *)(a1 + 584),
v26);
(*(void (__fastcall **)(struct cocos2d::CCLabelBMFont *))(*(_QWORD *)v26 + 160LL))(v26);
v30 = v11;
if ( *v11 == 1 )
v30 = v21;
v31 = (cocos2d::CCObject *)cocos2d::CCArray::create(v29);
*(_QWORD *)(a1 + 664) = v31;
cocos2d::CCObject::retain(v31);
v91 = (cocos2d::CCArray *)cocos2d::CCArray::create(v32);
v34 = cocos2d::CCMenu::create(v33);
*(_QWORD *)(a1 + 552) = v34;
(*(void (__fastcall **)(_QWORD, __int64, __int64))(**(_QWORD **)(a1 + 584) + 456LL))(*(_QWORD *)(a1 + 584), v34, 10);
v35 = 7;
v88 = 7;
v36 = 45.0;
v37 = 25.0;
if ( !*v11 )
{
v35 = 10;
v36 = 35.0;
v37 = 75.0;
LABEL_26:
v88 = v35;
goto LABEL_27;
}
if ( *v11 == 1 )
{
v35 = 8;
v36 = 40.0;
v37 = 40.0;
goto LABEL_26;
}
LABEL_27:
v38 = *(_QWORD *)(a1 + 552);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v93, v89 * 0.5, (float)((float)(v90 * 0.5) + (float)(v36 * 0.5)) + v37);
cocos2d::CCNode::convertToNodeSpace(v38, v92, v39);
v40 = (int)v96;
v41 = (int)v96;
v42 = (float)((float)v35 * 0.5) * v36;
do
{
v43 = *v30;
if ( *v30 )
{
if ( v43 == 1 )
{
v46 = cocos2d::CCString::createWithFormat("gIcon_%02d_001.png", v41);
CString = cocos2d::CCString::getCString(v46);
}
else if ( v43 == 2 )
{
v47 = cocos2d::CCString::createWithFormat("mgIcon_%02d_001.png", v41);
CString = cocos2d::CCString::getCString(v47);
}
else
{
LODWORD(v96) = EditorUI::smartTypeForKey(v41);
v49 = ObjectToolbox::sharedState(v48);
CString = (const char *)sub_1402D6130((__int64 *)(v49 + 320), (int *)&v96);
if ( *((_QWORD *)CString + 3) > 0xFu )
CString = *(const char **)CString;
}
}
else
{
v44 = cocos2d::CCString::createWithFormat("bgIcon_%02d_001.png", v41);
CString = cocos2d::CCString::getCString(v44);
}
v50 = cocos2d::CCSprite::createWithSpriteFrameName(CString);
cocos2d::CCArray::addObject(*(cocos2d::CCArray **)(a1 + 664), v50);
(*(void (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v50 + 160LL))(v50);
v94 = operator new(0x208u);
v51 = (cocos2d::CCObject *)CCMenuItemSpriteExtra::CCMenuItemSpriteExtra((__int64)v94);
if ( v51 )
{
if ( CCMenuItemSpriteExtra::init((__int64 *)v51, (__int64 *)v50, 0, a1, (__int64)SelectArtLayer::selectArt) )
{
cocos2d::CCObject::autorelease(v51);
goto LABEL_41;
}
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v51 + 8LL))(v51, 1);
}
v51 = nullptr;
LABEL_41:
(*(void (__fastcall **)(cocos2d::CCObject *, _QWORD))(*(_QWORD *)v51 + 64LL))(v51, (unsigned int)v41);
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v51);
cocos2d::CCArray::addObject(v91, v51);
v52 = floorf((float)((v41 - v40) / v88)) * (float)-v36;
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)v95,
(float)((float)((float)((v41 - v40) % v88) * v36) - v42) + (float)(v36 * 0.5),
v52);
cocos2d::CCPoint::operator+(v92, &v93, v53);
(*(void (__fastcall **)(cocos2d::CCObject *, __int64 *))(*(_QWORD *)v51 + 184LL))(v51, &v93);
++v41;
}
while ( v41 <= v10 );
*(_DWORD *)(a1 + 640) = -1;
cocos2d::CCArray::removeAllObjects(v91);
v96 = operator new(0x2C8u);
v54 = (cocos2d::CCObject *)ButtonSprite::ButtonSprite((__int64)v96);
if ( v54 )
{
if ( ButtonSprite::init_1(
(__int64)v54,
(__int64)"OK",
40,
0,
1061997773,
1,
"goldFont.fnt",
(__int64)"GJ_button_01.png",
1106247680) )
{
cocos2d::CCObject::autorelease(v54);
}
else
{
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v54 + 8LL))(v54, 1);
v54 = nullptr;
}
}
v96 = operator new(0x208u);
v55 = (cocos2d::CCObject *)CCMenuItemSpriteExtra::CCMenuItemSpriteExtra((__int64)v96);
if ( v55 )
{
if ( CCMenuItemSpriteExtra::init((__int64 *)v55, (__int64 *)v54, 0, a1, (__int64)SelectArtLayer::onClose) )
{
cocos2d::CCObject::autorelease(v55);
goto LABEL_51;
}
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v55 + 8LL))(v55, 1);
}
v55 = nullptr;
LABEL_51:
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v55);
v56 = *(_QWORD *)v55;
v57 = *(_QWORD *)(a1 + 552);
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)&v96,
v89 * 0.5,
(float)((float)(v90 * 0.5) - (float)(v20 * 0.5)) + 25.0);
cocos2d::CCNode::convertToNodeSpace(v57, v95, v58);
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(v56 + 184))(v55, v59);
SelectArtLayer::selectArt(a1, 0);
if ( *(_DWORD *)(a1 + 688) == 1 )
{
v61 = (cocos2d::CCObject *)cocos2d::CCArray::create(v60);
*(_QWORD *)(a1 + 672) = v61;
cocos2d::CCObject::retain(v61);
v62 = cocos2d::CCLabelBMFont::create("Line", "goldFont.fnt");
(*(void (__fastcall **)(struct cocos2d::CCLabelBMFont *))(*(_QWORD *)v62 + 160LL))(v62);
(*(void (__fastcall **)(_QWORD, struct cocos2d::CCLabelBMFont *))(**(_QWORD **)(a1 + 584) + 464LL))(
*(_QWORD *)(a1 + 584),
v62);
v63 = *(_QWORD *)v62;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v96, (float)(v89 * 0.5) + 130.0, (float)(v90 * 0.5) - 45.0);
(*(void (__fastcall **)(struct cocos2d::CCLabelBMFont *, __int64))(v63 + 184))(v62, v64);
v96 = operator new(0x2C8u);
v65 = (cocos2d::CCObject *)ButtonSprite::ButtonSprite((__int64)v96);
v66 = (cocos2d::CCArray **)(a1 + 672);
if ( v65 )
{
if ( ButtonSprite::init_1(
(__int64)v65,
(__int64)&word_14070D060,
20,
0,
1053609165,
1,
&qword_140704F78,
(__int64)"GJ_button_04.png",
1101004800) )
{
cocos2d::CCObject::autorelease(v65);
}
else
{
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v65 + 8LL))(v65, 1);
v65 = nullptr;
}
v66 = (cocos2d::CCArray **)(a1 + 672);
}
v67 = CCMenuItemSpriteExtra::create((int)v65, 0, a1, (__int64)SelectArtLayer::onSelectCustom);
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v67 + 64LL))(v67, 1);
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v67);
cocos2d::CCArray::addObject(*(cocos2d::CCArray **)(a1 + 672), v65);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v95, -23.0, -25.0);
v69 = v68;
v70 = (*(__int64 (__fastcall **)(struct cocos2d::CCLabelBMFont *))(*(_QWORD *)v62 + 200LL))(v62);
cocos2d::CCPoint::operator+(v70, &v96, v69);
v71 = *(_QWORD *)v67;
cocos2d::CCNode::convertToNodeSpace(*(_QWORD *)(a1 + 552), &v94, &v96);
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(v71 + 184))(v67, v72);
v96 = operator new(0x2C8u);
v73 = (cocos2d::CCObject *)ButtonSprite::ButtonSprite((__int64)v96);
v74 = v66;
if ( v73 )
{
if ( ButtonSprite::init_1(
(__int64)v73,
(__int64)&word_14070D058,
20,
0,
1053609165,
1,
&qword_140704F78,
(__int64)"GJ_button_04.png",
1101004800) )
{
cocos2d::CCObject::autorelease(v73);
}
else
{
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v73 + 8LL))(v73, 1);
v73 = nullptr;
v74 = (cocos2d::CCArray **)(a1 + 672);
}
}
v75 = CCMenuItemSpriteExtra::create((int)v73, 0, a1, (__int64)SelectArtLayer::onSelectCustom);
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v75 + 64LL))(v75, 2);
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v75);
cocos2d::CCArray::addObject(*v66, v73);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v95, 23.0, -25.0);
v77 = v76;
v78 = (*(__int64 (__fastcall **)(struct cocos2d::CCLabelBMFont *))(*(_QWORD *)v62 + 200LL))(v62);
cocos2d::CCPoint::operator+(v78, &v96, v77);
v79 = *(_QWORD *)v75;
cocos2d::CCNode::convertToNodeSpace(*(_QWORD *)(a1 + 552), &v94, &v96);
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(v79 + 184))(v75, v80);
v96 = operator new(0x2C8u);
v81 = (cocos2d::CCObject *)ButtonSprite::ButtonSprite((__int64)v96);
if ( v81 )
{
if ( ButtonSprite::init_1(
(__int64)v81,
(__int64)&word_14070D054,
20,
0,
1053609165,
1,
&qword_140704F78,
(__int64)"GJ_button_04.png",
1101004800) )
{
cocos2d::CCObject::autorelease(v81);
}
else
{
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v81 + 8LL))(v81, 1);
v81 = nullptr;
}
}
v82 = CCMenuItemSpriteExtra::create((int)v81, 0, a1, (__int64)SelectArtLayer::onSelectCustom);
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v82 + 64LL))(v82, 3);
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v82);
cocos2d::CCArray::addObject(*v74, v81);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v95, -23.0, -50.0);
v84 = v83;
v85 = (*(__int64 (__fastcall **)(struct cocos2d::CCLabelBMFont *))(*(_QWORD *)v62 + 200LL))(v62);
cocos2d::CCPoint::operator+(v85, &v96, v84);
v86 = *(_QWORD *)v82;
cocos2d::CCNode::convertToNodeSpace(*(_QWORD *)(a1 + 552), &v94, &v96);
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(v86 + 184))(v82, v87);
}
*(_BYTE *)(a1 + 596) = 1;
return 1;
}