//
// UploadPopup::init from 0x100281aa0 to 0x100281f9c (1276 bytes)
//
// 1 xrefs:
// > UploadPopup::create @ 0x100281890
//
// 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
//
bool __fastcall UploadPopup::init(UploadPopup *a1, GJGameLevel *a2)
{
bool result; // al
bool v4; // r13
cocos2d::CCLayer *v5; // rax
cocos2d::extension::CCScale9Sprite *v6; // r14
double v7; // xmm0_8
GJGameLevel *m_level; // rax
std::string *p_m_levelName; // rax
const char *v10; // rdi
cocos2d::CCLabelBMFont *v11; // r14
cocos2d::CCMenu *v12; // rax
TextArea *m_textArea; // rax
TextArea *v14; // r14
LoadingCircle *v15; // rax
cocos2d::CCSprite *m_sprite; // r14
TextArea *v17; // rdi
GameLevelManager *v18; // rax
cocos2d::CCSprite *v19; // rax
CCMenuItemSpriteExtra *v20; // rax
CCMenuItemSpriteExtra *m_backButton; // r14
cocos2d::CCMenu *m_buttonMenu; // rbx
cocos2d::CCDirector *v23; // rax
cocos2d::CCDirector *v24; // rax
double v25; // xmm0_8
_BYTE v26[8]; // [rsp+0h] [rbp-90h] BYREF
_QWORD v27[2]; // [rsp+8h] [rbp-88h] BYREF
void *v28; // [rsp+18h] [rbp-78h]
void *v29[3]; // [rsp+20h] [rbp-70h] BYREF
float v30; // [rsp+3Ch] [rbp-54h]
__int128 v31; // [rsp+40h] [rbp-50h] BYREF
void *__p; // [rsp+50h] [rbp-40h]
float v33; // [rsp+60h] [rbp-30h] BYREF
float v34; // [rsp+64h] [rbp-2Ch]
double v35; // 0:xmm0_8.8
double v36; // 0:xmm0_8.8
cocos2d::CCRect v37; // 0:xmm0_8.8,8:xmm1_8.8
LODWORD(v31) = -1778384896;
result = cocos2d::CCLayerColor::initWithColor(a1, (const cocos2d::ccColor4B *)&v31);
if ( !result )
return result;
v4 = result;
FLAlertLayer::incrementForcePrio(a1);
a1->m_level = a2;
cocos2d::CCObject::retain(a2);
((void (__fastcall *)(UploadPopup *, __int64))a1->setTouchEnabled)(a1, 1);
((void (__fastcall *)(UploadPopup *, __int64))a1->setKeypadEnabled)(a1, 1);
cocos2d::CCDirector::sharedDirector();
*(cocos2d::CCSize *)&v35 = cocos2d::CCDirector::getWinSize((cocos2d::CCDirector *)&v33);
v5 = cocos2d::CCLayer::create();
a1->m_mainLayer = v5;
((void (__fastcall *)(UploadPopup *, cocos2d::CCLayer *, double))a1->addChild)(a1, v5, v35);
v37.origin = 0;
v37.size = 0;
sub_10028CC00(&v31, 0.0, 0.0, 80.0, 80.0);
v6 = cocos2d::extension::CCScale9Sprite::create_2("square04_001.png", v37);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, __int64))v6->setOpacity)(v6, 255);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, void *))v6->setColor)(v6, &unk_1008189C4);
sub_10028CBF0(&v31, 420.0, 300.0);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, __int128 *))v6->setContentSize)(v6, &v31);
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::extension::CCScale9Sprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v6,
0xFFFFFFFFLL);
*(_QWORD *)&v7 = LODWORD(v33);
*(float *)&v7 = v33 * 0.5;
sub_10028CBE0(&v31, v33 * 0.5, v34 * 0.5);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, __int128 *))v6->setPosition)(v6, &v31);
m_level = a1->m_level;
if ( (m_level->m_levelName.m_data.m_short.sizex2 & 1) != 0 )
{
sub_100006B70(&v31, m_level->m_levelName.m_data.m_long.longStorage, m_level->m_levelName.m_data.m_long.size, v7);
if ( (v31 & 1) == 0 )
goto LABEL_4;
LABEL_6:
v10 = (const char *)__p;
goto LABEL_7;
}
p_m_levelName = &m_level->m_levelName;
__p = p_m_levelName->m_data.m_long.longStorage;
v31 = *(_OWORD *)&p_m_levelName->m_data.m_short.sizex2;
if ( (v31 & 1) != 0 )
goto LABEL_6;
LABEL_4:
v10 = (char *)&v31 + 1;
LABEL_7:
v11 = cocos2d::CCLabelBMFont::create_3(v10, "goldFont.fnt");
if ( (v31 & 1) != 0 )
operator delete(__p);
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCLabelBMFont *))a1->m_mainLayer->addChild)(a1->m_mainLayer, v11);
sub_10028CBE0(&v31, v33 * 0.5, (float)((float)(v34 * 0.5) + 150.0) + -25.0);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, __int128 *))v11->setPosition)(v11, &v31);
v12 = cocos2d::CCMenu::create();
a1->m_buttonMenu = v12;
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCMenu *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v12,
10);
v28 = operator new(0x20u);
v27[0] = 33;
v27[1] = 31;
strcpy((char *)v28, "Please wait, uploading level...");
sub_10028CBE0(&v31, 0.5, 1.0);
m_textArea = (TextArea *)TextArea::create(v27, "chatFont.fnt", &v31, 0, 1.0, 400.0, 20.0);
a1->m_textArea = m_textArea;
if ( (v27[0] & 1) != 0 )
{
operator delete(v28);
m_textArea = a1->m_textArea;
}
((void (__fastcall *)(cocos2d::CCLayer *, TextArea *))a1->m_mainLayer->addChild)(a1->m_mainLayer, m_textArea);
v14 = a1->m_textArea;
sub_10028CBE0(&v31, v33 * 0.5, (float)(v34 * 0.5) + -30.0);
((void (__fastcall *)(TextArea *, __int128 *))v14->setPosition)(v14, &v31);
a1->m_joystickConnected = -1;
v15 = LoadingCircle::create();
a1->m_loadingCircle = v15;
v15->m_parentLayer = a1->m_mainLayer;
v15->m_fade = 0;
LoadingCircle::show(v15);
m_sprite = a1->m_loadingCircle->m_sprite;
sub_10028CBE0(&v31, v33 * 0.5, (float)(0.5 * v34) + 20.0);
((void (__fastcall *)(cocos2d::CCSprite *, __int128 *))m_sprite->setPosition)(m_sprite, &v31);
if ( a1->m_level->m_isUploaded )
{
((void (__fastcall *)(UploadPopup *))a1->levelUploadFinished)(a1);
v17 = a1->m_textArea;
strcpy((char *)v29, ",Level already uploaded");
TextArea::setString(v17, v29);
if ( ((__int64)v29[0] & 1) != 0 )
operator delete(v29[2]);
}
else
{
GameLevelManager::sharedState()->m_levelUploadDelegate = &a1->LevelUploadDelegate;
v18 = GameLevelManager::sharedState();
GameLevelManager::uploadLevel(v18, a1->m_level);
}
v19 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_01_001.png");
v20 = CCMenuItemSpriteExtra::create(v19, nullptr, a1, (cocos2d::SEL_MenuHandler)(unsigned __int64)UploadPopup::onBack);
a1->m_backButton = v20;
((void (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild)(a1->m_buttonMenu, v20);
m_backButton = a1->m_backButton;
m_buttonMenu = a1->m_buttonMenu;
v23 = cocos2d::CCDirector::sharedDirector();
v30 = sub_100484D90(v23) + 40.0;
v24 = cocos2d::CCDirector::sharedDirector();
v25 = sub_100484D70(v24);
sub_10028CBE0(v26, v30, *(float *)&v25 + -40.0);
*(cocos2d::CCPoint *)&v36 = cocos2d::CCNode::convertToNodeSpace(
(cocos2d::CCNode *)&v31,
(const cocos2d::CCPoint *)m_buttonMenu);
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int128 *, double))m_backButton->setPosition)(m_backButton, &v31, v36);
return v4;
}