//
// SetupRandTriggerPopup::init from 0x504d90 to 0x505638 (2216 bytes)
//
// 1 xrefs:
// > SetupRandTriggerPopup::create @ 0x50580e
//
// 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 SetupRandTriggerPopup::init(SetupRandTriggerPopup *a1, EffectGameObject *a2, cocos2d::CCArray *a3)
{
_BOOL4 v4; // r10
cocos2d::CCDirector *v5; // r0
cocos2d::CCLabelBMFont *v6; // r6
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r9
ButtonSprite *v8; // r0
CCMenuItemSpriteExtra *v9; // r0
CCMenuItemSpriteExtra *v10; // r7
cocos2d::CCMenu *m_buttonMenu; // r9
void (__fastcall *v12)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r8
int v13; // r5
float v14; // s17
int v15; // r9
void (*v16)(SetupRandTriggerPopup *, cocos2d::CCObject *); // r3
int v17; // r8
cocos2d::CCString *v18; // r0
cocos2d::CCLabelBMFont *v19; // r11
cocos2d::CCNode *v20; // r5
int (__fastcall *getTag)(const cocos2d::CCObject *__hidden); // r3
CCTextInputNode *v22; // r5
CCTextInputNode_vtbl *v23; // r3
cocos2d::CCSprite *v24; // r11
CCMenuItemSpriteExtra *v25; // r11
cocos2d::CCSprite *v26; // r11
CCMenuItemSpriteExtra *v27; // r11
cocos2d::CCLabelBMFont *v28; // r6
void (__fastcall *setAnchorPoint)(cocos2d::CCLabelBMFont *__hidden, const cocos2d::CCPoint *); // r7
cocos2d::CCNode *v30; // r6
void (__fastcall *v31)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r9
const char *v32; // r2
CCTextInputNode *v33; // r0
CCTextInputNode *m_chanceInput; // r9
int v35; // r0
CCTextInputNode *v36; // r6
CCTextInputNode *v37; // r3
Slider *v38; // r0
Slider *m_chanceSlider; // r5
void (__fastcall *v40)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r9
float v41; // s15
cocos2d::CCPoint v42; // r1
float v44; // r2
float v45; // r3
float v46; // r2
float v47; // r3
_BYTE v48[12]; // [sp+0h] [bp-BCh]
float v49; // [sp+10h] [bp-ACh]
void (__fastcall *v50)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // [sp+14h] [bp-A8h]
cocos2d::CCString *v51; // [sp+1Ch] [bp-A0h]
void (__fastcall *v52)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // [sp+34h] [bp-88h]
void (__fastcall *v53)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // [sp+34h] [bp-88h]
cocos2d::ccColor3B v54; // [sp+3Ch] [bp-80h]
cocos2d::ccColor3B v55; // [sp+40h] [bp-7Ch]
cocos2d::CCSize v56; // [sp+44h] [bp-78h] BYREF
cocos2d::CCPoint v57; // [sp+4Ch] [bp-70h] BYREF
cocos2d::CCPoint v58; // [sp+54h] [bp-68h] BYREF
cocos2d::CCSize v59; // [sp+5Ch] [bp-60h] BYREF
cocos2d::CCPoint v60; // [sp+64h] [bp-58h] BYREF
cocos2d::CCPoint v61; // [sp+6Ch] [bp-50h] BYREF
cocos2d::CCSize v62; // [sp+74h] [bp-48h] BYREF
cocos2d::CCPoint v63; // [sp+7Ch] [bp-40h] BYREF
cocos2d::CCPoint v64; // [sp+84h] [bp-38h] BYREF
int v65; // [sp+8Ch] [bp-30h]
int v66; // [sp+90h] [bp-2Ch]
cocos2d::CCRect v67; // [sp+94h] [bp-28h] BYREF
cocos2d::CCRect v68; // [sp+A4h] [bp-18h] BYREF
cocos2d::CCPoint v69; // 0:kr20_8.8
cocos2d::CCRect v70; // 0:kr00_16.16
cocos2d::CCRect v71; // 0:kr10_16.16
v4 = SetupTriggerPopup::init(a1, a2, a3, 320.0, 280.0, 1);
if ( v4 )
{
a1->determineStartValues(a1);
v5 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(&v56, v5);
v6 = cocos2d::CCLabelBMFont::create();
a1->m_mainLayer->addChild(a1->m_mainLayer, v6);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, int))v6->setScale)(v6, 1060320051);
setPosition = v6->setPosition;
cocos2d::CCPoint::CCPoint(
&v68.origin,
v56.width * 0.5,
(float)((float)(a1->m_height * 0.5) + (float)(v56.height * 0.5)) - 18.0);
setPosition(v6, &v68.origin);
v8 = ButtonSprite::create(
(ButtonSprite *)"OK",
(const char *)&word_28,
0,
0.8,
1,
"goldFont.fnt",
"GJ_button_01.png",
COERCE_CONST_CHAR_(30.0),
v49);
v65 = 660;
v66 = 1;
v9 = CCMenuItemSpriteExtra::create(v8, nullptr, (cocos2d::SEL_MenuHandler)((unsigned int)a1 | 0x29400000000LL));
a1->m_buttonMenu->addChild(a1->m_buttonMenu, v9);
sub_776584((int)&v67, "Help");
sub_776584(
(int)&v68,
"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.");
v10 = InfoAlertButton::create((int)&v67, (int)&v68, 1065353216);
sub_774008(&v68);
sub_774008(&v67);
a1->m_buttonMenu->addChild(a1->m_buttonMenu, v10);
m_buttonMenu = a1->m_buttonMenu;
v12 = v10->setPosition;
cocos2d::CCPoint::CCPoint(
&v67.origin,
(float)((float)(v56.width * 0.5) - (float)(a1->m_width * 0.5)) + 18.0,
(float)((float)(a1->m_height * 0.5) + (float)(v56.height * 0.5)) - 18.0);
cocos2d::CCNode::convertToNodeSpace(&v68.origin, m_buttonMenu, &v67.origin);
v13 = 0;
v12(v10, &v68.origin);
cocos2d::CCPoint::CCPoint(&v57, v56.width * 0.5, (float)(v56.height * 0.5) + 50.0);
do
{
cocos2d::CCPoint::CCPoint(&v60, &v57);
v61.y = 0.0;
if ( v13 )
{
v14 = v60.x + 75.0;
v15 = 5;
v16 = SetupRandTriggerPopup::onTargetID2Arrow;
}
else
{
v14 = v60.x - 75.0;
v15 = 3;
v16 = SetupRandTriggerPopup::onTargetIDArrow;
}
v17 = v13 + 1;
LODWORD(v61.x) = v16;
v60.x = v14;
v18 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"Group ID %i",
(const char *)(v13 + 1));
cocos2d::CCString::getCString(v18);
v19 = cocos2d::CCLabelBMFont::create();
a1->m_mainLayer->addChild(a1->m_mainLayer, v19);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, int))v19->setScale)(v19, 1056964608);
v50 = v19->setPosition;
cocos2d::CCPoint::CCPoint(&v67.origin, 0.0, 34.0);
cocos2d::CCPoint::operator+(&v68, &v60, &v67);
v50(v19, &v68.origin);
cocos2d::CCRect::CCRect(&v67, 0.0, 0.0, 40.0, 40.0);
cocos2d::CCRect::CCRect(&v68, &v67);
v70.origin.x = v44;
v70.origin.y = v45;
v70.size = *(cocos2d::CCSize *)v48;
v20 = (cocos2d::CCNode *)cocos2d::extension::CCScale9Sprite::create(
(cocos2d::extension::CCScale9Sprite *)"square02b_small.png",
(const char *)&v68,
v70);
((void (__fastcall *)(cocos2d::CCNode *, int))v20->__vftable[1].~CCNode_0)(v20, 100);
getTag = v20->__vftable[1].getTag;
LOWORD(v68.origin.x) = 0;
BYTE2(v68.origin.x) = 0;
((void (__fastcall *)(cocos2d::CCNode *, cocos2d::CCRect *))getTag)(v20, &v68);
cocos2d::CCSize::CCSize(&v62, 50.0, 30.0);
v20->setContentSize(v20, &v62);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v20, -1);
v20->setPosition(v20, &v60);
v22 = CCTextInputNode::create(50.0, 40.0, "Num", "Thonburi");
((void (__fastcall *)(cocos2d::CCLayer *, CCTextInputNode *, int, void (__fastcall *)(cocos2d::CCNode *__hidden, cocos2d::CCNode *, int), int *, const char *))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v22,
20,
a1->m_mainLayer->addChild_0,
&dword_18,
"bigFont.fnt");
v22->setPosition(v22, &v60);
CCTextInputNode::setMaxLabelScale(v22, 0.6);
CCTextInputNode::setMaxLabelWidth(v22, 200.0);
v22->m_textField->setVisible(v22->m_textField, 0);
v22->m_maxLabelLength = 6;
sub_776584((int)&v68, "0123456789");
CCTextInputNode::setAllowedChars((int)v22, (int)&v68);
sub_774008(&v68);
*(_WORD *)&v54.r = -21896;
v54.b = -16;
CCTextInputNode::setLabelPlaceholderColor(v22, v54);
CCTextInputNode::setLabelPlaceholderScale(v22, 0.5);
v22->m_delegate = &a1->TextInputDelegate;
v23 = v22->cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v22->m_numberInput = 1;
v23->setTag(v22, v15);
cocos2d::CCNode::convertToNodeSpace(&v63, a1->m_buttonMenu, &v60);
v24 = cocos2d::CCSprite::createWithSpriteFrameName("edit_leftBtn_001.png");
((void (__fastcall *)(cocos2d::CCSprite *, int))v24->setScale)(v24, 1066192077);
v25 = CCMenuItemSpriteExtra::create(
v24,
nullptr,
(cocos2d::SEL_MenuHandler)__PAIR64__(LODWORD(v61.x), (unsigned int)a1));
a1->m_buttonMenu->addChild(a1->m_buttonMenu, v25);
v25->setTag(v25, 1);
v52 = v25->setPosition;
cocos2d::CCPoint::CCPoint(&v64, -50.0, 0.0);
cocos2d::CCPoint::operator+(&v68, &v63, &v64);
v52(v25, &v68.origin);
CCMenuItemSpriteExtra::setSizeMult(v25, 2.0);
v26 = cocos2d::CCSprite::createWithSpriteFrameName("edit_rightBtn_001.png");
((void (__fastcall *)(cocos2d::CCSprite *, int))v26->setScale)(v26, 1066192077);
v27 = CCMenuItemSpriteExtra::create(
v26,
nullptr,
(cocos2d::SEL_MenuHandler)__PAIR64__(LODWORD(v61.x), (unsigned int)a1));
a1->m_buttonMenu->addChild(a1->m_buttonMenu, v27);
v27->setTag(v27, 2);
v53 = v27->setPosition;
cocos2d::CCPoint::CCPoint(&v64, 50.0, 0.0);
cocos2d::CCPoint::operator+(&v68, &v63, &v64);
v53(v27, &v68.origin);
CCMenuItemSpriteExtra::setSizeMult(v27, 2.0);
if ( v17 == 1 )
a1->m_groupID1Input = v22;
else
a1->m_groupID2Input = v22;
v13 = 1;
}
while ( v17 != 2 );
SetupRandTriggerPopup::updateTextInputLabel(a1);
SetupRandTriggerPopup::updateTextInputLabel2(a1);
cocos2d::CCPoint::CCPoint(&v58, v56.width * 0.5, (float)(v56.height * 0.5) - 10.0);
v28 = cocos2d::CCLabelBMFont::create();
((void (__fastcall *)(cocos2d::CCLabelBMFont *, int))v28->setScale)(v28, 1060320051);
v28->setPosition(v28, &v58);
setAnchorPoint = v28->setAnchorPoint;
cocos2d::CCPoint::CCPoint(&v68.origin, 1.0, 0.5);
setAnchorPoint(v28, &v68.origin);
a1->m_mainLayer->addChild(a1->m_mainLayer, v28);
cocos2d::CCRect::CCRect(&v67, 0.0, 0.0, 40.0, 40.0);
cocos2d::CCRect::CCRect(&v68, &v67);
v71.origin.x = v46;
v71.origin.y = v47;
v71.size = *(cocos2d::CCSize *)v48;
v30 = (cocos2d::CCNode *)cocos2d::extension::CCScale9Sprite::create(
(cocos2d::extension::CCScale9Sprite *)"square02_small.png",
(const char *)&v68,
v71);
((void (__fastcall *)(cocos2d::CCNode *, int))v30->__vftable[1].~CCNode_0)(v30, 100);
cocos2d::CCSize::CCSize(&v59, 70.0, 30.0);
v30->setContentSize(v30, &v59);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v30, -1);
v31 = v30->setPosition;
cocos2d::CCPoint::CCPoint(&v64, 45.0, 0.0);
cocos2d::CCPoint::operator+(&v68, &v58, &v64);
v31(v30, &v68.origin);
if ( a1->m_chancePercent == -99999.0 )
v32 = "Mixed";
else
v32 = "Num";
*(_DWORD *)&v48[4] = "bigFont.fnt";
v33 = CCTextInputNode::create(50.0, 40.0, v32, "Thonburi");
a1->m_chanceInput = v33;
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v33, 20);
m_chanceInput = a1->m_chanceInput;
v51 = (cocos2d::CCString *)m_chanceInput->setPosition;
v35 = (int)v30->getPosition(v30);
((void (__fastcall *)(CCTextInputNode *, int))v51)(m_chanceInput, v35);
CCTextInputNode::setMaxLabelScale(a1->m_chanceInput, 0.6);
CCTextInputNode::setMaxLabelWidth(a1->m_chanceInput, 200.0);
a1->m_chanceInput->m_textField->setVisible(a1->m_chanceInput->m_textField, 0);
v36 = a1->m_chanceInput;
v36->m_maxLabelLength = 7;
sub_776584((int)&v68, "0123456789.");
CCTextInputNode::setAllowedChars((int)v36, (int)&v68);
sub_774008(&v68);
*(_WORD *)&v55.r = -21896;
v55.b = -16;
CCTextInputNode::setLabelPlaceholderColor(a1->m_chanceInput, v55);
CCTextInputNode::setLabelPlaceholderScale(a1->m_chanceInput, 0.5);
v37 = a1->m_chanceInput;
v37->m_numberInput = 1;
v37->m_delegate = &a1->TextInputDelegate;
a1->m_chanceInput->setTag(a1->m_chanceInput, 4);
v68.origin.y = 0.0;
LODWORD(v68.origin.x) = SetupRandTriggerPopup::sliderChanged;
v38 = (Slider *)Slider::create(a1, (unsigned int)SetupRandTriggerPopup::sliderChanged, 0, 0.8);
a1->m_chanceSlider = v38;
Slider::setBarVisibility(v38, 0);
a1->m_mainLayer->addChild(a1->m_mainLayer, a1->m_chanceSlider);
m_chanceSlider = a1->m_chanceSlider;
v40 = m_chanceSlider->setPosition;
cocos2d::CCPoint::CCPoint(&v63, 0.0, -32.0);
cocos2d::CCPoint::operator+(&v64, &v58, &v63);
v40(m_chanceSlider, &v64);
v41 = a1->m_chancePercent / 100.0;
if ( v41 >= 100.0 )
{
v41 = 100.0;
}
else if ( v41 <= 0.0 )
{
v41 = 0.0;
}
Slider::setValue(a1->m_chanceSlider, v41);
SetupRandTriggerPopup::updateChanceLabel(a1, 0);
cocos2d::CCPoint::CCPoint(
&v60,
(float)((float)(v56.width * 0.5) - (float)(a1->m_width * 0.5)) + 20.0,
(float)((float)(v56.height * 0.5) - (float)(a1->m_height * 0.5)) + 20.0);
cocos2d::CCPoint::CCPoint(&v61, 0.0, 30.0);
cocos2d::CCPoint::operator+(&v62, &v60, &v61);
cocos2d::CCPoint::CCPoint(&v64, &v60);
cocos2d::CCPoint::CCPoint(&v63, (float)((float)(a1->m_width * 0.5) + (float)(v56.width * 0.5)) - 80.0, v60.y + 30.0);
LODWORD(v42.x) = &v62;
LODWORD(v42.y) = &v64;
LODWORD(v69.x) = &v63;
LODWORD(v69.y) = &dword_18;
SetupTriggerPopup::createMultiTriggerItems(a1, v42, v69, *(cocos2d::CCPoint *)&v48[4]);
a1->m_disableTextDelegate = 0;
}
return v4;
}