//
// LevelPickerPopup::onToggleKind from 0x1400e97f0 to 0x1400e9aac (700 bytes)
//
// 4 xrefs:
// > LevelPickerPopup::init @ 0x1400e961c
// > ??> @ 0x1408937d4
// > ??> @ 0x140893838
// > ??> @ 0x140914df8
//
// 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:26:34 +0000
//
__int64 __fastcall LevelPickerPopup::onToggleKind(__int64 a1)
{
__int64 v1; // rdx
char v3; // bp
__int64 v4; // rcx
__int64 *v5; // r14
const char *v6; // rbx
__int64 v7; // rdi
cocos2d::CCSpriteFrameCache *v8; // rax
struct cocos2d::CCSpriteFrame *v9; // rax
__int64 v10; // rcx
void (__fastcall ***v11)(_QWORD, const char *); // rcx
const char *v12; // rdx
__int64 v13; // rcx
void (__fastcall ***v14)(_QWORD, const char *); // rcx
const char *v15; // rdx
__int64 v16; // rax
_BYTE *v17; // rax
size_t v18; // r8
char v19; // bl
void *v20; // rcx
_QWORD *v21; // rcx
__int64 *v22; // rcx
__int64 v23; // rcx
__int64 v24; // rcx
__int64 v25; // rcx
void *Block[2]; // [rsp+38h] [rbp-40h] BYREF
__int128 v28; // [rsp+48h] [rbp-30h]
v1 = *(unsigned __int8 *)(a1 + 809);
v3 = 0;
*(_BYTE *)(a1 + 1080) = 0;
*(_BYTE *)(a1 + 809) = (_BYTE)v1 == 0;
v4 = *(_QWORD *)(a1 + 816);
if ( v4 )
{
LOBYTE(v1) = (_BYTE)v1 != 0;
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v4 + 336LL))(v4, v1);
}
v5 = *(__int64 **)(a1 + 824);
if ( v5 )
{
v6 = "GJ_viewListsBtn_001.png";
v7 = *v5;
if ( *(_BYTE *)(a1 + 809) )
v6 = "GJ_viewLevelsBtn_001.png";
v8 = (cocos2d::CCSpriteFrameCache *)cocos2d::CCSpriteFrameCache::sharedSpriteFrameCache();
v9 = cocos2d::CCSpriteFrameCache::spriteFrameByName(v8, v6);
(*(void (__fastcall **)(__int64 *, struct cocos2d::CCSpriteFrame *))(v7 + 1008))(v5, v9);
}
v10 = *(_QWORD *)(a1 + 744);
if ( v10 )
{
v11 = (void (__fastcall ***)(_QWORD, const char *))(v10 + 360);
v12 = "Share Level";
if ( *(_BYTE *)(a1 + 809) )
v12 = "Share List";
(**v11)(v11, v12);
}
v13 = *(_QWORD *)(a1 + 920);
if ( v13 )
{
v14 = (void (__fastcall ***)(_QWORD, const char *))(v13 + 360);
v15 = "Showing your online levels";
if ( *(_BYTE *)(a1 + 809) )
v15 = "Showing your online lists";
(**v14)(v14, v15);
}
v16 = *(_QWORD *)(a1 + 912);
if ( !v16 )
goto LABEL_20;
v17 = (_BYTE *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)(*(_QWORD *)(v16 + 592) + 600LL) + 8LL))(*(_QWORD *)(v16 + 592) + 600LL);
*(_OWORD *)Block = 0;
v18 = -1;
v28 = 0;
do
++v18;
while ( v17[v18] );
sub_14003D230(Block, v17, v18);
v3 = 3;
if ( (_QWORD)v28 )
v19 = 1;
else
LABEL_20:
v19 = 0;
if ( (v3 & 1) != 0 && *((_QWORD *)&v28 + 1) > 0xFu )
{
v20 = Block[0];
if ( (unsigned __int64)(*((_QWORD *)&v28 + 1) + 1LL) >= 0x1000 )
{
v20 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v20 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v20);
}
if ( v19 )
{
v21 = *(_QWORD **)(a1 + 912);
*(_QWORD *)&v28 = 0;
*(_OWORD *)Block = 0;
LOBYTE(Block[0]) = 0;
*((_QWORD *)&v28 + 1) = 15;
CCTextInputNode::setString(v21, Block);
}
sub_1400405A0((void **)(a1 + 880), &byte_1406ED6E0, 0);
v22 = *(__int64 **)(a1 + 936);
*(_BYTE *)(a1 + 808) = 0;
*(_DWORD *)(a1 + 680) = 0;
if ( v22 )
ButtonSprite::setString(v22, "Online");
v23 = *(_QWORD *)(a1 + 920);
if ( v23 )
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v23 + 336LL))(v23, 0);
v24 = *(_QWORD *)(a1 + 928);
if ( v24 )
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v24 + 336LL))(v24, 0);
LevelPickerPopup::refreshUseID(a1);
v25 = *(_QWORD *)(a1 + 696);
if ( v25 )
LoadingCircle::fadeAndRemove(v25);
return LevelPickerPopup::buildSavedPage(a1);
}