//
// ThreadOptionsPopup::init from 0x1400f4340 to 0x1400f4c79 (2361 bytes)
//
// 2 xrefs:
// > ThreadOptionsPopup::create @ 0x1400f42fc
// > ??> @ 0x1409151d0
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:26:38 +0000
//
// Hidden C++ exception states: #wind=5
char __fastcall ThreadOptionsPopup::init(__int64 a1, __int64 a2, __int64 a3, char a4)
{
int v6; // r12d
char v7; // r15
__int64 v8; // rax
bool v9; // cl
__int64 v10; // r13
float v11; // xmm6_4
__int64 v12; // rcx
__int64 v13; // rcx
cocos2d::CCArray *ThreadMembers; // rdi
signed int i; // ebx
signed int v16; // eax
struct cocos2d::CCObject *v17; // rax
__int64 v18; // rax
__int64 v19; // rax
float v20; // xmm10_4
float v21; // xmm8_4
__int64 v22; // rdx
_QWORD *v23; // rdx
size_t v24; // r8
cocos2d::CCLabelBMFont *v25; // rsi
_QWORD *RoleBadge; // rax
_QWORD *v27; // r12
__int64 v28; // rdi
double (__fastcall *v29)(cocos2d::CCLabelBMFont *); // rbx
float v30; // xmm6_4
double v31; // xmm0_8
float v32; // xmm7_4
double v33; // xmm0_8
float v34; // xmm6_4
double v35; // xmm0_8
__int64 v36; // rax
__time64_t v37; // rdx
char *v38; // rax
__int64 v39; // rax
const char *v40; // rcx
struct cocos2d::CCLabelBMFont *v41; // rdi
__int64 v42; // rdx
void (__fastcall *v43)(char *, __int64); // r8
__int64 v44; // rbx
__int64 v45; // rax
struct cocos2d::CCSprite *v46; // rax
int v47; // ebx
cocos2d::CCObject *v48; // rsi
__int64 v49; // rdi
__int64 v50; // rbx
__int64 v51; // rax
__int64 v52; // rax
__int64 (__fastcall *v53)(); // rax
const char *v54; // rcx
__int64 v55; // rdx
__int64 v56; // r8
_BYTE *v57; // r11
const char *v58; // rax
const char *v59; // rax
__int64 v60; // r10
__int64 v61; // rax
__int64 (__fastcall *v62)(); // rdx
const char *v63; // rcx
__int64 (__fastcall **v64)(); // r11
_QWORD *v65; // r10
const char **v66; // rax
__int64 v67; // r15
float v68; // xmm8_4
__int64 v69; // rdi
__int64 v70; // rax
cocos2d::CCObject *v71; // rbx
cocos2d::CCObject *v72; // rsi
__int64 v73; // rdi
__int64 v74; // rbx
__int64 v75; // rax
__int64 v76; // rax
char v78; // [rsp+58h] [rbp-B0h]
bool v79; // [rsp+59h] [rbp-AFh]
void *v80; // [rsp+60h] [rbp-A8h] BYREF
float v81[2]; // [rsp+68h] [rbp-A0h] BYREF
void *v82; // [rsp+70h] [rbp-98h] BYREF
__int64 (__fastcall *v83)(); // [rsp+78h] [rbp-90h] BYREF
_QWORD v84[7]; // [rsp+80h] [rbp-88h]
_BYTE v85[16]; // [rsp+B8h] [rbp-50h] BYREF
__int128 v86; // [rsp+C8h] [rbp-40h] BYREF
_OWORD v87[3]; // [rsp+D8h] [rbp-30h]
const char *v88; // [rsp+108h] [rbp+0h] BYREF
_QWORD v89[7]; // [rsp+110h] [rbp+8h]
v6 = 0;
if ( !a2 )
return 0;
*(_QWORD *)(a1 + 1024) = a3;
*(_BYTE *)(a1 + 1040) = a4;
v7 = *(_BYTE *)(a2 + 320);
v9 = false;
if ( !v7 )
{
v8 = GJAccountManager::sharedState(a1);
if ( *(_DWORD *)(a2 + 240) == *(_DWORD *)(v8 + 360) - *(_DWORD *)(v8 + 364) )
v9 = true;
}
v79 = v9;
if ( *(_BYTE *)(a1 + 1040) )
{
v10 = 1;
}
else
{
if ( !v7 && *(_DWORD *)(a2 + 324) == 8 )
{
v78 = 1;
v10 = 2;
goto LABEL_16;
}
if ( v7 )
v10 = 5;
else
v10 = (unsigned int)v9 + 5;
}
v78 = 0;
LABEL_16:
v11 = (float)((float)(v10 - 1) * 29.0) + 88.0;
if ( !(unsigned __int8)SetupTriggerPopup::init(a1, 0, 0, a4, LODWORD(v11), 1, 0) )
return 0;
*(_QWORD *)(a1 + 1016) = a2;
cocos2d::CCObject::retain((cocos2d::CCObject *)a2);
if ( v7 )
{
v13 = *(_QWORD *)&qword_14090BFB0;
if ( !*(_QWORD *)&qword_14090BFB0 )
{
v80 = operator new(0x690u);
*(_QWORD *)&qword_14090BFB0 = GameLevelManager::GameLevelManager(v80);
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)&qword_14090BFB0 + 72LL))(*(_QWORD *)&qword_14090BFB0);
v13 = *(_QWORD *)&qword_14090BFB0;
}
ThreadMembers = (cocos2d::CCArray *)GameLevelManager::getThreadMembers(
v13,
*(unsigned int *)(*(_QWORD *)(a1 + 1016) + 56LL));
for ( i = 0; ; ++i )
{
v16 = ThreadMembers ? cocos2d::CCArray::count(ThreadMembers) : 0;
if ( i >= v16 )
break;
v17 = cocos2d::CCArray::objectAtIndex(ThreadMembers, i);
v12 = *(_QWORD *)(a1 + 1016);
if ( *((_DWORD *)v17 + 98) == *(_DWORD *)(v12 + 60) )
{
v12 = *((_DWORD *)v17 + 118) > 0;
*(_DWORD *)(a1 + 1036) = v12;
}
}
v18 = *(_QWORD *)(a1 + 1016);
if ( *(int *)(v18 + 344) <= 0 )
{
v12 = *(unsigned int *)(v18 + 324);
if ( (_DWORD)v12 )
*(_DWORD *)(a1 + 1036) = v12 == 6;
}
else
{
*(_DWORD *)(a1 + 1036) = 1;
}
}
v19 = cocos2d::CCDirector::sharedDirector(v12);
cocos2d::CCDirector::getWinSize(v19, v81);
v20 = v81[0] * 0.5;
v21 = (float)(v81[1] * 0.5) + (float)(v11 * 0.5);
v22 = *(_QWORD *)(a1 + 1016);
if ( v7 )
v23 = (_QWORD *)(v22 + 64);
else
v23 = (_QWORD *)(v22 + 96);
if ( v23[3] > 0xFu )
v23 = (_QWORD *)*v23;
v86 = 0;
v87[0] = 0u;
v24 = -1;
do
++v24;
while ( *((_BYTE *)v23 + v24) );
sub_14003D230(&v86, v23, v24);
v25 = (cocos2d::CCLabelBMFont *)SetupTriggerPopup::addTitle(a1, &v86);
cocos2d::CCLabelBMFont::limitLabelWidth(v25, 180.0, 0.5, 0.2);
if ( v7 )
{
RoleBadge = (_QWORD *)GJMessageThread::createRoleBadge(*(_QWORD *)(a1 + 1016));
v27 = RoleBadge;
if ( RoleBadge )
{
v28 = *RoleBadge;
v29 = *(double (__fastcall **)(cocos2d::CCLabelBMFont *))(*(_QWORD *)v25 + 232LL);
v30 = *(float *)(*(__int64 (__fastcall **)(cocos2d::CCLabelBMFont *))(*(_QWORD *)v25 + 320LL))(v25);
v31 = (*(double (__fastcall **)(cocos2d::CCLabelBMFont *))(*(_QWORD *)v25 + 168LL))(v25);
v32 = (float)(*(float *)&v31 * v30) * 0.5;
v33 = (*(double (__fastcall **)(cocos2d::CCLabelBMFont *))(*(_QWORD *)v25 + 216LL))(v25);
v34 = (float)(*(float *)&v33 + v32) + 6.0;
v35 = v29(v25);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v80, v34, *(float *)&v35);
(*(void (__fastcall **)(_QWORD *, __int64))(v28 + 184))(v27, v36);
(*(void (__fastcall **)(_QWORD, _QWORD *, __int64))(**(_QWORD **)(a1 + 584) + 456LL))(
*(_QWORD *)(a1 + 584),
v27,
1);
}
v6 = 0;
}
v37 = *(_QWORD *)(*(_QWORD *)(a1 + 1016) + 336LL);
if ( v37 > 0 )
{
v38 = GameToolbox::timestampToDateString((char *)&v88, v37);
v39 = sub_140059D70(v38, 0, "Created: ", 9u);
v86 = 0;
v87[0] = 0u;
v86 = *(_OWORD *)v39;
v87[0] = *(_OWORD *)(v39 + 16);
*(_QWORD *)(v39 + 16) = 0;
*(_QWORD *)(v39 + 24) = 15;
*(_BYTE *)v39 = 0;
sub_14003D310((__int64)&v88);
v40 = (const char *)&v86;
if ( *((_QWORD *)&v87[0] + 1) > 0xFu )
v40 = (const char *)v86;
v41 = cocos2d::CCLabelBMFont::create(v40, "chatFont.fnt");
(*(void (__fastcall **)(struct cocos2d::CCLabelBMFont *))(*(_QWORD *)v41 + 160LL))(v41);
(**((void (__fastcall ***)(__int64, void *))v41 + 46))((__int64)v41 + 368, &unk_140702E6C);
v42 = *((_QWORD *)v41 + 46);
v43 = *(void (__fastcall **)(char *, __int64))(v42 + 40);
LOBYTE(v42) = -106;
v43((char *)v41 + 368, v42);
v44 = *(_QWORD *)v41;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v80, v20, v21 - 33.0);
(*(void (__fastcall **)(struct cocos2d::CCLabelBMFont *, __int64))(v44 + 184))(v41, v45);
(*(void (__fastcall **)(_QWORD, struct cocos2d::CCLabelBMFont *, __int64))(**(_QWORD **)(a1 + 584) + 456LL))(
*(_QWORD *)(a1 + 584),
v41,
1);
sub_14003D310((__int64)&v86);
}
v46 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_closeBtn_001.png");
v47 = (int)v46;
(*(void (__fastcall **)(struct cocos2d::CCSprite *))(*(_QWORD *)v46 + 160LL))(v46);
v48 = CCMenuItemSpriteExtra::create(v47, 0, a1, (__int64)sub_14009D628);
*((_DWORD *)v48 + 93) = 1069547520;
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v48);
v49 = *(_QWORD *)v48;
v50 = *(_QWORD *)(a1 + 552);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v80, (float)(v20 - 120.0) + 8.0, v21 - 12.0);
cocos2d::CCNode::convertToNodeSpace(v50, &v82, v51);
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(v49 + 184))(v48, v52);
if ( v78 )
{
*(_QWORD *)&v86 = &dword_140724044;
v88 = "GJ_button_05.png";
v83 = ThreadOptionsPopup::onReport;
*((_QWORD *)&v86 + 1) = "Remove";
v89[0] = "GJ_button_06.png";
v53 = ThreadOptionsPopup::onDismissRemoved;
LABEL_57:
v55 = 2;
v84[0] = v53;
LABEL_58:
v56 = v55;
goto LABEL_59;
}
if ( *(_BYTE *)(a1 + 1040) )
{
v54 = "Lock Conversation";
if ( *(_BYTE *)(*(_QWORD *)(a1 + 1016) + 328LL) )
v54 = "Unlock Conversation";
*(_QWORD *)&v86 = v54;
v88 = "GJ_button_06.png";
v83 = ThreadOptionsPopup::onModLock;
v55 = 1;
goto LABEL_58;
}
LODWORD(v55) = 1;
v56 = 1;
if ( v7 )
{
*(_QWORD *)&v86 = "View Profile";
v88 = "GJ_button_01.png";
v83 = ThreadOptionsPopup::onViewProfile;
}
else
{
*(_QWORD *)&v86 = "Members";
v88 = "GJ_button_01.png";
v83 = ThreadOptionsPopup::onMembers;
if ( v79 )
{
*((_QWORD *)&v86 + 1) = "Rename";
v89[0] = "GJ_button_04.png";
v53 = ThreadOptionsPopup::onRename;
goto LABEL_57;
}
}
LABEL_59:
v57 = *(_BYTE **)(a1 + 1016);
v58 = "Mute";
if ( v57[244] )
v58 = "Unmute";
*((_QWORD *)&v87[-1] + (unsigned int)v55) = v58;
v89[(unsigned int)v55 - 1] = "GJ_button_04.png";
v84[(unsigned int)v55 - 1] = ThreadOptionsPopup::onMuteRow;
v59 = "Pin";
if ( v57[330] )
v59 = "Unpin";
*((_QWORD *)&v86 + (int)v55 + 1) = v59;
v89[(int)v55] = "GJ_button_04.png";
v84[(int)v55] = ThreadOptionsPopup::onPinRow;
*((_QWORD *)v87 + v56) = &dword_140724044;
v89[v56 + 1] = "GJ_button_05.png";
v84[v56 + 1] = ThreadOptionsPopup::onReport;
v60 = (unsigned int)(v55 + 3);
v61 = v60;
if ( v7 )
{
if ( v57[321] )
{
v62 = ThreadOptionsPopup::onCancelRequest;
v63 = "Cancel Request";
v64 = (__int64 (__fastcall **)())&v84[v60 - 1];
v65 = &v89[v61 - 1];
v66 = (const char **)((char *)&v87[-1] + v61 * 8);
}
else
{
v62 = ThreadOptionsPopup::onHide;
v63 = "Clear";
if ( !*(_DWORD *)(a1 + 1036) )
v63 = "Leave";
v64 = (__int64 (__fastcall **)())&v84[v60 - 1];
v65 = &v89[v61 - 1];
v66 = (const char **)((char *)&v87[-1] + v61 * 8);
}
}
else
{
v62 = ThreadOptionsPopup::onLeave;
v64 = (__int64 (__fastcall **)())&v84[v61 - 1];
v65 = &v89[v61 - 1];
v63 = "Leave";
v66 = (const char **)((char *)&v87[-1] + v61 * 8);
}
*v66 = v63;
*v65 = "GJ_button_06.png";
*v64 = v62;
v67 = 0;
if ( v10 )
{
v68 = v21 - 61.0;
do
{
v69 = v89[v67 - 1];
v82 = operator new(0x2C8u);
v70 = ButtonSprite::ButtonSprite((__int64)v82);
v71 = (cocos2d::CCObject *)v70;
if ( v70 )
{
if ( ButtonSprite::init_1(
v70,
*((_QWORD *)&v87[-1] + v67),
130,
0,
1056964608,
1,
&qword_140704F78,
v69,
1102053376) )
{
cocos2d::CCObject::autorelease(v71);
}
else
{
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v71 + 8LL))(v71, 1);
LODWORD(v71) = 0;
}
}
v72 = CCMenuItemSpriteExtra::create((int)v71, 0, a1, v84[v67 - 1]);
*((_DWORD *)v72 + 93) = 1066192077;
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(
*(_QWORD *)(a1 + 552),
v72);
v73 = *(_QWORD *)v72;
v74 = *(_QWORD *)(a1 + 552);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v80, v20, v68 - (float)((float)v6 * 29.0));
cocos2d::CCNode::convertToNodeSpace(v74, v85, v75);
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(v73 + 184))(v72, v76);
++v6;
++v67;
}
while ( v67 < v10 );
}
return 1;
}