//
// SetupEndPopup::init from 0x14041cbc0 to 0x14041d57a (2490 bytes)
//
// 2 xrefs:
// > SetupEndPopup::create @ 0x14041cb78
// > ??> @ 0x1406d93b0
//
// 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=3
bool SetupEndPopup::init(SetupEndPopup *a1, EffectGameObject *a2, cocos2d::CCArray *a3)
{
bool result; // al
__int64 v6; // rcx
cocos2d::CCDirector *v7; // rax
struct cocos2d::CCLabelBMFont *v8; // rdi
cocos2d::CCLabelBMFont_vtbl *v9; // rbx
const cocos2d::CCPoint *v10; // rax
ButtonSprite *v11; // rbx
CCMenuItemSpriteExtra *v12; // rax
_QWORD *v13; // rax
_QWORD *v14; // rcx
const char *v15; // rdx
__int64 v16; // r8
char *v17; // rdi
__int64 v18; // rbx
struct cocos2d::CCPoint v19; // rax
float v20; // xmm0_4
struct cocos2d::CCLabelBMFont *v21; // rbx
float v22; // xmm0_4
struct cocos2d::CCRect *v23; // rax
struct cocos2d::extension::CCScale9Sprite *v24; // rdi
__int64 v25; // rdx
const char *v26; // r9
CCTextInputNode *v27; // rax
CCTextInputNode *m_groupIDInput; // rcx
CCTextInputNode *v29; // rcx
std::string *p_m_allowedChars; // rcx
CCTextInputNode *v31; // rcx
CCTextInputNode *v32; // rcx
struct cocos2d::CCSprite *v33; // rbx
cocos2d::CCNode *v34; // rbx
float v35; // xmm0_4
struct cocos2d::CCSprite *v36; // rbx
cocos2d::CCNode *v37; // rbx
float v38; // xmm0_4
__int64 v39; // rax
__int64 v40; // rax
int v41; // [rsp+28h] [rbp-E0h]
float v42; // [rsp+58h] [rbp-B0h]
float v43; // [rsp+5Ch] [rbp-ACh]
__int128 v44; // [rsp+60h] [rbp-A8h] BYREF
__int64 v45; // [rsp+70h] [rbp-98h]
__int64 v46; // [rsp+78h] [rbp-90h]
cocos2d::CCPoint v47; // [rsp+80h] [rbp-88h] BYREF
__int128 *v48; // [rsp+88h] [rbp-80h] BYREF
struct cocos2d::CCPoint v49; // [rsp+90h] [rbp-78h] BYREF
_QWORD Src[4]; // [rsp+98h] [rbp-70h] BYREF
cocos2d::CCRect v51; // [rsp+B8h] [rbp-50h] BYREF
__int64 v52; // [rsp+C8h] [rbp-40h]
__int64 v53; // [rsp+D0h] [rbp-38h]
cocos2d::CCSize v54; // [rsp+D8h] [rbp-30h] BYREF
char v55[8]; // [rsp+E0h] [rbp-28h] BYREF
cocos2d::CCRect v56[4]; // [rsp+E8h] [rbp-20h] BYREF
ButtonSprite *v57; // [rsp+170h] [rbp+68h] BYREF
result = SetupTriggerPopup::init(a1, a2, a3, 300.0, 240.0, 1);
if ( result )
{
a1->determineStartValues(a1);
v7 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v6);
cocos2d::CCDirector::getWinSize(v7);
v8 = cocos2d::CCLabelBMFont::create("End Trigger", "goldFont.fnt");
a1->addChild_1(a1, v8);
((void (__fastcall *)(struct cocos2d::CCLabelBMFont *))v8->setScale_0)(v8);
v9 = v8->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(v43 * 0.5, v42 * 0.5);
v9->setPosition_0(v8, v10);
v57 = (ButtonSprite *)operator new(0x2C0u);
v11 = ButtonSprite::ButtonSprite(v57);
if ( v11 )
{
if ( ButtonSprite::init_1(v11, "OK", 40, 0, 0.80000001, 1, "goldFont.fnt", "GJ_button_01.png", 30.0) )
{
cocos2d::CCObject::autorelease(v11);
}
else
{
((void (__fastcall *)(ButtonSprite *, __int64))v11->~ButtonSprite)(v11, 1);
v11 = nullptr;
}
}
v12 = CCMenuItemSpriteExtra::create(v11, nullptr, a1, (cocos2d::SEL_MenuHandler *)sub_14009BEF0);
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, v12);
v57 = (ButtonSprite *)&v44;
v44 = 0;
v45 = 0;
v46 = 15;
v13 = sub_14003AA10(0x140u);
*(_QWORD *)&v44 = v13;
v45 = 307;
v46 = 319;
v14 = v13;
v15 = "Sets a specific object given by Group ID to be the end of the level when the game type is Clas"
"sic. This essentially spawns the endwall at a set location.\n"
"Use Reversed if gameplay is reverse at the end.\n"
"Lock Y locks the endwall to the ground instead of the group's Y position.";
v16 = 2;
do
{
*(_OWORD *)v14 = *(_OWORD *)v15;
*((_OWORD *)v14 + 1) = *((_OWORD *)v15 + 1);
*((_OWORD *)v14 + 2) = *((_OWORD *)v15 + 2);
*((_OWORD *)v14 + 3) = *((_OWORD *)v15 + 3);
*((_OWORD *)v14 + 4) = *((_OWORD *)v15 + 4);
*((_OWORD *)v14 + 5) = *((_OWORD *)v15 + 5);
*((_OWORD *)v14 + 6) = *((_OWORD *)v15 + 6);
v14 += 16;
*((_OWORD *)v14 - 1) = *((_OWORD *)v15 + 7);
v15 += 128;
--v16;
}
while ( v16 );
*(_OWORD *)v14 = *(_OWORD *)v15;
*((_OWORD *)v14 + 1) = *((_OWORD *)v15 + 1);
*((_OWORD *)v14 + 2) = *((_OWORD *)v15 + 2);
*((_WORD *)v14 + 24) = *((_WORD *)v15 + 24);
*((_BYTE *)v14 + 50) = v15[50];
*((_BYTE *)v13 + 307) = 0;
v51 = 0;
v52 = 4;
v53 = 15;
strcpy((char *)&v51, "Help");
v17 = InfoAlertButton::create((__int64)&v51, (__int64)&v44);
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, (cocos2d::CCNode *)v17);
v18 = *(_QWORD *)v17;
cocos2d::CCPoint::CCPoint(a1->m_width * 0.5, (float)((float)(v42 * 0.5) - (float)(a1->m_width * 0.5)) + 18.0);
v19 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, (const struct cocos2d::CCPoint *)&v48);
v20 = (*(float (__fastcall **)(char *, struct cocos2d::CCPoint))(v18 + 184))(v17, v19);
cocos2d::CCPoint::CCPoint(v20, v42 * 0.5);
v21 = cocos2d::CCLabelBMFont::create((const char *)&qword_1405DA090, "goldFont.fnt");
a1->addChild_1(a1, v21);
v22 = ((float (__fastcall *)(struct cocos2d::CCLabelBMFont *))v21->setScale_0)(v21);
cocos2d::CCPoint::CCPoint(v22, 0.0);
cocos2d::CCPoint::operator+(&v47, &v57);
v21->setPosition_0(v21, (const cocos2d::CCPoint *)&v57);
cocos2d::CCRect::CCRect(v56, 0.0, 0.0, 40.0, 40.0);
cocos2d::CCRect::CCRect(&v51, v56);
v24 = cocos2d::extension::CCScale9Sprite::create("square02b_small.png", v23);
LOBYTE(v25) = 100;
v24->setOpacity(&v24->cocos2d::CCRGBAProtocol, v25);
LOWORD(v57) = 0;
BYTE2(v57) = 0;
v24->setColor(&v24->cocos2d::CCRGBAProtocol, (const cocos2d::ccColor3B *)&v57);
cocos2d::CCSize::CCSize(&v54, 50.0, 30.0);
v24->setContentSize(v24, &v54);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v24, -1);
v24->setPosition_0(v24, &v47);
v27 = CCTextInputNode::create(50.0, 40.0, "Num", v26, v41, (const char *)&qword_14052A4D8);
a1->m_groupIDInput = v27;
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v27, 20);
a1->m_groupIDInput->setPosition_0(a1->m_groupIDInput, &v47);
m_groupIDInput = a1->m_groupIDInput;
m_groupIDInput->m_maxLabelScale = 0.60000002;
CCTextInputNode::refreshLabel(m_groupIDInput);
v29 = a1->m_groupIDInput;
v29->m_maxLabelWidth = 200.0;
CCTextInputNode::refreshLabel(v29);
a1->m_groupIDInput->m_textField->setVisible(a1->m_groupIDInput->m_textField, 0);
a1->m_groupIDInput->m_maxLabelLength = 6;
Src[1] = 14648;
Src[2] = 10;
Src[3] = 15;
Src[0] = 0x3736353433323130LL;
v57 = (ButtonSprite *)Src;
p_m_allowedChars = &a1->m_groupIDInput->m_allowedChars;
if ( p_m_allowedChars != (std::string *)Src )
sub_14003CCE0((void **)p_m_allowedChars, Src, 0xAu);
sub_14003A830((__int64)Src);
LOWORD(v57) = -21896;
v31 = a1->m_groupIDInput;
*(_WORD *)&v31->m_placeholderColor.r = -21896;
v31->m_placeholderColor.b = -16;
CCTextInputNode::refreshLabel(v31);
v32 = a1->m_groupIDInput;
v32->m_placeholderScale = 0.5;
CCTextInputNode::refreshLabel(v32);
a1->m_groupIDInput->m_delegate = &a1->TextInputDelegate;
a1->m_groupIDInput->m_numberInput = 1;
cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, &v49);
v33 = cocos2d::CCSprite::createWithSpriteFrameName("edit_leftBtn_001.png");
((void (__fastcall *)(struct cocos2d::CCSprite *))v33->setScale_0)(v33);
v34 = CCMenuItemSpriteExtra::create(v33, nullptr, a1, (cocos2d::SEL_MenuHandler *)SetupEndPopup::onTargetIDArrow);
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, v34);
v35 = ((float (__fastcall *)(cocos2d::CCNode *, __int64))v34->setTag)(v34, 1);
cocos2d::CCPoint::CCPoint(v35, -50.0);
cocos2d::CCPoint::operator+(&v49, &v57);
v34->setPosition_0(v34, (const cocos2d::CCPoint *)&v57);
v34[1].m_unknown5 = 0x40000000;
v36 = cocos2d::CCSprite::createWithSpriteFrameName("edit_rightBtn_001.png");
((void (__fastcall *)(struct cocos2d::CCSprite *))v36->setScale_0)(v36);
v37 = CCMenuItemSpriteExtra::create(v36, nullptr, a1, (cocos2d::SEL_MenuHandler *)SetupEndPopup::onTargetIDArrow);
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, v37);
v38 = ((float (__fastcall *)(cocos2d::CCNode *, __int64))v37->setTag)(v37, 2);
cocos2d::CCPoint::CCPoint(v38, 50.0);
cocos2d::CCPoint::operator+(&v49, &v57);
v37->setPosition_0(v37, (const cocos2d::CCPoint *)&v57);
v37[1].m_unknown5 = 0x40000000;
SetupEndPopup::updateTextInputLabel(a1);
cocos2d::CCPoint::CCPoint(a1->m_width * 0.5, (float)((float)(v42 * 0.5) - (float)(a1->m_width * 0.5)) + 20.0);
if ( a2 && a2->getType(a2) == CustomRing )
{
if ( a2->getType(a2) == CustomRing )
{
v48 = &v44;
v45 = 14;
v46 = 15;
strcpy((char *)&v44, "Multi\nActivate");
HIBYTE(v44) = 0;
cocos2d::CCPoint::CCPoint(7.4936597e31, 0.0);
cocos2d::CCPoint::operator+(v55, &v57);
SetupTriggerPopup::createToggleButton(
(_DWORD)a1,
(unsigned int)&v44,
(unsigned int)SetupEndPopup::onMultiActivate,
a1->m_multiActivate,
(__int64)&v57);
}
}
else
{
SetupTriggerPopup::createMultiTriggerItemsDefault(a1);
}
v57 = (ButtonSprite *)&v44;
v45 = 8;
v46 = 15;
v44 = 0x6465737265766552uLL;
cocos2d::CCPoint::CCPoint(0.0, (float)(v42 * 0.5) - 50.0);
SetupTriggerPopup::createToggleButton(
(_DWORD)a1,
(unsigned int)&v44,
(unsigned int)SetupEndPopup::onReversed,
a1->m_reversed,
v39);
v57 = (ButtonSprite *)&v44;
v44 = 0;
v45 = 6;
v46 = 15;
strcpy((char *)&v44, "Lock Y");
cocos2d::CCPoint::CCPoint(0.0, (float)(v42 * 0.5) + 50.0);
SetupTriggerPopup::createToggleButton(
(_DWORD)a1,
(unsigned int)&v44,
(unsigned int)SetupEndPopup::onLockY,
a1->m_lockY,
v40);
a1->m_disableTextDelegate = 0;
return 1;
}
return result;
}