//
// GJMessagePopup::init from 0x1402974b0 to 0x140297dbd (2317 bytes)
//
// 2 xrefs:
// > GJMessagePopup::create @ 0x14029746b
// > ??> @ 0x1406d1c58
//
// 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
//
// Hidden C++ exception states: #wind=6
bool GJMessagePopup::init(GJMessagePopup *a1, GJUserMessage *a2)
{
__int64 v4; // rcx
__int64 v5; // rax
cocos2d::CCTouchDispatcher *v6; // rax
_BOOL8 v7; // rdx
_BOOL8 v8; // rdx
__int64 v9; // rcx
cocos2d::CCDirector *v10; // rax
cocos2d::CCLayer *v11; // rax
struct cocos2d::CCRect *v12; // rax
struct cocos2d::extension::CCScale9Sprite *v13; // rdi
__int64 v14; // rdx
cocos2d::extension::CCScale9Sprite_vtbl *v15; // rbx
const cocos2d::CCSize *v16; // rax
float v17; // xmm0_4
cocos2d::extension::CCScale9Sprite_vtbl *v18; // rbx
double v19; // xmm0_8
const cocos2d::CCPoint *v20; // rax
__int64 v21; // rcx
cocos2d::CCMenu *v22; // rax
const char *v23; // rcx
struct cocos2d::CCLabelBMFont *v24; // r14
cocos2d::CCLabelBMFont_vtbl *v25; // rbx
const cocos2d::CCPoint *v26; // rax
int *v27; // rdx
size_t v28; // r8
cocos2d::CCRect *origin; // rdx
void **v30; // rcx
struct cocos2d::CCLabelBMFont *v31; // rdi
__int64 v32; // rax
double v33; // xmm0_8
LoadingCircle *v34; // rax
cocos2d::CCSprite *m_sprite; // rbx
cocos2d::CCSprite_vtbl *v36; // rdi
const cocos2d::CCPoint *v37; // rax
cocos2d::CCLabelBMFont *v38; // rax
float v39; // xmm0_4
cocos2d::CCLabelBMFont_vtbl *v40; // rbx
const cocos2d::CCPoint *v41; // rax
struct cocos2d::CCSprite *v42; // rbx
CCMenuItemSpriteExtra *v43; // rax
float v44; // xmm0_4
CCMenuItemSpriteExtra_vtbl *v45; // rbx
struct cocos2d::CCPoint v46; // rax
float v47; // xmm0_4
struct cocos2d::CCRect *v48; // rax
struct cocos2d::extension::CCScale9Sprite *v49; // rbx
DS_Dictionary *v50; // rdx
const char *v51; // rdx
cocos2d::CCString *v52; // rax
const char *CString; // rax
struct cocos2d::CCLabelBMFont *v54; // rdi
float v55; // xmm0_4
cocos2d::CCLabelBMFont_vtbl *v56; // rbx
const cocos2d::CCPoint *v57; // rax
__int64 v58; // rdx
float v59; // xmm0_4
cocos2d::CCLabelBMFont_vtbl *v60; // rbx
const cocos2d::CCPoint *v61; // rax
bool v62; // bl
_BOOL8 v63; // rdx
GameLevelManager *v64; // rcx
void *v65; // rcx
cocos2d::CCSize v67; // [rsp+38h] [rbp-89h] BYREF
float v68; // [rsp+40h] [rbp-81h]
cocos2d::CCSize v69; // [rsp+48h] [rbp-79h] BYREF
cocos2d::CCPoint v70; // [rsp+50h] [rbp-71h] BYREF
cocos2d::CCRect v71; // [rsp+58h] [rbp-69h] BYREF
_QWORD v72[2]; // [rsp+68h] [rbp-59h] BYREF
__int64 v73; // [rsp+78h] [rbp-49h]
unsigned __int64 v74; // [rsp+80h] [rbp-41h]
cocos2d::CCRect v75; // [rsp+88h] [rbp-39h] BYREF
size_t Size; // [rsp+98h] [rbp-29h]
unsigned __int64 v77; // [rsp+A0h] [rbp-21h]
void *Block[2]; // [rsp+A8h] [rbp-19h] BYREF
__int64 v79; // [rsp+B8h] [rbp-9h]
unsigned __int64 v80; // [rsp+C0h] [rbp-1h]
if ( !a2 )
return 0;
v67.width = -1.0339758e-25;
if ( !cocos2d::CCLayerColor::initWithColor(a1, (const struct cocos2d::_ccColor4B *)&v67) )
return 0;
if ( !a1->m_forcePrioRegistered )
{
a1->m_forcePrioRegistered = 1;
v5 = cocos2d::CCDirector::sharedDirector(v4);
v6 = (cocos2d::CCTouchDispatcher *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v5 + 144LL))(v5);
cocos2d::CCTouchDispatcher::registerForcePrio(v6, a1, 2);
}
a1->m_message = a2;
cocos2d::CCObject::retain(a2);
LOBYTE(v7) = 1;
a1->setTouchEnabled(a1, v7);
LOBYTE(v8) = 1;
a1->setKeypadEnabled(a1, v8);
v10 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v9);
cocos2d::CCDirector::getWinSize(v10);
v11 = (cocos2d::CCLayer *)cocos2d::CCLayer::create();
a1->m_mainLayer = v11;
a1->addChild_1(a1, v11);
cocos2d::CCRect::CCRect(&v75, 0.0, 0.0, 80.0, 80.0);
v13 = cocos2d::extension::CCScale9Sprite::create("GJ_square02.png", v12);
LOBYTE(v14) = -1;
v13->setOpacity(&v13->cocos2d::CCRGBAProtocol, v14);
v15 = v13->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCSize::CCSize(&v67, 420.0, 240.0);
v15->setContentSize(v13, v16);
v17 = ((float (__fastcall *)(cocos2d::CCLayer *, struct cocos2d::extension::CCScale9Sprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v13,
0xFFFFFFFFLL);
v18 = v13->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v19 = cocos2d::CCPoint::CCPoint(v17, v68 * 0.5);
v18->setPosition_0(v13, v20);
v22 = (cocos2d::CCMenu *)cocos2d::CCMenu::create(v21);
a1->m_buttonMenu = v22;
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v22, 10);
a1->m_joystickConnected = -1;
sub_14003BDB0((__int64)v72, (__int64)&a1->m_message->m_title);
v23 = (const char *)v72;
if ( v74 > 0xF )
v23 = (const char *)v72[0];
v24 = cocos2d::CCLabelBMFont::create(v23, (const char *)&qword_14052A4D8);
sub_14003A830((__int64)v72);
v25 = v24->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(*(float *)&v19, v68 * 0.5);
v25->setPosition_0(v24, v26);
a1->m_mainLayer->addChild_1(a1->m_mainLayer, v24);
((void (__fastcall *)(struct cocos2d::CCLabelBMFont *))v24->setScale_0)(v24);
v27 = &dword_140570C94;
if ( a1->m_message->m_outgoing )
v27 = (int *)"To: ";
*(_OWORD *)Block = 0;
v79 = 0;
v80 = 0;
v28 = -1;
do
++v28;
while ( *((_BYTE *)v27 + v28) );
sub_14003A930(Block, v27, v28);
sub_14003BDB0((__int64)&v75, (__int64)&a1->m_message->m_username);
origin = &v75;
if ( v77 > 0xF )
origin = (cocos2d::CCRect *)v75.origin;
sub_140041270(Block, origin, Size);
sub_14003A830((__int64)&v75);
v30 = Block;
if ( v80 > 0xF )
v30 = (void **)Block[0];
v31 = cocos2d::CCLabelBMFont::create((const char *)v30, "goldFont.fnt");
cocos2d::CCPoint::CCPoint(0.0, 0.0);
v32 = (__int64)v24->getPosition_0(v24);
cocos2d::CCPoint::operator+(v32, &v67);
v31->setPosition_0(v31, (const cocos2d::CCPoint *)&v67);
v33 = ((double (__fastcall *)(cocos2d::CCLayer *, struct cocos2d::CCLabelBMFont *))a1->m_mainLayer->addChild_1)(
a1->m_mainLayer,
v31);
((void (__fastcall *)(struct cocos2d::CCLabelBMFont *))v31->setScale_0)(v31);
v34 = LoadingCircle::create();
a1->m_loadingCircle = v34;
v34->m_parentLayer = a1->m_mainLayer;
a1->m_loadingCircle->m_fade = 0;
((void (__fastcall *)(LoadingCircle *))a1->m_loadingCircle->setScale_0)(a1->m_loadingCircle);
LoadingCircle::show(a1->m_loadingCircle);
m_sprite = a1->m_loadingCircle->m_sprite;
v36 = m_sprite->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(*(float *)&v33, v68 * 0.5);
v36->setPosition_0(m_sprite, v37);
a1->m_loadingCircle->setVisible(a1->m_loadingCircle, 0);
v38 = cocos2d::CCLabelBMFont::create("Something went wrong...", "goldFont.fnt");
a1->m_errorLabel = v38;
v39 = ((float (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCLabelBMFont *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v38,
10);
v40 = a1->m_errorLabel->__vftable;
cocos2d::CCPoint::CCPoint(v39, v68 * 0.5);
v40->setPosition_0(a1->m_errorLabel, v41);
((void (__fastcall *)(cocos2d::CCLabelBMFont *))a1->m_errorLabel->setScale_0)(a1->m_errorLabel);
a1->m_errorLabel->setVisible(a1->m_errorLabel, 0);
v42 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_closeBtn_001.png");
((void (__fastcall *)(struct cocos2d::CCSprite *))v42->setScale_0)(v42);
v43 = CCMenuItemSpriteExtra::create(v42, nullptr, a1, (cocos2d::SEL_MenuHandler *)AudioAssetsBrowser::onClose);
a1->m_closeButton = v43;
HIDWORD(v43->m_pfnSelector.adj) = 1070386381;
v44 = ((float (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild_1)(
a1->m_buttonMenu,
a1->m_closeButton);
v45 = a1->m_closeButton->__vftable;
cocos2d::CCPoint::CCPoint(v44, (float)((float)(v68 * 0.5) - 210.0) + 5.0);
v46 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, (const struct cocos2d::CCPoint *)&v67);
v47 = ((float (__fastcall *)(CCMenuItemSpriteExtra *, struct cocos2d::CCPoint))v45->setPosition_0)(
a1->m_closeButton,
v46);
cocos2d::CCPoint::CCPoint(v47, v68 * 0.5);
cocos2d::CCRect::CCRect(&v71, 0.0, 0.0, 80.0, 80.0);
v48 = (struct cocos2d::CCRect *)cocos2d::CCRect::CCRect(&v75, &v71);
v49 = cocos2d::extension::CCScale9Sprite::create("square02b_001.png", v48);
cocos2d::CCSize::CCSize(&v69, 370.0, 130.0);
v49->setContentSize(v49, &v69);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v49, -1);
v49->setPosition_0(v49, &v70);
LOWORD(v67.width) = 16514;
BYTE2(v67.width) = 33;
v49 = (struct cocos2d::extension::CCScale9Sprite *)((char *)v49 + 320);
v49->copyWithZone(v49, (cocos2d::CCZone *)&v67);
v49->copyWithZone(v49, (cocos2d::CCZone *)&stru_140529AD4);
LOBYTE(v50) = 75;
v49->encodeWithCoder(v49, v50);
sub_14003BDB0((__int64)v72, (__int64)&a1->m_message->m_uploadDate);
LOBYTE(v49) = v73 != 0;
sub_14003A830((__int64)v72);
if ( (_BYTE)v49 )
{
sub_14003BDB0((__int64)v72, (__int64)&a1->m_message->m_uploadDate);
v51 = (const char *)v72;
if ( v74 > 0xF )
v51 = (const char *)v72[0];
v52 = cocos2d::CCString::createWithFormat("%s ago", v51);
CString = cocos2d::CCString::getCString(v52);
v54 = cocos2d::CCLabelBMFont::create(CString, "chatFont.fnt");
sub_14003A830((__int64)v72);
v55 = ((float (__fastcall *)(cocos2d::CCLayer *, struct cocos2d::CCLabelBMFont *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v54,
1);
v56 = v54->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(v55, 1.0);
v56->setAnchorPoint(v54, v57);
((void (__fastcall *)(struct cocos2d::CCLabelBMFont *))v54->setScale_0)(v54);
v54->setColor(&v54->cocos2d::CCRGBAProtocol, &stru_140529AD4);
LOBYTE(v58) = -31;
v59 = ((float (__fastcall *)(cocos2d::CCRGBAProtocol *, __int64))v54->setOpacity)(
&v54->cocos2d::CCRGBAProtocol,
v58);
v60 = v54->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(v59, (float)((float)(v68 * 0.5) + 210.0) - 8.0);
v60->setPosition_0(v54, v61);
}
sub_14003BDB0((__int64)v72, (__int64)&a1->m_message->m_content);
v62 = v73 != 0;
sub_14003A830((__int64)v72);
if ( v62 )
{
GJMessagePopup::loadFromGJMessage(a1, a1->m_message);
}
else
{
LOBYTE(v63) = 1;
a1->m_loadingCircle->setVisible(a1->m_loadingCircle, v63);
v64 = (GameLevelManager *)qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v75.origin = (cocos2d::CCPoint)operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280(*(_QWORD *)&v75.origin);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v64 = (GameLevelManager *)qword_1406C2EC0;
}
v64->m_downloadMessageDelegate = &a1->DownloadMessageDelegate;
GameLevelManager::downloadUserMessage(v64, a1->m_message->m_messageID, a1->m_message->m_outgoing);
}
if ( v80 > 0xF )
{
v65 = Block[0];
if ( v80 + 1 >= 0x1000 )
{
v65 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v65 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v65);
}
return 1;
}