//
// PurchaseItemPopup::init from 0xa8093c to 0xa81434 (2808 bytes)
//
// 2 xrefs:
// > PurchaseItemPopup::create @ 0xa81594
// > ??> @ 0x7c450
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 13:00:32 +0000
//
__int64 __fastcall PurchaseItemPopup::init(PurchaseItemPopup *this, GJStoreItem *a2)
{
unsigned __int8 v4; // w0
unsigned int v5; // w22
cocos2d::CCDirector *v7; // x0
cocos2d::CCDirector *v8; // x0
cocos2d::CCLayer *WinSize; // x0
__int64 v10; // x0
__int64 v11; // x23
float v12; // s10
void (__fastcall *v13)(__int64, __int64 *); // x25
void (__fastcall *v14)(__int64, __int64 *); // x25
const char *v15; // x2
__int64 v16; // x23
void (__fastcall *v17)(__int64, __int64 *); // x25
_DWORD *v18; // x25
int v19; // w23
int v20; // w26
__int64 StoreItem; // x27
float v22; // s9
unsigned __int64 v23; // x1
const char *v24; // x1
size_t v25; // x0
char *v26; // x1
char *v27; // x2
char *v28; // x3
cocos2d::CCString *v29; // x0
char *CString; // x0
const char *v31; // x1
size_t v32; // x0
__int64 v33; // x24
void (__fastcall *v34)(__int64, __int64 *); // x27
__int64 v35; // x0
__int64 v36; // x3
cocos2d::CCArray *v37; // x0
cocos2d::CCArray *v38; // x24
const char *v39; // x6
__int64 v40; // x0
cocos2d::CCObject *v41; // x27
const char *v42; // x6
__int64 v43; // x0
cocos2d::CCObject *v44; // x27
cocos2d::CCNode *v45; // x27
float v46; // s9
float v47; // s8
__int64 v48; // x0
char *v49; // x1
char *v50; // x2
char *v51; // x3
int v52; // w1
__int64 v53; // x27
cocos2d::CCNode *v54; // x23
void (__fastcall *v55)(__int64, __int64 *); // x24
void (__fastcall *v56)(__int64, __int64 *); // [xsp+88h] [xbp+88h]
char *v57; // [xsp+88h] [xbp+88h]
_BOOL4 v58; // [xsp+94h] [xbp+94h]
int v59; // [xsp+98h] [xbp+98h]
char *v60; // [xsp+98h] [xbp+98h]
__int64 v61; // [xsp+A0h] [xbp+A0h] BYREF
_BYTE v62[8]; // [xsp+A8h] [xbp+A8h] BYREF
__int64 v63[2]; // [xsp+B0h] [xbp+B0h] BYREF
unsigned __int64 v64; // [xsp+C0h] [xbp+C0h] BYREF
size_t v65; // [xsp+C8h] [xbp+C8h]
void *v66; // [xsp+D0h] [xbp+D0h]
unsigned __int64 v67; // [xsp+D8h] [xbp+D8h] BYREF
unsigned __int64 v68; // [xsp+E0h] [xbp+E0h]
char *v69; // [xsp+E8h] [xbp+E8h]
unsigned __int64 v70[3]; // [xsp+F0h] [xbp+F0h] BYREF
__int64 v71[2]; // [xsp+108h] [xbp+108h] BYREF
void *v72; // [xsp+118h] [xbp+118h]
unsigned __int64 v73[2]; // [xsp+120h] [xbp+120h] BYREF
void *v74; // [xsp+130h] [xbp+130h]
__int64 v75[2]; // [xsp+138h] [xbp+138h] BYREF
void *v76; // [xsp+148h] [xbp+148h]
__int64 v77; // [xsp+150h] [xbp+150h] BYREF
size_t v78; // [xsp+158h] [xbp+158h]
void *v79; // [xsp+160h] [xbp+160h]
unsigned __int64 v80; // [xsp+168h] [xbp+168h] BYREF
size_t v81; // [xsp+170h] [xbp+170h]
void *v82; // [xsp+178h] [xbp+178h]
__int64 v83; // [xsp+180h] [xbp+180h] BYREF
size_t v84; // [xsp+188h] [xbp+188h]
void *v85; // [xsp+190h] [xbp+190h]
LODWORD(v63[0]) = 1258291200;
v4 = cocos2d::CCLayerColor::initWithColor(this, v63);
v5 = v4;
if ( !v4 )
return v5;
*((_QWORD *)this + 83) = a2;
cocos2d::CCObject::retain(a2);
FLAlertLayer::incrementForcePrio(this);
(*(void (__fastcall **)(PurchaseItemPopup *, __int64))(*(_QWORD *)this + 1000LL))(this, 1);
v7 = (cocos2d::CCDirector *)(*(__int64 (__fastcall **)(PurchaseItemPopup *, __int64))(*(_QWORD *)this + 1072LL))(
this,
1);
v8 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v7);
WinSize = (cocos2d::CCLayer *)cocos2d::CCDirector::getWinSize(&v61, v8);
v10 = cocos2d::CCLayer::create(WinSize);
*((_QWORD *)this + 73) = v10;
(*(void (__fastcall **)(PurchaseItemPopup *, __int64))(*(_QWORD *)this + 456LL))(this, v10);
cocos2d::CCRect::CCRect((cocos2d::CCRect *)v63, 0.0, 0.0, 80.0, 80.0);
v11 = cocos2d::extension::CCScale9Sprite::create("GJ_square02.png", v63);
if ( *(_DWORD *)(*((_QWORD *)this + 83) + 340LL) - *(_DWORD *)(*((_QWORD *)this + 83) + 344LL) == 11 )
v12 = 280.0;
else
v12 = 260.0;
v13 = *(void (__fastcall **)(__int64, __int64 *))(*(_QWORD *)v11 + 320LL);
cocos2d::CCSize::CCSize((cocos2d::CCSize *)v63, v12, 190.0);
v13(v11, v63);
(*(void (__fastcall **)(_QWORD, __int64, __int64))(**((_QWORD **)this + 73) + 464LL))(
*((_QWORD *)this + 73),
v11,
0xFFFFFFFFLL);
v14 = *(void (__fastcall **)(__int64, __int64 *))(*(_QWORD *)v11 + 184LL);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v63, *(float *)&v61 * 0.5, *((float *)&v61 + 1) * 0.5);
v14(v11, v63);
v16 = cocos2d::CCLabelBMFont::create((cocos2d::CCLabelBMFont *)"Buy Item", "bigFont.fnt", v15);
v17 = *(void (__fastcall **)(__int64, __int64 *))(*(_QWORD *)v16 + 184LL);
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)v63,
*(float *)&v61 * 0.5,
(float)((float)(*((float *)&v61 + 1) * 0.5) + 95.0) - 16.0);
v17(v16, v63);
(*(void (__fastcall **)(_QWORD, __int64))(**((_QWORD **)this + 73) + 456LL))(*((_QWORD *)this + 73), v16);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v16 + 160LL))(v16, 0.6);
v18 = *((_DWORD **)this + 83);
v19 = v18[82] - v18[83];
v20 = v18[85] - v18[86];
StoreItem = GJItemIcon::createStoreItem(v20, v19, 0);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)StoreItem + 160LL))(StoreItem, 1.2);
if ( v20 == 6 )
{
v58 = 0;
v22 = -8.0;
goto LABEL_10;
}
v58 = v20 == 12 && (unsigned int)(v19 - 6) <= 9;
if ( v20 != 12 || (unsigned int)(v19 - 6) > 9 )
{
v22 = 0.0;
v58 = v20 == 12;
LABEL_10:
v59 = 0;
goto LABEL_11;
}
switch ( v19 )
{
case 7:
v59 = 1;
v22 = 12.0;
break;
case 8:
case 10:
case 12:
v59 = 1;
v22 = 15.0;
break;
case 9:
case 13:
case 14:
case 15:
v59 = 1;
v22 = 10.0;
break;
case 11:
v59 = 1;
v22 = 5.0;
break;
default:
v59 = 1;
v22 = 0.0;
break;
}
LABEL_11:
(*(void (__fastcall **)(_QWORD, __int64, __int64))(**((_QWORD **)this + 73) + 464LL))(
*((_QWORD *)this + 73),
StoreItem,
1);
v56 = *(void (__fastcall **)(__int64, __int64 *))(*(_QWORD *)StoreItem + 184LL);
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)v63,
*(float *)&v61 * 0.5,
(float)((float)(*((float *)&v61 + 1) * 0.5) + 22.0) + v22);
v56(StoreItem, v63);
ItemInfoPopup::nameForUnlockType(v19, v20, (__int64 *)&v64);
v67 = 0;
v68 = 0;
v69 = nullptr;
if ( (v64 & 1) != 0 )
{
std::string::__init((__int64 *)&v67, v66, v65);
}
else
{
v69 = (char *)v66;
v67 = v64;
v68 = v65;
}
v23 = (unsigned __int8)v67 >> 1;
if ( (v67 & 1) != 0 )
v23 = v68;
if ( v23 > 7 )
{
std::operator+(&byte_11AAA48, (__int64)&v67, v70);
if ( (v67 & 1) != 0 )
{
*v69 = 0;
v68 = 0;
}
else
{
LOWORD(v67) = 0;
}
std::string::reserve((__int64 *)&v67, 0);
v69 = (char *)v70[2];
v67 = v70[0];
v68 = v70[1];
if ( *((_DWORD *)a2 + 91) != 4 )
goto LABEL_17;
}
else if ( *((_DWORD *)a2 + 91) != 4 )
{
LABEL_17:
v24 = "Mana Orbs";
goto LABEL_18;
}
v24 = "Diamond Shards";
LABEL_18:
v57 = (char *)v24;
v71[0] = 0;
v71[1] = 0;
v72 = nullptr;
v25 = strlen(v24);
std::string::__init(v71, v57, v25);
GameToolbox::pointsToString(
(GameToolbox *)(unsigned int)(*(_DWORD *)(*((_QWORD *)this + 83) + 352LL)
- *(_DWORD *)(*((_QWORD *)this + 83) + 356LL)),
v73);
v75[0] = 0;
v75[1] = 0;
v76 = nullptr;
std::string::__init(v75, &byte_11B8890, 0);
if ( v59 )
{
v26 = (char *)&v67 + 1;
if ( (v67 & 1) != 0 )
v26 = v69;
v27 = (char *)v73 + 1;
if ( (v73[0] & 1) != 0 )
v27 = (char *)v74;
v28 = (char *)v71 + 1;
if ( (v71[0] & 1) != 0 )
v28 = (char *)v72;
v29 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"Do you want to unlock%s\nfor %s %s?",
v26,
v27,
v28);
}
else
{
v49 = (char *)&v67 + 1;
if ( (v67 & 1) != 0 )
v49 = v69;
v50 = (char *)v73 + 1;
if ( (v73[0] & 1) != 0 )
v50 = (char *)v74;
v51 = (char *)v71 + 1;
if ( (v71[0] & 1) != 0 )
v51 = (char *)v72;
v29 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"Do you want to buy this %s\nfor %s %s?",
v49,
v50,
v51);
}
CString = (char *)cocos2d::CCString::getCString(v29);
std::string::assign(v75, CString);
v31 = (char *)v75 + 1;
if ( (v75[0] & 1) != 0 )
v31 = (const char *)v76;
v60 = (char *)v31;
v77 = 0;
v78 = 0;
v79 = nullptr;
v32 = strlen(v31);
std::string::__init(&v77, v60, v32);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v63, 0.5, 1.0);
v33 = TextArea::create((char *)&v77, "bigFont.fnt", (const cocos2d::CCPoint *)v63, 0, 0, 1.0, 999.0, 35.0);
if ( (v77 & 1) != 0 )
operator delete(v79);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v33 + 160LL))(v33, 0.4);
(*(void (__fastcall **)(_QWORD, __int64))(**((_QWORD **)this + 73) + 456LL))(*((_QWORD *)this + 73), v33);
v34 = *(void (__fastcall **)(__int64, __int64 *))(*(_QWORD *)v33 + 184LL);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v63, *(float *)&v61 * 0.5, (float)(*((float *)&v61 + 1) * 0.5) + -20.0);
v34(v33, v63);
*((_DWORD *)this + 160) = -1;
v35 = cocos2d::CCMenu::create((cocos2d::CCMenu *)0xFFFFFFFFLL);
v36 = *((_QWORD *)this + 73);
*((_QWORD *)this + 69) = v35;
v37 = (cocos2d::CCArray *)(*(__int64 (__fastcall **)(__int64, __int64, __int64))(*(_QWORD *)v36 + 464LL))(
v36,
v35,
10);
v38 = (cocos2d::CCArray *)cocos2d::CCArray::create(v37);
v40 = ButtonSprite::create(
(ButtonSprite *)"Cancel",
(const char *)&dword_30 + 2,
0,
1,
0.6,
"bigFont.fnt",
"GJ_button_06.png",
v39,
30.0);
v41 = (cocos2d::CCObject *)CCMenuItemSpriteExtra::create(
v40,
0,
(__int64)this,
(__int64)PurchaseItemPopup::onClose,
0);
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**((_QWORD **)this + 69) + 456LL))(*((_QWORD *)this + 69), v41);
cocos2d::CCArray::addObject(v38, v41);
v43 = ButtonSprite::create(
(ButtonSprite *)"Buy",
(const char *)&dword_30 + 2,
0,
1,
0.6,
"bigFont.fnt",
"GJ_button_01.png",
v42,
30.0);
v44 = (cocos2d::CCObject *)CCMenuItemSpriteExtra::create(
v43,
0,
(__int64)this,
(__int64)PurchaseItemPopup::onPurchase,
0);
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**((_QWORD **)this + 69) + 456LL))(*((_QWORD *)this + 69), v44);
cocos2d::CCArray::addObject(v38, v44);
v45 = *((cocos2d::CCNode **)this + 69);
v46 = *(float *)&v61 * 0.5;
v47 = (float)((float)(*((float *)&v61 + 1) * 0.5) + -95.0) + 22.0;
v48 = (*(__int64 (__fastcall **)(_QWORD))(**((_QWORD **)this + 73) + 192LL))(*((_QWORD *)this + 73));
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v62, v46, v47 + *(float *)(v48 + 4));
cocos2d::CCNode::convertToNodeSpace(v63, v45, (const cocos2d::CCPoint *)v62);
GameToolbox::alignItemsHorisontally((__int64)v38, (__int64)v63, 0, 15.0);
if ( v58 )
{
v77 = 0;
v78 = 0;
v79 = nullptr;
if ( v19 == 16 )
{
std::string::assign(
&v77,
"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.");
}
else if ( v19 == 17 )
{
std::string::assign(
&v77,
"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.");
}
if ( (unsigned int)(v19 - 6) <= 9 )
std::string::assign(
&v77,
"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.");
v52 = v77 & 1;
if ( v52 )
{
if ( !v78 )
goto LABEL_69;
}
else if ( !((int)(unsigned __int8)v77 >> 1) )
{
goto LABEL_31;
}
v80 = 0;
v81 = 0;
v82 = nullptr;
if ( (v64 & 1) != 0 )
{
std::string::__init((__int64 *)&v80, v66, v65);
v52 = v77 & 1;
}
else
{
v82 = v66;
v80 = v64;
v81 = v65;
}
v83 = 0;
v84 = 0;
v85 = nullptr;
if ( v52 )
{
std::string::__init(&v83, v79, v78);
}
else
{
v83 = v77;
v84 = v78;
v85 = v79;
}
v53 = InfoAlertButton::create((char *)&v80, (char *)&v83, 1.0);
if ( (v83 & 1) != 0 )
operator delete(v85);
if ( (v80 & 1) != 0 )
operator delete(v82);
(*(void (__fastcall **)(_QWORD, __int64))(**((_QWORD **)this + 69) + 456LL))(*((_QWORD *)this + 69), v53);
v54 = *((cocos2d::CCNode **)this + 69);
v55 = *(void (__fastcall **)(__int64, __int64 *))(*(_QWORD *)v53 + 184LL);
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)v62,
(float)((float)(v12 * 0.5) + (float)(*(float *)&v61 * 0.5)) - 20.0,
(float)((float)(*((float *)&v61 + 1) * 0.5) + 95.0) - 18.0);
cocos2d::CCNode::convertToNodeSpace(v63, v54, (const cocos2d::CCPoint *)v62);
v55(v53, v63);
if ( (v77 & 1) == 0 )
goto LABEL_31;
LABEL_69:
operator delete(v79);
}
LABEL_31:
if ( (v75[0] & 1) != 0 )
operator delete(v76);
if ( (v73[0] & 1) == 0 )
{
if ( (v71[0] & 1) == 0 )
goto LABEL_35;
LABEL_51:
operator delete(v72);
if ( (v67 & 1) == 0 )
goto LABEL_36;
goto LABEL_52;
}
operator delete(v74);
if ( (v71[0] & 1) != 0 )
goto LABEL_51;
LABEL_35:
if ( (v67 & 1) == 0 )
goto LABEL_36;
LABEL_52:
operator delete(v69);
LABEL_36:
if ( (v64 & 1) != 0 )
operator delete(v66);
return v5;
}