//
// PlatformerControlsPopup::onUpload from 0xcfc114 to 0xcfc484 (880 bytes)
//
// 3 xrefs:
// > ??> @ 0x4fe28
// > PlatformerControlsPopup::init @ 0xcfb44c
// > ??> @ 0x1541b08
//
// This function is hookable on this platform (idp: arm, 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 13:06:51 +0000
//
__int64 __fastcall PlatformerControlsPopup::onUpload(PlatformerControlsPopup *this, cocos2d::CCObject *a2)
{
__int64 v3; // x1
GameLevelManager *v4; // x0
__int64 v5; // x1
__int64 v6; // x0
void (__fastcall *v8)(PlatformerControlsPopup *, __int64, __int64); // x23
__int64 v9; // x0
GameLevelManager *v10; // x0
__int64 v11; // x0
__int64 v12; // x1
cocos2d::CCObject *v13; // x24
int v14; // w22
unsigned int v15; // w22
int v16; // w21
__int64 v17; // x0
__int64 v18; // x0
char v19; // w1
__int64 v20; // [xsp+48h] [xbp+48h] BYREF
GameLevelManager *v21; // [xsp+50h] [xbp+50h]
void *v22; // [xsp+58h] [xbp+58h]
__int64 v23[2]; // [xsp+60h] [xbp+60h] BYREF
void *v24; // [xsp+70h] [xbp+70h]
__int64 v25[2]; // [xsp+78h] [xbp+78h] BYREF
void *v26; // [xsp+88h] [xbp+88h]
__int64 v27[2]; // [xsp+90h] [xbp+90h] BYREF
void *v28; // [xsp+A0h] [xbp+A0h]
__int64 v29; // [xsp+A8h] [xbp+A8h] BYREF
GameLevelManager *v30; // [xsp+B0h] [xbp+B0h]
void *v31; // [xsp+B8h] [xbp+B8h]
__int64 v32[2]; // [xsp+C0h] [xbp+C0h] BYREF
void *v33; // [xsp+D0h] [xbp+D0h]
v3 = *((_QWORD *)this + 131);
if ( !v3 || *(_DWORD *)(v3 + 328) - *(_DWORD *)(v3 + 332) <= 0 )
return _stack_chk_guard;
PlatformerControlsPopup::commitCustomDraft(this);
PlatformerControlsPopup::refreshClassUI((LevelControlConfig **)this);
GJGameLevel::shippedControls(*((GJGameLevel **)this + 131), &v20);
if ( (v20 & 1) != 0 )
v4 = v21;
else
v4 = (GameLevelManager *)((unsigned __int8)v20 >> 1);
if ( !v4 )
{
v5 = *(_BYTE *)(*((_QWORD *)this + 131) + 1784LL) >> 1;
if ( (*(_BYTE *)(*((_QWORD *)this + 131) + 1784LL) & 1) != 0 )
v5 = *(_QWORD *)(*((_QWORD *)this + 131) + 1792LL);
if ( v5 )
{
v23[0] = 0;
v23[1] = 0;
v24 = nullptr;
std::string::__init(v23, "Nothing selected. Remove the uploaded controls from this level?", 0x3Fu);
v6 = FLAlertLayer::create(
(__int64)this + 1040,
(cocos2d::CCLabelBMFont *)"Remove Controls",
(char *)v23,
(ButtonSprite *)"Cancel",
(ButtonSprite *)"Remove");
(*(void (__fastcall **)(__int64))(*(_QWORD *)v6 + 1312LL))(v6);
if ( (v23[0] & 1) != 0 )
operator delete(v24);
}
else
{
v8 = *(void (__fastcall **)(PlatformerControlsPopup *, __int64, __int64))(*(_QWORD *)this + 464LL);
v25[0] = 0;
v25[1] = 0;
v26 = nullptr;
std::string::__init(v25, "Nothing selected", 0x10u);
v27[0] = 0;
v27[1] = 0;
v28 = nullptr;
std::string::__init(v27, &byte_11B8890, 0);
v9 = TextAlertPopup::create((char *)v25, 150, (char *)v27, 0.5, 0.6);
v8(this, v9, 100);
if ( (v27[0] & 1) != 0 )
operator delete(v28);
if ( (v25[0] & 1) != 0 )
operator delete(v26);
}
goto LABEL_11;
}
v10 = (GameLevelManager *)GameLevelManager::sharedState(v4);
*((_QWORD *)v10 + 170) = (char *)this + 1016;
v11 = GameLevelManager::sharedState(v10);
v12 = *((_QWORD *)this + 131);
v13 = (cocos2d::CCObject *)v11;
v29 = 0;
LODWORD(v11) = *(_DWORD *)(v12 + 328);
v14 = *(_DWORD *)(v12 + 332);
v30 = nullptr;
v31 = nullptr;
v15 = v11 - v14;
if ( (v20 & 1) != 0 )
{
std::string::__init(&v29, v22, (size_t)v21);
}
else
{
v31 = v22;
v29 = v20;
v30 = v21;
}
v16 = (unsigned __int8)GameLevelManager::uploadLevelControls(v13, v15, (__int64)&v29);
if ( (v29 & 1) != 0 )
{
operator delete(v31);
if ( v16 )
goto LABEL_23;
}
else if ( v16 )
{
LABEL_23:
v17 = *((_QWORD *)this + 149);
if ( v17 )
{
*(_QWORD *)(v17 + 664) = 0;
*((_QWORD *)this + 149) = 0;
}
v32[0] = 0;
v32[1] = 0;
v33 = nullptr;
std::string::__init(v32, "Uploading controls...", 0x15u);
v18 = UploadActionPopup::create((__int64)this + 1024, (char *)v32);
v19 = v32[0];
*((_QWORD *)this + 149) = v18;
if ( (v19 & 1) != 0 )
{
operator delete(v33);
v18 = *((_QWORD *)this + 149);
}
(*(void (__fastcall **)(__int64))(*(_QWORD *)v18 + 1312LL))(v18);
}
LABEL_11:
if ( (v20 & 1) != 0 )
operator delete(v22);
return _stack_chk_guard;
}