//
// OptionsCell::loadFromObject from 0x615de8 to 0x61625c (1140 bytes)
//
// 3 xrefs:
// > CustomListView::reloadAll @ 0x61e110
// > CustomListView::loadCell @ 0x6204a0
// > ??> @ 0x6fbe8
//
// 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 OptionsCell::loadFromObject(OptionsCell *a1, OptionsObject *a2)
{
cocos2d::CCLayer *m_mainLayer; // x2
int m_count; // w22
cocos2d::CCLabelBMFont *v6; // x19
void (__fastcall *setAnchorPoint)(cocos2d::CCLabelBMFont *__hidden, const cocos2d::CCPoint *); // x24
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x24
void *v9; // x0
cocos2d::CCLabelBMFont *v10; // x22
void (__fastcall *v11)(cocos2d::CCLabelBMFont *__hidden, const cocos2d::CCPoint *); // x25
void (__fastcall *v12)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x25
__int64 v13; // x26
float width; // s9
float v15; // s0
cocos2d::CCArray **p_m_pTargetArray; // x22
const char *v17; // x0
cocos2d::CCSprite *v18; // x19
CCMenuItemSpriteExtra *v19; // x19
cocos2d::CCNode *v20; // x19
float v21; // s1
void (__fastcall *v22)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x21
void (__fastcall *setColor)(cocos2d::CCLabelBMFont *__hidden, const cocos2d::ccColor3B *); // x3
unsigned int *p_m_nExtraKerning; // x19
int m_nExtraKerning; // w0
unsigned int *v26; // x1
int v27; // w2
cocos2d::CCLabelBMFont *v28; // [xsp+60h] [xbp+60h] BYREF
cocos2d::CCPoint v29; // [xsp+68h] [xbp+68h] BYREF
cocos2d::CCPoint v30; // [xsp+70h] [xbp+70h] BYREF
cocos2d::SEL_MenuHandler v31; // 0:x2.16
m_mainLayer = a1->m_mainLayer;
a1->m_optionsObject = a2;
m_mainLayer->removeAllChildrenWithCleanup(m_mainLayer, 1);
m_count = a2->m_count;
v6 = cocos2d::CCLabelBMFont::create();
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v6, 2);
v6->setScale(v6, 0.4);
setAnchorPoint = v6->setAnchorPoint;
cocos2d::CCPoint::CCPoint(&v30, 0.0, 0.5);
setAnchorPoint(v6, &v30);
setPosition = v6->setPosition;
cocos2d::CCPoint::CCPoint(&v30, 40.0, a1->m_height * 0.5);
setPosition(v6, &v30);
if ( m_count )
{
if ( m_count > 0 )
{
sub_D153B8((int)&v28, "[ ");
GameToolbox::intToString((__int64 *)&v30, (GameToolbox *)(unsigned int)m_count);
sub_D15E14(&v28, &v30);
v9 = (void *)(*(_QWORD *)&v30 - 24LL);
if ( (__int64 *)(*(_QWORD *)&v30 - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v26 = (unsigned int *)(*(_QWORD *)&v30 - 8LL);
do
v27 = __ldaxr(v26);
while ( __stlxr(v27 - 1, v26) );
}
else
{
v27 = *(_DWORD *)(*(_QWORD *)&v30 - 8LL);
*(_DWORD *)(*(_QWORD *)&v30 - 8LL) = v27 - 1;
}
if ( v27 <= 0 )
operator delete(v9);
}
sub_D15FD4(&v28, " ]", 2);
v10 = cocos2d::CCLabelBMFont::create();
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v10, 2);
v10->setScale(v10, 0.6);
v11 = v10->setAnchorPoint;
cocos2d::CCPoint::CCPoint(&v30, 0.0, 0.5);
v11(v10, &v30);
v10->setColor(v10, (const cocos2d::ccColor3B *)&unk_EBE230);
v10->setOpacity(v10, 4294967215LL);
v12 = v10->setPosition;
v13 = (__int64)v6->getPosition(v6);
width = v6->getContentSize(v6)->width;
v15 = v6->getScale(v6);
cocos2d::CCPoint::CCPoint(&v29, (float)(width * v15) + 8.0, 0.0);
cocos2d::CCPoint::operator+(&v30, v13, &v29);
v12(v10, &v30);
p_m_pTargetArray = &v28[-1].m_pTargetArray;
if ( &v28[-1].m_pTargetArray != (cocos2d::CCArray **)&qword_124B6B0 )
{
if ( &pthread_create )
{
p_m_nExtraKerning = (unsigned int *)&v28[-1].m_nExtraKerning;
do
m_nExtraKerning = __ldaxr(p_m_nExtraKerning);
while ( __stlxr(m_nExtraKerning - 1, p_m_nExtraKerning) );
}
else
{
m_nExtraKerning = v28[-1].m_nExtraKerning;
v28[-1].m_nExtraKerning = m_nExtraKerning - 1;
}
if ( m_nExtraKerning <= 0 )
operator delete(p_m_pTargetArray);
}
}
}
else
{
setColor = v6->setColor;
LOWORD(v30.x) = -26986;
BYTE2(v30.x) = -106;
setColor(v6, (const cocos2d::ccColor3B *)&v30);
}
if ( a1->m_optionsObject->m_enabled )
v17 = "GJ_checkOn_001.png";
else
v17 = "GJ_checkOff_001.png";
v18 = cocos2d::CCSprite::createWithSpriteFrameName(v17);
v18->setScale(v18, 0.6);
v31.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v31.adj = (size_t)OptionsCell::onToggleOption;
v19 = CCMenuItemSpriteExtra::create(v18, nullptr, v31);
CCMenuItemSpriteExtra::setSizeMult(v19, 1.5);
v20 = (cocos2d::CCNode *)cocos2d::CCMenu::create((cocos2d::CCMenu *)v19, nullptr);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v20, 3);
v21 = a1->m_height * 0.5;
v22 = v20->setPosition;
cocos2d::CCPoint::CCPoint(&v30, 20.0, v21);
v22(v20, &v30);
}