Skip to content

Commit e477aa7

Browse files
authored
refactor(input): Simplify click conditions for MSG_RAW_MOUSE_RIGHT_BUTTON_UP (#1499)
1 parent 806ebab commit e477aa7

File tree

2 files changed

+6
-38
lines changed

2 files changed

+6
-38
lines changed

Generals/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -910,30 +910,14 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessa
910910
//-----------------------------------------------------------------------------
911911
case GameMessage::MSG_RAW_MOUSE_RIGHT_BUTTON_UP:
912912
{
913-
ICoord2D delta, pixel;
914-
UnsignedInt currentTime;
915913
Coord3D cameraPos;
916-
917914
TheTacticalView->getPosition(&cameraPos);
918915
cameraPos.sub(&m_deselectDownCameraPosition);
919916

920-
pixel = msg->getArgument( 0 )->pixel;
921-
currentTime = (UnsignedInt) msg->getArgument( 2 )->integer;
922-
923-
delta.x = m_deselectFeedbackAnchor.x - pixel.x;
924-
delta.y = m_deselectFeedbackAnchor.y - pixel.y;
917+
ICoord2D pixel = msg->getArgument( 0 )->pixel;
918+
UnsignedInt currentTime = (UnsignedInt) msg->getArgument( 2 )->integer;
925919

926-
Bool isClick = TRUE;
927-
if (abs(delta.x) > TheMouse->m_dragTolerance || abs(delta.y) > TheMouse->m_dragTolerance)
928-
{
929-
isClick = FALSE;
930-
}
931-
932-
if (isClick &&
933-
currentTime - m_lastClick > TheMouse->m_dragToleranceMS)
934-
{
935-
isClick = FALSE;
936-
}
920+
Bool isClick = TheMouse->isClick(&m_deselectFeedbackAnchor, &pixel, m_lastClick, currentTime);
937921

938922
if (isClick &&
939923
cameraPos.length() > TheMouse->m_dragTolerance3D)

GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -986,30 +986,14 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessa
986986
//-----------------------------------------------------------------------------
987987
case GameMessage::MSG_RAW_MOUSE_RIGHT_BUTTON_UP:
988988
{
989-
ICoord2D delta, pixel;
990-
UnsignedInt currentTime;
991989
Coord3D cameraPos;
992-
993990
TheTacticalView->getPosition(&cameraPos);
994991
cameraPos.sub(&m_deselectDownCameraPosition);
995992

996-
pixel = msg->getArgument( 0 )->pixel;
997-
currentTime = (UnsignedInt) msg->getArgument( 2 )->integer;
998-
999-
delta.x = m_deselectFeedbackAnchor.x - pixel.x;
1000-
delta.y = m_deselectFeedbackAnchor.y - pixel.y;
993+
ICoord2D pixel = msg->getArgument( 0 )->pixel;
994+
UnsignedInt currentTime = (UnsignedInt) msg->getArgument( 2 )->integer;
1001995

1002-
Bool isClick = TRUE;
1003-
if (abs(delta.x) > TheMouse->m_dragTolerance || abs(delta.y) > TheMouse->m_dragTolerance)
1004-
{
1005-
isClick = FALSE;
1006-
}
1007-
1008-
if (isClick &&
1009-
currentTime - m_lastClick > TheMouse->m_dragToleranceMS)
1010-
{
1011-
isClick = FALSE;
1012-
}
996+
Bool isClick = TheMouse->isClick(&m_deselectFeedbackAnchor, &pixel, m_lastClick, currentTime);
1013997

1014998
if (isClick &&
1015999
cameraPos.length() > TheMouse->m_dragTolerance3D)

0 commit comments

Comments
 (0)