//
// EditorSoundConfigInfoLayer::onFavorite from 0x1401950c0 to 0x140195419 (857 bytes)
//
// 3 xrefs:
// > EditorSoundConfigInfoLayer::downloadEditorSoundFinished @ 0x140198db6
// > EditorSoundConfigInfoLayer::init @ 0x1401940b9
// > ??> @ 0x1409193f4
//
// 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 11:27:45 +0000
//
// Hidden C++ exception states: #wind=1
void __fastcall EditorSoundConfigInfoLayer::onFavorite(__int64 a1)
{
__int64 v2; // rax
__int64 v3; // rcx
unsigned int v4; // ebx
int v5; // r14d
__int64 v6; // rbp
cocos2d::CCArray *v7; // rcx
unsigned int v8; // edi
struct cocos2d::CCObject *v9; // rax
int v10; // ebp
__int64 v11; // rdi
cocos2d::CCArray *v12; // rcx
struct cocos2d::CCObject *v13; // rax
__int64 v14; // rcx
__int64 v15; // rcx
__int64 v16; // rdi
cocos2d::CCObject *v17; // rax
cocos2d::CCArray *v18; // rcx
__int64 v19; // rax
cocos2d::CCObject *v20; // rbx
struct cocos2d::CCObject *v21; // rbp
__int64 v22; // rax
__int64 v23; // rcx
__int64 v24; // rdi
cocos2d::CCObject *v25; // rax
struct cocos2d::CCObject *v26; // rax
__int128 v27; // [rsp+50h] [rbp-58h] BYREF
__int64 v28; // [rsp+60h] [rbp-48h]
__int64 v29; // [rsp+68h] [rbp-40h]
_BYTE v30[32]; // [rsp+70h] [rbp-38h] BYREF
if ( *(_QWORD *)(a1 + 1072) )
{
v2 = EditorSFXManager::sharedState();
v3 = *(_QWORD *)(a1 + 1072);
v4 = 0;
if ( !v2 )
goto LABEL_39;
v5 = *(_DWORD *)(v3 + 320);
v6 = EditorSFXManager::sharedState();
v7 = *(cocos2d::CCArray **)(v6 + 208);
if ( v7 && (v8 = 0, cocos2d::CCArray::count(v7)) )
{
while ( 1 )
{
v9 = cocos2d::CCArray::objectAtIndex(*(cocos2d::CCArray **)(v6 + 208), v8);
if ( v9 )
{
if ( *((_DWORD *)v9 + 80) == v5 )
break;
}
if ( ++v8 >= cocos2d::CCArray::count(*(cocos2d::CCArray **)(v6 + 208)) )
goto LABEL_8;
}
}
else
{
LABEL_8:
v9 = nullptr;
}
v3 = *(_QWORD *)(a1 + 1072);
if ( v9 )
{
v10 = *(_DWORD *)(v3 + 320);
v11 = EditorSFXManager::sharedState();
v12 = *(cocos2d::CCArray **)(v11 + 208);
if ( v12 && cocos2d::CCArray::count(v12) )
{
while ( 1 )
{
v13 = cocos2d::CCArray::objectAtIndex(*(cocos2d::CCArray **)(v11 + 208), v4);
if ( v13 )
{
if ( *((_DWORD *)v13 + 80) == v10 )
break;
}
if ( ++v4 >= cocos2d::CCArray::count(*(cocos2d::CCArray **)(v11 + 208)) )
goto LABEL_17;
}
cocos2d::CCArray::removeObjectAtIndex(*(cocos2d::CCArray **)(v11 + 208), v4, 1);
}
LABEL_17:
EditorSoundConfigInfoLayer::refreshActionButtons(a1);
v14 = *(_QWORD *)(a1 + 1088);
if ( v14 )
cocos2d::CCNode::scheduleOnce(v14, FLAlertLayer::rebuildContentDeferred);
}
else
{
LABEL_39:
if ( *(_BYTE *)(v3 + 544) )
{
v16 = EditorSFXManager::sharedState();
if ( !*(_QWORD *)(v16 + 208) )
{
v17 = (cocos2d::CCObject *)cocos2d::CCArray::create(v15);
*(_QWORD *)(v16 + 208) = v17;
cocos2d::CCObject::retain(v17);
}
v18 = *(cocos2d::CCArray **)(v16 + 208);
if ( v18 && cocos2d::CCArray::count(v18) >= 0x32 )
{
v27 = 0;
*(_QWORD *)&v27 = sub_14003D460(0x50u);
v28 = 64;
v29 = 79;
strcpy((char *)v27, "You have reached the maximum of 50 favorites. Remove some first.");
v19 = sub_14003F4F0((__int64)v30, (__int64)&v27);
v20 = FLAlertLayer::create(0, (int)"Limit Reached", v19, (__int64)"OK", 0, 1132068864, 0, 0, 1065353216);
sub_14003D310((__int64)&v27);
(*(void (__fastcall **)(cocos2d::CCObject *))(*(_QWORD *)v20 + 1064LL))(v20);
}
else
{
v21 = *(struct cocos2d::CCObject **)(a1 + 1072);
v22 = EditorSFXManager::sharedState();
v24 = v22;
if ( v21 )
{
if ( !*(_QWORD *)(v22 + 208) )
{
v25 = (cocos2d::CCObject *)cocos2d::CCArray::create(v23);
*(_QWORD *)(v24 + 208) = v25;
cocos2d::CCObject::retain(v25);
}
if ( cocos2d::CCArray::count(*(cocos2d::CCArray **)(v24 + 208)) )
{
while ( 1 )
{
v26 = cocos2d::CCArray::objectAtIndex(*(cocos2d::CCArray **)(v24 + 208), v4);
if ( v26 )
{
if ( *((_DWORD *)v26 + 80) == *((_DWORD *)v21 + 80) )
break;
}
if ( ++v4 >= cocos2d::CCArray::count(*(cocos2d::CCArray **)(v24 + 208)) )
goto LABEL_35;
}
cocos2d::CCArray::removeObjectAtIndex(*(cocos2d::CCArray **)(v24 + 208), v4, 1);
}
LABEL_35:
cocos2d::CCArray::addObject(*(cocos2d::CCArray **)(v24 + 208), v21);
}
EditorSoundConfigInfoLayer::refreshActionButtons(a1);
}
}
else
{
*(_BYTE *)(a1 + 1105) = 1;
EditorSoundConfigInfoLayer::startDownload(a1);
}
}
}
}