//
// LevelBrowserLayer::onNew from 0x1403e7d60 to 0x1403e813a (986 bytes)
//
// 2 xrefs:
// > LevelBrowserLayer::init @ 0x1403e3483
// > ??> @ 0x140924fc8
//
// 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:31:44 +0000
//
// Hidden C++ exception states: #wind=6
char __fastcall LevelBrowserLayer::onNew(__int64 a1)
{
__int64 v2; // rax
__int64 v3; // rbp
char *v4; // r13
__int64 v5; // rcx
cocos2d::CCDictionary *v6; // r14
signed int v7; // esi
__int64 v8; // rdx
__int64 v9; // rcx
struct cocos2d::CCObject *v10; // r12
unsigned int i; // r15d
struct cocos2d::CCObject *v12; // rax
signed int v13; // ebx
unsigned int v14; // ebx
__int64 v15; // rax
_QWORD *v17; // rax
struct cocos2d::CCObject *NewLevelList; // rbx
__int64 v19; // rcx
struct cocos2d::CCScene *v20; // rax
__int64 v21; // rdx
__int64 NewLevel; // rbx
__int64 v23; // r8
__int64 v24; // r9
__int64 v25; // rcx
struct cocos2d::CCScene *v26; // rbx
__int64 v27; // rcx
cocos2d::CCDirector *v28; // rax
__int64 v29; // [rsp+30h] [rbp-68h] BYREF
__int64 v30; // [rsp+38h] [rbp-60h]
__int64 v31; // [rsp+40h] [rbp-58h]
__int64 v32; // [rsp+48h] [rbp-50h]
__int128 v33; // [rsp+50h] [rbp-48h] BYREF
__int64 v34; // [rsp+60h] [rbp-38h]
__int64 v35; // [rsp+68h] [rbp-30h]
void *v36; // [rsp+A0h] [rbp+8h]
void *v37; // [rsp+A0h] [rbp+8h]
void *v38; // [rsp+A0h] [rbp+8h]
void *v39; // [rsp+A0h] [rbp+8h]
void *v40; // [rsp+A0h] [rbp+8h]
v2 = *(_QWORD *)(a1 + 664);
if ( !v2 )
goto LABEL_23;
if ( *(_DWORD *)(v2 + 320) != 101 )
{
if ( *(_DWORD *)(v2 + 320) == 102 )
{
if ( *(_BYTE *)(a1 + 748) )
{
v33 = 0;
v34 = 0;
v35 = 15;
LOBYTE(v33) = 0;
v31 = 9;
v32 = 15;
v29 = *(_QWORD *)"List Name";
v30 = (unsigned __int8)aListName[8];
BYTE1(v30) = 0;
v17 = (_QWORD *)ShareCommentLayer::create((unsigned int)&v29, 25, 5, 0, (__int64)&v33);
v17[103] = a1 + 584;
return (*(__int64 (__fastcall **)(_QWORD *))(*v17 + 1064LL))(v17);
}
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)a1 + 992LL))(a1, 0);
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)a1 + 1008LL))(a1, 0);
if ( !*(_QWORD *)&qword_14090BFB0 )
{
v37 = operator new(0x690u);
*(_QWORD *)&qword_14090BFB0 = GameLevelManager::GameLevelManager((__int64)v37);
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)&qword_14090BFB0 + 72LL))(*(_QWORD *)&qword_14090BFB0);
}
NewLevelList = GameLevelManager::createNewLevelList();
v19 = *(_QWORD *)&qword_14090BFB0;
if ( !*(_QWORD *)&qword_14090BFB0 )
{
v38 = operator new(0x690u);
*(_QWORD *)&qword_14090BFB0 = GameLevelManager::GameLevelManager((__int64)v38);
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)&qword_14090BFB0 + 72LL))(*(_QWORD *)&qword_14090BFB0);
v19 = *(_QWORD *)&qword_14090BFB0;
}
*(_BYTE *)(v19 + 1344) = 1;
v20 = (struct cocos2d::CCScene *)LevelListLayer::scene(NewLevelList);
goto LABEL_28;
}
LABEL_23:
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)a1 + 992LL))(a1, 0);
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)a1 + 1008LL))(a1, 0);
if ( !*(_QWORD *)&qword_14090BFB0 )
{
v39 = operator new(0x690u);
*(_QWORD *)&qword_14090BFB0 = GameLevelManager::GameLevelManager((__int64)v39);
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)&qword_14090BFB0 + 72LL))(*(_QWORD *)&qword_14090BFB0);
}
NewLevel = GameLevelManager::createNewLevel();
v25 = *(_QWORD *)&qword_14090BFB0;
if ( !*(_QWORD *)&qword_14090BFB0 )
{
v40 = operator new(0x690u);
*(_QWORD *)&qword_14090BFB0 = GameLevelManager::GameLevelManager((__int64)v40);
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)&qword_14090BFB0 + 72LL))(*(_QWORD *)&qword_14090BFB0);
v25 = *(_QWORD *)&qword_14090BFB0;
}
*(_BYTE *)(v25 + 1344) = 1;
v20 = (struct cocos2d::CCScene *)EditLevelLayer::scene(NewLevel, v21, v23, v24);
LABEL_28:
v26 = cocos2d::CCTransitionFade::create(0.5, v20);
v28 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v27);
return cocos2d::CCDirector::replaceScene(v28, v26);
}
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)a1 + 992LL))(a1, 0);
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)a1 + 1008LL))(a1, 0);
v3 = *(_QWORD *)&qword_14090BFB0;
if ( !*(_QWORD *)&qword_14090BFB0 )
{
v36 = operator new(0x690u);
*(_QWORD *)&qword_14090BFB0 = GameLevelManager::GameLevelManager((__int64)v36);
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)&qword_14090BFB0 + 72LL))(*(_QWORD *)&qword_14090BFB0);
v3 = *(_QWORD *)&qword_14090BFB0;
}
v4 = GJSmartTemplate::create();
v6 = (cocos2d::CCDictionary *)cocos2d::CCDictionary::create(v5);
v7 = 0;
v10 = (struct cocos2d::CCObject *)cocos2d::CCNode::create(v9, v8);
for ( i = 0; i < cocos2d::CCArray::count(*(cocos2d::CCArray **)(v3 + 1656)); v7 = v13 )
{
v12 = cocos2d::CCArray::objectAtIndex(*(cocos2d::CCArray **)(v3 + 1656), i);
v13 = *((_DWORD *)v12 + 50);
if ( v13 <= v7 )
v13 = v7;
cocos2d::CCDictionary::setObject(v6, v10, *((int *)v12 + 50));
++i;
}
v14 = 1;
while ( cocos2d::CCDictionary::objectForKey(v6, v14) )
{
if ( (int)++v14 > 1000 )
goto LABEL_14;
}
v7 = v14;
LABEL_14:
*((_DWORD *)v4 + 50) = v7;
cocos2d::CCArray::insertObject(*(cocos2d::CCArray **)(v3 + 1656), (struct cocos2d::CCObject *)v4, 0);
v15 = SetupSmartTemplateLayer::create(v4);
(*(void (__fastcall **)(__int64))(*(_QWORD *)v15 + 1064LL))(v15);
return (*(__int64 (__fastcall **)(__int64, _QWORD))(*(_QWORD *)a1 + 1056LL))(a1, 0);
}