//
// PurchaseItemPopup::init from 0x100313140 to 0x100313b5a (2586 bytes)
//
// 1 xrefs:
// > PurchaseItemPopup::create @ 0x100310c45
//
// This function is hookable on this platform (idp: pc, 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 12:28:39 +0000
//
__int64 __fastcall PurchaseItemPopup::init(_QWORD *a1, __int64 a2)
{
unsigned int v3; // eax
unsigned int v4; // r12d
__int64 v5; // rsi
__int64 v6; // rax
__int64 v7; // rbx
__int64 v8; // rbx
int *v9; // rax
__int64 v10; // r15
unsigned int v11; // r12d
__int64 StoreItem; // rbx
int v13; // eax
__int64 v14; // rcx
bool v15; // r12
float v16; // xmm0_4
_BOOL8 v17; // rbx
const char *v18; // rsi
size_t v19; // rdx
char *v20; // rdi
__int64 v21; // rax
const std::string::value_type *CString; // rax
const char *data; // rbx
size_t v24; // rax
size_t v25; // r13
char *v26; // r15
size_t v27; // r12
char *v28; // rbx
__int64 v29; // rax
__int64 v30; // rdi
__int64 v31; // r13
char *v32; // rax
int v33; // r15d
void *v34; // rbx
char *v35; // rax
void *v36; // rbx
__int64 v37; // rbx
__int64 v38; // rax
const std::string::value_type *v39; // rsi
char v40; // cl
__int64 v41; // r15
__int64 v42; // rbx
unsigned int v44; // [rsp+0h] [rbp-160h] BYREF
char v45; // [rsp+8h] [rbp-158h] BYREF
void *v46; // [rsp+18h] [rbp-148h]
__int128 v47; // [rsp+20h] [rbp-140h] BYREF
void *v48; // [rsp+30h] [rbp-130h]
__int128 v49; // [rsp+40h] [rbp-120h] BYREF
void *v50; // [rsp+50h] [rbp-110h]
std::string v51; // [rsp+60h] [rbp-100h] BYREF
__int128 v52; // [rsp+78h] [rbp-E8h] BYREF
void *v53; // [rsp+88h] [rbp-D8h]
double v54; // [rsp+94h] [rbp-CCh] BYREF
float v55; // [rsp+9Ch] [rbp-C4h]
float v56; // [rsp+A0h] [rbp-C0h]
unsigned int v57; // [rsp+A4h] [rbp-BCh]
__int128 __dst; // [rsp+A8h] [rbp-B8h] BYREF
void *v59; // [rsp+B8h] [rbp-A8h]
__int64 v60; // [rsp+C0h] [rbp-A0h]
__int64 v61; // [rsp+C8h] [rbp-98h]
__int128 v62; // [rsp+D0h] [rbp-90h] BYREF
void *__p; // [rsp+E0h] [rbp-80h]
unsigned int v64; // [rsp+ECh] [rbp-74h]
std::string v65; // [rsp+F0h] [rbp-70h] BYREF
__int128 v66; // [rsp+110h] [rbp-50h] BYREF
void *v67; // [rsp+120h] [rbp-40h]
float v68; // [rsp+12Ch] [rbp-34h] BYREF
float v69; // [rsp+130h] [rbp-30h]
unsigned __int8 v70; // [rsp+137h] [rbp-29h]
LODWORD(v66) = 1258291200;
v3 = cocos2d::CCLayerColor::initWithColor(a1, &v66);
v4 = v3;
if ( !(_BYTE)v3 )
return v4;
v70 = v3;
a1[83] = a2;
v60 = a2;
cocos2d::CCObject::retain(a2);
FLAlertLayer::incrementForcePrio(a1);
(*(void (__fastcall **)(_QWORD *, __int64))(*a1 + 1000LL))(a1, 1);
(*(void (__fastcall **)(_QWORD *, __int64))(*a1 + 1072LL))(a1, 1);
v5 = cocos2d::CCDirector::sharedDirector(a1, 1);
cocos2d::CCDirector::getWinSize(&v68, v5);
v6 = cocos2d::CCLayer::create();
a1[73] = v6;
(*(void (__fastcall **)(_QWORD *, __int64))(*a1 + 456LL))(a1, v6);
sub_100278270((__int64)&v66, 0.0, 0.0, (__m128)0x42A00000u, (__m128)0x42A00000u);
v7 = cocos2d::extension::CCScale9Sprite::create_2("GJ_square02.png", &v66);
v56 = flt_100A07F68[*(_DWORD *)(a1[83] + 340LL) - *(_DWORD *)(a1[83] + 344LL) == 11];
sub_100278260((float *)&v66, v56, 190.0);
(*(void (__fastcall **)(__int64, __int128 *))(*(_QWORD *)v7 + 320LL))(v7, &v66);
(*(void (__fastcall **)(_QWORD, __int64, __int64))(*(_QWORD *)a1[73] + 464LL))(a1[73], v7, 0xFFFFFFFFLL);
sub_100278250((float *)&v66, v68 * 0.5, v69 * 0.5);
(*(void (__fastcall **)(__int64, __int128 *))(*(_QWORD *)v7 + 184LL))(v7, &v66);
v8 = cocos2d::CCLabelBMFont::create_3("Buy Item", "bigFont.fnt");
sub_100278250((float *)&v66, v68 * 0.5, (float)((float)(v69 * 0.5) + 95.0) + -16.0);
(*(void (__fastcall **)(__int64, __int128 *))(*(_QWORD *)v8 + 184LL))(v8, &v66);
(*(void (__fastcall **)(_QWORD, __int64))(*(_QWORD *)a1[73] + 456LL))(a1[73], v8);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v8 + 160LL))(v8, 0.60000002);
v9 = (int *)a1[83];
v10 = v9[82] - (__int64)v9[83];
v11 = v9[85] - v9[86];
StoreItem = GJItemIcon::createStoreItem(v11, (unsigned int)(v9[82] - v9[83]), 0, 0xFFFFFF);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)StoreItem + 160LL))(StoreItem, 1.2);
v13 = 0;
LOBYTE(v14) = v11 != 6;
v64 = v11;
v57 = v10 - 6;
v15 = v11 == 12 && (unsigned int)(v10 - 6) < 0xA;
if ( v15 )
{
v16 = flt_100A07FC4[v10 - 6];
}
else
{
LOBYTE(v13) = v14;
v16 = (float)(8 * v13 - 8);
}
*(float *)&v61 = v16;
(*(void (__fastcall **)(_QWORD, __int64, __int64, __int64))(*(_QWORD *)a1[73] + 464LL))(a1[73], StoreItem, 1, v14);
sub_100278250((float *)&v66, v68 * 0.5, (float)((float)(0.5 * v69) + 22.0) + v16);
(*(void (__fastcall **)(__int64, __int128 *))(*(_QWORD *)StoreItem + 184LL))(StoreItem, &v66);
ItemInfoPopup::nameForUnlockType(&v66, (unsigned int)v10, v64);
if ( (v66 & 1) != 0 )
{
sub_10001AD30(&v62, v67, *((unsigned __int64 *)&v66 + 1));
}
else
{
__p = v67;
v62 = v66;
}
if ( (v62 & 1) != 0 )
{
if ( *((_QWORD *)&v62 + 1) < 8u )
goto LABEL_15;
}
else if ( (unsigned __int8)v62 >> 1 < 8uLL )
{
goto LABEL_15;
}
std::operator+(&__dst, "\n", &v62);
if ( (v62 & 1) != 0 )
operator delete(__p);
__p = v59;
v62 = __dst;
LABEL_15:
v17 = *(_DWORD *)(v60 + 364) == 4;
v18 = "Mana Orbs";
if ( *(_DWORD *)(v60 + 364) == 4 )
v18 = "Diamond Shards";
v19 = 5 * v17 + 17;
LOBYTE(__dst) = 2 * v19;
memcpy((char *)&__dst + 1, v18, v19);
*((_BYTE *)&v59 + 5 * v17 + 2) = 0;
GameToolbox::pointsToString(&v45);
*(_WORD *)&v51.__r_.__value_.__l.0 = 0;
v20 = "Do you want to buy this %s\nfor %s %s?";
if ( v15 )
v20 = "Do you want to unlock%s\nfor %s %s?";
v21 = sub_10088E820(v20, v44);
CString = (const std::string::value_type *)cocos2d::CCString::getCString(v21);
std::string::assign(&v51, CString);
if ( (*(_BYTE *)&v51.__r_.__value_.__s.0 & 1) != 0 )
data = v51.__r_.__value_.__l.__data_;
else
data = v51.__r_.__value_.__s.__data_;
v24 = strlen(data);
if ( v24 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
v25 = v24;
v61 = v10;
if ( v24 >= 0x17 )
{
v27 = 26;
if ( (v24 | 7) != 0x17 )
v27 = (v24 | 7) + 1;
v26 = (char *)operator new(v27);
v53 = v26;
*(_QWORD *)&v52 = v27 | 1;
*((_QWORD *)&v52 + 1) = v25;
goto LABEL_29;
}
LOBYTE(v52) = 2 * v24;
v26 = (char *)&v52 + 1;
if ( v24 )
LABEL_29:
memmove(v26, data, v25);
v26[v25] = 0;
sub_100278250((float *)&v65, 0.5, 1.0);
v28 = TextArea::create(&v52, (__int64)"bigFont.fnt", &v65, 0, 0, 1.0, 999.0, 35.0);
if ( (v52 & 1) != 0 )
operator delete(v53);
(*(void (__fastcall **)(char *, float))(*(_QWORD *)v28 + 160LL))(v28, 0.40000001);
(*(void (__fastcall **)(_QWORD, char *))(*(_QWORD *)a1[73] + 456LL))(a1[73], v28);
sub_100278250((float *)&v65, v68 * 0.5, (float)(v69 * 0.5) + -20.0);
(*(void (__fastcall **)(char *, std::string *))(*(_QWORD *)v28 + 184LL))(v28, &v65);
*((_DWORD *)a1 + 160) = -1;
v29 = cocos2d::CCMenu::create();
a1[69] = v29;
v30 = a1[73];
(*(void (__fastcall **)(__int64, __int64, __int64))(*(_QWORD *)v30 + 464LL))(v30, v29, 10);
v31 = sub_1007FE900(v30);
v32 = ButtonSprite::create_1(
(__int64)"Cancel",
0x32u,
0,
1u,
(__int64)"bigFont.fnt",
(__int64)"GJ_button_06.png",
0.60000002,
30.0);
v4 = v70;
v33 = v61;
v34 = CCMenuItemSpriteExtra::create((__int64)v32, 0, (__int64)a1, (__int64)PurchaseItemPopup::onClose, 0);
(*(void (__fastcall **)(_QWORD, void *))(*(_QWORD *)a1[69] + 456LL))(a1[69], v34);
sub_1007FEBF0(v31, v34);
v35 = ButtonSprite::create_1(
(__int64)"Buy",
0x32u,
0,
1u,
(__int64)"bigFont.fnt",
(__int64)"GJ_button_01.png",
0.60000002,
30.0);
v36 = CCMenuItemSpriteExtra::create((__int64)v35, 0, (__int64)a1, (__int64)PurchaseItemPopup::onPurchase, 0);
(*(void (__fastcall **)(_QWORD, void *))(*(_QWORD *)a1[69] + 456LL))(a1[69], v36);
sub_1007FEBF0(v31, v36);
v37 = a1[69];
v55 = v68;
*(float *)&v60 = v69;
v38 = (*(__int64 (__fastcall **)(_QWORD))(*(_QWORD *)a1[73] + 192LL))(a1[73]);
sub_100278250(
(float *)&v54,
v55 * 0.5,
(float)((float)((float)(*(float *)&v60 * 0.5) + -95.0) + 22.0) + *(float *)(v38 + 4));
cocos2d::CCNode::convertToNodeSpace((double *)&v65, v37, (unsigned int *)&v54);
GameToolbox::alignItemsHorisontally(v31, &v65, 0, 15.0);
if ( v64 == 12 )
{
memset(&v65, 0, sizeof(v65));
if ( v33 == 16 )
{
v39 = "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 ( v33 == 17 )
{
v39 = "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.";
}
else
{
if ( v57 > 9 )
goto LABEL_40;
v39 = "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.";
}
std::string::assign(&v65, v39);
LABEL_40:
v40 = *(_BYTE *)&v65.__r_.__value_.__s.0 & 1;
if ( (*(_BYTE *)&v65.__r_.__value_.__s.0 & 1) != 0 )
{
if ( !v65.__r_.__value_.__l.__size_ )
{
LABEL_54:
if ( v40 )
operator delete(v65.__r_.__value_.__l.__data_);
goto LABEL_56;
}
}
else if ( !(*(_BYTE *)&v65.__r_.__value_.__l.0 >> 1) )
{
goto LABEL_54;
}
if ( (v66 & 1) != 0 )
{
sub_10001AD30(&v47, v67, *((unsigned __int64 *)&v66 + 1));
if ( (*(_BYTE *)&v65.__r_.__value_.__s.0 & 1) == 0 )
goto LABEL_46;
}
else
{
v48 = v67;
v47 = v66;
if ( (*(_BYTE *)&v65.__r_.__value_.__s.0 & 1) == 0 )
{
LABEL_46:
v50 = v65.__r_.__value_.__l.__data_;
v49 = *(_OWORD *)&v65.__r_.__value_.__l.0;
LABEL_49:
v41 = InfoAlertButton::create(&v47, &v49, 1.0);
if ( (v49 & 1) != 0 )
operator delete(v50);
if ( (v47 & 1) != 0 )
operator delete(v48);
(*(void (__fastcall **)(_QWORD, __int64))(*(_QWORD *)a1[69] + 456LL))(a1[69], v41);
v42 = a1[69];
sub_100278250(
(float *)&v44,
(float)((float)(v56 * 0.5) + (float)(v68 * 0.5)) + -20.0,
(float)((float)(0.5 * v69) + 95.0) + -18.0);
cocos2d::CCNode::convertToNodeSpace(&v54, v42, &v44);
(*(void (__fastcall **)(__int64, double *))(*(_QWORD *)v41 + 184LL))(v41, &v54);
v40 = *(_BYTE *)&v65.__r_.__value_.__s.0 & 1;
goto LABEL_54;
}
}
sub_10001AD30(&v49, v65.__r_.__value_.__l.__data_, v65.__r_.__value_.__l.__size_);
goto LABEL_49;
}
LABEL_56:
if ( (*(_BYTE *)&v51.__r_.__value_.__s.0 & 1) != 0 )
{
operator delete(v51.__r_.__value_.__l.__data_);
if ( (v45 & 1) == 0 )
{
LABEL_58:
if ( (__dst & 1) == 0 )
goto LABEL_59;
goto LABEL_65;
}
}
else if ( (v45 & 1) == 0 )
{
goto LABEL_58;
}
operator delete(v46);
if ( (__dst & 1) == 0 )
{
LABEL_59:
if ( (v62 & 1) == 0 )
goto LABEL_60;
LABEL_66:
operator delete(__p);
if ( (v66 & 1) == 0 )
return v4;
goto LABEL_61;
}
LABEL_65:
operator delete(v59);
if ( (v62 & 1) != 0 )
goto LABEL_66;
LABEL_60:
if ( (v66 & 1) != 0 )
LABEL_61:
operator delete(v67);
return v4;
}