//
// SetupInstantCountPopup::init from 0x1404223b0 to 0x1404232db (3883 bytes)
//
// 2 xrefs:
// > SetupInstantCountPopup::create @ 0x14042236d
// > ??> @ 0x1406d9614
//
// 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 SetupInstantCountPopup::init(SetupInstantCountPopup *a1, CountTriggerGameObject *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
float v19; // xmm0_4
int i; // r15d
__int64 v21; // rbx
double v22; // xmm0_8
char v23; // r12
unsigned __int64 v24; // rdi
void **v25; // rbx
unsigned __int64 v26; // rcx
__int64 v27; // rsi
char *v28; // rbx
void *v29; // rcx
cocos2d::SEL_MenuHandler *v30; // rsi
void **v31; // rbx
unsigned __int64 v32; // rcx
char *v33; // rsi
void *v34; // rcx
void **v35; // rbx
unsigned __int64 v36; // rcx
char *v37; // rsi
void *v38; // rcx
void **v39; // rcx
struct cocos2d::CCLabelBMFont *v40; // rbx
float v41; // xmm0_4
struct cocos2d::CCRect *v42; // rax
struct cocos2d::extension::CCScale9Sprite *v43; // rdi
__int64 v44; // rdx
const char *v45; // r9
CCTextInputNode *v46; // rdi
void **p_m_allowedChars; // rcx
struct cocos2d::CCSprite *v48; // rbx
cocos2d::CCNode *v49; // rbx
float v50; // xmm0_4
struct cocos2d::CCSprite *v51; // rbx
cocos2d::CCNode *v52; // rbx
float v53; // xmm0_4
double ToggleButton; // xmm0_8
int v55; // r9d
CCMenuItemToggler *v56; // rax
int v57; // r9d
CCMenuItemToggler *v58; // rax
float v59; // xmm0_4
int v60; // r9d
CCMenuItemToggler *v61; // rax
int v62; // [rsp+28h] [rbp-E0h]
ButtonSprite *v63; // [rsp+58h] [rbp-B0h] BYREF
float v64; // [rsp+60h] [rbp-A8h]
__int16 v65; // [rsp+68h] [rbp-A0h]
__int16 v66; // [rsp+6Ch] [rbp-9Ch] BYREF
char v67; // [rsp+6Eh] [rbp-9Ah]
__int16 v68; // [rsp+70h] [rbp-98h]
cocos2d::CCPoint v69; // [rsp+78h] [rbp-90h] BYREF
char v70[8]; // [rsp+80h] [rbp-88h] BYREF
void **v71; // [rsp+90h] [rbp-78h]
char v72[8]; // [rsp+98h] [rbp-70h] BYREF
char *v73; // [rsp+A0h] [rbp-68h]
char Src[12]; // [rsp+A8h] [rbp-60h] BYREF
int v75; // [rsp+B4h] [rbp-54h]
__int64 v76; // [rsp+B8h] [rbp-50h]
__int64 v77; // [rsp+C0h] [rbp-48h]
struct cocos2d::CCPoint v78; // [rsp+C8h] [rbp-40h] BYREF
struct cocos2d::CCPoint v79; // [rsp+D0h] [rbp-38h] BYREF
_QWORD v80[4]; // [rsp+D8h] [rbp-30h] BYREF
char v81[8]; // [rsp+F8h] [rbp-10h] BYREF
char v82[8]; // [rsp+100h] [rbp-8h] BYREF
char v83[8]; // [rsp+108h] [rbp+0h] BYREF
cocos2d::CCPoint v84; // [rsp+110h] [rbp+8h] BYREF
cocos2d::CCSize v85; // [rsp+118h] [rbp+10h] BYREF
cocos2d::CCRect v86; // [rsp+120h] [rbp+18h] BYREF
__int64 v87; // [rsp+130h] [rbp+28h]
__int64 v88; // [rsp+138h] [rbp+30h]
cocos2d::CCRect v89; // [rsp+160h] [rbp+58h] BYREF
void *v90[2]; // [rsp+170h] [rbp+68h] BYREF
__int64 v91; // [rsp+180h] [rbp+78h]
unsigned __int64 v92; // [rsp+188h] [rbp+80h]
result = SetupTriggerPopup::init(a1, a2, a3, 320.0, 280.0, 1);
if ( result )
{
a1->determineStartValues(a1);
v6 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v5);
cocos2d::CCDirector::getWinSize(v6);
v7 = cocos2d::CCLabelBMFont::create("Instant 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, v64 * 0.5);
v8->setPosition_0(v7, v9);
v63 = (ButtonSprite *)operator new(0x2C0u);
v10 = ButtonSprite::ButtonSprite(v63);
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);
v63 = (ButtonSprite *)v90;
*(_OWORD *)v90 = 0;
v91 = 0;
v92 = 15;
v12 = sub_14003AA10(0x140u);
v90[0] = v12;
v91 = 314;
v92 = 319;
v13 = v12;
v14 = "Disables objects using Target ID when an Item ID reaches a certain Target Count. The c"
"ondition is only checked once when the trigger is activated.\n"
"Equals, Larger, or Smaller specify which condition to use.\n"
"Activate Group makes the trigger enable and spawn the group instead.";
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;
*((_OWORD *)v13 + 1) = *((_OWORD *)v14 + 1);
*((_OWORD *)v13 + 2) = *((_OWORD *)v14 + 2);
*((_QWORD *)v13 + 6) = *((_QWORD *)v14 + 6);
*((_WORD *)v13 + 28) = *((_WORD *)v14 + 28);
v12[314] = 0;
v86 = 0;
v87 = 4;
v88 = 15;
strcpy((char *)&v86, "Help");
v16 = InfoAlertButton::create((__int64)&v86, (__int64)v90);
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, (cocos2d::CCNode *)v16);
v17 = *(_QWORD *)v16;
cocos2d::CCPoint::CCPoint(a1->m_width * 0.5, (float)((float)(v64 * 0.5) - (float)(a1->m_width * 0.5)) + 18.0);
v18 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, &v79);
v19 = (*(float (__fastcall **)(char *, struct cocos2d::CCPoint))(v17 + 184))(v16, v18);
a1->m_joystickConnected = -1;
cocos2d::CCPoint::CCPoint(v19, v64 * 0.5);
for ( i = 0; i < 3; ++i )
{
v21 = 0x7FFFFFFFFFFFFFFFLL;
*(_OWORD *)v90 = 0;
v91 = 0;
v92 = 15;
LOBYTE(v90[0]) = 0;
v22 = cocos2d::CCPoint::CCPoint(&v69);
v23 = 0;
v24 = v92;
if ( i )
{
if ( i == 1 )
{
if ( v92 < 0xC )
{
v32 = v92 >> 1;
if ( v92 <= 0x7FFFFFFFFFFFFFFFLL - (v92 >> 1) )
{
v21 = 15;
if ( v92 + v32 > 0xF )
v21 = v92 + v32;
}
v33 = (char *)sub_14003AA10(v21 + 1);
v91 = 12;
v92 = v21;
LODWORD(v22) = *(_DWORD *)"Target Count";
strcpy(v33, "Target Count");
if ( v24 > 0xF )
{
v34 = v90[0];
if ( v24 + 1 >= 0x1000 )
{
v34 = *((void **)v90[0] - 1);
if ( (unsigned __int64)((char *)v90[0] - (char *)v34 - 8) > 0x1F )
goto LABEL_68;
}
j_j_free(v34);
}
v90[0] = v33;
}
else
{
v31 = v90;
if ( v92 > 0xF )
v31 = (void **)v90[0];
v91 = 12;
memmove(v31, "Target Count", 0xCu);
*((_BYTE *)v31 + 12) = 0;
}
cocos2d::CCPoint::CCPoint(*(float *)&v22, -70.0);
cocos2d::CCPoint::operator+(v70, v82);
cocos2d::CCPoint::operator=(&v69, v82);
v30 = (cocos2d::SEL_MenuHandler *)SetupCountTriggerPopup::onTargetCountArrow;
v23 = 1;
}
else
{
if ( v92 < 9 )
{
v36 = v92 >> 1;
if ( v92 <= 0x7FFFFFFFFFFFFFFFLL - (v92 >> 1) )
{
v21 = 15;
if ( v92 + v36 > 0xF )
v21 = v92 + v36;
}
v37 = (char *)sub_14003AA10(v21 + 1);
v91 = 9;
v92 = v21;
LODWORD(v22) = *(_DWORD *)"Target ID";
strcpy(v37, "Target ID");
if ( v24 > 0xF )
{
v38 = v90[0];
if ( v24 + 1 >= 0x1000 )
{
v38 = *((void **)v90[0] - 1);
if ( (unsigned __int64)((char *)v90[0] - (char *)v38 - 8) > 0x1F )
LABEL_68:
invalid_parameter_noinfo_noreturn();
}
j_j_free(v38);
}
v90[0] = v37;
}
else
{
v35 = v90;
if ( v92 > 0xF )
v35 = (void **)v90[0];
v91 = 9;
memmove(v35, "Target ID", 9u);
*((_BYTE *)v35 + 9) = 0;
}
cocos2d::CCPoint::CCPoint(*(float *)&v22, 70.0);
cocos2d::CCPoint::operator+(v70, v83);
cocos2d::CCPoint::operator=(&v69, v83);
v30 = (cocos2d::SEL_MenuHandler *)SetupInstantCountPopup::onTargetID2Arrow;
}
}
else
{
if ( v92 < 7 )
{
v26 = v92 >> 1;
if ( v92 <= 0x7FFFFFFFFFFFFFFFLL - (v92 >> 1) )
{
v27 = 15;
if ( v92 + v26 > 0xF )
v27 = v92 + v26;
}
else
{
v27 = 0x7FFFFFFFFFFFFFFFLL;
}
v28 = (char *)sub_14003AA10(v27 + 1);
v91 = 7;
v92 = v27;
strcpy(v28, "Item ID");
if ( v24 > 0xF )
{
v29 = v90[0];
if ( v24 + 1 >= 0x1000 )
{
v29 = *((void **)v90[0] - 1);
if ( (unsigned __int64)((char *)v90[0] - (char *)v29 - 8) > 0x1F )
goto LABEL_68;
}
j_j_free(v29);
}
v90[0] = v28;
}
else
{
v25 = v90;
if ( v92 > 0xF )
v25 = (void **)v90[0];
v91 = 7;
memmove(v25, "Item ID", 7u);
*((_BYTE *)v25 + 7) = 0;
}
cocos2d::CCPoint::CCPoint(*(float *)&v22, -70.0);
cocos2d::CCPoint::operator+(v70, v81);
cocos2d::CCPoint::operator=(&v69, v81);
v30 = (cocos2d::SEL_MenuHandler *)SetupCountTriggerPopup::onItemIDArrow;
}
v39 = v90;
if ( v92 > 0xF )
v39 = (void **)v90[0];
v40 = cocos2d::CCLabelBMFont::create((const char *)v39, "goldFont.fnt");
a1->m_mainLayer->addChild_1(a1->m_mainLayer, v40);
v41 = ((float (__fastcall *)(struct cocos2d::CCLabelBMFont *))v40->setScale_0)(v40);
cocos2d::CCPoint::CCPoint(v41, 0.0);
cocos2d::CCPoint::operator+(&v69, &v84);
v40->setPosition_0(v40, &v84);
cocos2d::CCRect::CCRect(&v89, 0.0, 0.0, 40.0, 40.0);
cocos2d::CCRect::CCRect(&v86, &v89);
v43 = cocos2d::extension::CCScale9Sprite::create("square02b_small.png", v42);
LOBYTE(v44) = 100;
v43->setOpacity(&v43->cocos2d::CCRGBAProtocol, v44);
v65 = 0;
v66 = 0;
v67 = 0;
v43->setColor(&v43->cocos2d::CCRGBAProtocol, (const cocos2d::ccColor3B *)&v66);
cocos2d::CCSize::CCSize(&v85, 50.0, 30.0);
v43->setContentSize(v43, &v85);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v43, -1);
v43->setPosition_0(v43, &v69);
v46 = CCTextInputNode::create(50.0, 40.0, "Num", v45, v62, (const char *)&qword_14052A4D8);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v46, 20);
v46->setPosition_0(v46, &v69);
v46->m_maxLabelScale = 0.60000002;
CCTextInputNode::refreshLabel(v46);
v46->m_maxLabelWidth = 200.0;
CCTextInputNode::refreshLabel(v46);
v46->m_textField->setVisible(v46->m_textField, 0);
v46->m_maxLabelLength = 6;
p_m_allowedChars = (void **)&v46->m_allowedChars;
if ( v23 )
{
v75 = 0;
v76 = 11;
v77 = 15;
strcpy(Src, "0123456789-");
v73 = Src;
if ( p_m_allowedChars != (void **)Src )
sub_14003CCE0(p_m_allowedChars, Src, 0xBu);
sub_14003A830((__int64)Src);
}
else
{
v80[1] = 14648;
v80[2] = 10;
v80[3] = 15;
v80[0] = 0x3736353433323130LL;
v73 = (char *)v80;
if ( p_m_allowedChars != v80 )
sub_14003CCE0(p_m_allowedChars, v80, 0xAu);
sub_14003A830((__int64)v80);
}
v68 = -21896;
*(_WORD *)&v46->m_placeholderColor.r = -21896;
v46->m_placeholderColor.b = -16;
CCTextInputNode::refreshLabel(v46);
v46->m_placeholderScale = 0.5;
CCTextInputNode::refreshLabel(v46);
v46->m_delegate = &a1->TextInputDelegate;
v46->m_numberInput = 1;
v46->setTag(v46, i);
cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, &v78);
v48 = cocos2d::CCSprite::createWithSpriteFrameName("edit_leftBtn_001.png");
((void (__fastcall *)(struct cocos2d::CCSprite *))v48->setScale_0)(v48);
v49 = CCMenuItemSpriteExtra::create(v48, nullptr, a1, v30);
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, v49);
v50 = ((float (__fastcall *)(cocos2d::CCNode *, __int64))v49->setTag)(v49, 1);
cocos2d::CCPoint::CCPoint(v50, -50.0);
cocos2d::CCPoint::operator+(&v78, &v79);
v49->setPosition_0(v49, &v79);
v49[1].m_unknown5 = 0x40000000;
v51 = cocos2d::CCSprite::createWithSpriteFrameName("edit_rightBtn_001.png");
((void (__fastcall *)(struct cocos2d::CCSprite *))v51->setScale_0)(v51);
v52 = CCMenuItemSpriteExtra::create(v51, nullptr, a1, v30);
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, v52);
v53 = ((float (__fastcall *)(cocos2d::CCNode *, __int64))v52->setTag)(v52, 2);
cocos2d::CCPoint::CCPoint(v53, 50.0);
cocos2d::CCPoint::operator+(&v78, &v63);
v52->setPosition_0(v52, (const cocos2d::CCPoint *)&v63);
v52[1].m_unknown5 = 0x40000000;
if ( i )
{
if ( i == 1 )
a1->m_targetCountInput = v46;
else
a1->m_targetIDInput = v46;
}
else
{
a1->m_itemIDInput = v46;
}
sub_14003A830((__int64)v90);
}
SetupCountTriggerPopup::updateItemIDInputLabel((__int64)a1);
SetupCountTriggerPopup::updateTargetIDInputLabel((__int64)a1);
SetupCollisionTriggerPopup::updateTargetIDInputLabel((__int64)a1);
SetupTriggerPopup::createMultiTriggerItemsDefault(a1);
v71 = v90;
v91 = 14;
v92 = 15;
strcpy((char *)v90, "Activate\nGroup");
HIBYTE(v90[1]) = 0;
cocos2d::CCPoint::CCPoint(1.8465413e25, 50.0);
cocos2d::CCPoint::operator+(v70, &v63);
ToggleButton = SetupTriggerPopup::createToggleButton(
(_DWORD)a1,
(unsigned int)v90,
(unsigned int)SetupCollisionTriggerPopup::onEnableGroup,
a1->m_activateGroup,
(__int64)&v63);
cocos2d::CCPoint::CCPoint(*(float *)&ToggleButton, (float)(v64 * 0.5) - 28.0);
v71 = v90;
*(_OWORD *)v90 = 0;
v91 = 6;
v92 = 15;
strcpy((char *)v90, "Equals");
cocos2d::CCPoint::CCPoint(0.0, -90.0);
cocos2d::CCPoint::operator+(v72, &v63);
LOBYTE(v55) = a1->m_mode == 0;
SetupTriggerPopup::createToggleButton(
(_DWORD)a1,
(unsigned int)v90,
(unsigned int)SetupInstantCountPopup::onCountType,
v55,
(__int64)&v63);
a1->m_equalsToggler = v56;
v56->setTag(v56, 0);
BYTE1(a1->m_equalsToggler->m_onButton) = 1;
v71 = v90;
*(_OWORD *)v90 = 0;
v91 = 6;
v92 = 15;
strcpy((char *)v90, "Larger");
cocos2d::CCPoint::CCPoint(0.0, 0.0);
cocos2d::CCPoint::operator+(v72, &v63);
LOBYTE(v57) = a1->m_mode == 1;
SetupTriggerPopup::createToggleButton(
(_DWORD)a1,
(unsigned int)v90,
(unsigned int)SetupInstantCountPopup::onCountType,
v57,
(__int64)&v63);
a1->m_largerToggler = v58;
v59 = ((float (__fastcall *)(CCMenuItemToggler *, __int64))v58->setTag)(v58, 1);
BYTE1(a1->m_largerToggler->m_onButton) = 1;
v71 = v90;
v90[1] = nullptr;
v91 = 7;
v92 = 15;
v90[0] = (void *)0x72656C6C616D53LL;
cocos2d::CCPoint::CCPoint(v59, 90.0);
cocos2d::CCPoint::operator+(v72, &v63);
LOBYTE(v60) = a1->m_mode == 2;
SetupTriggerPopup::createToggleButton(
(_DWORD)a1,
(unsigned int)v90,
(unsigned int)SetupInstantCountPopup::onCountType,
v60,
(__int64)&v63);
a1->m_smallerToggler = v61;
v61->setTag(v61, 2);
BYTE1(a1->m_smallerToggler->m_onButton) = 1;
a1->m_disableTextDelegate = 0;
return 1;
}
return result;
}