//
// LevelListLayer::onRefreshLevelList from 0x140306710 to 0x1403068d0 (448 bytes)
//
// 2 xrefs:
// > LevelListLayer::init @ 0x140304538
// > ??> @ 0x1406d449c
//
// 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=4
void LevelListLayer::onRefreshLevelList(LevelListLayer *a1, cocos2d::CCObject *a2)
{
LevelManagerDelegate *v3; // rbx
__int64 v4; // rax
CCMenuItemSpriteExtra *m_refreshBtn; // rcx
GJSearchObject *v6; // rsi
std::string *v7; // rax
__int64 v8; // rbx
std::string *m_bigStorage; // rdx
char *Key; // rax
size_t v11; // r8
std::string *p_m_searchKey2; // rbx
GameLevelManager *v13; // rcx
GameLevelManager *v14; // rcx
__int64 v15[5]; // [rsp+20h] [rbp-28h] BYREF
void *v16; // [rsp+50h] [rbp+8h]
void *v17; // [rsp+50h] [rbp+8h]
void *v18; // [rsp+50h] [rbp+8h]
v3 = &a1->LevelManagerDelegate;
if ( !a1 )
v3 = nullptr;
v4 = qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v16 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v16);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v4 = qword_1406C2EC0;
}
*(_QWORD *)(v4 + 720) = v3;
m_refreshBtn = a1->m_refreshBtn;
if ( m_refreshBtn )
m_refreshBtn->setVisible(m_refreshBtn, 0);
LOBYTE(a2) = 1;
a1->m_circle->setVisible(a1->m_circle, (bool)a2);
LevelBrowserLayer::setupLevelBrowser(a1, nullptr);
v6 = GJSearchObject::create_2((SearchType)0);
v7 = (std::string *)GameToolbox::intToString(v15, a1->m_levelList->m_listID);
v8 = (__int64)v7;
if ( &v6->m_searchQuery != v7 )
{
m_bigStorage = v7;
if ( v7->m_data.m_capacity > 0xF )
m_bigStorage = (std::string *)v7->m_data.m_bigStorage;
sub_14003CCE0((void **)&v6->m_searchQuery, m_bigStorage, v7->m_data.m_size);
}
sub_14003A830(v8);
v6->m_searchMode = 1;
Key = (char *)GJSearchObject::getKey(v6);
v11 = -1;
do
++v11;
while ( Key[v11] );
p_m_searchKey2 = &a1->m_searchKey2;
sub_14003CCE0((void **)&a1->m_searchKey2, Key, v11);
if ( a1->m_searchKey2.m_data.m_capacity > 0xF )
p_m_searchKey2 = (std::string *)p_m_searchKey2->m_data.m_bigStorage;
v13 = (GameLevelManager *)qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v17 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v17);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v13 = (GameLevelManager *)qword_1406C2EC0;
}
GameLevelManager::resetTimerForKey(v13, p_m_searchKey2->m_data.m_smallStorage._Elems);
v14 = (GameLevelManager *)qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v18 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v18);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v14 = (GameLevelManager *)qword_1406C2EC0;
}
GameLevelManager::getLevelLists(v14, v6);
}