//
// SetupShaderEffectPopup::setupShaderTrigger from 0x1001894fc to 0x1001899c4 (1224 bytes)
//
// 1 xrefs:
// > SetupShaderEffectPopup::init @ 0x100181e48
//
// 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
//
void __fastcall SetupShaderEffectPopup::setupShaderTrigger(SetupShaderEffectPopup *a1)
{
cocos2d::CCDirector *v2; // x0
__n128 v3; // q0
__n128 v4; // q1
__n128 v5; // q0
__n128 v6; // q1
__n128 v7; // q0
__n128 v8; // q1
__n128 v9; // q0
__n128 v10; // q1
__int64 ToggleValueControl; // x0
cocos2d::CCArray *v12; // x0
__int64 v13; // x0
cocos2d::CCArray *v14; // x21
__int64 v15; // x22
cocos2d::CCArray *v16; // x20
void **v17; // x0
ButtonSprite *v18; // x26
CCMenuItemSpriteExtra *v19; // x27
cocos2d::CCArray *v20; // x0
__n128 v21; // q0
__n128 v22; // q1
cocos2d::CCMenu *m_buttonMenu; // x22
cocos2d::CCMenu *v24; // x21
__n128 v25; // q0
__n128 v26; // q1
__int64 v27; // x0
cocos2d::CCArray *m_gameObjects; // x20
__int64 v29; // x0
__int64 v30; // x21
cocos2d::CCObject *v31; // x0
cocos2d::CCObject *v32; // x0
unsigned int *v33; // x9
__int64 v34; // x8
char v35; // w22
unsigned __int64 v36; // x23
unsigned __int64 v37; // x24
int v38; // w21
cocos2d::ccArray *data; // x9
__int64 num; // x8
float TriggerValue; // s0
GameObject **arr; // x25
unsigned __int64 v43; // x26
float v44; // s10
bool v45; // zf
cocos2d::CCPoint v46; // [xsp+8h] [xbp-118h] BYREF
void *v47[2]; // [xsp+10h] [xbp-110h] BYREF
char v48; // [xsp+27h] [xbp-F9h]
void *v49[2]; // [xsp+28h] [xbp-F8h] BYREF
char v50; // [xsp+3Fh] [xbp-E1h]
void *v51[2]; // [xsp+40h] [xbp-E0h] BYREF
char v52; // [xsp+57h] [xbp-C9h]
float v53; // [xsp+58h] [xbp-C8h]
float v54; // [xsp+5Ch] [xbp-C4h]
void *v55[2]; // [xsp+60h] [xbp-C0h] BYREF
char v56; // [xsp+77h] [xbp-A9h]
void *v57[2]; // [xsp+78h] [xbp-A8h] BYREF
char v58; // [xsp+8Fh] [xbp-91h]
void *__p[2]; // [xsp+90h] [xbp-90h] BYREF
char v60; // [xsp+A7h] [xbp-79h]
cocos2d::SEL_MenuHandler v61; // 0:x3.16
cocos2d::CCPoint v62; // 0:s1.4,4:s2.4
cocos2d::CCPoint v63; // 0:s1.4,4:s2.4
sub_100009900(__p, "Setup Shader Trigger");
SetupTriggerPopup::addTitle((__int64)a1, (__int64)__p);
if ( v60 < 0 )
operator delete(__p[0]);
sub_100009900(v57, "Help");
sub_100009900(
v55,
"Edits how other shader effects work. They can be limited to certain layers or disabled entirely.\n"
"Disable All disables all other shader effects.");
SetupTriggerPopup::addHelpButton((__int64)a1, (__int64)v57, (__int64)v55, 1.0);
if ( v56 < 0 )
operator delete(v55[0]);
if ( v58 < 0 )
operator delete(v57[0]);
v2 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v2);
sub_100009900(v51, "Disable All");
v3.n128_f32[0] = v53 * 0.5;
v4.n128_f32[0] = (float)(v54 * 0.5) + 90.0;
sub_100022980(v3, v4, v47);
v5.n128_u32[0] = 1.0;
SetupTriggerPopup::createToggleValueControl((__int64)a1, 192, (__int64)v51, (__int64 *)v47, 0, 0, 0, v5, v6);
if ( v52 < 0 )
operator delete(v51[0]);
sub_100009900(v49, "No Player\nParticles");
v7.n128_f32[0] = v53 * 0.5;
v8.n128_f32[0] = (float)(v54 * 0.5) + 50.0;
sub_100022980(v7, v8, v47);
v9.n128_u32[0] = 1.0;
ToggleValueControl = SetupTriggerPopup::createToggleValueControl(
(__int64)a1,
188,
(__int64)v49,
(__int64 *)v47,
0,
0,
0,
v9,
v10);
if ( v50 < 0 )
operator delete(v49[0]);
v12 = (cocos2d::CCArray *)sub_10024A15C(ToggleValueControl);
a1->m_zLayerSprites = v12;
cocos2d::CCObject::retain(v12);
v14 = (cocos2d::CCArray *)sub_10024A15C(v13);
v15 = 1;
v16 = (cocos2d::CCArray *)sub_10024A15C(v14);
do
{
SetupShaderEffectPopup::zLayerToString(v47, v15);
if ( v48 >= 0 )
v17 = v47;
else
v17 = (void **)v47[0];
v18 = ButtonSprite::create_1((const char *)v17, 220, 0, 0.3, 0, "bigFont.fnt", "GJ_button_04.png", 25.0);
if ( v48 < 0 )
operator delete(v47[0]);
sub_10024A2D0(a1->m_zLayerSprites, v18);
v61.ptr = (void (__cdecl *)(cocos2d::CCObject *))SetupShaderEffectPopup::onZLayer;
v61.adj = 0;
v19 = CCMenuItemSpriteExtra::create(v18, nullptr, a1, v61);
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64))v19->setTag)(v19, v15);
((void (__fastcall *)(ButtonSprite *, __int64))v18->setTag)(v18, v15);
((void (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild)(a1->m_buttonMenu, v19);
if ( (unsigned int)v15 <= 7 )
v20 = v14;
else
v20 = v16;
v21 = sub_10024A2D0(v20, v19);
v15 = (unsigned int)(v15 + 1);
}
while ( (_DWORD)v15 != 16 );
m_buttonMenu = a1->m_buttonMenu;
v21.n128_f32[0] = v53 * 0.5;
v22.n128_f32[0] = v54 * 0.5;
sub_100022980(v21, v22, &v46);
LODWORD(v62.x) = COERCE_UNSIGNED_INT(cocos2d::CCNode::convertToNodeSpace(m_buttonMenu, &v46).y);
GameToolbox::alignItemsHorisontally(v14, 8.0, v62, (bool)v47);
v24 = a1->m_buttonMenu;
v25.n128_f32[0] = v53 * 0.5;
v26.n128_f32[0] = (float)(v54 * 0.5) + -40.0;
sub_100022980(v25, v26, &v46);
LODWORD(v63.x) = COERCE_UNSIGNED_INT(cocos2d::CCNode::convertToNodeSpace(v24, &v46).y);
GameToolbox::alignItemsHorisontally(v16, 8.0, v63, (bool)v47);
if ( a1->m_gameObject )
{
m_gameObjects = (cocos2d::CCArray *)sub_10024A15C(v27);
sub_10024A2D0(m_gameObjects, a1->m_gameObject);
if ( !m_gameObjects )
goto LABEL_48;
}
else
{
m_gameObjects = a1->m_gameObjects;
if ( !m_gameObjects )
goto LABEL_48;
}
v29 = sub_10024A36C(m_gameObjects);
if ( (_DWORD)v29 )
{
v30 = sub_10024A15C(v29);
v31 = sub_10011C030(196);
sub_10024A2D0(v30, v31);
v32 = sub_10011C030(197);
sub_10024A2D0(v30, v32);
if ( v30 )
{
v33 = *(unsigned int **)(v30 + 56);
v34 = *v33;
if ( (_DWORD)v34 )
{
v35 = 0;
v36 = *((_QWORD *)v33 + 2);
v37 = v36 + 8 * v34 - 8;
do
{
if ( !*(_QWORD *)v36 )
break;
v38 = *(_DWORD *)(*(_QWORD *)v36 + 56LL);
data = m_gameObjects->data;
num = data->num;
TriggerValue = -9999.0;
if ( (_DWORD)num )
{
arr = (GameObject **)data->arr;
v43 = (unsigned __int64)&arr[num - 1];
v44 = -9999.0;
while ( *arr )
{
TriggerValue = SetupTriggerPopup::getTriggerValue(a1, v38, *arr);
if ( v44 != -9999.0 )
{
v45 = v44 == TriggerValue;
TriggerValue = v44;
if ( !v45 )
goto LABEL_43;
}
++arr;
v44 = TriggerValue;
if ( (unsigned __int64)arr > v43 )
goto LABEL_39;
}
TriggerValue = v44;
LABEL_39:
if ( TriggerValue != -9998.0 )
goto LABEL_40;
LABEL_43:
v35 = 1;
}
else
{
LABEL_40:
if ( v38 == 197 )
{
a1->m_zLayerMax = (int)TriggerValue;
}
else if ( v38 == 196 )
{
a1->m_zLayerMin = (int)TriggerValue;
}
}
v36 += 8LL;
}
while ( v36 <= v37 );
if ( (v35 & 1) != 0 )
{
*(_QWORD *)&a1->m_zLayerMin = 0;
goto LABEL_52;
}
}
}
}
LABEL_48:
if ( a1->m_zLayerMin <= 0 )
a1->m_zLayerMin = 1;
if ( a1->m_zLayerMax <= 0 )
a1->m_zLayerMax = 15;
LABEL_52:
SetupShaderEffectPopup::updateZLayerButtons(a1);
}