//
// LevelEditorLayer::updateLevelFont from 0x1000c4890 to 0x1000c4dbd (1325 bytes)
//
// 4 xrefs:
// > SelectFontLayer::onChangeFont @ 0x1002856c2
// > sub_100970840 @ 0x100970850
// > SelectFontLayer2::cellPerformedAction @ 0x1009708a7
// > sub_1009708E0 @ 0x10097090e
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:20:35 +0000
//
void __fastcall LevelEditorLayer::updateLevelFont(__int64 a1, int a2)
{
__int64 v2; // r14
__int64 v3; // rbx
__int64 v4; // r12
unsigned int i; // r13d
__int64 v6; // rax
int v7; // ecx
__int64 v8; // rdi
__int64 v9; // rax
const char *v10; // rsi
unsigned int v11; // r12d
__int64 j; // r13
__int64 v13; // r15
unsigned int v14; // r12d
__int64 v15; // rax
__int64 v16; // r15
__int64 v17; // rdi
__int64 v18; // rax
__int64 v19; // rdx
double v20; // xmm0_8
__int64 v21; // rax
const char *FontTexture; // r15
size_t v23; // rax
size_t v24; // r12
char *v25; // r13
size_t v26; // r15
__int64 v27; // rax
char *v28; // rsi
__int64 v29; // r12
unsigned int k; // r15d
__int64 v31; // r13
unsigned int m; // r14d
__int64 v33; // rax
__int64 v34; // r12
__int128 v35; // [rsp+0h] [rbp-90h] BYREF
void *v36; // [rsp+10h] [rbp-80h]
__int128 v37; // [rsp+20h] [rbp-70h] BYREF
void *__p; // [rsp+30h] [rbp-60h]
__int64 v39; // [rsp+40h] [rbp-50h]
_QWORD __dst[2]; // [rsp+48h] [rbp-48h] BYREF
void *v41; // [rsp+58h] [rbp-38h]
const char *v42; // [rsp+60h] [rbp-30h]
if ( *(_DWORD *)(*(_QWORD *)(a1 + 3272) + 360LL) == a2 )
return;
LODWORD(v42) = a2;
v2 = sub_1007FE900(a1);
v3 = sub_1007FE900(a1);
v39 = a1;
v4 = *(_QWORD *)(a1 + 3280);
if ( (unsigned int)sub_1007FEF90(v4) )
{
for ( i = 0; i < (unsigned int)sub_1007FEF90(v4); ++i )
{
v6 = sub_1007FEFE0(v4, i);
v7 = *(_DWORD *)(v6 + 1028);
v8 = v2;
if ( v7 != 914 )
{
if ( v7 != 1615 )
continue;
v8 = v3;
}
sub_1007FEBF0(v8, v6);
}
}
v9 = cocos2d::CCTextureCache::sharedTextureCache();
v10 = "bigFont.png";
v11 = 0;
for ( j = cocos2d::CCTextureCache::addImage(v9, "bigFont.png", 0); v11 < (unsigned int)sub_1007FEF90(v2); ++v11 )
{
v13 = sub_1007FEFE0(v2, v11);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v13 + 1312LL))(v13, 1);
(*(void (__fastcall **)(__int64))(*(_QWORD *)v13 + 576LL))(v13);
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v13 + 1120LL))(v13, 0);
v10 = (const char *)j;
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v13 + 1064LL))(v13, j);
}
if ( (unsigned int)sub_1007FEF90(v3) )
{
v14 = 0;
do
{
v10 = (const char *)v14;
v15 = sub_1007FEFE0(v3, v14);
LabelGameObject::removeLabel(v15);
++v14;
}
while ( v14 < (unsigned int)sub_1007FEF90(v3) );
}
v16 = v39;
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)(v39 + 2344) + 520LL))(*(_QWORD *)(v39 + 2344));
*(_QWORD *)(v39 + 2344) = 0;
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)(v16 + 2352) + 520LL))(*(_QWORD *)(v16 + 2352));
*(_QWORD *)(v16 + 2352) = 0;
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)(v16 + 2456) + 520LL))(*(_QWORD *)(v16 + 2456));
*(_QWORD *)(v16 + 2456) = 0;
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)(v16 + 2464) + 520LL))(*(_QWORD *)(v16 + 2464));
*(_QWORD *)(v16 + 2464) = 0;
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)(v16 + 2568) + 520LL))(*(_QWORD *)(v16 + 2568));
*(_QWORD *)(v16 + 2568) = 0;
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)(v16 + 2576) + 520LL))(*(_QWORD *)(v16 + 2576));
*(_QWORD *)(v16 + 2576) = 0;
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)(v16 + 2728) + 520LL))(*(_QWORD *)(v16 + 2728));
*(_QWORD *)(v16 + 2728) = 0;
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)(v16 + 2736) + 520LL))(*(_QWORD *)(v16 + 2736));
*(_QWORD *)(v16 + 2736) = 0;
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)(v16 + 2840) + 520LL))(*(_QWORD *)(v16 + 2840));
*(_QWORD *)(v16 + 2840) = 0;
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)(v16 + 2848) + 520LL))(*(_QWORD *)(v16 + 2848));
*(_QWORD *)(v16 + 2848) = 0;
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)(v16 + 2952) + 520LL))(*(_QWORD *)(v16 + 2952));
*(_QWORD *)(v16 + 2952) = 0;
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)(v16 + 2960) + 520LL))(*(_QWORD *)(v16 + 2960));
*(_QWORD *)(v16 + 2960) = 0;
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)(v16 + 3064) + 520LL))(*(_QWORD *)(v16 + 3064));
*(_QWORD *)(v16 + 3064) = 0;
v17 = *(_QWORD *)(v16 + 3072);
(*(void (__fastcall **)(__int64))(*(_QWORD *)v17 + 520LL))(v17);
*(_QWORD *)(v16 + 3072) = 0;
v18 = *(_QWORD *)(v16 + 3272);
LODWORD(v16) = (_DWORD)v42;
*(_DWORD *)(v18 + 360) = (_DWORD)v42;
*(_QWORD *)&v20 = GameManager::sharedState(v17, v10, v19).u64[0];
FontTexture = (const char *)GameManager::getFontTexture(v21, (unsigned int)v16, v20);
v23 = strlen(FontTexture);
if ( v23 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
v24 = v23;
if ( v23 >= 0x17 )
{
v42 = FontTexture;
v26 = 26;
if ( (v23 | 7) != 0x17 )
v26 = (v23 | 7) + 1;
v25 = (char *)operator new(v26);
v41 = v25;
__dst[0] = v26 + 1;
FontTexture = v42;
__dst[1] = v24;
}
else
{
LOBYTE(__dst[0]) = 2 * v23;
v25 = (char *)__dst + 1;
if ( !v23 )
goto LABEL_22;
}
memmove(v25, FontTexture, v24);
LABEL_22:
v25[v24] = 0;
v27 = cocos2d::CCTextureCache::sharedTextureCache();
if ( (__dst[0] & 1) != 0 )
v28 = (char *)v41;
else
v28 = (char *)__dst + 1;
v29 = cocos2d::CCTextureCache::addImage(v27, v28, 0);
GJBaseGameLayer::createTextLayers(v39);
for ( k = 0; k < (unsigned int)sub_1007FEF90(v2); ++k )
{
v31 = sub_1007FEFE0(v2, k);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v31 + 1064LL))(v31, v29);
if ( (*(_BYTE *)(v31 + 1352) & 1) != 0 )
{
sub_10001AD30(&v37, *(const void **)(v31 + 1368), *(_QWORD *)(v31 + 1360));
}
else
{
__p = *(void **)(v31 + 1368);
v37 = *(_OWORD *)(v31 + 1352);
}
TextGameObject::updateTextObject(v31, &v37, 0);
if ( (v37 & 1) != 0 )
operator delete(__p);
*(_BYTE *)(v31 + 1149) = 1;
(*(void (__fastcall **)(__int64, void *))(*(_QWORD *)v31 + 1496LL))(v31, &unk_100A04A53);
}
for ( m = 0; m < (unsigned int)sub_1007FEF90(v3); ++m )
{
v33 = sub_1007FEFE0(v3, m);
v34 = v33;
if ( (*(_BYTE *)(v33 + 1856) & 1) != 0 )
{
sub_10001AD30(&v35, *(const void **)(v33 + 1872), *(_QWORD *)(v33 + 1864));
}
else
{
v36 = *(void **)(v33 + 1872);
v35 = *(_OWORD *)(v33 + 1856);
}
LabelGameObject::createLabel(v34, &v35);
if ( (v35 & 1) != 0 )
operator delete(v36);
}
if ( (__dst[0] & 1) != 0 )
operator delete(v41);
}