diff --git a/Generals/Code/GameEngine/Include/GameClient/InGameUI.h b/Generals/Code/GameEngine/Include/GameClient/InGameUI.h index f349892ec5..4286ef71ee 100644 --- a/Generals/Code/GameEngine/Include/GameClient/InGameUI.h +++ b/Generals/Code/GameEngine/Include/GameClient/InGameUI.h @@ -416,6 +416,8 @@ friend class Drawable; // for selection/deselection transactions virtual void placeBuildAvailable( const ThingTemplate *build, Drawable *buildDrawable ); ///< built thing being placed virtual const ThingTemplate *getPendingPlaceType( void ); ///< get item we're trying to place virtual const ObjectID getPendingPlaceSourceObjectID( void ); ///< get producing object + virtual Bool getPreventLeftClickDeselectionInAlternateMouseModeForOneClick() const { return m_preventLeftClickDeselectionInAlternateMouseModeForOneClick; } + virtual void setPreventLeftClickDeselectionInAlternateMouseModeForOneClick( Bool set ) { m_preventLeftClickDeselectionInAlternateMouseModeForOneClick = set; } virtual void setPlacementStart( const ICoord2D *start ); ///< placement anchor point (for choosing angles) virtual void setPlacementEnd( const ICoord2D *end ); ///< set target placement point (for choosing angles) virtual Bool isPlacementAnchored( void ); ///< is placement arrow anchor set @@ -692,6 +694,7 @@ friend class Drawable; // for selection/deselection transactions BuildProgress m_buildProgress[ MAX_BUILD_PROGRESS ]; ///< progress for building units const ThingTemplate * m_pendingPlaceType; ///< type of built thing we're trying to place ObjectID m_pendingPlaceSourceObjectID; ///< source object of the thing constructing the item + Bool m_preventLeftClickDeselectionInAlternateMouseModeForOneClick; Drawable ** m_placeIcon; ///< array for drawables to appear at the cursor when building in the world Bool m_placeAnchorInProgress; ///< is place angle interface for placement active ICoord2D m_placeAnchorStart; ///< place angle anchor start diff --git a/Generals/Code/GameEngine/Source/GameClient/InGameUI.cpp b/Generals/Code/GameEngine/Source/GameClient/InGameUI.cpp index 6c074b9247..c6b7f738be 100644 --- a/Generals/Code/GameEngine/Source/GameClient/InGameUI.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/InGameUI.cpp @@ -905,6 +905,7 @@ InGameUI::InGameUI() m_placeIcon[ i ] = NULL; m_pendingPlaceType = NULL; m_pendingPlaceSourceObjectID = INVALID_ID; + m_preventLeftClickDeselectionInAlternateMouseModeForOneClick = FALSE; m_placeAnchorStart.x = m_placeAnchorStart.y = 0; m_placeAnchorEnd.x = m_placeAnchorEnd.y = 0; m_placeAnchorInProgress = FALSE; @@ -2878,6 +2879,10 @@ void InGameUI::placeBuildAvailable( const ThingTemplate *build, Drawable *buildD // place something, it is overwritten // m_pendingPlaceType = build; + + //Keep the prev pending place for left click deselection prevention in alternate mouse mode. + //We want to keep our dozer selected after initiating construction. + setPreventLeftClickDeselectionInAlternateMouseModeForOneClick( m_pendingPlaceSourceObjectID != INVALID_ID ); m_pendingPlaceSourceObjectID = INVALID_ID; Object *sourceObject = NULL; diff --git a/Generals/Code/GameEngine/Source/GameClient/MessageStream/GUICommandTranslator.cpp b/Generals/Code/GameEngine/Source/GameClient/MessageStream/GUICommandTranslator.cpp index 712dc707c2..788bffdea0 100644 --- a/Generals/Code/GameEngine/Source/GameClient/MessageStream/GUICommandTranslator.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/MessageStream/GUICommandTranslator.cpp @@ -492,7 +492,10 @@ GameMessageDisposition GUICommandTranslator::translateGameMessage(const GameMess // get out of GUI command mode if we completed the command one way or another if( commandStatus == COMMAND_COMPLETE ) + { + TheInGameUI->setPreventLeftClickDeselectionInAlternateMouseModeForOneClick( TRUE ); TheInGameUI->setGUICommand( NULL ); + } } // end if break; diff --git a/Generals/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp b/Generals/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp index aa60a4139d..b1b2ac9f23 100644 --- a/Generals/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp @@ -870,6 +870,30 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessa buildRegion( &m_selectFeedbackAnchor, &msg->getArgument(0)->pixel, &selectionRegion ); dragMsg->appendPixelRegionArgument( selectionRegion ); } + else + { + // left click behavior (not right drag) + + //Added support to cancel the GUI command without deselecting the unit(s) involved + //when you right click. + if( !TheInGameUI->getGUICommand() && !TheKeyboard->isShift() && !TheKeyboard->isCtrl() && !TheKeyboard->isAlt() ) + { + //No GUI command mode, so deselect everyone if we're in alternate mouse mode. + if( TheGlobalData->m_useAlternateMouse && TheInGameUI->getPendingPlaceSourceObjectID() == INVALID_ID ) + { + if( !TheInGameUI->getPreventLeftClickDeselectionInAlternateMouseModeForOneClick() ) + { + deselectAll(); + } + else + { + //Prevent deselection of unit if it just issued some type of UI order such as attack move, guard, + //initiating construction of a new structure. + TheInGameUI->setPreventLeftClickDeselectionInAlternateMouseModeForOneClick( FALSE ); + } + } + } + } break; }