//
// LevelEditorLayer::updateLevelFont from 0x660bc4 to 0x66115c (1432 bytes)
//
// 2 xrefs:
// > SelectFontLayer::onChangeFont @ 0x8c6b6c
// > ??> @ 0xa6c80
//
// 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 LevelEditorLayer::updateLevelFont(LevelEditorLayer *a1, int a2)
{
cocos2d::CCArray *m_fontIndex; // x0
cocos2d::CCArray *v5; // x23
cocos2d::CCArray *v6; // x24
unsigned int v7; // w19
cocos2d::CCArray *AllObjects; // x20
__int64 v9; // x1
int v10; // w0
cocos2d::CCTextureCache *v11; // x0
unsigned int v12; // w20
cocos2d::CCTexture2D *v13; // x21
unsigned int v14; // w1
__int64 v15; // x19
unsigned int i; // w19
unsigned int v17; // w1
LabelGameObject *v18; // x0
GameManager *v19; // x0
char *FontTexture; // x0
cocos2d::CCTextureCache *v21; // x0
cocos2d::CCTexture2D *v22; // x27
unsigned int j; // w20
__int64 v24; // x2
__int64 v25; // x19
char *v26; // x0
unsigned int *v27; // x1
int v28; // w2
char *v29; // x0
unsigned int *v30; // x19
int v31; // w1
unsigned int v32; // w19
LabelGameObject *v33; // x20
void *v34; // x0
unsigned int *v35; // x1
int v36; // w2
char *v37; // [xsp+70h] [xbp+70h] BYREF
_DWORD *v38; // [xsp+78h] [xbp+78h] BYREF
__int64 v39; // [xsp+80h] [xbp+80h] BYREF
m_fontIndex = (cocos2d::CCArray *)(unsigned int)a1->m_levelSettings->m_fontIndex;
if ( (_DWORD)m_fontIndex != a2 )
{
v5 = (cocos2d::CCArray *)cocos2d::CCArray::create(m_fontIndex);
v6 = (cocos2d::CCArray *)cocos2d::CCArray::create(v5);
v7 = 0;
AllObjects = LevelEditorLayer::getAllObjects(a1);
if ( (unsigned int)cocos2d::CCArray::count(AllObjects) )
{
do
{
v9 = cocos2d::CCArray::objectAtIndex(AllObjects, v7);
v10 = *(_DWORD *)(v9 + 1012);
if ( v10 == 914 )
{
++v7;
cocos2d::CCArray::addObject(v5, (cocos2d::CCObject *)v9);
}
else
{
++v7;
if ( v10 == 1615 )
cocos2d::CCArray::addObject(v6, (cocos2d::CCObject *)v9);
}
}
while ( v7 < (unsigned int)cocos2d::CCArray::count(AllObjects) );
}
v11 = cocos2d::CCTextureCache::sharedTextureCache();
v12 = 0;
v13 = cocos2d::CCTextureCache::addImage(v11, "bigFont.png", 0);
while ( v12 < (unsigned int)cocos2d::CCArray::count(v5) )
{
v14 = v12++;
v15 = cocos2d::CCArray::objectAtIndex(v5, v14);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v15 + 1296LL))(v15, 1);
(*(void (__fastcall **)(__int64))(*(_QWORD *)v15 + 560LL))(v15);
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v15 + 1104LL))(v15, 0);
(*(void (__fastcall **)(__int64, cocos2d::CCTexture2D *))(*(_QWORD *)v15 + 1048LL))(v15, v13);
}
for ( i = 0; i < (unsigned int)cocos2d::CCArray::count(v6); ++i )
{
v17 = i;
v18 = (LabelGameObject *)cocos2d::CCArray::objectAtIndex(v6, v17);
LabelGameObject::removeLabel(v18);
}
a1->m_textLayerT3->removeFromParent(a1->m_textLayerT3);
a1->m_textLayerT3 = nullptr;
a1->m_textBlendingLayerT3->removeFromParent(a1->m_textBlendingLayerT3);
a1->m_textBlendingLayerT3 = nullptr;
a1->m_textLayerT2->removeFromParent(a1->m_textLayerT2);
a1->m_textLayerT2 = nullptr;
a1->m_textBlendingLayerT2->removeFromParent(a1->m_textBlendingLayerT2);
a1->m_textBlendingLayerT2 = nullptr;
a1->m_textLayerT1->removeFromParent(a1->m_textLayerT1);
a1->m_textLayerT1 = nullptr;
a1->m_textBlendingLayerT1->removeFromParent(a1->m_textBlendingLayerT1);
a1->m_textBlendingLayerT1 = nullptr;
a1->m_textLayerB1->removeFromParent(a1->m_textLayerB1);
a1->m_textLayerB1 = nullptr;
a1->m_textBlendingLayerB1->removeFromParent(a1->m_textBlendingLayerB1);
a1->m_textBlendingLayerB1 = nullptr;
a1->m_textLayerB2->removeFromParent(a1->m_textLayerB2);
a1->m_textLayerB2 = nullptr;
a1->m_textBlendingLayerB2->removeFromParent(a1->m_textBlendingLayerB2);
a1->m_textBlendingLayerB2 = nullptr;
a1->m_textLayerB3->removeFromParent(a1->m_textLayerB3);
a1->m_textLayerB3 = nullptr;
a1->m_textBlendingLayerB3->removeFromParent(a1->m_textBlendingLayerB3);
a1->m_textBlendingLayerB3 = nullptr;
a1->m_textLayerB4->removeFromParent(a1->m_textLayerB4);
a1->m_textLayerB4 = nullptr;
a1->m_textBlendingLayerB4->removeFromParent(a1->m_textBlendingLayerB4);
a1->m_textBlendingLayerB4 = nullptr;
a1->m_levelSettings->m_fontIndex = a2;
v19 = GameManager::sharedState();
FontTexture = (char *)GameManager::getFontTexture(v19, a2);
sub_D153B8((int)&v37, FontTexture);
v21 = cocos2d::CCTextureCache::sharedTextureCache();
v22 = cocos2d::CCTextureCache::addImage(v21, v37, 0);
GJBaseGameLayer::createTextLayers(a1);
for ( j = 0; j < (unsigned int)cocos2d::CCArray::count(v5); ++j )
{
v25 = cocos2d::CCArray::objectAtIndex(v5, j);
(*(void (__fastcall **)(__int64, cocos2d::CCTexture2D *))(*(_QWORD *)v25 + 1048LL))(v25, v22);
sub_D18D28(&v38, v25 + 1336);
TextGameObject::updateTextObject((__int64 *)v25, (const void **)&v38, 0);
v26 = (char *)(v38 - 6);
if ( v38 - 6 != (_DWORD *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v27 = v38 - 2;
do
v28 = __ldaxr(v27);
while ( __stlxr(v28 - 1, v27) );
}
else
{
v28 = *(v38 - 2);
*(v38 - 2) = v28 - 1;
}
if ( v28 <= 0 )
operator delete(v26);
}
v24 = *(_QWORD *)v25;
*(_BYTE *)(v25 + 1133) = 1;
(*(void (__fastcall **)(__int64, _UNKNOWN **))(v24 + 1480))(v25, &off_EC3BE0);
}
v32 = 0;
while ( v32 < (unsigned int)cocos2d::CCArray::count(v6) )
{
v33 = (LabelGameObject *)cocos2d::CCArray::objectAtIndex(v6, v32);
sub_D18D28(&v39, &v33->m_labelString);
LabelGameObject::createLabel(v33, (std::string)&v39);
v34 = (void *)(v39 - 24);
if ( (__int64 *)(v39 - 24) == &qword_124B6B0 )
goto LABEL_34;
if ( &pthread_create )
{
v35 = (unsigned int *)(v39 - 8);
do
v36 = __ldaxr(v35);
while ( __stlxr(v36 - 1, v35) );
}
else
{
v36 = *(_DWORD *)(v39 - 8);
*(_DWORD *)(v39 - 8) = v36 - 1;
}
if ( v36 > 0 )
{
LABEL_34:
++v32;
}
else
{
++v32;
operator delete(v34);
}
}
v29 = v37 - 24;
if ( v37 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v30 = (unsigned int *)(v37 - 8);
do
v31 = __ldaxr(v30);
while ( __stlxr(v31 - 1, v30) );
}
else
{
v31 = *((_DWORD *)v37 - 2);
*((_DWORD *)v37 - 2) = v31 - 1;
}
if ( v31 <= 0 )
operator delete(v29);
}
}
}