//
// GJItemIcon::init from 0x1003710b0 to 0x10037159b (1259 bytes)
//
// 1 xrefs:
// > GJItemIcon::create @ 0x100371047
//
// 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 v9; // r14d
bool result; // al
GameManager *v14; // rax
const std::string::value_type *v15; // rsi
const std::string::value_type *v16; // rsi
int v17; // eax
int v18; // eax
char *v19; // r14
GameManager *v20; // rax
IconType v21; // r12d
GameManager *v22; // rax
_QWORD *v23; // rax
cocos2d::CCString *v24; // rax
const char *CString; // rax
GameManager *v26; // rax
const char *v27; // rdi
cocos2d::CCLabelBMFont *v28; // r15
__int64 v29; // rax
__int64 v30; // [rsp+0h] [rbp-60h] BYREF
float v31; // [rsp+8h] [rbp-58h] BYREF
std::string v32; // [rsp+10h] [rbp-50h] BYREF
cocos2d::ccColor3B v33; // [rsp+28h] [rbp-38h] BYREF
cocos2d::ccColor3B v34; // [rsp+2Ch] [rbp-34h] BYREF
float v35; // [rsp+30h] [rbp-30h]
cocos2d::ccColor3B v36; // [rsp+34h] [rbp-2Ch] BYREF
bool v37; // [rsp+37h] [rbp-29h]
v9 = a6;
v33 = a4;
v34 = a5;
result = cocos2d::CCSprite::init(a1);
if ( result )
{
v35 = *(float *)&v9;
v37 = result;
a1->m_unlockID = a3;
a1->m_unlockType = a2;
v14 = GameManager::sharedState();
a1->m_iconRequestID = GameManager::getIconRequestID(v14);
((void (__fastcall *)(GJItemIcon *, void *))a1->setTextureRect)(a1, &unk_1009A0D38);
sub_10028CBF0((float *)&v30, 30.0, 30.0);
sub_10028CFF0(&a1->m_playerSize, &v30);
((void (__fastcall *)(GJItemIcon *, __int64 *))a1->setContentSize)(a1, &v30);
memset(&v32, 0, sizeof(v32));
switch ( a2 )
{
case 1:
v15 = "player";
goto LABEL_18;
case 4:
v15 = "ship";
goto LABEL_18;
case 5:
v15 = "player_ball";
goto LABEL_18;
case 6:
v15 = "bird";
goto LABEL_18;
case 7:
v15 = "dart";
goto LABEL_18;
case 8:
v15 = "robot";
goto LABEL_18;
case 9:
v15 = "spider";
goto LABEL_18;
case 10:
v16 = "player_special";
goto LABEL_30;
case 11:
v16 = "explosionIcon";
goto LABEL_30;
case 12:
v16 = "gjItem";
goto LABEL_30;
case 13:
v15 = "swing";
goto LABEL_18;
case 14:
v15 = "jetpack";
LABEL_18:
std::string::assign(&v32, v15);
goto LABEL_19;
case 15:
v16 = "shipfireIcon";
LABEL_30:
std::string::assign(&v32, v16);
goto LABEL_31;
default:
v15 = "player";
std::string::assign(&v32, "player");
if ( (unsigned int)a2 > (GJItem|Col1) )
goto LABEL_31;
v17 = 24578;
if ( _bittest(&v17, a2) )
{
LABEL_19:
a1->m_isIcon = 1;
v19 = (char *)operator new(0x2A8u);
cocos2d::CCSprite::CCSprite((__int64)v19, (__int64)v15);
*(_QWORD *)v19 = off_10091BD20;
*((_QWORD *)v19 + 40) = off_10091C1F8;
*((_QWORD *)v19 + 43) = off_10091C278;
*((_DWORD *)v19 + 166) = 0;
v19[668] = 0;
v19[672] = 0;
*(_OWORD *)(v19 + 600) = 0;
*(_OWORD *)(v19 + 616) = 0;
*(_OWORD *)(v19 + 632) = 0;
*(_OWORD *)(v19 + 645) = 0;
if ( SimplePlayer::init((SimplePlayer *)v19, 1) )
{
cocos2d::CCObject::autorelease((cocos2d::CCObject *)v19);
}
else
{
(*(void (__fastcall **)(char *))(*(_QWORD *)v19 + 16LL))(v19);
v19 = nullptr;
}
v20 = GameManager::sharedState();
v21 = GameManager::unlockTypeToIconType(v20, a2);
v22 = GameManager::sharedState();
GameManager::isIconLoaded(v22, a3, v21);
SimplePlayer::updatePlayerFrame((SimplePlayer *)v19, a3, v21);
(*(void (__fastcall **)(_QWORD, cocos2d::ccColor3B *))(**((_QWORD **)v19 + 75) + 944LL))(
*((_QWORD *)v19 + 75),
&v33);
(*(void (__fastcall **)(_QWORD, cocos2d::ccColor3B *))(**((_QWORD **)v19 + 76) + 944LL))(
*((_QWORD *)v19 + 76),
&v34);
SimplePlayer::updateColors((SimplePlayer *)v19);
v23 = (_QWORD *)(*(__int64 (__fastcall **)(_QWORD))(**((_QWORD **)v19 + 75) + 312LL))(*((_QWORD *)v19 + 75));
sub_10028CFF0(&a1->m_playerSize, v23);
}
else
{
v18 = 12;
if ( _bittest(&v18, a2) )
{
v19 = (char *)cocos2d::CCSprite::createWithSpriteFrameName("player_special_01_001.png");
if ( LOBYTE(v35) )
{
LABEL_14:
(*(void (__fastcall **)(char *, void *))(*(_QWORD *)v19 + 944LL))(v19, &unk_100819EA0);
(*(void (__fastcall **)(char *, __int64))(*(_QWORD *)v19 + 896LL))(v19, 120);
goto LABEL_23;
}
v26 = GameManager::sharedState();
v36 = GameManager::colorForIdx(v26, a3);
(*(void (__fastcall **)(char *, cocos2d::ccColor3B *))(*(_QWORD *)v19 + 944LL))(v19, &v36);
if ( !a8 )
{
v27 = "2";
if ( a2 == Col1 )
v27 = "1";
v28 = cocos2d::CCLabelBMFont::create_3(v27, "bigFont.fnt");
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float))v28->setScale)(v28, 0.5);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, cocos2d::ccColor3B *))v28->setColor)(v28, &v36);
(*(void (__fastcall **)(char *, cocos2d::CCLabelBMFont *, __int64))(*(_QWORD *)v19 + 448LL))(v19, v28, 1);
v35 = *(float *)(*(__int64 (__fastcall **)(char *))(*(_QWORD *)v19 + 312LL))(v19);
v29 = (*(__int64 (__fastcall **)(char *))(*(_QWORD *)v19 + 312LL))(v19);
sub_10028CBE0(&v31, v35 * 0.5, 0.5 * *(float *)(v29 + 4));
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float *))v28->setPosition)(v28, &v31);
}
}
else
{
LABEL_31:
if ( (unsigned int)(a3 - 6) <= 9 && a1->m_unlockType == GJItem )
{
v19 = (char *)GJPathSprite::create(a3 - 5);
}
else
{
v24 = (cocos2d::CCString *)sub_1007AB580("%s_%02d_001.png", v30);
CString = cocos2d::CCString::getCString(v24);
v19 = (char *)cocos2d::CCSprite::createWithSpriteFrameName(CString);
if ( LOBYTE(v35) )
goto LABEL_14;
}
}
}
LABEL_23:
((void (__fastcall *)(GJItemIcon *, char *))a1->addChild)(a1, v19);
sub_10028CBE0(&v31, *(float *)&v30 * 0.5, 0.5 * *((float *)&v30 + 1));
(*(void (__fastcall **)(char *, float *))(*(_QWORD *)v19 + 184LL))(v19, &v31);
a1->m_player = (cocos2d::CCSprite *)v19;
if ( (*(_BYTE *)&v32.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v32.__r_.__value_.__l.__data_);
result = v37;
break;
}
}
return result;
}