//
// LevelListLayer::onFavorite from 0x140307730 to 0x140307854 (292 bytes)
//
// 2 xrefs:
// > LevelListLayer::init @ 0x1403047c1
// > ??> @ 0x1406d44f0
//
// 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
//
// Hidden C++ exception states: #wind=2
void LevelListLayer::onFavorite(LevelListLayer *a1, cocos2d::CCObject *a2)
{
GJLevelList *m_levelList; // r8
bool m_favorite; // bp
__int64 v5; // rcx
__int64 *v6; // rdi
__int64 v7; // rsi
const char *v8; // rbx
cocos2d::CCSpriteFrameCache *v9; // rax
struct cocos2d::CCSpriteFrame *v10; // rax
GameLevelManager *v11; // rcx
void *v12; // [rsp+40h] [rbp+8h]
void *v13; // [rsp+40h] [rbp+8h]
if ( !a1->m_exiting )
{
m_levelList = a1->m_levelList;
m_favorite = m_levelList->m_favorite;
m_levelList->m_favorite = !m_favorite;
v6 = (__int64 *)((__int64 (__fastcall *)(cocos2d::CCObject *))a2->__vftable[13].copyWithZone)(a2);
v7 = *v6;
v8 = "gj_heartOff_001.png";
if ( !m_favorite )
v8 = "gj_heartOn_001.png";
v9 = (cocos2d::CCSpriteFrameCache *)cocos2d::CCSpriteFrameCache::sharedSpriteFrameCache(v5);
v10 = cocos2d::CCSpriteFrameCache::spriteFrameByName(v9, v8);
(*(void (__fastcall **)(__int64 *, struct cocos2d::CCSpriteFrame *))(v7 + 992))(v6, v10);
v11 = (GameLevelManager *)qword_1406C2EC0;
if ( m_favorite )
{
if ( !qword_1406C2EC0 )
{
v13 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v13);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v11 = (GameLevelManager *)qword_1406C2EC0;
}
GameLevelManager::deleteLevelList(v11, a1->m_levelList);
}
else
{
if ( !qword_1406C2EC0 )
{
v12 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v12);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v11 = (GameLevelManager *)qword_1406C2EC0;
}
GameLevelManager::saveLevelList(v11, a1->m_levelList);
}
}
}