//
// UISaveLoadLayer::init from 0x8d8e94 to 0x8d9358 (1220 bytes)
//
// 2 xrefs:
// > UISaveLoadLayer::create @ 0x8d94f8
// > ??> @ 0x95af0
//
// 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 UISaveLoadLayer::init(UISaveLoadLayer *a1, UIOptionsLayer *a2)
{
bool v4; // w26
char *v6; // x1
void *v7; // x0
void *v8; // x0
cocos2d::CCDirector *v9; // x0
char *v10; // x20
cocos2d::CCString *v11; // x0
ButtonSprite *CString; // x0
const char *v13; // x6
cocos2d::CCNode *v14; // x0
CCMenuItemSpriteExtra *v15; // x21
cocos2d::CCMenu *m_buttonMenu; // x28
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x27
cocos2d::CCString *v18; // x0
ButtonSprite *v19; // x0
const char *v20; // x6
cocos2d::CCNode *v21; // x0
CCMenuItemSpriteExtra *v22; // x21
cocos2d::CCMenu *v23; // x28
void (__fastcall *v24)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x27
void *v25; // x27
unsigned int *v26; // x21
int v27; // w0
unsigned int *v28; // x1
int v29; // w2
unsigned int *v30; // x1
int v31; // w2
__int64 v32; // [xsp+98h] [xbp+98h] BYREF
float v33; // [xsp+A0h] [xbp+A0h]
float v34; // [xsp+A4h] [xbp+A4h]
cocos2d::CCPoint v35; // [xsp+A8h] [xbp+A8h] BYREF
cocos2d::CCPoint v36; // [xsp+B0h] [xbp+B0h] BYREF
cocos2d::CCPoint v37; // [xsp+B8h] [xbp+B8h] BYREF
__int64 v38; // [xsp+C0h] [xbp+C0h] BYREF
cocos2d::CCPoint v39; // 0:kr08_8.8
cocos2d::CCPoint v40; // 0:kr10_8.8
cocos2d::SEL_MenuHandler v41; // 0:x2.16
cocos2d::SEL_MenuHandler v42; // 0:x2.16
v4 = SetupTriggerPopup::init(a1, nullptr, nullptr, 240.0, 220.0, 1);
if ( v4 )
{
a1->m_optionsLayer = a2;
SetupTriggerPopup::preSetup(a1);
if ( a2->m_dual )
v6 = "Save/Load Dual UI";
else
v6 = "Save/Load UI";
sub_D153B8((int)&v32, v6);
sub_D18D28(&v37);
SetupTriggerPopup::addTitle(a1, (std::string)&v37);
v7 = (void *)(*(_QWORD *)&v37 - 24LL);
if ( (__int64 *)(*(_QWORD *)&v37 - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v30 = (unsigned int *)(*(_QWORD *)&v37 - 8LL);
do
v31 = __ldaxr(v30);
while ( __stlxr(v31 - 1, v30) );
}
else
{
v31 = *(_DWORD *)(*(_QWORD *)&v37 - 8LL);
*(_DWORD *)(*(_QWORD *)&v37 - 8LL) = v31 - 1;
}
if ( v31 <= 0 )
operator delete(v7);
}
sub_D153B8((int)&v38, "OK");
SetupTriggerPopup::addCloseButton(a1, (std::string)&v38);
v8 = (void *)(v38 - 24);
if ( (__int64 *)(v38 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v28 = (unsigned int *)(v38 - 8);
do
v29 = __ldaxr(v28);
while ( __stlxr(v29 - 1, v28) );
}
else
{
v29 = *(_DWORD *)(v38 - 8);
*(_DWORD *)(v38 - 8) = v29 - 1;
}
if ( v29 <= 0 )
operator delete(v8);
}
v9 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v9);
cocos2d::CCPoint::CCPoint(&v35, v33 * 0.5, (float)(v34 * 0.5) + 50.0);
v10 = (char *)&dword_0 + 1;
do
{
v11 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"Save %i",
(const char *)(unsigned int)v10);
CString = (ButtonSprite *)cocos2d::CCString::getCString(v11);
v14 = (cocos2d::CCNode *)ButtonSprite::create(
CString,
(const char *)&dword_30 + 2,
0,
1,
0.8,
"goldFont.fnt",
"GJ_button_01.png",
v13,
30.0);
v41.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v41.adj = (size_t)UISaveLoadLayer::onSave;
v15 = CCMenuItemSpriteExtra::create(v14, nullptr, v41);
a1->m_buttonMenu->addChild(a1->m_buttonMenu, v15);
m_buttonMenu = a1->m_buttonMenu;
setPosition = v15->setPosition;
cocos2d::CCPoint::CCPoint(&v36, -40.0, (float)((int)v10 - 1) * -40.0);
cocos2d::CCPoint::operator+(&v37, &v35, &v36);
v39 = cocos2d::CCNode::convertToNodeSpace(m_buttonMenu, &v37);
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64 *, float, float))setPosition)(v15, &v38, v39.x, v39.y);
v15->setTag(v15, (int)v10);
v18 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"Load %i",
(const char *)(unsigned int)v10);
v19 = (ButtonSprite *)cocos2d::CCString::getCString(v18);
v21 = (cocos2d::CCNode *)ButtonSprite::create(
v19,
(const char *)&dword_30 + 2,
0,
1,
0.8,
"goldFont.fnt",
"GJ_button_02.png",
v20,
30.0);
v42.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v42.adj = (size_t)UISaveLoadLayer::onLoad;
v22 = CCMenuItemSpriteExtra::create(v21, nullptr, v42);
a1->m_buttonMenu->addChild(a1->m_buttonMenu, v22);
v23 = a1->m_buttonMenu;
v24 = v22->setPosition;
cocos2d::CCPoint::CCPoint(&v36, 40.0, (float)((int)v10 - 1) * -40.0);
cocos2d::CCPoint::operator+(&v37, &v35, &v36);
v40 = cocos2d::CCNode::convertToNodeSpace(v23, &v37);
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64 *, float, float))v24)(v22, &v38, v40.x, v40.y);
v22->setTag(v22, (int)v10);
LODWORD(v10) = (_DWORD)v10 + 1;
}
while ( (_DWORD)v10 != 4 );
SetupTriggerPopup::postSetup(a1);
v25 = (void *)(v32 - 24);
if ( (__int64 *)(v32 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v26 = (unsigned int *)(v32 - 8);
do
v27 = __ldaxr(v26);
while ( __stlxr(v27 - 1, v26) );
}
else
{
v27 = *(_DWORD *)(v32 - 8);
*(_DWORD *)(v32 - 8) = v27 - 1;
}
if ( v27 <= 0 )
operator delete(v25);
}
}
return v4;
}