//
// SetupRandAdvTriggerPopup::init from 0x10038dc90 to 0x10038e5b7 (2343 bytes)
//
// 1 xrefs:
// > SetupRandAdvTriggerPopup::create @ 0x10038dc50
//
// 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)
{
bool result; // al
cocos2d::CCArray *v4; // rax
cocos2d::CCLabelBMFont *v5; // rbx
float v6; // xmm1_4
cocos2d::CCLabelBMFont_vtbl *v7; // rax
cocos2d::CCLabelBMFont *v8; // rdi
SetupRandAdvTriggerPopup *v9; // rbx
ButtonSprite *v10; // rax
CCMenuItemSpriteExtra *v11; // rax
__int64 v12; // r12
SetupRandAdvTriggerPopup *v13; // r15
const cocos2d::CCPoint *m_buttonMenu; // rbx
int v15; // eax
float v16; // xmm1_4
const char *v17; // rbx
cocos2d::CCLabelBMFont *v18; // rbx
SetupRandAdvTriggerPopup *v19; // r15
cocos2d::extension::CCScale9Sprite *v20; // rbx
CCTextInputNode *v21; // r12
__int64 v22; // rax
cocos2d::CCString *v23; // rax
const char *CString; // rbx
size_t v25; // rax
size_t v26; // r13
char *v27; // r14
size_t v28; // r15
SetupRandAdvTriggerPopup *v29; // r14
ButtonSprite *v30; // rax
CCMenuItemSpriteExtra *v31; // rbx
SetupRandAdvTriggerPopup *v32; // r12
unsigned __int64 *v33; // r15
cocos2d::extension::CCScale9Sprite *v34; // rbx
__int64 v35; // [rsp+0h] [rbp-F0h] BYREF
float v36; // [rsp+8h] [rbp-E8h] BYREF
__m128 v37; // [rsp+10h] [rbp-E0h] BYREF
TextInputDelegate *v38; // [rsp+20h] [rbp-D0h]
char v39; // [rsp+28h] [rbp-C8h] BYREF
char v40[15]; // [rsp+29h] [rbp-C7h] BYREF
void *v41; // [rsp+38h] [rbp-B8h]
_QWORD v42[2]; // [rsp+40h] [rbp-B0h] BYREF
void *__p; // [rsp+50h] [rbp-A0h]
std::string v44; // [rsp+58h] [rbp-98h] BYREF
std::string::pointer *p_data; // [rsp+70h] [rbp-80h]
_QWORD __dst[2]; // [rsp+78h] [rbp-78h] BYREF
void *v47; // [rsp+88h] [rbp-68h]
unsigned __int64 v48; // [rsp+90h] [rbp-60h] BYREF
cocos2d::CCMenu *v49; // [rsp+98h] [rbp-58h]
unsigned __int64 v50[2]; // [rsp+A0h] [rbp-50h] BYREF
SetupRandAdvTriggerPopup *v51; // [rsp+B0h] [rbp-40h]
float v52; // [rsp+BCh] [rbp-34h] BYREF
float v53; // [rsp+C0h] [rbp-30h]
bool v54; // [rsp+C7h] [rbp-29h]
double v55; // 0:xmm0_8.8
double v56; // 0:xmm0_8.8
double v57; // 0:xmm0_8.8
cocos2d::CCRect v58; // 0:xmm0_8.8,8:xmm1_8.8
cocos2d::CCRect v59; // 0:xmm0_8.8,8:xmm1_8.8
result = SetupTriggerPopup::init(a1, a2, a3, 380.0, 300.0, 1);
if ( result )
{
v54 = result;
v4 = (cocos2d::CCArray *)sub_10071F9E0(a1, a2);
a1->m_groupButtons = v4;
cocos2d::CCObject::retain(v4);
((void (__fastcall *)(SetupRandAdvTriggerPopup *))a1->determineStartValues)(a1);
cocos2d::CCDirector::sharedDirector();
*(cocos2d::CCSize *)&v55 = cocos2d::CCDirector::getWinSize((cocos2d::CCDirector *)&v52);
v5 = cocos2d::CCLabelBMFont::create_3("Advanced Random Trigger", "goldFont.fnt");
((void (__fastcall *)(SetupRandAdvTriggerPopup *, cocos2d::CCLabelBMFont *, double))a1->addChild)(a1, v5, v55);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float))v5->setScale)(v5, 0.69999999);
v6 = (float)((float)(a1->m_height * 0.5) + (float)(v53 * 0.5)) + -18.0;
v51 = a1;
sub_10028CBE0((float *)v50, v52 * 0.5, v6);
v7 = v5->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v8 = v5;
v9 = v51;
((void (__fastcall *)(cocos2d::CCLabelBMFont *, unsigned __int64 *))v7->setPosition)(v8, v50);
v10 = ButtonSprite::create_1("OK", 40, 0, 0.80000001, 1, "goldFont.fnt", "GJ_button_01.png", 30.0);
v11 = CCMenuItemSpriteExtra::create(v10, nullptr, v9, (cocos2d::SEL_MenuHandler)0x529uLL);
((void (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))v9->m_buttonMenu->addChild)(v9->m_buttonMenu, v11);
v39 = 8;
strcpy(v40, "Help");
__p = operator new(0xE0u);
v42[0] = 225;
v42[1] = 219;
strcpy(
(char *)__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.");
v12 = InfoAlertButton::create(&v39, v42, 1.0);
if ( (v42[0] & 1) != 0 )
operator delete(__p);
if ( (v39 & 1) != 0 )
operator delete(v41);
v13 = v51;
((void (__fastcall *)(cocos2d::CCMenu *, __int64))v51->m_buttonMenu->addChild)(v51->m_buttonMenu, v12);
m_buttonMenu = (const cocos2d::CCPoint *)v13->m_buttonMenu;
sub_10028CBE0(
v37.f32,
(float)((float)(v52 * 0.5) - (float)(v13->m_width * 0.5)) + 18.0,
(float)((float)(v13->m_height * 0.5) + (float)(v53 * 0.5)) + -18.0);
*(cocos2d::CCPoint *)&v56 = cocos2d::CCNode::convertToNodeSpace((cocos2d::CCNode *)v50, m_buttonMenu);
(*(void (__fastcall **)(__int64, unsigned __int64 *, double))(*(_QWORD *)v12 + 184LL))(v12, v50, v56);
p_data = &v44.__r_.__value_.__l.__data_;
v15 = (_DWORD)v13 + 632;
v38 = &v13->TextInputDelegate;
LOBYTE(v15) = 1;
while ( 1 )
{
v16 = -50.0;
LODWORD(v49) = v15;
if ( (v15 & 1) == 0 )
v16 = 50.0;
v17 = "Chance";
if ( (v15 & 1) != 0 )
v17 = "GroupID";
sub_10028CBE0((float *)&v48, (float)((float)(v52 * 0.5) + v16) + -50.0, (float)(v53 * 0.5) + 65.0);
v18 = cocos2d::CCLabelBMFont::create_3(v17, "bigFont.fnt");
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float))v18->setScale)(v18, 0.5);
sub_10028CBE0(v37.f32, 0.0, 30.0);
sub_10028CCE0((double *)v50, &v48, (unsigned __int64 *)&v37);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, unsigned __int64 *))v18->setPosition)(v18, v50);
sub_10028CBE0((float *)v50, 0.5, 0.5);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, unsigned __int64 *))v18->setAnchorPoint)(v18, v50);
v19 = v51;
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCLabelBMFont *))v51->m_mainLayer->addChild)(
v51->m_mainLayer,
v18);
v58.size = 0;
sub_10028CC00((__int64)v50, 0.0, 0.0, (__m128)0x42200000u, (__m128)0x42200000u);
*(double *)&v58.origin = sub_10028D180(&v37, v50);
v20 = cocos2d::extension::CCScale9Sprite::create_2("square02_small.png", v58);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, __int64))v20->setOpacity)(v20, 100);
sub_10028CBF0(v37.f32, 70.0, 30.0);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, __m128 *))v20->setContentSize)(v20, &v37);
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::extension::CCScale9Sprite *, __int64))v19->m_mainLayer->addChild_0)(
v19->m_mainLayer,
v20,
0xFFFFFFFFLL);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, unsigned __int64 *))v20->setPosition)(v20, &v48);
v21 = CCTextInputNode::create(60.0, 40.0, "Num", "Thonburi", 24, "bigFont.fnt");
((void (__fastcall *)(cocos2d::CCLayer *, CCTextInputNode *, __int64))v19->m_mainLayer->addChild_0)(
v19->m_mainLayer,
v21,
20);
v22 = ((__int64 (__fastcall *)(cocos2d::extension::CCScale9Sprite *))v20->getPosition)(v20);
((void (__fastcall *)(CCTextInputNode *, __int64))v21->setPosition)(v21, v22);
CCTextInputNode::setMaxLabelScale(v21, 0.60000002);
CCTextInputNode::setMaxLabelWidth(v21, 200.0);
((void (__fastcall *)(cocos2d::CCTextFieldTTF *, _QWORD))v21->m_textField->setVisible)(v21->m_textField, 0);
v21->m_maxLabelLength = 5;
v44.__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)20;
strcpy(v44.__r_.__value_.__s.__data_, "0123456789");
CCTextInputNode::setAllowedChars((std::string *)v21, &v44);
if ( (*(_BYTE *)&v44.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v44.__r_.__value_.__l.__data_);
CCTextInputNode::setLabelPlaceholderColor(v21, (cocos2d::ccColor3B)-1004936);
CCTextInputNode::setLabelPlaceholderScale(v21, 0.5);
v21->m_delegate = v38;
v21->m_numberInput = 1;
v23 = (cocos2d::CCString *)sub_1007AB580("%i", v35);
CString = cocos2d::CCString::getCString(v23);
v25 = strlen(CString);
if ( v25 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(COERCE_DOUBLE(1056964608));
v26 = v25;
if ( v25 >= 0x17 )
break;
LOBYTE(__dst[0]) = 2 * v25;
v27 = (char *)__dst + 1;
if ( v25 )
goto LABEL_20;
LABEL_21:
v27[v26] = 0;
CCTextInputNode::setString(v21, (__int64)__dst, (__m128)0x3F000000u);
if ( (__dst[0] & 1) != 0 )
operator delete(v47);
if ( ((unsigned __int8)v49 & 1) == 0 )
{
v29 = v51;
v51->m_chanceInput = v21;
((void (__fastcall *)(CCTextInputNode *, __int64))v21->setTag)(v21, 2);
v30 = ButtonSprite::create_1("Add", 50, 0, 0.69999999, 1, "goldFont.fnt", "GJ_button_04.png", 25.0);
v31 = CCMenuItemSpriteExtra::create(
v30,
nullptr,
v29,
(cocos2d::SEL_MenuHandler)(unsigned __int64)SetupRandAdvTriggerPopup::onAddChance);
((void (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))v29->m_buttonMenu->addChild)(
v29->m_buttonMenu,
v31);
v49 = v29->m_buttonMenu;
v32 = v29;
v33 = (unsigned __int64 *)((__int64 (__fastcall *)(CCTextInputNode *))v29->m_chanceInput->getPosition)(v29->m_chanceInput);
sub_10028CBE0((float *)&v48, 100.0, 0.0);
sub_10028CCE0((double *)v37.i64, v33, &v48);
*(cocos2d::CCPoint *)&v57 = cocos2d::CCNode::convertToNodeSpace(
(cocos2d::CCNode *)v50,
(const cocos2d::CCPoint *)v49);
((void (__fastcall *)(CCMenuItemSpriteExtra *, unsigned __int64 *, double))v31->setPosition)(v31, v50, v57);
v59.origin = 0;
v59.size = 0;
sub_10028CC00((__int64)v50, 0.0, 0.0, (__m128)0x42A00000u, (__m128)0x42A00000u);
v34 = cocos2d::extension::CCScale9Sprite::create_2("square02_001.png", v59);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, __int64))v34->setOpacity)(v34, 50);
sub_10028CBF0((float *)v50, 350.0, 90.0);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, unsigned __int64 *))v34->setContentSize)(v34, v50);
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::extension::CCScale9Sprite *, __int64))v32->m_mainLayer->addChild_0)(
v32->m_mainLayer,
v34,
0xFFFFFFFFLL);
sub_10028CBE0((float *)v50, v52 * 0.5, (float)(v53 * 0.5) + -10.0);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, unsigned __int64 *))v34->setPosition)(v34, v50);
sub_10028CBE0(
(float *)v50,
(float)((float)(v52 * 0.5) - (float)(v32->m_width * 0.5)) + 20.0,
(float)((float)(v53 * 0.5) - (float)(v32->m_height * 0.5)) + 20.0);
sub_10028CBE0((float *)&v48, 0.0, 30.0);
sub_10028CCE0((double *)v37.i64, v50, &v48);
sub_10028CC60(&v35, (double *)v50);
v59.origin = (cocos2d::CCPoint)COERCE_UNSIGNED_INT((float)((float)(0.5 * v29->m_width) + (float)(v52 * 0.5)) + -76.0);
sub_10028CBE0(&v36, v59.origin.x, *((float *)v50 + 1) + 30.0);
SetupTriggerPopup::createMultiTriggerItems(v29, v59.origin, 0, (cocos2d::CCPoint)1101004800LL);
SetupRandAdvTriggerPopup::updateGroupIDButtons(v29);
v29->m_disableTextDelegate = 0;
return v54;
}
v51->m_groupIDInput = v21;
((void (__fastcall *)(CCTextInputNode *, __int64))v21->setTag)(v21, 1);
v15 = 0;
}
v28 = (v25 | 7) + 1;
if ( (v25 | 7) == 0x17 )
v28 = 26;
v27 = (char *)operator new(v28);
v47 = v27;
__dst[0] = v28 + 1;
__dst[1] = v26;
LABEL_20:
memmove(v27, CString, v26);
goto LABEL_21;
}
return result;
}