//
// SetupRandAdvTriggerPopup::init from 0x10002e62c to 0x10002edf4 (1992 bytes)
//
// 1 xrefs:
// > SetupRandAdvTriggerPopup::create @ 0x10002e5dc
//
// 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 SetupRandAdvTriggerPopup::init(
SetupRandAdvTriggerPopup *a1,
RandTriggerGameObject *a2,
cocos2d::CCArray *a3)
{
_BOOL8 v4; // x0
bool v5; // w20
cocos2d::CCArray *v6; // x0
cocos2d::CCDirector *v7; // x0
cocos2d::CCLabelBMFont *v8; // x22
__n128 v9; // q0
__n128 v10; // q1
ButtonSprite *v11; // x0
CCMenuItemSpriteExtra *v12; // x0
__int64 v13; // x21
__n128 v14; // q0
cocos2d::CCMenu *m_buttonMenu; // x22
__n128 v16; // q1
__n128 v17; // q0
__n128 v18; // q1
char i; // w23
int v20; // w24
const char *v21; // x27
cocos2d::CCLabelBMFont *v22; // x27
__n128 v23; // q0
__n128 v24; // q1
double v25; // d0
__n128 v26; // q0
__n128 v27; // q1
double v28; // d0
cocos2d::extension::CCScale9Sprite *v29; // x28
CCTextInputNode *v30; // x27
__int64 v31; // x0
cocos2d::CCString *v32; // x0
char *CString; // x0
ButtonSprite *v34; // x0
CCMenuItemSpriteExtra *v35; // x21
cocos2d::CCMenu *v36; // x22
float32x2_t *v37; // x23
__n128 v38; // q0
__n128 v39; // q1
cocos2d::extension::CCScale9Sprite *v40; // x21
__n128 v41; // q0
__n128 v42; // q1
__n128 v43; // q0
__n128 v44; // q1
__n128 v45; // q0
__n128 v46; // q1
__n128 v47; // q0
__n128 v48; // q1
float v50; // s1
float v51; // s2
float v52; // s3
int v53; // [xsp+18h] [xbp-138h] BYREF
__int64 v54; // [xsp+20h] [xbp-130h] BYREF
void *v55[2]; // [xsp+28h] [xbp-128h] BYREF
char v56; // [xsp+3Fh] [xbp-111h]
void *v57[2]; // [xsp+40h] [xbp-110h] BYREF
char v58; // [xsp+57h] [xbp-F9h]
float32x2_t v59[2]; // [xsp+58h] [xbp-F8h] BYREF
float32x2_t v60[2]; // [xsp+68h] [xbp-E8h] BYREF
float32x2_t v61; // [xsp+78h] [xbp-D8h] BYREF
void *__p[2]; // [xsp+80h] [xbp-D0h] BYREF
char v63; // [xsp+97h] [xbp-B9h]
void *v64[2]; // [xsp+98h] [xbp-B8h] BYREF
char v65; // [xsp+AFh] [xbp-A1h]
float v66; // [xsp+B0h] [xbp-A0h]
float v67; // [xsp+B4h] [xbp-9Ch]
cocos2d::CCPoint v68; // 0:kr08_8.8
cocos2d::CCPoint v69; // 0:kr10_8.8
cocos2d::SEL_MenuHandler v70; // 0:x3.16
cocos2d::SEL_MenuHandler v71; // 0:x3.16
cocos2d::CCRect v72; // 0:kr20_16.16
cocos2d::CCPoint v73; // 0:s0.4,4:s1.4
cocos2d::CCPoint v74; // 0:s2.4,4:s3.4
cocos2d::CCPoint v75; // 0:s4.4,4:s5.4
cocos2d::CCRect v76; // 0:s0.4,4:s1.4,8:s2.4,12:s3.4
v4 = SetupTriggerPopup::init(a1, a2, a3, 380.0, 300.0, 1);
v5 = v4;
if ( v4 )
{
v6 = (cocos2d::CCArray *)sub_10024A15C(v4);
a1->m_groupButtons = v6;
cocos2d::CCObject::retain(v6);
((void (__fastcall *)(SetupRandAdvTriggerPopup *))a1->determineStartValues)(a1);
v7 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v7);
v8 = cocos2d::CCLabelBMFont::create_1("Advanced Random Trigger", "goldFont.fnt");
((void (__fastcall *)(SetupRandAdvTriggerPopup *, cocos2d::CCLabelBMFont *))a1->addChild)(a1, v8);
v9 = ((__n128 (__fastcall *)(cocos2d::CCLabelBMFont *, float))v8->setScale)(v8, 0.7);
v9.n128_f32[0] = v66 * 0.5;
v10.n128_f32[0] = (float)((float)(v67 * 0.5) + (float)(a1->m_height * 0.5)) + -18.0;
sub_100022980(v9, v10, v60);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float32x2_t *))v8->setPosition)(v8, v60);
v11 = ButtonSprite::create_1("OK", 40, 0, 0.8, 1, "goldFont.fnt", "GJ_button_01.png", 30.0);
v70.ptr = (void (__cdecl *)(cocos2d::CCObject *))1320;
v70.adj = 1;
v12 = CCMenuItemSpriteExtra::create(v11, nullptr, a1, v70);
((void (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild)(a1->m_buttonMenu, v12);
sub_100009900(v64, "Help");
sub_100009900(
__p,
"Triggers one of several groups randomly. Chance is how likely it is that the group is triggered. T"
"his value is then divided by the sum of the chances to calculate the chance in percentage for each group.");
v13 = InfoAlertButton::create(v64, __p, 1.0);
if ( v63 < 0 )
operator delete(__p[0]);
if ( v65 < 0 )
operator delete(v64[0]);
v14 = ((__n128 (__fastcall *)(cocos2d::CCMenu *, __int64))a1->m_buttonMenu->addChild)(a1->m_buttonMenu, v13);
m_buttonMenu = a1->m_buttonMenu;
v14.n128_f32[0] = (float)((float)(v66 * 0.5) - (float)(a1->m_width * 0.5)) + 18.0;
v16.n128_f32[0] = (float)((float)(v67 * 0.5) + (float)(a1->m_height * 0.5)) + -18.0;
sub_100022980(v14, v16, v59);
v68 = cocos2d::CCNode::convertToNodeSpace(m_buttonMenu, (const cocos2d::CCPoint *)v59);
(*(void (__fastcall **)(__int64, float32x2_t *, float, float))(*(_QWORD *)v13 + 184LL))(v13, v60, v68.x, v68.y);
for ( i = 1; ; i = 0 )
{
if ( (i & 1) != 0 )
v17.n128_f32[0] = -50.0;
else
v17.n128_f32[0] = 50.0;
if ( (i & 1) != 0 )
v20 = 0;
else
v20 = 10;
if ( (i & 1) != 0 )
v21 = "GroupID";
else
v21 = "Chance";
v17.n128_f32[0] = (float)(v17.n128_f32[0] + (float)(v66 * 0.5)) + -50.0;
v18.n128_f32[0] = (float)(v67 * 0.5) + 65.0;
sub_100022980(v17, v18, &v61);
v22 = cocos2d::CCLabelBMFont::create_1(v21, "bigFont.fnt");
v23 = ((__n128 (__fastcall *)(cocos2d::CCLabelBMFont *, float))v22->setScale)(v22, 0.5);
v23.n128_u32[0] = 0;
v24.n128_u32[0] = 30.0;
sub_100022980(v23, v24, v59);
*(float32x2_t *)&v25 = sub_1000229DC(&v61, v59, v60);
v26 = ((__n128 (__fastcall *)(cocos2d::CCLabelBMFont *, float32x2_t *, double))v22->setPosition)(v22, v60, v25);
v26.n128_u32[0] = 0.5;
v27.n128_u32[0] = 0.5;
sub_100022980(v26, v27, v60);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float32x2_t *))v22->setAnchorPoint)(v22, v60);
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCLabelBMFont *))a1->m_mainLayer->addChild)(
a1->m_mainLayer,
v22);
sub_100022990((float *)v60, 0.0, 0.0, 40.0, 40.0);
v28 = sub_100022B98(v59, (__int64)v60);
v72.origin.x = *(float *)&v28;
v72.origin.y = v50;
v72.size.width = v51;
v72.size.height = v52;
v29 = cocos2d::extension::CCScale9Sprite::create("square02_small.png", v72);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, __int64))v29->setOpacity)(v29, 100);
sub_100022988((float *)v59, 70.0, 30.0);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, float32x2_t *))v29->setContentSize)(v29, v59);
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::extension::CCScale9Sprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v29,
0xFFFFFFFFLL);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, float32x2_t *))v29->setPosition)(v29, &v61);
v30 = CCTextInputNode::create(60.0, 40.0, "Num", "Thonburi", 24, "bigFont.fnt");
((void (__fastcall *)(cocos2d::CCLayer *, CCTextInputNode *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v30,
20);
v31 = ((__int64 (__fastcall *)(cocos2d::extension::CCScale9Sprite *))v29->getPosition)(v29);
((void (__fastcall *)(CCTextInputNode *, __int64))v30->setPosition)(v30, v31);
CCTextInputNode::setMaxLabelScale(v30, 0.6);
CCTextInputNode::setMaxLabelWidth(v30, 200.0);
((void (__fastcall *)(cocos2d::CCTextFieldTTF *, _QWORD))v30->m_textField->setVisible)(v30->m_textField, 0);
v30->m_maxLabelLength = 5;
sub_100009900(v57, "0123456789");
CCTextInputNode::setAllowedChars(v30, v57);
if ( v58 < 0 )
operator delete(v57[0]);
CCTextInputNode::setLabelPlaceholderColor(v30, (cocos2d::ccColor3B)-1004936);
CCTextInputNode::setLabelPlaceholderScale(v30, 0.5);
v30->m_delegate = &a1->TextInputDelegate;
v30->m_numberInput = 1;
v32 = (cocos2d::CCString *)sub_100268F4C("%i", v20);
CString = (char *)cocos2d::CCString::getCString(v32);
sub_100009900(v55, CString);
CCTextInputNode::setString(v30, v55);
if ( v56 < 0 )
operator delete(v55[0]);
if ( (i & 1) == 0 )
break;
a1->m_groupIDInput = v30;
((void (__fastcall *)(CCTextInputNode *, __int64))v30->setTag)(v30, 1);
}
a1->m_chanceInput = v30;
((void (__fastcall *)(CCTextInputNode *, __int64))v30->setTag)(v30, 2);
v34 = ButtonSprite::create_1("Add", 50, 0, 0.7, 1, "goldFont.fnt", "GJ_button_04.png", 25.0);
v71.ptr = (void (__cdecl *)(cocos2d::CCObject *))SetupRandAdvTriggerPopup::onAddChance;
v71.adj = 0;
v35 = CCMenuItemSpriteExtra::create(v34, nullptr, a1, v71);
((void (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild)(a1->m_buttonMenu, v35);
v36 = a1->m_buttonMenu;
v37 = (float32x2_t *)((__int64 (__fastcall *)(CCTextInputNode *))a1->m_chanceInput->getPosition)(a1->m_chanceInput);
v38.n128_u32[0] = 1120403456;
v39.n128_u32[0] = 0;
sub_100022980(v38, v39, &v61);
sub_1000229DC(v37, &v61, v59);
v69 = cocos2d::CCNode::convertToNodeSpace(v36, (const cocos2d::CCPoint *)v59);
((void (__fastcall *)(CCMenuItemSpriteExtra *, float32x2_t *, float, float))v35->setPosition)(
v35,
v60,
v69.x,
v69.y);
sub_100022990((float *)v60, 0.0, 0.0, 80.0, 80.0);
v40 = cocos2d::extension::CCScale9Sprite::create("square02_001.png", v76);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, __int64))v40->setOpacity)(v40, 50);
sub_100022988((float *)v60, 350.0, 90.0);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, float32x2_t *))v40->setContentSize)(v40, v60);
v41 = ((__n128 (__fastcall *)(cocos2d::CCLayer *, cocos2d::extension::CCScale9Sprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v40,
0xFFFFFFFFLL);
v41.n128_f32[0] = v66 * 0.5;
v42.n128_f32[0] = (float)(v67 * 0.5) + -10.0;
sub_100022980(v41, v42, v60);
v43 = ((__n128 (__fastcall *)(cocos2d::extension::CCScale9Sprite *, float32x2_t *))v40->setPosition)(v40, v60);
v43.n128_f32[0] = (float)((float)(v66 * 0.5) - (float)(a1->m_width * 0.5)) + 20.0;
v44.n128_f32[0] = (float)((float)(v67 * 0.5) - (float)(a1->m_height * 0.5)) + 20.0;
sub_100022980(v43, v44, v60);
v45.n128_u32[0] = 0;
v46.n128_u32[0] = 30.0;
sub_100022980(v45, v46, &v61);
sub_1000229DC(v60, &v61, v59);
sub_1000229B8(&v54, (__int64 *)v60);
v47.n128_f32[0] = (float)((float)(v66 * 0.5) + (float)(a1->m_width * 0.5)) + -76.0;
v48.n128_f32[0] = v60[0].f32[1] + 30.0;
sub_100022980(v47, v48, &v53);
SetupTriggerPopup::createMultiTriggerItems(a1, v73, v74, v75);
SetupRandAdvTriggerPopup::updateGroupIDButtons(a1);
a1->m_disableTextDelegate = 0;
}
return v5;
}