//
// LevelEditorLayer::updateLevelFont from 0x1000f1140 to 0x1000f166d (1325 bytes)
//
// 1 xrefs:
// > SelectFontLayer::onChangeFont @ 0x10029a5c2
//
// 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
//
// local variable allocation has failed, the output may be wrong!
void __fastcall LevelEditorLayer::updateLevelFont(LevelEditorLayer *a1, int a2)
{
__int128 v2; // xmm0
__int64 v3; // r14
__int64 v4; // rbx
cocos2d::CCArray *m_objects; // r12
unsigned int i; // r13d
__int64 v7; // rax
int v8; // ecx
__int64 v9; // rdi
cocos2d::CCTextureCache *v10; // rax
unsigned int v11; // r12d
cocos2d::CCTexture2D *j; // r13
__int64 v13; // r15
unsigned int v14; // r12d
LabelGameObject *v15; // rax
LevelEditorLayer *v16; // r15
LevelSettingsObject *m_levelSettings; // rax
GameManager *v18; // rax
const char *FontTexture; // r15
size_t v20; // rax
size_t v21; // r12
char *v22; // r13
size_t v23; // r15
cocos2d::CCTextureCache *v24; // rax
const char *v25; // rsi
cocos2d::CCTexture2D *v26; // r12
unsigned int k; // r15d
__int64 v28; // r13
unsigned int m; // r14d
__int64 v30; // rax
__int64 v31; // r12
__int128 v32; // [rsp+0h] [rbp-90h] BYREF
void *v33; // [rsp+10h] [rbp-80h]
__int128 v34; // [rsp+20h] [rbp-70h] BYREF
void *__p; // [rsp+30h] [rbp-60h]
LevelEditorLayer *v36; // [rsp+40h] [rbp-50h]
_QWORD __dst[2]; // [rsp+48h] [rbp-48h] BYREF
void *v38; // [rsp+58h] [rbp-38h]
const char *v39; // [rsp+60h] [rbp-30h]
if ( a1->m_levelSettings->m_fontIndex == a2 )
return;
LODWORD(v39) = a2;
v3 = sub_10071F9E0(a1, *(_QWORD *)&a2);
v4 = sub_10071F9E0(a1, *(_QWORD *)&a2);
v36 = a1;
m_objects = a1->m_objects;
if ( (unsigned int)sub_100720070(m_objects) )
{
for ( i = 0; i < (unsigned int)sub_100720070(m_objects); ++i )
{
v7 = sub_1007200C0(m_objects, i);
v8 = *(_DWORD *)(v7 + 1028);
v9 = v3;
if ( v8 != 914 )
{
if ( v8 != 1615 )
continue;
v9 = v4;
}
sub_10071FCD0(v9, v7);
}
}
v10 = cocos2d::CCTextureCache::sharedTextureCache();
v11 = 0;
for ( j = cocos2d::CCTextureCache::addImage(v10, "bigFont.png", 0); v11 < (unsigned int)sub_100720070(v3); ++v11 )
{
v13 = sub_1007200C0(v3, v11);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v13 + 1296LL))(v13, 1);
(*(void (__fastcall **)(__int64))(*(_QWORD *)v13 + 560LL))(v13);
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v13 + 1104LL))(v13, 0);
(*(void (__fastcall **)(__int64, cocos2d::CCTexture2D *))(*(_QWORD *)v13 + 1048LL))(v13, j);
}
if ( (unsigned int)sub_100720070(v4) )
{
v14 = 0;
do
{
v15 = (LabelGameObject *)sub_1007200C0(v4, v14);
LabelGameObject::removeLabel(v15);
++v14;
}
while ( v14 < (unsigned int)sub_100720070(v4) );
}
v16 = v36;
((void (__fastcall *)(cocos2d::CCSpriteBatchNode *))v36->m_textLayerT3->removeFromParent)(v36->m_textLayerT3);
v36->m_textLayerT3 = nullptr;
((void (__fastcall *)(cocos2d::CCSpriteBatchNode *))v16->m_textBlendingLayerT3->removeFromParent)(v16->m_textBlendingLayerT3);
v16->m_textBlendingLayerT3 = nullptr;
((void (__fastcall *)(cocos2d::CCSpriteBatchNode *))v16->m_textLayerT2->removeFromParent)(v16->m_textLayerT2);
v16->m_textLayerT2 = nullptr;
((void (__fastcall *)(cocos2d::CCSpriteBatchNode *))v16->m_textBlendingLayerT2->removeFromParent)(v16->m_textBlendingLayerT2);
v16->m_textBlendingLayerT2 = nullptr;
((void (__fastcall *)(cocos2d::CCSpriteBatchNode *))v16->m_textLayerT1->removeFromParent)(v16->m_textLayerT1);
v16->m_textLayerT1 = nullptr;
((void (__fastcall *)(cocos2d::CCSpriteBatchNode *))v16->m_textBlendingLayerT1->removeFromParent)(v16->m_textBlendingLayerT1);
v16->m_textBlendingLayerT1 = nullptr;
((void (__fastcall *)(cocos2d::CCSpriteBatchNode *))v16->m_textLayerB1->removeFromParent)(v16->m_textLayerB1);
v16->m_textLayerB1 = nullptr;
((void (__fastcall *)(cocos2d::CCSpriteBatchNode *))v16->m_textBlendingLayerB1->removeFromParent)(v16->m_textBlendingLayerB1);
v16->m_textBlendingLayerB1 = nullptr;
((void (__fastcall *)(cocos2d::CCSpriteBatchNode *))v16->m_textLayerB2->removeFromParent)(v16->m_textLayerB2);
v16->m_textLayerB2 = nullptr;
((void (__fastcall *)(cocos2d::CCSpriteBatchNode *))v16->m_textBlendingLayerB2->removeFromParent)(v16->m_textBlendingLayerB2);
v16->m_textBlendingLayerB2 = nullptr;
((void (__fastcall *)(cocos2d::CCSpriteBatchNode *))v16->m_textLayerB3->removeFromParent)(v16->m_textLayerB3);
v16->m_textLayerB3 = nullptr;
((void (__fastcall *)(cocos2d::CCSpriteBatchNode *))v16->m_textBlendingLayerB3->removeFromParent)(v16->m_textBlendingLayerB3);
v16->m_textBlendingLayerB3 = nullptr;
((void (__fastcall *)(cocos2d::CCSpriteBatchNode *))v16->m_textLayerB4->removeFromParent)(v16->m_textLayerB4);
v16->m_textLayerB4 = nullptr;
((void (__fastcall *)(cocos2d::CCSpriteBatchNode *))v16->m_textBlendingLayerB4->removeFromParent)(v16->m_textBlendingLayerB4);
v16->m_textBlendingLayerB4 = nullptr;
m_levelSettings = v16->m_levelSettings;
LODWORD(v16) = (_DWORD)v39;
m_levelSettings->m_fontIndex = (int)v39;
v18 = GameManager::sharedState();
FontTexture = GameManager::getFontTexture(v18, (int)v16);
v20 = strlen(FontTexture);
if ( v20 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(*(double *)&v2);
v21 = v20;
if ( v20 >= 0x17 )
{
v39 = FontTexture;
v23 = 26;
if ( (v20 | 7) != 0x17 )
v23 = (v20 | 7) + 1;
v22 = (char *)operator new(v23);
v38 = v22;
__dst[0] = v23 + 1;
FontTexture = v39;
__dst[1] = v21;
}
else
{
LOBYTE(__dst[0]) = 2 * v20;
v22 = (char *)__dst + 1;
if ( !v20 )
goto LABEL_22;
}
memmove(v22, FontTexture, v21);
LABEL_22:
v22[v21] = 0;
v24 = cocos2d::CCTextureCache::sharedTextureCache();
if ( (__dst[0] & 1) != 0 )
v25 = (const char *)v38;
else
v25 = (char *)__dst + 1;
v26 = cocos2d::CCTextureCache::addImage(v24, v25, 0);
GJBaseGameLayer::createTextLayers(v36);
for ( k = 0; k < (unsigned int)sub_100720070(v3); ++k )
{
v28 = sub_1007200C0(v3, k);
(*(void (__fastcall **)(__int64, cocos2d::CCTexture2D *))(*(_QWORD *)v28 + 1048LL))(v28, v26);
if ( (*(_BYTE *)(v28 + 1352) & 1) != 0 )
{
sub_100006B70(&v34, *(const void **)(v28 + 1368), *(_QWORD *)(v28 + 1360), *(double *)&v2);
}
else
{
__p = *(void **)(v28 + 1368);
v2 = *(_OWORD *)(v28 + 1352);
v34 = v2;
}
TextGameObject::updateTextObject(v28, &v34, 0);
if ( (v34 & 1) != 0 )
operator delete(__p);
*(_BYTE *)(v28 + 1149) = 1;
(*(void (__fastcall **)(__int64, void *))(*(_QWORD *)v28 + 1480LL))(v28, &unk_100816673);
}
for ( m = 0; m < (unsigned int)sub_100720070(v4); ++m )
{
v30 = sub_1007200C0(v4, m);
v31 = v30;
if ( (*(_BYTE *)(v30 + 1856) & 1) != 0 )
{
sub_100006B70(&v32, *(const void **)(v30 + 1872), *(_QWORD *)(v30 + 1864), *(double *)&v2);
}
else
{
v33 = *(void **)(v30 + 1872);
v2 = *(_OWORD *)(v30 + 1856);
v32 = v2;
}
LabelGameObject::createLabel(v31, &v32);
if ( (v32 & 1) != 0 )
operator delete(v33);
}
if ( (__dst[0] & 1) != 0 )
operator delete(v38);
}