//
// SetupItemEditTriggerPopup::init from 0x140600fc0 to 0x14060224c (4748 bytes)
//
// 2 xrefs:
// > SetupItemEditTriggerPopup::create @ 0x140600f69
// > ??> @ 0x14092f8a0
//
// 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:35:11 +0000
//
// Hidden C++ exception states: #wind=3
char __fastcall SetupItemEditTriggerPopup::init(__int64 a1, int a2, int a3, int a4)
{
char result; // al
__int64 v6; // rax
__int64 v7; // rdi
__int64 v8; // rax
__int64 v9; // rbx
__int64 v10; // rax
_BYTE *v11; // r8
_OWORD *v12; // rcx
const char *v13; // rax
__int64 v14; // rdx
__int64 v15; // rcx
__int64 v16; // rax
int v17; // edi
__int64 v18; // rax
int v19; // r8d
void *v20; // rcx
__int64 v21; // rax
int v22; // r8d
int v23; // r9d
__int64 v24; // rax
int v25; // r8d
int v26; // r9d
__int64 v27; // rax
int v28; // r8d
int v29; // r9d
__int64 v30; // rax
int v31; // r8d
int v32; // r9d
__int64 v33; // rax
int v34; // r8d
int v35; // r9d
int v36; // edi
__int64 v37; // rax
int v38; // r8d
void *v39; // rcx
__int64 v40; // rax
int v41; // r8d
int v42; // r9d
__int64 v43; // rax
int v44; // r8d
int v45; // r9d
__int64 v46; // rax
int v47; // r8d
int v48; // r9d
__int64 v49; // rax
int v50; // r8d
int v51; // r9d
__int64 v52; // rax
int v53; // r8d
int v54; // r9d
__int64 v55; // rax
int v56; // edi
__int64 v57; // rax
int v58; // r8d
void *v59; // rcx
__int64 v60; // rax
int v61; // r8d
int v62; // r9d
__int64 v63; // rax
int v64; // r8d
int v65; // r9d
__int64 v66; // rax
int v67; // r8d
int v68; // r9d
int v69; // esi
unsigned int v70; // r14d
__int64 *v71; // r12
__int64 v72; // rbx
__int64 v73; // rax
__int64 *v74; // rdi
__int64 v75; // rax
void ***v76; // r8
char *v77; // rdx
__int64 v78; // rax
__int64 v79; // rbx
__int64 v80; // rax
float v81; // xmm0_4
__int64 v82; // rcx
__int64 v83; // rax
_QWORD *v84; // rdi
__int64 v85; // rdx
void (__fastcall *v86)(_QWORD *, __int64); // r8
__int64 v87; // rbx
__int64 v88; // rax
struct cocos2d::CCLabelBMFont *v89; // rax
__int64 v90; // rax
_BYTE v91[8]; // [rsp+88h] [rbp-80h] BYREF
void **v92; // [rsp+90h] [rbp-78h] BYREF
_BYTE v93[8]; // [rsp+98h] [rbp-70h] BYREF
_BYTE v94[8]; // [rsp+A0h] [rbp-68h] BYREF
__int128 v95; // [rsp+A8h] [rbp-60h] BYREF
__int64 v96; // [rsp+B8h] [rbp-50h]
__int64 v97; // [rsp+C0h] [rbp-48h]
float v98; // [rsp+C8h] [rbp-40h] BYREF
float v99; // [rsp+CCh] [rbp-3Ch]
_BYTE v100[8]; // [rsp+D0h] [rbp-38h] BYREF
_BYTE v101[8]; // [rsp+D8h] [rbp-30h] BYREF
_BYTE v102[8]; // [rsp+E0h] [rbp-28h] BYREF
void *v103; // [rsp+E8h] [rbp-20h]
_BYTE v104[8]; // [rsp+F0h] [rbp-18h] BYREF
char v105; // [rsp+F8h] [rbp-10h] BYREF
void *Block[2]; // [rsp+100h] [rbp-8h] BYREF
__int64 v107; // [rsp+110h] [rbp+8h]
unsigned __int64 v108; // [rsp+118h] [rbp+10h]
result = SetupTriggerPopup::init(a1, a2, a3, a4, 1133903872, 1, 0);
if ( result )
{
*(_BYTE *)(a1 + 744) = 1;
(*(void (__fastcall **)(__int64))(*(_QWORD *)a1 + 1096LL))(a1);
*(_OWORD *)Block = 0;
v107 = 0;
v108 = 0;
Block[0] = sub_14003D460(0x20u);
v107 = 17;
v108 = 31;
strcpy((char *)Block[0], "Item Edit Trigger");
SetupTriggerPopup::addTitle(a1, Block);
v7 = v6;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v92, -85.0, 0.0);
v9 = v8;
v10 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v7 + 200LL))(v7);
cocos2d::CCPoint::operator+(v10, v91, v9);
(*(void (__fastcall **)(__int64, _BYTE *))(*(_QWORD *)v7 + 184LL))(v7, v91);
*(_OWORD *)Block = 0;
v107 = 2;
v108 = 15;
strcpy((char *)Block, "OK");
SetupTriggerPopup::addCloseButton(a1, Block);
v92 = Block;
*(_OWORD *)Block = 0;
v107 = 0;
v108 = 0;
v11 = sub_14003D460(0x1D0u);
Block[0] = v11;
v107 = 449;
v108 = 463;
v12 = v11;
v13 = "Edits Target ItemID using operations on ItemID1 and ItemID2.\n"
"Use Item, Timer, Points, Time, or Att to specify type.\n"
"The first operator button sets the interaction with target.\n"
"The second sets interaction between the two initial IDs.\n"
"The third sets how Mod interacts with the equation.\n"
"Button 4/5 are used to force the values positive or negative.\n"
"Click the NA button to switch to different rounding functions.";
v14 = 3;
do
{
*v12 = *(_OWORD *)v13;
v12[1] = *((_OWORD *)v13 + 1);
v12[2] = *((_OWORD *)v13 + 2);
v12[3] = *((_OWORD *)v13 + 3);
v12[4] = *((_OWORD *)v13 + 4);
v12[5] = *((_OWORD *)v13 + 5);
v12[6] = *((_OWORD *)v13 + 6);
v12 += 8;
*(v12 - 1) = *((_OWORD *)v13 + 7);
v13 += 128;
--v14;
}
while ( v14 );
*v12 = *(_OWORD *)v13;
v12[1] = *((_OWORD *)v13 + 1);
v12[2] = *((_OWORD *)v13 + 2);
v12[3] = *((_OWORD *)v13 + 3);
*((_BYTE *)v12 + 64) = v13[64];
v11[449] = 0;
v95 = 0;
v96 = 4;
v97 = 15;
strcpy((char *)&v95, "Help");
SetupTriggerPopup::addHelpButton(a1, &v95, Block);
SetupTriggerPopup::createMultiTriggerItemsDefaultHorizontal(a1);
v16 = cocos2d::CCDirector::sharedDirector(v15);
cocos2d::CCDirector::getWinSize(v16, &v98);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v93, v98 * 0.5, (float)(v99 * 0.5) + 58.0);
v17 = (int)(*(float (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 1168LL))(a1, 476);
Block[1] = nullptr;
v107 = 7;
v108 = 15;
Block[0] = (void *)0x3144496D657449LL;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v92, -105.0, 45.0);
cocos2d::CCPoint::operator+(v93, v91, v18);
if ( v17 == 1 )
{
v19 = 2;
}
else if ( v17 == 2 )
{
v19 = 4;
}
else
{
v19 = 0;
}
IDNameInput::create(
a1,
a1 + 544,
v19,
80,
(__int64)Block,
(const struct cocos2d::CCPoint *)v91,
1061997773,
6,
0,
0,
1);
if ( v108 > 0xF )
{
v20 = Block[0];
if ( v108 + 1 >= 0x1000 )
{
v20 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v20 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v20);
}
v92 = (void **)&v95;
v95 = 0;
v96 = 4;
v97 = 15;
strcpy((char *)&v95, "Item");
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v94, 20.0, 45.0);
cocos2d::CCPoint::operator+(v93, v91, v21);
LOBYTE(v22) = v17 == 1;
SetupTriggerPopup::createCustomToggleValueControl(a1, 1, v22, v23, (__int64)&v95, (__int64)v91, 1, 0, 0);
v92 = Block;
*(_OWORD *)Block = 0;
v107 = 5;
v108 = 15;
strcpy((char *)Block, "Timer");
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v94, 62.0, 45.0);
cocos2d::CCPoint::operator+(v93, v91, v24);
LOBYTE(v25) = v17 == 2;
SetupTriggerPopup::createCustomToggleValueControl(a1, 2, v25, v26, (__int64)Block, (__int64)v91, 1, 0, 0);
v92 = Block;
*(_OWORD *)Block = 0;
v107 = 6;
v108 = 15;
strcpy((char *)Block, "Points");
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v94, 104.0, 45.0);
cocos2d::CCPoint::operator+(v93, v91, v27);
LOBYTE(v28) = v17 == 3;
SetupTriggerPopup::createCustomToggleValueControl(a1, 3, v28, v29, (__int64)Block, (__int64)v91, 1, 0, 0);
v92 = (void **)&v95;
v95 = 0;
v96 = 4;
v97 = 15;
strcpy((char *)&v95, "Time");
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v94, 146.0, 45.0);
cocos2d::CCPoint::operator+(v93, v91, v30);
LOBYTE(v31) = v17 == 4;
SetupTriggerPopup::createCustomToggleValueControl(a1, 4, v31, v32, (__int64)&v95, (__int64)v91, 1, 0, 0);
v92 = Block;
*(_OWORD *)Block = 0;
v107 = 3;
v108 = 15;
LODWORD(Block[0]) = 7631937;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v94, 188.0, 45.0);
cocos2d::CCPoint::operator+(v93, v91, v33);
LOBYTE(v34) = v17 == 5;
SetupTriggerPopup::createCustomToggleValueControl(a1, 5, v34, v35, (__int64)Block, (__int64)v91, 1, 0, 0);
v36 = (int)(*(float (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 1168LL))(a1, 477);
Block[1] = nullptr;
v107 = 7;
v108 = 15;
Block[0] = (void *)0x3244496D657449LL;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v92, -105.0, 0.0);
cocos2d::CCPoint::operator+(v93, v91, v37);
if ( v36 == 1 )
{
v38 = 2;
}
else if ( v36 == 2 )
{
v38 = 4;
}
else
{
v38 = 0;
}
IDNameInput::create(
a1,
a1 + 544,
v38,
95,
(__int64)Block,
(const struct cocos2d::CCPoint *)v91,
1061997773,
6,
0,
0,
1);
if ( v108 > 0xF )
{
v39 = Block[0];
if ( v108 + 1 >= 0x1000 )
{
v39 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v39 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v39);
}
v92 = (void **)&v95;
v95 = 0;
v96 = 4;
v97 = 15;
strcpy((char *)&v95, "Item");
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v94, 20.0, 0.0);
cocos2d::CCPoint::operator+(v93, v91, v40);
LOBYTE(v41) = v36 == 1;
SetupTriggerPopup::createCustomToggleValueControl(a1, 101, v41, v42, (__int64)&v95, (__int64)v91, 1, 0, 0);
v92 = Block;
*(_OWORD *)Block = 0;
v107 = 5;
v108 = 15;
strcpy((char *)Block, "Timer");
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v94, 62.0, 0.0);
cocos2d::CCPoint::operator+(v93, v91, v43);
LOBYTE(v44) = v36 == 2;
SetupTriggerPopup::createCustomToggleValueControl(a1, 102, v44, v45, (__int64)Block, (__int64)v91, 1, 0, 0);
v92 = Block;
*(_OWORD *)Block = 0;
v107 = 6;
v108 = 15;
strcpy((char *)Block, "Points");
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v94, 104.0, 0.0);
cocos2d::CCPoint::operator+(v93, v91, v46);
LOBYTE(v47) = v36 == 3;
SetupTriggerPopup::createCustomToggleValueControl(a1, 103, v47, v48, (__int64)Block, (__int64)v91, 1, 0, 0);
v92 = (void **)&v95;
v95 = 0;
v96 = 4;
v97 = 15;
strcpy((char *)&v95, "Time");
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v94, 146.0, 0.0);
cocos2d::CCPoint::operator+(v93, v91, v49);
LOBYTE(v50) = v36 == 4;
SetupTriggerPopup::createCustomToggleValueControl(a1, 104, v50, v51, (__int64)&v95, (__int64)v91, 1, 0, 0);
v92 = Block;
*(_OWORD *)Block = 0;
v107 = 3;
v108 = 15;
LODWORD(Block[0]) = 7631937;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v94, 188.0, 0.0);
cocos2d::CCPoint::operator+(v93, v91, v52);
LOBYTE(v53) = v36 == 5;
SetupTriggerPopup::createCustomToggleValueControl(a1, 105, v53, v54, (__int64)Block, (__int64)v91, 1, 0, 0);
v92 = (void **)&v95;
v95 = 0;
v96 = 4;
v97 = 15;
strcpy((char *)&v95, "Mod:");
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v94, -105.0, -45.0);
cocos2d::CCPoint::operator+(v93, v91, v55);
SetupTriggerPopup::createValueControlAdvanced(
a1,
479,
(unsigned int)&v95,
(unsigned int)v91,
1061997773,
0,
1,
10,
0,
-1073741824,
0x40000000,
0,
0,
1,
3,
0);
v56 = (int)(*(float (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 1168LL))(a1, 478);
v107 = 13;
v108 = 15;
strcpy((char *)Block, "Target\nItemID");
HIWORD(Block[1]) = 0;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v92, -105.0, -90.0);
cocos2d::CCPoint::operator+(v93, v91, v57);
if ( v56 == 1 )
{
v58 = 2;
}
else if ( v56 == 2 )
{
v58 = 4;
}
else
{
v58 = 0;
}
IDNameInput::create(
a1,
a1 + 544,
v58,
51,
(__int64)Block,
(const struct cocos2d::CCPoint *)v91,
1061997773,
6,
0,
0,
1);
if ( v108 > 0xF )
{
v59 = Block[0];
if ( v108 + 1 >= 0x1000 )
{
v59 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v59 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v59);
}
v92 = (void **)&v95;
v95 = 0;
v96 = 4;
v97 = 15;
strcpy((char *)&v95, "Item");
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v94, 20.0, -90.0);
cocos2d::CCPoint::operator+(v93, v91, v60);
LOBYTE(v61) = v56 == 1;
SetupTriggerPopup::createCustomToggleValueControl(a1, 1001, v61, v62, (__int64)&v95, (__int64)v91, 1, 0, 0);
v92 = Block;
*(_OWORD *)Block = 0;
v107 = 5;
v108 = 15;
strcpy((char *)Block, "Timer");
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v94, 62.0, -90.0);
cocos2d::CCPoint::operator+(v93, v91, v63);
LOBYTE(v64) = v56 == 2;
SetupTriggerPopup::createCustomToggleValueControl(a1, 1002, v64, v65, (__int64)Block, (__int64)v91, 1, 0, 0);
v92 = Block;
*(_OWORD *)Block = 0;
v107 = 6;
v108 = 15;
strcpy((char *)Block, "Points");
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v94, 104.0, -90.0);
cocos2d::CCPoint::operator+(v93, v91, v66);
LOBYTE(v67) = v56 == 3;
SetupTriggerPopup::createCustomToggleValueControl(a1, 1003, v67, v68, (__int64)Block, (__int64)v91, 1, 0, 0);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v102, 2.0, 2.0);
v69 = 0;
while ( 1 )
{
switch ( v69 )
{
case 1:
v70 = 481;
break;
case 2:
v70 = 482;
break;
case 3:
v70 = 578;
break;
case 4:
v70 = 579;
break;
case 5:
v70 = 485;
break;
default:
v70 = 480;
if ( v69 == 6 )
v70 = 486;
break;
}
v71 = (__int64 *)ButtonSprite::create_1(
(int)"+",
15,
15,
1.0,
1,
(__int64)"goldFont.fnt",
(__int64)"GJ_button_01.png",
0);
(*(void (__fastcall **)(__int64 *))(*v71 + 160))(v71);
(*(void (__fastcall **)(__int64))(*(_QWORD *)v71[79] + 160LL))(v71[79]);
v72 = v71[79];
v73 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v72 + 200LL))(v72);
cocos2d::CCPoint::operator+(v73, v91, v102);
(*(void (__fastcall **)(__int64, _BYTE *))(*(_QWORD *)v72 + 184LL))(v72, v91);
v103 = operator new(0x208u);
v74 = (__int64 *)CCMenuItemSpriteExtra::CCMenuItemSpriteExtra((__int64)v103);
if ( !v74 )
goto LABEL_51;
if ( !CCMenuItemSpriteExtra::init(v74, v71, 0, a1, (__int64)SetupItemEditTriggerPopup::onOpButton) )
break;
cocos2d::CCObject::autorelease((cocos2d::CCObject *)v74);
LABEL_52:
(*(void (__fastcall **)(__int64 *, _QWORD))(*v74 + 64))(v74, v70);
(*(void (__fastcall **)(_QWORD, __int64 *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v74);
if ( (unsigned int)v69 >= 5 )
{
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)Block, (float)((float)(v69 - 2) * 42.0) + 20.0, -90.0);
cocos2d::CCPoint::operator+(v93, &v92, v78);
v76 = &v92;
v77 = v101;
}
else
{
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v104, (float)((float)v69 * 42.0) + 20.0, -45.0);
cocos2d::CCPoint::operator+(v93, v94, v75);
v76 = (void ***)v94;
v77 = &v105;
}
v79 = *v74;
cocos2d::CCNode::convertToNodeSpace(*(_QWORD *)(a1 + 552), v77, v76);
(*(void (__fastcall **)(__int64 *, __int64))(v79 + 184))(v74, v80);
v81 = (*(float (__fastcall **)(__int64, _QWORD))(*(_QWORD *)a1 + 1168LL))(a1, v70);
SetupItemEditTriggerPopup::updateOpButton(v82, v74, (unsigned int)(int)v81, v70);
if ( ++v69 >= 7 )
{
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v100, v98 * 0.5, (float)(v99 * 0.5) - 82.0);
cocos2d::CCRect::CCRect((cocos2d::CCRect *)Block, 0.0, 0.0, 80.0, 80.0);
v84 = (_QWORD *)cocos2d::extension::CCScale9Sprite::create("GJ_square01.png", v83);
v85 = v84[40];
v86 = *(void (__fastcall **)(_QWORD *, __int64))(v85 + 40);
LOBYTE(v85) = 50;
v86(v84 + 40, v85);
(*(void (__fastcall **)(_QWORD *, void *))v84[40])(v84 + 40, &unk_1407046A0);
v87 = *v84;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)v101, 1520.0, 140.0);
(*(void (__fastcall **)(_QWORD *, __int64))(v87 + 312))(v84, v88);
(*(void (__fastcall **)(_QWORD, _QWORD *, __int64))(**(_QWORD **)(a1 + 584) + 456LL))(
*(_QWORD *)(a1 + 584),
v84,
1);
(*(void (__fastcall **)(_QWORD *, _BYTE *))(*v84 + 184LL))(v84, v100);
(*(void (__fastcall **)(_QWORD *))(*v84 + 160LL))(v84);
v89 = cocos2d::CCLabelBMFont::create("T = (A + B) x M", "goldFont.fnt");
*(_QWORD *)(a1 + 1000) = v89;
(*(void (__fastcall **)(_QWORD, struct cocos2d::CCLabelBMFont *, __int64))(**(_QWORD **)(a1 + 584) + 456LL))(
*(_QWORD *)(a1 + 584),
v89,
2);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v101, 0.0, 1.0);
cocos2d::CCPoint::operator+(v100, &v92, v90);
(*(void (__fastcall **)(_QWORD, void ***))(**(_QWORD **)(a1 + 1000) + 184LL))(*(_QWORD *)(a1 + 1000), &v92);
SetupItemEditTriggerPopup::updateFormulaLabel(a1);
(*(void (__fastcall **)(__int64))(*(_QWORD *)a1 + 1136LL))(a1);
*(_BYTE *)(a1 + 744) = 0;
return 1;
}
}
(*(void (__fastcall **)(__int64 *, __int64))(*v74 + 8))(v74, 1);
LABEL_51:
v74 = nullptr;
goto LABEL_52;
}
return result;
}