//
// GJMessagePopup::init from 0x8ce3ac to 0x8cedf8 (2636 bytes)
//
// 2 xrefs:
// > GJMessagePopup::create @ 0x8cef08
// > ??> @ 0x868c8
//
// 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)
{
char v4; // w23
cocos2d::CCDirector *v6; // x0
cocos2d::CCLayer *v7; // x0
cocos2d::CCNode *v8; // x22
void (__fastcall *setContentSize)(cocos2d::CCNode *__hidden, const cocos2d::CCSize *); // x24
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x24
cocos2d::CCMenu *v11; // x0
cocos2d::CCLayer *m_mainLayer; // x3
cocos2d::CCLabelBMFont *v13; // x22
void *v14; // x0
void (__fastcall *v15)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x25
char *v16; // x1
void *v17; // x0
cocos2d::CCLabelBMFont *v18; // x25
void (__fastcall *v19)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x27
__int64 v20; // x28
LoadingCircle *v21; // x0
LoadingCircle *m_loadingCircle; // x0
LoadingCircle_vtbl *v23; // x2
cocos2d::CCSprite *m_sprite; // x25
void (__fastcall *v25)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // x27
cocos2d::CCLabelBMFont *v26; // x0
cocos2d::CCLayer *v27; // x3
cocos2d::CCLabelBMFont *m_errorLabel; // x25
void (__fastcall *v29)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x26
cocos2d::CCSprite *v30; // x25
CCMenuItemSpriteExtra *v31; // x0
CCMenuItemSpriteExtra *m_closeButton; // x25
cocos2d::CCMenu *m_buttonMenu; // x27
void (__fastcall *v34)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x26
cocos2d::CCNode *v35; // x22
int (__fastcall *getTag)(const cocos2d::CCObject *__hidden); // x2
void *v37; // x0
__int64 v38; // x22
double v39; // d0
cocos2d::CCString *v40; // x0
cocos2d::CCLabelBMFont *v41; // x22
char *v42; // x0
void (__fastcall *setAnchorPoint)(cocos2d::CCLabelBMFont *__hidden, const cocos2d::CCPoint *); // x26
void (__fastcall *v44)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x25
void *v45; // x0
__int64 v46; // x22
cocos2d::CCArray **p_m_pTargetArray; // x22
unsigned int *p_m_nExtraKerning; // x19
int m_nExtraKerning; // w0
GameLevelManager *v50; // x0
unsigned int *v51; // x1
int v52; // w2
unsigned int *v53; // x1
int v54; // w2
unsigned int *v55; // x1
int v56; // w2
unsigned int *v57; // x1
int v58; // w2
unsigned int *v59; // x1
int v60; // w2
float v61; // [xsp+90h] [xbp+90h]
float v62; // [xsp+94h] [xbp+94h]
cocos2d::CCLabelBMFont *v63; // [xsp+98h] [xbp+98h] BYREF
__int64 v64; // [xsp+A0h] [xbp+A0h] BYREF
cocos2d::CCPoint v65; // [xsp+A8h] [xbp+A8h] BYREF
cocos2d::CCSize v66; // [xsp+B0h] [xbp+B0h] BYREF
__int64 v67; // [xsp+B8h] [xbp+B8h] BYREF
char *v68; // [xsp+C0h] [xbp+C0h] BYREF
cocos2d::CCRect v69; // [xsp+C8h] [xbp+C8h] BYREF
cocos2d::CCRect v70; // [xsp+D8h] [xbp+D8h] BYREF
cocos2d::CCPoint v71; // 0:kr08_8.8
cocos2d::SEL_MenuHandler v72; // 0:x2.16
cocos2d::CCRect v73; // 0:s0.4,4:s1.4,8:s2.4,12:s3.4
cocos2d::CCRect v74; // 0:s0.4,4:s1.4,8:s2.4,12:s3.4
if ( !a2 )
return 0;
v70.origin.x = -1.034e-25;
v4 = cocos2d::CCLayerColor::initWithColor(a1, (const cocos2d::_ccColor4B *)&v70);
if ( !v4 )
return 0;
FLAlertLayer::incrementForcePrio(a1);
a1->m_message = a2;
cocos2d::CCObject::retain(a2);
a1->setTouchEnabled(a1, 1);
a1->setKeypadEnabled(a1, 1);
v6 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v6);
v7 = cocos2d::CCLayer::create();
a1->m_mainLayer = v7;
a1->addChild(a1, v7);
cocos2d::CCRect::CCRect(&v70, 0.0, 0.0, 80.0, 80.0);
v8 = (cocos2d::CCNode *)cocos2d::extension::CCScale9Sprite::create(
(cocos2d::extension::CCScale9Sprite *)"GJ_square02.png",
(const char *)&v70,
v73);
((void (__fastcall *)(cocos2d::CCNode *, __int64))v8->__vftable[1].~CCNode_0)(v8, 0xFFFFFFFFLL);
setContentSize = v8->setContentSize;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v70, 420.0, 240.0);
setContentSize(v8, (const cocos2d::CCSize *)&v70);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v8, -1);
setPosition = v8->setPosition;
cocos2d::CCPoint::CCPoint(&v70.origin, v61 * 0.5, v62 * 0.5);
setPosition(v8, &v70.origin);
v11 = cocos2d::CCMenu::create();
m_mainLayer = a1->m_mainLayer;
a1->m_buttonMenu = v11;
m_mainLayer->addChild_0(m_mainLayer, v11, 10);
a1->m_joystickConnected = -1;
sub_D18D28(&v70);
v13 = cocos2d::CCLabelBMFont::create();
v14 = (void *)(*(_QWORD *)&v70.origin - 24LL);
if ( (__int64 *)(*(_QWORD *)&v70.origin - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v55 = (unsigned int *)(*(_QWORD *)&v70.origin - 8LL);
do
v56 = __ldaxr(v55);
while ( __stlxr(v56 - 1, v55) );
}
else
{
v56 = *(_DWORD *)(*(_QWORD *)&v70.origin - 8LL);
*(_DWORD *)(*(_QWORD *)&v70.origin - 8LL) = v56 - 1;
}
if ( v56 <= 0 )
operator delete(v14);
}
v15 = v13->setPosition;
cocos2d::CCPoint::CCPoint(&v70.origin, v61 * 0.5, (float)((float)(v62 * 0.5) + 120.0) - 16.0);
v15(v13, &v70.origin);
a1->m_mainLayer->addChild(a1->m_mainLayer, v13);
v13->setScale(v13, 0.6);
if ( a1->m_message->m_outgoing )
v16 = "To: ";
else
v16 = "From: ";
sub_D153B8((int)&v63, v16);
sub_D18D28(&v64);
sub_D15E14(&v63, &v64);
v17 = (void *)(v64 - 24);
if ( (__int64 *)(v64 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v57 = (unsigned int *)(v64 - 8);
do
v58 = __ldaxr(v57);
while ( __stlxr(v58 - 1, v57) );
}
else
{
v58 = *(_DWORD *)(v64 - 8);
*(_DWORD *)(v64 - 8) = v58 - 1;
}
if ( v58 <= 0 )
operator delete(v17);
}
v18 = cocos2d::CCLabelBMFont::create();
v19 = v18->setPosition;
v20 = (__int64)v13->getPosition(v13);
cocos2d::CCPoint::CCPoint(&v69.origin, 0.0, -20.0);
cocos2d::CCPoint::operator+(&v70, v20, &v69);
v19(v18, &v70.origin);
a1->m_mainLayer->addChild(a1->m_mainLayer, v18);
v18->setScale(v18, 0.6);
v21 = LoadingCircle::create();
a1->m_loadingCircle = v21;
v21->m_parentLayer = a1->m_mainLayer;
m_loadingCircle = a1->m_loadingCircle;
v23 = m_loadingCircle->cocos2d::CCLayerColor::cocos2d::CCLayerRGBA::cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
m_loadingCircle->m_fade = 0;
v23->setScale(m_loadingCircle, 0.8);
LoadingCircle::show(a1->m_loadingCircle);
m_sprite = a1->m_loadingCircle->m_sprite;
v25 = m_sprite->setPosition;
cocos2d::CCPoint::CCPoint(&v70.origin, v61 * 0.5, (float)(v62 * 0.5) + -4.0);
v25(m_sprite, &v70.origin);
a1->m_loadingCircle->setVisible(a1->m_loadingCircle, 0);
v26 = cocos2d::CCLabelBMFont::create();
v27 = a1->m_mainLayer;
a1->m_errorLabel = v26;
v27->addChild_0(v27, v26, 10);
m_errorLabel = a1->m_errorLabel;
v29 = m_errorLabel->setPosition;
cocos2d::CCPoint::CCPoint(&v70.origin, v61 * 0.5, v62 * 0.5);
v29(m_errorLabel, &v70.origin);
a1->m_errorLabel->setScale(a1->m_errorLabel, 0.6);
a1->m_errorLabel->setVisible(a1->m_errorLabel, 0);
v30 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_closeBtn_001.png");
v30->setScale(v30, 0.8);
v72.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v72.adj = (size_t)GJMessagePopup::onClose;
v31 = CCMenuItemSpriteExtra::create(v30, nullptr, v72);
a1->m_closeButton = v31;
CCMenuItemSpriteExtra::setSizeMult(v31, 1.6);
a1->m_buttonMenu->addChild(a1->m_buttonMenu, a1->m_closeButton);
m_closeButton = a1->m_closeButton;
m_buttonMenu = a1->m_buttonMenu;
v34 = m_closeButton->setPosition;
cocos2d::CCPoint::CCPoint(
&v69.origin,
(float)((float)(v61 * 0.5) + -210.0) + 5.0,
(float)((float)(v62 * 0.5) + 120.0) - 5.0);
v71 = cocos2d::CCNode::convertToNodeSpace(m_buttonMenu, &v69.origin);
((void (__fastcall *)(CCMenuItemSpriteExtra *, cocos2d::CCRect *, float, float))v34)(
m_closeButton,
&v70,
v71.x,
v71.y);
cocos2d::CCPoint::CCPoint(&v65, v61 * 0.5, v62 * 0.5);
cocos2d::CCRect::CCRect(&v69, 0.0, 0.0, 80.0, 80.0);
cocos2d::CCRect::CCRect(&v70, &v69);
v35 = (cocos2d::CCNode *)cocos2d::extension::CCScale9Sprite::create(
(cocos2d::extension::CCScale9Sprite *)"square02b_001.png",
(const char *)&v70,
v74);
cocos2d::CCSize::CCSize(&v66, 370.0, 130.0);
v35->setContentSize(v35, &v66);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v35, -1);
v35->setPosition(v35, &v65);
getTag = v35->__vftable[1].getTag;
LOWORD(v70.origin.x) = 16514;
BYTE2(v70.origin.x) = 33;
((void (__fastcall *)(cocos2d::CCNode *, cocos2d::CCRect *))getTag)(v35, &v70);
((void (__fastcall *)(cocos2d::CCNode *, void *))v35->__vftable[1].getTag)(v35, &unk_EEDED0);
((void (__fastcall *)(cocos2d::CCNode *, __int64))v35->__vftable[1].~CCNode_0)(v35, 75);
sub_D18D28(&v67);
v37 = (void *)(v67 - 24);
v38 = *(_QWORD *)(v67 - 24);
if ( (__int64 *)(v67 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v53 = (unsigned int *)(v67 - 8);
do
v54 = __ldaxr(v53);
while ( __stlxr(v54 - 1, v53) );
}
else
{
v54 = *(_DWORD *)(v67 - 8);
*(_DWORD *)(v67 - 8) = v54 - 1;
}
if ( v54 <= 0 )
operator delete(v37);
}
if ( v38 )
{
*(_QWORD *)&v39 = sub_D18D28(&v68).n128_u64[0];
v40 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%s ago", v68, v39);
cocos2d::CCString::getCString(v40);
v41 = cocos2d::CCLabelBMFont::create();
v42 = v68 - 24;
if ( v68 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v59 = (unsigned int *)(v68 - 8);
do
v60 = __ldaxr(v59);
while ( __stlxr(v60 - 1, v59) );
}
else
{
v60 = *((_DWORD *)v68 - 2);
*((_DWORD *)v68 - 2) = v60 - 1;
}
if ( v60 <= 0 )
operator delete(v42);
}
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v41, 1);
setAnchorPoint = v41->setAnchorPoint;
cocos2d::CCPoint::CCPoint(&v70.origin, 1.0, 0.5);
setAnchorPoint(v41, &v70.origin);
v41->setScale(v41, 0.6);
v41->setColor(v41, (const cocos2d::ccColor3B *)&unk_EEDED0);
v41->setOpacity(v41, 4294967265LL);
v44 = v41->setPosition;
cocos2d::CCPoint::CCPoint(
&v70.origin,
(float)((float)(v61 * 0.5) + 210.0) - 8.0,
(float)((float)(v62 * 0.5) + 120.0) - 12.0);
v44(v41, &v70.origin);
}
sub_D18D28(&v70);
v45 = (void *)(*(_QWORD *)&v70.origin - 24LL);
v46 = *(_QWORD *)(*(_QWORD *)&v70.origin - 24LL);
if ( (__int64 *)(*(_QWORD *)&v70.origin - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v51 = (unsigned int *)(*(_QWORD *)&v70.origin - 8LL);
do
v52 = __ldaxr(v51);
while ( __stlxr(v52 - 1, v51) );
}
else
{
v52 = *(_DWORD *)(*(_QWORD *)&v70.origin - 8LL);
*(_DWORD *)(*(_QWORD *)&v70.origin - 8LL) = v52 - 1;
}
if ( v52 <= 0 )
operator delete(v45);
}
if ( v46 )
{
GJMessagePopup::loadFromGJMessage(a1, a1->m_message);
}
else
{
a1->m_loadingCircle->setVisible(a1->m_loadingCircle, 1);
GameLevelManager::sharedState()->m_downloadMessageDelegate = &a1->DownloadMessageDelegate;
v50 = GameLevelManager::sharedState();
GameLevelManager::downloadUserMessage(v50, a1->m_message->m_messageID, a1->m_message->m_outgoing);
}
p_m_pTargetArray = &v63[-1].m_pTargetArray;
if ( &v63[-1].m_pTargetArray != (cocos2d::CCArray **)&qword_124B6B0 )
{
if ( &pthread_create )
{
p_m_nExtraKerning = (unsigned int *)&v63[-1].m_nExtraKerning;
do
m_nExtraKerning = __ldaxr(p_m_nExtraKerning);
while ( __stlxr(m_nExtraKerning - 1, p_m_nExtraKerning) );
}
else
{
m_nExtraKerning = v63[-1].m_nExtraKerning;
v63[-1].m_nExtraKerning = m_nExtraKerning - 1;
}
if ( m_nExtraKerning <= 0 )
operator delete(p_m_pTargetArray);
}
return v4;
}