//
// GJWriteMessagePopup::init from 0x140299240 to 0x14029a0e0 (3744 bytes)
//
// 2 xrefs:
// > GJWriteMessagePopup::create @ 0x140299204
// > ??> @ 0x1406d1ce8
//
// 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=7
bool GJWriteMessagePopup::init(GJWriteMessagePopup *a1, int a2, int a3)
{
bool result; // al
_BOOL8 v7; // rdx
__int64 v8; // rcx
__int64 v9; // rax
cocos2d::CCTouchDispatcher *v10; // rax
_BOOL8 v11; // rdx
__int64 v12; // rcx
struct cocos2d::CCObject *v13; // r15
__int64 v14; // rcx
cocos2d::CCDirector *v15; // rax
cocos2d::CCLayer *v16; // rax
struct cocos2d::CCRect *v17; // rax
struct cocos2d::extension::CCScale9Sprite *v18; // rdi
__int64 v19; // rdx
cocos2d::extension::CCScale9Sprite_vtbl *v20; // rbx
const cocos2d::CCSize *v21; // rax
float v22; // xmm0_4
double v23; // xmm0_8
const char *v24; // rcx
struct cocos2d::CCLabelBMFont *v25; // r14
cocos2d::CCLabelBMFont_vtbl *v26; // rbx
const cocos2d::CCPoint *v27; // rax
__int64 v28; // rcx
void **v29; // rdx
const char *v30; // rcx
struct cocos2d::CCLabelBMFont *v31; // rdi
__int64 v32; // rax
double v33; // xmm0_8
__int64 v34; // rcx
cocos2d::CCMenu *v35; // rax
__int64 v36; // rcx
cocos2d::CCArray *v37; // r14
const char *v38; // rdi
ButtonSprite *v39; // rbx
CCMenuItemSpriteExtra *v40; // rbx
ButtonSprite *v41; // rbx
CCMenuItemSpriteExtra *v42; // rbx
struct cocos2d::CCPoint v43; // rax
double v44; // xmm0_8
struct cocos2d::CCRect *v45; // rax
struct cocos2d::extension::CCScale9Sprite *v46; // rbx
cocos2d::CCRGBAProtocol *v47; // rdi
__int64 v48; // rdx
const char *v49; // r9
CCTextInputNode *v50; // rax
std::string *p_m_allowedChars; // rcx
void **v52; // rdx
const struct cocos2d::CCPoint *v53; // rax
char *v54; // rax
cocos2d::CCString *v55; // rax
const char *CString; // rax
cocos2d::CCLabelBMFont *v57; // rax
float v58; // xmm0_4
cocos2d::CCLabelBMFont_vtbl *v59; // rbx
__int64 v60; // rax
float v61; // xmm0_4
float updated; // xmm0_4
struct cocos2d::CCRect *v63; // rax
struct cocos2d::extension::CCScale9Sprite *v64; // rbx
__int64 v65; // rdx
const char *v66; // r9
CCTextInputNode *v67; // rax
std::string *v68; // rcx
void **v69; // rdx
CCTextInputNode_vtbl *v70; // rbx
const cocos2d::CCSize *v71; // rax
const struct cocos2d::CCPoint *v72; // rax
char *v73; // rax
cocos2d::CCString *v74; // rax
const char *v75; // rax
cocos2d::CCLabelBMFont *v76; // rax
float v77; // xmm0_4
cocos2d::CCLabelBMFont_vtbl *v78; // rbx
const cocos2d::CCPoint *v79; // rax
struct cocos2d::CCSprite *v80; // rax
CCMenuItemSpriteExtra *v81; // rdi
float v82; // xmm0_4
CCMenuItemSpriteExtra_vtbl *v83; // rbx
struct cocos2d::CCPoint v84; // rax
int v85; // [rsp+28h] [rbp-E0h]
int v86; // [rsp+28h] [rbp-E0h]
cocos2d::CCSize v87; // [rsp+58h] [rbp-B0h] BYREF
cocos2d::CCRect v88; // [rsp+60h] [rbp-A8h] BYREF
_QWORD v89[3]; // [rsp+70h] [rbp-98h] BYREF
__int64 v90; // [rsp+88h] [rbp-80h]
__int64 v91; // [rsp+90h] [rbp-78h]
float v92; // [rsp+98h] [rbp-70h]
cocos2d::CCPoint v93; // [rsp+A0h] [rbp-68h] BYREF
void *Src[2]; // [rsp+A8h] [rbp-60h] BYREF
size_t Size; // [rsp+B8h] [rbp-50h]
unsigned __int64 v96; // [rsp+C0h] [rbp-48h]
void *v97[2]; // [rsp+C8h] [rbp-40h] BYREF
size_t v98; // [rsp+D8h] [rbp-30h]
unsigned __int64 v99; // [rsp+E0h] [rbp-28h]
cocos2d::CCPoint v100; // [rsp+E8h] [rbp-20h] BYREF
cocos2d::CCSize v101; // [rsp+F0h] [rbp-18h] BYREF
cocos2d::CCSize v102; // [rsp+F8h] [rbp-10h] BYREF
cocos2d::CCRect v103; // [rsp+100h] [rbp-8h] BYREF
__int128 v104; // [rsp+110h] [rbp+8h] BYREF
__int64 v105; // [rsp+120h] [rbp+18h]
unsigned __int64 v106; // [rsp+128h] [rbp+20h]
void *v107[4]; // [rsp+130h] [rbp+28h] BYREF
v87.width = -1.0339758e-25;
result = cocos2d::CCLayerColor::initWithColor(a1, (const struct cocos2d::_ccColor4B *)&v87);
if ( result )
{
if ( !a1->m_forcePrioRegistered )
{
a1->m_forcePrioRegistered = 1;
v9 = cocos2d::CCDirector::sharedDirector(v8);
v10 = (cocos2d::CCTouchDispatcher *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v9 + 144LL))(v9);
cocos2d::CCTouchDispatcher::registerForcePrio(v10, a1, 2);
}
LOBYTE(v7) = 1;
a1->setTouchEnabled(a1, v7);
LOBYTE(v11) = 1;
a1->setKeypadEnabled(a1, v11);
a1->m_messageID = a2;
a1->m_accountID = a3;
v13 = nullptr;
if ( a3 > 0 )
{
v14 = qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v87 = (cocos2d::CCSize)operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280(*(_QWORD *)&v87);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v14 = qword_1406C2EC0;
}
v13 = cocos2d::CCDictionary::objectForKey(*(cocos2d::CCDictionary **)(v14 + 624), a1->m_accountID);
}
v15 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v12);
cocos2d::CCDirector::getWinSize(v15);
v16 = (cocos2d::CCLayer *)cocos2d::CCLayer::create();
a1->m_mainLayer = v16;
a1->addChild_1(a1, v16);
cocos2d::CCRect::CCRect(&v88, 0.0, 0.0, 80.0, 80.0);
v18 = cocos2d::extension::CCScale9Sprite::create("GJ_square02.png", v17);
LOBYTE(v19) = -1;
v18->setOpacity(&v18->cocos2d::CCRGBAProtocol, v19);
v20 = v18->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCSize::CCSize(&v87, 420.0, 240.0);
v20->setContentSize(v18, v21);
v22 = ((float (__fastcall *)(cocos2d::CCLayer *, struct cocos2d::extension::CCScale9Sprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v18,
0xFFFFFFFFLL);
v23 = cocos2d::CCPoint::CCPoint(v22, v92 * 0.5);
v18->setPosition_0(v18, (const cocos2d::CCPoint *)v89);
v24 = "Send Message";
if ( a1->m_accountID )
v24 = "Send Reply";
v25 = cocos2d::CCLabelBMFont::create(v24, (const char *)&qword_14052A4D8);
v26 = v25->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(*(float *)&v23, v92 * 0.5);
v26->setPosition_0(v25, v27);
a1->m_mainLayer->addChild_1(a1->m_mainLayer, v25);
((void (__fastcall *)(struct cocos2d::CCLabelBMFont *))v25->setScale_0)(v25);
v104 = 0;
v105 = 4;
v106 = 15;
strcpy((char *)&v104, "To: ");
v28 = qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v87 = (cocos2d::CCSize)operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280(*(_QWORD *)&v87);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v28 = qword_1406C2EC0;
}
GameLevelManager::tryGetUsername(v28, (__int64)v107, a1->m_messageID);
v29 = v107;
if ( v107[3] > (void *)0xF )
v29 = (void **)v107[0];
sub_140041270(&v104, v29, (size_t)v107[2]);
v30 = (const char *)&v104;
if ( v106 > 0xF )
v30 = (const char *)v104;
v31 = cocos2d::CCLabelBMFont::create(v30, "goldFont.fnt");
cocos2d::CCPoint::CCPoint(0.0, 0.0);
v32 = (__int64)v25->getPosition_0(v25);
cocos2d::CCPoint::operator+(v32, &v87);
v31->setPosition_0(v31, (const cocos2d::CCPoint *)&v87);
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);
a1->m_joystickConnected = -1;
v35 = (cocos2d::CCMenu *)cocos2d::CCMenu::create(v34);
a1->m_buttonMenu = v35;
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v35, 10);
v37 = (cocos2d::CCArray *)cocos2d::CCArray::create(v36);
v38 = "Cancel";
if ( a1->m_accountID )
v38 = "Back";
v88.origin = (cocos2d::CCPoint)operator new(0x2C0u);
v39 = ButtonSprite::ButtonSprite(*(ButtonSprite **)&v88.origin);
if ( v39 )
{
if ( ButtonSprite::init_1(
v39,
v38,
65,
0,
0.55000001,
1,
(const char *)&qword_14052A4D8,
"GJ_button_05.png",
26.0) )
{
cocos2d::CCObject::autorelease(v39);
}
else
{
((void (__fastcall *)(ButtonSprite *, __int64))v39->~ButtonSprite)(v39, 1);
v39 = nullptr;
}
}
v40 = CCMenuItemSpriteExtra::create(v39, nullptr, a1, (cocos2d::SEL_MenuHandler *)GJWriteMessagePopup::onClose);
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, v40);
cocos2d::CCArray::addObject(v37, v40);
v88.origin = (cocos2d::CCPoint)operator new(0x2C0u);
v41 = ButtonSprite::ButtonSprite(*(ButtonSprite **)&v88.origin);
if ( v41 )
{
if ( ButtonSprite::init_1(
v41,
"Send",
65,
0,
0.55000001,
1,
(const char *)&qword_14052A4D8,
"GJ_button_01.png",
26.0) )
{
cocos2d::CCObject::autorelease(v41);
}
else
{
((void (__fastcall *)(ButtonSprite *, __int64))v41->~ButtonSprite)(v41, 1);
v41 = nullptr;
}
}
v42 = CCMenuItemSpriteExtra::create(v41, nullptr, a1, (cocos2d::SEL_MenuHandler *)GJWriteMessagePopup::onSend);
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, v42);
cocos2d::CCArray::addObject(v37, v42);
a1->m_mainLayer->getPosition_0(a1->m_mainLayer);
cocos2d::CCPoint::CCPoint(*(float *)&v33, *(float *)v89);
v43 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, (const struct cocos2d::CCPoint *)&v87);
GameToolbox::alignItemsHorisontally(v37, 15.0, v43, 0);
v44 = cocos2d::CCRect::CCRect(&v103, 0.0, 0.0, 80.0, 80.0);
cocos2d::CCPoint::CCPoint(*(float *)&v44, *(float *)v89);
cocos2d::CCRect::CCRect(&v88, 0.0, 0.0, 40.0, 40.0);
v46 = cocos2d::extension::CCScale9Sprite::create("square02_small.png", v45);
v47 = &v46->cocos2d::CCRGBAProtocol;
LOBYTE(v48) = 100;
v46->setOpacity(&v46->cocos2d::CCRGBAProtocol, v48);
v47->setColor(v47, &stru_140529AD4);
cocos2d::CCSize::CCSize(&v101, 370.0, 28.0);
v46->setContentSize(v46, &v101);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v46, 1);
v46->setPosition_0(v46, &v93);
LOWORD(v87.width) = 0;
BYTE2(v87.width) = 0;
v47->setColor(v47, (const cocos2d::ccColor3B *)&v87);
v50 = CCTextInputNode::create(370.0, 50.0, "Subject", v49, v85, nullptr);
a1->m_subjectInput = v50;
v50->m_filterSwearWords = 0;
a1->m_mainLayer->addChild_0(a1->m_mainLayer, a1->m_subjectInput, 20);
a1->m_subjectInput->m_delegate = &a1->TextInputDelegate;
a1->m_subjectInput->setPosition_0(a1->m_subjectInput, &v93);
*(_OWORD *)Src = 0;
Size = 0;
v96 = 15;
Src[0] = sub_14003AA10(0x70u);
Size = 97;
v96 = 111;
strcpy(
(char *)Src[0],
" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,-!?:;)(/\\\"'`*=+-_%[]<>|@&^#{}%$~");
v88.origin = (cocos2d::CCPoint)Src;
p_m_allowedChars = &a1->m_subjectInput->m_allowedChars;
if ( p_m_allowedChars != (std::string *)Src )
{
v52 = Src;
if ( v96 > 0xF )
v52 = (void **)Src[0];
sub_14003CCE0((void **)p_m_allowedChars, v52, Size);
}
sub_14003A830((__int64)Src);
a1->m_subjectInput->m_maxLabelLength = 35;
a1->m_subjectInput->m_textField->setVisible(a1->m_subjectInput->m_textField, 0);
a1->m_subjectInput->setTag(a1->m_subjectInput, 0);
v88.origin = (cocos2d::CCPoint)&v89[1];
*(_OWORD *)&v89[1] = 0;
v90 = 0;
v91 = 15;
LOBYTE(v89[1]) = 0;
cocos2d::CCPoint::CCPoint(0.0, 0.5);
v54 = TextArea::create((__int64)&v89[1], "chatFont.fnt", 1.0, 305.0, v53, 1101004800, 1);
CCTextInputNode::addTextArea(a1->m_subjectInput, (TextArea *)v54);
v55 = cocos2d::CCString::createWithFormat("%i", 200);
CString = cocos2d::CCString::getCString(v55);
v57 = cocos2d::CCLabelBMFont::create(CString, "chatFont.fnt");
a1->m_subjectCountLabel = v57;
v58 = ((float (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCLabelBMFont *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v57,
2);
v59 = a1->m_subjectCountLabel->__vftable;
cocos2d::CCPoint::CCPoint(v58, 1.0);
v61 = ((float (__fastcall *)(cocos2d::CCLabelBMFont *, __int64))v59->setAnchorPoint)(a1->m_subjectCountLabel, v60);
cocos2d::CCPoint::CCPoint(v61, 175.0);
cocos2d::CCPoint::operator+(&v93, &v87);
a1->m_subjectCountLabel->setPosition_0(a1->m_subjectCountLabel, (const cocos2d::CCPoint *)&v87);
*(_OWORD *)&v89[1] = 0;
v90 = 0;
v91 = 15;
LOBYTE(v89[1]) = 0;
updated = GJWriteMessagePopup::updateSubject(a1, &v89[1]);
cocos2d::CCPoint::CCPoint(updated, *(float *)v89);
v63 = (struct cocos2d::CCRect *)cocos2d::CCRect::CCRect(&v88, &v103);
v64 = cocos2d::extension::CCScale9Sprite::create("square02b_001.png", v63);
LOBYTE(v65) = 100;
v64->setOpacity(&v64->cocos2d::CCRGBAProtocol, v65);
cocos2d::CCSize::CCSize(&v102, 370.0, 106.0);
v64->setContentSize(v64, &v102);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v64, 1);
v64->setPosition_0(v64, &v100);
LOWORD(v87.width) = 0;
BYTE2(v87.width) = 0;
v64->setColor(&v64->cocos2d::CCRGBAProtocol, (const cocos2d::ccColor3B *)&v87);
v67 = CCTextInputNode::create(370.0, 50.0, "Message", v66, v86, nullptr);
a1->m_messageInput = v67;
v67->m_filterSwearWords = 0;
a1->m_mainLayer->addChild_0(a1->m_mainLayer, a1->m_messageInput, 20);
a1->m_messageInput->m_delegate = &a1->TextInputDelegate;
a1->m_messageInput->setPosition_0(a1->m_messageInput, &v100);
*(_OWORD *)v97 = 0;
v98 = 0;
v99 = 15;
v97[0] = sub_14003AA10(0x70u);
v98 = 97;
v99 = 111;
strcpy(
(char *)v97[0],
" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,-!?:;)(/\\\"'`*=+-_%[]<>|@&^#{}%$~");
v88.origin = (cocos2d::CCPoint)v97;
v68 = &a1->m_messageInput->m_allowedChars;
if ( v68 != (std::string *)v97 )
{
v69 = v97;
if ( v99 > 0xF )
v69 = (void **)v97[0];
sub_14003CCE0((void **)v68, v69, v98);
}
sub_14003A830((__int64)v97);
a1->m_messageInput->m_maxLabelLength = 200;
a1->m_messageInput->m_textField->setVisible(a1->m_messageInput->m_textField, 0);
a1->m_messageInput->setTag(a1->m_messageInput, 1);
v70 = a1->m_messageInput->__vftable;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v88, 370.0, 96.0);
v70->setContentSize(a1->m_messageInput, v71);
v88.origin = (cocos2d::CCPoint)&v89[1];
*(_OWORD *)&v89[1] = 0;
v90 = 0;
v91 = 15;
LOBYTE(v89[1]) = 0;
cocos2d::CCPoint::CCPoint(0.0, 0.5);
v73 = TextArea::create((__int64)&v89[1], "chatFont.fnt", 1.0, 305.0, v72, 1101004800, 1);
CCTextInputNode::addTextArea(a1->m_messageInput, (TextArea *)v73);
v74 = cocos2d::CCString::createWithFormat("%i", 200);
v75 = cocos2d::CCString::getCString(v74);
v76 = cocos2d::CCLabelBMFont::create(v75, "chatFont.fnt");
a1->m_messageCountLabel = v76;
v77 = ((float (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCLabelBMFont *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v76,
2);
v78 = a1->m_messageCountLabel->__vftable;
cocos2d::CCPoint::CCPoint(v77, 1.0);
v78->setAnchorPoint(a1->m_messageCountLabel, v79);
((void (__fastcall *)(cocos2d::CCLabelBMFont *))a1->m_messageCountLabel->setPosition)(a1->m_messageCountLabel);
*(_OWORD *)&v89[1] = 0;
v90 = 0;
v91 = 15;
LOBYTE(v89[1]) = 0;
GJWriteMessagePopup::updateBody(a1, &v89[1]);
v80 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_resetBtn_001.png");
v81 = CCMenuItemSpriteExtra::create(v80, nullptr, a1, (cocos2d::SEL_MenuHandler *)GJWriteMessagePopup::onClearBody);
v82 = ((float (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild_1)(
a1->m_buttonMenu,
v81);
v83 = v81->cocos2d::CCMenuItemSprite::cocos2d::CCMenuItem::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(v82, (float)((float)(v92 * 0.5) + 210.0) - 18.0);
v84 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, (const struct cocos2d::CCPoint *)&v87);
((void (__fastcall *)(CCMenuItemSpriteExtra *, struct cocos2d::CCPoint))v83->setPosition_0)(v81, v84);
if ( v13 )
{
sub_14003BDB0((__int64)&v89[1], (__int64)&v13[6]);
CCTextInputNode::setString((__int64)a1->m_subjectInput, &v89[1]);
sub_14003BDB0((__int64)&v89[1], (__int64)&v13[6].m_uIndexInArray);
CCTextInputNode::setString((__int64)a1->m_messageInput, &v89[1]);
}
sub_14003A830((__int64)v107);
sub_14003A830((__int64)&v104);
return 1;
}
return result;
}