//
// SetupCountTriggerPopup::init from 0x14041afb0 to 0x14041c05c (4268 bytes)
//
// 2 xrefs:
// > SetupCountTriggerPopup::create @ 0x14041af6e
// > ??> @ 0x1406d929c
//
// 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=5
bool SetupCountTriggerPopup::init(SetupCountTriggerPopup *a1, EffectGameObject *a2, cocos2d::CCArray *a3)
{
bool result; // al
__int64 v5; // rcx
cocos2d::CCDirector *v6; // rax
struct cocos2d::CCLabelBMFont *v7; // rdi
cocos2d::CCLabelBMFont_vtbl *v8; // rbx
const cocos2d::CCPoint *v9; // rax
ButtonSprite *v10; // rbx
CCMenuItemSpriteExtra *v11; // rax
_BYTE *v12; // rax
_BYTE *v13; // rcx
const char *v14; // rdx
__int64 v15; // r8
char *v16; // rdi
__int64 v17; // rbx
struct cocos2d::CCPoint v18; // rax
int i; // r15d
__int64 v20; // rbx
double v21; // xmm0_8
char v22; // r12
unsigned __int64 v23; // rdi
void **v24; // rbx
unsigned __int64 v25; // rcx
__int64 v26; // r14
char *v27; // rbx
void *v28; // rcx
__int64 v29; // rax
void (*v30)(SetupCountTriggerPopup *, cocos2d::CCObject *); // r14
void **v31; // rbx
unsigned __int64 v32; // rcx
char *v33; // r14
void *v34; // rcx
__int64 v35; // rax
void **v36; // rbx
unsigned __int64 v37; // rcx
char *v38; // r14
void *v39; // rcx
__int64 v40; // rax
void **v41; // rcx
struct cocos2d::CCLabelBMFont *v42; // rbx
float v43; // xmm0_4
struct cocos2d::CCRect *v44; // rax
struct cocos2d::extension::CCScale9Sprite *v45; // rdi
__int64 v46; // rdx
const char *v47; // r9
CCTextInputNode *v48; // rdi
void **p_m_allowedChars; // rcx
struct cocos2d::CCSprite *v50; // rbx
cocos2d::CCNode *v51; // rbx
float v52; // xmm0_4
struct cocos2d::CCSprite *v53; // rbx
cocos2d::CCNode *v54; // rbx
float v55; // xmm0_4
float *v56; // rax
float *v57; // rbx
struct cocos2d::CCPoint v58; // rax
double v59; // xmm0_8
float *v60; // rax
double v61; // xmm0_8
float *v62; // rax
__int64 v63; // rax
int v64; // [rsp+28h] [rbp-E0h]
float v65; // [rsp+88h] [rbp-80h]
ButtonSprite *v66; // [rsp+90h] [rbp-78h] BYREF
__int16 v67; // [rsp+98h] [rbp-70h]
__int16 v68; // [rsp+9Ch] [rbp-6Ch] BYREF
char v69; // [rsp+9Eh] [rbp-6Ah]
__int16 v70; // [rsp+A0h] [rbp-68h]
cocos2d::CCPoint v71; // [rsp+A8h] [rbp-60h] BYREF
char *v72; // [rsp+B0h] [rbp-58h] BYREF
void **v73; // [rsp+C0h] [rbp-48h]
char v74[8]; // [rsp+C8h] [rbp-40h] BYREF
char Src[12]; // [rsp+D0h] [rbp-38h] BYREF
int v76; // [rsp+DCh] [rbp-2Ch]
__int64 v77; // [rsp+E0h] [rbp-28h]
__int64 v78; // [rsp+E8h] [rbp-20h]
struct cocos2d::CCPoint v79; // [rsp+F0h] [rbp-18h] BYREF
struct cocos2d::CCPoint v80; // [rsp+F8h] [rbp-10h] BYREF
_QWORD v81[4]; // [rsp+100h] [rbp-8h] BYREF
cocos2d::CCPoint v82; // [rsp+120h] [rbp+18h] BYREF
cocos2d::CCSize v83; // [rsp+128h] [rbp+20h] BYREF
cocos2d::CCRect v84; // [rsp+130h] [rbp+28h] BYREF
__int64 v85; // [rsp+140h] [rbp+38h]
__int64 v86; // [rsp+148h] [rbp+40h]
cocos2d::CCRect v87; // [rsp+170h] [rbp+68h] BYREF
void *v88[2]; // [rsp+180h] [rbp+78h] BYREF
__int64 v89; // [rsp+190h] [rbp+88h]
unsigned __int64 v90; // [rsp+198h] [rbp+90h]
result = SetupTriggerPopup::init(a1, a2, a3, 300.0, 240.0, 1);
if ( result )
{
a1->determineStartValues(a1);
v6 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v5);
cocos2d::CCDirector::getWinSize(v6);
v7 = cocos2d::CCLabelBMFont::create("Count Trigger", "goldFont.fnt");
a1->m_mainLayer->addChild_1(a1->m_mainLayer, v7);
((void (__fastcall *)(struct cocos2d::CCLabelBMFont *))v7->setScale_0)(v7);
v8 = v7->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(a1->m_height * 0.5, v65 * 0.5);
v8->setPosition_0(v7, v9);
v66 = (ButtonSprite *)operator new(0x2C0u);
v10 = ButtonSprite::ButtonSprite(v66);
if ( v10 )
{
if ( ButtonSprite::init_1(v10, "OK", 40, 0, 0.80000001, 1, "goldFont.fnt", "GJ_button_01.png", 30.0) )
{
cocos2d::CCObject::autorelease(v10);
}
else
{
((void (__fastcall *)(ButtonSprite *, __int64))v10->~ButtonSprite)(v10, 1);
v10 = nullptr;
}
}
v11 = CCMenuItemSpriteExtra::create(v10, nullptr, a1, (cocos2d::SEL_MenuHandler *)sub_14009BEF0);
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, v11);
v66 = (ButtonSprite *)v88;
*(_OWORD *)v88 = 0;
v89 = 0;
v90 = 15;
v12 = sub_14003AA10(0x120u);
v88[0] = v12;
v89 = 287;
v90 = 287;
v13 = v12;
v14 = "Disable objects using Target ID when an Item ID reaches a certain Target Count. The co"
"ndition is checked constantly.\n"
"Activate Group makes the trigger enable and spawn the group instead.\n"
"Multi Activate allows the trigger to activate more than once.";
v15 = 2;
do
{
*(_OWORD *)v13 = *(_OWORD *)v14;
*((_OWORD *)v13 + 1) = *((_OWORD *)v14 + 1);
*((_OWORD *)v13 + 2) = *((_OWORD *)v14 + 2);
*((_OWORD *)v13 + 3) = *((_OWORD *)v14 + 3);
*((_OWORD *)v13 + 4) = *((_OWORD *)v14 + 4);
*((_OWORD *)v13 + 5) = *((_OWORD *)v14 + 5);
*((_OWORD *)v13 + 6) = *((_OWORD *)v14 + 6);
v13 += 128;
*((_OWORD *)v13 - 1) = *((_OWORD *)v14 + 7);
v14 += 128;
--v15;
}
while ( v15 );
*(_OWORD *)v13 = *(_OWORD *)v14;
*((_QWORD *)v13 + 2) = *((_QWORD *)v14 + 2);
*((_DWORD *)v13 + 6) = *((_DWORD *)v14 + 6);
*((_WORD *)v13 + 14) = *((_WORD *)v14 + 14);
v13[30] = v14[30];
v12[287] = 0;
v84 = 0;
v85 = 4;
v86 = 15;
strcpy((char *)&v84, "Help");
v16 = InfoAlertButton::create((__int64)&v84, (__int64)v88);
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, (cocos2d::CCNode *)v16);
v17 = *(_QWORD *)v16;
cocos2d::CCPoint::CCPoint(a1->m_width * 0.5, (float)((float)(v65 * 0.5) - (float)(a1->m_width * 0.5)) + 18.0);
v18 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, &v80);
(*(void (__fastcall **)(char *, struct cocos2d::CCPoint))(v17 + 184))(v16, v18);
for ( i = 0; i < 3; ++i )
{
v20 = 0x7FFFFFFFFFFFFFFFLL;
*(_OWORD *)v88 = 0;
v89 = 0;
v90 = 15;
LOBYTE(v88[0]) = 0;
v21 = cocos2d::CCPoint::CCPoint(&v71);
v22 = 0;
v23 = v90;
if ( i )
{
if ( i == 1 )
{
if ( v90 < 0xC )
{
v32 = v90 >> 1;
if ( v90 <= 0x7FFFFFFFFFFFFFFFLL - (v90 >> 1) )
{
v20 = 15;
if ( v32 + v90 > 0xF )
v20 = v32 + v90;
}
v33 = (char *)sub_14003AA10(v20 + 1);
v89 = 12;
v90 = v20;
LODWORD(v21) = *(_DWORD *)"Target Count";
strcpy(v33, "Target Count");
if ( v23 > 0xF )
{
v34 = v88[0];
if ( v23 + 1 >= 0x1000 )
{
v34 = *((void **)v88[0] - 1);
if ( (unsigned __int64)((char *)v88[0] - (char *)v34 - 8) > 0x1F )
goto LABEL_68;
}
j_j_free(v34);
}
v88[0] = v33;
}
else
{
v31 = v88;
if ( v90 > 0xF )
v31 = (void **)v88[0];
v89 = 12;
memmove(v31, "Target Count", 0xCu);
*((_BYTE *)v31 + 12) = 0;
}
cocos2d::CCPoint::CCPoint(*(float *)&v21, (float)(v65 * 0.5) - 70.0);
cocos2d::CCPoint::operator=(&v71, v35);
v30 = (void (*)(SetupCountTriggerPopup *, cocos2d::CCObject *))SetupCountTriggerPopup::onTargetCountArrow;
v22 = 1;
}
else
{
if ( v90 < 9 )
{
v37 = v90 >> 1;
if ( v90 <= 0x7FFFFFFFFFFFFFFFLL - (v90 >> 1) )
{
v20 = 15;
if ( v37 + v90 > 0xF )
v20 = v37 + v90;
}
v38 = (char *)sub_14003AA10(v20 + 1);
v89 = 9;
v90 = v20;
LODWORD(v21) = *(_DWORD *)"Target ID";
strcpy(v38, "Target ID");
if ( v23 > 0xF )
{
v39 = v88[0];
if ( v23 + 1 >= 0x1000 )
{
v39 = *((void **)v88[0] - 1);
if ( (unsigned __int64)((char *)v88[0] - (char *)v39 - 8) > 0x1F )
LABEL_68:
invalid_parameter_noinfo_noreturn();
}
j_j_free(v39);
}
v88[0] = v38;
}
else
{
v36 = v88;
if ( v90 > 0xF )
v36 = (void **)v88[0];
v89 = 9;
memmove(v36, "Target ID", 9u);
*((_BYTE *)v36 + 9) = 0;
}
cocos2d::CCPoint::CCPoint(*(float *)&v21, (float)(v65 * 0.5) + 70.0);
cocos2d::CCPoint::operator=(&v71, v40);
v30 = SetupCountTriggerPopup::onTargetIDArrow;
}
}
else
{
if ( v90 < 7 )
{
v25 = v90 >> 1;
if ( v90 <= 0x7FFFFFFFFFFFFFFFLL - (v90 >> 1) )
{
v26 = 15;
if ( v90 + v25 > 0xF )
v26 = v90 + v25;
}
else
{
v26 = 0x7FFFFFFFFFFFFFFFLL;
}
v27 = (char *)sub_14003AA10(v26 + 1);
v89 = 7;
v90 = v26;
strcpy(v27, "Item ID");
if ( v23 > 0xF )
{
v28 = v88[0];
if ( v23 + 1 >= 0x1000 )
{
v28 = *((void **)v88[0] - 1);
if ( (unsigned __int64)((char *)v88[0] - (char *)v28 - 8) > 0x1F )
goto LABEL_68;
}
j_j_free(v28);
}
v88[0] = v27;
}
else
{
v24 = v88;
if ( v90 > 0xF )
v24 = (void **)v88[0];
v89 = 7;
memmove(v24, "Item ID", 7u);
*((_BYTE *)v24 + 7) = 0;
}
cocos2d::CCPoint::CCPoint(*(float *)&v21, (float)(v65 * 0.5) - 70.0);
cocos2d::CCPoint::operator=(&v71, v29);
v30 = (void (*)(SetupCountTriggerPopup *, cocos2d::CCObject *))SetupCountTriggerPopup::onItemIDArrow;
}
v41 = v88;
if ( v90 > 0xF )
v41 = (void **)v88[0];
v42 = cocos2d::CCLabelBMFont::create((const char *)v41, "goldFont.fnt");
a1->m_mainLayer->addChild_1(a1->m_mainLayer, v42);
v43 = ((float (__fastcall *)(struct cocos2d::CCLabelBMFont *))v42->setScale_0)(v42);
cocos2d::CCPoint::CCPoint(v43, 0.0);
cocos2d::CCPoint::operator+(&v71, &v82);
v42->setPosition_0(v42, &v82);
cocos2d::CCRect::CCRect(&v87, 0.0, 0.0, 40.0, 40.0);
cocos2d::CCRect::CCRect(&v84, &v87);
v45 = cocos2d::extension::CCScale9Sprite::create("square02b_small.png", v44);
LOBYTE(v46) = 100;
v45->setOpacity(&v45->cocos2d::CCRGBAProtocol, v46);
v67 = 0;
v68 = 0;
v69 = 0;
v45->setColor(&v45->cocos2d::CCRGBAProtocol, (const cocos2d::ccColor3B *)&v68);
cocos2d::CCSize::CCSize(&v83, 50.0, 30.0);
v45->setContentSize(v45, &v83);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v45, -1);
v45->setPosition_0(v45, &v71);
v48 = CCTextInputNode::create(50.0, 40.0, "Num", v47, v64, (const char *)&qword_14052A4D8);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v48, 20);
v48->setPosition_0(v48, &v71);
v48->m_maxLabelScale = 0.60000002;
CCTextInputNode::refreshLabel(v48);
v48->m_maxLabelWidth = 200.0;
CCTextInputNode::refreshLabel(v48);
v48->m_textField->setVisible(v48->m_textField, 0);
v48->m_maxLabelLength = 6;
p_m_allowedChars = (void **)&v48->m_allowedChars;
if ( v22 )
{
v76 = 0;
v77 = 11;
v78 = 15;
strcpy(Src, "0123456789-");
v72 = Src;
if ( p_m_allowedChars != (void **)Src )
sub_14003CCE0(p_m_allowedChars, Src, 0xBu);
sub_14003A830((__int64)Src);
}
else
{
v81[1] = 14648;
v81[2] = 10;
v81[3] = 15;
v81[0] = 0x3736353433323130LL;
v72 = (char *)v81;
if ( p_m_allowedChars != v81 )
sub_14003CCE0(p_m_allowedChars, v81, 0xAu);
sub_14003A830((__int64)v81);
}
v70 = -21896;
*(_WORD *)&v48->m_placeholderColor.r = -21896;
v48->m_placeholderColor.b = -16;
CCTextInputNode::refreshLabel(v48);
v48->m_placeholderScale = 0.5;
CCTextInputNode::refreshLabel(v48);
v48->m_delegate = &a1->TextInputDelegate;
v48->m_numberInput = 1;
v48->setTag(v48, i);
cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, &v79);
v50 = cocos2d::CCSprite::createWithSpriteFrameName("edit_leftBtn_001.png");
((void (__fastcall *)(struct cocos2d::CCSprite *))v50->setScale_0)(v50);
v51 = CCMenuItemSpriteExtra::create(v50, nullptr, a1, (cocos2d::SEL_MenuHandler *)v30);
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, v51);
v52 = ((float (__fastcall *)(cocos2d::CCNode *, __int64))v51->setTag)(v51, 1);
cocos2d::CCPoint::CCPoint(v52, -50.0);
cocos2d::CCPoint::operator+(&v79, &v80);
v51->setPosition_0(v51, &v80);
v51[1].m_unknown5 = 0x40000000;
v53 = cocos2d::CCSprite::createWithSpriteFrameName("edit_rightBtn_001.png");
((void (__fastcall *)(struct cocos2d::CCSprite *))v53->setScale_0)(v53);
v54 = CCMenuItemSpriteExtra::create(v53, nullptr, a1, (cocos2d::SEL_MenuHandler *)v30);
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, v54);
v55 = ((float (__fastcall *)(cocos2d::CCNode *, __int64))v54->setTag)(v54, 2);
cocos2d::CCPoint::CCPoint(v55, 50.0);
cocos2d::CCPoint::operator+(&v79, &v66);
v54->setPosition_0(v54, (const cocos2d::CCPoint *)&v66);
v54[1].m_unknown5 = 0x40000000;
if ( i )
{
if ( i == 1 )
a1->m_targetCountInput = v48;
else
a1->m_targetIDInput = v48;
}
else
{
a1->m_itemIDInput = v48;
}
sub_14003A830((__int64)v88);
}
SetupCountTriggerPopup::updateItemIDInputLabel(a1);
SetupCountTriggerPopup::updateTargetIDInputLabel(a1);
SetupCollisionTriggerPopup::updateTargetIDInputLabel((__int64)a1);
cocos2d::CCPoint::CCPoint(a1->m_width * 0.5, (float)((float)(v65 * 0.5) - (float)(a1->m_width * 0.5)) + 20.0);
v73 = v88;
v89 = 13;
v90 = 15;
strcpy((char *)v88, "Touch\nTrigger");
HIWORD(v88[1]) = 0;
cocos2d::CCPoint::CCPoint(4.5274743e21, 8.0);
v57 = v56;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v72);
a1->m_touchToggle = GameToolbox::createToggleButton(
(const char *)v88,
(cocos2d::SEL_MenuHandler *)SetupTriggerPopup::onTouchTriggered,
a1->m_touchTriggered,
a1->m_buttonMenu,
v58,
a1,
a1->m_mainLayer,
0.69999999,
0.34999999,
110.0,
v57,
(const char *)&qword_14052A4D8,
0,
0,
nullptr);
v73 = v88;
v89 = 13;
v90 = 15;
strcpy((char *)v88, "Spawn\nTrigger");
HIWORD(v88[1]) = 0;
cocos2d::CCPoint::CCPoint(4.5724414e33, 0.0);
v59 = cocos2d::CCPoint::operator+(v74, &v66);
cocos2d::CCPoint::CCPoint(*(float *)&v59, 8.0);
a1->m_spawnToggle = GameToolbox::createToggleButton(
(const char *)v88,
(cocos2d::SEL_MenuHandler *)SetupTriggerPopup::onSpawnedByTrigger,
a1->m_spawnTriggered,
a1->m_buttonMenu,
(struct cocos2d::CCPoint)&v66,
a1,
a1->m_mainLayer,
0.69999999,
0.34999999,
110.0,
v60,
(const char *)&qword_14052A4D8,
0,
0,
nullptr);
v73 = v88;
v89 = 13;
v90 = 15;
strcpy((char *)v88, "Multi\nTrigger");
HIWORD(v88[1]) = 0;
cocos2d::CCPoint::CCPoint(7.4936597e31, 200.0);
v61 = cocos2d::CCPoint::operator+(v74, &v66);
cocos2d::CCPoint::CCPoint(*(float *)&v61, 8.0);
GameToolbox::createToggleButton(
(const char *)v88,
(cocos2d::SEL_MenuHandler *)SetupTriggerPopup::onMultiTrigger,
a1->m_multiTriggered,
a1->m_buttonMenu,
(struct cocos2d::CCPoint)&v66,
a1,
a1->m_mainLayer,
0.69999999,
0.34999999,
110.0,
v62,
(const char *)&qword_14052A4D8,
0,
0,
a1->m_multiTriggerContainer);
SetupTriggerPopup::updateMultiTriggerBtn(a1);
v73 = v88;
v89 = 14;
v90 = 15;
strcpy((char *)v88, "Multi\nActivate");
HIBYTE(v88[1]) = 0;
cocos2d::CCPoint::CCPoint(7.4936597e31, 200.0);
cocos2d::CCPoint::operator+(v74, &v66);
SetupTriggerPopup::createToggleButton(
(_DWORD)a1,
(unsigned int)v88,
(unsigned int)SetupCountTriggerPopup::onMultiActivate,
a1->m_multiActivate,
(__int64)&v66);
v73 = v88;
v89 = 14;
v90 = 15;
strcpy((char *)v88, "Activate\nGroup");
HIBYTE(v88[1]) = 0;
cocos2d::CCPoint::CCPoint(1.8465413e25, (float)(v65 * 0.5) + 50.0);
SetupTriggerPopup::createToggleButton(
(_DWORD)a1,
(unsigned int)v88,
(unsigned int)SetupCollisionTriggerPopup::onEnableGroup,
a1->m_activateGroup,
v63);
a1->m_disableTextDelegate = 0;
return 1;
}
return result;
}