//
// SetupRandTriggerPopup::init from 0x14043fb30 to 0x1404408a4 (3444 bytes)
//
// 2 xrefs:
// > SetupRandTriggerPopup::create @ 0x14043faee
// > ??> @ 0x1406da2f8
//
// 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=3
bool SetupRandTriggerPopup::init(SetupRandTriggerPopup *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
_QWORD *v12; // rax
_QWORD *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 v20; // r15d
int v21; // r14d
float v22; // xmm0_4
void (*v23)(SetupRandTriggerPopup *, cocos2d::CCObject *); // r12
unsigned int v24; // r13d
cocos2d::CCString *v25; // rax
const char *CString; // rax
struct cocos2d::CCLabelBMFont *v27; // rbx
float v28; // xmm0_4
struct cocos2d::CCRect *v29; // rax
struct cocos2d::extension::CCScale9Sprite *v30; // rdi
__int64 v31; // rdx
const char *v32; // r9
CCTextInputNode *v33; // rdi
struct cocos2d::CCSprite *v34; // rbx
cocos2d::CCNode *v35; // rbx
float v36; // xmm0_4
struct cocos2d::CCSprite *v37; // rbx
cocos2d::CCNode *v38; // rbx
float v39; // xmm0_4
double v40; // xmm0_8
struct cocos2d::CCLabelBMFont *v41; // rdi
float v42; // xmm0_4
cocos2d::CCLabelBMFont_vtbl *v43; // rbx
const cocos2d::CCPoint *v44; // rax
struct cocos2d::CCRect *v45; // rax
struct cocos2d::extension::CCScale9Sprite *v46; // rdi
__int64 v47; // rdx
float v48; // xmm0_4
const char *v49; // r9
const char *v50; // rax
CCTextInputNode *v51; // rax
CCTextInputNode_vtbl *v52; // rbx
__int64 v53; // rax
CCTextInputNode *m_chanceInput; // rcx
CCTextInputNode *v55; // rcx
std::string *p_m_allowedChars; // rcx
CCTextInputNode *v57; // rcx
CCTextInputNode *v58; // rcx
const char *v59; // r8
Slider *v60; // rax
float v61; // xmm0_4
float v62; // xmm1_4
bool v63; // dl
double v64; // xmm0_8
cocos2d::CCPoint v65; // rax
cocos2d::CCPoint v66; // rbx
cocos2d::CCPoint v67; // rax
int v68; // [rsp+28h] [rbp-E0h]
int v69; // [rsp+28h] [rbp-E0h]
float v70; // [rsp+58h] [rbp-B0h]
cocos2d::CCPoint v71; // [rsp+60h] [rbp-A8h] BYREF
__int16 v72; // [rsp+68h] [rbp-A0h] BYREF
char v73; // [rsp+6Ah] [rbp-9Eh]
__int16 v74; // [rsp+6Ch] [rbp-9Ch]
char v75[8]; // [rsp+70h] [rbp-98h] BYREF
char v76[4]; // [rsp+78h] [rbp-90h] BYREF
_DWORD v77[4]; // [rsp+88h] [rbp-80h] BYREF
__int64 v78; // [rsp+98h] [rbp-70h]
__int64 v79; // [rsp+A0h] [rbp-68h]
struct cocos2d::CCPoint v80; // [rsp+A8h] [rbp-60h] BYREF
struct cocos2d::CCPoint v81; // [rsp+B0h] [rbp-58h] BYREF
_QWORD Src[4]; // [rsp+B8h] [rbp-50h] BYREF
cocos2d::CCRect v83; // [rsp+D8h] [rbp-30h] BYREF
__int64 v84; // [rsp+E8h] [rbp-20h]
__int64 v85; // [rsp+F0h] [rbp-18h]
cocos2d::CCRect v86; // [rsp+F8h] [rbp-10h] BYREF
__int64 v87; // [rsp+108h] [rbp+0h]
__int64 v88; // [rsp+110h] [rbp+8h]
cocos2d::CCPoint v89; // [rsp+120h] [rbp+18h] BYREF
cocos2d::CCSize v90; // [rsp+128h] [rbp+20h] BYREF
cocos2d::CCPoint v91; // [rsp+130h] [rbp+28h] BYREF
cocos2d::CCSize v92; // [rsp+138h] [rbp+30h] BYREF
cocos2d::CCPoint v93[3]; // [rsp+140h] [rbp+38h] BYREF
cocos2d::CCRect v94[11]; // [rsp+160h] [rbp+58h] BYREF
ButtonSprite *v95; // [rsp+260h] [rbp+158h] BYREF
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("Random 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, v70 * 0.5);
v8->setPosition_0(v7, v9);
v95 = (ButtonSprite *)operator new(0x2C0u);
v10 = ButtonSprite::ButtonSprite(v95);
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);
v95 = (ButtonSprite *)&v83;
v83 = 0;
v84 = 0;
v85 = 15;
v12 = sub_14003AA10(0x110u);
v83.origin = (cocos2d::CCPoint)v12;
v84 = 268;
v85 = 271;
v13 = v12;
v14 = "Triggers one of two groups randomly.\n"
"Chance is how likely it is that the first group is triggered.\n"
"For example, setting this to 80% means that there is 80% chance that Group ID 1 is triggered and 20% c"
"hance that Group ID 2 is triggered.";
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 += 16;
*((_OWORD *)v13 - 1) = *((_OWORD *)v14 + 7);
v14 += 128;
--v15;
}
while ( v15 );
*v13 = *(_QWORD *)v14;
*((_DWORD *)v13 + 2) = *((_DWORD *)v14 + 2);
*((_BYTE *)v12 + 268) = 0;
v86 = 0;
v87 = 4;
v88 = 15;
strcpy((char *)&v86, "Help");
v16 = InfoAlertButton::create((__int64)&v86, (__int64)&v83);
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, (cocos2d::CCNode *)v16);
v17 = *(_QWORD *)v16;
cocos2d::CCPoint::CCPoint(a1->m_width * 0.5, (float)((float)(v70 * 0.5) - (float)(a1->m_width * 0.5)) + 18.0);
v18 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, &v81);
v19 = (*(float (__fastcall **)(char *, struct cocos2d::CCPoint))(v17 + 184))(v16, v18);
cocos2d::CCPoint::CCPoint(v19, v70 * 0.5);
v20 = 0;
LOWORD(v95) = 0;
v93[2] = (cocos2d::CCPoint)Src;
v74 = -21896;
do
{
v21 = v20;
cocos2d::CCPoint::CCPoint(&v71);
if ( v20 )
v22 = v71.x + 75.0;
else
v22 = v71.x + -75.0;
v71.x = v22;
v23 = SetupRandTriggerPopup::onTargetIDArrow;
if ( v20 )
v23 = SetupRandTriggerPopup::onTargetID2Arrow;
v24 = 3;
if ( v20 )
v24 = 5;
v25 = cocos2d::CCString::createWithFormat("Group ID %i", ++v20);
CString = cocos2d::CCString::getCString(v25);
v27 = cocos2d::CCLabelBMFont::create(CString, "goldFont.fnt");
a1->m_mainLayer->addChild_1(a1->m_mainLayer, v27);
v28 = ((float (__fastcall *)(struct cocos2d::CCLabelBMFont *))v27->setScale_0)(v27);
cocos2d::CCPoint::CCPoint(v28, 0.0);
cocos2d::CCPoint::operator+(&v71, &v89);
v27->setPosition_0(v27, &v89);
cocos2d::CCRect::CCRect(&v86, 0.0, 0.0, 40.0, 40.0);
cocos2d::CCRect::CCRect(&v83, &v86);
v30 = cocos2d::extension::CCScale9Sprite::create("square02b_small.png", v29);
LOBYTE(v31) = 100;
v30->setOpacity(&v30->cocos2d::CCRGBAProtocol, v31);
v72 = (__int16)v95;
v73 = 0;
v30->setColor(&v30->cocos2d::CCRGBAProtocol, (const cocos2d::ccColor3B *)&v72);
cocos2d::CCSize::CCSize(&v90, 50.0, 30.0);
v30->setContentSize(v30, &v90);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v30, -1);
v30->setPosition_0(v30, &v71);
v33 = CCTextInputNode::create(50.0, 40.0, "Num", v32, v68, (const char *)&qword_14052A4D8);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v33, 20);
v33->setPosition_0(v33, &v71);
v33->m_maxLabelScale = 0.60000002;
CCTextInputNode::refreshLabel(v33);
v33->m_maxLabelWidth = 200.0;
CCTextInputNode::refreshLabel(v33);
v33->m_textField->setVisible(v33->m_textField, 0);
v33->m_maxLabelLength = 6;
Src[1] = 14648;
Src[2] = 10;
Src[3] = 15;
Src[0] = 0x3736353433323130LL;
if ( &v33->m_allowedChars != (std::string *)Src )
sub_14003CCE0((void **)&v33->m_allowedChars, Src, 0xAu);
sub_14003A830((__int64)Src);
*(_WORD *)&v33->m_placeholderColor.r = v74;
v33->m_placeholderColor.b = -16;
CCTextInputNode::refreshLabel(v33);
v33->m_placeholderScale = 0.5;
CCTextInputNode::refreshLabel(v33);
v33->m_delegate = &a1->TextInputDelegate;
v33->m_numberInput = 1;
v33->setTag(v33, v24);
cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, &v80);
v34 = cocos2d::CCSprite::createWithSpriteFrameName("edit_leftBtn_001.png");
((void (__fastcall *)(struct cocos2d::CCSprite *))v34->setScale_0)(v34);
v35 = CCMenuItemSpriteExtra::create(v34, nullptr, a1, (cocos2d::SEL_MenuHandler *)v23);
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, v35);
v36 = ((float (__fastcall *)(cocos2d::CCNode *, __int64))v35->setTag)(v35, 1);
cocos2d::CCPoint::CCPoint(v36, -50.0);
cocos2d::CCPoint::operator+(&v80, &v91);
v35->setPosition_0(v35, &v91);
v35[1].m_unknown5 = 0x40000000;
v37 = cocos2d::CCSprite::createWithSpriteFrameName("edit_rightBtn_001.png");
((void (__fastcall *)(struct cocos2d::CCSprite *))v37->setScale_0)(v37);
v38 = CCMenuItemSpriteExtra::create(v37, nullptr, a1, (cocos2d::SEL_MenuHandler *)v23);
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, v38);
v39 = ((float (__fastcall *)(cocos2d::CCNode *, __int64))v38->setTag)(v38, 2);
cocos2d::CCPoint::CCPoint(v39, 50.0);
v40 = cocos2d::CCPoint::operator+(&v80, &v81);
v38->setPosition_0(v38, &v81);
v38[1].m_unknown5 = 0x40000000;
if ( v21 )
a1->m_groupID2Input = v33;
else
a1->m_groupID1Input = v33;
}
while ( v20 < 2 );
SetupRandTriggerPopup::updateTextInputLabel(a1);
SetupRandTriggerPopup::updateTextInputLabel2(a1);
cocos2d::CCPoint::CCPoint(*(float *)&v40, v70 * 0.5);
v41 = cocos2d::CCLabelBMFont::create("Chance %: ", "goldFont.fnt");
((void (__fastcall *)(struct cocos2d::CCLabelBMFont *))v41->setScale_0)(v41);
v42 = ((float (__fastcall *)(struct cocos2d::CCLabelBMFont *, char *))v41->setPosition_0)(v41, v75);
v43 = v41->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(v42, 1.0);
v43->setAnchorPoint(v41, v44);
a1->m_mainLayer->addChild_1(a1->m_mainLayer, v41);
cocos2d::CCRect::CCRect(v94, 0.0, 0.0, 40.0, 40.0);
cocos2d::CCRect::CCRect(&v83, v94);
v46 = cocos2d::extension::CCScale9Sprite::create("square02_small.png", v45);
LOBYTE(v47) = 100;
v46->setOpacity(&v46->cocos2d::CCRGBAProtocol, v47);
cocos2d::CCSize::CCSize(&v92, 70.0, 30.0);
v46->setContentSize(v46, &v92);
v48 = ((float (__fastcall *)(cocos2d::CCLayer *, struct cocos2d::extension::CCScale9Sprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v46,
0xFFFFFFFFLL);
cocos2d::CCPoint::CCPoint(v48, 45.0);
cocos2d::CCPoint::operator+(v75, &v95);
v46->setPosition_0(v46, (const cocos2d::CCPoint *)&v95);
v50 = "Mixed";
if ( a1->m_chancePercent != -99999.0 )
v50 = "Num";
v51 = CCTextInputNode::create(50.0, 40.0, v50, v49, v69, (const char *)&qword_14052A4D8);
a1->m_chanceInput = v51;
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v51, 20);
v52 = a1->m_chanceInput->__vftable;
v53 = (__int64)v46->getPosition_0(v46);
v52->setPosition_0(a1->m_chanceInput, (const cocos2d::CCPoint *)v53);
m_chanceInput = a1->m_chanceInput;
m_chanceInput->m_maxLabelScale = 0.60000002;
CCTextInputNode::refreshLabel(m_chanceInput);
v55 = a1->m_chanceInput;
v55->m_maxLabelWidth = 200.0;
CCTextInputNode::refreshLabel(v55);
a1->m_chanceInput->m_textField->setVisible(a1->m_chanceInput->m_textField, 0);
a1->m_chanceInput->m_maxLabelLength = 7;
v77[3] = 0;
v78 = 11;
v79 = 15;
strcpy((char *)v77, "0123456789.");
v95 = (ButtonSprite *)v77;
p_m_allowedChars = &a1->m_chanceInput->m_allowedChars;
if ( p_m_allowedChars != (std::string *)v77 )
sub_14003CCE0((void **)p_m_allowedChars, v77, 0xBu);
sub_14003A830((__int64)v77);
LOWORD(v95) = -21896;
v57 = a1->m_chanceInput;
*(_WORD *)&v57->m_placeholderColor.r = -21896;
v57->m_placeholderColor.b = -16;
CCTextInputNode::refreshLabel(v57);
v58 = a1->m_chanceInput;
v58->m_placeholderScale = 0.5;
CCTextInputNode::refreshLabel(v58);
a1->m_chanceInput->m_numberInput = 1;
a1->m_chanceInput->m_delegate = &a1->TextInputDelegate;
a1->m_chanceInput->setTag(a1->m_chanceInput, 4);
v60 = Slider::create(
a1,
(cocos2d::SEL_MenuHandler *)SetupRandTriggerPopup::sliderChanged,
v59,
"slidergroove.png",
"sliderthumb.png",
"sliderthumbsel.png",
0.80000001);
a1->m_chanceSlider = v60;
v60->m_sliderBar->setVisible(v60->m_sliderBar, 0);
v61 = ((float (__fastcall *)(cocos2d::CCLayer *, Slider *))a1->m_mainLayer->addChild_1)(
a1->m_mainLayer,
a1->m_chanceSlider);
cocos2d::CCPoint::CCPoint(v61, 0.0);
cocos2d::CCPoint::operator+(v75, &v95);
a1->m_chanceSlider->setPosition_0(a1->m_chanceSlider, (const cocos2d::CCPoint *)&v95);
v62 = fminf(100.0, a1->m_chancePercent / 100.0);
if ( v62 < 0.0 )
v62 = 0.0;
Slider::setValue(a1->m_chanceSlider, v62);
SetupRandTriggerPopup::updateChanceLabel(a1, v63);
v64 = cocos2d::CCPoint::CCPoint(a1->m_width * 0.5, (float)((float)(v70 * 0.5) - (float)(a1->m_width * 0.5)) + 20.0);
cocos2d::CCPoint::CCPoint(*(float *)&v64, 0.0);
cocos2d::CCPoint::operator+(v76, &v95);
cocos2d::CCPoint::CCPoint(v70 * 0.5, (float)((float)(a1->m_width * 0.5) + (float)(v70 * 0.5)) - 80.0);
v66 = v65;
cocos2d::CCPoint::CCPoint(v93);
SetupTriggerPopup::createMultiTriggerItems(a1, (cocos2d::CCPoint)&v95, v67, v66);
a1->m_disableTextDelegate = 0;
return 1;
}
return result;
}