//
// LevelEditorLayer::getLevelString from 0x37495c to 0x374b20 (452 bytes)
//
// 1 xrefs:
// > EditorPauseLayer::saveLevel @ 0x4012fa
//
// 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
//
LevelEditorLayer *__fastcall LevelEditorLayer::getLevelString(LevelEditorLayer *this, int a2)
{
cocos2d::CCDictionary *v4; // r0
cocos2d::CCDictionary *v5; // r11
int v6; // r3
_DWORD *v7; // r3
int v8; // r9
GameObject *v9; // r4
int v10; // r10
int v11; // r3
cocos2d::CCObject *v12; // r8
int v13; // r3
GameObject **v15; // [sp+0h] [bp-24h]
int v16; // [sp+8h] [bp-1Ch]
GameObject **v17; // [sp+Ch] [bp-18h]
std::string v18; // [sp+18h] [bp-Ch] BYREF
GJBaseGameLayer::generateSpawnRemap((GJBaseGameLayer *)a2);
GJBaseGameLayer::calculateColorGroups((GJBaseGameLayer *)a2);
v4 = cocos2d::CCDictionary::create();
*(_BYTE *)(a2 + 11777) = 0;
v5 = v4;
sub_776584((int)this, (char *)&unk_939830);
LevelSettingsObject::getSaveString((LevelSettingsObject *)&v18, *(_DWORD *)(a2 + 2240));
sub_77441C(this, &v18);
sub_774008(&v18);
sub_774544((int)this, ";");
qsort(
*(void **)(*(_DWORD *)(*(_DWORD *)(a2 + 2244) + 52) + 12),
**(_DWORD **)(*(_DWORD *)(a2 + 2244) + 52),
4u,
mIDSaveSort);
v6 = *(_DWORD *)(a2 + 2244);
if ( v6 )
{
v7 = *(_DWORD **)(v6 + 52);
if ( *v7 )
{
v8 = 1;
v15 = (GameObject **)v7[3];
v17 = &v15[*v7] + 0x3FFFFFFF;
while ( v15 <= v17 )
{
v9 = *v15++;
if ( !v9 )
break;
if ( !v9->m_unk507 )
{
GameObject::updateHSVState(v9);
v10 = 0;
if ( GameObject::hasSecondaryColor(v9) )
v11 = 2;
else
v11 = 1;
v16 = v11;
do
{
GameObject::getColorKey((GameObject *)&v18, v9, ((unsigned __int8)v10 ^ 1) & 1, 1);
if ( cocos2d::CCDictionary::objectForKey(v5, &v18) )
{
v13 = *(_DWORD *)(cocos2d::CCDictionary::objectForKey(v5, &v18) + 52);
}
else
{
v12 = (cocos2d::CCObject *)operator new(0x38u);
cocos2d::CCObject::CCObject(v12);
v12[1].__vftable = (cocos2d::CCObject_vtbl *)v8;
v12->__vftable = (cocos2d::CCObject_vtbl *)&off_A45350;
cocos2d::CCObject::autorelease(v12);
cocos2d::CCDictionary::setObject((int)v5, v12);
v13 = v8++;
}
if ( (((unsigned __int8)v10 ^ 1) & 1) != 0 )
v9->m_mainColorKeyIndex = v13;
else
v9->m_detailColorKeyIndex = v13;
++v10;
sub_774008(&v18);
}
while ( v10 != v16 );
((void (__fastcall *)(std::string *, GameObject *, int))v9->getSaveString)(&v18, v9, a2);
sub_77441C(this, &v18);
sub_774544((int)this, ";");
if ( !*(_BYTE *)(a2 + 11777) )
*(_BYTE *)(a2 + 11777) = v9->m_isHighDetail;
sub_774008(&v18);
}
}
}
}
return this;
}