//
// SetupShaderEffectPopup::setupShaderTrigger from 0x551f18 to 0x5522b4 (924 bytes)
//
// 1 xrefs:
// > SetupShaderEffectPopup::init @ 0x557260
//
// 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 SetupShaderEffectPopup::setupShaderTrigger(SetupShaderEffectPopup *a1)
{
cocos2d::CCDirector *v2; // r0
int v3; // r7
cocos2d::CCArray *v4; // r0
cocos2d::CCArray *v5; // r0
cocos2d::CCArray *v6; // r0
cocos2d::CCArray *v7; // r9
cocos2d::CCArray *v8; // r8
ButtonSprite *v9; // r11
CCMenuItemSpriteExtra *v10; // r10
cocos2d::CCArray *v12; // r0
cocos2d::CCMenu *m_buttonMenu; // r7
cocos2d::CCMenu *v14; // r7
cocos2d::CCArray *v15; // r0
cocos2d::CCArray *m_gameObjects; // r6
cocos2d::CCArray *v17; // r0
cocos2d::CCArray *v18; // r5
int v19; // r1
cocos2d::CCObject *v20; // r0
int v21; // r1
cocos2d::CCObject *v22; // r0
int v23; // r3
cocos2d::ccArray *data; // r2
cocos2d::CCObject **arr; // r7
int v26; // r8
cocos2d::CCObject **v27; // r5
int v28; // r3
int v29; // t1
cocos2d::ccArray *v30; // r2
int v31; // r10
int v32; // r3
cocos2d::CCObject **v33; // r2
float v34; // s16
unsigned int v35; // r9
GameObject **v36; // r11
float v37; // s15
GameObject *v38; // r2
GameObject *v39; // t1
float TriggerValue; // r0
bool v41; // [sp+0h] [bp-3Ch]
float v42; // [sp+10h] [bp-2Ch]
cocos2d::CCSize v43; // [sp+24h] [bp-18h] BYREF
cocos2d::CCPoint v44; // [sp+2Ch] [bp-10h] BYREF
cocos2d::CCPoint v45; // [sp+34h] [bp-8h] BYREF
cocos2d::CCPoint v46; // [sp+3Ch] [bp+0h] BYREF
sub_776584((int)&v46, "Setup Shader Trigger");
SetupTriggerPopup::addTitle((int)a1);
sub_774008(&v46);
sub_776584((int)&v45, "Help");
sub_776584(
(int)&v46,
"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((int)a1, (int)&v45, (int)&v46, 1065353216);
sub_774008(&v46);
sub_774008(&v45);
v2 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(&v43, v2);
sub_776584((int)&v45, "Disable All");
cocos2d::CCPoint::CCPoint(&v46, v43.width * 0.5, (float)(v43.height * 0.5) + 90.0);
SetupTriggerPopup::createToggleValueControl(a1, 192, (int)&v45, &v46, 0, 0, 0, 1.0);
sub_774008(&v45);
sub_776584((int)&v45, "No Player\nParticles");
cocos2d::CCPoint::CCPoint(&v46, v43.width * 0.5, (float)(v43.height * 0.5) + 50.0);
SetupTriggerPopup::createToggleValueControl(a1, 188, (int)&v45, &v46, 0, 0, 0, 1.0);
v3 = 1;
v4 = (cocos2d::CCArray *)sub_774008(&v45);
v5 = (cocos2d::CCArray *)cocos2d::CCArray::create(v4);
a1->m_zLayerSprites = v5;
cocos2d::CCObject::retain(v5);
v7 = (cocos2d::CCArray *)cocos2d::CCArray::create(v6);
v8 = (cocos2d::CCArray *)cocos2d::CCArray::create(v7);
do
{
SetupShaderEffectPopup::zLayerToString((SetupShaderEffectPopup *)&v45, v3);
v9 = ButtonSprite::create(
(ButtonSprite *)LODWORD(v45.x),
(const char *)off_DC,
0,
0.3,
0,
"bigFont.fnt",
"GJ_button_04.png",
(const char *)0x41C80000,
v42);
sub_774008(&v45);
cocos2d::CCArray::addObject(a1->m_zLayerSprites, v9);
LODWORD(v46.x) = SetupShaderEffectPopup::onZLayer;
v46.y = 0.0;
v10 = CCMenuItemSpriteExtra::create(
v9,
nullptr,
(cocos2d::SEL_MenuHandler)__PAIR64__(SetupShaderEffectPopup::onZLayer, (unsigned int)a1));
v10->setTag(v10, v3);
v9->setTag(v9, v3);
a1->m_buttonMenu->addChild(a1->m_buttonMenu, v10);
if ( v3++ <= 7 )
v12 = v7;
else
v12 = v8;
cocos2d::CCArray::addObject(v12, v10);
}
while ( v3 != 16 );
m_buttonMenu = a1->m_buttonMenu;
cocos2d::CCPoint::CCPoint(&v44, v43.width * 0.5, v43.height * 0.5);
cocos2d::CCNode::convertToNodeSpace(&v45, m_buttonMenu, &v44);
GameToolbox::alignItemsHorisontally(v7, 8.0, (cocos2d::CCPoint)(unsigned int)&v45, 0);
v14 = a1->m_buttonMenu;
cocos2d::CCPoint::CCPoint(&v44, v43.width * 0.5, (float)(v43.height * 0.5) - 40.0);
cocos2d::CCNode::convertToNodeSpace(&v45, v14, &v44);
GameToolbox::alignItemsHorisontally(v8, 8.0, (cocos2d::CCPoint)(unsigned int)&v45, v41);
if ( a1->m_gameObject )
{
m_gameObjects = (cocos2d::CCArray *)cocos2d::CCArray::create(v15);
cocos2d::CCArray::addObject(m_gameObjects, a1->m_gameObject);
}
else
{
m_gameObjects = a1->m_gameObjects;
}
if ( m_gameObjects )
{
v17 = (cocos2d::CCArray *)cocos2d::CCArray::count(m_gameObjects);
if ( v17 )
{
v18 = (cocos2d::CCArray *)cocos2d::CCArray::create(v17);
v20 = cocos2d::CCInteger::create((cocos2d::CCInteger *)&dword_C4, v19);
cocos2d::CCArray::addObject(v18, v20);
v22 = cocos2d::CCInteger::create((cocos2d::CCInteger *)((char *)&dword_C4 + 1), v21);
cocos2d::CCArray::addObject(v18, v22);
if ( v18 )
{
data = v18->data;
if ( data->num )
{
arr = data->arr;
v26 = 0;
v27 = &arr[data->num] + 0x3FFFFFFF;
while ( arr <= v27 )
{
v29 = (int)*arr++;
v28 = v29;
if ( !v29 )
break;
v30 = m_gameObjects->data;
v31 = *(int *)((char *)&dword_34 + v28);
if ( v30->num )
{
v32 = v30->num + 0x40000000;
v33 = v30->arr;
v34 = -9999.0;
v35 = (unsigned int)&v33[v32 - 1];
v36 = (GameObject **)v33;
while ( (unsigned int)v36 <= v35 )
{
v39 = *v36++;
v38 = v39;
if ( !v39 )
break;
TriggerValue = SetupTriggerPopup::getTriggerValue(a1, v31, v38);
if ( v34 == -9999.0 )
{
v34 = TriggerValue;
}
else if ( v34 != TriggerValue )
{
goto LABEL_28;
}
}
v37 = v34;
if ( v34 != -9998.0 )
goto LABEL_32;
LABEL_28:
v26 = 1;
}
else
{
v37 = -9999.0;
LABEL_32:
if ( v31 == 196 )
{
a1->m_zLayerMin = (int)v37;
}
else if ( v31 == 197 )
{
a1->m_zLayerMax = (int)v37;
}
}
}
if ( v26 )
{
v23 = 0;
a1->m_zLayerMin = 0;
goto LABEL_16;
}
}
}
}
}
if ( a1->m_zLayerMin <= 0 )
a1->m_zLayerMin = 1;
if ( a1->m_zLayerMax <= 0 )
{
v23 = 15;
LABEL_16:
a1->m_zLayerMax = v23;
}
SetupShaderEffectPopup::updateZLayerButtons(a1);
}