//
// LevelBrowserLayer::loadPage from 0x4a6490 to 0x4a6c70 (2016 bytes)
//
// 17 xrefs:
// > LevelBrowserLayer::init @ 0x4a7eae
// > LevelBrowserLayer::onGoToLastPage @ 0x4a86ae
// > LevelBrowserLayer::setIDPopupClosed @ 0x4a8708
// > LevelBrowserLayer::setIDPopupClosed @ 0x4a8776
// > LevelBrowserLayer::onNextPage @ 0x4a87b2
// > LevelBrowserLayer::onPrevPage @ 0x4a87dc
// > LevelBrowserLayer::shareCommentClosed @ 0x4a8816
// > LevelBrowserLayer::onRefresh @ 0x4a8876
// > LevelBrowserLayer::onClearSearch @ 0x4a8900
// > LevelBrowserLayer::setTextPopupClosed @ 0x4a896a
// > LevelBrowserLayer::showImportResult @ 0x4a8a2e
// > LevelBrowserLayer::deleteSelected @ 0x4a8b4a
// > LevelBrowserLayer::onSafeMode @ 0x4a8cbe
// > LevelBrowserLayer::reloadPageRows @ 0x4a8d06
// > LevelBrowserLayer::onEnter @ 0x4a943e
// > LevelListLayer::loadLevelsFinished @ 0x6d726a
// > LevelListLayer::init @ 0x6d97cc
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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:49:54 +0000
//
int __fastcall LevelBrowserLayer::loadPage(GJSearchObject **this, GJSearchObject *a2)
{
const char *Key; // r0
char *v5; // r6
size_t v6; // r0
int v7; // r0
LocalLevelManager *v8; // r0
int v9; // r5
LocalLevelManager *v10; // r0
LocalLevelManager *v11; // r0
GameLevelManager *v12; // r0
bool v13; // r1
GameLevelManager *v14; // r0
GameLevelManager *v15; // r0
cocos2d::CCArray *CreatedLevels; // r0
cocos2d::CCArray *ItemsMatchingSearch; // r6
int v18; // r7
cocos2d::CCArray *v19; // r0
GameManager *v20; // r11
int v21; // r7
GameManager *v22; // r0
int v23; // r9
int v24; // r7
unsigned int v25; // r0
float v26; // r0
unsigned int i; // r8
cocos2d::CCObject *v28; // r0
void (__fastcall *v29)(GJSearchObject **, _BYTE *, char *); // r8
int v30; // r0
unsigned int v31; // r8
_BOOL4 v32; // r1
char *v33; // r2
char *v34; // r2
cocos2d::CCDirector *v35; // r0
_DWORD *v36; // r5
int *v37; // r6
int v38; // r0
GameLevelManager *v39; // r0
char *v40; // r1
const char *NextPageKey; // r0
int StoredOnlineLevels; // r1
GameLevelManager *v43; // r0
GameLevelManager *v44; // r7
void (__fastcall *v45)(GJSearchObject **, int *, char *); // r8
GameLevelManager *v46; // r0
char *v47; // r1
const char *PageInfo; // r9
size_t v49; // r0
char *v50; // r2
char *v51; // r2
GameLevelManager *v52; // r0
GameLevelManager *v53; // r0
GameLevelManager *v54; // r0
GameLevelManager *v55; // r0
GameLevelManager *v56; // r0
int v57; // r7
size_t v58; // r0
int v59; // r7
size_t v60; // r0
int v62; // r5
void (__fastcall *v63)(int, int); // r6
int v64; // r1
int v65; // [sp+14h] [bp-E8h]
float v66[2]; // [sp+24h] [bp-D8h] BYREF
char v67[8]; // [sp+2Ch] [bp-D0h] BYREF
char v68[4]; // [sp+34h] [bp-C8h] BYREF
int v69; // [sp+38h] [bp-C4h]
char *v70; // [sp+3Ch] [bp-C0h]
int v71[3]; // [sp+40h] [bp-BCh] BYREF
int v72[3]; // [sp+4Ch] [bp-B0h] BYREF
_BYTE v73[12]; // [sp+58h] [bp-A4h] BYREF
int v74[3]; // [sp+64h] [bp-98h] BYREF
int v75[3]; // [sp+70h] [bp-8Ch] BYREF
int v76[3]; // [sp+7Ch] [bp-80h] BYREF
int v77[3]; // [sp+88h] [bp-74h] BYREF
int v78[3]; // [sp+94h] [bp-68h] BYREF
int v79[3]; // [sp+A0h] [bp-5Ch] BYREF
int v80[3]; // [sp+ACh] [bp-50h] BYREF
int v81[3]; // [sp+B8h] [bp-44h] BYREF
int v82[3]; // [sp+C4h] [bp-38h] BYREF
int v83[3]; // [sp+D0h] [bp-2Ch] BYREF
int v84[3]; // [sp+DCh] [bp-20h] BYREF
int v85[3]; // [sp+E8h] [bp-14h] BYREF
LevelBrowserLayer::setSearchObject(this, a2);
Key = (const char *)GJSearchObject::getKey(*(this + 125));
*(_DWORD *)v68 = 0;
v69 = 0;
v70 = nullptr;
v5 = (char *)Key;
v6 = strlen(Key);
std::string::__init((int *)v68, v5, v6);
(*(void (__fastcall **)(_DWORD, int))(*(_DWORD *)*(this + 135) + 172))(*(this + 135), 1);
v7 = (int)*(this + 123);
if ( v7 )
(*(void (__fastcall **)(int, _DWORD))(*(_DWORD *)v7 + 172))(v7, 0);
v8 = *(this + 122);
if ( v8 )
v8 = (LocalLevelManager *)(*(int (__fastcall **)(LocalLevelManager *, _DWORD))(*(_DWORD *)v8 + 172))(v8, 0);
if ( !*((_BYTE *)this + 560) )
v8 = (LocalLevelManager *)(*(int (__fastcall **)(_DWORD))(*(_DWORD *)*(this + 120) + 172))(*(this + 120));
v9 = *((_DWORD *)*(this + 125) + 66);
if ( (unsigned int)(v9 - 98) <= 1 )
{
if ( v9 == 98 )
{
v10 = (LocalLevelManager *)LocalLevelManager::sharedState(v8);
CreatedLevels = (cocos2d::CCArray *)LocalLevelManager::getCreatedLevels(v10, *((_DWORD *)*(this + 125) + 83));
goto LABEL_20;
}
v12 = (GameLevelManager *)GameLevelManager::sharedState(v8);
v13 = 0;
LABEL_19:
CreatedLevels = (cocos2d::CCArray *)GameLevelManager::getSavedLevels(v12, v13, *((_DWORD *)a2 + 83));
goto LABEL_20;
}
switch ( v9 )
{
case 'f':
v11 = (LocalLevelManager *)LocalLevelManager::sharedState(v8);
CreatedLevels = (cocos2d::CCArray *)LocalLevelManager::getCreatedLists(v11, *((_DWORD *)*(this + 125) + 83));
goto LABEL_20;
case 'd':
v12 = (GameLevelManager *)GameLevelManager::sharedState(v8);
v13 = 1;
goto LABEL_19;
case 'e':
v14 = (GameLevelManager *)GameLevelManager::sharedState(v8);
CreatedLevels = (cocos2d::CCArray *)GameLevelManager::getAllSmartTemplates(v14);
goto LABEL_20;
case 'g':
v15 = (GameLevelManager *)GameLevelManager::sharedState(v8);
CreatedLevels = (cocos2d::CCArray *)GameLevelManager::getSavedLevelLists(v15, *((_DWORD *)a2 + 83));
LABEL_20:
ItemsMatchingSearch = CreatedLevels;
std::string::basic_string(v71, (int)*(this + 125) + 268);
if ( (v71[0] & 1) != 0 )
v18 = v71[1];
else
v18 = (int)LOBYTE(v71[0]) >> 1;
v19 = (cocos2d::CCArray *)std::string::~string((int)v71);
if ( v18 )
{
std::string::basic_string(v72, (int)a2 + 268);
ItemsMatchingSearch = LevelBrowserLayer::getItemsMatchingSearch((int)this, (int)ItemsMatchingSearch, (int)v72);
std::string::~string((int)v72);
v19 = *(this + 122);
if ( v19 )
v19 = (cocos2d::CCArray *)(*(int (__fastcall **)(cocos2d::CCArray *, int))(*(_DWORD *)v19 + 172))(v19, 1);
}
v20 = (GameManager *)cocos2d::CCArray::create(v19);
v21 = *((_DWORD *)*(this + 125) + 76);
v22 = (GameManager *)GameManager::sharedState(v20);
if ( GameManager::getGameVariable(v22, "0093") )
v23 = 20;
else
v23 = 10;
v65 = cocos2d::CCArray::count(ItemsMatchingSearch);
v24 = v23 * v21;
v25 = cocos2d::CCArray::count(ItemsMatchingSearch);
v26 = ceilf((float)v25 / (float)v23);
*(this + 136) = (GJSearchObject *)(int)(float)(v26 - 1.0);
if ( ItemsMatchingSearch )
{
v26 = COERCE_FLOAT(cocos2d::CCArray::count(ItemsMatchingSearch));
if ( v26 != 0.0 )
{
for ( i = v24; (int)i < v24 + v23; ++i )
{
LODWORD(v26) = cocos2d::CCArray::count(ItemsMatchingSearch) - 1;
if ( i > LODWORD(v26) )
break;
v28 = (cocos2d::CCObject *)cocos2d::CCArray::objectAtIndex(ItemsMatchingSearch, i);
v26 = COERCE_FLOAT(cocos2d::CCArray::addObject(v20, v28));
}
}
}
if ( !*((_BYTE *)this + 560) )
{
v31 = cocos2d::CCArray::count(v20) + v24;
v32 = v31 < cocos2d::CCArray::count(ItemsMatchingSearch);
v26 = COERCE_FLOAT((*(int (__fastcall **)(_DWORD, _BOOL4))(*(_DWORD *)*(this + 119) + 172))(*(this + 119), v32));
}
v29 = *((void (__fastcall **)(GJSearchObject **, _BYTE *, char *))*this + 165);
v30 = GameLevelManager::sharedState((GameLevelManager *)LODWORD(v26));
GameLevelManager::createPageInfo((GameLevelManager *)v73, v30, v65, v24);
if ( (v68[0] & 1) != 0 )
v33 = v70;
else
v33 = &v68[1];
v29(this, v73, v33);
std::string::~string((int)v73);
v5 = *((char **)*this + 163);
if ( (v68[0] & 1) != 0 )
v34 = v70;
else
v34 = &v68[1];
((void (__fastcall *)(GJSearchObject **, GameManager *, char *, int, int))v5)(this, v20, v34, v9, v23);
v35 = *(this + 126);
if ( *(this + 132) )
{
if ( v35 )
v35 = (cocos2d::CCDirector *)(*(int (__fastcall **)(cocos2d::CCDirector *, int))(*(_DWORD *)v35 + 172))(
v35,
1);
}
else
{
if ( v35 )
v35 = (cocos2d::CCDirector *)(*(int (__fastcall **)(cocos2d::CCDirector *))(*(_DWORD *)v35 + 172))(v35);
cocos2d::CCDirector::sharedDirector(v35);
cocos2d::CCDirector::getWinSize((cocos2d::CCDirector *)v66);
if ( v9 == 99 )
{
memset(v74, 0, sizeof(v74));
std::string::__init(v74, " ", 1u);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v67, 0.5, 1.0);
v36 = (_DWORD *)TextArea::create(
(int)v74,
"bigFont.fnt",
1065353216,
1142292480,
(const cocos2d::CCPoint *)v67,
1101004800,
0,
0);
std::string::~string((int)v74);
v37 = v75;
v36[136] = 1109393408;
memset(v75, 0, sizeof(v75));
std::string::__init(v75, "You have not downloaded any levels yet!", 0x37u);
TextArea::setString((int)v36, v75);
}
else if ( v9 == 103 )
{
memset(v76, 0, sizeof(v76));
std::string::__init(v76, " ", 1u);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v67, 0.5, 1.0);
v36 = (_DWORD *)TextArea::create(
(int)v76,
"bigFont.fnt",
1065353216,
1142292480,
(const cocos2d::CCPoint *)v67,
1101004800,
0,
0);
std::string::~string((int)v76);
v37 = v77;
v36[136] = 1109393408;
memset(v77, 0, sizeof(v77));
std::string::__init(v77, "You have not favorited\nany lists yet!", 0x35u);
TextArea::setString((int)v36, v77);
}
else if ( v9 == 100 )
{
memset(v78, 0, sizeof(v78));
std::string::__init(v78, " ", 1u);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v67, 0.5, 1.0);
v36 = (_DWORD *)TextArea::create(
(int)v78,
"bigFont.fnt",
1065353216,
1142292480,
(const cocos2d::CCPoint *)v67,
1101004800,
0,
0);
std::string::~string((int)v78);
v37 = v79;
v36[136] = 1109393408;
memset(v79, 0, sizeof(v79));
std::string::__init(v79, "Levels marked as Favorite will show up here!", 0x34u);
TextArea::setString((int)v36, v79);
}
else
{
if ( v9 == 98 )
{
v37 = v80;
memset(v80, 0, sizeof(v80));
std::string::__init(v80, "Tap New to create a level!", 0x2Au);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v67, 0.5, 1.0);
v38 = TextArea::create(
(int)v80,
"bigFont.fnt",
1065353216,
1142292480,
(const cocos2d::CCPoint *)v67,
1101004800,
0,
0);
}
else if ( v9 == 102 )
{
v37 = v81;
memset(v81, 0, sizeof(v81));
std::string::__init(v81, "Tap New to create a list!", 0x29u);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v67, 0.5, 1.0);
v38 = TextArea::create(
(int)v81,
"bigFont.fnt",
1065353216,
1142292480,
(const cocos2d::CCPoint *)v67,
1101004800,
0,
0);
}
else
{
v37 = v82;
memset(v82, 0, sizeof(v82));
std::string::__init(v82, "Tap New to create a Template!", 0x2Du);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v67, 0.5, 1.0);
v38 = TextArea::create(
(int)v82,
"bigFont.fnt",
1065353216,
1142292480,
(const cocos2d::CCPoint *)v67,
1101004800,
0,
0);
}
v36 = (_DWORD *)v38;
}
std::string::~string((int)v37);
v5 = *(char **)(*v36 + 92);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v67, v66[0] * 0.5, (float)(v66[1] * 0.5) + 10.0);
((void (__fastcall *)(_DWORD *, char *))v5)(v36, v67);
(*(void (__fastcall **)(_DWORD *, int))(*v36 + 80))(v36, 1058642330);
v35 = (cocos2d::CCDirector *)(*((int (__fastcall **)(GJSearchObject **, _DWORD *))*this + 57))(this, v36);
}
goto LABEL_88;
}
if ( !*((_BYTE *)this + 560) )
{
v5 = (char *)GameLevelManager::sharedState(v8);
NextPageKey = (const char *)GJSearchObject::getNextPageKey(*(this + 125));
StoredOnlineLevels = GameLevelManager::getStoredOnlineLevels((GameLevelManager *)v5, NextPageKey);
v8 = (LocalLevelManager *)(*(int (__fastcall **)(_DWORD, bool))(*(_DWORD *)*(this + 119) + 172))(
*(this + 119),
StoredOnlineLevels != 0);
}
v39 = (GameLevelManager *)GameLevelManager::sharedState(v8);
if ( (v68[0] & 1) != 0 )
v40 = v70;
else
v40 = &v68[1];
v43 = (GameLevelManager *)GameLevelManager::getStoredOnlineLevels(v39, v40);
v44 = v43;
if ( v43 )
{
v45 = *((void (__fastcall **)(GJSearchObject **, int *, char *))*this + 165);
v46 = (GameLevelManager *)GameLevelManager::sharedState(v43);
if ( (v68[0] & 1) != 0 )
v47 = v70;
else
v47 = &v68[1];
PageInfo = (const char *)GameLevelManager::getPageInfo(v46, v47);
memset(v83, 0, sizeof(v83));
v49 = strlen(PageInfo);
std::string::__init(v83, PageInfo, v49);
if ( (v68[0] & 1) != 0 )
v50 = v70;
else
v50 = &v68[1];
v45(this, v83, v50);
std::string::~string((int)v83);
v5 = *((char **)*this + 163);
if ( (v68[0] & 1) != 0 )
v51 = v70;
else
v51 = &v68[1];
v35 = (cocos2d::CCDirector *)((int (__fastcall *)(GJSearchObject **, GameLevelManager *, char *, int))v5)(
this,
v44,
v51,
v9);
}
else
{
if ( !*((_BYTE *)this + 580) )
v43 = (GameLevelManager *)LevelBrowserLayer::setupLevelBrowser(
(LevelBrowserLayer *)this,
(cocos2d::CCArray *)*((unsigned __int8 *)this + 580));
v52 = (GameLevelManager *)GameLevelManager::sharedState(v43);
*((_DWORD *)v52 + 205) = this + 110;
if ( v9 == 14 )
{
v53 = (GameLevelManager *)GameLevelManager::sharedState(v52);
GameLevelManager::getUsers(v53, a2);
}
else if ( v9 == 9 )
{
v54 = (GameLevelManager *)GameLevelManager::sharedState(v52);
GameLevelManager::getMapPacks(v54, a2);
}
else if ( *((_DWORD *)*(this + 125) + 86) == 1 )
{
v55 = (GameLevelManager *)GameLevelManager::sharedState(v52);
GameLevelManager::getLevelLists(v55, a2);
}
else
{
v56 = (GameLevelManager *)GameLevelManager::sharedState(v52);
GameLevelManager::getOnlineLevels(v56, a2);
}
v35 = *(this + 126);
if ( v35 )
v35 = (cocos2d::CCDirector *)(*(int (__fastcall **)(cocos2d::CCDirector *, const char *))(*(_DWORD *)v35 + 464))(
v35,
" ");
}
LABEL_88:
if ( !*((_BYTE *)this + 548) )
{
v57 = GameLevelManager::sharedState(v35);
if ( (v68[0] & 1) == 0 )
v5 = &v68[1];
v84[0] = 0;
if ( (v68[0] & 1) != 0 )
v5 = v70;
v84[1] = 0;
v84[2] = 0;
v58 = strlen(v5);
std::string::__init(v84, v5, v58);
std::string::operator=((unsigned __int8 *)(v57 + 784), (unsigned __int8 *)v84);
v35 = (cocos2d::CCDirector *)std::string::~string((int)v84);
}
if ( *((_DWORD *)*(this + 125) + 66) == 9 )
{
v59 = GameLevelManager::sharedState(v35);
if ( (v68[0] & 1) == 0 )
v5 = &v68[1];
v85[0] = 0;
if ( (v68[0] & 1) != 0 )
v5 = v70;
v85[1] = 0;
v85[2] = 0;
v60 = strlen(v5);
std::string::__init(v85, v5, v60);
std::string::operator=((unsigned __int8 *)(v59 + 796), (unsigned __int8 *)v85);
std::string::~string((int)v85);
}
if ( !*((_BYTE *)this + 560) )
{
v62 = (int)*(this + 128);
v63 = *(void (__fastcall **)(int, int))(*(_DWORD *)v62 + 172);
v64 = (*(int (__fastcall **)(_DWORD))(*(_DWORD *)*(this + 119) + 176))(*(this + 119));
if ( !v64 )
v64 = (*(int (__fastcall **)(_DWORD))(*(_DWORD *)*(this + 120) + 176))(*(this + 120));
v63(v62, v64);
}
return std::string::~string((int)v68);
}