//
// GJWriteMessagePopup::init from 0x4ae8f0 to 0x4af21e (2350 bytes)
//
// 1 xrefs:
// > GJWriteMessagePopup::create @ 0x4af314
//
// 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 GJWriteMessagePopup::init(GJWriteMessagePopup *a1, int a2, int a3)
{
GameLevelManager *v6; // r0
GJUserMessage *StoredUserMessageReply; // r6
cocos2d::CCDirector *v8; // r0
cocos2d::CCLayer *v9; // r0
GJWriteMessagePopup_vtbl *v10; // r3
cocos2d::CCNode *v11; // r7
void (__fastcall *setContentSize)(cocos2d::CCNode *__hidden, const cocos2d::CCSize *); // r9
cocos2d::CCLabelBMFont *v13; // r9
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r7
GameLevelManager *v15; // r0
cocos2d::CCLabelBMFont *v16; // r7
void (__fastcall *v17)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r10
int v18; // r11
cocos2d::CCMenu *v19; // r0
cocos2d::CCArray *v20; // r0
cocos2d::CCArray *v21; // r9
char *v22; // r0
ButtonSprite *v23; // r0
CCMenuItemSpriteExtra *v24; // r7
ButtonSprite *v25; // r0
CCMenuItemSpriteExtra *v26; // r7
cocos2d::CCMenu *m_buttonMenu; // r10
float x; // r11
float v29; // s16
const cocos2d::CCPoint *v30; // r0
cocos2d::CCNode *v31; // r9
int (__fastcall *getTag)(const cocos2d::CCObject *__hidden); // r2
CCTextInputNode *v33; // r0
CCTextInputNode *m_subjectInput; // r10
CCTextInputNode *v35; // r3
cocos2d::CCTextFieldTTF *m_textField; // r0
TextArea *v37; // r9
cocos2d::CCString *v38; // r0
cocos2d::CCLabelBMFont *v39; // r0
cocos2d::CCLabelBMFont *m_subjectCountLabel; // r9
void (__fastcall *setAnchorPoint)(cocos2d::CCLabelBMFont *__hidden, const cocos2d::CCPoint *); // r10
cocos2d::CCLabelBMFont *v42; // r10
cocos2d::CCNode *v43; // r7
int (__fastcall *v44)(const cocos2d::CCObject *__hidden); // r2
CCTextInputNode *v45; // r0
CCTextInputNode *m_messageInput; // r10
CCTextInputNode *v47; // r3
cocos2d::CCTextFieldTTF *v48; // r0
CCTextInputNode *v49; // r7
void (__fastcall *v50)(cocos2d::CCNode *__hidden, const cocos2d::CCSize *); // r10
TextArea *v51; // r9
cocos2d::CCString *v52; // r0
cocos2d::CCLabelBMFont *v53; // r0
cocos2d::CCLabelBMFont *m_messageCountLabel; // r7
void (__fastcall *v55)(cocos2d::CCLabelBMFont *__hidden, const cocos2d::CCPoint *); // r9
cocos2d::CCSprite *v56; // r0
CCMenuItemSpriteExtra *v57; // r9
cocos2d::CCMenu *v58; // r11
void (__fastcall *v59)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r10
CCTextInputNode *v60; // r9
char *v61; // r2
CCTextInputNode *v62; // r4
char *v63; // r2
float v65; // r2
float v66; // r3
cocos2d::CCPoint v67; // [sp+4h] [bp-B8h]
float v68; // [sp+10h] [bp-ACh]
int v69; // [sp+14h] [bp-A8h]
void (__fastcall *v70)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // [sp+18h] [bp-A4h]
cocos2d::CCLabelBMFont *v71; // [sp+24h] [bp-98h] BYREF
char v72; // [sp+28h] [bp-94h] BYREF
char v73[4]; // [sp+2Ch] [bp-90h] BYREF
char v74; // [sp+30h] [bp-8Ch] BYREF
char v75[4]; // [sp+34h] [bp-88h] BYREF
char v76[4]; // [sp+38h] [bp-84h] BYREF
char v77; // [sp+3Ch] [bp-80h] BYREF
char v78[4]; // [sp+40h] [bp-7Ch] BYREF
cocos2d::CCSize v79; // [sp+44h] [bp-78h] BYREF
cocos2d::CCPoint v80; // [sp+4Ch] [bp-70h] BYREF
cocos2d::CCPoint v81; // [sp+54h] [bp-68h] BYREF
cocos2d::CCSize v82; // [sp+5Ch] [bp-60h] BYREF
cocos2d::CCPoint v83; // [sp+64h] [bp-58h] BYREF
cocos2d::CCSize v84; // [sp+6Ch] [bp-50h] BYREF
cocos2d::CCPoint v85; // [sp+74h] [bp-48h] BYREF
cocos2d::CCPoint v86; // [sp+7Ch] [bp-40h] BYREF
void (*v87)(GJWriteMessagePopup *, cocos2d::CCObject *); // [sp+84h] [bp-38h]
int v88; // [sp+88h] [bp-34h]
void (*v89)(GJWriteMessagePopup *, cocos2d::CCObject *); // [sp+8Ch] [bp-30h]
int v90; // [sp+90h] [bp-2Ch]
cocos2d::CCRect v91; // [sp+94h] [bp-28h] BYREF
cocos2d::CCRect v92; // [sp+A4h] [bp-18h] BYREF
cocos2d::CCSize v93; // 0:^0.8
cocos2d::CCRect v94; // 0:kr00_16.16
cocos2d::CCRect v95; // 0:r2.8,8:^0.8
cocos2d::CCRect v96; // 0:r2.8,8:^0.8
v92.origin.x = -1.034e-25;
v69 = cocos2d::CCLayerColor::initWithColor(a1, (const cocos2d::_ccColor4B *)&v92);
if ( v69 )
{
FLAlertLayer::incrementForcePrio(a1);
a1->setTouchEnabled(a1, 1);
a1->setKeypadEnabled(a1, 1);
a1->m_messageID = a2;
a1->m_accountID = a3;
if ( a3 <= 0 )
{
StoredUserMessageReply = nullptr;
}
else
{
v6 = GameLevelManager::sharedState();
StoredUserMessageReply = GameLevelManager::getStoredUserMessageReply(v6, a1->m_accountID);
}
v8 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(&v79, v8);
v9 = cocos2d::CCLayer::create();
v10 = a1->FLAlertLayer::cocos2d::CCLayerColor::cocos2d::CCLayerRGBA::cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a1->m_mainLayer = v9;
v10->addChild(a1, v9);
cocos2d::CCRect::CCRect(&v92, 0.0, 0.0, 80.0, 80.0);
v94.origin.x = v65;
v94.origin.y = v66;
v94.size = v93;
v11 = (cocos2d::CCNode *)cocos2d::extension::CCScale9Sprite::create(
(cocos2d::extension::CCScale9Sprite *)"GJ_square02.png",
(const char *)&v92,
v94);
((void (__fastcall *)(cocos2d::CCNode *, int))v11->__vftable[1].~CCNode_0)(v11, 255);
setContentSize = v11->setContentSize;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v92, 420.0, 240.0);
setContentSize(v11, (const cocos2d::CCSize *)&v92);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v11, -1);
cocos2d::CCPoint::CCPoint(&v80, v79.width * 0.5, v79.height * 0.5);
v11->setPosition(v11, &v80);
v13 = cocos2d::CCLabelBMFont::create();
setPosition = v13->setPosition;
cocos2d::CCPoint::CCPoint(&v92.origin, v79.width * 0.5, (float)((float)(v79.height * 0.5) + 120.0) - 16.0);
setPosition(v13, &v92.origin);
a1->m_mainLayer->addChild(a1->m_mainLayer, v13);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, int))v13->setScale)(v13, 1058642330);
sub_776584((int)&v71, "To: ");
v15 = GameLevelManager::sharedState();
GameLevelManager::tryGetUsername((GameLevelManager *)&v72, (GameLevelManager_vtbl *)v15, a1->m_messageID, (int)&v72);
sub_77441C(&v71, &v72);
v16 = cocos2d::CCLabelBMFont::create();
v17 = v16->setPosition;
v18 = (int)v13->getPosition(v13);
cocos2d::CCPoint::CCPoint(&v91.origin, 0.0, -20.0);
cocos2d::CCPoint::operator+(&v92, v18, &v91);
v17(v16, &v92.origin);
a1->m_mainLayer->addChild(a1->m_mainLayer, v16);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, int))v16->setScale)(v16, 1058642330);
a1->m_joystickConnected = -1;
v19 = cocos2d::CCMenu::create();
a1->m_buttonMenu = v19;
v20 = (cocos2d::CCArray *)((int (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCMenu *, int))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v19,
10);
v21 = (cocos2d::CCArray *)cocos2d::CCArray::create(v20);
if ( a1->m_accountID )
v22 = "Back";
else
v22 = "Cancel";
v23 = ButtonSprite::create(
(ButtonSprite *)v22,
(const char *)&dword_40 + 1,
0,
0.55,
1,
"bigFont.fnt",
"GJ_button_05.png",
(const char *)0x41D00000,
COERCE_FLOAT(&v72));
v88 = 0;
v87 = GJWriteMessagePopup::onClose;
v24 = CCMenuItemSpriteExtra::create(
v23,
nullptr,
(cocos2d::SEL_MenuHandler)__PAIR64__(GJWriteMessagePopup::onClose, (unsigned int)a1));
a1->m_buttonMenu->addChild(a1->m_buttonMenu, v24);
cocos2d::CCArray::addObject(v21, v24);
v25 = ButtonSprite::create(
(ButtonSprite *)"Send",
(const char *)&dword_40 + 1,
0,
0.55,
1,
"bigFont.fnt",
"GJ_button_01.png",
(const char *)0x41D00000,
v68);
v90 = 0;
v89 = GJWriteMessagePopup::onSend;
v26 = CCMenuItemSpriteExtra::create(
v25,
nullptr,
(cocos2d::SEL_MenuHandler)__PAIR64__(GJWriteMessagePopup::onSend, (unsigned int)a1));
a1->m_buttonMenu->addChild(a1->m_buttonMenu, v26);
cocos2d::CCArray::addObject(v21, v26);
m_buttonMenu = a1->m_buttonMenu;
x = v80.x;
v29 = (float)(v80.y - 120.0) + 22.0;
v30 = a1->m_mainLayer->getPosition(a1->m_mainLayer);
cocos2d::CCPoint::CCPoint(&v91.origin, x, v29 + v30->y);
cocos2d::CCNode::convertToNodeSpace(&v92.origin, m_buttonMenu, &v91.origin);
GameToolbox::alignItemsHorisontally(v21, 15.0, (cocos2d::CCPoint)(unsigned int)&v92, 0);
cocos2d::CCRect::CCRect(&v91, 0.0, 0.0, 80.0, 80.0);
cocos2d::CCPoint::CCPoint(&v81, v80.x, v80.y + 53.0);
cocos2d::CCRect::CCRect(&v92, 0.0, 0.0, 40.0, 40.0);
v31 = (cocos2d::CCNode *)cocos2d::extension::CCScale9Sprite::create(
(cocos2d::extension::CCScale9Sprite *)"square02_small.png",
(const char *)&v92,
v95);
((void (__fastcall *)(cocos2d::CCNode *, int))v31->__vftable[1].~CCNode_0)(v31, 100);
((void (__fastcall *)(cocos2d::CCNode *, cocos2d::ccColor3B *))v31->__vftable[1].getTag)(v31, &stru_9AC15C);
cocos2d::CCSize::CCSize(&v82, 370.0, 28.0);
v31->setContentSize(v31, &v82);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v31, 1);
v31->setPosition(v31, &v81);
getTag = v31->__vftable[1].getTag;
LOWORD(v92.origin.x) = 0;
BYTE2(v92.origin.x) = 0;
((void (__fastcall *)(cocos2d::CCNode *, cocos2d::CCRect *))getTag)(v31, &v92);
v33 = CCTextInputNode::create(370.0, 50.0, "Subject", "Thonburi");
a1->m_subjectInput = v33;
v33->m_filterSwearWords = 0;
((void (__fastcall *)(cocos2d::CCLayer *, CCTextInputNode *, int, void (__fastcall *)(cocos2d::CCNode *__hidden, cocos2d::CCNode *, int), int *, _DWORD))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v33,
20,
a1->m_mainLayer->addChild_0,
&dword_18,
0);
a1->m_subjectInput->m_delegate = &a1->TextInputDelegate;
a1->m_subjectInput->setPosition(a1->m_subjectInput, &v81);
m_subjectInput = a1->m_subjectInput;
sub_776584(
(int)v73,
" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,-!?:;)(/\\\"'`*=+-_%[]<>|@&^#{}%$~");
CCTextInputNode::setAllowedChars((int)m_subjectInput, (int)v73);
sub_774008(v73);
v35 = a1->m_subjectInput;
m_textField = v35->m_textField;
v35->m_maxLabelLength = 35;
m_textField->setVisible(m_textField, 0);
a1->m_subjectInput->setTag(a1->m_subjectInput, 0);
sub_776584((int)&v74, (char *)&unk_939830);
cocos2d::CCPoint::CCPoint(&v92.origin, 0.5, 0.5);
v67.x = 20.0;
LODWORD(v67.y) = (char *)&dword_0 + 1;
v37 = (TextArea *)TextArea::create(
(TextArea *)&v74,
(std::string)"chatFont.fnt",
(const char *)0x3F800000,
1134067712,
&v92.origin,
v67);
sub_774008(&v74);
CCTextInputNode::addTextArea(a1->m_subjectInput, v37);
v38 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", (const char *)&dword_C8);
cocos2d::CCString::getCString(v38);
v39 = cocos2d::CCLabelBMFont::create();
a1->m_subjectCountLabel = v39;
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v39, 2);
m_subjectCountLabel = a1->m_subjectCountLabel;
setAnchorPoint = m_subjectCountLabel->setAnchorPoint;
cocos2d::CCPoint::CCPoint(&v92.origin, 1.0, 0.5);
setAnchorPoint(m_subjectCountLabel, &v92.origin);
v42 = a1->m_subjectCountLabel;
v70 = v42->setPosition;
cocos2d::CCPoint::CCPoint(&v86, 175.0, 0.0);
cocos2d::CCPoint::operator+(&v92, &v81, &v86);
v70(v42, &v92.origin);
sub_776584((int)v75, (char *)&unk_939830);
GJWriteMessagePopup::updateSubject((char *)a1, v75);
sub_774008(v75);
cocos2d::CCPoint::CCPoint(&v83, v80.x, v80.y - 25.0);
cocos2d::CCRect::CCRect(&v92, &v91);
v43 = (cocos2d::CCNode *)cocos2d::extension::CCScale9Sprite::create(
(cocos2d::extension::CCScale9Sprite *)"square02b_001.png",
(const char *)&v92,
v96);
((void (__fastcall *)(cocos2d::CCNode *, int))v43->__vftable[1].~CCNode_0)(v43, 100);
cocos2d::CCSize::CCSize(&v84, 370.0, 106.0);
v43->setContentSize(v43, &v84);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v43, 1);
v43->setPosition(v43, &v83);
v44 = v43->__vftable[1].getTag;
LOWORD(v92.origin.x) = 0;
BYTE2(v92.origin.x) = 0;
((void (__fastcall *)(cocos2d::CCNode *, cocos2d::CCRect *))v44)(v43, &v92);
v45 = CCTextInputNode::create(370.0, 50.0, "Message", "Thonburi");
a1->m_messageInput = v45;
v45->m_filterSwearWords = 0;
((void (__fastcall *)(cocos2d::CCLayer *, CCTextInputNode *, int, void (__fastcall *)(cocos2d::CCNode *__hidden, cocos2d::CCNode *, int), int, _DWORD))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v45,
20,
a1->m_mainLayer->addChild_0,
24,
0);
a1->m_messageInput->m_delegate = &a1->TextInputDelegate;
a1->m_messageInput->setPosition(a1->m_messageInput, &v83);
m_messageInput = a1->m_messageInput;
sub_776584(
(int)v76,
" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,-!?:;)(/\\\"'`*=+-_%[]<>|@&^#{}%$~");
CCTextInputNode::setAllowedChars((int)m_messageInput, (int)v76);
sub_774008(v76);
v47 = a1->m_messageInput;
v48 = v47->m_textField;
v47->m_maxLabelLength = 200;
v48->setVisible(v48, 0);
a1->m_messageInput->setTag(a1->m_messageInput, 1);
v49 = a1->m_messageInput;
v50 = v49->setContentSize;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v92, 370.0, 96.0);
v50(v49, (const cocos2d::CCSize *)&v92);
a1->m_messageInput->m_forceOffset = 1;
sub_776584((int)&v77, (char *)&unk_939830);
cocos2d::CCPoint::CCPoint(&v92.origin, 0.5, 0.5);
v51 = (TextArea *)TextArea::create(
(TextArea *)&v77,
(std::string)"chatFont.fnt",
(const char *)0x3F800000,
1134067712,
&v92.origin,
(cocos2d::CCPoint)(COERCE_UNSIGNED_INT(20.0) | 0x100000000LL));
sub_774008(&v77);
CCTextInputNode::addTextArea(a1->m_messageInput, v51);
v52 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", (const char *)&dword_C8);
cocos2d::CCString::getCString(v52);
v53 = cocos2d::CCLabelBMFont::create();
a1->m_messageCountLabel = v53;
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v53, 2);
m_messageCountLabel = a1->m_messageCountLabel;
v55 = m_messageCountLabel->setAnchorPoint;
cocos2d::CCPoint::CCPoint(&v92.origin, 1.0, 0.5);
v55(m_messageCountLabel, &v92.origin);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, _DWORD, _DWORD))a1->m_messageCountLabel->setPosition_0)(
a1->m_messageCountLabel,
(float)(v80.x + 210.0) - 10.0,
(float)(v80.y + 120.0) - 14.0);
sub_776584((int)v78, (char *)&unk_939830);
GJWriteMessagePopup::updateBody((char *)a1, v78);
sub_774008(v78);
v56 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_resetBtn_001.png");
v92.origin.y = 0.0;
LODWORD(v92.origin.x) = GJWriteMessagePopup::onClearBody;
v57 = CCMenuItemSpriteExtra::create(
v56,
nullptr,
(cocos2d::SEL_MenuHandler)__PAIR64__(GJWriteMessagePopup::onClearBody, (unsigned int)a1));
a1->m_buttonMenu->addChild(a1->m_buttonMenu, v57);
v58 = a1->m_buttonMenu;
v59 = v57->setPosition;
cocos2d::CCPoint::CCPoint(
&v85,
(float)((float)(v79.width * 0.5) + 210.0) - 18.0,
(float)((float)(v79.height * 0.5) - 120.0) + 20.0);
cocos2d::CCNode::convertToNodeSpace(&v86, v58, &v85);
v59(v57, &v86);
if ( StoredUserMessageReply )
{
v60 = a1->m_subjectInput;
sub_775C20(&v85);
CCTextInputNode::setString((int)v60, (char *)&v85, v61);
sub_774008(&v85);
v62 = a1->m_messageInput;
sub_775C20(&v86);
CCTextInputNode::setString((int)v62, (char *)&v86, v63);
sub_774008(&v86);
}
sub_774008(&v72);
sub_774008(&v71);
}
return v69;
}