//
// AutoBackupOptionsPopup::init from 0x1400cda10 to 0x1400ce269 (2137 bytes)
//
// 2 xrefs:
// > AutoSaveSettingsLayer::onAdvanced @ 0x14009d35b
// > ??> @ 0x140914114
//
// 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 11:26:24 +0000
//
// Hidden C++ exception states: #wind=6
char __fastcall AutoBackupOptionsPopup::init(__int64 a1, __int64 a2, __int64 a3, int a4)
{
char result; // al
__int64 v6; // rcx
__int64 v7; // rax
float v8; // xmm8_4
float v9; // xmm7_4
char *v10; // r15
_OWORD *v11; // rax
char *v12; // rdx
__int64 v13; // r8
__int64 *v14; // rsi
__int64 v15; // rdi
__int64 v16; // rbx
__int64 v17; // rax
__int64 v18; // rax
__int64 v19; // rax
struct cocos2d::CCLabelBMFont *v20; // rax
__int64 v21; // rdi
__int64 v22; // rbx
__int64 v23; // rax
float v24; // xmm11_4
cocos2d::CCObject *v25; // rbx
cocos2d::CCObject *v26; // rsi
__int64 v27; // rdi
__int64 v28; // rbx
__int64 v29; // rax
__int64 v30; // rax
cocos2d::CCObject *v31; // rbx
cocos2d::CCObject *v32; // rsi
__int64 v33; // rdi
__int64 v34; // rbx
__int64 v35; // rax
__int64 v36; // rax
cocos2d::CCObject *v37; // rbx
cocos2d::CCObject *v38; // rsi
__int64 v39; // rdi
__int64 v40; // rbx
__int64 v41; // rax
__int64 v42; // rax
__int64 *v43; // [rsp+58h] [rbp-B0h] BYREF
__int64 v44[3]; // [rsp+60h] [rbp-A8h] BYREF
__int64 v45; // [rsp+78h] [rbp-90h]
__int64 v46; // [rsp+80h] [rbp-88h]
float v47[2]; // [rsp+88h] [rbp-80h] BYREF
__int128 v48; // [rsp+90h] [rbp-78h] BYREF
__int64 v49; // [rsp+A0h] [rbp-68h]
__int64 v50; // [rsp+A8h] [rbp-60h]
__int128 v51; // [rsp+B0h] [rbp-58h]
__int64 v52; // [rsp+C0h] [rbp-48h]
__int64 v53; // [rsp+C8h] [rbp-40h]
int v54; // [rsp+D8h] [rbp-30h] BYREF
void *v55[4]; // [rsp+E0h] [rbp-28h] BYREF
_BYTE v56[8]; // [rsp+100h] [rbp-8h] BYREF
int v57; // [rsp+108h] [rbp+0h]
char v58; // [rsp+10Ch] [rbp+4h]
int v59; // [rsp+110h] [rbp+8h]
int v60; // [rsp+114h] [rbp+Ch]
char v61; // [rsp+118h] [rbp+10h]
int v62; // [rsp+11Ch] [rbp+14h]
int v63; // [rsp+120h] [rbp+18h]
char v64; // [rsp+135h] [rbp+2Dh]
_BYTE v65[32]; // [rsp+140h] [rbp+38h] BYREF
int v66; // [rsp+160h] [rbp+58h]
_BYTE v67[32]; // [rsp+168h] [rbp+60h] BYREF
*(_QWORD *)(a1 + 1008) = a2;
result = SetupTriggerPopup::init(a1, 0, 0, a4, 1130102784, 1, 0);
if ( result )
{
*(_BYTE *)(a1 + 744) = 1;
(*(void (__fastcall **)(__int64))(*(_QWORD *)a1 + 1096LL))(a1);
v7 = cocos2d::CCDirector::sharedDirector(v6);
cocos2d::CCDirector::getWinSize(v7, v47);
v8 = v47[0] * 0.5;
v9 = v47[1] * 0.5;
*(_OWORD *)&v44[1] = 0;
v44[1] = (__int64)sub_14003D460(0x20u);
v45 = 19;
v46 = 31;
strcpy((char *)v44[1], "Auto-Backup Options");
SetupTriggerPopup::addTitle(a1, &v44[1]);
v51 = 0;
v10 = (char *)sub_14003D460(0x100u);
*(_QWORD *)&v51 = v10;
v52 = 255;
v53 = 255;
strcpy(
v10,
"Max per level: number of backups kept for each level. When the limit is reached, the oldest is deleted whe"
"n a new backup is created. 0 = unlimited.\n"
"\n"
"Prune Now: applies the current limit immediately.\n"
"Delete All: deletes all backups.");
v43 = &v44[1];
*(_OWORD *)&v44[1] = 0;
v45 = 0;
v46 = 0;
v11 = sub_14003D460(0x100u);
v44[1] = (__int64)v11;
v45 = 255;
v46 = 255;
v12 = v10;
v13 = 2;
do
{
*v11 = *(_OWORD *)v12;
v11[1] = *((_OWORD *)v12 + 1);
v11[2] = *((_OWORD *)v12 + 2);
v11[3] = *((_OWORD *)v12 + 3);
v11[4] = *((_OWORD *)v12 + 4);
v11[5] = *((_OWORD *)v12 + 5);
v11[6] = *((_OWORD *)v12 + 6);
v11 += 8;
*(v11 - 1) = *((_OWORD *)v12 + 7);
v12 += 128;
--v13;
}
while ( v13 );
v48 = 0;
v49 = 0;
v50 = 0;
*(_QWORD *)&v48 = sub_14003D460(0x20u);
v49 = 19;
v50 = 31;
strcpy((char *)v48, "Auto-Backup Options");
v14 = (__int64 *)InfoAlertButton::create(&v48, &v44[1]);
(*(void (__fastcall **)(_QWORD, __int64 *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v14);
v15 = *v14;
v16 = *(_QWORD *)(a1 + 552);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v44, (float)(v8 + 170.0) - 18.0, (float)(v9 + 110.0) - 19.0);
cocos2d::CCNode::convertToNodeSpace(v16, &v43, v17);
(*(void (__fastcall **)(__int64 *, __int64))(v15 + 184))(v14, v18);
sub_14009BE60((__int64)&v54);
v54 = -1;
sub_1400405A0(v55, "Max per level (0 = unlimited):", 0x1Eu);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v44, v8, v9 + 40.0);
cocos2d::CCPoint::operator=(v56, v19);
v57 = 1058642330;
v58 = 1;
v61 = 1;
v64 = 1;
v66 = 1057803469;
v59 = 3;
v60 = 4;
v62 = 0;
v63 = 1148846080;
SetupTriggerPopup::createValueControlAdvanced_1(a1, &v54);
LODWORD(v43) = -1;
*(_BYTE *)sub_14016EE40(a1 + 872, &v43) = 1;
LODWORD(v43) = -1;
*(_BYTE *)sub_14016EE40(a1 + 856, &v43) = 1;
v20 = cocos2d::CCLabelBMFont::create(&byte_1406ED6E0, "chatFont.fnt");
*(_QWORD *)(a1 + 1016) = v20;
(*(void (__fastcall **)(struct cocos2d::CCLabelBMFont *))(*(_QWORD *)v20 + 160LL))(v20);
v21 = **(_QWORD **)(a1 + 1016);
v22 = *(_QWORD *)(a1 + 1016);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v44, v8, v9 - 2.0);
(*(void (__fastcall **)(__int64, __int64))(v21 + 184))(v22, v23);
(*(void (__fastcall **)(_QWORD, _QWORD))(**(_QWORD **)(a1 + 584) + 464LL))(
*(_QWORD *)(a1 + 584),
*(_QWORD *)(a1 + 1016));
AutoBackupOptionsPopup::refreshStats(a1);
v24 = v9 - 40.0;
v44[0] = (__int64)operator new(0x2C8u);
v25 = (cocos2d::CCObject *)ButtonSprite::ButtonSprite(v44[0]);
if ( v25 )
{
if ( ButtonSprite::init_1(
(__int64)v25,
(__int64)"Prune Now",
64,
0,
1055286886,
1,
&qword_140704F78,
(__int64)"GJ_button_05.png",
1103101952) )
{
cocos2d::CCObject::autorelease(v25);
}
else
{
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v25 + 8LL))(v25, 1);
LODWORD(v25) = 0;
}
}
v26 = CCMenuItemSpriteExtra::create((int)v25, 0, a1, (__int64)AutoBackupOptionsPopup::onPrune);
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v26);
v27 = *(_QWORD *)v26;
v28 = *(_QWORD *)(a1 + 552);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v44, v8 - 45.0, v24);
cocos2d::CCNode::convertToNodeSpace(v28, &v43, v29);
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(v27 + 184))(v26, v30);
v44[0] = (__int64)operator new(0x2C8u);
v31 = (cocos2d::CCObject *)ButtonSprite::ButtonSprite(v44[0]);
if ( v31 )
{
if ( ButtonSprite::init_1(
(__int64)v31,
(__int64)"Delete All",
64,
0,
1055286886,
1,
&qword_140704F78,
(__int64)"GJ_button_06.png",
1103101952) )
{
cocos2d::CCObject::autorelease(v31);
}
else
{
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v31 + 8LL))(v31, 1);
LODWORD(v31) = 0;
}
}
v32 = CCMenuItemSpriteExtra::create((int)v31, 0, a1, (__int64)AutoBackupOptionsPopup::onDeleteAll);
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v32);
v33 = *(_QWORD *)v32;
v34 = *(_QWORD *)(a1 + 552);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v44, v8 + 45.0, v24);
cocos2d::CCNode::convertToNodeSpace(v34, &v43, v35);
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(v33 + 184))(v32, v36);
v44[0] = (__int64)operator new(0x2C8u);
v37 = (cocos2d::CCObject *)ButtonSprite::ButtonSprite(v44[0]);
if ( v37 )
{
if ( ButtonSprite::init_1(
(__int64)v37,
(__int64)"OK",
40,
0,
1061997773,
1,
"goldFont.fnt",
(__int64)"GJ_button_01.png",
1106247680) )
{
cocos2d::CCObject::autorelease(v37);
}
else
{
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v37 + 8LL))(v37, 1);
LODWORD(v37) = 0;
}
}
v38 = CCMenuItemSpriteExtra::create((int)v37, 0, a1, (__int64)sub_14009D628);
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v38);
v39 = *(_QWORD *)v38;
v40 = *(_QWORD *)(a1 + 552);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v44, v8, (float)(v9 - 110.0) + 25.0);
cocos2d::CCNode::convertToNodeSpace(v40, &v43, v41);
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(v39 + 184))(v38, v42);
(*(void (__fastcall **)(__int64))(*(_QWORD *)a1 + 1136LL))(a1);
*(_BYTE *)(a1 + 744) = 0;
sub_14003D310((__int64)v67);
sub_14003D310((__int64)v65);
sub_14003D310((__int64)v55);
j_j_free(v10);
return 1;
}
return result;
}