Skip to content
Merged
3 changes: 3 additions & 0 deletions Generals/Code/GameEngine/Include/GameClient/InGameUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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; // TheSuperHackers @feature @ShizCalev 04/04/2025 - Backports Zero Hour's alt-mouse mode's left click deselect functionality
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
Expand Down
5 changes: 5 additions & 0 deletions Generals/Code/GameEngine/Source/GameClient/InGameUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down