//
// GJWriteMessagePopup::init from 0x1002dbc90 to 0x1002dc868 (3032 bytes)
//
// 1 xrefs:
// > GJWriteMessagePopup::create @ 0x1002db5d0
//
// 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 __fastcall GJWriteMessagePopup::init(GJWriteMessagePopup *a1, int a2, int a3)
{
_BOOL4 v6; // w19
GameLevelManager *v7; // x0
GJUserMessage *StoredUserMessageReply; // x21
cocos2d::CCDirector *v9; // x0
cocos2d::CCLayer *v10; // x0
cocos2d::extension::CCScale9Sprite *v11; // x22
__n128 v12; // q0
__n128 v13; // q1
const char *v14; // x0
cocos2d::CCLabelBMFont *v15; // x22
__n128 v16; // q0
__n128 v17; // q1
GameLevelManager *v18; // x0
const std::string::value_type *v19; // x1
std::string::size_type v20; // x2
std::string *v21; // x0
cocos2d::CCLabelBMFont *v22; // x23
float32x2_t *v23; // x22
__n128 v24; // q0
__n128 v25; // q1
double v26; // d0
cocos2d::CCArray *v27; // x22
const char *v28; // x0
ButtonSprite *v29; // x0
CCMenuItemSpriteExtra *v30; // x0
ButtonSprite *v31; // x0
CCMenuItemSpriteExtra *v32; // x0
cocos2d::CCMenu *m_buttonMenu; // x23
unsigned __int32 v34; // s8
float v35; // s9
__n128 v36; // q1
__n128 v37; // q0
__n128 v38; // q0
__n128 v39; // q1
cocos2d::extension::CCScale9Sprite *v40; // x22
CCTextInputNode *v41; // x0
CCTextInputNode *m_subjectInput; // x0
std::string *v43; // x22
CCTextInputNode *v44; // x8
__n128 v45; // q0
__n128 v46; // q1
TextArea *v47; // x22
cocos2d::CCString *v48; // x0
const char *CString; // x0
__n128 v50; // q0
cocos2d::CCLabelBMFont *m_subjectCountLabel; // x22
__n128 v52; // q1
__n128 v53; // q0
cocos2d::CCLabelBMFont *v54; // x22
__n128 v55; // q1
double v56; // d0
__n128 v57; // q0
__n128 v58; // q1
double v59; // d0
cocos2d::extension::CCScale9Sprite *v60; // x22
CCTextInputNode *v61; // x0
CCTextInputNode *m_messageInput; // x0
std::string *v63; // x22
CCTextInputNode *v64; // x8
CCTextInputNode *v65; // x22
__n128 v66; // q0
__n128 v67; // q1
TextArea *v68; // x22
cocos2d::CCString *v69; // x0
const char *v70; // x0
__n128 v71; // q0
cocos2d::CCLabelBMFont *m_messageCountLabel; // x22
__n128 v73; // q1
cocos2d::CCSprite *v74; // x0
CCMenuItemSpriteExtra *v75; // x22
__n128 v76; // q0
cocos2d::CCMenu *v77; // x23
__n128 v78; // q1
CCTextInputNode *v79; // x22
CCTextInputNode *v80; // x20
float v82; // s1
float v83; // s2
float v84; // s3
void *v85[2]; // [xsp+10h] [xbp-190h] BYREF
char *v86; // [xsp+20h] [xbp-180h]
void *__dst[2]; // [xsp+30h] [xbp-170h] BYREF
char *longStorage; // [xsp+40h] [xbp-160h]
cocos2d::CCPoint v89; // [xsp+48h] [xbp-158h] BYREF
void *v90[2]; // [xsp+50h] [xbp-150h] BYREF
char v91; // [xsp+67h] [xbp-139h]
void *v92[2]; // [xsp+68h] [xbp-138h] BYREF
char v93; // [xsp+7Fh] [xbp-121h]
__int64 v94; // [xsp+80h] [xbp-120h] BYREF
std::string v95; // [xsp+88h] [xbp-118h] BYREF
void *v96[2]; // [xsp+A0h] [xbp-100h] BYREF
char v97; // [xsp+B7h] [xbp-E9h]
float32x2_t v98; // [xsp+B8h] [xbp-E8h] BYREF
void *__p[2]; // [xsp+C0h] [xbp-E0h] BYREF
char v100; // [xsp+D7h] [xbp-C9h]
std::string v101; // [xsp+D8h] [xbp-C8h] BYREF
float v102; // [xsp+F0h] [xbp-B0h] BYREF
float32x2_t v103[2]; // [xsp+F8h] [xbp-A8h] BYREF
float32x2_t v104; // [xsp+108h] [xbp-98h] BYREF
float32x2_t v105[2]; // [xsp+110h] [xbp-90h] BYREF
void *v106[2]; // [xsp+120h] [xbp-80h] BYREF
unsigned __int8 v107; // [xsp+137h] [xbp-69h]
std::string v108; // [xsp+138h] [xbp-68h] BYREF
float v109; // [xsp+150h] [xbp-50h] BYREF
float v110; // [xsp+154h] [xbp-4Ch]
float v111; // [xsp+158h] [xbp-48h]
float v112; // [xsp+15Ch] [xbp-44h]
cocos2d::CCPoint v113; // 0:kr10_8.8
cocos2d::SEL_MenuHandler v114; // 0:x3.16
cocos2d::SEL_MenuHandler v115; // 0:x3.16
cocos2d::SEL_MenuHandler v116; // 0:x3.16
cocos2d::CCRect v117; // 0:kr20_16.16
cocos2d::CCPoint v118; // 0:s1.4,4:s2.4
cocos2d::CCRect v119; // 0:s0.4,4:s1.4,8:s2.4,12:s3.4
cocos2d::CCRect v120; // 0:s0.4,4:s1.4,8:s2.4,12:s3.4
LODWORD(v108.__r_.__value_.__l.__data_) = -1778384896;
v6 = cocos2d::CCLayerColor::initWithColor(a1, (const cocos2d::ccColor4B *)&v108);
if ( v6 )
{
FLAlertLayer::incrementForcePrio(a1);
((void (__fastcall *)(GJWriteMessagePopup *, __int64))a1->setTouchEnabled)(a1, 1);
((void (__fastcall *)(GJWriteMessagePopup *, __int64))a1->setKeypadEnabled)(a1, 1);
a1->m_messageID = a2;
a1->m_accountID = a3;
if ( a3 < 1 )
{
StoredUserMessageReply = nullptr;
}
else
{
v7 = GameLevelManager::sharedState();
StoredUserMessageReply = GameLevelManager::getStoredUserMessageReply(v7, a1->m_accountID);
}
v9 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v9);
v10 = cocos2d::CCLayer::create();
a1->m_mainLayer = v10;
((void (__fastcall *)(GJWriteMessagePopup *, cocos2d::CCLayer *))a1->addChild)(a1, v10);
sub_100022990((float *)&v108, 0.0, 0.0, 80.0, 80.0);
v11 = cocos2d::extension::CCScale9Sprite::create("GJ_square02.png", v119);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, __int64))v11->setOpacity)(v11, 255);
sub_100022988((float *)&v108, 420.0, 240.0);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, std::string *))v11->setContentSize)(v11, &v108);
v12 = ((__n128 (__fastcall *)(cocos2d::CCLayer *, cocos2d::extension::CCScale9Sprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v11,
0xFFFFFFFFLL);
v12.n128_f32[0] = v111 * 0.5;
v13.n128_f32[0] = v112 * 0.5;
sub_100022980(v12, v13, &v109);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, float *))v11->setPosition)(v11, &v109);
if ( a1->m_accountID )
v14 = "Send Reply";
else
v14 = "Send Message";
v15 = cocos2d::CCLabelBMFont::create_1(v14, "bigFont.fnt");
v16.n128_f32[0] = v111 * 0.5;
v17.n128_f32[0] = (float)((float)(v112 * 0.5) + 120.0) + -16.0;
sub_100022980(v16, v17, &v108);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, std::string *))v15->setPosition)(v15, &v108);
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCLabelBMFont *))a1->m_mainLayer->addChild)(a1->m_mainLayer, v15);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float))v15->setScale)(v15, 0.6);
sub_100009900(&v108, "To: ");
v18 = GameLevelManager::sharedState();
GameLevelManager::tryGetUsername((__int64)v18, a1->m_messageID, (__int64)v106);
if ( (v107 & 0x80u) == 0 )
v19 = (const std::string::value_type *)v106;
else
v19 = (const std::string::value_type *)v106[0];
if ( (v107 & 0x80u) == 0 )
v20 = v107;
else
v20 = (std::string::size_type)v106[1];
std::string::append(&v108, v19, v20);
if ( (v108.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v21 = &v108;
else
v21 = (std::string *)v108.__r_.__value_.__r.__words[0];
v22 = cocos2d::CCLabelBMFont::create_1((const char *)v21, "goldFont.fnt");
v23 = (float32x2_t *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))v15->getPosition)(v15);
v24.n128_u32[0] = 0;
v25.n128_u32[0] = -20.0;
sub_100022980(v24, v25, v103);
*(float32x2_t *)&v26 = sub_1000229DC(v23, v103, v105);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float32x2_t *, double))v22->setPosition)(v22, v105, v26);
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCLabelBMFont *))a1->m_mainLayer->addChild)(a1->m_mainLayer, v22);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float))v22->setScale)(v22, 0.6);
a1->m_joystickConnected = -1;
a1->m_buttonMenu = cocos2d::CCMenu::create();
((void (__fastcall *)(cocos2d::CCLayer *))a1->m_mainLayer->addChild_0)(a1->m_mainLayer);
v27 = (cocos2d::CCArray *)sub_10024A15C();
if ( a1->m_accountID )
v28 = "Back";
else
v28 = "Cancel";
v29 = ButtonSprite::create_1(v28, 65, 0, 0.55, 1, "bigFont.fnt", "GJ_button_05.png", 26.0);
v114.ptr = (void (__cdecl *)(cocos2d::CCObject *))GJWriteMessagePopup::onClose;
v114.adj = 0;
v30 = CCMenuItemSpriteExtra::create(v29, nullptr, a1, v114);
((void (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild)(a1->m_buttonMenu, v30);
sub_10024A2D0((__int64)v27);
v31 = ButtonSprite::create_1("Send", 65, 0, 0.55, 1, "bigFont.fnt", "GJ_button_01.png", 26.0);
v115.ptr = (void (__cdecl *)(cocos2d::CCObject *))GJWriteMessagePopup::onSend;
v115.adj = 0;
v32 = CCMenuItemSpriteExtra::create(v31, nullptr, a1, v115);
((void (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild)(a1->m_buttonMenu, v32);
sub_10024A2D0((__int64)v27);
m_buttonMenu = a1->m_buttonMenu;
v34 = LODWORD(v109);
v35 = v110;
v36.n128_f32[0] = (float)((float)(v35 + -120.0) + 22.0)
+ *(float *)(((__int64 (__fastcall *)(cocos2d::CCLayer *))a1->m_mainLayer->getPosition)(a1->m_mainLayer)
+ 4);
v37.n128_u32[0] = v34;
sub_100022980(v37, v36, v103);
LODWORD(v118.x) = COERCE_UNSIGNED_INT(cocos2d::CCNode::convertToNodeSpace(
m_buttonMenu,
(const cocos2d::CCPoint *)v103).y);
GameToolbox::alignItemsHorisontally(v27, 15.0, v118, (bool)v105);
sub_100022990((float *)v105, 0.0, 0.0, 80.0, 80.0);
v38.n128_f32[0] = v109;
v39.n128_f32[0] = v110 + 53.0;
sub_100022980(v38, v39, &v104);
sub_100022990((float *)v103, 0.0, 0.0, 40.0, 40.0);
v40 = cocos2d::extension::CCScale9Sprite::create("square02_small.png", v120);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, __int64))v40->setOpacity)(v40, 100);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, void *))v40->setColor)(v40, &unk_100644748);
sub_100022988(&v102, 370.0, 28.0);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, float *))v40->setContentSize)(v40, &v102);
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::extension::CCScale9Sprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v40,
1);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, float32x2_t *))v40->setPosition)(v40, &v104);
v103[0].i8[2] = 0;
v103[0].i16[0] = 0;
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, float32x2_t *))v40->setColor)(v40, v103);
v41 = CCTextInputNode::create(370.0, 50.0, "Subject", "Thonburi", 24, nullptr);
a1->m_subjectInput = v41;
v41->m_filterSwearWords = 0;
((void (__fastcall *)(cocos2d::CCLayer *))a1->m_mainLayer->addChild_0)(a1->m_mainLayer);
m_subjectInput = a1->m_subjectInput;
m_subjectInput->m_delegate = &a1->TextInputDelegate;
((void (__fastcall *)(CCTextInputNode *, float32x2_t *))m_subjectInput->setPosition)(m_subjectInput, &v104);
v43 = (std::string *)a1->m_subjectInput;
sub_100009900(
&v101,
" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,-!?:;)(/\\\"'`*=+-_%[]<>|@&^#{}%$~");
CCTextInputNode::setAllowedChars(v43, &v101);
if ( SHIBYTE(v101.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v101.__r_.__value_.__l.__data_);
v44 = a1->m_subjectInput;
v44->m_maxLabelLength = 35;
((void (__fastcall *)(cocos2d::CCTextFieldTTF *, _QWORD))v44->m_textField->setVisible)(v44->m_textField, 0);
((void (__fastcall *)(CCTextInputNode *, _QWORD))a1->m_subjectInput->setTag)(a1->m_subjectInput, 0);
sub_100009900(__p, "");
v45.n128_u32[0] = 0.5;
v46.n128_u32[0] = 0.5;
sub_100022980(v45, v46, v103);
v47 = (TextArea *)TextArea::create((__int64)__p, (__int64)"chatFont.fnt", (__int64 *)v103, 1, 1.0, 305.0, 20.0);
if ( v100 < 0 )
operator delete(__p[0]);
CCTextInputNode::addTextArea(a1->m_subjectInput, v47);
v48 = (cocos2d::CCString *)sub_100268F4C("%i", 200);
CString = cocos2d::CCString::getCString(v48);
a1->m_subjectCountLabel = cocos2d::CCLabelBMFont::create_1(CString, "chatFont.fnt");
v50 = ((__n128 (__fastcall *)(cocos2d::CCLayer *))a1->m_mainLayer->addChild_0)(a1->m_mainLayer);
m_subjectCountLabel = a1->m_subjectCountLabel;
v50.n128_u32[0] = 1.0;
v52.n128_u32[0] = 0.5;
sub_100022980(v50, v52, v103);
v53 = ((__n128 (__fastcall *)(cocos2d::CCLabelBMFont *, float32x2_t *))m_subjectCountLabel->setAnchorPoint)(
m_subjectCountLabel,
v103);
v54 = a1->m_subjectCountLabel;
v53.n128_u32[0] = 1127153664;
v55.n128_u32[0] = 0;
sub_100022980(v53, v55, &v98);
*(float32x2_t *)&v56 = sub_1000229DC(&v104, &v98, v103);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float32x2_t *, double))v54->setPosition)(v54, v103, v56);
sub_100009900(v96, "");
GJWriteMessagePopup::updateSubject(a1, v96);
if ( v97 < 0 )
operator delete(v96[0]);
v57.n128_f32[0] = v109;
v58.n128_f32[0] = v110 + -25.0;
sub_100022980(v57, v58, &v98);
v59 = sub_100022B98(v103, (__int64)v105);
v117.origin.x = *(float *)&v59;
v117.origin.y = v82;
v117.size.width = v83;
v117.size.height = v84;
v60 = cocos2d::extension::CCScale9Sprite::create("square02b_001.png", v117);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, __int64))v60->setOpacity)(v60, 100);
sub_100022988((float *)v103, 370.0, 106.0);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, float32x2_t *))v60->setContentSize)(v60, v103);
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::extension::CCScale9Sprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v60,
1);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, float32x2_t *))v60->setPosition)(v60, &v98);
BYTE2(v94) = 0;
LOWORD(v94) = 0;
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, __int64 *))v60->setColor)(v60, &v94);
v61 = CCTextInputNode::create(370.0, 50.0, "Message", "Thonburi", 24, nullptr);
a1->m_messageInput = v61;
v61->m_filterSwearWords = 0;
((void (__fastcall *)(cocos2d::CCLayer *))a1->m_mainLayer->addChild_0)(a1->m_mainLayer);
m_messageInput = a1->m_messageInput;
m_messageInput->m_delegate = &a1->TextInputDelegate;
((void (__fastcall *)(CCTextInputNode *, float32x2_t *))m_messageInput->setPosition)(m_messageInput, &v98);
v63 = (std::string *)a1->m_messageInput;
sub_100009900(
&v95,
" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,-!?:;)(/\\\"'`*=+-_%[]<>|@&^#{}%$~");
CCTextInputNode::setAllowedChars(v63, &v95);
if ( SHIBYTE(v95.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v95.__r_.__value_.__l.__data_);
v64 = a1->m_messageInput;
v64->m_maxLabelLength = 200;
((void (__fastcall *)(cocos2d::CCTextFieldTTF *, _QWORD))v64->m_textField->setVisible)(v64->m_textField, 0);
((void (__fastcall *)(CCTextInputNode *, __int64))a1->m_messageInput->setTag)(a1->m_messageInput, 1);
v65 = a1->m_messageInput;
sub_100022988((float *)&v94, 370.0, 96.0);
((void (__fastcall *)(CCTextInputNode *, __int64 *))v65->setContentSize)(v65, &v94);
a1->m_messageInput->m_forceOffset = 1;
sub_100009900(v92, "");
v66.n128_u32[0] = 0.5;
v67.n128_u32[0] = 0.5;
sub_100022980(v66, v67, &v94);
v68 = (TextArea *)TextArea::create((__int64)v92, (__int64)"chatFont.fnt", &v94, 1, 1.0, 305.0, 20.0);
if ( v93 < 0 )
operator delete(v92[0]);
CCTextInputNode::addTextArea(a1->m_messageInput, v68);
v69 = (cocos2d::CCString *)sub_100268F4C("%i", 200);
v70 = cocos2d::CCString::getCString(v69);
a1->m_messageCountLabel = cocos2d::CCLabelBMFont::create_1(v70, "chatFont.fnt");
v71 = ((__n128 (__fastcall *)(cocos2d::CCLayer *))a1->m_mainLayer->addChild_0)(a1->m_mainLayer);
m_messageCountLabel = a1->m_messageCountLabel;
v71.n128_u32[0] = 1.0;
v73.n128_u32[0] = 0.5;
sub_100022980(v71, v73, &v94);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, __int64 *))m_messageCountLabel->setAnchorPoint)(
m_messageCountLabel,
&v94);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float, float))a1->m_messageCountLabel->setPosition_0)(
a1->m_messageCountLabel,
(float)(v109 + 210.0) + -10.0,
(float)(v110 + 120.0) + -14.0);
sub_100009900(v90, "");
GJWriteMessagePopup::updateBody(a1, v90);
if ( v91 < 0 )
operator delete(v90[0]);
v74 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_resetBtn_001.png");
v116.ptr = (void (__cdecl *)(cocos2d::CCObject *))GJWriteMessagePopup::onClearBody;
v116.adj = 0;
v75 = CCMenuItemSpriteExtra::create(v74, nullptr, a1, v116);
v76 = ((__n128 (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild)(
a1->m_buttonMenu,
v75);
v76.n128_f32[0] = (float)((float)(v111 * 0.5) + 210.0) + -18.0;
v77 = a1->m_buttonMenu;
v78.n128_f32[0] = (float)((float)(v112 * 0.5) + -120.0) + 20.0;
sub_100022980(v76, v78, &v89);
v113 = cocos2d::CCNode::convertToNodeSpace(v77, &v89);
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64 *, float, float))v75->setPosition)(v75, &v94, v113.x, v113.y);
if ( StoredUserMessageReply )
{
v79 = a1->m_subjectInput;
if ( StoredUserMessageReply->m_title.m_data.m_short.shortStorage.__elems_[22] < 0 )
{
sub_1000097D0(
__dst,
(void *)StoredUserMessageReply->m_title.m_data.m_long.capacitym1,
StoredUserMessageReply->m_title.m_data.m_long.size);
}
else
{
*(_OWORD *)__dst = *(_OWORD *)&StoredUserMessageReply->m_title.m_data.m_short.sizex2;
longStorage = StoredUserMessageReply->m_title.m_data.m_long.longStorage;
}
CCTextInputNode::setString(v79, (__int64 **)__dst);
if ( SHIBYTE(longStorage) < 0 )
operator delete(__dst[0]);
v80 = a1->m_messageInput;
if ( StoredUserMessageReply->m_content.m_data.m_short.shortStorage.__elems_[22] < 0 )
{
sub_1000097D0(
v85,
(void *)StoredUserMessageReply->m_content.m_data.m_long.capacitym1,
StoredUserMessageReply->m_content.m_data.m_long.size);
}
else
{
*(_OWORD *)v85 = *(_OWORD *)&StoredUserMessageReply->m_content.m_data.m_short.sizex2;
v86 = StoredUserMessageReply->m_content.m_data.m_long.longStorage;
}
CCTextInputNode::setString(v80, (__int64 **)v85);
if ( SHIBYTE(v86) < 0 )
operator delete(v85[0]);
}
if ( (char)v107 < 0 )
operator delete(v106[0]);
if ( SHIBYTE(v108.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v108.__r_.__value_.__l.__data_);
}
return v6;
}