//
// GJItemIcon::init from 0x100307a74 to 0x100307ee8 (1140 bytes)
//
// 1 xrefs:
// > GJItemIcon::create @ 0x100307a18
//
// 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
//
bool __fastcall GJItemIcon::init(
GJItemIcon *a1,
UnlockType a2,
int a3,
cocos2d::ccColor3B a4,
cocos2d::ccColor3B a5,
bool a6,
bool a7,
bool a8,
cocos2d::ccColor3B a9)
{
_BOOL4 v10; // w24
_BOOL4 v14; // w20
GameManager *v15; // x0
double v16; // d0
const std::string::value_type *v17; // x8
const std::string::value_type *v18; // x1
cocos2d::CCSprite *v19; // x0
SimplePlayer *v20; // x21
__n128 v21; // q0
GameManager *v22; // x0
IconType v23; // w23
GameManager *v24; // x0
double *v25; // x0
__n128 v26; // q0
__n128 v27; // q1
std::string *v29; // x8
cocos2d::CCString *v30; // x0
const char *CString; // x0
GameManager *v32; // x0
const char *v33; // x0
cocos2d::CCLabelBMFont *v34; // x22
float v35; // s8
__int64 v36; // x0
__n128 v37; // q0
__n128 v38; // q1
int v39; // [xsp+1Ch] [xbp-84h] BYREF
cocos2d::ccColor3B v40; // [xsp+24h] [xbp-7Ch] BYREF
std::string v41; // [xsp+28h] [xbp-78h] BYREF
double v42; // [xsp+40h] [xbp-60h] BYREF
cocos2d::ccColor3B v43; // [xsp+48h] [xbp-58h] BYREF
cocos2d::ccColor3B v44; // [xsp+4Ch] [xbp-54h] BYREF
v10 = a6;
v44 = a4;
v43 = a5;
v14 = cocos2d::CCSprite::init(a1);
if ( v14 )
{
a1->m_unlockID = a3;
a1->m_unlockType = a2;
v15 = GameManager::sharedState();
a1->m_iconRequestID = GameManager::getIconRequestID(v15);
((void (__fastcall *)(GJItemIcon *, void *))a1->setTextureRect)(a1, &unk_10086DF50);
sub_100022988((float *)&v42, 30.0, 30.0);
v16 = sub_100022B14(&a1->m_playerSize, &v42);
((void (__fastcall *)(GJItemIcon *, double *, double))a1->setContentSize)(a1, &v42, v16);
memset(&v41, 0, sizeof(v41));
v17 = "player_special";
v18 = "ship";
switch ( a2 )
{
case 1:
v18 = "player";
goto LABEL_17;
case 4:
goto LABEL_17;
case 5:
v18 = "player_ball";
goto LABEL_17;
case 6:
v18 = "bird";
goto LABEL_17;
case 7:
v18 = "dart";
goto LABEL_17;
case 8:
v18 = "robot";
goto LABEL_17;
case 9:
v18 = "spider";
goto LABEL_17;
case 10:
goto LABEL_24;
case 11:
v17 = "explosionIcon";
goto LABEL_24;
case 12:
v17 = "gjItem";
goto LABEL_24;
case 13:
v18 = "swing";
goto LABEL_17;
case 14:
v18 = "jetpack";
LABEL_17:
std::string::assign(&v41, v18);
goto LABEL_18;
case 15:
v17 = "shipfireIcon";
LABEL_24:
std::string::assign(&v41, v17);
goto LABEL_25;
default:
std::string::assign(&v41, "player");
if ( (unsigned int)a2 > (GJItem|Col1) )
goto LABEL_25;
if ( ((1 << a2) & 0x6002) != 0 )
{
LABEL_18:
a1->m_isIcon = 1;
v20 = SimplePlayer::create(1);
v22 = GameManager::sharedState();
v23 = GameManager::unlockTypeToIconType(v22, a2);
v24 = GameManager::sharedState();
GameManager::isIconLoaded(v24, a3, v23);
SimplePlayer::updatePlayerFrame(v20, a3, v23);
((void (__fastcall *)(cocos2d::CCSprite *, cocos2d::ccColor3B *))v20->m_firstLayer->setColor)(
v20->m_firstLayer,
&v44);
((void (__fastcall *)(cocos2d::CCSprite *, cocos2d::ccColor3B *))v20->m_secondLayer->setColor)(
v20->m_secondLayer,
&v43);
SimplePlayer::updateColors(v20);
v25 = (double *)((__int64 (__fastcall *)(cocos2d::CCSprite *))v20->m_firstLayer->getContentSize)(v20->m_firstLayer);
v21.n128_f64[0] = sub_100022B14(&a1->m_playerSize, v25);
}
else if ( ((1 << a2) & 0xC) != 0 )
{
v19 = cocos2d::CCSprite::createWithSpriteFrameName("player_special_01_001.png");
v20 = (SimplePlayer *)v19;
if ( v10 )
{
LABEL_14:
((void (__fastcall *)(cocos2d::CCSprite *, _BYTE *))v19->setColor)(v19, algn_100644D16);
((void (__fastcall *)(SimplePlayer *, __int64))v20->setOpacity)(v20, 120);
goto LABEL_19;
}
v32 = GameManager::sharedState();
v40 = GameManager::colorForIdx(v32, a3);
((void (__fastcall *)(SimplePlayer *, cocos2d::ccColor3B *))v20->setColor)(v20, &v40);
if ( !a8 )
{
if ( a2 == Col1 )
v33 = "1";
else
v33 = "2";
v34 = cocos2d::CCLabelBMFont::create_1(v33, "bigFont.fnt");
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float))v34->setScale)(v34, 0.5);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, cocos2d::ccColor3B *))v34->setColor)(v34, &v40);
((void (__fastcall *)(SimplePlayer *, cocos2d::CCLabelBMFont *, __int64))v20->addChild_0)(v20, v34, 1);
v35 = *(float *)((__int64 (__fastcall *)(SimplePlayer *))v20->getContentSize)(v20);
v36 = ((__int64 (__fastcall *)(SimplePlayer *))v20->getContentSize)(v20);
v37.n128_f32[0] = v35 * 0.5;
v38.n128_f32[0] = *(float *)(v36 + 4) * 0.5;
sub_100022980(v37, v38, &v39);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, int *))v34->setPosition)(v34, &v39);
}
}
else
{
LABEL_25:
if ( (unsigned int)(a3 - 6) <= 9 && a1->m_unlockType == GJItem )
{
v20 = (SimplePlayer *)GJPathSprite::create(a3 - 5);
}
else
{
v29 = &v41;
if ( (v41.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
v29 = (std::string *)v41.__r_.__value_.__r.__words[0];
v30 = (cocos2d::CCString *)sub_100268F4C("%s_%02d_001.png", (const char *)v29, a3);
CString = cocos2d::CCString::getCString(v30);
v19 = cocos2d::CCSprite::createWithSpriteFrameName(CString);
v20 = (SimplePlayer *)v19;
if ( v10 )
goto LABEL_14;
}
}
LABEL_19:
v26 = ((__n128 (__fastcall *)(GJItemIcon *, SimplePlayer *, __n128))a1->addChild)(a1, v20, v21);
v26.n128_f32[0] = *(float *)&v42 * 0.5;
v27.n128_f32[0] = *((float *)&v42 + 1) * 0.5;
sub_100022980(v26, v27, &v39);
((void (__fastcall *)(SimplePlayer *, int *))v20->setPosition)(v20, &v39);
a1->m_player = v20;
if ( SHIBYTE(v41.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v41.__r_.__value_.__l.__data_);
break;
}
}
return v14;
}