//
// SetupArtSwitchPopup::init from 0x1005858e0 to 0x100585cd3 (1011 bytes)
//
// 1 xrefs:
// > SetupArtSwitchPopup::create @ 0x10058589a
//
// 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 SetupArtSwitchPopup::init(
SetupArtSwitchPopup *a1,
ArtTriggerGameObject *a2,
cocos2d::CCArray *a3,
int a4)
{
bool v6; // bl
double v7; // xmm0_8
const std::string::value_type *v8; // rsi
const char *data; // rdi
cocos2d::CCLabelBMFont *v10; // r15
const char *v11; // rdi
cocos2d::CCSprite *m_artSprite; // rax
CCMenuItemSpriteExtra *v13; // r15
unsigned __int64 v15; // [rsp+0h] [rbp-F0h] BYREF
char v16; // [rsp+8h] [rbp-E8h] BYREF
char v17[15]; // [rsp+9h] [rbp-E7h] BYREF
void *v18; // [rsp+18h] [rbp-D8h]
char v19; // [rsp+20h] [rbp-D0h] BYREF
char v20[15]; // [rsp+21h] [rbp-CFh] BYREF
void *v21; // [rsp+30h] [rbp-C0h]
__int128 v22; // [rsp+38h] [rbp-B8h] BYREF
void *v23; // [rsp+48h] [rbp-A8h]
__int128 v24; // [rsp+50h] [rbp-A0h] BYREF
void *__p; // [rsp+60h] [rbp-90h]
float v26[2]; // [rsp+70h] [rbp-80h] BYREF
unsigned __int64 v27; // [rsp+78h] [rbp-78h] BYREF
std::string v28; // [rsp+80h] [rbp-70h] BYREF
float v29; // [rsp+A4h] [rbp-4Ch]
double v30[2]; // [rsp+A8h] [rbp-48h] BYREF
void *v31; // [rsp+B8h] [rbp-38h]
std::string v32; // [rsp+C0h] [rbp-30h] BYREF
double v33; // 0:xmm0_8.8
v6 = SetupTriggerPopup::init(a1, a2, a3, 300.0, 200.0, 1);
if ( v6 )
{
HIDWORD(v7) = 0;
memset(&v32, 0, sizeof(v32));
memset(&v28, 0, sizeof(v28));
*(float *)&v7 = ((float (__fastcall *)(SetupArtSwitchPopup *, __int64))a1->getValue)(a1, 533);
v29 = *(float *)&v7;
switch ( a4 )
{
case 3029:
a1->m_artType = Background;
std::string::assign(&v32, "Change Background");
v8 = "BG:";
break;
case 3030:
a1->m_artType = Ground;
std::string::assign(&v32, "Change Ground");
v8 = "G:";
break;
case 3031:
a1->m_artType = Middleground;
std::string::assign(&v32, "Change Middleground");
v8 = "MG:";
break;
default:
a1->m_artType = Background;
std::string::assign(&v32, "NA");
v8 = "NA:";
break;
}
std::string::assign(&v28, v8);
SetupTriggerPopup::preSetup(a1);
if ( (*(_BYTE *)&v32.__r_.__value_.__s.0 & 1) != 0 )
{
sub_100006B70(&v24, v32.__r_.__value_.__l.__data_, v32.__r_.__value_.__l.__size_, v7);
}
else
{
__p = v32.__r_.__value_.__l.__data_;
v24 = *(_OWORD *)&v32.__r_.__value_.__l.0;
}
SetupTriggerPopup::addTitle((__int64)a1, (__int64)&v24);
if ( (v24 & 1) != 0 )
operator delete(__p);
v16 = 4;
strcpy(v17, "OK");
SetupTriggerPopup::addCloseButton((__int64)a1, (__int64)&v16);
if ( (v16 & 1) != 0 )
operator delete(v18);
v19 = 8;
strcpy(v20, "Help");
v23 = operator new(0x40u);
*(_QWORD *)&v22 = 65;
*((_QWORD *)&v22 + 1) = 62;
strcpy((char *)v23, "Seems pretty obvious what this does.\nWhy are you here?");
SetupTriggerPopup::addHelpButton((__int64)a1, (__int64)&v19, &v22, (__m128)0x3F800000u);
if ( (v22 & 1) != 0 )
operator delete(v23);
if ( (v19 & 1) != 0 )
operator delete(v21);
SetupTriggerPopup::createMultiTriggerItemsDefault(a1);
cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize((cocos2d::CCDirector *)v26);
sub_10028CBE0((float *)&v27, v26[0] * 0.5, 0.5 * v26[1]);
if ( (*(_BYTE *)&v28.__r_.__value_.__s.0 & 1) != 0 )
data = v28.__r_.__value_.__l.__data_;
else
data = v28.__r_.__value_.__s.__data_;
v10 = cocos2d::CCLabelBMFont::create_3(data, "goldFont.fnt");
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float))v10->setScale)(v10, 0.60000002);
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCLabelBMFont *))a1->m_mainLayer->addChild)(a1->m_mainLayer, v10);
sub_10028CBE0((float *)&v15, 0.0, 40.0);
sub_10028CCE0(v30, &v27, &v15);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, double *))v10->setPosition)(v10, v30);
sub_100585DA0(v30, (unsigned int)(int)v29, (unsigned int)a1->m_artType);
if ( (LOBYTE(v30[0]) & 1) != 0 )
v11 = (const char *)v31;
else
v11 = (char *)v30 + 1;
m_artSprite = cocos2d::CCSprite::createWithSpriteFrameName(v11);
a1->m_artSprite = m_artSprite;
if ( (LOBYTE(v30[0]) & 1) != 0 )
{
operator delete(v31);
m_artSprite = a1->m_artSprite;
}
v13 = CCMenuItemSpriteExtra::create(
m_artSprite,
nullptr,
a1,
(cocos2d::SEL_MenuHandler)(unsigned __int64)SetupArtSwitchPopup::onArt);
((void (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild)(a1->m_buttonMenu, v13);
*(cocos2d::CCPoint *)&v33 = cocos2d::CCNode::convertToNodeSpace(
(cocos2d::CCNode *)v30,
(const cocos2d::CCPoint *)a1->m_buttonMenu);
((void (__fastcall *)(CCMenuItemSpriteExtra *, double *, double))v13->setPosition)(v13, v30, v33);
SetupTriggerPopup::postSetup(a1);
if ( (*(_BYTE *)&v28.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v28.__r_.__value_.__l.__data_);
if ( (*(_BYTE *)&v32.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v32.__r_.__value_.__l.__data_);
}
return v6;
}