完善游戏映射

This commit is contained in:
Barry 2018-11-21 21:27:54 +08:00
commit c73874246e
2 changed files with 29 additions and 5 deletions

View file

@ -49,11 +49,21 @@ void InputConvertGame::keyEvent(const QKeyEvent *from, const QSize& frameSize, c
switch (from->key()) { switch (from->key()) {
case Qt::Key_QuoteLeft: case Qt::Key_QuoteLeft:
if (QEvent::KeyPress == from->type()) { if (QEvent::KeyPress == from->type()) {
switchGameMap(); if (!switchGameMap()) {
m_needSwitchGameAgain = false;
}
} }
return; return;
} }
if (m_needSwitchGameAgain) {
updateSize(frameSize, showSize);
// Qt::Key_Tab Qt::Key_M
if (processKeyClick(from)) {
return;
}
}
if (m_gameMap) { if (m_gameMap) {
updateSize(frameSize, showSize); updateSize(frameSize, showSize);
if (!from || from->isAutoRepeat()) { if (!from || from->isAutoRepeat()) {
@ -267,12 +277,14 @@ bool InputConvertGame::processKeyClick(const QKeyEvent *from)
break; break;
case Qt::Key_M: // 地图 case Qt::Key_M: // 地图
if (QEvent::KeyRelease == from->type()) { if (QEvent::KeyRelease == from->type()) {
m_needSwitchGameAgain = !m_needSwitchGameAgain;
switchGameMap(); switchGameMap();
} }
clickPos = QPointF(0.98f, 0.03f); clickPos = QPointF(0.98f, 0.03f);
break; break;
case Qt::Key_Tab: // 背包 case Qt::Key_Tab: // 背包
if (QEvent::KeyRelease == from->type()) { if (QEvent::KeyRelease == from->type()) {
m_needSwitchGameAgain = !m_needSwitchGameAgain;
switchGameMap(); switchGameMap();
} }
clickPos = QPointF(0.06f, 0.9f); clickPos = QPointF(0.06f, 0.9f);
@ -307,15 +319,24 @@ bool InputConvertGame::processKeyClick(const QKeyEvent *from)
case Qt::Key_3: // 手雷 case Qt::Key_3: // 手雷
clickPos = QPointF(0.67f, 0.92f); clickPos = QPointF(0.67f, 0.92f);
break; break;
case Qt::Key_4: // 快速打药
clickPos = QPointF(0.33f, 0.95f);
break;
case Qt::Key_5: // 下车 case Qt::Key_5: // 下车
clickPos = QPointF(0.92f, 0.4f); clickPos = QPointF(0.92f, 0.4f);
break; break;
case Qt::Key_6: // 救人
clickPos = QPointF(0.49f, 0.63f);
break;
case Qt::Key_Shift: // 车加速 case Qt::Key_Shift: // 车加速
clickPos = QPointF(0.82f, 0.8f); clickPos = QPointF(0.82f, 0.8f);
break; break;
case Qt::Key_4: // 开关门 case Qt::Key_X: // 开关门
clickPos = QPointF(0.7f, 0.7f); clickPos = QPointF(0.7f, 0.7f);
break; break;
case Qt::Key_T: // 舔包
clickPos = QPointF(0.72f, 0.26f);
break;
case Qt::Key_Q: // 左探头 case Qt::Key_Q: // 左探头
clickTwice = true; clickTwice = true;
clickPos = QPointF(0.12f, 0.35f); clickPos = QPointF(0.12f, 0.35f);
@ -458,7 +479,7 @@ void InputConvertGame::mouseMoveStopTouch()
} }
} }
void InputConvertGame::switchGameMap() bool InputConvertGame::switchGameMap()
{ {
m_gameMap = !m_gameMap; m_gameMap = !m_gameMap;
emit grabCursor(m_gameMap); emit grabCursor(m_gameMap);
@ -468,6 +489,7 @@ void InputConvertGame::switchGameMap()
mouseMoveStopTouch(); mouseMoveStopTouch();
QGuiApplication::restoreOverrideCursor(); QGuiApplication::restoreOverrideCursor();
} }
return m_gameMap;
} }
bool InputConvertGame::checkCursorPos(const QMouseEvent *from) bool InputConvertGame::checkCursorPos(const QMouseEvent *from)

View file

@ -51,7 +51,7 @@ protected:
void mouseMoveStartTouch(const QMouseEvent* from); void mouseMoveStartTouch(const QMouseEvent* from);
void mouseMoveStopTouch(); void mouseMoveStopTouch();
void switchGameMap(); bool switchGameMap();
bool checkCursorPos(const QMouseEvent* from); bool checkCursorPos(const QMouseEvent* from);
protected: protected:
@ -86,6 +86,8 @@ private:
QPointF m_mouseMoveLastPos = {0.0f, 0.0f}; QPointF m_mouseMoveLastPos = {0.0f, 0.0f};
bool m_mouseMovePress = false; bool m_mouseMovePress = false;
int m_mouseMoveTimer = 0; int m_mouseMoveTimer = 0;
bool m_needSwitchGameAgain = false;
}; };
#endif // INPUTCONVERTGAME_H #endif // INPUTCONVERTGAME_H