//
// SetupGradientPopup::init from 0x140420a20 to 0x140421b74 (4436 bytes)
//
// 2 xrefs:
// > EditorUI::editObjectSpecial @ 0x14011e26c
// > ??> @ 0x1406d9530
//
// 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=9
bool SetupGradientPopup::init(SetupGradientPopup *a1, GradientTriggerObject *a2, cocos2d::CCArray *a3)
{
bool result; // al
__int64 v5; // rcx
cocos2d::CCDirector *v6; // rax
_QWORD *v7; // r8
_OWORD *v8; // rcx
const char *v9; // rax
__int64 v10; // rdx
ButtonSprite *v11; // rbx
CCMenuItemSpriteExtra *v12; // rax
float v13; // xmm0_4
double ValueControlAdvanced; // xmm0_8
__int64 v15; // rcx
cocos2d::CCArray *v16; // rax
int i; // r14d
struct cocos2d::CCLabelBMFont *v18; // rdi
cocos2d::CCLabelBMFont_vtbl *v19; // rbx
const cocos2d::CCPoint *v20; // rax
float v21; // xmm0_4
unsigned int v22; // ebx
struct cocos2d::CCObject *v23; // rax
const char *v24; // rdx
int v25; // eax
double ToggleValueControl; // xmm0_8
int v27; // eax
int v28; // eax
double v29; // xmm0_8
double v30; // xmm0_8
int v31; // r9d
struct cocos2d::CCLabelBMFont *v32; // rdi
cocos2d::CCLabelBMFont *v33; // rax
float v34; // xmm0_4
__int64 v35; // rax
cocos2d::CCSprite *v36; // rbx
CCMenuItemSpriteExtra *v37; // rax
cocos2d::CCObject *v38; // rdi
float v39; // xmm0_4
const cocos2d::CCPoint *v40; // rax
cocos2d::CCObject_vtbl *v41; // rbx
struct cocos2d::CCPoint v42; // rax
struct cocos2d::CCSprite *v43; // rbx
CCMenuItemSpriteExtra *v44; // rax
cocos2d::CCObject *v45; // rdi
float v46; // xmm0_4
const cocos2d::CCPoint *v47; // rax
double v48; // xmm0_8
cocos2d::CCObject_vtbl *v49; // rbx
struct cocos2d::CCPoint v50; // rax
__int64 v51; // rcx
cocos2d::CCArray *v52; // rax
__int64 v53; // rcx
cocos2d::CCArray *v54; // r15
__int64 v55; // rcx
cocos2d::CCArray *v56; // r12
unsigned int v57; // r14d
__int64 v58; // rax
const char *v59; // rbx
ButtonSprite *v60; // rdi
CCMenuItemSpriteExtra *v61; // rbx
cocos2d::CCArray *v62; // rcx
double v63; // xmm0_8
struct cocos2d::CCPoint v64; // rax
struct cocos2d::CCPoint v65; // rax
__int64 v66; // [rsp+78h] [rbp-88h]
__int64 v67; // [rsp+78h] [rbp-88h]
__int64 v68; // [rsp+78h] [rbp-88h]
__int64 v69; // [rsp+78h] [rbp-88h]
__int64 v70; // [rsp+78h] [rbp-88h]
int v71[2]; // [rsp+80h] [rbp-80h] BYREF
CCMenuItemSpriteExtra *v72; // [rsp+88h] [rbp-78h]
CCMenuItemSpriteExtra *v73; // [rsp+90h] [rbp-70h] BYREF
float v74; // [rsp+98h] [rbp-68h]
__int128 v75; // [rsp+A0h] [rbp-60h] BYREF
__int64 v76; // [rsp+B0h] [rbp-50h]
__int64 v77; // [rsp+B8h] [rbp-48h]
char v78[8]; // [rsp+C0h] [rbp-40h] BYREF
char v79[8]; // [rsp+C8h] [rbp-38h] BYREF
char v80[8]; // [rsp+D0h] [rbp-30h] BYREF
__int128 v81; // [rsp+D8h] [rbp-28h] BYREF
__int64 v82; // [rsp+E8h] [rbp-18h]
__int64 v83; // [rsp+F0h] [rbp-10h]
result = SetupTriggerPopup::init(a1, a2, a3, 420.0, 290.0, 1);
if ( result )
{
a1->determineStartValues(a1);
v6 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v5);
cocos2d::CCDirector::getWinSize(v6);
v75 = 0;
*(_QWORD *)&v75 = sub_14003AA10(0x20u);
v76 = 21;
v77 = 31;
strcpy((char *)v75, "Setup Gradient Effect");
SetupTriggerPopup::addTitle(a1, &v75);
*(_QWORD *)v71 = &v75;
v75 = 0;
v76 = 0;
v77 = 15;
v7 = sub_14003AA10(0x170u);
*(_QWORD *)&v75 = v7;
v76 = 354;
v77 = 367;
v8 = v7;
v9 = "Creates a gradient with set colors in a given area.\n"
"U, D, L, and R must be set to a group at each side of the area.\n"
"Use Vertex Mode to set corners of the area instead.\n"
"Blending changes the gradient method.\n"
"Use ID to give a gradient a unique identifier that can be used to disable it with another of these triggers.";
v10 = 2;
do
{
*v8 = *(_OWORD *)v9;
v8[1] = *((_OWORD *)v9 + 1);
v8[2] = *((_OWORD *)v9 + 2);
v8[3] = *((_OWORD *)v9 + 3);
v8[4] = *((_OWORD *)v9 + 4);
v8[5] = *((_OWORD *)v9 + 5);
v8[6] = *((_OWORD *)v9 + 6);
v8 += 8;
*(v8 - 1) = *((_OWORD *)v9 + 7);
v9 += 128;
--v10;
}
while ( v10 );
*v8 = *(_OWORD *)v9;
v8[1] = *((_OWORD *)v9 + 1);
v8[2] = *((_OWORD *)v9 + 2);
v8[3] = *((_OWORD *)v9 + 3);
v8[4] = *((_OWORD *)v9 + 4);
v8[5] = *((_OWORD *)v9 + 5);
*((_WORD *)v8 + 48) = *((_WORD *)v9 + 48);
*((_BYTE *)v7 + 354) = 0;
v81 = 0;
v82 = 4;
v83 = 15;
strcpy((char *)&v81, "Help");
SetupTriggerPopup::addHelpButton(a1, &v81, &v75);
*(_QWORD *)v71 = operator new(0x2C0u);
v11 = ButtonSprite::ButtonSprite(*(ButtonSprite **)v71);
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);
v13 = ((float (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild_1)(
a1->m_buttonMenu,
v12);
cocos2d::CCPoint::CCPoint(v13, (float)(v74 * 0.5) - 20.0);
v73 = (CCMenuItemSpriteExtra *)&v81;
v81 = 0;
v82 = 1;
v83 = 15;
LOWORD(v81) = (unsigned __int8)asc_140518984[0];
cocos2d::CCPoint::CCPoint(0.0, -135.0);
cocos2d::CCPoint::operator+(v78, v71);
SetupTriggerPopup::createValueControlAdvanced(
(_DWORD)a1,
203,
(unsigned int)&v81,
(unsigned int)v71,
1060320051,
1,
2,
5,
0,
0,
0,
0,
0,
0,
2,
0,
*(_QWORD *)v71);
v72 = (CCMenuItemSpriteExtra *)&v81;
v81 = 0;
v82 = 1;
v83 = 15;
LOWORD(v81) = (unsigned __int8)asc_140518984[0];
cocos2d::CCPoint::CCPoint(0.0, -45.0);
cocos2d::CCPoint::operator+(v78, v71);
LOBYTE(v66) = 0;
SetupTriggerPopup::createValueControlAdvanced(
(_DWORD)a1,
204,
(unsigned int)&v81,
(unsigned int)v71,
1060320051,
1,
2,
5,
0,
0,
0,
0,
0,
0,
2,
v66);
v72 = (CCMenuItemSpriteExtra *)&v81;
v81 = 0;
v82 = 1;
v83 = 15;
LOWORD(v81) = (unsigned __int8)asc_140518984[0];
cocos2d::CCPoint::CCPoint(0.0, 45.0);
cocos2d::CCPoint::operator+(v78, v71);
LOBYTE(v67) = 0;
SetupTriggerPopup::createValueControlAdvanced(
(_DWORD)a1,
205,
(unsigned int)&v81,
(unsigned int)v71,
1060320051,
1,
2,
5,
0,
0,
0,
0,
0,
0,
2,
v67);
v72 = (CCMenuItemSpriteExtra *)&v81;
v81 = 0;
v82 = 1;
v83 = 15;
LOWORD(v81) = (unsigned __int8)asc_140518984[0];
cocos2d::CCPoint::CCPoint(0.0, 135.0);
cocos2d::CCPoint::operator+(v78, v71);
LOBYTE(v68) = 0;
ValueControlAdvanced = SetupTriggerPopup::createValueControlAdvanced(
(_DWORD)a1,
206,
(unsigned int)&v81,
(unsigned int)v71,
1060320051,
1,
2,
5,
0,
0,
0,
0,
0,
0,
2,
v68);
v16 = (cocos2d::CCArray *)cocos2d::CCArray::create(v15);
a1->m_gradientLabels = v16;
cocos2d::CCObject::retain(v16);
for ( i = 0; i < 4; ++i )
{
v18 = cocos2d::CCLabelBMFont::create(" ", "goldFont.fnt");
v19 = v18->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(*(float *)&ValueControlAdvanced, 1.0);
v19->setAnchorPoint(v18, v20);
a1->m_mainLayer->addChild_1(a1->m_mainLayer, v18);
v21 = ((float (__fastcall *)(struct cocos2d::CCLabelBMFont *))v18->setScale_0)(v18);
cocos2d::CCPoint::CCPoint(v21, (float)((float)i - 1.5) * 90.0);
ValueControlAdvanced = cocos2d::CCPoint::operator+(v78, v71);
v18->setPosition_0(v18, (const cocos2d::CCPoint *)v71);
cocos2d::CCArray::addObject(a1->m_gradientLabels, v18);
}
v22 = 0;
if ( cocos2d::CCArray::count(a1->m_gradientLabels) )
{
while ( 1 )
{
v23 = cocos2d::CCArray::objectAtIndex(a1->m_gradientLabels, v22);
if ( !v22 )
{
v24 = "U:";
goto LABEL_19;
}
if ( v22 == 1 )
{
v24 = "D:";
goto LABEL_19;
}
if ( v22 == 2 )
break;
if ( v22 == 3 )
{
v24 = (const char *)&unk_14053FEC0;
LABEL_19:
(**(void (__fastcall ***)(__int64, const char *))&v23[6].m_uAutoReleaseCount)(
(__int64)&v23[6].m_uAutoReleaseCount,
v24);
}
if ( ++v22 >= cocos2d::CCArray::count(a1->m_gradientLabels) )
goto LABEL_21;
}
v24 = "L:";
goto LABEL_19;
}
LABEL_21:
v72 = (CCMenuItemSpriteExtra *)&v75;
v76 = 11;
v77 = 15;
*(_QWORD *)&v75 = 0x4D0A786574726556LL;
*((_QWORD *)&v75 + 1) = 6644847;
cocos2d::CCPoint::CCPoint(v74 * 0.5, (float)((float)(a1->m_width * 0.5) + (float)(v74 * 0.5)) - 72.0);
ToggleValueControl = SetupTriggerPopup::createToggleValueControl(
(_DWORD)a1,
207,
(unsigned int)&v75,
v25,
0,
0,
0,
1065353216);
cocos2d::CCPoint::CCPoint(*(float *)&ToggleValueControl, (float)(v74 * 0.5) + 145.0);
v72 = (CCMenuItemSpriteExtra *)&v75;
HIWORD(v75) = 0;
v76 = 7;
v77 = 15;
qmemcpy(&v75, "Disabl", 6);
*(_QWORD *)((char *)&v75 + 6) = (unsigned __int8)aDisable[6];
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v73);
SetupTriggerPopup::createToggleValueControl((_DWORD)a1, 208, (unsigned int)&v75, v27, 0, 0, 0, 1061997773);
v72 = (CCMenuItemSpriteExtra *)&v75;
v76 = 11;
v77 = 15;
*(_QWORD *)&v75 = 0xA656C6261736944LL;
*((_QWORD *)&v75 + 1) = 7105601;
cocos2d::CCPoint::CCPoint(2.80634e20, 0.0);
cocos2d::CCPoint::operator+(v80, v71);
SetupTriggerPopup::createToggleValueControl(
(_DWORD)a1,
508,
(unsigned int)&v75,
(unsigned int)v71,
0,
0,
0,
1061997773);
v72 = (CCMenuItemSpriteExtra *)&v75;
v76 = 15;
v77 = 15;
strcpy((char *)&v75, "Preview\nOpacity");
cocos2d::CCPoint::CCPoint(a1->m_width * 0.5, (float)((float)(v74 * 0.5) + (float)(a1->m_width * 0.5)) - 72.0);
LOBYTE(v69) = 0;
v29 = SetupTriggerPopup::createValueControlAdvanced(
(_DWORD)a1,
456,
(unsigned int)&v75,
v28,
1059481190,
0,
1,
5,
0,
0,
0,
0,
0,
0,
2,
v69);
cocos2d::CCPoint::CCPoint(*(float *)&v29, (float)(v74 * 0.5) - 20.0);
v72 = (CCMenuItemSpriteExtra *)&v81;
v81 = 0;
v82 = 2;
v83 = 15;
strcpy((char *)&v81, "ID");
cocos2d::CCPoint::CCPoint(0.0, 75.0);
cocos2d::CCPoint::operator+(v79, v71);
LOBYTE(v70) = 0;
SetupTriggerPopup::createValueControlAdvanced(
(_DWORD)a1,
209,
(unsigned int)&v81,
(unsigned int)v71,
1060320051,
1,
2,
3,
1,
0,
0,
0,
0,
0,
2,
v70);
v72 = (CCMenuItemSpriteExtra *)&v81;
v81 = 0;
v82 = 0;
v83 = 15;
LOBYTE(v81) = 0;
cocos2d::CCPoint::CCPoint(0.0, 95.0);
v30 = cocos2d::CCPoint::operator+(v79, v71);
SetupTriggerPopup::createPlusButton((int)a1, 209, (int)v71, v31, &v81, 0, 0);
v32 = cocos2d::CCLabelBMFont::create((const char *)&qword_14053FEB0, "goldFont.fnt");
cocos2d::CCPoint::CCPoint(*(float *)&v30, -85.0);
cocos2d::CCPoint::operator+(v79, v71);
v32->setPosition_0(v32, (const cocos2d::CCPoint *)v71);
a1->m_mainLayer->addChild_1(a1->m_mainLayer, v32);
((void (__fastcall *)(struct cocos2d::CCLabelBMFont *))v32->setScale_0)(v32);
v33 = cocos2d::CCLabelBMFont::create(" ", (const char *)&qword_14052A4D8);
a1->m_blendingLabel = v33;
v34 = ((float (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCLabelBMFont *))a1->m_mainLayer->addChild_1)(
a1->m_mainLayer,
v33);
cocos2d::CCPoint::CCPoint(v34, 0.0);
v35 = (__int64)v32->getPosition_0(v32);
cocos2d::CCPoint::operator+(v35, v71);
a1->m_blendingLabel->setPosition_0(a1->m_blendingLabel, (const cocos2d::CCPoint *)v71);
((void (__fastcall *)(cocos2d::CCLabelBMFont *))a1->m_blendingLabel->setScale_0)(a1->m_blendingLabel);
SetupGradientPopup::updateBlendingLabel(a1);
v36 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_01_001.png");
cocos2d::CCSprite::setFlipX(v36, 1);
((void (__fastcall *)(cocos2d::CCSprite *))v36->setScale_0)(v36);
v72 = (CCMenuItemSpriteExtra *)operator new(0x208u);
v37 = CCMenuItemSpriteExtra::CCMenuItemSpriteExtra(v72);
v38 = v37;
if ( v37 )
{
if ( CCMenuItemSpriteExtra::init(
v37,
v36,
nullptr,
a1,
(cocos2d::SEL_MenuHandler *)SetupGradientPopup::onBlending) )
{
cocos2d::CCObject::autorelease(v38);
goto LABEL_26;
}
((void (__fastcall *)(cocos2d::CCObject *, __int64))v38->~CCObject)(v38, 1);
}
v38 = nullptr;
LABEL_26:
v39 = ((float (__fastcall *)(cocos2d::CCMenu *, cocos2d::CCObject *))a1->m_buttonMenu->addChild_1)(
a1->m_buttonMenu,
v38);
cocos2d::CCPoint::CCPoint(v39, 75.0);
v40 = a1->m_blendingLabel->getPosition_0(a1->m_blendingLabel);
cocos2d::CCPoint::operator+(v40, v71);
v41 = v38->__vftable;
v42 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, (const struct cocos2d::CCPoint *)&v73);
((void (__fastcall *)(cocos2d::CCObject *, struct cocos2d::CCPoint))v41[2].encodeWithCoder)(v38, v42);
v38[6].m_uUnknown = 1068708659;
v38->setTag(v38, 1);
v43 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_01_001.png");
((void (__fastcall *)(struct cocos2d::CCSprite *))v43->setScale_0)(v43);
v72 = (CCMenuItemSpriteExtra *)operator new(0x208u);
v44 = CCMenuItemSpriteExtra::CCMenuItemSpriteExtra(v72);
v45 = v44;
if ( v44 )
{
if ( CCMenuItemSpriteExtra::init(
v44,
v43,
nullptr,
a1,
(cocos2d::SEL_MenuHandler *)SetupGradientPopup::onBlending) )
{
cocos2d::CCObject::autorelease(v45);
LABEL_31:
v46 = ((float (__fastcall *)(cocos2d::CCMenu *, cocos2d::CCObject *))a1->m_buttonMenu->addChild_1)(
a1->m_buttonMenu,
v45);
cocos2d::CCPoint::CCPoint(v46, -75.0);
v47 = a1->m_blendingLabel->getPosition_0(a1->m_blendingLabel);
v48 = cocos2d::CCPoint::operator+(v47, v71);
v49 = v45->__vftable;
v50 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, (const struct cocos2d::CCPoint *)&v73);
((void (__fastcall *)(cocos2d::CCObject *, struct cocos2d::CCPoint))v49[2].encodeWithCoder)(v45, v50);
v45[6].m_uUnknown = 1068708659;
v45->setTag(v45, 0);
SetupTriggerPopup::createMultiTriggerItemsCorner(a1);
v52 = (cocos2d::CCArray *)cocos2d::CCArray::create(v51);
a1->m_layerButtons = v52;
cocos2d::CCObject::retain(v52);
v54 = (cocos2d::CCArray *)cocos2d::CCArray::create(v53);
v56 = (cocos2d::CCArray *)cocos2d::CCArray::create(v55);
v57 = 1;
while ( 1 )
{
v58 = SetupShaderEffectPopup::zLayerToString(&v81, v57);
v59 = (const char *)v58;
if ( *(_QWORD *)(v58 + 24) > 0xFu )
v59 = *(const char **)v58;
v72 = (CCMenuItemSpriteExtra *)operator new(0x2C0u);
v60 = ButtonSprite::ButtonSprite((ButtonSprite *)v72);
if ( v60 )
{
if ( ButtonSprite::init_1(
v60,
v59,
220,
0,
0.30000001,
0,
(const char *)&qword_14052A4D8,
"GJ_button_04.png",
25.0) )
{
cocos2d::CCObject::autorelease(v60);
}
else
{
((void (__fastcall *)(ButtonSprite *, __int64))v60->~ButtonSprite)(v60, 1);
v60 = nullptr;
}
}
sub_14003A830((__int64)&v81);
cocos2d::CCArray::addObject(a1->m_layerButtons, v60);
v73 = (CCMenuItemSpriteExtra *)operator new(0x208u);
v61 = CCMenuItemSpriteExtra::CCMenuItemSpriteExtra(v73);
if ( !v61 )
goto LABEL_42;
if ( !CCMenuItemSpriteExtra::init(
v61,
v60,
nullptr,
a1,
(cocos2d::SEL_MenuHandler *)SetupGradientPopup::onZLayer) )
break;
cocos2d::CCObject::autorelease(v61);
LABEL_43:
v61->setTag(v61, v57);
v60->setTag(v60, v57);
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, v61);
v62 = v56;
if ( v57 <= 7 )
v62 = v54;
cocos2d::CCArray::addObject(v62, v61);
if ( (int)++v57 > 15 )
{
SetupGradientPopup::updateZLayerButtons(a1);
v63 = cocos2d::CCPoint::CCPoint(*(float *)&v48, (float)(v74 * 0.5) - 20.0);
v64 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, (const struct cocos2d::CCPoint *)&v73);
GameToolbox::alignItemsHorisontally(v54, 8.0, v64, 0);
cocos2d::CCPoint::CCPoint(*(float *)&v63, (float)(v74 * 0.5) - 20.0);
v65 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, (const struct cocos2d::CCPoint *)&v73);
GameToolbox::alignItemsHorisontally(v56, 8.0, v65, 0);
a1->updateDefaultTriggerValues(a1);
a1->m_disableTextDelegate = 0;
return 1;
}
}
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64))v61->~CCMenuItemSpriteExtra)(v61, 1);
LABEL_42:
v61 = nullptr;
goto LABEL_43;
}
((void (__fastcall *)(cocos2d::CCObject *, __int64))v45->~CCObject)(v45, 1);
}
v45 = nullptr;
goto LABEL_31;
}
return result;
}