//
// EditorUI::onPlaytest from 0x1401120b0 to 0x14011252d (1149 bytes)
//
// 4 xrefs:
// > EditorUI::onPlaytest @ 0x1401124fc
// > EditorUI::keyDown @ 0x140125c82
// > EditorUI::init @ 0x1400e040b
// > ??> @ 0x1406c8ff4
//
// 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=1
void EditorUI::onPlaytest(EditorUI *a1, cocos2d::CCObject *a2)
{
char v4; // r14
char v5; // bp
__int64 v6; // rcx
LevelEditorLayer *m_editorLayer; // rdi
PlaybackMode m_playbackMode; // eax
__int64 v9; // rax
UILayer *m_uiLayer; // rbx
__int64 v11; // rcx
cocos2d::CCDirector *v12; // rax
__int64 v13; // rcx
GJBaseGameLayer *v14; // rcx
__int64 v15; // rax
UILayer *v16; // rbx
_BOOL8 v17; // rdx
__int64 v18; // rcx
cocos2d::CCDirector *v19; // rax
__int64 v20; // rcx
double v21; // xmm0_8
GJBaseGameLayer *v22; // rcx
GameManager *v23; // rcx
cocos2d::CCNode *v24; // rdi
cocos2d::CCNode_vtbl *v25; // rbx
LevelEditorLayer *v26; // rcx
cocos2d::CCSpriteFrameCache *v27; // rax
const char *v28; // rdx
struct cocos2d::CCSpriteFrame *v29; // rax
_BOOL8 v30; // rdx
void *v31; // [rsp+40h] [rbp+8h]
if ( !a1->m_isPaused )
{
v4 = 0;
if ( a1->m_editorLayer->m_playbackMode != Playing )
{
v4 = 1;
GJBaseGameLayer::pauseAudio((GJBaseGameLayer *)a1);
}
v5 = 0;
a1->m_isPlayingMusic = 0;
if ( a1->m_editorLayer->m_playbackMode != Playing )
EditorUI::toggleMode(a1, a1->m_editModeBtn);
EditorUI::deselectAll(a1);
m_editorLayer = a1->m_editorLayer;
m_playbackMode = m_editorLayer->m_playbackMode;
switch ( m_playbackMode )
{
case Playing:
v9 = cocos2d::CCDirector::sharedDirector(v6);
*(_BYTE *)((*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v9 + 176LL))(v9) + 92) = 0;
m_uiLayer = m_editorLayer->m_uiLayer;
*(_QWORD *)&m_uiLayer->m_p1TouchId = -1;
*(_WORD *)&m_uiLayer->m_p1Jumping = 0;
m_uiLayer->m_checkpointBtnDown = 0;
UILayer::resetUINodeState(m_uiLayer);
UILayer::toggleMenuVisibility(m_uiLayer, 0);
m_uiLayer->setVisible(m_uiLayer, 0);
*(_BYTE *)(cocos2d::CCEGLView::sharedOpenGLView() + 237) = 0;
LevelEditorLayer::quickUpdateAllPositions(m_editorLayer);
if ( m_editorLayer->m_collisionBlocksAdded )
{
m_editorLayer->m_collisionBlocksAdded = 0;
GJBaseGameLayer::removeObjectFromSection(m_editorLayer, m_editorLayer->m_player1CollisionBlock);
GJBaseGameLayer::removeObjectFromSection(m_editorLayer, m_editorLayer->m_player2CollisionBlock);
}
if ( m_editorLayer->m_playTestSmoothFix )
{
v12 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v11);
cocos2d::CCDirector::resetSmoothFixCounter(v12);
*(_BYTE *)(cocos2d::CCDirector::sharedDirector(v13) + 170) = 0;
}
m_editorLayer->m_playbackMode = Paused;
cocos2d::CCNode::pauseSchedulerAndActions(m_editorLayer->m_player1);
cocos2d::CCNode::pauseSchedulerAndActions(m_editorLayer->m_player2);
m_editorLayer->m_playtestTimeWarp = m_editorLayer->m_gameState.m_timeWarp;
((void (__fastcall *)(LevelEditorLayer *))m_editorLayer->updateTimeWarp)(m_editorLayer);
m_editorLayer->m_playtestCameraZoom = m_editorLayer->m_gameState.m_cameraZoom;
GJBaseGameLayer::pauseAudio(v14);
if ( m_editorLayer->m_playtestOrderChanged )
m_editorLayer->m_spawnOrderObjectsChanged = 1;
break;
case Paused:
v15 = cocos2d::CCDirector::sharedDirector(v6);
*(_BYTE *)((*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v15 + 176LL))(v15) + 92) = 1;
v16 = m_editorLayer->m_uiLayer;
*(_QWORD *)&v16->m_p1TouchId = -1;
*(_WORD *)&v16->m_p1Jumping = 0;
v16->m_checkpointBtnDown = 0;
UILayer::resetUINodeState(v16);
UILayer::toggleMenuVisibility(v16, 1);
LOBYTE(v17) = 1;
v16->setVisible(v16, v17);
*(_BYTE *)(cocos2d::CCEGLView::sharedOpenGLView() + 237) = 1;
if ( !m_editorLayer->m_collisionBlocksAdded )
{
m_editorLayer->m_collisionBlocksAdded = 1;
m_editorLayer->addToSection(m_editorLayer, m_editorLayer->m_player1CollisionBlock);
m_editorLayer->addToSection(m_editorLayer, m_editorLayer->m_player2CollisionBlock);
}
if ( m_editorLayer->m_playTestSmoothFix )
{
v19 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v18);
cocos2d::CCDirector::resetSmoothFixCounter(v19);
*(_BYTE *)(cocos2d::CCDirector::sharedDirector(v20) + 170) = 1;
}
v21 = ((double (__fastcall *)(cocos2d::CCLayer *))m_editorLayer->m_objectLayer->getScale)(m_editorLayer->m_objectLayer);
m_editorLayer->m_playtestZoom = *(float *)&v21;
((void (__fastcall *)(cocos2d::CCLayer *))m_editorLayer->m_objectLayer->setScale_0)(m_editorLayer->m_objectLayer);
((void (__fastcall *)(LevelEditorLayer *))m_editorLayer->updateTimeWarp)(m_editorLayer);
m_editorLayer->m_playbackMode = Playing;
cocos2d::CCNode::resumeSchedulerAndActions(m_editorLayer->m_player1);
cocos2d::CCNode::pauseSchedulerAndActions(m_editorLayer->m_player2);
m_editorLayer->m_gameState.m_cameraZoom = m_editorLayer->m_playtestCameraZoom;
LevelEditorLayer::recreateGroups(m_editorLayer);
GJBaseGameLayer::optimizeMoveGroups(m_editorLayer);
*(_DWORD *)&m_editorLayer->m_triggersChanged = 16843009;
m_editorLayer->m_spawnTriggersChanged = 1;
GJBaseGameLayer::resumeAudio(v22);
break;
case Not:
a1->m_editorZoom = m_editorLayer->m_objectLayer->getScale(m_editorLayer->m_objectLayer);
LevelEditorLayer::onPlaytest(a1->m_editorLayer);
if ( !a1->m_editorLayer->m_startPosObject )
goto LABEL_25;
v23 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v31 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00(v31);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v23 = (GameManager *)qword_1406C2ED8;
}
if ( GameManager::getGameVariable(v23, "0150") )
v5 = 1;
else
LABEL_25:
v5 = 0;
break;
}
EditorUI::showUI(a1, a1->m_editorLayer->m_playbackMode != Playing);
v24 = a1->m_playtestBtn->getNormalImage(a1->m_playtestBtn);
v25 = v24->__vftable;
v26 = a1->m_editorLayer;
if ( v26->m_playbackMode == Playing )
{
v27 = (cocos2d::CCSpriteFrameCache *)cocos2d::CCSpriteFrameCache::sharedSpriteFrameCache(v26);
v28 = "GJ_pauseEditorBtn_001.png";
}
else
{
v27 = (cocos2d::CCSpriteFrameCache *)cocos2d::CCSpriteFrameCache::sharedSpriteFrameCache(v26);
v28 = "GJ_playEditorBtn_001.png";
}
v29 = cocos2d::CCSpriteFrameCache::spriteFrameByName(v27, v28);
((void (__fastcall *)(cocos2d::CCNode *, struct cocos2d::CCSpriteFrame *))v25[1].setScaleX)(v24, v29);
LOBYTE(v30) = 1;
a1->m_playtestStopBtn->setVisible(a1->m_playtestStopBtn, v30);
EditorUI::updatePlaybackBtn(a1);
if ( v5 )
EditorUI::onPlaytest(a1, a2);
if ( v4 )
a1->m_editorLayer->m_audioPaused = 1;
}
}