//
// PurchaseItemPopup::init from 0x92fba8 to 0x93088c (3300 bytes)
//
// 2 xrefs:
// > PurchaseItemPopup::create @ 0x930970
// > ??> @ 0x5a7c8
//
// 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 PurchaseItemPopup::init(PurchaseItemPopup *a1, GJStoreItem *a2)
{
char v4; // w23
cocos2d::CCDirector *v6; // x0
cocos2d::CCLayer *v7; // x0
cocos2d::CCNode *v8; // x22
float v9; // s10
void (__fastcall *setContentSize)(cocos2d::CCNode *__hidden, const cocos2d::CCSize *); // x24
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x24
cocos2d::CCLabelBMFont *v12; // x22
void (__fastcall *v13)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x24
GJStoreItem *m_storeItem; // x22
int v15; // w24
UnlockType v16; // w28
GJItemIcon *StoreItem; // x22
float v18; // s9
char *v19; // x1
cocos2d::CCString *v20; // x0
size_t v21; // x0
cocos2d::CCNode *v22; // x25
char *v23; // x0
void (__fastcall *v24)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x28
cocos2d::CCMenu *v25; // x0
cocos2d::CCLayer *m_mainLayer; // x3
cocos2d::CCArray *v27; // x0
cocos2d::CCArray *v28; // x25
const char *v29; // x6
cocos2d::CCNode *v30; // x0
CCMenuItemSpriteExtra *v31; // x28
const char *v32; // x6
cocos2d::CCNode *v33; // x0
CCMenuItemSpriteExtra *v34; // x26
cocos2d::CCMenu *m_buttonMenu; // x26
const cocos2d::CCPoint *v36; // x0
unsigned __int64 v37; // d0
char *v38; // x0
void *v39; // x0
void *v40; // x0
char *v41; // x0
void *v42; // x0
unsigned int *v43; // x19
int v44; // w1
void *v45; // x0
unsigned int *v46; // x1
int v47; // w2
char *v48; // x1
char *v49; // x0
unsigned int *v50; // x1
int v51; // w2
unsigned int *v52; // x1
int v53; // w2
unsigned int *v54; // x1
int v55; // w2
unsigned int *v56; // x1
int v57; // w2
unsigned int *v58; // x1
int v59; // w2
unsigned int *v60; // x1
int v61; // w2
cocos2d::CCNode *v62; // x25
void *v63; // x0
void *v64; // x0
cocos2d::CCMenu *v65; // x26
void (__fastcall *v66)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x28
unsigned int *v67; // x1
int v68; // w2
unsigned int *v69; // x1
int v70; // w2
void (__fastcall *v71)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // [xsp+80h] [xbp+80h]
_BOOL4 v72; // [xsp+94h] [xbp+94h]
int v73; // [xsp+98h] [xbp+98h]
const char *CString; // [xsp+98h] [xbp+98h]
float v75; // [xsp+B0h] [xbp+B0h]
float v76; // [xsp+B4h] [xbp+B4h]
__int64 v77; // [xsp+B8h] [xbp+B8h] BYREF
char *v78; // [xsp+C0h] [xbp+C0h] BYREF
__int64 v79; // [xsp+C8h] [xbp+C8h] BYREF
__int64 v80; // [xsp+D0h] [xbp+D0h] BYREF
__int64 v81; // [xsp+D8h] [xbp+D8h] BYREF
char *v82; // [xsp+E0h] [xbp+E0h] BYREF
char *v83; // [xsp+E8h] [xbp+E8h] BYREF
cocos2d::CCPoint v84; // [xsp+F0h] [xbp+F0h] BYREF
cocos2d::CCRect v85; // [xsp+F8h] [xbp+F8h] BYREF
cocos2d::CCPoint v86; // 0:kr10_8.8
cocos2d::SEL_MenuHandler v87; // 0:x2.16
cocos2d::SEL_MenuHandler v88; // 0:x2.16
cocos2d::CCPoint v89; // 0:s1.4,4:s2.4
cocos2d::CCRect v90; // 0:s0.4,4:s1.4,8:s2.4,12:s3.4
v85.origin.x = 8388600.0;
v4 = cocos2d::CCLayerColor::initWithColor(a1, (const cocos2d::_ccColor4B *)&v85);
if ( !v4 )
return v4;
a1->m_storeItem = a2;
cocos2d::CCObject::retain(a2);
FLAlertLayer::incrementForcePrio(a1);
a1->setTouchEnabled(a1, 1);
a1->setKeypadEnabled(a1, 1);
v6 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v6);
v7 = cocos2d::CCLayer::create();
a1->m_mainLayer = v7;
a1->addChild(a1, v7);
cocos2d::CCRect::CCRect(&v85, 0.0, 0.0, 80.0, 80.0);
v8 = (cocos2d::CCNode *)cocos2d::extension::CCScale9Sprite::create(
(cocos2d::extension::CCScale9Sprite *)"GJ_square02.png",
(const char *)&v85,
v90);
if ( a1->m_storeItem->m_unlockType.random - a1->m_storeItem->m_unlockType.seed == 11 )
v9 = 280.0;
else
v9 = 260.0;
setContentSize = v8->setContentSize;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v85, v9, 190.0);
setContentSize(v8, (const cocos2d::CCSize *)&v85);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v8, -1);
setPosition = v8->setPosition;
cocos2d::CCPoint::CCPoint(&v85.origin, v75 * 0.5, v76 * 0.5);
setPosition(v8, &v85.origin);
v12 = cocos2d::CCLabelBMFont::create();
v13 = v12->setPosition;
cocos2d::CCPoint::CCPoint(&v85.origin, v75 * 0.5, (float)((float)(v76 * 0.5) + 95.0) - 16.0);
v13(v12, &v85.origin);
a1->m_mainLayer->addChild(a1->m_mainLayer, v12);
v12->setScale(v12, 0.6);
m_storeItem = a1->m_storeItem;
v15 = m_storeItem->m_typeID.random - m_storeItem->m_typeID.seed;
v16 = m_storeItem->m_unlockType.random - m_storeItem->m_unlockType.seed;
StoreItem = GJItemIcon::createStoreItem(v16, v15, 0, (cocos2d::ccColor3B)&unk_FFFFFF);
StoreItem->setScale(StoreItem, 1.2);
if ( v16 == Bird )
{
v72 = 0;
v18 = -8.0;
}
else
{
v72 = v16 == GJItem && (unsigned int)(v15 - 6) <= 9;
if ( v16 == GJItem && (unsigned int)(v15 - 6) <= 9 )
{
switch ( v15 )
{
case 7:
v73 = 1;
v18 = 12.0;
break;
case 8:
case 10:
case 12:
v73 = 1;
v18 = 15.0;
break;
case 9:
case 13:
case 14:
case 15:
v73 = 1;
v18 = 10.0;
break;
case 11:
v73 = 1;
v18 = 5.0;
break;
default:
v73 = 1;
v18 = 0.0;
break;
}
goto LABEL_11;
}
v18 = 0.0;
v72 = v16 == GJItem;
}
v73 = 0;
LABEL_11:
a1->m_mainLayer->addChild_0(a1->m_mainLayer, StoreItem, 1);
v71 = StoreItem->setPosition;
cocos2d::CCPoint::CCPoint(&v85.origin, v75 * 0.5, (float)((float)(v76 * 0.5) + 22.0) + v18);
v71(StoreItem, &v85.origin);
ItemInfoPopup::nameForUnlockType(v15, v16, (__int64)&v77);
sub_D18D28(&v78);
if ( *((_QWORD *)v78 - 3) > 7u )
{
sub_583094(&byte_F1AB78, &v78, &v79);
sub_D163D4(&v78, &v79);
v45 = (void *)(v79 - 24);
if ( (__int64 *)(v79 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v46 = (unsigned int *)(v79 - 8);
do
v47 = __ldaxr(v46);
while ( __stlxr(v47 - 1, v46) );
}
else
{
v47 = *(_DWORD *)(v79 - 8);
*(_DWORD *)(v79 - 8) = v47 - 1;
}
if ( v47 <= 0 )
operator delete(v45);
}
}
if ( a2->m_shopType == Diamond )
v19 = "Diamond Shards";
else
v19 = "Mana Orbs";
sub_D153B8((int)&v80, v19);
GameToolbox::pointsToString(
(GameToolbox *)(unsigned int)(a1->m_storeItem->m_price.random - a1->m_storeItem->m_price.seed),
&v81);
sub_D153B8((int)&v82, &byte_F288A0);
if ( v73 )
v20 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"Do you want to unlock%s\nfor %s %s?",
v78,
v81,
v80);
else
v20 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"Do you want to buy this %s\nfor %s %s?",
v78,
v81,
v80);
CString = cocos2d::CCString::getCString(v20);
v21 = strlen(CString);
sub_D1798C(&v82, CString, v21);
sub_D153B8((int)&v83, v82);
cocos2d::CCPoint::CCPoint(&v85.origin, 0.5, 1.0);
v22 = (cocos2d::CCNode *)TextArea::create((__int64)&v83, "bigFont.fnt", &v85.origin, 0, 1.0, 999.0, 35.0);
v23 = v83 - 24;
if ( v83 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v58 = (unsigned int *)(v83 - 8);
do
v59 = __ldaxr(v58);
while ( __stlxr(v59 - 1, v58) );
}
else
{
v59 = *((_DWORD *)v83 - 2);
*((_DWORD *)v83 - 2) = v59 - 1;
}
if ( v59 <= 0 )
operator delete(v23);
}
v22->setScale(v22, 0.4);
a1->m_mainLayer->addChild(a1->m_mainLayer, v22);
v24 = v22->setPosition;
cocos2d::CCPoint::CCPoint(&v85.origin, v75 * 0.5, (float)(v76 * 0.5) + -20.0);
v24(v22, &v85.origin);
a1->m_joystickConnected = -1;
v25 = cocos2d::CCMenu::create();
m_mainLayer = a1->m_mainLayer;
a1->m_buttonMenu = v25;
v27 = (cocos2d::CCArray *)((__int64 (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCMenu *, __int64))m_mainLayer->addChild_0)(
m_mainLayer,
v25,
10);
v28 = (cocos2d::CCArray *)cocos2d::CCArray::create(v27);
v30 = (cocos2d::CCNode *)ButtonSprite::create(
(ButtonSprite *)"Cancel",
(const char *)&dword_30 + 2,
0,
1,
0.6,
"bigFont.fnt",
"GJ_button_06.png",
v29,
30.0);
v87.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v87.adj = (size_t)PurchaseItemPopup::onClose;
v31 = CCMenuItemSpriteExtra::create(v30, nullptr, v87);
a1->m_buttonMenu->addChild(a1->m_buttonMenu, v31);
cocos2d::CCArray::addObject(v28, v31);
v33 = (cocos2d::CCNode *)ButtonSprite::create(
(ButtonSprite *)"Buy",
(const char *)&dword_30 + 2,
0,
1,
0.6,
"bigFont.fnt",
"GJ_button_01.png",
v32,
30.0);
v88.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v88.adj = (size_t)PurchaseItemPopup::onPurchase;
v34 = CCMenuItemSpriteExtra::create(v33, nullptr, v88);
a1->m_buttonMenu->addChild(a1->m_buttonMenu, v34);
cocos2d::CCArray::addObject(v28, v34);
m_buttonMenu = a1->m_buttonMenu;
v36 = a1->m_mainLayer->getPosition(a1->m_mainLayer);
cocos2d::CCPoint::CCPoint(&v84, v75 * 0.5, (float)((float)((float)(v76 * 0.5) + -95.0) + 22.0) + v36->y);
LODWORD(v89.x) = COERCE_UNSIGNED_INT(cocos2d::CCNode::convertToNodeSpace(m_buttonMenu, &v84).y);
GameToolbox::alignItemsHorisontally(v28, 15.0, v89, (bool)&v85);
if ( v72 )
{
v83 = &byte_124B6C8;
if ( v15 == 16 )
{
v37 = sub_D1798C(
&v83,
"This item lets you customize Practice and Menu music.\n"
"After purchasing this item you will be able to change practice and menu music from the more info page on custom songs.",
180).n128_u64[0];
}
else if ( v15 == 17 )
{
v37 = sub_D1798C(
&v83,
"This item lets you play\n"
"Normal mode music in sync in Practice mode.\n"
"After purchasing this item you will be able to toggle the option in the game menu.",
158).n128_u64[0];
}
if ( (unsigned int)(v15 - 6) <= 9 )
sub_D1798C(
&v83,
"When you activate a path, Stars and Moons you collect will level up your Path.\n"
"You can unlock multiple paths, but only one can be active at a time.",
195,
*(double *)&v37);
v48 = v83;
if ( *((_QWORD *)v83 - 3) )
{
sub_D18D28(&v84);
sub_D18D28(&v85);
v62 = (cocos2d::CCNode *)InfoAlertButton::create(1.0);
v63 = (void *)(*(_QWORD *)&v85.origin - 24LL);
if ( (__int64 *)(*(_QWORD *)&v85.origin - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v69 = (unsigned int *)(*(_QWORD *)&v85.origin - 8LL);
do
v70 = __ldaxr(v69);
while ( __stlxr(v70 - 1, v69) );
}
else
{
v70 = *(_DWORD *)(*(_QWORD *)&v85.origin - 8LL);
*(_DWORD *)(*(_QWORD *)&v85.origin - 8LL) = v70 - 1;
}
if ( v70 <= 0 )
operator delete(v63);
}
v64 = (void *)(*(_QWORD *)&v84 - 24LL);
if ( (__int64 *)(*(_QWORD *)&v84 - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v67 = (unsigned int *)(*(_QWORD *)&v84 - 8LL);
do
v68 = __ldaxr(v67);
while ( __stlxr(v68 - 1, v67) );
}
else
{
v68 = *(_DWORD *)(*(_QWORD *)&v84 - 8LL);
*(_DWORD *)(*(_QWORD *)&v84 - 8LL) = v68 - 1;
}
if ( v68 <= 0 )
operator delete(v64);
}
a1->m_buttonMenu->addChild(a1->m_buttonMenu, v62);
v65 = a1->m_buttonMenu;
v66 = v62->setPosition;
cocos2d::CCPoint::CCPoint(
&v84,
(float)((float)(v9 * 0.5) + (float)(v75 * 0.5)) - 20.0,
(float)((float)(v76 * 0.5) + 95.0) - 18.0);
v86 = cocos2d::CCNode::convertToNodeSpace(v65, &v84);
((void (__fastcall *)(cocos2d::CCNode *, cocos2d::CCRect *, float, float))v66)(v62, &v85, v86.x, v86.y);
v48 = v83;
}
v49 = v48 - 24;
if ( v48 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v50 = (unsigned int *)(v48 - 8);
do
v51 = __ldaxr(v50);
while ( __stlxr(v51 - 1, v50) );
}
else
{
v51 = *((_DWORD *)v48 - 2);
*((_DWORD *)v48 - 2) = v51 - 1;
}
if ( v51 <= 0 )
operator delete(v49);
}
}
v38 = v82 - 24;
if ( v82 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v56 = (unsigned int *)(v82 - 8);
do
v57 = __ldaxr(v56);
while ( __stlxr(v57 - 1, v56) );
}
else
{
v57 = *((_DWORD *)v82 - 2);
*((_DWORD *)v82 - 2) = v57 - 1;
}
if ( v57 <= 0 )
operator delete(v38);
}
v39 = (void *)(v81 - 24);
if ( (__int64 *)(v81 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v54 = (unsigned int *)(v81 - 8);
do
v55 = __ldaxr(v54);
while ( __stlxr(v55 - 1, v54) );
}
else
{
v55 = *(_DWORD *)(v81 - 8);
*(_DWORD *)(v81 - 8) = v55 - 1;
}
if ( v55 <= 0 )
operator delete(v39);
}
v40 = (void *)(v80 - 24);
if ( (__int64 *)(v80 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v52 = (unsigned int *)(v80 - 8);
do
v53 = __ldaxr(v52);
while ( __stlxr(v53 - 1, v52) );
}
else
{
v53 = *(_DWORD *)(v80 - 8);
*(_DWORD *)(v80 - 8) = v53 - 1;
}
if ( v53 <= 0 )
operator delete(v40);
}
v41 = v78 - 24;
if ( v78 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v60 = (unsigned int *)(v78 - 8);
do
v61 = __ldaxr(v60);
while ( __stlxr(v61 - 1, v60) );
}
else
{
v61 = *((_DWORD *)v78 - 2);
*((_DWORD *)v78 - 2) = v61 - 1;
}
if ( v61 <= 0 )
operator delete(v41);
}
v42 = (void *)(v77 - 24);
if ( (__int64 *)(v77 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v43 = (unsigned int *)(v77 - 8);
do
v44 = __ldaxr(v43);
while ( __stlxr(v44 - 1, v43) );
}
else
{
v44 = *(_DWORD *)(v77 - 8);
*(_DWORD *)(v77 - 8) = v44 - 1;
}
if ( v44 <= 0 )
operator delete(v42);
}
return v4;
}