//
// SetupRandAdvTriggerPopup::init from 0x14043d360 to 0x14043dddb (2683 bytes)
//
// 2 xrefs:
// > SetupRandAdvTriggerPopup::create @ 0x14043d31e
// > ??> @ 0x1406da184
//
// 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 SetupRandAdvTriggerPopup::init(SetupRandAdvTriggerPopup *a1, RandTriggerGameObject *a2, cocos2d::CCArray *a3)
{
bool result; // al
__int64 v5; // rcx
cocos2d::CCArray *v6; // rax
__int64 v7; // rcx
cocos2d::CCDirector *v8; // rax
struct cocos2d::CCLabelBMFont *v9; // rdi
cocos2d::CCLabelBMFont_vtbl *v10; // rbx
const cocos2d::CCPoint *v11; // rax
ButtonSprite *v12; // rbx
int v13; // r12d
CCMenuItemSpriteExtra *v14; // rax
char *v15; // rdi
__int64 v16; // rbx
struct cocos2d::CCPoint v17; // rax
int v18; // r14d
const char *v19; // rbx
float v20; // xmm0_4
struct cocos2d::CCLabelBMFont *v21; // rdi
float v22; // xmm0_4
float v23; // xmm0_4
cocos2d::CCLabelBMFont_vtbl *v24; // rbx
const cocos2d::CCPoint *v25; // rax
struct cocos2d::CCRect *v26; // rax
struct cocos2d::extension::CCScale9Sprite *v27; // rdi
__int64 v28; // rdx
const char *v29; // r9
CCTextInputNode *v30; // rsi
CCTextInputNode_vtbl *v31; // rbx
__int64 v32; // rax
cocos2d::CCString *v33; // rax
const char *CString; // rax
size_t v35; // r8
ButtonSprite *v36; // rbx
CCMenuItemSpriteExtra *v37; // rdi
float v38; // xmm0_4
const cocos2d::CCPoint *v39; // rax
CCMenuItemSpriteExtra_vtbl *v40; // rbx
struct cocos2d::CCPoint v41; // rax
struct cocos2d::CCRect *v42; // rax
struct cocos2d::extension::CCScale9Sprite *v43; // rdi
__int64 v44; // rdx
cocos2d::extension::CCScale9Sprite_vtbl *v45; // rbx
const cocos2d::CCSize *v46; // rax
float v47; // xmm0_4
cocos2d::extension::CCScale9Sprite_vtbl *v48; // rbx
const cocos2d::CCPoint *v49; // rax
double v50; // xmm0_8
cocos2d::CCPoint v51; // rax
cocos2d::CCPoint v52; // rbx
cocos2d::CCPoint v53; // rax
int v54; // [rsp+28h] [rbp-E0h]
float v55; // [rsp+58h] [rbp-B0h]
float v56; // [rsp+5Ch] [rbp-ACh]
char v57[4]; // [rsp+60h] [rbp-A8h] BYREF
cocos2d::CCPoint v58; // [rsp+70h] [rbp-98h] BYREF
cocos2d::CCSize v59; // [rsp+78h] [rbp-90h] BYREF
struct cocos2d::CCPoint v60; // [rsp+80h] [rbp-88h] BYREF
_QWORD Src[4]; // [rsp+88h] [rbp-80h] BYREF
cocos2d::CCRect v62; // [rsp+A8h] [rbp-60h] BYREF
__int64 v63; // [rsp+B8h] [rbp-50h]
__int64 v64; // [rsp+C0h] [rbp-48h]
cocos2d::CCRect v65; // [rsp+C8h] [rbp-40h] BYREF
__int64 v66; // [rsp+D8h] [rbp-30h]
__int64 v67; // [rsp+E0h] [rbp-28h]
char v68[8]; // [rsp+E8h] [rbp-20h] BYREF
cocos2d::CCPoint v69; // [rsp+F0h] [rbp-18h] BYREF
__int128 v70; // [rsp+F8h] [rbp-10h] BYREF
__int64 v71; // [rsp+108h] [rbp+0h]
__int64 v72; // [rsp+110h] [rbp+8h]
_QWORD *v73; // [rsp+118h] [rbp+10h]
cocos2d::CCRect *v74; // [rsp+200h] [rbp+F8h] BYREF
result = SetupTriggerPopup::init(a1, a2, a3, 380.0, 300.0, 1);
if ( result )
{
v6 = (cocos2d::CCArray *)cocos2d::CCArray::create(v5);
a1->m_groupButtons = v6;
cocos2d::CCObject::retain(v6);
a1->determineStartValues(a1);
v8 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v7);
cocos2d::CCDirector::getWinSize(v8);
v9 = cocos2d::CCLabelBMFont::create("Advanced Random Trigger", "goldFont.fnt");
a1->addChild_1(a1, v9);
((void (__fastcall *)(struct cocos2d::CCLabelBMFont *))v9->setScale_0)(v9);
v10 = v9->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(v56 * 0.5, v55 * 0.5);
v10->setPosition_0(v9, v11);
v74 = (cocos2d::CCRect *)operator new(0x2C0u);
v12 = ButtonSprite::ButtonSprite((ButtonSprite *)v74);
v13 = 0;
if ( v12 )
{
if ( ButtonSprite::init_1(v12, "OK", 40, 0, 0.80000001, 1, "goldFont.fnt", "GJ_button_01.png", 30.0) )
{
cocos2d::CCObject::autorelease(v12);
}
else
{
((void (__fastcall *)(ButtonSprite *, __int64))v12->~ButtonSprite)(v12, 1);
v12 = nullptr;
}
}
v14 = CCMenuItemSpriteExtra::create(v12, nullptr, a1, (cocos2d::SEL_MenuHandler *)sub_14009BEF0);
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, v14);
v74 = &v62;
v62 = 0;
v63 = 0;
v64 = 15;
v62.origin = (cocos2d::CCPoint)sub_14003AA10(0xE0u);
v63 = 219;
v64 = 223;
strcpy(
*(char **)&v62.origin,
"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.");
v65 = 0;
v66 = 4;
v67 = 15;
strcpy((char *)&v65, "Help");
v15 = InfoAlertButton::create((__int64)&v65, (__int64)&v62);
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, (cocos2d::CCNode *)v15);
v16 = *(_QWORD *)v15;
cocos2d::CCPoint::CCPoint(a1->m_width * 0.5, (float)((float)(v55 * 0.5) - (float)(a1->m_width * 0.5)) + 18.0);
v17 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, (const struct cocos2d::CCPoint *)&v59);
(*(void (__fastcall **)(char *, struct cocos2d::CCPoint))(v16 + 184))(v15, v17);
v18 = 0;
v73 = Src;
LOWORD(v74) = -21896;
do
{
while ( 1 )
{
if ( v18 )
{
v19 = (const char *)&dword_14056482C;
v13 = 10;
v20 = 50.0;
}
else
{
v19 = (const char *)&qword_1405DBAD8;
v20 = -50.0;
}
cocos2d::CCPoint::CCPoint(v20, (float)((float)(v55 * 0.5) + v20) - 50.0);
v21 = cocos2d::CCLabelBMFont::create(v19, (const char *)&qword_14052A4D8);
v22 = ((float (__fastcall *)(struct cocos2d::CCLabelBMFont *))v21->setScale_0)(v21);
cocos2d::CCPoint::CCPoint(v22, 0.0);
cocos2d::CCPoint::operator+(&v58, v68);
v23 = ((float (__fastcall *)(struct cocos2d::CCLabelBMFont *, char *))v21->setPosition_0)(v21, v68);
v24 = v21->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(v23, 0.5);
v24->setAnchorPoint(v21, v25);
a1->m_mainLayer->addChild_1(a1->m_mainLayer, v21);
cocos2d::CCRect::CCRect(&v65, 0.0, 0.0, 40.0, 40.0);
cocos2d::CCRect::CCRect(&v62, &v65);
v27 = cocos2d::extension::CCScale9Sprite::create("square02_small.png", v26);
LOBYTE(v28) = 100;
v27->setOpacity(&v27->cocos2d::CCRGBAProtocol, v28);
cocos2d::CCSize::CCSize(&v59, 70.0, 30.0);
v27->setContentSize(v27, &v59);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v27, -1);
v27->setPosition_0(v27, &v58);
v30 = CCTextInputNode::create(60.0, 40.0, "Num", v29, v54, (const char *)&qword_14052A4D8);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v30, 20);
v31 = v30->cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v32 = (__int64)v27->getPosition_0(v27);
v31->setPosition_0(v30, (const cocos2d::CCPoint *)v32);
v30->m_maxLabelScale = 0.60000002;
CCTextInputNode::refreshLabel(v30);
v30->m_maxLabelWidth = 200.0;
CCTextInputNode::refreshLabel(v30);
v30->m_textField->setVisible(v30->m_textField, 0);
v30->m_maxLabelLength = 5;
Src[1] = 14648;
Src[2] = 10;
Src[3] = 15;
Src[0] = 0x3736353433323130LL;
if ( &v30->m_allowedChars != (std::string *)Src )
sub_14003CCE0((void **)&v30->m_allowedChars, Src, 0xAu);
sub_14003A830((__int64)Src);
*(_WORD *)&v30->m_placeholderColor.r = (_WORD)v74;
v30->m_placeholderColor.b = -16;
CCTextInputNode::refreshLabel(v30);
v30->m_placeholderScale = 0.5;
CCTextInputNode::refreshLabel(v30);
v30->m_delegate = &a1->TextInputDelegate;
v30->m_numberInput = 1;
v33 = cocos2d::CCString::createWithFormat("%i", v13);
CString = cocos2d::CCString::getCString(v33);
v70 = 0;
v13 = 0;
v71 = 0;
v72 = 0;
v35 = -1;
do
++v35;
while ( CString[v35] );
sub_14003A930(&v70, CString, v35);
CCTextInputNode::setString((__int64)v30, &v70);
if ( v18 )
break;
a1->m_groupIDInput = v30;
v30->setTag(v30, 1);
v18 = 1;
}
a1->m_chanceInput = v30;
v30->setTag(v30, 2);
++v18;
}
while ( v18 < 2 );
v74 = (cocos2d::CCRect *)operator new(0x2C0u);
v36 = ButtonSprite::ButtonSprite((ButtonSprite *)v74);
if ( v36 )
{
if ( ButtonSprite::init_1(v36, "Add", 50, 0, 0.69999999, 1, "goldFont.fnt", "GJ_button_04.png", 25.0) )
{
cocos2d::CCObject::autorelease(v36);
}
else
{
((void (__fastcall *)(ButtonSprite *, __int64))v36->~ButtonSprite)(v36, 1);
v36 = nullptr;
}
}
v74 = (cocos2d::CCRect *)operator new(0x208u);
v37 = CCMenuItemSpriteExtra::CCMenuItemSpriteExtra((CCMenuItemSpriteExtra *)v74);
if ( v37 )
{
if ( CCMenuItemSpriteExtra::init(
v37,
v36,
nullptr,
a1,
(cocos2d::SEL_MenuHandler *)SetupRandAdvTriggerPopup::onAddChance) )
{
cocos2d::CCObject::autorelease(v37);
LABEL_26:
v38 = ((float (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild_1)(
a1->m_buttonMenu,
v37);
cocos2d::CCPoint::CCPoint(v38, 100.0);
v39 = a1->m_chanceInput->getPosition_0(a1->m_chanceInput);
cocos2d::CCPoint::operator+(v39, &v74);
v40 = v37->cocos2d::CCMenuItemSprite::cocos2d::CCMenuItem::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v41 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, &v60);
((void (__fastcall *)(CCMenuItemSpriteExtra *, struct cocos2d::CCPoint))v40->setPosition_0)(v37, v41);
cocos2d::CCRect::CCRect(&v62, 0.0, 0.0, 80.0, 80.0);
v43 = cocos2d::extension::CCScale9Sprite::create("square02_001.png", v42);
LOBYTE(v44) = 50;
v43->setOpacity(&v43->cocos2d::CCRGBAProtocol, v44);
v45 = v43->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v74, 350.0, 90.0);
v45->setContentSize(v43, v46);
v47 = ((float (__fastcall *)(cocos2d::CCLayer *, struct cocos2d::extension::CCScale9Sprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v43,
0xFFFFFFFFLL);
v48 = v43->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(v47, v55 * 0.5);
v48->setPosition_0(v43, v49);
v50 = cocos2d::CCPoint::CCPoint(
a1->m_width * 0.5,
(float)((float)(v55 * 0.5) - (float)(a1->m_width * 0.5)) + 20.0);
cocos2d::CCPoint::CCPoint(*(float *)&v50, 0.0);
cocos2d::CCPoint::operator+(v57, &v74);
cocos2d::CCPoint::CCPoint(v55 * 0.5, (float)((float)(a1->m_width * 0.5) + (float)(v55 * 0.5)) - 76.0);
v52 = v51;
cocos2d::CCPoint::CCPoint(&v69);
SetupTriggerPopup::createMultiTriggerItems(a1, (cocos2d::CCPoint)&v74, v53, v52);
SetupRandAdvTriggerPopup::updateGroupIDButtons(a1);
a1->m_disableTextDelegate = 0;
return 1;
}
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64))v37->~CCMenuItemSpriteExtra)(v37, 1);
}
v37 = nullptr;
goto LABEL_26;
}
return result;
}