//
// MapPackCell::loadFromMapPack from 0x100244990 to 0x1002454d6 (2886 bytes)
//
// 3 xrefs:
// > CustomListView::loadCell @ 0x1002426f0
// > CustomListView::reloadAll @ 0x10024e3c3
// > MapPackCell::reloadCell @ 0x10024e5ac
//
// 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 __fastcall MapPackCell::loadFromMapPack(MapPackCell *a1, GJMapPack *a2)
{
GJDifficulty m_difficulty; // r14d
cocos2d::CCString *v4; // rax
const char *CString; // rax
const char *v6; // rdi
cocos2d::CCSprite *v7; // r14
GJMapPack *m_mapPack; // rax
std::string *p_m_packName; // rax
const char *v10; // rdi
cocos2d::CCLabelBMFont *v11; // r14
GJMapPack *v12; // rax
__int16 v13; // cx
float *v14; // rax
double v15; // xmm0_8
ButtonSprite *v16; // r14
CCMenuItemSpriteExtra *v17; // rax
int v18; // edx
int v19; // ecx
int v20; // r8d
int v21; // r9d
__int64 v22; // r15
float *v23; // rax
GameStatsManager *v24; // rax
int v25; // r12d
cocos2d::CCSprite *v26; // rax
CCMenuItemSpriteExtra *v27; // rax
CCMenuItemSpriteExtra *m_rewardButton; // r15
__int64 v29; // rax
cocos2d::CCSprite *v30; // r15
cocos2d::CCSprite *v31; // r12
GJMapPack *v32; // rax
__int16 v33; // cx
__int64 v34; // rax
int v35; // eax
cocos2d::CCString *v36; // rax
const char *v37; // rax
cocos2d::CCLabelBMFont *v38; // r12
__int64 v39; // rax
GJMapPack *v40; // rax
int m_stars; // ecx
int m_coins; // eax
unsigned int v43; // r14d
cocos2d::CCSprite *v44; // r12
float v45; // xmm0_4
cocos2d::CCString *v46; // rax
const char *v47; // rax
cocos2d::CCLabelBMFont *v48; // r13
__int64 v49; // r14
cocos2d::CCSprite *v50; // r12
float v51; // xmm0_4
cocos2d::CCString *v52; // rax
const char *v53; // rax
cocos2d::CCLabelBMFont *v54; // r13
__int64 v55; // r14
cocos2d::CCSprite *v56; // r14
__int64 v57; // rbx
char v58; // [rsp+0h] [rbp-70h]
char v59; // [rsp+0h] [rbp-70h]
char v60; // [rsp+0h] [rbp-70h]
_BYTE v61[8]; // [rsp+10h] [rbp-60h] BYREF
unsigned int v62; // [rsp+18h] [rbp-58h]
__int16 v63; // [rsp+1Ch] [rbp-54h] BYREF
char v64; // [rsp+1Eh] [rbp-52h]
__int128 v65; // [rsp+20h] [rbp-50h] BYREF
void *__p; // [rsp+30h] [rbp-40h]
cocos2d::CCSprite *v67; // [rsp+38h] [rbp-38h]
bool hasCompletedMapPack; // [rsp+47h] [rbp-29h]
((void (__fastcall *)(cocos2d::CCLayer *, __int64))a1->m_mainLayer->removeAllChildrenWithCleanup)(a1->m_mainLayer, 1);
sub_100720270(a1->m_rewardSprites);
sub_100720270(a1->m_rewardLabels);
a1->m_mapPack = a2;
m_difficulty = a2->m_difficulty;
v4 = (cocos2d::CCString *)sub_1007AB580("difficulty_%02d_btn_001.png", v58);
CString = cocos2d::CCString::getCString(v4);
v6 = "difficulty_auto_btn_001.png";
if ( m_difficulty )
v6 = CString;
v7 = cocos2d::CCSprite::createWithSpriteFrameName(v6);
sub_10028CBE0(&v65, 31.0, a1->m_height * 0.5);
((void (__fastcall *)(cocos2d::CCSprite *, __int128 *))v7->setPosition)(v7, &v65);
((void (__fastcall *)(cocos2d::CCSprite *, float))v7->setScale)(v7, 1.1);
((void (__fastcall *)(MapPackCell *, cocos2d::CCSprite *, __int64))a1->addChild_0)(a1, v7, 2);
m_mapPack = a1->m_mapPack;
if ( (m_mapPack->m_packName.m_data.m_short.sizex2 & 1) != 0 )
{
sub_100006B70(
&v65,
m_mapPack->m_packName.m_data.m_long.longStorage,
m_mapPack->m_packName.m_data.m_long.size,
COERCE_DOUBLE(1066192077));
if ( (v65 & 1) == 0 )
goto LABEL_5;
}
else
{
p_m_packName = &m_mapPack->m_packName;
__p = p_m_packName->m_data.m_long.longStorage;
v65 = *(_OWORD *)&p_m_packName->m_data.m_short.sizex2;
if ( (v65 & 1) == 0 )
{
LABEL_5:
v10 = (char *)&v65 + 1;
goto LABEL_8;
}
}
v10 = (const char *)__p;
LABEL_8:
v11 = cocos2d::CCLabelBMFont::create_3(v10, "bigFont.fnt");
if ( (v65 & 1) != 0 )
operator delete(__p);
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCLabelBMFont *))a1->m_mainLayer->addChild)(a1->m_mainLayer, v11);
v12 = a1->m_mapPack;
v13 = *(_WORD *)&v12->m_barColour.r;
BYTE2(v65) = v12->m_barColour.b;
LOWORD(v65) = v13;
((void (__fastcall *)(cocos2d::CCLabelBMFont *, __int128 *))v11->setColor)(v11, &v65);
sub_10028CBE0(&v65, (float)((float)(a1->m_width * 0.5) + -14.0) + -2.0, (float)(a1->m_height * 0.5) + 30.0);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, __int128 *))v11->setPosition)(v11, &v65);
if ( *(float *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))v11->getContentSize)(v11) > 205.0 )
{
v14 = (float *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))v11->getContentSize)(v11);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float))v11->setScale)(v11, 205.0 / *v14);
}
v15 = ((double (__fastcall *)(cocos2d::CCLabelBMFont *))v11->getScale)(v11);
if ( *(float *)&v15 <= 0.89999998 )
((void (__fastcall *)(cocos2d::CCLabelBMFont *))v11->getScale)(v11);
((void (__fastcall *)(cocos2d::CCLabelBMFont *))v11->setScale)(v11);
v16 = ButtonSprite::create_1("View", 50, 0, 0.60000002, 0, "bigFont.fnt", "GJ_button_01.png", 50.0);
v17 = CCMenuItemSpriteExtra::create(
v16,
nullptr,
a1,
(cocos2d::SEL_MenuHandler)(unsigned __int64)MapPackCell::onClick);
a1->m_viewButton = v17;
CCMenuItemSpriteExtra::setSizeMult(v17, 1.5);
v22 = sub_100792C50(a1->m_viewButton, 0, v18, v19, v20, v21);
((void (__fastcall *)(cocos2d::CCLayer *, __int64))a1->m_mainLayer->addChild)(a1->m_mainLayer, v22);
*(float *)&v67 = a1->m_width;
v23 = (float *)((__int64 (__fastcall *)(ButtonSprite *))v16->getContentSize)(v16);
sub_10028CBE0(&v65, (float)(*(float *)&v67 - (float)(*v23 * 0.5)) + -9.0, a1->m_height * 0.5);
(*(void (__fastcall **)(__int64, __int128 *))(*(_QWORD *)v22 + 184LL))(v22, &v65);
v24 = GameStatsManager::sharedState();
hasCompletedMapPack = GameStatsManager::hasCompletedMapPack(v24, a1->m_mapPack->m_packID);
if ( !hasCompletedMapPack )
{
v25 = GJMapPack::completedMaps(a1->m_mapPack);
if ( v25 >= GJMapPack::totalMaps(a1->m_mapPack) )
{
((void (__fastcall *)(CCMenuItemSpriteExtra *, _QWORD))a1->m_viewButton->setVisible)(a1->m_viewButton, 0);
((void (__fastcall *)(CCMenuItemSpriteExtra *, _QWORD))a1->m_viewButton->setEnabled)(a1->m_viewButton, 0);
v26 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_rewardBtn_001.png");
v27 = CCMenuItemSpriteExtra::create(
v26,
nullptr,
a1,
(cocos2d::SEL_MenuHandler)(unsigned __int64)MapPackCell::onClaimReward);
a1->m_rewardButton = v27;
CCMenuItemSpriteExtra::setSizeMult(v27, 1.5);
(*(void (__fastcall **)(__int64, CCMenuItemSpriteExtra *))(*(_QWORD *)v22 + 440LL))(v22, a1->m_rewardButton);
m_rewardButton = a1->m_rewardButton;
v29 = ((__int64 (__fastcall *)(CCMenuItemSpriteExtra *))a1->m_viewButton->getPosition)(a1->m_viewButton);
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64))m_rewardButton->setPosition)(m_rewardButton, v29);
}
}
v64 = 0;
v63 = 0;
v30 = cocos2d::CCSprite::create_1("GJ_progressBar_001.png");
((void (__fastcall *)(cocos2d::CCSprite *, __int16 *))v30->setColor)(v30, &v63);
((void (__fastcall *)(cocos2d::CCSprite *, __int64))v30->setOpacity)(v30, 125);
((void (__fastcall *)(cocos2d::CCSprite *, float))v30->setScaleY)(v30, 0.80000001);
((void (__fastcall *)(cocos2d::CCSprite *, float))v30->setScaleX)(v30, 0.60000002);
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCSprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v30,
3);
sub_10028CBE0(&v65, (float)(a1->m_width * 0.5) + -14.0, (float)(a1->m_height * 0.5) + -2.0);
((void (__fastcall *)(cocos2d::CCSprite *, __int128 *))v30->setPosition)(v30, &v65);
v31 = cocos2d::CCSprite::create_1("GJ_progressBar_001.png");
((void (__fastcall *)(cocos2d::CCSprite *, float))v31->setScaleX)(v31, 0.98500001);
((void (__fastcall *)(cocos2d::CCSprite *, float))v31->setScaleY)(v31, 0.82999998);
v32 = a1->m_mapPack;
v33 = *(_WORD *)&v32->m_textColour.r;
BYTE2(v65) = v32->m_textColour.b;
LOWORD(v65) = v33;
((void (__fastcall *)(cocos2d::CCSprite *, __int128 *))v31->setColor)(v31, &v65);
*(float *)&v67 = v31->m_obRect.size.width - (float)(0.98500001 * v31->m_obRect.size.width);
((void (__fastcall *)(cocos2d::CCSprite *, cocos2d::CCSprite *, __int64))v30->addChild_0)(v30, v31, 1);
sub_10028CBE0(&v65, 0.0, 0.5);
((void (__fastcall *)(cocos2d::CCSprite *, __int128 *))v31->setAnchorPoint)(v31, &v65);
*(float *)&v67 = *(float *)&v67 * 0.5;
v34 = ((__int64 (__fastcall *)(cocos2d::CCSprite *))v30->getContentSize)(v30);
sub_10028CBE0(&v65, *(float *)&v67, *(float *)(v34 + 4) * 0.5);
((void (__fastcall *)(cocos2d::CCSprite *, __int128 *))v31->setPosition)(v31, &v65);
*(float *)&v67 = (float)GJMapPack::completedMaps(a1->m_mapPack);
v35 = GJMapPack::totalMaps(a1->m_mapPack);
sub_10028CC00(
&v65,
0.0,
0.0,
fminf((float)(*(float *)&v67 / (float)v35) * v31->m_obRect.size.width, v31->m_obRect.size.width),
v31->m_obRect.size.height);
((void (__fastcall *)(cocos2d::CCSprite *, __int128 *))v31->setTextureRect)(v31, &v65);
GJMapPack::completedMaps(a1->m_mapPack);
GJMapPack::totalMaps(a1->m_mapPack);
v36 = (cocos2d::CCString *)sub_1007AB580("%i/%i", v59);
v37 = cocos2d::CCString::getCString(v36);
v38 = cocos2d::CCLabelBMFont::create_3(v37, "bigFont.fnt");
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCLabelBMFont *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v38,
4);
v39 = ((__int64 (__fastcall *)(cocos2d::CCSprite *))v30->getPosition)(v30);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, __int64))v38->setPosition)(v38, v39);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float))v38->setScale)(v38, 0.5);
v40 = a1->m_mapPack;
m_stars = v40->m_stars;
m_coins = v40->m_coins;
v43 = (m_stars > 0) + (m_coins > 0);
*(float *)&v67 = (float)(0.5 * a1->m_height) + -30.0;
if ( m_stars > 0 )
{
v44 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_starsIcon_001.png");
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCSprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v44,
2);
v62 = v43;
if ( v43 > 1 )
v45 = (float)((float)(a1->m_width * 0.5) + -4.0) + -40.0;
else
v45 = (float)(a1->m_width * 0.5) + -4.0;
sub_10028CBE0(&v65, v45, *(float *)&v67);
((void (__fastcall *)(cocos2d::CCSprite *, __int128 *))v44->setPosition)(v44, &v65);
v46 = (cocos2d::CCString *)sub_1007AB580("%i", v60);
v47 = cocos2d::CCString::getCString(v46);
v48 = cocos2d::CCLabelBMFont::create_3(v47, "bigFont.fnt");
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCLabelBMFont *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v48,
1);
sub_10028CBE0(&v65, 1.0, 0.5);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, __int128 *))v48->setAnchorPoint)(v48, &v65);
v49 = ((__int64 (__fastcall *)(cocos2d::CCSprite *))v44->getPosition)(v44);
sub_10028CBE0(v61, -17.0, 0.0);
sub_10028CCE0(&v65, v49);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, __int128 *))v48->setPosition)(v48, &v65);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float))v48->setScale)(v48, 0.69999999);
sub_10071FCD0(a1->m_rewardSprites, v44);
sub_10071FCD0(a1->m_rewardLabels, v48);
if ( hasCompletedMapPack )
{
BYTE2(v65) = 50;
LOWORD(v65) = -1;
((void (__fastcall *)(cocos2d::CCLabelBMFont *, __int128 *))v48->setColor)(v48, &v65);
v43 = v62;
if ( a1->m_mapPack->m_coins <= 0 )
goto LABEL_33;
}
else
{
v43 = v62;
if ( a1->m_mapPack->m_coins <= 0 )
return;
}
LABEL_28:
v50 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_coinsIcon_001.png");
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCSprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v50,
2);
if ( v43 > 1 )
v51 = (float)((float)(a1->m_width * 0.5) + -4.0) + 40.0;
else
v51 = (float)(a1->m_width * 0.5) + -4.0;
sub_10028CBE0(&v65, v51, *(float *)&v67);
((void (__fastcall *)(cocos2d::CCSprite *, __int128 *))v50->setPosition)(v50, &v65);
v52 = (cocos2d::CCString *)sub_1007AB580("%i", v60);
v53 = cocos2d::CCString::getCString(v52);
v54 = cocos2d::CCLabelBMFont::create_3(v53, "bigFont.fnt");
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCLabelBMFont *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v54,
1);
sub_10028CBE0(&v65, 1.0, 0.5);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, __int128 *))v54->setAnchorPoint)(v54, &v65);
v55 = ((__int64 (__fastcall *)(cocos2d::CCSprite *))v50->getPosition)(v50);
sub_10028CBE0(v61, -19.0, 0.0);
v67 = v50;
sub_10028CCE0(&v65, v55);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, __int128 *))v54->setPosition)(v54, &v65);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float))v54->setScale)(v54, 0.69999999);
sub_10071FCD0(a1->m_rewardSprites, v67);
sub_10071FCD0(a1->m_rewardLabels, v54);
if ( hasCompletedMapPack )
{
BYTE2(v65) = 50;
LOWORD(v65) = -1;
((void (__fastcall *)(cocos2d::CCLabelBMFont *, __int128 *))v54->setColor)(v54, &v65);
goto LABEL_33;
}
return;
}
if ( m_coins > 0 )
goto LABEL_28;
if ( hasCompletedMapPack )
{
LABEL_33:
v56 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_completesIcon_001.png");
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCSprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v56,
5);
((void (__fastcall *)(cocos2d::CCSprite *, float))v56->setScale)(v56, 1.0);
v57 = ((__int64 (__fastcall *)(cocos2d::CCSprite *))v30->getPosition)(v30);
sub_10028CBE0(v61, 86.0, 1.0);
sub_10028CCE0(&v65, v57);
((void (__fastcall *)(cocos2d::CCSprite *, __int128 *))v56->setPosition)(v56, &v65);
}
}