//
// BrowseSmartKeyLayer::onButton from 0x14045be50 to 0x14045c26e (1054 bytes)
//
// 5 xrefs:
// > BrowseSmartKeyLayer::init @ 0x14045ba8a
// > BrowseSmartKeyLayer::init @ 0x14045bb37
// > BrowseSmartKeyLayer::init @ 0x14045bbe4
// > BrowseSmartKeyLayer::init @ 0x14045bc91
// > ??> @ 0x1406dabe0
//
// 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=3
void BrowseSmartKeyLayer::onButton(BrowseSmartKeyLayer *a1, cocos2d::CCObject *a2)
{
BrowseSmartKeyLayer *v2; // rdi
int v3; // eax
int v4; // eax
int v5; // eax
cocos2d::CCArray *AllSelectedBlocks; // r14
unsigned int v7; // esi
__int64 p_m_prefabKey; // r15
struct cocos2d::CCObject *v9; // rdi
__int64 v10; // rbx
int v11; // eax
struct cocos2d::CCObject *PrefabWithID; // rax
cocos2d::CCArray *v13; // r15
unsigned int v14; // r14d
__int64 v15; // r12
struct cocos2d::CCObject *v16; // rdi
__int64 v17; // rbx
int v18; // eax
struct cocos2d::CCObject *v19; // rax
unsigned int v20; // esi
cocos2d::CCArray *v21; // r12
unsigned int v22; // esi
struct cocos2d::CCObject *v23; // r15
_BYTE *v24; // rbx
__int64 v25; // r13
int v26; // r14d
cocos2d::CCArray *v27; // rax
cocos2d::CCArray *v28; // rdi
unsigned int v29; // ebx
cocos2d::CCArray *v30; // r15
unsigned int v31; // r14d
__int64 v32; // rdx
__int64 v33; // r8
__int64 v34; // r12
struct cocos2d::CCObject *v35; // rdi
__int64 v36; // rbx
int v37; // eax
BrowseSmartKeyLayer_vtbl *v38; // rbx
cocos2d::CCNode *v39; // rax
char v40[16]; // [rsp+30h] [rbp-48h] BYREF
__int64 v41; // [rsp+40h] [rbp-38h]
__int64 v42; // [rsp+48h] [rbp-30h]
__int128 v43; // [rsp+50h] [rbp-28h] BYREF
__int64 v44; // [rsp+60h] [rbp-18h]
__int64 v45; // [rsp+68h] [rbp-10h]
unsigned int i; // [rsp+C8h] [rbp+50h]
v2 = a1;
v3 = ((__int64 (__fastcall *)(cocos2d::CCObject *))a2->getTag)(a2) - 1;
if ( v3 )
{
v4 = v3 - 1;
if ( v4 )
{
v5 = v4 - 1;
if ( v5 )
{
if ( v5 != 1 )
return;
AllSelectedBlocks = BrowseSmartKeyLayer::getAllSelectedBlocks(v2);
v7 = 0;
if ( cocos2d::CCArray::count(AllSelectedBlocks) )
{
p_m_prefabKey = (__int64)&v2->m_prefabKey;
do
{
v9 = cocos2d::CCArray::objectAtIndex(AllSelectedBlocks, v7);
v10 = sub_14003BDB0((__int64)&v43, p_m_prefabKey);
v11 = v9->getTag(v9);
v2 = a1;
PrefabWithID = GJSmartTemplate::getPrefabWithID((__int64)a1->m_template, v10, v11);
if ( PrefabWithID )
PrefabWithID[2].m_nLuaID += 10;
++v7;
}
while ( v7 < cocos2d::CCArray::count(AllSelectedBlocks) );
}
}
else
{
v13 = BrowseSmartKeyLayer::getAllSelectedBlocks(v2);
v14 = 0;
if ( cocos2d::CCArray::count(v13) )
{
v15 = (__int64)&v2->m_prefabKey;
do
{
v16 = cocos2d::CCArray::objectAtIndex(v13, v14);
v17 = sub_14003BDB0((__int64)&v43, v15);
v18 = v16->getTag(v16);
v2 = a1;
v19 = GJSmartTemplate::getPrefabWithID((__int64)a1->m_template, v17, v18);
if ( v19 )
v19[2].m_nLuaID = 0;
++v14;
}
while ( v14 < cocos2d::CCArray::count(v13) );
}
}
}
else
{
v20 = 0;
for ( i = 0; i < cocos2d::CCArray::count(v2->m_pages); v20 = i )
{
v21 = (cocos2d::CCArray *)cocos2d::CCArray::objectAtIndex(v2->m_pages, v20);
v22 = 0;
while ( v22 < cocos2d::CCArray::count(v21) )
{
v23 = cocos2d::CCArray::objectAtIndex(v21, v22);
v24 = (_BYTE *)((__int64 (__fastcall *)(struct cocos2d::CCObject *))v23->__vftable[13].copyWithZone)(v23);
if ( v24[368] )
{
v25 = sub_14003BDB0((__int64)&v43, (__int64)&v2->m_prefabKey);
v26 = (*(__int64 (__fastcall **)(_BYTE *))(*(_QWORD *)v24 + 56LL))(v24);
if ( v26 > 0 )
{
v27 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(v2->m_template->m_prefabArrays, v25);
v28 = v27;
if ( v27 )
{
if ( cocos2d::CCArray::count(v27) )
{
v29 = 0;
if ( cocos2d::CCArray::count(v28) )
{
while ( cocos2d::CCArray::objectAtIndex(v28, v29)[2].m_uID != v26 )
{
if ( ++v29 >= cocos2d::CCArray::count(v28) )
goto LABEL_28;
}
cocos2d::CCArray::removeObjectAtIndex(v28, v29, 1);
}
}
}
LABEL_28:
v2 = a1;
}
sub_14003A830(v25);
v23->__vftable[7].~CCObject(v23);
cocos2d::CCArray::removeObjectAtIndex(v21, v22, 1);
}
else
{
++v22;
}
}
++i;
}
}
BrowseSmartKeyLayer::updateChanceValues(v2);
}
else
{
v30 = BrowseSmartKeyLayer::getAllSelectedBlocks(v2);
if ( cocos2d::CCArray::count(v30) )
{
v31 = 0;
if ( cocos2d::CCArray::count(v30) )
{
v34 = (__int64)&v2->m_prefabKey;
do
{
v35 = cocos2d::CCArray::objectAtIndex(v30, v31);
v36 = sub_14003BDB0((__int64)&v43, v34);
v37 = v35->getTag(v35);
v2 = a1;
BrowseSmartTemplateLayer::createPrefab((__int64)a1, v36, v37);
++v31;
}
while ( v31 < cocos2d::CCArray::count(v30) );
}
v43 = 0;
v44 = 0;
v45 = 15;
LOBYTE(v43) = 0;
v41 = 15;
v42 = 15;
strcpy(v40, "Added to editor");
v38 = v2->BrowseSmartTemplateLayer::FLAlertLayer::cocos2d::CCLayerColor::cocos2d::CCLayerRGBA::cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v39 = TextAlertPopup::create((__int64)v40, v32, v33, 150, (__int64)&v43);
v38->addChild_0(v2, v39, 100);
}
}
}