//
// GJMessagePopup::init from 0x1002a6cc0 to 0x1002a75d7 (2327 bytes)
//
// 1 xrefs:
// > GJMessagePopup::create @ 0x1002a6c81
//
// 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 GJMessagePopup::init(GJMessagePopup *a1, GJUserMessage *a2)
{
cocos2d::CCLayer *v3; // rax
cocos2d::extension::CCScale9Sprite *v4; // r14
double v5; // xmm0_8
cocos2d::CCMenu *v6; // rax
GJUserMessage *m_message; // rax
const char *elems; // rdi
cocos2d::CCLabelBMFont *v10; // r14
GJUserMessage *v11; // r13
const char *v12; // rsi
__int64 v13; // r12
const char *v14; // r15
std::string *p_m_username; // r13
const std::string::value_type *v16; // rsi
std::string::size_type v17; // rdx
cocos2d::CCLabelBMFont *v18; // r15
unsigned __int64 *v19; // r14
LoadingCircle *v20; // rax
cocos2d::CCSprite *m_sprite; // r14
cocos2d::CCLabelBMFont *v22; // rax
cocos2d::CCLabelBMFont *m_errorLabel; // r14
cocos2d::CCSprite *v24; // r14
CCMenuItemSpriteExtra *v25; // rax
CCMenuItemSpriteExtra *m_closeButton; // r14
cocos2d::CCMenu *m_buttonMenu; // r15
cocos2d::extension::CCScale9Sprite *v28; // r14
__int128 v29; // xmm0
GJUserMessage *v30; // rax
std::string *p_m_uploadDate; // rax
__int64 v32; // r14
GJUserMessage *v33; // rax
std::string *v34; // rax
cocos2d::CCString *v35; // rax
const char *CString; // rax
cocos2d::CCLabelBMFont *v37; // r14
GJUserMessage *v38; // rax
std::string *p_m_content; // rax
__int64 v40; // r14
GameLevelManager *v41; // rax
float v42; // [rsp+0h] [rbp-80h] BYREF
float v43; // [rsp+8h] [rbp-78h] BYREF
unsigned __int64 v44[2]; // [rsp+10h] [rbp-70h] BYREF
std::string __dst; // [rsp+20h] [rbp-60h] BYREF
float v46; // [rsp+38h] [rbp-48h] BYREF
float v47; // [rsp+3Ch] [rbp-44h]
std::string::value_type __s[16]; // [rsp+40h] [rbp-40h] BYREF
void *longStorage; // [rsp+50h] [rbp-30h]
double v50; // 0:xmm0_8.8
double v51; // 0:xmm0_8.8
cocos2d::CCRect v52; // 0:xmm0_8.8,8:xmm1_8.8
cocos2d::CCRect v53; // 0:xmm0_8.8,8:xmm1_8.8
if ( !a2 )
return 0;
*(_DWORD *)&__dst.m_data.m_short.sizex2 = -1778384896;
if ( !cocos2d::CCLayerColor::initWithColor(a1, (const cocos2d::ccColor4B *)&__dst) )
return 0;
FLAlertLayer::incrementForcePrio(a1);
a1->m_message = a2;
cocos2d::CCObject::retain(a2);
((void (__fastcall *)(GJMessagePopup *, __int64))a1->setTouchEnabled)(a1, 1);
((void (__fastcall *)(GJMessagePopup *, __int64))a1->setKeypadEnabled)(a1, 1);
cocos2d::CCDirector::sharedDirector();
*(cocos2d::CCSize *)&v50 = cocos2d::CCDirector::getWinSize((cocos2d::CCDirector *)&v46);
v3 = cocos2d::CCLayer::create();
a1->m_mainLayer = v3;
((void (__fastcall *)(GJMessagePopup *, cocos2d::CCLayer *, double))a1->addChild)(a1, v3, v50);
v52.origin = 0;
v52.size = 0;
sub_10028CC00((__int64)&__dst, 0.0, 0.0, (__m128)0x42A00000u, (__m128)0x42A00000u);
v4 = cocos2d::extension::CCScale9Sprite::create_2("GJ_square02.png", v52);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, __int64))v4->setOpacity)(v4, 255);
sub_10028CBF0((float *)&__dst.m_data.m_short.sizex2, 420.0, 240.0);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, std::string *))v4->setContentSize)(v4, &__dst);
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::extension::CCScale9Sprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v4,
0xFFFFFFFFLL);
*(_QWORD *)&v5 = LODWORD(v46);
*(float *)&v5 = v46 * 0.5;
sub_10028CBE0((float *)&__dst.m_data.m_short.sizex2, v46 * 0.5, v47 * 0.5);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, std::string *))v4->setPosition)(v4, &__dst);
v6 = cocos2d::CCMenu::create();
a1->m_buttonMenu = v6;
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCMenu *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v6,
10);
a1->m_joystickConnected = -1;
m_message = a1->m_message;
if ( (m_message->m_title.m_data.m_short.sizex2 & 1) != 0 )
{
sub_100006B70(&__dst, m_message->m_title.m_data.m_long.longStorage, m_message->m_title.m_data.m_long.size, v5);
if ( (__dst.m_data.m_short.sizex2 & 1) == 0 )
goto LABEL_5;
}
else
{
__dst = m_message->m_title;
if ( (__dst.m_data.m_short.sizex2 & 1) == 0 )
{
LABEL_5:
elems = __dst.m_data.m_short.shortStorage.__elems_;
goto LABEL_9;
}
}
elems = __dst.m_data.m_long.longStorage;
LABEL_9:
v10 = cocos2d::CCLabelBMFont::create_3(elems, "bigFont.fnt");
if ( (__dst.m_data.m_short.sizex2 & 1) != 0 )
operator delete(__dst.m_data.m_long.longStorage);
sub_10028CBE0((float *)&__dst.m_data.m_short.sizex2, v46 * 0.5, (float)((float)(v47 * 0.5) + 120.0) + -16.0);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, std::string *))v10->setPosition)(v10, &__dst);
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCLabelBMFont *))a1->m_mainLayer->addChild)(a1->m_mainLayer, v10);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float))v10->setScale)(v10, 0.60000002);
v11 = a1->m_message;
v12 = "From: ";
if ( v11->m_outgoing )
v12 = "To: ";
v13 = 2 * !v11->m_outgoing;
__dst.m_data.m_short.sizex2 = 2 * (2 * !v11->m_outgoing + 4);
v14 = __dst.m_data.m_short.shortStorage.__elems_;
memcpy(&__dst.m_data.m_short.shortStorage, v12, v13 + 4);
__dst.m_data.m_short.shortStorage.__elems_[v13 + 4] = 0;
if ( (v11->m_username.m_data.m_short.sizex2 & 1) != 0 )
{
sub_100006B70(
__s,
v11->m_username.m_data.m_long.longStorage,
v11->m_username.m_data.m_long.size,
COERCE_DOUBLE(1058642330));
}
else
{
p_m_username = &v11->m_username;
longStorage = p_m_username->m_data.m_long.longStorage;
*(_OWORD *)__s = *(_OWORD *)&p_m_username->m_data.m_short.sizex2;
}
if ( (__s[0] & 1) != 0 )
{
v16 = (const std::string::value_type *)longStorage;
v17 = *(_QWORD *)&__s[8];
}
else
{
v17 = (unsigned __int8)__s[0] >> 1;
v16 = &__s[1];
}
std::string::append((std::string *)&__dst, v16, v17);
if ( (__s[0] & 1) != 0 )
operator delete(longStorage);
if ( (__dst.m_data.m_short.sizex2 & 1) != 0 )
v14 = __dst.m_data.m_long.longStorage;
v18 = cocos2d::CCLabelBMFont::create_3(v14, "goldFont.fnt");
v19 = (unsigned __int64 *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))v10->getPosition)(v10);
sub_10028CBE0((float *)v44, 0.0, -20.0);
sub_10028CCE0((double *)__s, v19, v44);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, std::string::value_type *))v18->setPosition)(v18, __s);
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCLabelBMFont *))a1->m_mainLayer->addChild)(a1->m_mainLayer, v18);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float))v18->setScale)(v18, 0.60000002);
v20 = LoadingCircle::create();
a1->m_loadingCircle = v20;
v20->m_parentLayer = a1->m_mainLayer;
v20->m_fade = 0;
((void (__fastcall *)(LoadingCircle *, float))v20->setScale)(v20, 0.80000001);
LoadingCircle::show(a1->m_loadingCircle);
m_sprite = a1->m_loadingCircle->m_sprite;
sub_10028CBE0((float *)__s, v46 * 0.5, (float)(v47 * 0.5) + -4.0);
((void (__fastcall *)(cocos2d::CCSprite *, std::string::value_type *))m_sprite->setPosition)(m_sprite, __s);
((void (__fastcall *)(LoadingCircle *, _QWORD))a1->m_loadingCircle->setVisible)(a1->m_loadingCircle, 0);
v22 = cocos2d::CCLabelBMFont::create_3("Something went wrong...", "goldFont.fnt");
a1->m_errorLabel = v22;
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCLabelBMFont *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v22,
10);
m_errorLabel = a1->m_errorLabel;
sub_10028CBE0((float *)__s, v46 * 0.5, v47 * 0.5);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, std::string::value_type *))m_errorLabel->setPosition)(
m_errorLabel,
__s);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float))a1->m_errorLabel->setScale)(a1->m_errorLabel, 0.60000002);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, _QWORD))a1->m_errorLabel->setVisible)(a1->m_errorLabel, 0);
v24 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_closeBtn_001.png");
((void (__fastcall *)(cocos2d::CCSprite *, float))v24->setScale)(v24, 0.80000001);
v25 = CCMenuItemSpriteExtra::create(
v24,
nullptr,
a1,
(cocos2d::SEL_MenuHandler)(unsigned __int64)GJMessagePopup::onClose);
a1->m_closeButton = v25;
CCMenuItemSpriteExtra::setSizeMult(v25, 1.6);
((void (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild)(
a1->m_buttonMenu,
a1->m_closeButton);
m_closeButton = a1->m_closeButton;
m_buttonMenu = a1->m_buttonMenu;
sub_10028CBE0((float *)v44, (float)((float)(v46 * 0.5) + -210.0) + 5.0, (float)((float)(v47 * 0.5) + 120.0) + -5.0);
*(cocos2d::CCPoint *)&v51 = cocos2d::CCNode::convertToNodeSpace(
(cocos2d::CCNode *)__s,
(const cocos2d::CCPoint *)m_buttonMenu);
((void (__fastcall *)(CCMenuItemSpriteExtra *, std::string::value_type *, double))m_closeButton->setPosition)(
m_closeButton,
__s,
v51);
sub_10028CBE0(&v42, v46 * 0.5, 0.5 * v47);
v53.size = 0;
sub_10028CC00((__int64)v44, 0.0, 0.0, (__m128)0x42A00000u, (__m128)0x42A00000u);
*(double *)&v53.origin = sub_10028D180((__m128 *)__s, v44);
v28 = cocos2d::extension::CCScale9Sprite::create_2("square02b_001.png", v53);
*(_QWORD *)&v29 = 1136197632;
sub_10028CBF0(&v43, 370.0, 130.0);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, float *))v28->setContentSize)(v28, &v43);
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::extension::CCScale9Sprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v28,
0xFFFFFFFFLL);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, float *))v28->setPosition)(v28, &v42);
__s[2] = 33;
*(_WORD *)__s = 16514;
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, std::string::value_type *))v28->setColor)(v28, __s);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, void *))v28->setColor)(v28, &unk_100818EA8);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, __int64))v28->setOpacity)(v28, 75);
v30 = a1->m_message;
if ( (v30->m_uploadDate.m_data.m_short.sizex2 & 1) != 0 )
{
sub_100006B70(
__s,
v30->m_uploadDate.m_data.m_long.longStorage,
v30->m_uploadDate.m_data.m_long.size,
COERCE_DOUBLE(1136197632));
}
else
{
p_m_uploadDate = &v30->m_uploadDate;
longStorage = p_m_uploadDate->m_data.m_long.longStorage;
v29 = *(_OWORD *)&p_m_uploadDate->m_data.m_short.sizex2;
*(_OWORD *)__s = *(_OWORD *)&p_m_uploadDate->m_data.m_short.sizex2;
}
if ( (__s[0] & 1) != 0 )
{
v32 = *(_QWORD *)&__s[8];
operator delete(longStorage);
if ( !v32 )
goto LABEL_36;
}
else if ( !__s[0] )
{
goto LABEL_36;
}
v33 = a1->m_message;
if ( (v33->m_uploadDate.m_data.m_short.sizex2 & 1) != 0 )
{
sub_100006B70(
__s,
v33->m_uploadDate.m_data.m_long.longStorage,
v33->m_uploadDate.m_data.m_long.size,
*(double *)&v29);
}
else
{
v34 = &v33->m_uploadDate;
longStorage = v34->m_data.m_long.longStorage;
*(_OWORD *)__s = *(_OWORD *)&v34->m_data.m_short.sizex2;
}
v35 = (cocos2d::CCString *)sub_1007AB580("%s ago", SLOBYTE(v42));
CString = cocos2d::CCString::getCString(v35);
v37 = cocos2d::CCLabelBMFont::create_3(CString, "chatFont.fnt");
if ( (__s[0] & 1) != 0 )
operator delete(longStorage);
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCLabelBMFont *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v37,
1);
sub_10028CBE0((float *)__s, 1.0, 0.5);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, std::string::value_type *))v37->setAnchorPoint)(v37, __s);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float))v37->setScale)(v37, 0.60000002);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, void *))v37->setColor)(v37, &unk_100818EA8);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, __int64))v37->setOpacity)(v37, 225);
*(_QWORD *)&v29 = LODWORD(v46);
*(float *)&v29 = (float)((float)(v46 * 0.5) + 210.0) + -8.0;
sub_10028CBE0((float *)__s, *(float *)&v29, (float)((float)(0.5 * v47) + 120.0) + -12.0);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, std::string::value_type *))v37->setPosition)(v37, __s);
LABEL_36:
v38 = a1->m_message;
if ( (v38->m_content.m_data.m_short.sizex2 & 1) != 0 )
{
sub_100006B70(__s, v38->m_content.m_data.m_long.longStorage, v38->m_content.m_data.m_long.size, *(double *)&v29);
}
else
{
p_m_content = &v38->m_content;
longStorage = p_m_content->m_data.m_long.longStorage;
*(_OWORD *)__s = *(_OWORD *)&p_m_content->m_data.m_short.sizex2;
}
if ( (__s[0] & 1) != 0 )
{
v40 = *(_QWORD *)&__s[8];
operator delete(longStorage);
if ( v40 )
goto LABEL_41;
LABEL_43:
((void (__fastcall *)(LoadingCircle *, __int64))a1->m_loadingCircle->setVisible)(a1->m_loadingCircle, 1);
GameLevelManager::sharedState()->m_downloadMessageDelegate = &a1->DownloadMessageDelegate;
v41 = GameLevelManager::sharedState();
GameLevelManager::downloadUserMessage(v41, a1->m_message->m_messageID, a1->m_message->m_outgoing);
goto LABEL_44;
}
if ( !__s[0] )
goto LABEL_43;
LABEL_41:
GJMessagePopup::loadFromGJMessage(a1, a1->m_message);
LABEL_44:
if ( (__dst.m_data.m_short.sizex2 & 1) != 0 )
operator delete(__dst.m_data.m_long.longStorage);
return 1;
}