//
// LevelEditorLayer::updateEditorMode from 0x1402db7a0 to 0x1402dbde0 (1600 bytes)
//
// 4 xrefs:
// > EditorPauseLayer::toggleEditorColorMode @ 0x1400dd033
// > EditorUI::keyDown @ 0x140126241
// > LevelEditorLayer::init @ 0x1402d2e41
// > ??> @ 0x1406d32cc
//
// 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=1
void LevelEditorLayer::updateEditorMode(LevelEditorLayer *a1)
{
GameManager *v2; // rcx
bool GameVariable; // al
__int64 v4; // r15
int v5; // r14d
GJGroundLayer *m_groundLayer2; // rsi
cocos2d::CCArray *v7; // rax
cocos2d::CCArray *v8; // rdi
unsigned int v9; // ebx
struct cocos2d::CCObject *v10; // rax
cocos2d::CCSprite *m_ground2Sprite; // rcx
cocos2d::CCArray *v12; // rax
cocos2d::CCArray *v13; // rdi
unsigned int v14; // ebx
struct cocos2d::CCObject *v15; // rax
__int64 v16; // rdx
bool v17; // al
cocos2d::CCTextureProtocol *v18; // rcx
bool v19; // zf
cocos2d::CCTextureProtocol_vtbl *v20; // rax
__int64 v21; // rdx
GJGroundLayer *m_groundLayer; // rsi
cocos2d::CCArray *v23; // rax
cocos2d::CCArray *v24; // rdi
unsigned int v25; // ebx
struct cocos2d::CCObject *v26; // rax
cocos2d::CCSprite *v27; // rcx
cocos2d::CCArray *v28; // rax
cocos2d::CCArray *v29; // rdi
unsigned int v30; // ebx
struct cocos2d::CCObject *v31; // rax
__int64 v32; // rdx
bool v33; // al
cocos2d::CCTextureProtocol *v34; // rcx
cocos2d::CCTextureProtocol_vtbl *v35; // rax
__int64 v36; // rdx
GJMGLayer *m_middleground; // rcx
cocos2d::CCSprite *m_ground1Sprite; // rcx
cocos2d::CCArray *v39; // rdi
unsigned int i; // ebx
struct cocos2d::CCObject *v41; // rax
cocos2d::CCSprite *v42; // rcx
cocos2d::CCArray *v43; // rdi
unsigned int j; // ebx
struct cocos2d::CCObject *v45; // rax
__int64 v46; // r8
std::_Vector_val *, std::allocator *>> *>>::pointer Myfirst; // rdx
__int64 v48; // r12
_QWORD *p_Myfirst; // rcx
__int64 v50; // rax
__int64 v51; // rsi
std::_Simple_types *>::value_type v52; // r14
__int64 v53; // rbx
__int64 v54; // r15
std::_Simple_types::value_type v55; // rdi
cocos2d::CCArray *m_objects; // rdi
unsigned int k; // ebx
unsigned __int64 v58; // r8
__int64 v59; // r9
std::_Simple_types::value_type *v60; // rdx
void *v61; // [rsp+80h] [rbp+48h] BYREF
__int64 v62; // [rsp+88h] [rbp+50h] BYREF
__int16 v63; // [rsp+90h] [rbp+58h] BYREF
char v64; // [rsp+92h] [rbp+5Ah]
__int64 v65; // [rsp+98h] [rbp+60h]
if ( a1->m_alwaysPreviewMode )
goto LABEL_5;
v2 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v61 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v61);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v2 = (GameManager *)qword_1406C2ED8;
}
GameVariable = GameManager::getGameVariable(v2, "0036");
if ( GameVariable )
LABEL_5:
GameVariable = 1;
a1->m_previewMode = GameVariable;
a1->m_updateColorSprites = 1;
a1->m_background->setColor(&a1->m_background->cocos2d::CCRGBAProtocol, (const cocos2d::ccColor3B *)&word_140529B20);
v4 = 0;
v5 = 0;
LOWORD(v61) = -7711;
do
{
if ( v5 )
m_groundLayer2 = a1->m_groundLayer2;
else
m_groundLayer2 = a1->m_groundLayer;
LOWORD(v61) = -22874;
BYTE2(v61) = -90;
v7 = m_groundLayer2->m_ground1Sprite->getChildren(m_groundLayer2->m_ground1Sprite);
v8 = v7;
if ( v7 )
{
v9 = 0;
if ( cocos2d::CCArray::count(v7) )
{
do
{
v10 = cocos2d::CCArray::objectAtIndex(v8, v9);
(**(void (__fastcall ***)(__int64, void **))&v10[5].m_unknown2)((__int64)&v10[5].m_unknown2, &v61);
++v9;
}
while ( v9 < cocos2d::CCArray::count(v8) );
}
}
v63 = -22874;
v64 = -90;
m_ground2Sprite = m_groundLayer2->m_ground2Sprite;
if ( m_ground2Sprite )
{
v12 = m_ground2Sprite->getChildren(m_ground2Sprite);
v13 = v12;
if ( v12 )
{
v14 = 0;
if ( cocos2d::CCArray::count(v12) )
{
do
{
v15 = cocos2d::CCArray::objectAtIndex(v13, v14);
(**(void (__fastcall ***)(__int64, __int16 *))&v15[5].m_unknown2)((__int64)&v15[5].m_unknown2, &v63);
++v14;
}
while ( v14 < cocos2d::CCArray::count(v13) );
}
}
}
LOWORD(v62) = -7711;
BYTE2(v62) = -31;
m_groundLayer2->m_lineSprite->setColor(
&m_groundLayer2->m_lineSprite->cocos2d::CCRGBAProtocol,
(const cocos2d::ccColor3B *)&v62);
LOBYTE(v16) = -1;
m_groundLayer2->m_lineSprite->setOpacity(&m_groundLayer2->m_lineSprite->cocos2d::CCRGBAProtocol, v16);
v17 = a1->m_previewMode && LevelEditorLayer::shouldBlend(a1, 1002);
if ( m_groundLayer2->m_blendLine != v17 )
{
m_groundLayer2->m_blendLine = v17;
v18 = &m_groundLayer2->m_lineSprite->cocos2d::CCTextureProtocol;
v19 = !v17;
v20 = v18->__vftable;
if ( v19 )
{
v21 = 0x30300000001LL;
}
else
{
v65 = 0x100000302LL;
v21 = 0x100000302LL;
}
((void (__fastcall *)(cocos2d::CCTextureProtocol *, __int64))v20->setBlendFunc)(v18, v21);
}
if ( v5 == -1 )
m_groundLayer = a1->m_groundLayer;
else
m_groundLayer = a1->m_groundLayer2;
LOWORD(v61) = -22874;
BYTE2(v61) = -90;
v23 = m_groundLayer->m_ground1Sprite->getChildren(m_groundLayer->m_ground1Sprite);
v24 = v23;
if ( v23 )
{
v25 = 0;
if ( cocos2d::CCArray::count(v23) )
{
do
{
v26 = cocos2d::CCArray::objectAtIndex(v24, v25);
(**(void (__fastcall ***)(__int64, void **))&v26[5].m_unknown2)((__int64)&v26[5].m_unknown2, &v61);
++v25;
}
while ( v25 < cocos2d::CCArray::count(v24) );
}
}
v63 = -22874;
v64 = -90;
v27 = m_groundLayer->m_ground2Sprite;
if ( v27 )
{
v28 = v27->getChildren(v27);
v29 = v28;
if ( v28 )
{
v30 = 0;
if ( cocos2d::CCArray::count(v28) )
{
do
{
v31 = cocos2d::CCArray::objectAtIndex(v29, v30);
(**(void (__fastcall ***)(__int64, __int16 *))&v31[5].m_unknown2)((__int64)&v31[5].m_unknown2, &v63);
++v30;
}
while ( v30 < cocos2d::CCArray::count(v29) );
}
}
}
LOWORD(v62) = -7711;
BYTE2(v62) = -31;
m_groundLayer->m_lineSprite->setColor(
&m_groundLayer->m_lineSprite->cocos2d::CCRGBAProtocol,
(const cocos2d::ccColor3B *)&v62);
LOBYTE(v32) = -1;
m_groundLayer->m_lineSprite->setOpacity(&m_groundLayer->m_lineSprite->cocos2d::CCRGBAProtocol, v32);
v33 = a1->m_previewMode && LevelEditorLayer::shouldBlend(a1, 1002);
if ( m_groundLayer->m_blendLine != v33 )
{
m_groundLayer->m_blendLine = v33;
v34 = &m_groundLayer->m_lineSprite->cocos2d::CCTextureProtocol;
v19 = !v33;
v35 = v34->__vftable;
if ( v19 )
{
v36 = 0x30300000001LL;
}
else
{
v65 = 0x100000302LL;
v36 = 0x100000302LL;
}
((void (__fastcall *)(cocos2d::CCTextureProtocol *, __int64))v35->setBlendFunc)(v34, v36);
}
v5 += 2;
}
while ( v5 < 2 );
m_middleground = a1->m_middleground;
if ( m_middleground )
{
memset(&v61, 100, 3);
m_ground1Sprite = m_middleground->m_ground1Sprite;
if ( m_ground1Sprite )
{
v39 = m_ground1Sprite->getChildren(m_ground1Sprite);
for ( i = 0; i < cocos2d::CCArray::count(v39); ++i )
{
v41 = cocos2d::CCArray::objectAtIndex(v39, i);
(**(void (__fastcall ***)(__int64, void **))&v41[5].m_unknown2)((__int64)&v41[5].m_unknown2, &v61);
}
}
LOWORD(v61) = -26986;
BYTE2(v61) = -106;
v42 = a1->m_middleground->m_ground2Sprite;
if ( v42 )
{
v43 = v42->getChildren(v42);
for ( j = 0; j < cocos2d::CCArray::count(v43); ++j )
{
v45 = cocos2d::CCArray::objectAtIndex(v43, j);
(**(void (__fastcall ***)(__int64, void **))&v45[5].m_unknown2)((__int64)&v45[5].m_unknown2, &v61);
}
}
}
v46 = 0;
LODWORD(v61) = 0;
Myfirst = a1->m_sections._Mypair._Myval2._Myfirst;
if ( a1->m_sections._Mypair._Myval2._Mylast - Myfirst )
{
v48 = 0;
do
{
p_Myfirst = &Myfirst[v48]->_Mypair._Myval2._Myfirst;
if ( p_Myfirst )
v50 = (__int64)(p_Myfirst[1] - *p_Myfirst) >> 3;
else
LODWORD(v50) = -1;
v51 = 0;
v62 = (int)v50;
if ( (int)v50 > 0 )
{
do
{
v52 = a1->m_sections._Mypair._Myval2._Myfirst[v48]->_Mypair._Myval2._Myfirst[v51];
if ( v52 )
{
v53 = 0;
v54 = a1->m_sectionSizes._Mypair._Myval2._Myfirst[v48]->_Mypair._Myval2._Myfirst[v51];
if ( v54 > 0 )
{
do
{
v55 = v52->_Mypair._Myval2._Myfirst[v53];
((void (__fastcall *)(std::_Simple_types::value_type, std::_Vector_val *, std::allocator *>> *>>::pointer, __int64))v55->updateStartValues)(
v55,
Myfirst,
v46);
v55->resetObject(v55);
++v53;
}
while ( v53 < v54 );
}
v4 = 0;
}
++v51;
}
while ( v51 < v62 );
LODWORD(v46) = (_DWORD)v61;
}
v46 = (unsigned int)(v46 + 1);
LODWORD(v61) = v46;
++v48;
Myfirst = a1->m_sections._Mypair._Myval2._Myfirst;
}
while ( (int)v46 < (unsigned __int64)(a1->m_sections._Mypair._Myval2._Mylast - Myfirst) );
}
if ( !a1->m_previewMode )
{
m_objects = a1->m_objects;
for ( k = 0; k < cocos2d::CCArray::count(m_objects); ++k )
BYTE1(cocos2d::CCArray::objectAtIndex(m_objects, k)[20].m_uUnknown) = 1;
}
v58 = 0;
v59 = 10000;
do
{
a1->m_toggledGroupStates._Mypair._Myval2._Myfirst[v4] = 0;
v60 = &a1->m_toggledGroups._Myvec._Mypair._Myval2._Myfirst[v58 >> 5];
*v60 &= ~(1 << (v58++ & 0x1F));
++v4;
--v59;
}
while ( v59 );
LevelEditorLayer::updatePreviewParticles(a1);
}