//
// EditorUI::keyDown from 0x6c5640 to 0x6c6648 (4104 bytes)
//
// 3 xrefs:
// > `non-virtual thunk to'EditorUI::keyDown @ 0x6c665c
// > ??> @ 0x8aa08
// > ??> @ 0x1156b08
//
// 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
//
// local variable allocation has failed, the output may be wrong!
void EditorUI::keyDown(EditorUI *a1, cocos2d::enumKeyCodes a2, double a3)
{
long double v5; // q0
double v6; // d1
LevelEditorLayer *m_editorLayer; // x0
cocos2d::CCDirector *v8; // x0
unsigned int v9; // w23
cocos2d::CCDirector *v10; // x0
cocos2d::CCDirector *v11; // x0
cocos2d::CCDirector *v12; // x0
cocos2d::CCDirector *v13; // x0
cocos2d::CCDirector *v14; // x0
cocos2d::CCDirector *v15; // x0
cocos2d::CCDirector *v16; // x0
cocos2d::CCDirector *v17; // x0
float v18; // s9
cocos2d::CCDirector *v19; // x0
float v20; // s10
float v21; // s8
cocos2d::CCDirector *v22; // x0
const cocos2d::CCPoint *v23; // x0
cocos2d::CCString *v24; // x0
char *CString; // x0
void (__fastcall *addChild_0)(cocos2d::CCNode *__hidden, cocos2d::CCNode *, int); // x23
cocos2d::CCNode *v27; // x0
cocos2d::CCDirector *v28; // x0
cocos2d::CCLayer *m_objectLayer; // x23
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x24
cocos2d::CCDirector *v31; // x0
cocos2d::CCDirector *v32; // x0
cocos2d::CCDirector *v33; // x0
cocos2d::CCDirector *v34; // x0
cocos2d::CCDirector *v35; // x0
cocos2d::CCDirector *v36; // x0
cocos2d::CCDirector *v37; // x0
_BOOL4 m_bShiftPressed; // w1
EditorUI *v39; // x0
EditCommand v40; // w1
cocos2d::CCDirector *v41; // x0
bool v42; // zf
cocos2d::CCDirector *v43; // x0
cocos2d::CCDirector *v44; // x0
cocos2d::CCDirector *v45; // x0
TextAlertPopup *v46; // x24
void (__fastcall *v47)(cocos2d::CCNode *__hidden, cocos2d::CCNode *, int); // x23
cocos2d::CCNode *v48; // x0
void *v49; // x0
cocos2d::CCDirector *v50; // x0
float v51; // s8
const cocos2d::CCPoint *v52; // x0
cocos2d::CCPoint *p_m_previewPosition; // x23
float v54; // s0
float v55; // s1
void (__fastcall *v56)(cocos2d::CCNode *__hidden, cocos2d::CCNode *, int); // x23
cocos2d::CCNode *v57; // x0
GameManager *v58; // x0
GameManager *v59; // x0
int GameVariable; // w24
GameManager *v61; // x0
GameManager *v62; // x0
GameObject *v63; // x0
LevelEditorLayer *v64; // x1
GameObject *m_selectedObject; // x0
LevelEditorLayer *v66; // x1
GameManager *v67; // x0
GameManager *v68; // x0
GameManager *v69; // x0
bool v70; // w0
GameManager *v71; // x0
GameManager *v72; // x0
GameManager *v73; // x0
GameManager *v74; // x0
float v75; // s0
__int64 v76; // [xsp+0h] [xbp+0h] BYREF
cocos2d::CCPoint *v77[2]; // [xsp+70h] [xbp+70h]
float v78; // [xsp+90h] [xbp+90h]
float v79; // [xsp+94h] [xbp+94h]
cocos2d::CCPoint v80; // [xsp+98h] [xbp+98h] BYREF
cocos2d::CCPoint v81; // [xsp+A0h] [xbp+A0h] BYREF
char *v82; // [xsp+A8h] [xbp+A8h] BYREF
cocos2d::CCPoint v83; // [xsp+B0h] [xbp+B0h] BYREF
cocos2d::CCPoint v84[2]; // [xsp+B8h] [xbp+B8h] BYREF
std::string v85; // 0:x3.8
std::string v86; // 0:x3.8
std::string v87; // 0:x3.8
std::string v88; // 0:x3.8
cocos2d::CCPoint v89; // 0:s0.4,4:s1.4
cocos2d::CCPoint v90; // 0:s0.4,4:s1.4
cocos2d::CCPoint v91; // 0:s0.4,4:s1.4
cocos2d::CCPoint v92; // 0:s2.4,4:s3.4
*(_OWORD *)v77 = *(_OWORD *)&a3;
clock_gettime(0, (struct timespec *)v84);
v5 = *(long double *)v77;
v6 = (double)(__int64)v84[0] + (double)(__int64)v84[1] / 1000000000.0;
a1->m_keyTime = v6;
if ( a2 == KEY_Space )
{
if ( a1->m_pressedSpace )
return;
m_editorLayer = a1->m_editorLayer;
a1->m_pressedSpace = 1;
if ( m_editorLayer->m_playbackMode != Playing )
goto LABEL_12;
LABEL_50:
m_editorLayer->m_uiLayer->keyDown(m_editorLayer->m_uiLayer, a2, v5);
goto LABEL_51;
}
m_editorLayer = a1->m_editorLayer;
if ( m_editorLayer->m_playbackMode == Playing )
goto LABEL_50;
switch ( a2 )
{
case KEY_Z:
v13 = cocos2d::CCDirector::sharedDirector();
if ( v13->getKeyboardDispatcher(v13)->m_bControlPressed )
{
v16 = cocos2d::CCDirector::sharedDirector();
if ( v16->getKeyboardDispatcher(v16)->m_bShiftPressed )
{
EditorUI::redoLastAction(a1, nullptr);
goto LABEL_42;
}
}
v14 = cocos2d::CCDirector::sharedDirector();
if ( v14->getKeyboardDispatcher(v14)->m_bControlPressed )
{
EditorUI::undoLastAction(a1, nullptr);
goto LABEL_42;
}
break;
case KEY_D:
v12 = cocos2d::CCDirector::sharedDirector();
if ( v12->getKeyboardDispatcher(v12)->m_bAltPressed )
{
EditorUI::onDeselectAll(a1, nullptr);
goto LABEL_42;
}
v8 = cocos2d::CCDirector::sharedDirector();
if ( v8->getKeyboardDispatcher(v8)->m_bControlPressed )
{
EditorUI::onDuplicate(a1, nullptr);
goto LABEL_42;
}
goto LABEL_17;
case KEY_C:
v15 = cocos2d::CCDirector::sharedDirector();
if ( v15->getKeyboardDispatcher(v15)->m_bControlPressed )
{
EditorUI::onCopy(a1, nullptr);
goto LABEL_42;
}
break;
case KEY_V:
v28 = cocos2d::CCDirector::sharedDirector();
if ( v28->getKeyboardDispatcher(v28)->m_bControlPressed )
{
EditorUI::onPaste(a1, nullptr);
goto LABEL_42;
}
goto LABEL_17;
}
LABEL_12:
v9 = a2 - 48;
if ( (unsigned int)(a2 - 48) <= 9 )
{
v17 = cocos2d::CCDirector::sharedDirector();
if ( v17->getKeyboardDispatcher(v17)->m_bControlPressed
|| (v31 = cocos2d::CCDirector::sharedDirector(), v31->getKeyboardDispatcher(v31)->m_bAltPressed) )
{
v18 = a1->m_editorLayer->m_objectLayer->getScale(a1->m_editorLayer->m_objectLayer);
v19 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v19);
v20 = v78 * 0.5;
v21 = (float)(a1->m_toolbarHeight * 0.5) + (float)(v79 * 0.5);
v22 = cocos2d::CCDirector::sharedDirector();
if ( !v22->getKeyboardDispatcher(v22)->m_bControlPressed )
{
LevelEditorLayer::getSavedEditorPosition(a1->m_editorLayer, v9);
if ( v83.x != 0.0 || v83.y != 0.0 )
{
m_objectLayer = a1->m_editorLayer->m_objectLayer;
setPosition = m_objectLayer->setPosition;
cocos2d::CCPoint::CCPoint(v84, v20 - (float)(v83.x * v18), v21 - (float)(v83.y * v18));
setPosition(m_objectLayer, v84);
}
LABEL_51:
if ( a2 == CONTROLLER_Back || a2 == KEY_Escape )
{
EditorUI::onPause(a1, nullptr);
return;
}
goto LABEL_42;
}
v23 = a1->m_editorLayer->m_objectLayer->getPosition(a1->m_editorLayer->m_objectLayer);
cocos2d::CCPoint::CCPoint(&v80, v23);
v77[0] = &v81;
cocos2d::CCPoint::CCPoint(&v81, (float)(v20 - v80.x) / v18, (float)(v21 - v80.y) / v18);
LevelEditorLayer::saveEditorPosition(a1->m_editorLayer, v77[0], v9);
v24 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"Position %i saved.",
(const char *)v9);
CString = (char *)cocos2d::CCString::getCString(v24);
sub_D153B8((unsigned int)&v76 + 168, CString);
addChild_0 = a1->addChild_0;
sub_D18D28(&v83, &v82);
sub_D153B8((int)v84, &byte_F288A0);
v27 = (cocos2d::CCNode *)TextAlertPopup::create(
(TextAlertPopup *)&v83,
(std::string)150LL,
0.5,
0.6,
(int)v84,
v85);
addChild_0(a1, v27, 100);
if ( (__int64 *)(*(_QWORD *)v84 - 24LL) != &qword_124B6B0 )
sub_6865FC((void *)(*(_QWORD *)v84 - 24LL));
if ( (__int64 *)(*(_QWORD *)&v83 - 24LL) != &qword_124B6B0 )
sub_6865FC((void *)(*(_QWORD *)&v83 - 24LL));
LABEL_69:
if ( v82 - 24 != (char *)&qword_124B6B0 )
sub_6865FC(v82 - 24);
goto LABEL_51;
}
if ( a2 == KEY_One )
{
EditorUI::toggleMode(a1, a1->m_buildModeBtn);
goto LABEL_42;
}
}
switch ( a2 )
{
case KEY_Two:
EditorUI::toggleMode(a1, a1->m_editModeBtn);
goto LABEL_42;
case KEY_Three:
EditorUI::toggleMode(a1, a1->m_deleteModeBtn);
goto LABEL_42;
case KEY_OEMPlus:
v32 = cocos2d::CCDirector::sharedDirector();
if ( v32->getKeyboardDispatcher(v32)->m_bShiftPressed )
{
EditorUI::zoomIn(a1, nullptr);
}
else
{
cocos2d::CCPoint::CCPoint(v84, 0.0, -10.0);
EditorUI::moveGamelayer(a1, v89);
}
goto LABEL_42;
case KEY_OEMMinus:
v33 = cocos2d::CCDirector::sharedDirector();
if ( v33->getKeyboardDispatcher(v33)->m_bShiftPressed )
{
EditorUI::zoomOut(a1, nullptr);
}
else
{
cocos2d::CCPoint::CCPoint(v84, 0.0, 10.0);
EditorUI::moveGamelayer(a1, v90);
}
goto LABEL_42;
}
LABEL_17:
switch ( a2 )
{
case KEY_Backspace:
case KEY_Delete:
EditorUI::onDeleteSelected(a1, nullptr);
goto LABEL_51;
case KEY_T:
v34 = cocos2d::CCDirector::sharedDirector();
if ( v34->getKeyboardDispatcher(v34)->m_bControlPressed )
EditorUI::activateTransformControl(a1, nullptr);
else
EditorUI::toggleSwipe(a1, nullptr);
goto LABEL_42;
case KEY_Q:
v35 = cocos2d::CCDirector::sharedDirector();
if ( v35->getKeyboardDispatcher(v35)->m_bAltPressed )
EditorUI::transformObjectCall(a1, FlipX);
else
EditorUI::transformObjectCall(a1, RotateCCW);
goto LABEL_42;
case KEY_E:
v36 = cocos2d::CCDirector::sharedDirector();
if ( v36->getKeyboardDispatcher(v36)->m_bAltPressed )
EditorUI::transformObjectCall(a1, FlipY);
else
EditorUI::transformObjectCall(a1, RotateCW);
goto LABEL_42;
case KEY_A:
v37 = cocos2d::CCDirector::sharedDirector();
m_bShiftPressed = v37->getKeyboardDispatcher(v37)->m_bShiftPressed;
v39 = a1;
if ( m_bShiftPressed )
v40 = SmallLeft;
else
v40 = Left;
goto LABEL_108;
case KEY_D:
v41 = cocos2d::CCDirector::sharedDirector();
v42 = !v41->getKeyboardDispatcher(v41)->m_bShiftPressed;
v39 = a1;
if ( v42 )
v40 = Right;
else
v40 = SmallRight;
goto LABEL_108;
case KEY_W:
v44 = cocos2d::CCDirector::sharedDirector();
v42 = !v44->getKeyboardDispatcher(v44)->m_bShiftPressed;
v39 = a1;
if ( v42 )
v40 = Up;
else
v40 = SmallUp;
goto LABEL_108;
case KEY_S:
v43 = cocos2d::CCDirector::sharedDirector();
v42 = !v43->getKeyboardDispatcher(v43)->m_bShiftPressed;
v39 = a1;
if ( v42 )
v40 = Down;
else
v40 = SmallDown;
LABEL_108:
EditorUI::moveObjectCall(v39, v40);
goto LABEL_42;
case KEY_R:
EditorUI::toggleEnableRotate(a1, nullptr);
goto LABEL_42;
case KEY_F:
EditorUI::toggleFreeMove(a1, nullptr);
goto LABEL_42;
case KEY_G:
EditorUI::toggleSnap(a1, nullptr);
goto LABEL_42;
case KEY_Enter:
v45 = cocos2d::CCDirector::sharedDirector();
if ( !v45->getKeyboardDispatcher(v45)->m_bControlPressed )
goto LABEL_35;
if ( a1->m_touchID == -1 )
EditorUI::onPlayback(a1, nullptr);
goto LABEL_42;
case KEY_F1:
*(_OWORD *)v77 = ((long double (__fastcall *)(cocos2d::CCLayer *))a1->m_editorLayer->m_objectLayer->getScale)(a1->m_editorLayer->m_objectLayer);
v50 = cocos2d::CCDirector::sharedDirector();
LODWORD(v75) = COERCE_UNSIGNED_INT(cocos2d::CCDirector::getWinSize(v50).width);
v51 = (float)(a1->m_toolbarHeight * 0.5) + (float)(v81.y * 0.5);
v52 = (const cocos2d::CCPoint *)((__int64 (__fastcall *)(cocos2d::CCLayer *, float))a1->m_editorLayer->m_objectLayer->getPosition)(
a1->m_editorLayer->m_objectLayer,
v75);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v82, v52);
p_m_previewPosition = &a1->m_editorLayer->m_previewPosition;
cocos2d::CCPoint::CCPoint(
v84,
(float)-(float)(*(float *)&v82 - (float)(v81.x * 0.5)) / *(float *)v77,
(float)(v51 - *((float *)&v82 + 1)) / *(float *)v77);
cocos2d::CCPoint::operator=(p_m_previewPosition, v54, v55);
v56 = a1->addChild_0;
sub_D153B8((int)&v83, "Preview Locked");
sub_D153B8((int)v84, &byte_F288A0);
v57 = (cocos2d::CCNode *)TextAlertPopup::create(
(TextAlertPopup *)&v83,
(std::string)150LL,
0.5,
0.6,
(int)v84,
v88);
v56(a1, v57, 100);
v49 = (void *)(*(_QWORD *)v84 - 24LL);
if ( (__int64 *)(*(_QWORD *)v84 - 24LL) == &qword_124B6B0 )
{
LABEL_131:
if ( (__int64 *)(*(_QWORD *)&v83 - 24LL) != &qword_124B6B0 )
sub_6865FC((void *)(*(_QWORD *)&v83 - 24LL));
goto LABEL_42;
}
LABEL_130:
sub_6865FC(v49);
goto LABEL_131;
case KEY_F2:
cocos2d::CCPoint::operator=(&a1->m_editorLayer->m_previewPosition, *(float *)&v5, *(float *)&v6);
v47 = a1->addChild_0;
sub_D153B8((int)&v83, "Preview Unlocked");
sub_D153B8((int)v84, &byte_F288A0);
v48 = (cocos2d::CCNode *)TextAlertPopup::create(
(TextAlertPopup *)&v83,
(std::string)150LL,
0.5,
0.6,
(int)v84,
v87);
v47(a1, v48, 100);
v49 = (void *)(*(_QWORD *)v84 - 24LL);
if ( (__int64 *)(*(_QWORD *)v84 - 24LL) == &qword_124B6B0 )
goto LABEL_131;
goto LABEL_130;
}
if ( (unsigned int)(a2 - 114) > 6 )
{
if ( a2 == KEY_Right )
{
EditorUI::onGroupUp(a1, nullptr);
}
else
{
if ( a2 != KEY_Left )
{
LABEL_35:
v10 = cocos2d::CCDirector::sharedDirector();
if ( v10->getKeyboardDispatcher(v10)->m_bAltPressed && a2 == KEY_Up )
{
EditorUI::onTargetIDChange(a1, 1);
}
else
{
v11 = cocos2d::CCDirector::sharedDirector();
if ( v11->getKeyboardDispatcher(v11)->m_bAltPressed && a2 == KEY_Down )
EditorUI::onTargetIDChange(a1, -1);
}
goto LABEL_51;
}
EditorUI::onGroupDown(a1, nullptr);
}
LABEL_42:
if ( a2 == CONTROLLER_Start || a2 == KEY_Enter )
{
if ( a1->m_playtestStopBtn->isVisible(a1->m_playtestStopBtn) )
{
EditorUI::onStopPlaytest(a1, nullptr);
}
else if ( a1->m_touchID == -1 )
{
EditorUI::onPlaytest(a1, nullptr);
}
}
else if ( a2 == KEY_Space )
{
a1->m_spaceSwiping = 1;
}
return;
}
sub_D153B8((int)&v82, &byte_F288A0);
switch ( a2 )
{
case KEY_F6:
v61 = GameManager::sharedState();
GameManager::toggleGameVariable(v61, "0121");
v62 = GameManager::sharedState();
GameVariable = GameManager::getGameVariable(v62, "0121");
sub_D1798C(&v82, "Hide Invisible: ", 16);
goto LABEL_138;
case KEY_F5:
v58 = GameManager::sharedState();
GameManager::toggleGameVariable(v58, "0045");
LevelEditorLayer::updateOptions(a1->m_editorLayer);
v59 = GameManager::sharedState();
GameVariable = GameManager::getGameVariable(v59, "0045");
sub_D1798C(&v82, "Show Hitboxes: ", 15);
LABEL_138:
if ( GameVariable )
sub_D15FD4(&v82, "On", 2);
else
sub_D15FD4(&v82, "Off", 3);
sub_D153B8((int)&v83, v82);
sub_D153B8((int)v84, "chatFont.fnt");
v46 = (TextAlertPopup *)TextAlertPopup::create(
(TextAlertPopup *)&v83,
(std::string)100LL,
0.6,
0.6,
(int)v84,
v86);
if ( (__int64 *)(*(_QWORD *)v84 - 24LL) != &qword_124B6B0 )
sub_6865FC((void *)(*(_QWORD *)v84 - 24LL));
if ( (__int64 *)(*(_QWORD *)&v83 - 24LL) != &qword_124B6B0 )
sub_6865FC((void *)(*(_QWORD *)&v83 - 24LL));
TextAlertPopup::setLabelColor(v46, (cocos2d::ccColor3B)65280);
cocos2d::CCPoint::CCPoint(&v83, 0.0, 1.0);
cocos2d::CCPoint::CCPoint(v84, 20.0, -20.0);
TextAlertPopup::setAlertPosition(v46, v91, v92);
a1->addChild_0(a1, v46, 100);
goto LABEL_69;
case KEY_F4:
v73 = GameManager::sharedState();
GameManager::toggleGameVariable(v73, "0137");
LevelEditorLayer::updatePreviewParticles(a1->m_editorLayer);
v74 = GameManager::sharedState();
GameVariable = !GameManager::getGameVariable(v74, "0137");
sub_D1798C(&v82, "Particle Icons: ", 16);
goto LABEL_138;
case KEY_F3:
v71 = GameManager::sharedState();
GameManager::toggleGameVariable(v71, "0036");
LevelEditorLayer::updateEditorMode(a1->m_editorLayer);
v72 = GameManager::sharedState();
GameVariable = GameManager::getGameVariable(v72, "0036");
sub_D1798C(&v82, "Preview Mode: ", 14);
goto LABEL_138;
case KEY_F7:
v67 = GameManager::sharedState();
if ( GameManager::getGameVariable(v67, "0097") )
{
v68 = GameManager::sharedState();
GameManager::toggleGameVariable(v68, "0180");
v69 = GameManager::sharedState();
v70 = GameManager::getGameVariable(v69, "0180");
a1->m_linkControlsDisabled = v70;
GameVariable = !v70;
EditorUI::updateButtons(a1);
sub_D1798C(&v82, "Link Mode: ", 11);
goto LABEL_138;
}
break;
case KEY_F8:
if ( !(unsigned int)cocos2d::CCArray::count(a1->m_selectedObjects) )
{
m_selectedObject = a1->m_selectedObject;
if ( m_selectedObject )
{
v66 = a1->m_editorLayer;
if ( m_selectedObject == v66->m_traceInObject )
m_selectedObject = nullptr;
v66->m_traceInObject = (EffectGameObject *)m_selectedObject;
}
else
{
a1->m_editorLayer->m_traceInObject = nullptr;
}
GameVariable = a1->m_editorLayer->m_traceInObject != nullptr;
sub_D1798C(&v82, "Trace In: ", 10);
goto LABEL_147;
}
break;
default:
if ( !(unsigned int)cocos2d::CCArray::count(a1->m_selectedObjects) )
{
v63 = a1->m_selectedObject;
if ( v63 )
{
v64 = a1->m_editorLayer;
if ( v63 != v64->m_traceOutObject && v63->m_classType == Effect )
v64->m_traceOutObject = (EffectGameObject *)v63;
else
v64->m_traceOutObject = nullptr;
}
else
{
a1->m_editorLayer->m_traceOutObject = nullptr;
}
GameVariable = a1->m_editorLayer->m_traceOutObject != nullptr;
sub_D1798C(&v82, "Trace Out: ", 11);
LABEL_147:
a1->m_editorLayer->m_unk3b22 = 1;
goto LABEL_138;
}
break;
}
if ( v82 - 24 != (char *)&qword_124B6B0 )
sub_6865FC(v82 - 24);
}