Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

fix(gameclient): draw armed-key lines and circles with the left button

Olcay Seygan74783db27aba
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 21842a7dc..2e8468ca7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -159,6 +159,7 @@ found and fixed — EA's own, not port damage.**
- The choice between a Classic and a Reforged interface is gone. There is one, laid out the way Zero Hour shipped, and the orders Reforged added now live on the keys you already know: A attack-moves, holding Ctrl fires on whatever is under the cursor as it did in 2003 (that hold is yours to move on the launcher's Command bar page), a guard order can cover a patch of ground instead of one spot, and orders queue up one after another. Everything your base is building stands on the screen as a line of text each, the six closest to done first and "+N more" for the rest. Superweapon countdowns are listed the same way, up to eighteen. Both lists are in bold type, the build list in white and each countdown in its owner's colour. The promotion screen no longer darkens the battlefield behind it. Whether the right button gives orders, or the left as in 1.04, is a setting in the launcher.
- An attack move and a Ctrl attack fire on the left click in every mouse setup. With the right button giving orders, A then a right click attack-moved, and Ctrl fired only on a right click, so the same hands did different things depending on one checkbox. Now A, or Ctrl held, then a left click is the attack everywhere, and a right click with A armed puts the key down without an order. Ctrl with a right click gives none. Plain orders stay on whichever button your setup gives them.
+- The drags followed the click there. Under the Alternate Mouse Setup the line you draw with attack move or guard armed, the Ctrl circle and the Ctrl+Shift attack line still wanted the right button, and a left drag with A armed drew a selection box instead. All of them, and every guard button, are the left button's now in every setup, and a right drag pans the map with the key still armed. On the radar a left press with A or G armed, or with a general's power waiting for its target, sends the order there, where it used to move the camera; the right button looks.
- Holding the right button on the radar now carries the camera with the cursor when the left button gives orders. The radar has looked with the held button since the last version, but only the left one ever got the drag: the right press moved the camera once and then sat there, so in the game's default setup crossing the map still meant clicking your way over it.
- Ctrl on a garrisoned Bunker fires on a unit as well as the ground, where it used to take only the ground. The soldiers inside do the shooting, and the Air Force General's Combat Chinook takes a Ctrl target the same way. Shift on top of the Ctrl hold keeps it: the pointer stays the force-fire one, and a drag draws the attack line instead of the circle. The Force Attack button 3.1.0 put on the command bar is gone again, since Ctrl already did everything it did, and each bar has its old empty place back.
- The dark plate behind Exit, Restart and the options screen in a match covers the whole picture. It used to sit in a 4:3 frame in the middle, so a widescreen left the battlefield bright down both sides. The box itself keeps the shape it was drawn in.
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
index 6754888d9..ac6c2c546 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
@@ -1148,7 +1148,7 @@ public: // ********************************************************************
Bool isMoveLineHeld( void ) const; ///< shift alone over a selection that can walk: a left drag draws the move line, not the box
Bool wantsDragLine( void ) const; ///< a drag of the order button now draws an order line
Bool wantsDragCircle( void ) const; ///< a drag of the order button now draws the attack circle
- Bool isOrderDragButton( Bool rightButton ) const; ///< lines and circles are drawn with the button that gives the move order
+ Bool isOrderDragButton( Bool rightButton ) const; ///< which button draws the line or circle wanted now: the left for an armed key or Ctrl, else the one that moves
// zeroing the repeat clock makes the first quantized step happen on the very next update, so a
// tap of the key is one eighth and a hold is one eighth every CAMERA_SNAP_REPEAT_MS.
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/SelectionXlat.h b/GeneralsMD/Code/GameEngine/Include/GameClient/SelectionXlat.h
index 503390788..1a797ffc8 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/SelectionXlat.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/SelectionXlat.h
@@ -49,7 +49,6 @@ private:
Bool m_leftMouseButtonIsDown;
Bool m_dragSelecting;
- Bool m_circleOnRight; ///< the attack circle being drawn belongs to the right button, where that is the move button (fork)
Bool m_leftDragIsLine; ///< latched at the press: this left drag draws an order line, so no box grows (fork)
Bool m_dragOrderJustIssued; ///< an attack circle or a left-drawn order line just went out, so eat the click that ends it (fork)
UnsignedInt m_lastGroupSelTime;
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/ControlBarCallback.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/ControlBarCallback.cpp
index be4bf5837..1d15a2ac1 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/ControlBarCallback.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/ControlBarCallback.cpp
@@ -330,16 +330,20 @@ WindowMsgHandledType LeftHUDInput( GameWindow *window, UnsignedInt msg,
break;
}
- // No drawables, or a left press, is a look at, and leaves an armed key armed the way a
- // pan of the main view does. A right press with drawables is an order.
+ // No drawables, or a press of the look button, is a look at, and leaves an armed key armed
+ // the way a pan of the main view does. The other button with drawables is an order.
const DrawableList *drawableList = TheInGameUI->getAllSelectedLocalDrawables(); // locally-owned only
-
+
// see if the user wants to move the tactical view
// Left on the radar looks and right orders, the same division the world has. Classic
// divides the world the other way round, and so did the radar in the game as shipped,
- // except under EA's Alternate Mouse Setup, which looked with the left.
- const UnsignedInt lookButton = TheGlobalData->leftButtonOrders() ? GWM_RIGHT_DOWN : GWM_LEFT_DOWN;
+ // except under EA's Alternate Mouse Setup, which looked with the left. An armed key or a
+ // command waiting for its target is aimed with the left button in every mouse, as it is in
+ // the world, so the right one looks then.
+ const Bool leftAims = TheGlobalData->leftButtonOrders() || TheInGameUI->isOrderKeyArmed()
+ || TheInGameUI->getGUICommand() != NULL;
+ const UnsignedInt lookButton = leftAims ? GWM_RIGHT_DOWN : GWM_LEFT_DOWN;
// that look button held on the radar keeps the camera under the cursor, Classic included
if( drawableList->empty() || msg == lookButton )
{
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
index 462aea09c..0b34144cc 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
@@ -5027,12 +5027,16 @@ Bool InGameUI::wantsDragCircle( void ) const
}
//-------------------------------------------------------------------------------------------------
-/** Every line and the circle are drawn with the button a click on the ground moves with: the left
- * in the default Classic mouse, the right under the Alternate Mouse Setup and the Reforged mouse.
- * The other button keeps its drag: the selection box on the left, the camera pan on the right. */
+/** An armed key's line (move, attack move, guard), the attack key's and Ctrl's circle and Ctrl+Shift's
+ * attack line are drawn with the left button in every mouse, the button their clicks are aimed with;
+ * the right one pans then, and its click puts the key down. Shift's move line is a plain move and is
+ * drawn with the button a click on the ground moves with: the left in the default Classic mouse, the
+ * right under the Alternate Mouse Setup and the Reforged mouse, where the left drag stays the box. */
//-------------------------------------------------------------------------------------------------
Bool InGameUI::isOrderDragButton( Bool rightButton ) const
{
+ if( isOrderKeyArmed() || m_forceAttackMode )
+ return !rightButton;
return rightButton ? TheGlobalData->rightButtonOrders() : TheGlobalData->leftButtonOrders();
}
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
index be475d625..10f328245 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
@@ -4153,18 +4153,19 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage
m_mouseRightDown = (UnsignedInt) msg->getArgument( 2 )->integer;
// a plain right drag pans the camera (LookAtXlat). Where the right button gives the move
- // order, a drag with a line wanted draws the line instead, and LookAtXlat leaves it alone
+ // order, a drag with Shift's move line wanted draws that line instead, and LookAtXlat leaves
+ // it alone. An armed key's line is the left button's in every mouse
if( TheInGameUI->isOrderDragButton( TRUE ) )
armFormationDrag( msg->getArgument( 0 )->pixel, TRUE );
break;
}
//-----------------------------------------------------------------------------
- // A formation line is drawn with the button that gives the move order, the left one in the
- // default mouse, and only once the move, attack move or guard key is armed: a drag without one
- // is a selection box. The attack key and the Force Attack hold keep their drag for the attack
- // circle; shift on the hold draws the attack line here instead, aimed at the enemies near it.
- // Shift alone draws the move line.
+ // A formation line is drawn with the left button in every mouse once the move, attack move or
+ // guard key is armed: a drag without one is a selection box. The attack key and the Force
+ // Attack hold keep their drag for the attack circle; shift on the hold draws the attack line
+ // here instead, aimed at the enemies near it. Shift alone draws the move line, with the button
+ // that gives the move order.
case GameMessage::MSG_RAW_MOUSE_LEFT_DOUBLE_CLICK:
case GameMessage::MSG_RAW_MOUSE_LEFT_BUTTON_DOWN:
{
@@ -4353,7 +4354,8 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage
|| command->getCommandType() == GUI_COMMAND_FIRE_WEAPON
|| command->getCommandType() == GUI_COMMAND_COMBATDROP
|| command->getCommandType() == GUICOMMANDMODE_HIJACK_VEHICLE
- || command->getCommandType() == GUICOMMANDMODE_CONVERT_TO_CARBOMB));
+ || command->getCommandType() == GUICOMMANDMODE_CONVERT_TO_CARBOMB
+ || command->getCommandType() == GUICOMMANDMODE_SABOTAGE_BUILDING));
// Where the right button gives the orders (Reforged, and Classic under EA's Alternate Mouse
// Setup) the left button selects and nothing else. The exceptions are a GUI command that is
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp
index 5bbfee201..6a6af50c0 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp
@@ -459,10 +459,10 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessage
m_lastMouseMoveFrame = TheGameLogic->getFrame();
m_anchor = msg->getArgument( 0 )->pixel;
- // where the right button gives the move order it also draws the order lines and the attack
- // circle (CommandXlat, SelectionXlat), and a drag that draws one does not pan as well
- if( TheInGameUI->isOrderDragButton( TRUE )
- && ( TheInGameUI->wantsDragLine() || TheInGameUI->wantsDragCircle() ) )
+ // where the right button gives the move order it also draws Shift's move line (CommandXlat),
+ // and a drag that draws it does not pan as well. An armed key's lines and the circle are
+ // the left button's in every mouse, so with one armed this press pans
+ if( TheInGameUI->isOrderDragButton( TRUE ) && TheInGameUI->wantsDragLine() )
{
m_rightPanArmed = false;
break;
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp
index 63797640e..948c3bbd6 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp
@@ -303,7 +303,6 @@ SelectionTranslator::SelectionTranslator()
{
m_leftMouseButtonIsDown = FALSE;
m_dragSelecting = FALSE;
- m_circleOnRight = FALSE;
m_leftDragIsLine = FALSE;
m_dragOrderJustIssued = FALSE;
m_lastGroupSelTime = 0;
@@ -457,7 +456,7 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessa
}
// a left drag that draws an order line over in CommandXlat grows no selection box under it.
- // A drag with no line wanted, or with the right button drawing the lines, is the box
+ // A drag with no line wanted, or Shift's move line where the right button draws it, is the box
const Bool leftDragIsOrder = m_leftDragIsLine && TheInGameUI->getSelectCount() > 0;
if (m_leftMouseButtonIsDown && !leftDragIsOrder)
{
@@ -1105,19 +1104,16 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessa
m_selectFeedbackAnchor = msg->getArgument( 0 )->pixel;
// latched here, the same moment CommandXlat latches the line, so letting go of shift
- // mid-drag cannot grow a box under a line that is already being drawn. Lines and the circle
- // belong to the button that moves; where that is the right one, the left drag is the box
+ // mid-drag cannot grow a box under a line that is already being drawn. Shift's move line
+ // belongs to the button that moves; where that is the right one, the left drag is the box
m_leftDragIsLine = TheInGameUI->isOrderDragButton( FALSE ) && TheInGameUI->wantsDragLine();
- // with the attack key armed or the Force Attack hold down the button draws a circle
- // instead of a selection box, and everything hostile inside it becomes a target list. An
- // armed line key (move, attack move, guard) keeps its line under the hold, and shift on top
- // of the hold draws the attack line over in CommandXlat instead.
+ // with the attack key armed or the Force Attack hold down the left button draws a circle
+ // in every mouse instead of a selection box, and everything hostile inside it becomes a
+ // target list. An armed line key (move, attack move, guard) keeps its line under the hold,
+ // and shift on top of the hold draws the attack line over in CommandXlat instead.
if( TheInGameUI->isOrderDragButton( FALSE ) && TheInGameUI->wantsDragCircle() )
- {
TheInGameUI->beginAttackCircle( m_selectFeedbackAnchor );
- m_circleOnRight = FALSE;
- }
break;
}
@@ -1129,9 +1125,9 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessa
{
m_leftMouseButtonIsDown = FALSE;
- // the circle is finished on the same button that drew it: the targets go out here, and the
+ // the circle is finished on the button that drew it: the targets go out here, and the
// click that follows this release has to be eaten or it would reselect under the anchor
- if( TheInGameUI->isAttackCircling() && !m_circleOnRight )
+ if( TheInGameUI->isAttackCircling() )
{
// a circle Ctrl started belongs to no key: undragged, the press was an ordinary Ctrl click
const Bool keyed = TheInGameUI->isOrderKeyArmed() || TheInGameUI->getGUICommand() != NULL;
@@ -1218,31 +1214,12 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessa
m_deselectFeedbackAnchor = msg->getArgument( 0 )->pixel;
m_lastClick = (UnsignedInt) msg->getArgument( 2 )->integer;
TheTacticalView->getPosition( &m_deselectDownCameraPosition );
-
- // where the right button moves, it draws the attack circle as well (LookAtXlat holds its pan)
- if( TheInGameUI->isOrderDragButton( TRUE ) && TheInGameUI->wantsDragCircle() )
- {
- TheInGameUI->beginAttackCircle( m_deselectFeedbackAnchor );
- m_circleOnRight = TRUE;
- }
break;
}
//-----------------------------------------------------------------------------
case GameMessage::MSG_RAW_MOUSE_RIGHT_BUTTON_UP:
{
- // a circle drawn with the right button goes out on its release. A circle that was never
- // dragged was a right click, which falls through to what a right click does under force fire
- if( m_circleOnRight && TheInGameUI->isAttackCircling() )
- {
- m_circleOnRight = FALSE;
- if( TheInGameUI->issueAttackCircle() )
- {
- TheInGameUI->spendOrderKey();
- break;
- }
- }
-
// Classic is 1.04's right release. Only a click counts: the press is the scroll as well
// (LookAtXlat), so a release that travelled, was held, or rode the camera too far is not one.
// The click takes back a waiting GUI command and nothing else, and eats the release, which
diff --git a/GeneralsMD/Code/Tests/test_minimap_input.inc b/GeneralsMD/Code/Tests/test_minimap_input.inc
index 3061fff65..00f5cb42e 100644
--- a/GeneralsMD/Code/Tests/test_minimap_input.inc
+++ b/GeneralsMD/Code/Tests/test_minimap_input.inc
@@ -1,5 +1,7 @@
-// Drive minimap gestures through the actual window and mouse message translators.
+// Drive minimap gestures, and the world's armed-key gestures, through the actual window and mouse
+// message translators.
#include "GameClient/MetaEvent.h"
+#include "GameClient/CommandXlat.h"
#include "GameClient/Keyboard.h"
#include "GameClient/KeyDefs.h"
#include "GameClient/Shell.h"
@@ -514,3 +516,206 @@ TEST(classic_right_click_deselects_or_takes_back_a_command_as_1_04_did)
guard->deleteInstance();
TheSelectionTranslator = savedSelection;
}
+
+namespace
+{
+class OrderButtonUI : public MinimapInputUI
+{
+public:
+ void select(Int count) { m_selectCount = count; }
+ void reset() { clearAttackMoveToMode(); setForceAttackMode(FALSE); clearFormationDrag(); cancelAttackCircle(); m_selectCount = 0; }
+ void placeBuildAvailable(const ThingTemplate*, Drawable*) {}
+ void deselectAllDrawables() {}
+};
+
+OrderButtonUI *orderButtonUI()
+{
+ // kept until process exit, as the other input tests keep theirs
+ static OrderButtonUI *ui = NEW OrderButtonUI;
+ return ui;
+}
+
+// the three mice: Classic, Classic under EA's Alternate Mouse Setup, Reforged
+const Int ORDER_BUTTON_STYLES[3] = { MOUSE_STYLE_CLASSIC, MOUSE_STYLE_CLASSIC, MOUSE_STYLE_REFORGED };
+const Bool ORDER_BUTTON_ALTERNATE[3] = { FALSE, TRUE, FALSE };
+
+GameMessageDisposition sendRawMouse(GameMessageTranslator &translator, GameMessage::Type type, Int x, Int y, Int time)
+{
+ GameMessage *message = newInstance(GameMessage)(type);
+ const ICoord2D pixel = {x, y};
+ message->appendPixelArgument(pixel);
+ message->appendIntegerArgument(0);
+ message->appendIntegerArgument(time);
+ const GameMessageDisposition disp = translator.translateGameMessage(message);
+ message->deleteInstance();
+ return disp;
+}
+
+GameMessageDisposition sendClick(GameMessageTranslator &translator, GameMessage::Type type, Int x, Int y)
+{
+ GameMessage *message = newInstance(GameMessage)(type);
+ IRegion2D region;
+ region.lo.x = region.hi.x = x;
+ region.lo.y = region.hi.y = y;
+ message->appendPixelRegionArgument(region);
+ message->appendIntegerArgument(0);
+ const GameMessageDisposition disp = translator.translateGameMessage(message);
+ message->deleteInstance();
+ return disp;
+}
+}
+
+/* Attack move, guard and the Ctrl hold are aimed with the left button in every mouse, the drag as well
+ as the click. Their lines and circle used to follow the button that orders, so under the Alternate
+ Mouse Setup an attack move line or a Ctrl circle took the right button and the left one drew a box.
+ Shift's plain move line still follows the button that orders. */
+TEST(armed_keys_and_ctrl_drag_with_the_left_button_in_every_mouse_setup)
+{
+ CHECK(bootOnce());
+ MinimapEngineFixture f;
+ OrderButtonUI *ui = orderButtonUI();
+ TheInGameUI = ui;
+ SelectionTranslator *savedSelection = TheSelectionTranslator;
+ f.mouse.m_dragTolerance = 25;
+ f.mouse.m_dragTolerance3D = 25;
+ f.mouse.m_dragToleranceMS = 250;
+ {
+ SelectionTranslator selection;
+ for (Int i = 0; i < 3; ++i)
+ {
+ f.global->m_mouseStyle = ORDER_BUTTON_STYLES[i];
+ f.global->m_useAlternateMouse = ORDER_BUTTON_ALTERNATE[i];
+ f.keyboard.modifiers(0);
+
+ // nothing armed: a line, Shift's move line, belongs to the button that orders
+ ui->reset();
+ ui->select(1);
+ CHECK(ui->isOrderDragButton(FALSE) == f.global->leftButtonOrders());
+ CHECK(ui->isOrderDragButton(TRUE) == f.global->rightButtonOrders());
+
+ // attack move, then guard: the left press latches the line, so the click behind the release
+ // that ends the drag is eaten instead of selecting
+ for (Int key = 0; key < 2; ++key)
+ {
+ ui->reset();
+ ui->select(1);
+ if (key == 0)
+ ui->toggleAttackMoveToMode();
+ else
+ ui->toggleGuardArmed();
+ CHECK(ui->isOrderDragButton(FALSE));
+ CHECK(!ui->isOrderDragButton(TRUE));
+
+ sendRawMouse(selection, GameMessage::MSG_RAW_MOUSE_LEFT_BUTTON_DOWN, 300, 300, 1000);
+ const ICoord2D from = {300, 300}, to = {420, 300};
+ ui->addFormationDragPoint(from);
+ ui->addFormationDragPoint(to);
+ sendRawMouse(selection, GameMessage::MSG_RAW_MOUSE_LEFT_BUTTON_UP, 420, 300, 1200);
+ CHECK(sendClick(selection, GameMessage::MSG_MOUSE_LEFT_CLICK, 420, 300) == DESTROY_MESSAGE);
+ }
+
+ // the Ctrl hold: the right press never starts the attack circle, the left one does
+ ui->reset();
+ ui->select(1);
+ ui->setForceAttackMode(TRUE);
+ f.keyboard.modifiers(KEY_STATE_LCONTROL);
+ sendRawMouse(selection, GameMessage::MSG_RAW_MOUSE_RIGHT_BUTTON_DOWN, 300, 300, 1000);
+ CHECK(!ui->isAttackCircling());
+ sendRawMouse(selection, GameMessage::MSG_RAW_MOUSE_LEFT_BUTTON_DOWN, 300, 300, 1000);
+ CHECK(ui->isAttackCircling());
+ ui->cancelAttackCircle();
+
+ // Ctrl+Shift draws the attack line, on the left as well
+ f.keyboard.modifiers(KEY_STATE_LCONTROL | KEY_STATE_LSHIFT);
+ CHECK(ui->isForceLineHeld());
+ CHECK(ui->isOrderDragButton(FALSE));
+ CHECK(!ui->isOrderDragButton(TRUE));
+ }
+ }
+ f.keyboard.modifiers(0);
+ ui->reset();
+ TheSelectionTranslator = savedSelection;
+}
+
+/* Where the right button gives the orders, a right click with attack move, guard or Ctrl puts the key
+ down and orders nothing, the way a right click takes back any command waiting for its target. A
+ right drag pans and leaves the key armed. */
+TEST(right_click_puts_an_armed_key_down_without_an_order_where_the_right_button_orders)
+{
+ CHECK(bootOnce());
+ MinimapEngineFixture f;
+ MinimapMessages messages;
+ OrderButtonUI *ui = orderButtonUI();
+ TheInGameUI = ui;
+ f.mouse.m_dragTolerance = 25;
+ f.mouse.m_dragTolerance3D = 25;
+ f.mouse.m_dragToleranceMS = 250;
+ {
+ CommandTranslator command;
+ const auto rightClick = [&command](Int dx)
+ {
+ sendRawMouse(command, GameMessage::MSG_RAW_MOUSE_RIGHT_BUTTON_DOWN, 300, 300, 1000);
+ sendRawMouse(command, GameMessage::MSG_RAW_MOUSE_RIGHT_BUTTON_UP, 300 + dx, 300, 1100);
+ return sendClick(command, GameMessage::MSG_MOUSE_RIGHT_CLICK, 300 + dx, 300);
+ };
+ for (Int i = 1; i < 3; ++i)
+ {
+ f.global->m_mouseStyle = ORDER_BUTTON_STYLES[i];
+ f.global->m_useAlternateMouse = ORDER_BUTTON_ALTERNATE[i];
+ for (Int key = 0; key < 2; ++key)
+ {
+ ui->reset();
+ ui->select(1);
+ if (key == 0)
+ ui->toggleAttackMoveToMode();
+ else
+ ui->toggleGuardArmed();
+ CHECK(rightClick(60) == DESTROY_MESSAGE);
+ CHECK(ui->isOrderKeyArmed());
+ CHECK(rightClick(0) == DESTROY_MESSAGE);
+ CHECK(!ui->isOrderKeyArmed());
+ }
+
+ ui->reset();
+ ui->select(1);
+ ui->setForceAttackMode(TRUE);
+ CHECK(rightClick(0) == DESTROY_MESSAGE);
+ CHECK(messages.stream.getFirstMessage() == NULL);
+ }
+ }
+ ui->reset();
+}
+
+/* The radar follows the world: with a key armed the left press is the order and the right one looks,
+ in the mice where the right button orders as well as in Classic's default. */
+TEST(minimap_armed_key_orders_on_the_left_and_looks_on_the_right_in_every_mouse_setup)
+{
+ CHECK(bootOnce());
+ GameClient *savedClient = TheGameClient;
+ TheGameClient = getTestGameClient();
+ for (Int i = 0; i < 3; ++i)
+ {
+ MinimapInputFixture f;
+ MinimapMessages messages;
+ messages.stream.attachTranslator(NEW WindowTranslator, 10);
+ TheWritableGlobalData->m_mouseStyle = ORDER_BUTTON_STYLES[i];
+ TheWritableGlobalData->m_useAlternateMouse = ORDER_BUTTON_ALTERNATE[i];
+ MinimapTestUI *ui = (MinimapTestUI*)TheInGameUI;
+ ui->selected.push_back(NULL);
+ ui->clearAttackMoveToMode();
+ ui->toggleAttackMoveToMode();
+
+ f.event(messages, GameMessage::MSG_RAW_MOUSE_POSITION, 120, 220);
+ f.event(messages, GameMessage::MSG_RAW_MOUSE_RIGHT_BUTTON_DOWN, 120, 220);
+ f.event(messages, GameMessage::MSG_RAW_MOUSE_RIGHT_BUTTON_UP, 120, 220);
+ CHECK(f.engine.view.lookAtCalls == 1);
+ CHECK(ui->isOrderKeyArmed());
+
+ f.event(messages, GameMessage::MSG_RAW_MOUSE_LEFT_BUTTON_DOWN, 120, 220);
+ f.event(messages, GameMessage::MSG_RAW_MOUSE_LEFT_BUTTON_UP, 120, 220);
+ CHECK(f.engine.view.lookAtCalls == 1);
+ CHECK(!ui->isOrderKeyArmed());
+ ui->clearAttackMoveToMode();
+ }
+ TheGameClient = savedClient;
+}