Skip to content

Commit 2a1e6c7

Browse files
committed
Added logic to avoid double deselection on left mouse click.
1 parent 8c156f6 commit 2a1e6c7

5 files changed

Lines changed: 15 additions & 12 deletions

File tree

GeneralsMD/Code/GameEngine/Include/Common/Player.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -645,9 +645,6 @@ class Player : public Snapshot
645645
// adds the given AIGroup to the current selection of this player.
646646
void addAIGroupToCurrentSelection(AIGroup *group);
647647

648-
// returns false if player has object(s) currently selected
649-
Bool isCurrentlySelectedGroupEmpty() const;
650-
651648
// return the requested hotkey squad
652649
Squad *getHotkeySquad(Int squadNumber);
653650

GeneralsMD/Code/GameEngine/Include/GameClient/SelectionXlat.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class SelectionTranslator : public GameMessageTranslator
4242
friend Bool killThemKillThemAllWrapper( Drawable *draw, void *userData );
4343
private:
4444

45+
Bool m_pendingDeselection;
4546
Bool m_leftMouseButtonIsDown;
4647
Bool m_dragSelecting;
4748
UnsignedInt m_lastGroupSelTime;

GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3819,11 +3819,6 @@ void Player::addAIGroupToCurrentSelection(AIGroup *group) {
38193819
}
38203820
}
38213821

3822-
Bool Player::isCurrentlySelectedGroupEmpty() const
3823-
{
3824-
return m_currentSelection->getSizeOfGroup() == 0;
3825-
}
3826-
38273822
//-------------------------------------------------------------------------------------------------
38283823
/** addTypeOfProductionCostChange adds a production change to the typeof list */
38293824
//-------------------------------------------------------------------------------------------------

GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3556,7 +3556,7 @@ void InGameUI::deselectDrawable( Drawable *draw )
35563556
void InGameUI::deselectAllDrawables( Bool updateGameLogic )
35573557
{
35583558
const DrawableList *selected = getAllSelectedDrawables();
3559-
const Bool emptyDrawableSelection = selected->empty();
3559+
const Bool emptySelectedDrawables = selected->empty();
35603560

35613561
// loop through all the selected drawables
35623562
for ( DrawableListCIt it = selected->begin(); it != selected->end(); )
@@ -3579,8 +3579,8 @@ void InGameUI::deselectAllDrawables( Bool updateGameLogic )
35793579

35803580
if (updateGameLogic)
35813581
{
3582-
// TheSuperHackers @tweak Avoid sending this message when no objects are currently selected.
3583-
if (!emptyDrawableSelection || !ThePlayerList->getLocalPlayer()->isCurrentlySelectedGroupEmpty())
3582+
// TheSuperHackers @tweak Only send this message when objects are currently selected.
3583+
if (!emptySelectedDrawables)
35843584
{
35853585
// TheSuperHackers @tweak Originally this message had one boolean argument, but it wasn't used for anything.
35863586
TheMessageStream->appendMessage(GameMessage::MSG_DESTROY_SELECTED_GROUP);

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ SelectionTranslator *TheSelectionTranslator = nullptr;
249249
//-----------------------------------------------------------------------------
250250
SelectionTranslator::SelectionTranslator()
251251
{
252+
m_pendingDeselection = FALSE;
252253
m_leftMouseButtonIsDown = FALSE;
253254
m_dragSelecting = FALSE;
254255
m_lastGroupSelTime = 0;
@@ -738,6 +739,7 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessa
738739
{
739740
if (!addToGroup)
740741
{
742+
m_pendingDeselection = FALSE;
741743
TheInGameUI->deselectAllDrawables(FALSE);
742744
}
743745

@@ -939,7 +941,7 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessa
939941
{
940942
if( !TheInGameUI->getPreventLeftClickDeselectionInAlternateMouseModeForOneClick() )
941943
{
942-
TheInGameUI->deselectAllDrawables();
944+
m_pendingDeselection = TRUE;
943945
m_lastGroupSelGroup = -1;
944946
}
945947
else
@@ -1318,6 +1320,14 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessa
13181320
#endif
13191321
}
13201322

1323+
// TheSuperHackers @tweak Avoid double deselection when selecting a new object with another object selected,
1324+
// triggered by RAW_MOUSE_LEFT_BUTTON_UP and MOUSE_LEFT_CLICK, respectively.
1325+
if (msg->getType() == GameMessage::MSG_MOUSE_LEFT_CLICK && m_pendingDeselection)
1326+
{
1327+
m_pendingDeselection = FALSE;
1328+
TheInGameUI->deselectAllDrawables();
1329+
}
1330+
13211331
return disp;
13221332
}
13231333

0 commit comments

Comments
 (0)