//
// SetupShaderEffectPopup::setupShaderTrigger from 0x14044a6a0 to 0x14044adbe (1822 bytes)
//
// 2 xrefs:
// > SetupShaderEffectPopup::init @ 0x14044a44c
// > ??> @ 0x1406da730
//
// 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
void SetupShaderEffectPopup::setupShaderTrigger(SetupShaderEffectPopup *a1)
{
__int64 v2; // rcx
cocos2d::CCDirector *v3; // rax
int v4; // eax
int v5; // eax
double ToggleValueControl; // xmm0_8
__int64 v7; // rcx
cocos2d::CCArray *v8; // rax
__int64 v9; // rcx
cocos2d::CCArray *v10; // r15
__int64 v11; // rcx
cocos2d::CCArray *v12; // r12
unsigned int i; // r14d
__int64 v14; // rax
const char *v15; // rbx
ButtonSprite *v16; // rsi
CCMenuItemSpriteExtra *v17; // rbx
cocos2d::CCArray *v18; // rcx
double v19; // xmm0_8
struct cocos2d::CCPoint v20; // rax
struct cocos2d::CCPoint v21; // rax
__int64 v22; // rcx
char v23; // r14
cocos2d::CCArray *m_gameObjects; // r13
__int64 v25; // rcx
cocos2d::CCArray *v26; // rbx
struct cocos2d::CCInteger *v27; // rax
struct cocos2d::CCInteger *v28; // rax
cocos2d::ccArray *data; // r15
__int64 num; // rax
cocos2d::CCObject **arr; // r15
cocos2d::CCObject **v32; // r12
int v33; // esi
float v34; // xmm6_4
cocos2d::ccArray *v35; // rbx
__int64 v36; // rax
GameObject **v37; // rbx
GameObject **v38; // r14
float TriggerValue; // xmm0_4
int v40; // esi
char v41; // [rsp+58h] [rbp-69h]
float v42; // [rsp+60h] [rbp-61h]
__int128 v43; // [rsp+68h] [rbp-59h] BYREF
__int64 v44; // [rsp+78h] [rbp-49h]
__int64 v45; // [rsp+80h] [rbp-41h]
CCMenuItemSpriteExtra *v46; // [rsp+88h] [rbp-39h] BYREF
ButtonSprite *v47; // [rsp+90h] [rbp-31h]
__int128 v48; // [rsp+98h] [rbp-29h] BYREF
__int64 v49; // [rsp+A8h] [rbp-19h]
__int64 v50; // [rsp+B0h] [rbp-11h]
v43 = 0;
*(_QWORD *)&v43 = sub_14003AA10(0x20u);
v44 = 20;
v45 = 31;
strcpy((char *)v43, "Setup Shader Trigger");
SetupTriggerPopup::addTitle(a1, &v43);
v46 = (CCMenuItemSpriteExtra *)&v43;
v43 = 0;
v44 = 0;
v45 = 15;
*(_QWORD *)&v43 = sub_14003AA10(0xA0u);
v44 = 159;
v45 = 159;
strcpy(
(char *)v43,
"Edits how other shader effects work. They can be limited to certain layers or disabled entirely.\n"
"Disable All disables all other shader effects.");
v48 = 0;
v49 = 4;
v50 = 15;
strcpy((char *)&v48, "Help");
SetupTriggerPopup::addHelpButton(a1, &v48, &v43);
v3 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v2);
cocos2d::CCDirector::getWinSize(v3);
v46 = (CCMenuItemSpriteExtra *)&v43;
v44 = 11;
v45 = 15;
*(_QWORD *)&v43 = 0x20656C6261736944LL;
*((_QWORD *)&v43 + 1) = 7105601;
cocos2d::CCPoint::CCPoint(2.80634e20, v42 * 0.5);
SetupTriggerPopup::createToggleValueControl((_DWORD)a1, 192, (unsigned int)&v43, v4, 0, 0, 0, 1065353216);
v47 = (ButtonSprite *)&v43;
v43 = 0;
v44 = 0;
v45 = 15;
*(_QWORD *)&v43 = sub_14003AA10(0x20u);
v44 = 19;
v45 = 31;
strcpy((char *)v43, "No Player\nParticles");
cocos2d::CCPoint::CCPoint(1.0766596e10, v42 * 0.5);
ToggleValueControl = SetupTriggerPopup::createToggleValueControl(
(_DWORD)a1,
188,
(unsigned int)&v43,
v5,
0,
0,
0,
1065353216);
v8 = (cocos2d::CCArray *)cocos2d::CCArray::create(v7);
a1->m_zLayerSprites = v8;
cocos2d::CCObject::retain(v8);
v10 = (cocos2d::CCArray *)cocos2d::CCArray::create(v9);
v12 = (cocos2d::CCArray *)cocos2d::CCArray::create(v11);
for ( i = 1; (int)i <= 15; ++i )
{
v14 = SetupShaderEffectPopup::zLayerToString(&v48, i);
v15 = (const char *)v14;
if ( *(_QWORD *)(v14 + 24) > 0xFu )
v15 = *(const char **)v14;
v47 = (ButtonSprite *)operator new(0x2C0u);
v16 = ButtonSprite::ButtonSprite(v47);
if ( v16 )
{
if ( ButtonSprite::init_1(
v16,
v15,
220,
0,
0.30000001,
0,
(const char *)&qword_14052A4D8,
"GJ_button_04.png",
25.0) )
{
cocos2d::CCObject::autorelease(v16);
}
else
{
((void (__fastcall *)(ButtonSprite *, __int64))v16->~ButtonSprite)(v16, 1);
v16 = nullptr;
}
}
sub_14003A830((__int64)&v48);
cocos2d::CCArray::addObject(a1->m_zLayerSprites, v16);
v46 = (CCMenuItemSpriteExtra *)operator new(0x208u);
v17 = CCMenuItemSpriteExtra::CCMenuItemSpriteExtra(v46);
if ( v17 )
{
if ( CCMenuItemSpriteExtra::init(
v17,
v16,
nullptr,
a1,
(cocos2d::SEL_MenuHandler *)SetupShaderEffectPopup::onZLayer) )
{
cocos2d::CCObject::autorelease(v17);
goto LABEL_13;
}
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64))v17->~CCMenuItemSpriteExtra)(v17, 1);
}
v17 = nullptr;
LABEL_13:
v17->setTag(v17, i);
v16->setTag(v16, i);
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, v17);
v18 = v12;
if ( i <= 7 )
v18 = v10;
cocos2d::CCArray::addObject(v18, v17);
}
v19 = cocos2d::CCPoint::CCPoint(*(float *)&ToggleValueControl, v42 * 0.5);
v20 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, (const struct cocos2d::CCPoint *)&v46);
GameToolbox::alignItemsHorisontally(v10, 8.0, v20, 0);
cocos2d::CCPoint::CCPoint(*(float *)&v19, v42 * 0.5);
v21 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, (const struct cocos2d::CCPoint *)&v46);
GameToolbox::alignItemsHorisontally(v12, 8.0, v21, 0);
v23 = 0;
v41 = 0;
if ( a1->m_gameObject )
{
m_gameObjects = (cocos2d::CCArray *)cocos2d::CCArray::create(v22);
cocos2d::CCArray::addObject(m_gameObjects, a1->m_gameObject);
}
else
{
m_gameObjects = a1->m_gameObjects;
}
if ( !m_gameObjects )
goto LABEL_42;
if ( !cocos2d::CCArray::count(m_gameObjects) )
goto LABEL_42;
v26 = (cocos2d::CCArray *)cocos2d::CCArray::create(v25);
v27 = cocos2d::CCInteger::create(196);
cocos2d::CCArray::addObject(v26, v27);
v28 = cocos2d::CCInteger::create(197);
cocos2d::CCArray::addObject(v26, v28);
if ( !v26 )
goto LABEL_42;
data = v26->data;
num = data->num;
if ( !(_DWORD)num )
goto LABEL_42;
arr = data->arr;
v32 = &arr[num - 1];
if ( arr > v32 )
goto LABEL_42;
while ( 2 )
{
if ( *arr )
{
v33 = (int)(*arr)[1].__vftable;
v34 = -9999.0;
v35 = m_gameObjects->data;
v36 = v35->num;
if ( (_DWORD)v36 )
{
v37 = (GameObject **)v35->arr;
v38 = &v37[v36 - 1];
if ( v37 <= v38 )
{
do
{
if ( !*v37 )
break;
TriggerValue = SetupTriggerPopup::getTriggerValue(a1, v33, *v37);
if ( v34 == -9999.0 )
{
v34 = TriggerValue;
}
else if ( v34 != TriggerValue )
{
goto LABEL_33;
}
++v37;
}
while ( v37 <= v38 );
if ( v34 != -9998.0 )
goto LABEL_34;
LABEL_33:
v23 = 1;
v41 = 1;
LABEL_39:
if ( ++arr > v32 )
break;
continue;
}
LABEL_34:
v23 = v41;
}
v40 = v33 - 196;
if ( v40 )
{
if ( v40 == 1 )
a1->m_zLayerMax = (int)v34;
}
else
{
a1->m_zLayerMin = (int)v34;
}
goto LABEL_39;
}
break;
}
if ( v23 )
{
*(_QWORD *)&a1->m_zLayerMin = 0;
goto LABEL_46;
}
LABEL_42:
if ( a1->m_zLayerMin <= 0 )
a1->m_zLayerMin = 1;
if ( a1->m_zLayerMax <= 0 )
a1->m_zLayerMax = 15;
LABEL_46:
SetupShaderEffectPopup::updateZLayerButtons(a1);
}