//
// UISaveLoadLayer::init from 0x1402a4000 to 0x1402a454e (1358 bytes)
//
// 2 xrefs:
// > UIOptionsLayer::onSaveLoad @ 0x1402a2d7e
// > ??> @ 0x1406d2018
//
// 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
//
// Hidden C++ exception states: #wind=5
bool UISaveLoadLayer::init(UISaveLoadLayer *a1, UIOptionsLayer *a2)
{
bool result; // al
const char *v5; // rdx
size_t v6; // r8
__int64 v7; // rdx
__int64 v8; // rcx
__int64 v9; // r8
__int64 v10; // r9
void **v11; // r14
__int64 v12; // rbx
unsigned __int64 v13; // rdi
__int64 v14; // rcx
cocos2d::CCDirector *v15; // rax
int v16; // r14d
cocos2d::CCString *v17; // rax
const char *CString; // rdi
ButtonSprite *v19; // rbx
CCMenuItemSpriteExtra *v20; // rax
cocos2d::CCObject *v21; // rdi
float v22; // xmm0_4
cocos2d::CCObject_vtbl *v23; // rbx
struct cocos2d::CCPoint v24; // rax
cocos2d::CCString *v25; // rax
const char *v26; // rdi
ButtonSprite *v27; // rbx
CCMenuItemSpriteExtra *v28; // rdi
float v29; // xmm0_4
CCMenuItemSpriteExtra_vtbl *v30; // rbx
struct cocos2d::CCPoint v31; // rax
__int128 v32; // [rsp+50h] [rbp-B0h] BYREF
__int64 v33; // [rsp+60h] [rbp-A0h]
__int64 v34; // [rsp+68h] [rbp-98h]
_BYTE v35[8]; // [rsp+70h] [rbp-90h] BYREF
float v36; // [rsp+78h] [rbp-88h]
_BYTE v37[8]; // [rsp+80h] [rbp-80h] BYREF
_BYTE v38[8]; // [rsp+88h] [rbp-78h] BYREF
ButtonSprite *v39; // [rsp+90h] [rbp-70h]
CCMenuItemSpriteExtra *v40; // [rsp+98h] [rbp-68h]
struct cocos2d::CCPoint v41; // [rsp+A8h] [rbp-58h] BYREF
ButtonSprite *v42; // [rsp+B0h] [rbp-50h]
CCMenuItemSpriteExtra *v43; // [rsp+B8h] [rbp-48h]
struct cocos2d::CCPoint v44; // [rsp+C8h] [rbp-38h] BYREF
void *Src[2]; // [rsp+D0h] [rbp-30h] BYREF
unsigned __int64 v46; // [rsp+E0h] [rbp-20h]
unsigned __int64 v47; // [rsp+E8h] [rbp-18h]
result = SetupTriggerPopup::init(a1, nullptr, nullptr, 240.0, 220.0, 1);
if ( result )
{
a1->m_optionsLayer = a2;
a1->m_disableTextDelegate = 1;
a1->determineStartValues(a1);
v5 = "Save/Load UI";
if ( a2->m_dual )
v5 = "Save/Load Dual UI";
*(_OWORD *)Src = 0;
v46 = 0;
v47 = 0;
v6 = -1;
do
++v6;
while ( v5[v6] );
sub_14003A930(Src, v5, v6);
v32 = 0;
v33 = 0;
v34 = 0;
v11 = Src;
if ( v47 > 0xF )
v11 = (void **)Src[0];
v12 = 0x7FFFFFFFFFFFFFFFLL;
v13 = v46;
if ( v46 > 0x7FFFFFFFFFFFFFFFLL )
sub_140007B50(v8, v7, v9, v10);
v34 = 15;
if ( v46 > 0xF )
{
if ( (v46 | 0xF) <= 0x7FFFFFFFFFFFFFFFLL )
{
v12 = v46 | 0xF;
if ( (v46 | 0xF) < 0x16 )
v12 = 22;
}
*(_QWORD *)&v32 = sub_14003AA10(v12 + 1);
v33 = v13;
v34 = v12;
memcpy((void *)v32, v11, v13 + 1);
}
else
{
v33 = v46;
v32 = *(_OWORD *)v11;
}
SetupTriggerPopup::addTitle(a1, &v32);
v32 = 0;
v33 = 2;
v34 = 15;
strcpy((char *)&v32, "OK");
SetupTriggerPopup::addCloseButton(a1, &v32);
v15 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v14);
cocos2d::CCDirector::getWinSize(v15);
cocos2d::CCPoint::CCPoint(0.0, v36 * 0.5);
v16 = 1;
while ( 1 )
{
v17 = cocos2d::CCString::createWithFormat("Save %i", v16);
CString = cocos2d::CCString::getCString(v17);
v39 = (ButtonSprite *)operator new(0x2C0u);
v19 = ButtonSprite::ButtonSprite(v39);
if ( v19 )
{
if ( ButtonSprite::init_1(v19, CString, 50, 0, 0.80000001, 1, "goldFont.fnt", "GJ_button_01.png", 30.0) )
{
cocos2d::CCObject::autorelease(v19);
}
else
{
((void (__fastcall *)(ButtonSprite *, __int64))v19->~ButtonSprite)(v19, 1);
v19 = nullptr;
}
}
v40 = (CCMenuItemSpriteExtra *)operator new(0x208u);
v20 = CCMenuItemSpriteExtra::CCMenuItemSpriteExtra(v40);
v21 = v20;
if ( v20 )
{
if ( CCMenuItemSpriteExtra::init(v20, v19, nullptr, a1, (cocos2d::SEL_MenuHandler *)UISaveLoadLayer::onSave) )
{
cocos2d::CCObject::autorelease(v21);
goto LABEL_25;
}
((void (__fastcall *)(cocos2d::CCObject *, __int64))v21->~CCObject)(v21, 1);
}
v21 = nullptr;
LABEL_25:
v22 = ((float (__fastcall *)(cocos2d::CCMenu *, cocos2d::CCObject *))a1->m_buttonMenu->addChild_1)(
a1->m_buttonMenu,
v21);
cocos2d::CCPoint::CCPoint(v22, -40.0);
cocos2d::CCPoint::operator+(v37, v38);
v23 = v21->__vftable;
v24 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, &v41);
((void (__fastcall *)(cocos2d::CCObject *, struct cocos2d::CCPoint))v23[2].encodeWithCoder)(v21, v24);
v21->setTag(v21, v16);
v25 = cocos2d::CCString::createWithFormat("Load %i", v16);
v26 = cocos2d::CCString::getCString(v25);
v42 = (ButtonSprite *)operator new(0x2C0u);
v27 = ButtonSprite::ButtonSprite(v42);
if ( v27 )
{
if ( ButtonSprite::init_1(v27, v26, 50, 0, 0.80000001, 1, "goldFont.fnt", "GJ_button_02.png", 30.0) )
{
cocos2d::CCObject::autorelease(v27);
}
else
{
((void (__fastcall *)(ButtonSprite *, __int64))v27->~ButtonSprite)(v27, 1);
v27 = nullptr;
}
}
v43 = (CCMenuItemSpriteExtra *)operator new(0x208u);
v28 = CCMenuItemSpriteExtra::CCMenuItemSpriteExtra(v43);
if ( !v28 )
goto LABEL_33;
if ( !CCMenuItemSpriteExtra::init(v28, v27, nullptr, a1, (cocos2d::SEL_MenuHandler *)UISaveLoadLayer::onLoad) )
{
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64))v28->~CCMenuItemSpriteExtra)(v28, 1);
LABEL_33:
v28 = nullptr;
goto LABEL_34;
}
cocos2d::CCObject::autorelease(v28);
LABEL_34:
v29 = ((float (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild_1)(
a1->m_buttonMenu,
v28);
cocos2d::CCPoint::CCPoint(v29, 40.0);
cocos2d::CCPoint::operator+(v37, v35);
v30 = v28->cocos2d::CCMenuItemSprite::cocos2d::CCMenuItem::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v31 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, &v44);
((void (__fastcall *)(CCMenuItemSpriteExtra *, struct cocos2d::CCPoint))v30->setPosition_0)(v28, v31);
v28->setTag(v28, v16++);
if ( v16 > 3 )
{
a1->updateDefaultTriggerValues(a1);
a1->m_disableTextDelegate = 0;
sub_14003A830((__int64)Src);
return 1;
}
}
}
return result;
}