//
// LevelEditorLayer::updateEditorMode from 0x100358ef4 to 0x100359194 (672 bytes)
//
// 3 xrefs:
// > LevelEditorLayer::init @ 0x100357738
// > EditorPauseLayer::toggleEditorColorMode @ 0x10039e258
// > EditorUI::keyDown @ 0x1003fa23c
//
// 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 LevelEditorLayer::updateEditorMode(LevelEditorLayer *a1)
{
int *p_m_activeGradients; // x21
bool m_alwaysPreviewMode; // w8
char v4; // w20
bool GameVariable; // w0
GameManager *v6; // x0
char v7; // w26
__int64 v8; // x8
GJGroundLayer *v9; // x20
cocos2d::CCSprite *m_lineSprite; // x0
_BOOL4 v11; // w1
GJMGLayer *m_middleground; // x0
std::__vector_base *, std::allocator *>> *, std::allocator *, std::allocator *>> *>>::pointer end; // x8
std::__vector_base *, std::allocator *>> *, std::allocator *, std::allocator *>> *>>::pointer begin; // x9
unsigned __int64 v15; // x22
std::vector *, std::allocator *>> *v16; // x10
unsigned __int64 v17; // x10
__int64 v18; // x23
__int64 v19; // x24
std::vector *v20; // x25
__int64 v21; // x8
unsigned __int64 v22; // x26
__int64 v23; // x27
GameObject *v24; // x20
cocos2d::CCArray *m_objects; // x20
unsigned int v26; // w21
unsigned __int64 i; // x8
__int16 v28; // [xsp+Ch] [xbp-54h] BYREF
char v29; // [xsp+Eh] [xbp-52h]
p_m_activeGradients = &a1->m_activeGradients;
m_alwaysPreviewMode = a1->m_alwaysPreviewMode;
v4 = 1;
GameVariable = 1;
if ( !m_alwaysPreviewMode )
{
v6 = GameManager::sharedState();
GameVariable = GameManager::getGameVariable(v6, "0036");
}
*((_BYTE *)p_m_activeGradients + 1745) = GameVariable;
*((_BYTE *)p_m_activeGradients + 1744) = 1;
((void (__fastcall *)(cocos2d::CCSprite *, void *))a1->m_background->setColor)(a1->m_background, &unk_100645676);
do
{
v7 = v4;
if ( (v4 & 1) != 0 )
v8 = 3848;
else
v8 = 3856;
v9 = *(GJGroundLayer **)((char *)&a1->GJBaseGameLayer::cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable
+ v8);
GJGroundLayer::updateGround01Color(v9, (cocos2d::ccColor3B)-5855578);
GJGroundLayer::updateGround02Color(v9, (cocos2d::ccColor3B)-5855578);
m_lineSprite = v9->m_lineSprite;
v29 = -31;
v28 = -7711;
((void (__fastcall *)(cocos2d::CCSprite *, __int16 *))m_lineSprite->setColor)(m_lineSprite, &v28);
((void (__fastcall *)(cocos2d::CCSprite *, __int64))v9->m_lineSprite->setOpacity)(v9->m_lineSprite, 255);
if ( *((_BYTE *)p_m_activeGradients + 1745) == 1 )
v11 = (*((unsigned __int8 *)a1->m_blendingColors.__begin_ + 125) >> 2) & 1;
else
LOBYTE(v11) = 0;
GJGroundLayer::updateLineBlend(v9, v11);
v4 = 0;
}
while ( (v7 & 1) != 0 );
m_middleground = a1->m_middleground;
if ( m_middleground )
{
GJMGLayer::updateGroundColor(m_middleground, (cocos2d::ccColor3B)6579300, 1);
GJMGLayer::updateGroundColor(a1->m_middleground, (cocos2d::ccColor3B)-6908266, 0);
}
end = a1->m_sections.__end_;
begin = a1->m_sections.__begin_;
if ( end != begin )
{
v15 = 0;
do
{
v16 = begin[v15];
if ( v16 )
{
v17 = (char *)v16->__end_ - (char *)v16->__begin_;
if ( (int)(v17 >> 3) >= 1 )
{
v18 = 0;
v19 = (v17 >> 3) & 0x7FFFFFFF;
do
{
v20 = a1->m_sections.__begin_[v15]->__begin_[v18];
if ( v20 )
{
v21 = (unsigned int)a1->m_sectionSizes.__begin_[v15]->__begin_[v18];
if ( (int)v21 >= 1 )
{
v22 = 0;
v23 = 8 * v21;
do
{
v24 = v20->__begin_[v22 / 8];
((void (__fastcall *)(GameObject *))v24->updateStartValues)(v24);
((void (__fastcall *)(GameObject *))v24->resetObject)(v24);
v22 += 8LL;
}
while ( v23 != v22 );
}
}
++v18;
}
while ( v18 != v19 );
end = a1->m_sections.__end_;
begin = a1->m_sections.__begin_;
}
}
++v15;
}
while ( v15 < end - begin );
}
if ( (*((_BYTE *)p_m_activeGradients + 1745) & 1) == 0 )
{
m_objects = a1->m_objects;
if ( (unsigned int)sub_10024A36C((__int64)m_objects) )
{
v26 = 0;
do
*(_BYTE *)(sub_10024A388((__int64)m_objects, v26++) + 1149) = 1;
while ( v26 < (unsigned int)sub_10024A36C((__int64)m_objects) );
}
}
for ( i = 0; i != 10000; ++i )
{
a1->m_toggledGroupStates.__begin_[i] = 0;
*(_QWORD *)&a1->m_toggledGroups.__begin_[(i >> 3) & 0x1FFFFFFFFFFFFFF8LL] &= ~(1LL << i);
}
LevelEditorLayer::updatePreviewParticles(a1);
}