//
// SetupRandTriggerPopup::init from 0x1001c9c88 to 0x1001ca750 (2760 bytes)
//
// 1 xrefs:
// > SetupRandTriggerPopup::create @ 0x1001c9c38
//
// 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
//
bool __fastcall SetupRandTriggerPopup::init(SetupRandTriggerPopup *a1, EffectGameObject *a2, cocos2d::CCArray *a3)
{
_BOOL4 v4; // w22
cocos2d::CCDirector *v5; // x0
cocos2d::CCLabelBMFont *v6; // x21
__n128 v7; // q0
__n128 v8; // q1
ButtonSprite *v9; // x0
CCMenuItemSpriteExtra *v10; // x0
char *v11; // x20
__n128 v12; // q0
cocos2d::CCMenu *m_buttonMenu; // x21
__n128 v14; // q1
__n128 v15; // q0
__n128 v16; // q1
TextInputDelegate *v17; // x24
char v18; // w25
int i; // w22
float v20; // s1
void (__cdecl *v21)(cocos2d::CCObject *); // x21
__int64 v22; // x23
cocos2d::CCString *v23; // x0
const char *CString; // x0
cocos2d::CCLabelBMFont *v25; // x22
__n128 v26; // q0
__n128 v27; // q1
double v28; // d0
double v29; // d0
cocos2d::extension::CCScale9Sprite *v30; // x22
CCTextInputNode *v31; // x22
cocos2d::CCSprite *v32; // x23
CCMenuItemSpriteExtra *v33; // x23
__n128 v34; // q0
__n128 v35; // q1
double v36; // d0
cocos2d::CCSprite *v37; // x23
CCMenuItemSpriteExtra *v38; // x21
__n128 v39; // q0
__n128 v40; // q1
double v41; // d0
__n128 v42; // q0
__n128 v43; // q1
cocos2d::CCLabelBMFont *v44; // x20
__n128 v45; // q0
__n128 v46; // q1
double v47; // d0
cocos2d::extension::CCScale9Sprite *v48; // x20
__n128 v49; // q0
__n128 v50; // q1
double v51; // d0
const char *v52; // x0
CCTextInputNode *v53; // x0
CCTextInputNode *m_chanceInput; // x21
__int64 v55; // x0
CCTextInputNode *v56; // x20
CCTextInputNode *v57; // x0
Slider *v58; // x0
__n128 v59; // q0
Slider *m_chanceSlider; // x20
__n128 v61; // q1
double v62; // d0
float v63; // s1
float v64; // s0
_BOOL4 v65; // w8
_BOOL4 v66; // w9
__n128 v67; // q0
__n128 v68; // q1
__n128 v69; // q0
__n128 v70; // q1
__n128 v71; // q0
__n128 v72; // q1
float v74; // s1
float v75; // s2
float v76; // s3
float v77; // s1
float v78; // s2
float v79; // s3
bool v80; // [xsp+10h] [xbp-160h]
int v81; // [xsp+18h] [xbp-158h] BYREF
__int64 v82; // [xsp+20h] [xbp-150h] BYREF
std::string v83; // [xsp+28h] [xbp-148h] BYREF
float32x2_t v84; // [xsp+40h] [xbp-130h] BYREF
float32x2_t v85; // [xsp+48h] [xbp-128h] BYREF
float32x2_t v86; // [xsp+50h] [xbp-120h] BYREF
std::string v87; // [xsp+58h] [xbp-118h] BYREF
float32x2_t v88[2]; // [xsp+70h] [xbp-100h] BYREF
float32x2_t v89[2]; // [xsp+80h] [xbp-F0h] BYREF
float32x2_t v90; // [xsp+90h] [xbp-E0h] BYREF
__int64 v91; // [xsp+98h] [xbp-D8h] BYREF
void *__p[2]; // [xsp+A0h] [xbp-D0h] BYREF
char v93; // [xsp+B7h] [xbp-B9h]
void *v94[2]; // [xsp+B8h] [xbp-B8h] BYREF
char v95; // [xsp+CFh] [xbp-A1h]
float v96; // [xsp+D0h] [xbp-A0h]
float v97; // [xsp+D4h] [xbp-9Ch]
cocos2d::CCPoint v98; // 0:kr08_8.8
cocos2d::SEL_MenuHandler v99; // 0:x1.16
cocos2d::SEL_MenuHandler v100; // 0:x3.16
cocos2d::SEL_MenuHandler v101; // 0:x3.16
cocos2d::SEL_MenuHandler v102; // 0:x3.16
cocos2d::CCRect v103; // 0:kr20_16.16
cocos2d::CCRect v104; // 0:kr30_16.16
cocos2d::CCPoint v105; // 0:s0.4,4:s1.4
cocos2d::CCPoint v106; // 0:s2.4,4:s3.4
cocos2d::CCPoint v107; // 0:s4.4,4:s5.4
v4 = SetupTriggerPopup::init(a1, a2, a3, 320.0, 280.0, 1);
if ( v4 )
{
((void (__fastcall *)(SetupRandTriggerPopup *))a1->determineStartValues)(a1);
v5 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v5);
v6 = cocos2d::CCLabelBMFont::create_1("Random Trigger", "goldFont.fnt");
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCLabelBMFont *))a1->m_mainLayer->addChild)(a1->m_mainLayer, v6);
v7 = ((__n128 (__fastcall *)(cocos2d::CCLabelBMFont *, float))v6->setScale)(v6, 0.7);
v7.n128_f32[0] = v96 * 0.5;
v8.n128_f32[0] = (float)((float)(v97 * 0.5) + (float)(a1->m_height * 0.5)) + -18.0;
sub_100022980(v7, v8, v89);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float32x2_t *))v6->setPosition)(v6, v89);
v9 = ButtonSprite::create_1("OK", 40, 0, 0.8, 1, "goldFont.fnt", "GJ_button_01.png", 30.0);
v100.ptr = (void (__cdecl *)(cocos2d::CCObject *))1320;
v100.adj = 1;
v10 = CCMenuItemSpriteExtra::create(v9, nullptr, a1, v100);
((void (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild)(a1->m_buttonMenu, v10);
sub_100009900(v94, "Help");
sub_100009900(
__p,
"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% chanc"
"e that Group ID 2 is triggered.");
v11 = InfoAlertButton::create((__int64)v94, (__int64)__p, 1.0);
if ( v93 < 0 )
operator delete(__p[0]);
v80 = v4;
if ( v95 < 0 )
operator delete(v94[0]);
v12 = ((__n128 (__fastcall *)(cocos2d::CCMenu *, char *))a1->m_buttonMenu->addChild)(a1->m_buttonMenu, v11);
m_buttonMenu = a1->m_buttonMenu;
v12.n128_f32[0] = (float)((float)(v96 * 0.5) - (float)(a1->m_width * 0.5)) + 18.0;
v14.n128_f32[0] = (float)((float)(v97 * 0.5) + (float)(a1->m_height * 0.5)) + -18.0;
sub_100022980(v12, v14, v88);
v98 = cocos2d::CCNode::convertToNodeSpace(m_buttonMenu, (const cocos2d::CCPoint *)v88);
v15 = ((__n128 (__fastcall *)(char *, float32x2_t *, float, float))*(_QWORD *)(*(_QWORD *)v11 + 184LL))(
v11,
v89,
v98.x,
v98.y);
v15.n128_f32[0] = v96 * 0.5;
v16.n128_f32[0] = (float)(v97 * 0.5) + 50.0;
sub_100022980(v15, v16, &v91);
v17 = &a1->TextInputDelegate;
v18 = 1;
for ( i = 1; ; i = 2 )
{
sub_1000229B8((__int64 *)&v90, &v91);
if ( (v18 & 1) != 0 )
v20 = -75.0;
else
v20 = 75.0;
if ( (v18 & 1) != 0 )
v21 = (void (__cdecl *)(cocos2d::CCObject *))SetupRandTriggerPopup::onTargetIDArrow;
else
v21 = (void (__cdecl *)(cocos2d::CCObject *))SetupRandTriggerPopup::onTargetID2Arrow;
if ( (v18 & 1) != 0 )
v22 = 3;
else
v22 = 5;
v90.f32[0] = v20 + v90.f32[0];
v23 = (cocos2d::CCString *)sub_100268F4C("Group ID %i", i);
CString = cocos2d::CCString::getCString(v23);
v25 = cocos2d::CCLabelBMFont::create_1(CString, "goldFont.fnt");
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCLabelBMFont *))a1->m_mainLayer->addChild)(
a1->m_mainLayer,
v25);
v26 = ((__n128 (__fastcall *)(cocos2d::CCLabelBMFont *, float))v25->setScale)(v25, 0.5);
v26.n128_u32[0] = 0;
v27.n128_u32[0] = 1107820544;
sub_100022980(v26, v27, v88);
*(float32x2_t *)&v28 = sub_1000229DC(&v90, v88, v89);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float32x2_t *, double))v25->setPosition)(v25, v89, v28);
sub_100022990((float *)v89, 0.0, 0.0, 40.0, 40.0);
v29 = sub_100022B98(v88, (__int64)v89);
v103.origin.x = *(float *)&v29;
v103.origin.y = v74;
v103.size.width = v75;
v103.size.height = v76;
v30 = cocos2d::extension::CCScale9Sprite::create("square02b_small.png", v103);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, __int64))v30->setOpacity)(v30, 100);
v88[0].i8[2] = 0;
v88[0].i16[0] = 0;
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, float32x2_t *))v30->setColor)(v30, v88);
sub_100022988((float *)v88, 50.0, 30.0);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, float32x2_t *))v30->setContentSize)(v30, v88);
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::extension::CCScale9Sprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v30,
0xFFFFFFFFLL);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, float32x2_t *))v30->setPosition)(v30, &v90);
v31 = CCTextInputNode::create(50.0, 40.0, "Num", "Thonburi", 24, "bigFont.fnt");
((void (__fastcall *)(cocos2d::CCLayer *, CCTextInputNode *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v31,
20);
((void (__fastcall *)(CCTextInputNode *, float32x2_t *))v31->setPosition)(v31, &v90);
CCTextInputNode::setMaxLabelScale(v31, 0.6);
CCTextInputNode::setMaxLabelWidth(v31, 200.0);
((void (__fastcall *)(cocos2d::CCTextFieldTTF *, _QWORD))v31->m_textField->setVisible)(v31->m_textField, 0);
v31->m_maxLabelLength = 6;
sub_100009900(&v87, "0123456789");
CCTextInputNode::setAllowedChars((std::string *)v31, &v87);
if ( SHIBYTE(v87.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v87.__r_.__value_.__l.__data_);
CCTextInputNode::setLabelPlaceholderColor(v31, (cocos2d::ccColor3B)-1004936);
CCTextInputNode::setLabelPlaceholderScale(v31, 0.5);
v31->m_delegate = v17;
v31->m_numberInput = 1;
((void (__fastcall *)(CCTextInputNode *, __int64))v31->setTag)(v31, v22);
cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, (const cocos2d::CCPoint *)&v90);
v32 = cocos2d::CCSprite::createWithSpriteFrameName("edit_leftBtn_001.png");
((void (__fastcall *)(cocos2d::CCSprite *, float))v32->setScale)(v32, 1.1);
v101.ptr = v21;
v101.adj = 0;
v33 = CCMenuItemSpriteExtra::create(v32, nullptr, a1, v101);
((void (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild)(
a1->m_buttonMenu,
v33);
v34 = ((__n128 (__fastcall *)(CCMenuItemSpriteExtra *, __int64))v33->setTag)(v33, 1);
v34.n128_u32[0] = -1035468800;
v35.n128_u32[0] = 0;
sub_100022980(v34, v35, &v84);
*(float32x2_t *)&v36 = sub_1000229DC(&v86, &v84, &v85);
((void (__fastcall *)(CCMenuItemSpriteExtra *, float32x2_t *, double))v33->setPosition)(v33, &v85, v36);
CCMenuItemSpriteExtra::setSizeMult(v33, 2.0);
v37 = cocos2d::CCSprite::createWithSpriteFrameName("edit_rightBtn_001.png");
((void (__fastcall *)(cocos2d::CCSprite *, float))v37->setScale)(v37, 1.1);
v102.ptr = v21;
v102.adj = 0;
v38 = CCMenuItemSpriteExtra::create(v37, nullptr, a1, v102);
((void (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild)(
a1->m_buttonMenu,
v38);
v39 = ((__n128 (__fastcall *)(CCMenuItemSpriteExtra *, __int64))v38->setTag)(v38, 2);
v40.n128_u32[0] = 0;
v39.n128_u32[0] = 1112014848;
sub_100022980(v39, v40, &v84);
*(float32x2_t *)&v41 = sub_1000229DC(&v86, &v84, &v85);
((void (__fastcall *)(CCMenuItemSpriteExtra *, float32x2_t *, double))v38->setPosition)(v38, &v85, v41);
CCMenuItemSpriteExtra::setSizeMult(v38, 2.0);
if ( (v18 & 1) == 0 )
break;
v18 = 0;
a1->m_groupID1Input = v31;
}
a1->m_groupID2Input = v31;
SetupRandTriggerPopup::updateTextInputLabel(a1);
SetupRandTriggerPopup::updateTextInputLabel2(a1);
v42.n128_f32[0] = v96 * 0.5;
v43.n128_f32[0] = (float)(v97 * 0.5) + -10.0;
sub_100022980(v42, v43, &v90);
v44 = cocos2d::CCLabelBMFont::create_1("Chance %: ", "goldFont.fnt");
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float))v44->setScale)(v44, 0.7);
v45 = ((__n128 (__fastcall *)(cocos2d::CCLabelBMFont *, float32x2_t *))v44->setPosition)(v44, &v90);
v45.n128_u32[0] = 1.0;
v46.n128_u32[0] = 0.5;
sub_100022980(v45, v46, v89);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float32x2_t *))v44->setAnchorPoint)(v44, v89);
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCLabelBMFont *))a1->m_mainLayer->addChild)(a1->m_mainLayer, v44);
sub_100022990((float *)v89, 0.0, 0.0, 40.0, 40.0);
v47 = sub_100022B98(v88, (__int64)v89);
v104.origin.x = *(float *)&v47;
v104.origin.y = v77;
v104.size.width = v78;
v104.size.height = v79;
v48 = cocos2d::extension::CCScale9Sprite::create("square02_small.png", v104);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, __int64))v48->setOpacity)(v48, 100);
sub_100022988((float *)v88, 70.0, 30.0);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, float32x2_t *))v48->setContentSize)(v48, v88);
v49 = ((__n128 (__fastcall *)(cocos2d::CCLayer *, cocos2d::extension::CCScale9Sprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v48,
0xFFFFFFFFLL);
v49.n128_u32[0] = 1110704128;
v50.n128_u32[0] = 0;
sub_100022980(v49, v50, &v85);
*(float32x2_t *)&v51 = sub_1000229DC(&v90, &v85, &v86);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, float32x2_t *, double))v48->setPosition)(v48, &v86, v51);
if ( a1->m_chancePercent == -99999.0 )
v52 = "Mixed";
else
v52 = "Num";
v53 = CCTextInputNode::create(50.0, 40.0, v52, "Thonburi", 24, "bigFont.fnt");
a1->m_chanceInput = v53;
((void (__fastcall *)(cocos2d::CCLayer *, CCTextInputNode *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v53,
20);
m_chanceInput = a1->m_chanceInput;
v55 = ((__int64 (__fastcall *)(cocos2d::extension::CCScale9Sprite *))v48->getPosition)(v48);
((void (__fastcall *)(CCTextInputNode *, __int64))m_chanceInput->setPosition)(m_chanceInput, v55);
CCTextInputNode::setMaxLabelScale(a1->m_chanceInput, 0.6);
CCTextInputNode::setMaxLabelWidth(a1->m_chanceInput, 200.0);
((void (__fastcall *)(cocos2d::CCTextFieldTTF *, _QWORD))a1->m_chanceInput->m_textField->setVisible)(
a1->m_chanceInput->m_textField,
0);
v56 = a1->m_chanceInput;
v56->m_maxLabelLength = 7;
sub_100009900(&v83, "0123456789.");
CCTextInputNode::setAllowedChars((std::string *)v56, &v83);
LOBYTE(v4) = v80;
if ( SHIBYTE(v83.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v83.__r_.__value_.__l.__data_);
CCTextInputNode::setLabelPlaceholderColor(a1->m_chanceInput, (cocos2d::ccColor3B)-1004936);
CCTextInputNode::setLabelPlaceholderScale(a1->m_chanceInput, 0.5);
v57 = a1->m_chanceInput;
v57->m_numberInput = 1;
v57->m_delegate = v17;
((void (__fastcall *)(CCTextInputNode *, __int64))v57->setTag)(v57, 4);
v99.ptr = (void (__cdecl *)(cocos2d::CCObject *))SetupRandTriggerPopup::sliderChanged;
v99.adj = 0;
v58 = Slider::create_1(a1, v99, 0.8);
a1->m_chanceSlider = v58;
Slider::setBarVisibility(v58, 0);
v59 = ((__n128 (__fastcall *)(cocos2d::CCLayer *, Slider *))a1->m_mainLayer->addChild)(
a1->m_mainLayer,
a1->m_chanceSlider);
m_chanceSlider = a1->m_chanceSlider;
v59.n128_u32[0] = 0;
v61.n128_u64[0] = 0xC2000000C2000000LL;
sub_100022980(v59, v61, &v85);
*(float32x2_t *)&v62 = sub_1000229DC(&v90, &v85, &v86);
((void (__fastcall *)(Slider *, float32x2_t *, double))m_chanceSlider->setPosition)(m_chanceSlider, &v86, v62);
v63 = 100.0;
v64 = a1->m_chancePercent / 100.0;
v65 = v64 >= 100.0;
v66 = v64 > 0.0 || v64 >= 100.0;
if ( v64 <= 0.0 )
v65 = 1;
if ( !v66 )
v63 = 0.0;
if ( v65 )
v64 = v63;
Slider::setValue(a1->m_chanceSlider, v64);
SetupRandTriggerPopup::updateChanceLabel(a1, 0);
v67.n128_f32[0] = (float)((float)(v96 * 0.5) - (float)(a1->m_width * 0.5)) + 20.0;
v68.n128_f32[0] = (float)((float)(v97 * 0.5) - (float)(a1->m_height * 0.5)) + 20.0;
sub_100022980(v67, v68, &v86);
v69.n128_u32[0] = 0;
v70.n128_u32[0] = 30.0;
sub_100022980(v69, v70, &v84);
sub_1000229DC(&v86, &v84, &v85);
sub_1000229B8(&v82, (__int64 *)&v86);
v71.n128_f32[0] = (float)((float)(v96 * 0.5) + (float)(a1->m_width * 0.5)) + -80.0;
v72.n128_f32[0] = v86.f32[1] + 30.0;
sub_100022980(v71, v72, &v81);
SetupTriggerPopup::createMultiTriggerItems(a1, v105, v106, v107);
a1->m_disableTextDelegate = 0;
}
return v4;
}