//
// VideoOptionsLayer::onApply from 0x140378490 to 0x140378944 (1204 bytes)
//
// 2 xrefs:
// > VideoOptionsLayer::init @ 0x140377b10
// > ??> @ 0x1406d5c3c
//
// 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=12
void VideoOptionsLayer::onApply(VideoOptionsLayer *a1, cocos2d::CCObject *a2)
{
float v2; // xmm3_4
cocos2d::CCString *v4; // rax
GameManager *v5; // rcx
int v6; // ebx
GameManager *v7; // rcx
char GameVariable; // al
char m_fullscreen; // cl
GameManager *v10; // rcx
GameManager *v11; // rcx
__int64 v12; // rcx
__int64 v13; // rax
FLAlertLayer *v14; // rbx
bool v15; // r15
bool m_fix; // r12
bool m_borderless; // r13
const struct cocos2d::CCSize *v18; // rax
const struct cocos2d::CCSize *v19; // rbx
__int64 v20; // rcx
struct cocos2d::CCScene *v21; // rsi
__int64 v22; // rdx
__int64 v23; // rcx
const struct cocos2d::CCSize *v24; // rax
const struct cocos2d::CCSize *v25; // rbx
char *v26; // rdi
__int64 v27; // rax
__int64 v28; // rbx
__int64 v29; // rbx
struct cocos2d::CCDelayTime *v30; // rax
struct cocos2d::CCSequence *v31; // rax
cocos2d::ccColor3B *v32; // r8
__int64 v33; // rcx
cocos2d::CCDirector *v34; // rax
float v35; // [rsp+20h] [rbp-69h]
cocos2d::CCSize v36; // [rsp+50h] [rbp-39h] BYREF
cocos2d::CCSize v37; // [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]
bool v49; // [rsp+F0h] [rbp+67h]
int m_textureQuality; // [rsp+100h] [rbp+77h]
struct cocos2d::CCSize v51; // [rsp+108h] [rbp+7Fh] BYREF
v4 = cocos2d::CCArray::stringAtIndex(a1->m_availableResolutions, a1->m_currentResolution);
v6 = cocos2d::CCString::intValue(v4);
if ( !qword_1406C2ED8 )
{
v43 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v43);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
}
GameManager::resolutionForKey(v5, (int)&v51);
v7 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v44 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v44);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v7 = (GameManager *)qword_1406C2ED8;
}
GameVariable = GameManager::getGameVariable(v7, "0025");
m_fullscreen = a1->m_fullscreen;
if ( GameVariable == m_fullscreen )
goto LABEL_18;
if ( !m_fullscreen )
goto LABEL_13;
v10 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v45 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v45);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v10 = (GameManager *)qword_1406C2ED8;
}
if ( GameManager::getGameVariable(v10, "0170") != a1->m_borderless )
goto LABEL_18;
v11 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v46 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v46);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v11 = (GameManager *)qword_1406C2ED8;
}
if ( GameManager::getGameVariable(v11, "0175") != a1->m_fix )
{
LABEL_18:
v12 = qword_1406C2ED8;
}
else
{
LABEL_13:
v12 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v47 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v47);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v12 = qword_1406C2ED8;
}
if ( *(_DWORD *)(v12 + 1028) == v6 && *(_DWORD *)(v12 + 1032) == a1->m_textureQuality )
{
v39 = 0;
*(_QWORD *)&v39 = sub_14003AA10(0x20u);
v40 = 26;
v41 = 31;
strcpy((char *)v39, "No changes have been made.");
v13 = sub_14003BDB0((__int64)v42, (__int64)&v39);
v14 = FLAlertLayer::create(0, (int)"Graphics", v13, (__int64)"OK", 0, 1132068864, 0, 0, 1065353216);
sub_14003A830((__int64)&v39);
v14->show(v14);
return;
}
}
if ( !v12 )
{
v48 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v48);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v12 = qword_1406C2ED8;
}
v15 = *(_DWORD *)(v12 + 1028) != v6;
*(_DWORD *)(v12 + 1028) = v6;
*(_DWORD *)(v12 + 1032) = a1->m_textureQuality;
m_fix = a1->m_fix;
m_borderless = a1->m_borderless;
v49 = a1->m_fullscreen;
cocos2d::CCSize::CCSize(&v36, &v51);
v19 = v18;
m_textureQuality = a1->m_textureQuality;
v21 = (struct cocos2d::CCScene *)cocos2d::CCScene::create(v20);
*(_QWORD *)(cocos2d::CCApplication::sharedApplication(v23, v22) + 224) = v21;
cocos2d::CCSize::CCSize(&v37, v19);
v25 = v24;
v26 = (char *)operator new(0x1A8u);
v38 = v26;
cocos2d::CCLayer::CCLayer((cocos2d::CCLayer *)v26);
*(_QWORD *)v26 = &GraphicsReloadLayer::`vftable';
*((_QWORD *)v26 + 40) = &GraphicsReloadLayer::`vftable';
*((_QWORD *)v26 + 41) = &GraphicsReloadLayer::`vftable';
*((_QWORD *)v26 + 42) = &GraphicsReloadLayer::`vftable';
*((_QWORD *)v26 + 43) = &GraphicsReloadLayer::`vftable';
*((_QWORD *)v26 + 44) = &GraphicsReloadLayer::`vftable';
cocos2d::CCSize::CCSize((cocos2d::CCSize *)(v26 + 412));
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v38, v25);
v28 = v27;
if ( cocos2d::CCLayer::init((cocos2d::CCLayer *)v26) )
{
*((_DWORD *)v26 + 102) = m_textureQuality;
cocos2d::CCSize::operator=(v26 + 412, v28);
v26[420] = v49;
v26[421] = m_borderless;
v26[422] = m_fix;
v26[423] = v15;
v29 = cocos2d::CCCallFunc::create(v26, GraphicsReloadLayer::performReload);
v30 = cocos2d::CCDelayTime::create(0.1);
v31 = cocos2d::CCSequence::create(v30, v29, 0);
cocos2d::CCNode::runAction((CCLightFlash *)v26, (cocos2d::CCPoint)v31, v32, v2, v35);
cocos2d::CCObject::autorelease((cocos2d::CCObject *)v26);
}
else
{
(*(void (__fastcall **)(char *, __int64))(*(_QWORD *)v26 + 8LL))(v26, 1);
v26 = nullptr;
}
v21->addChild_1(v21, (cocos2d::CCNode *)v26);
v34 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v33);
cocos2d::CCDirector::replaceScene(v34, v21);
}