//
// LevelBrowserLayer::onNew from 0x1402cdba0 to 0x1402cdf69 (969 bytes)
//
// 2 xrefs:
// > LevelBrowserLayer::init @ 0x1402ca2cf
// > ??> @ 0x1406d2d74
//
// 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
void LevelBrowserLayer::onNew(LevelBrowserLayer *a1, cocos2d::CCObject *a2)
{
GJSearchObject *m_searchObject; // rax
__int64 v4; // rbp
GJSmartTemplate *v5; // r13
__int64 v6; // rcx
cocos2d::CCDictionary *v7; // r14
int v8; // esi
__int64 v9; // rdx
__int64 v10; // rcx
struct cocos2d::CCObject *v11; // r12
unsigned int i; // r15d
struct cocos2d::CCObject *v13; // rax
int m_uIndexInArray; // ebx
int v15; // ebx
SetupSmartTemplateLayer *v16; // rax
_QWORD *v17; // rax
GameLevelManager *v18; // rcx
GJLevelList *NewLevelList; // rbx
__int64 v20; // rcx
struct cocos2d::CCScene *v21; // rax
GameLevelManager *v22; // rcx
GJGameLevel *NewLevel; // rbx
__int64 v24; // rcx
struct cocos2d::CCTransitionFade *v25; // rbx
__int64 v26; // rcx
cocos2d::CCDirector *v27; // rax
_QWORD v28[4]; // [rsp+30h] [rbp-68h] BYREF
__int128 v29; // [rsp+50h] [rbp-48h] BYREF
__int64 v30; // [rsp+60h] [rbp-38h]
__int64 v31; // [rsp+68h] [rbp-30h]
void *v32; // [rsp+A0h] [rbp+8h]
void *v33; // [rsp+A0h] [rbp+8h]
void *v34; // [rsp+A0h] [rbp+8h]
void *v35; // [rsp+A0h] [rbp+8h]
void *v36; // [rsp+A0h] [rbp+8h]
m_searchObject = a1->m_searchObject;
if ( !m_searchObject )
goto LABEL_24;
if ( m_searchObject->m_searchType != SmartTemplates )
{
if ( m_searchObject->m_searchType == MyLists )
{
if ( a1->m_isOverlay )
{
v29 = 0;
v30 = 0;
v31 = 15;
LOBYTE(v29) = 0;
v28[1] = 101;
v28[2] = 9;
v28[3] = 15;
v28[0] = 0x6D614E207473694CLL;
v17 = (_QWORD *)ShareCommentLayer::create((unsigned int)v28, 25, 5, 0, (__int64)&v29);
v17[97] = &a1->ShareCommentDelegate;
(*(void (__fastcall **)(_QWORD *))(*v17 + 1040LL))(v17);
return;
}
a1->setKeypadEnabled(a1, 0);
a1->setKeyboardEnabled(a1, 0);
if ( !qword_1406C2EC0 )
{
v33 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v33);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
}
NewLevelList = GameLevelManager::createNewLevelList(v18);
v20 = qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v34 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v34);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v20 = qword_1406C2EC0;
}
*(_BYTE *)(v20 + 712) = 1;
v21 = LevelListLayer::scene(NewLevelList);
goto LABEL_29;
}
LABEL_24:
a1->setKeypadEnabled(a1, 0);
a1->setKeyboardEnabled(a1, 0);
if ( !qword_1406C2EC0 )
{
v35 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v35);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
}
NewLevel = GameLevelManager::createNewLevel(v22);
v24 = qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v36 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v36);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v24 = qword_1406C2EC0;
}
*(_BYTE *)(v24 + 712) = 1;
v21 = EditLevelLayer::scene(NewLevel);
LABEL_29:
v25 = cocos2d::CCTransitionFade::create(0.5, v21);
v27 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v26);
cocos2d::CCDirector::replaceScene(v27, v25);
return;
}
a1->setKeypadEnabled(a1, 0);
a1->setKeyboardEnabled(a1, 0);
v4 = qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v32 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v32);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v4 = qword_1406C2EC0;
}
v5 = GJSmartTemplate::create();
v7 = (cocos2d::CCDictionary *)cocos2d::CCDictionary::create(v6);
v8 = 0;
v11 = (struct cocos2d::CCObject *)cocos2d::CCNode::create(v10, v9);
for ( i = 0; i < cocos2d::CCArray::count(*(cocos2d::CCArray **)(v4 + 952)); v8 = m_uIndexInArray )
{
v13 = cocos2d::CCArray::objectAtIndex(*(cocos2d::CCArray **)(v4 + 952), i);
m_uIndexInArray = v13[3].m_uIndexInArray;
if ( m_uIndexInArray <= v8 )
m_uIndexInArray = v8;
cocos2d::CCDictionary::setObject(v7, v11, v13[3].m_uIndexInArray);
++i;
}
v15 = 1;
while ( cocos2d::CCDictionary::objectForKey(v7, v15) )
{
if ( ++v15 > 1000 )
goto LABEL_14;
}
if ( v15 )
goto LABEL_15;
LABEL_14:
v15 = v8;
LABEL_15:
v5->m_nameIndex = v15;
cocos2d::CCArray::insertObject(*(cocos2d::CCArray **)(v4 + 952), v5, 0);
v16 = SetupSmartTemplateLayer::create(v5);
v16->show(v16);
a1->onBack(a1, nullptr);
}