//
// GJMessagePopup::init from 0x4adcc4 to 0x4ae2ea (1574 bytes)
//
// 1 xrefs:
// > GJMessagePopup::create @ 0x4ae37c
//
// 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 GJMessagePopup::init(GJMessagePopup *a1, GJUserMessage *a2)
{
int v4; // r9
cocos2d::CCDirector *v5; // r0
cocos2d::CCLayer *v6; // r0
GJMessagePopup_vtbl *v7; // r3
cocos2d::CCNode *v8; // r6
void (__fastcall *setContentSize)(cocos2d::CCNode *__hidden, const cocos2d::CCSize *); // r7
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r7
cocos2d::CCMenu *v11; // r0
cocos2d::CCLabelBMFont *v12; // r6
void (__fastcall *v13)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r7
char *v14; // r1
cocos2d::CCLabelBMFont *v15; // r7
void (__fastcall *v16)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r10
int v17; // r11
LoadingCircle *v18; // r0
cocos2d::CCLayer *m_mainLayer; // r3
LoadingCircle *m_loadingCircle; // r0
cocos2d::CCSprite *m_sprite; // r7
void (__fastcall *v22)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r10
cocos2d::CCLabelBMFont *v23; // r0
cocos2d::CCLabelBMFont *m_errorLabel; // r7
void (__fastcall *v25)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r10
cocos2d::CCSprite *v26; // r7
CCMenuItemSpriteExtra *v27; // r0
CCMenuItemSpriteExtra *m_closeButton; // r7
cocos2d::CCMenu *m_buttonMenu; // r11
void (__fastcall *v30)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r10
cocos2d::CCNode *v31; // r6
int (__fastcall *getTag)(const cocos2d::CCObject *__hidden); // r3
int v33; // r7
cocos2d::CCString *v34; // r0
cocos2d::CCLabelBMFont *v35; // r7
void (__fastcall *setAnchorPoint)(cocos2d::CCLabelBMFont *__hidden, const cocos2d::CCPoint *); // r6
void (__fastcall *v37)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r6
int v38; // r6
GameLevelManager *v39; // r0
float v41; // r2
float v42; // r3
cocos2d::CCLabelBMFont *v43; // [sp+14h] [bp-58h] BYREF
_BYTE v44[4]; // [sp+18h] [bp-54h] BYREF
int v45; // [sp+1Ch] [bp-50h] BYREF
char *v46; // [sp+20h] [bp-4Ch] BYREF
cocos2d::CCSize v47; // [sp+24h] [bp-48h] BYREF
cocos2d::CCPoint v48; // [sp+2Ch] [bp-40h] BYREF
cocos2d::CCSize v49; // [sp+34h] [bp-38h] BYREF
void (*v50)(GJMessagePopup *, cocos2d::CCObject *); // [sp+3Ch] [bp-30h]
int v51; // [sp+40h] [bp-2Ch]
cocos2d::CCRect v52; // [sp+44h] [bp-28h] BYREF
cocos2d::CCRect v53; // [sp+54h] [bp-18h] BYREF
cocos2d::CCSize v54; // 0:^0.8
cocos2d::CCRect v55; // 0:kr00_16.16
cocos2d::CCRect v56; // 0:r2.8,8:^0.8
if ( a2
&& (v53.origin.x = -1.034e-25,
(v4 = cocos2d::CCLayerColor::initWithColor(a1, (const cocos2d::_ccColor4B *)&v53)) != 0) )
{
FLAlertLayer::incrementForcePrio(a1);
a1->m_message = a2;
cocos2d::CCObject::retain(a2);
a1->setTouchEnabled(a1, 1);
a1->setKeypadEnabled(a1, 1);
v5 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(&v47, v5);
v6 = cocos2d::CCLayer::create();
v7 = a1->FLAlertLayer::cocos2d::CCLayerColor::cocos2d::CCLayerRGBA::cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a1->m_mainLayer = v6;
v7->addChild(a1, v6);
cocos2d::CCRect::CCRect(&v53, 0.0, 0.0, 80.0, 80.0);
v55.origin.x = v41;
v55.origin.y = v42;
v55.size = v54;
v8 = (cocos2d::CCNode *)cocos2d::extension::CCScale9Sprite::create(
(cocos2d::extension::CCScale9Sprite *)"GJ_square02.png",
(const char *)&v53,
v55);
((void (__fastcall *)(cocos2d::CCNode *, int))v8->__vftable[1].~CCNode_0)(v8, 255);
setContentSize = v8->setContentSize;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v53, 420.0, 240.0);
setContentSize(v8, (const cocos2d::CCSize *)&v53);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v8, -1);
setPosition = v8->setPosition;
cocos2d::CCPoint::CCPoint(&v53.origin, v47.width * 0.5, v47.height * 0.5);
setPosition(v8, &v53.origin);
v11 = cocos2d::CCMenu::create();
a1->m_buttonMenu = v11;
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v11, 10);
a1->m_joystickConnected = -1;
sub_775C20(&v53);
v12 = cocos2d::CCLabelBMFont::create();
sub_774008(&v53);
v13 = v12->setPosition;
cocos2d::CCPoint::CCPoint(&v53.origin, v47.width * 0.5, (float)((float)(v47.height * 0.5) + 120.0) - 16.0);
v13(v12, &v53.origin);
a1->m_mainLayer->addChild(a1->m_mainLayer, v12);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, int))v12->setScale)(v12, 1058642330);
if ( a1->m_message->m_outgoing )
v14 = "To: ";
else
v14 = "From: ";
sub_776584((int)&v43, v14);
sub_775C20(v44);
sub_77441C(&v43, v44);
sub_774008(v44);
v15 = cocos2d::CCLabelBMFont::create();
v16 = v15->setPosition;
v17 = (int)v12->getPosition(v12);
cocos2d::CCPoint::CCPoint(&v52.origin, 0.0, -20.0);
cocos2d::CCPoint::operator+(&v53, v17, &v52);
v16(v15, &v53.origin);
a1->m_mainLayer->addChild(a1->m_mainLayer, v15);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, int))v15->setScale)(v15, 1058642330);
v18 = LoadingCircle::create();
m_mainLayer = a1->m_mainLayer;
a1->m_loadingCircle = v18;
v18->m_parentLayer = m_mainLayer;
m_loadingCircle = a1->m_loadingCircle;
m_loadingCircle->m_fade = 0;
((void (__fastcall *)(LoadingCircle *, int))m_loadingCircle->setScale)(m_loadingCircle, 1061997773);
LoadingCircle::show(a1->m_loadingCircle);
m_sprite = a1->m_loadingCircle->m_sprite;
v22 = m_sprite->setPosition;
cocos2d::CCPoint::CCPoint(&v53.origin, v47.width * 0.5, (float)(v47.height * 0.5) - 4.0);
v22(m_sprite, &v53.origin);
a1->m_loadingCircle->setVisible(a1->m_loadingCircle, 0);
v23 = cocos2d::CCLabelBMFont::create();
a1->m_errorLabel = v23;
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v23, 10);
m_errorLabel = a1->m_errorLabel;
v25 = m_errorLabel->setPosition;
cocos2d::CCPoint::CCPoint(&v53.origin, v47.width * 0.5, v47.height * 0.5);
v25(m_errorLabel, &v53.origin);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, int))a1->m_errorLabel->setScale)(a1->m_errorLabel, 1058642330);
a1->m_errorLabel->setVisible(a1->m_errorLabel, 0);
v26 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_closeBtn_001.png");
((void (__fastcall *)(cocos2d::CCSprite *, int))v26->setScale)(v26, 1061997773);
v50 = GJMessagePopup::onClose;
v51 = 0;
v27 = CCMenuItemSpriteExtra::create(
v26,
nullptr,
(cocos2d::SEL_MenuHandler)__PAIR64__(GJMessagePopup::onClose, (unsigned int)a1));
a1->m_closeButton = v27;
CCMenuItemSpriteExtra::setSizeMult(v27, 1.6);
a1->m_buttonMenu->addChild(a1->m_buttonMenu, a1->m_closeButton);
m_closeButton = a1->m_closeButton;
m_buttonMenu = a1->m_buttonMenu;
v30 = m_closeButton->setPosition;
cocos2d::CCPoint::CCPoint(
&v52.origin,
(float)((float)(v47.width * 0.5) - 210.0) + 5.0,
(float)((float)(v47.height * 0.5) + 120.0) - 5.0);
cocos2d::CCNode::convertToNodeSpace(&v53.origin, m_buttonMenu, &v52.origin);
v30(m_closeButton, &v53.origin);
cocos2d::CCPoint::CCPoint(&v48, v47.width * 0.5, v47.height * 0.5);
cocos2d::CCRect::CCRect(&v52, 0.0, 0.0, 80.0, 80.0);
cocos2d::CCRect::CCRect(&v53, &v52);
v31 = (cocos2d::CCNode *)cocos2d::extension::CCScale9Sprite::create(
(cocos2d::extension::CCScale9Sprite *)"square02b_001.png",
(const char *)&v53,
v56);
cocos2d::CCSize::CCSize(&v49, 370.0, 130.0);
v31->setContentSize(v31, &v49);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v31, -1);
v31->setPosition(v31, &v48);
getTag = v31->__vftable[1].getTag;
LOWORD(v53.origin.x) = 16514;
BYTE2(v53.origin.x) = 33;
((void (__fastcall *)(cocos2d::CCNode *, cocos2d::CCRect *))getTag)(v31, &v53);
((void (__fastcall *)(cocos2d::CCNode *, cocos2d::ccColor3B *))v31->__vftable[1].getTag)(v31, &stru_9AC15C);
((void (__fastcall *)(cocos2d::CCNode *, int))v31->__vftable[1].~CCNode_0)(v31, 75);
sub_775C20(&v45);
v33 = *(_DWORD *)(v45 - 12);
sub_774008(&v45);
if ( v33 )
{
sub_775C20(&v46);
v34 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%s ago", v46);
cocos2d::CCString::getCString(v34);
v35 = cocos2d::CCLabelBMFont::create();
sub_774008(&v46);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v35, 1);
setAnchorPoint = v35->setAnchorPoint;
cocos2d::CCPoint::CCPoint(&v53.origin, 1.0, 0.5);
setAnchorPoint(v35, &v53.origin);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, int))v35->setScale)(v35, 1058642330);
v35->setColor(v35, &stru_9AC15C);
v35->setOpacity(v35, 225);
v37 = v35->setPosition;
cocos2d::CCPoint::CCPoint(
&v53.origin,
(float)((float)(v47.width * 0.5) + 210.0) - 8.0,
(float)((float)(v47.height * 0.5) + 120.0) - 12.0);
v37(v35, &v53.origin);
}
sub_775C20(&v53);
v38 = *(_DWORD *)(LODWORD(v53.origin.x) - 12);
sub_774008(&v53);
if ( v38 )
{
GJMessagePopup::loadFromGJMessage(a1, a1->m_message);
}
else
{
a1->m_loadingCircle->setVisible(a1->m_loadingCircle, 1);
GameLevelManager::sharedState()->m_downloadMessageDelegate = &a1->DownloadMessageDelegate;
v39 = GameLevelManager::sharedState();
GameLevelManager::downloadUserMessage(v39, a1->m_message->m_messageID, a1->m_message->m_outgoing);
}
sub_774008(&v43);
}
else
{
LOBYTE(v4) = 0;
}
return v4;
}