//
// BrowseSmartKeyLayer::onButton from 0x1405f1990 to 0x1405f1be3 (595 bytes)
//
// 5 xrefs:
// > BrowseSmartKeyLayer::init @ 0x1405f15b5
// > BrowseSmartKeyLayer::init @ 0x1405f166a
// > BrowseSmartKeyLayer::init @ 0x1405f171f
// > BrowseSmartKeyLayer::init @ 0x1405f17d4
// > ??> @ 0x14092f294
//
// 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:35:06 +0000
//
// Hidden C++ exception states: #wind=1
unsigned int __fastcall BrowseSmartKeyLayer::onButton(__int64 *a1, __int64 a2)
{
int v3; // eax
int v4; // eax
unsigned int result; // eax
cocos2d::CCArray *AllSelectedBlocks; // r12
unsigned int i; // ebp
struct cocos2d::CCObject *v8; // rsi
__int64 v9; // rdi
__int64 v10; // rbx
int v11; // eax
struct cocos2d::CCObject *PrefabWithID; // rax
cocos2d::CCArray *v13; // rbp
unsigned int j; // esi
__int64 v15; // rdx
__int64 v16; // r8
struct cocos2d::CCObject *v17; // rdi
__int64 v18; // rbx
int v19; // eax
__int64 v20; // rbx
cocos2d::CCNode *v21; // rax
char v22[16]; // [rsp+30h] [rbp-68h] BYREF
__int64 v23; // [rsp+40h] [rbp-58h]
__int64 v24; // [rsp+48h] [rbp-50h]
__int128 v25; // [rsp+50h] [rbp-48h] BYREF
__int64 v26; // [rsp+60h] [rbp-38h]
__int64 v27; // [rsp+68h] [rbp-30h]
v3 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)a2 + 56LL))(a2) - 1;
if ( v3 )
{
v4 = v3 - 1;
if ( v4 )
{
result = v4 - 1;
if ( result )
{
if ( result == 1 )
return BrowseSmartKeyLayer::addChanceToSelected(a1, 10, 0);
}
else
{
AllSelectedBlocks = (cocos2d::CCArray *)BrowseSmartKeyLayer::getAllSelectedBlocks(a1);
for ( i = 0; i < cocos2d::CCArray::count(AllSelectedBlocks); ++i )
{
v8 = cocos2d::CCArray::objectAtIndex(AllSelectedBlocks, i);
v9 = sub_14003F4F0((__int64)&v25, (__int64)(a1 + 89));
v10 = a1[83];
v11 = (*(__int64 (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v8 + 56LL))(v8);
PrefabWithID = GJSmartTemplate::getPrefabWithID(v10, v9, v11);
if ( PrefabWithID )
*((_DWORD *)PrefabWithID + 31) = 0;
}
return BrowseSmartKeyLayer::updateChanceValues(a1);
}
}
else
{
return BrowseSmartKeyLayer::deletedSelectedItems(a1);
}
}
else
{
v13 = (cocos2d::CCArray *)BrowseSmartKeyLayer::getAllSelectedBlocks(a1);
result = cocos2d::CCArray::count(v13);
if ( result )
{
for ( j = 0; j < cocos2d::CCArray::count(v13); ++j )
{
v17 = cocos2d::CCArray::objectAtIndex(v13, j);
v18 = sub_14003F4F0((__int64)&v25, (__int64)(a1 + 89));
v19 = (*(__int64 (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v17 + 56LL))(v17);
BrowseSmartTemplateLayer::createPrefab((__int64)a1, v18, v19);
}
v25 = 0;
v26 = 0;
v27 = 15;
LOBYTE(v25) = 0;
v23 = 15;
v24 = 15;
strcpy(v22, "Added to editor");
v20 = *a1;
v21 = TextAlertPopup::create((__int64)v22, v15, v16, 150, (__int64)&v25);
return (*(__int64 (__fastcall **)(__int64 *, cocos2d::CCNode *, __int64))(v20 + 456))(a1, v21, 100);
}
}
return result;
}