//
// VideoOptionsLayer::onApply from 0x1404ce1e0 to 0x1404ce6a7 (1223 bytes)
//
// 2 xrefs:
// > VideoOptionsLayer::init @ 0x1404cd86f
// > ??> @ 0x1409296c0
//
// 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:32:59 +0000
//
// Hidden C++ exception states: #wind=12
char __fastcall VideoOptionsLayer::onApply(__int64 a1)
{
cocos2d::CCString *v2; // rax
__int64 v3; // rcx
int v4; // ebx
__int64 v5; // r9
__int64 v6; // rcx
char GameVariable; // al
char v8; // cl
__int64 v9; // rcx
__int64 v10; // rcx
__int64 v11; // rcx
__int64 v12; // rax
cocos2d::CCObject *v13; // rbx
bool v15; // r15
char v16; // r12
char v17; // r13
const struct cocos2d::CCSize *v18; // rax
const struct cocos2d::CCSize *v19; // rbx
__int64 v20; // rdx
__int64 v21; // rcx
__int64 v22; // r8
__int64 v23; // r9
struct cocos2d::CCScene *v24; // rsi
__int64 v25; // rcx
const struct cocos2d::CCSize *v26; // rax
const struct cocos2d::CCSize *v27; // rbx
char *v28; // rdi
__int64 v29; // rax
__int64 v30; // rbx
__int64 v31; // rbx
struct cocos2d::CCFiniteTimeAction *v32; // rax
struct cocos2d::CCAction *v33; // rax
__int64 v34; // rcx
cocos2d::CCDirector *v35; // rax
char v36[8]; // [rsp+50h] [rbp-39h] BYREF
char v37[8]; // [rsp+58h] [rbp-31h] BYREF
char *v38; // [rsp+60h] [rbp-29h] BYREF
__int128 v39; // [rsp+68h] [rbp-21h] BYREF
__int64 v40; // [rsp+78h] [rbp-11h]
__int64 v41; // [rsp+80h] [rbp-9h]
char v42[88]; // [rsp+88h] [rbp-1h] BYREF
void *v43; // [rsp+F0h] [rbp+67h]
void *v44; // [rsp+F0h] [rbp+67h]
void *v45; // [rsp+F0h] [rbp+67h]
void *v46; // [rsp+F0h] [rbp+67h]
void *v47; // [rsp+F0h] [rbp+67h]
void *v48; // [rsp+F0h] [rbp+67h]
char v49; // [rsp+F0h] [rbp+67h]
int v50; // [rsp+100h] [rbp+77h]
char v51; // [rsp+108h] [rbp+7Fh] BYREF
v2 = cocos2d::CCArray::stringAtIndex(*(cocos2d::CCArray **)(a1 + 712), *(_DWORD *)(a1 + 756));
v4 = cocos2d::CCString::intValue(v2);
if ( !qword_14090BFD0 )
{
v43 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v43);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
}
GameManager::resolutionForKey(v3, (cocos2d::CCSize *)&v51, v4, v5);
v6 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v44 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v44);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v6 = qword_14090BFD0;
}
GameVariable = GameManager::getGameVariable(v6, "0025");
v8 = *(_BYTE *)(a1 + 752);
if ( GameVariable == v8 )
goto LABEL_18;
if ( !v8 )
goto LABEL_13;
v9 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v45 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v45);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v9 = qword_14090BFD0;
}
if ( GameManager::getGameVariable(v9, "0170") != *(_BYTE *)(a1 + 753) )
goto LABEL_18;
v10 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v46 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v46);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v10 = qword_14090BFD0;
}
if ( GameManager::getGameVariable(v10, "0175") != *(_BYTE *)(a1 + 754) )
{
LABEL_18:
v11 = qword_14090BFD0;
}
else
{
LABEL_13:
v11 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v47 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v47);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v11 = qword_14090BFD0;
}
if ( *(_DWORD *)(v11 + 1088) == v4 && *(_DWORD *)(v11 + 1092) == *(_DWORD *)(a1 + 704) )
{
v39 = 0;
*(_QWORD *)&v39 = sub_14003D460(0x20u);
v40 = 26;
v41 = 31;
strcpy((char *)v39, "No changes have been made.");
v12 = sub_14003F4F0((__int64)v42, (__int64)&v39);
v13 = FLAlertLayer::create(0, (int)"Graphics", v12, (__int64)"OK", 0, 1132068864, 0, 0, 1065353216);
sub_14003D310((__int64)&v39);
return (*(__int64 (__fastcall **)(cocos2d::CCObject *))(*(_QWORD *)v13 + 1064LL))(v13);
}
}
if ( !v11 )
{
v48 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v48);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v11 = qword_14090BFD0;
}
v15 = *(_DWORD *)(v11 + 1088) != v4;
*(_DWORD *)(v11 + 1088) = v4;
*(_DWORD *)(v11 + 1092) = *(_DWORD *)(a1 + 704);
v16 = *(_BYTE *)(a1 + 754);
v17 = *(_BYTE *)(a1 + 753);
v49 = *(_BYTE *)(a1 + 752);
cocos2d::CCSize::CCSize((cocos2d::CCSize *)v36, (const struct cocos2d::CCSize *)&v51);
v19 = v18;
v50 = *(_DWORD *)(a1 + 704);
v24 = (struct cocos2d::CCScene *)cocos2d::CCScene::create(v21, v20, v22, v23);
*(_QWORD *)(cocos2d::CCApplication::sharedApplication(v25) + 232) = v24;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)v37, v19);
v27 = v26;
v28 = (char *)operator new(0x1A8u);
v38 = v28;
cocos2d::CCLayer::CCLayer((cocos2d::CCLayer *)v28);
*(_QWORD *)v28 = &GraphicsReloadLayer::`vftable';
*((_QWORD *)v28 + 40) = &GraphicsReloadLayer::`vftable';
*((_QWORD *)v28 + 41) = &GraphicsReloadLayer::`vftable';
*((_QWORD *)v28 + 42) = &GraphicsReloadLayer::`vftable';
*((_QWORD *)v28 + 43) = &GraphicsReloadLayer::`vftable';
*((_QWORD *)v28 + 44) = &GraphicsReloadLayer::`vftable';
cocos2d::CCSize::CCSize((cocos2d::CCSize *)(v28 + 412));
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v38, v27);
v30 = v29;
if ( cocos2d::CCLayer::init((cocos2d::CCLayer *)v28) )
{
*((_DWORD *)v28 + 102) = v50;
cocos2d::CCSize::operator=(v28 + 412, v30);
v28[420] = v49;
v28[421] = v17;
v28[422] = v16;
v28[423] = v15;
v31 = cocos2d::CCCallFunc::create(v28, GraphicsReloadLayer::performReload);
v32 = cocos2d::CCDelayTime::create(0.1);
v33 = cocos2d::CCSequence::create(v32, v31, 0);
cocos2d::CCNode::runAction((cocos2d::CCNode *)v28, v33);
cocos2d::CCObject::autorelease((cocos2d::CCObject *)v28);
}
else
{
(*(void (__fastcall **)(char *, __int64))(*(_QWORD *)v28 + 8LL))(v28, 1);
v28 = nullptr;
}
(*(void (__fastcall **)(struct cocos2d::CCScene *, char *))(*(_QWORD *)v24 + 464LL))(v24, v28);
v35 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v34);
return cocos2d::CCDirector::replaceScene(v35, v24);
}