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.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
feat(gameclient): replay strip, observer look-through, side-button tilt
Olcay Seyganb7a3f5de2ca9
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex a775ec995..8d8727cc9 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -364,6 +364,7 @@ found and fixed — EA's own, not port damage.**- Shift and a number puts what you have selected into that control group and keeps everyone already in it, the way StarCraft does it. Fresh tanks off the line join group 1 with one key, where you used to select group 1, shift-click the new tanks in and press Ctrl+1 again. The selection stays as it is. Retail used Shift and a number to pull a group into your selection instead; that is gone, and Alt and the number still centres the view on the group.- Ordering a very large army works. A selection of more than 254 units reaches the game whole, and Ctrl+number groups keep all their units.- Hold Alt and drag with the middle mouse button, or hold Alt and turn the wheel, to tilt the camera between 20 and 60 degrees. Home resets heading, tilt and zoom, the way Numpad 5 does.+- The side buttons on your mouse tilt the camera five degrees a press, forward flatter and back steeper, on Windows, Mac and Linux. The game used to ignore them.## Aircraft, guards, and orders that used to be ignored@@ -542,6 +543,7 @@ found and fixed — EA's own, not port damage.**- A replay whose header the game cannot read warns you instead of starting anyway. It used toreport the file as compatible and go straight into playback on something it had already failed toparse.+- The replay has a control strip over the middle of the command bar: the time reached and the whole length, a pause button and five speeds from 0.5x to 8x, and the timeline under them. Drag along the timeline and the replay jumps when you let go, not once for every pixel you crossed. Grab the strip anywhere else and put it where you like; a double click sends it home. P pauses, minus and plus step through the speeds, unless your keys give those letters to something else.## Placing a building, then changing your mind@@ -873,6 +875,7 @@ A third pass went through the generals' powers, promotions and unit abilities.- The command bar slides up from the bottom of the screen again when a match starts. The new steel frame had been drawn at its final place from the first frame, so the buttons rose into a frame that was already standing.- A building that is still going up shows Cancel on S, and the seconds it has left across the top of the grid. A map building that hands out units shows that countdown there too, with the bar under it. Sell stands on N. One that sets a rally point puts that on B instead. Both used to stay where the old command panel had drawn them, off the new grid.- The Escape menu is Zero Hour's own again, the window, the logo, the buttons and the way it opens, along with the box that asks whether you really want to leave. The steel plate that replaced it for a while, and ControlBar Pro's version after that, are gone. Options on it opens the volume sliders, since every other setting lives in the launcher. The promotion screen opens across the middle of the screen.+- Watching, click a player's button on the observer bar and you see through his eyes: his fog and his camera. The same button again, the cancel button or Esc gives you the whole map and the camera you had before.## Placing buildingsdiff --git a/GeneralsMD/Code/Data/Patch.str b/GeneralsMD/Code/Data/Patch.strindex a58cb11f5..ee60b9ef4 100644--- a/GeneralsMD/Code/Data/Patch.str+++ b/GeneralsMD/Code/Data/Patch.str@@ -84,6 +84,11 @@ GUI:GameResumed"Game resumed."END+// The replay strip's pause button while the replay is paused.+GUI:ReplayResume+"Resume"+END+// Skirmish lobby: an opponent seat with no AI behind it (Shift-Ctrl-T takes it over).GUI:HumanSlot"Human"@@ -1116,6 +1121,10 @@ CONTROLBAR:MoneyDescription"The money you have, and what you earned a second over the last half minute"END+CONTROLBAR:ObsLookingThrough+"Watching through %ls's eyes. Esc brings back the whole map."+END+GUI:ScoreboardFavourite"FAVOURITE"ENDdiff --git a/GeneralsMD/Code/Data/Turkish/Generals.str b/GeneralsMD/Code/Data/Turkish/Generals.strindex ad0a135f7..eb924dabf 100644--- a/GeneralsMD/Code/Data/Turkish/Generals.str+++ b/GeneralsMD/Code/Data/Turkish/Generals.str@@ -9229,6 +9229,10 @@ CONTROLBAR:ObsPlayerLabel"%ls (Takım %ls)"END+CONTROLBAR:ObsLookingThrough+"Haritayı %ls oyuncusunun gözünden izliyorsun. Esc tüm haritayı geri getirir."+END+GUI:LowTextureDetail"Düşük Doku Ayrıntısı"END@@ -14697,6 +14701,10 @@ GUI:GameResumed"Oyun devam ediyor."END+GUI:ReplayResume+"Sürdür"+END+GUI:HumanSlot"İnsan"ENDdiff --git a/GeneralsMD/Code/GameEngine/Include/Common/MessageStream.h b/GeneralsMD/Code/GameEngine/Include/Common/MessageStream.hindex 63d5be191..763d61bdb 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/MessageStream.h+++ b/GeneralsMD/Code/GameEngine/Include/Common/MessageStream.h@@ -142,6 +142,7 @@ public:MSG_RAW_MOUSE_RIGHT_BUTTON_UP, ///< (pixel, modifiers, time)MSG_RAW_MOUSE_RIGHT_DRAG, ///< drag of the mouse with a button held downMSG_RAW_MOUSE_WHEEL, ///< (Real spin in notches, + is away, - is toward user)+ MSG_RAW_MOUSE_SIDE_BUTTON, ///< (pixel, Int +1 forward/X2 or -1 back/X1, modifiers) a side button went down (fork)MSG_RAW_MOUSE_END,MSG_RAW_KEY_DOWN, ///< (KeyDefType) the given key was pressed (uses Microsoft VK_ codes)diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/GUICallbacks.h b/GeneralsMD/Code/GameEngine/Include/GameClient/GUICallbacks.hindex fd3eb6fbc..f8586c59c 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/GUICallbacks.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/GUICallbacks.h@@ -329,6 +329,8 @@ extern void ShowControlBar( Bool immediate = TRUE );// Replay Controls --------------------------------------------------------------------------------extern WindowMsgHandledType ReplayControlSystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 );extern WindowMsgHandledType ReplayControlInput( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 );+extern void ReplayControlDraw( GameWindow *window, WinInstanceData *instData );+extern void ReplayControlStepSpeed( Int step ); ///< the replay one speed button faster (+1) or slower (-1)// InGame Chat Controls --------------------------------------------------------------------------------diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/Mouse.h b/GeneralsMD/Code/GameEngine/Include/GameClient/Mouse.hindex c50b65182..913523ada 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/Mouse.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/Mouse.h@@ -127,6 +127,7 @@ struct MouseIOInt wheelPos; /**< mouse wheel position, 0 is no event, + is up/away fromuser while - is down/toward user */+ Int sideButton; ///< a side button went down: +1 forward (X2), -1 back (X1), 0 noneICoord2D deltaPos; ///< overall change in mouse pointer this frameMouseButtonState leftState; // button state: Up, Down, DoubleClick (Which is also down)diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/ObserverCamera.h b/GeneralsMD/Code/GameEngine/Include/GameClient/ObserverCamera.hindex 056797fcd..4a846f2d2 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/ObserverCamera.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/ObserverCamera.h@@ -406,6 +406,11 @@ public:Bool isDriving( void ) const { return m_driving; }Bool isFogOn( void ) const { return m_fog; }void setFog( Bool fog ) { m_fog = fog; }+ /// a player picked on the observer bar: his fog on the screen and his camera driving it, until+ /// stopLooking puts back the whole map and the camera the watcher had before+ void lookThrough( Int playerIndex );+ /// FALSE when nobody was followed and no fog was on, so there was nothing to take back+ Bool stopLooking( void );/// the player whose fog the screen is drawn in: the local player, or whoever a watcher with fog/// on is following@@ -551,6 +556,7 @@ private:Coord2D m_skippedFight; ///< the last fizzling fight the director passed over, so it is logged onceObserverCameraMode m_mode;+ ObserverCameraMode m_modeBeforeLook; ///< what stopLooking gives back; kept across a rewind's resetInt m_followed;Bool m_fog;Int m_shroudViewer;diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarObserver.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarObserver.cppindex 2fd8fed90..994b10ee6 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarObserver.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarObserver.cpp@@ -66,6 +66,8 @@#include "GameClient/GadgetPushButton.h"#include "GameClient/GadgetStaticText.h"#include "GameClient/GameText.h"+#include "GameClient/InGameUI.h"+#include "GameClient/ObserverCamera.h"#include "GameNetwork/NetworkDefs.h"//-----------------------------------------------------------------------------// DEFINES ////////////////////////////////////////////////////////////////////@@ -163,6 +165,7 @@ WindowMsgHandledType ControlBarObserverSystem( GameWindow *window, UnsignedInt mInt controlID = control->winGetWindowId();if( controlID == buttonCancelID){+ TheObserverCamera.stopLooking();TheControlBar->setObserverLookAtPlayer(NULL);ObserverPlayerInfoWindow->winHide(TRUE);ObserverPlayerListWindow->winHide(FALSE);@@ -173,11 +176,24 @@ WindowMsgHandledType ControlBarObserverSystem( GameWindow *window, UnsignedInt m{if( controlID == buttonPlayerID[i]){+ // his button is a look through his eyes: his fog, his camera; the same button again,+ // the cancel button or Esc gives the whole map back. All of it is this screen's+ // picture, nothing reaches the logic+ Player *picked = (Player *) GadgetButtonGetData( buttonPlayer[i] );+ if( TheObserverCamera.isFogOn() && TheObserverCamera.getFollowedPlayerIndex() == picked->getPlayerIndex() )+ {+ TheObserverCamera.stopLooking();+ TheControlBar->watchPlayer( NULL );+ return MSG_HANDLED;+ }+ TheInGameUI->deselectAllDrawables();+ TheObserverCamera.lookThrough( picked->getPlayerIndex() );+ TheInGameUI->message( AsciiString( "CONTROLBAR:ObsLookingThrough" ), picked->getPlayerDisplayName().str() );+ObserverPlayerInfoWindow->winHide(FALSE);ObserverPlayerListWindow->winHide(TRUE);- TheControlBar->setObserverLookAtPlayer((Player *) GadgetButtonGetData( buttonPlayer[i]));- if(TheControlBar->getObserverLookAtPlayer())- TheControlBar->populateObserverInfoWindow();+ TheControlBar->setObserverLookAtPlayer(picked);+ TheControlBar->populateObserverInfoWindow();return MSG_HANDLED;}}diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/ReplayControls.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/ReplayControls.cppindex 924649b7d..ac548e38b 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/ReplayControls.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/ReplayControls.cpp@@ -30,20 +30,362 @@// INCLUDES ///////////////////////////////////////////////////////////////////////////////////////#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine+#include "Common/GameEngine.h"+#include "Common/GlobalData.h"+#include "Common/NameKeyGenerator.h"+#include "Common/Recorder.h"+#include "GameClient/ControlBar.h"+#include "GameClient/Display.h"+#include "GameClient/DisplayString.h"+#include "GameClient/DisplayStringManager.h"#include "GameClient/GameWindow.h"+#include "GameClient/GameWindowManager.h"#include "GameClient/Gadget.h"#include "GameClient/GameClient.h"+#include "GameClient/GameText.h"+#include "GameClient/GlobalLanguage.h"+#include "GameClient/GUICallbacks.h"+#include "GameClient/InGameUI.h"+#include "GameClient/Mouse.h"+#include "GameLogic/GameLogic.h"//--------------------------------------------------------------------------------------------------/** Input procedure for the control bar */+// The replay strip: the time reached and the whole length, pause, five speeds and the timeline,+// drawn by ReplayControl.wnd's parent window itself, standing over the middle of the command bar.+// EA's children in that layout (Slower, Faster, Pause, NextFrame) stay hidden. Every press goes+// through InGameUI::runSpectatorAction, the path the control socket takes, so a click and a script+// move the replay the same way. The timeline jumps when the button is let go, not while it is+// dragged: a jump back loads a checkpoint, and a drag would load one for every pixel it crossed.+//-------------------------------------------------------------------------------------------------++/// percent of the rate the game was played at+static const Int REPLAY_SPEEDS[] = { 50, 100, 200, 400, 800 };+static const WideChar *const REPLAY_SPEED_LABELS[] = { u"0.5x", u"1x", u"2x", u"4x", u"8x" };+static const Int REPLAY_SPEED_COUNT = (Int)ARRAY_SIZE( REPLAY_SPEEDS );+/// the pause button first, then the speeds+static const Int REPLAY_BUTTONS = 1 + REPLAY_SPEED_COUNT;++/// the strip in the command bar's own units, ControlBarHudScale() pixels each+enum+{+ STRIP_WIDTH = 300, STRIP_HEIGHT = 40, STRIP_PAD = 5, STRIP_GAP = 4, ROW_HEIGHT = 14,+ PAUSE_WIDTH = 56, SPEED_WIDTH = 30, BUTTON_GAP = 2, TRACK_HEIGHT = 12, FONT_SIZE = 9+};++/// the window's own strings, freed with it+struct ReplayStripText+{+ DisplayString *clock;+ DisplayString *buttons[ REPLAY_BUTTONS ];+};++struct ReplayStripLayout+{+ IRegion2D strip;+ IRegion2D track;+ IRegion2D buttons[ REPLAY_BUTTONS ];+ ICoord2D clock;+ Real unit;+};++/// a press on the timeline not yet let go, and the frame under the pointer+static Bool TheReplayStripDragging = FALSE;+static UnsignedInt TheReplayStripDragFrame = 0;++/// The strip can be carried by its ground (not a button, not the timeline) anywhere on the screen,+/// and a double click there puts it back over the money readout. Where it was put is kept in+/// screen pixels and held to the screen, so a resolution change cannot lose it off an edge.+static Bool TheReplayStripMoving = FALSE;+static Bool TheReplayStripPlaced = FALSE;+static ICoord2D TheReplayStripCorner = { 0, 0 };+static ICoord2D TheReplayStripGrab = { 0, 0 }; ///< the pointer less the strip's corner at the press++/** 1x: the rate the game was played at. A skirmish on its fast setting recorded 60. */+static Int replayNormalFramesPerSecond( void )+{+ const Int recorded = TheRecorder->getPlaybackFramesPerSecond();+ return recorded > 0 ? recorded : LOGICFRAMES_PER_SECOND;+}++/** The speed button lit now, -1 for a speed that is none of them. */+static Int replaySpeedIndex( void )+{+ const Int speed = TheGameEngine->getFramesPerSecondLimit() * 100 / replayNormalFramesPerSecond();+ for( Int each = 0; each < REPLAY_SPEED_COUNT; each++ )+ if( REPLAY_SPEEDS[ each ] == speed )+ return each;+ return -1;+}++/** The replay's length, or the frame reached if the header never had it written. */+static UnsignedInt replayLength( void )+{+ return max( TheRecorder->getPlaybackFrameDuration(), TheGameLogic->getFrame() );+}++static UnicodeString replayClock( UnsignedInt frame )+{+ const Int seconds = (Int)( frame / LOGICFRAMES_PER_SECOND );+ UnicodeString text;+ if( seconds >= 60 * 60 )+ text.format( u"%d:%02d:%02d", seconds / ( 60 * 60 ), seconds / 60 % 60, seconds % 60 );+ else+ text.format( u"%d:%02d", seconds / 60, seconds % 60 );+ return text;+}++/** Centred over the money readout, the middle of the command bar, at the bar's own scale. */+static ReplayStripLayout layOutReplayStrip( void )+{+ ReplayStripLayout layout;+ layout.unit = ControlBarHudScale();+ const Real u = layout.unit;++ GameWindow *money = TheWindowManager->winGetWindowFromId( NULL,+ TheNameKeyGenerator->nameToKey( AsciiString( "ControlBar.wnd:ControlBarProBlockInputMoney" ) ) );+ ICoord2D above, aboveSize;+ money->winGetScreenPosition( &above.x, &above.y );+ money->winGetSize( &aboveSize.x, &aboveSize.y );++ const Int width = REAL_TO_INT_FLOOR( STRIP_WIDTH * u );+ const Int height = REAL_TO_INT_FLOOR( STRIP_HEIGHT * u );+ const Int pad = REAL_TO_INT_FLOOR( STRIP_PAD * u );+ layout.strip.lo.x = above.x + aboveSize.x / 2 - width / 2;+ layout.strip.lo.y = above.y - REAL_TO_INT_FLOOR( STRIP_GAP * u ) - height;+ if( TheReplayStripPlaced )+ {+ layout.strip.lo.x = clamp( 0, TheReplayStripCorner.x, (Int)TheDisplay->getWidth() - width );+ layout.strip.lo.y = clamp( 0, TheReplayStripCorner.y, (Int)TheDisplay->getHeight() - height );+ }+ layout.strip.hi.x = layout.strip.lo.x + width;+ layout.strip.hi.y = layout.strip.lo.y + height;++ layout.clock.x = layout.strip.lo.x + pad;+ layout.clock.y = layout.strip.lo.y + pad;++ // the buttons right-aligned on the first row, the last speed at the right edge+ const Int rowTop = layout.strip.lo.y + pad;+ Int right = layout.strip.hi.x - pad;+ for( Int each = REPLAY_BUTTONS - 1; each >= 0; each-- )+ {+ IRegion2D &button = layout.buttons[ each ];+ button.hi.x = right;+ button.lo.x = right - REAL_TO_INT_FLOOR( ( each == 0 ? PAUSE_WIDTH : SPEED_WIDTH ) * u );+ button.lo.y = rowTop;+ button.hi.y = rowTop + REAL_TO_INT_FLOOR( ROW_HEIGHT * u );+ right = button.lo.x - REAL_TO_INT_FLOOR( BUTTON_GAP * u );+ }++ layout.track.lo.x = layout.strip.lo.x + pad;+ layout.track.hi.x = layout.strip.hi.x - pad;+ layout.track.lo.y = rowTop + REAL_TO_INT_FLOOR( ( ROW_HEIGHT + STRIP_GAP ) * u );+ layout.track.hi.y = layout.track.lo.y + REAL_TO_INT_FLOOR( TRACK_HEIGHT * u );+ return layout;+}++static Bool regionHolds( const IRegion2D ®ion, Int x, Int y )+{+ return x >= region.lo.x && x < region.hi.x && y >= region.lo.y && y < region.hi.y;+}++/** The frame under a pointer at this x on the timeline. */+static UnsignedInt replayFrameAt( const ReplayStripLayout &layout, Int x )+{+ const Real share = clamp( 0.0f, (Real)( x - layout.track.lo.x ) / (Real)( layout.track.hi.x - layout.track.lo.x ), 1.0f );+ return REAL_TO_UNSIGNEDINT( share * replayLength() );+}++static void endReplayStripDrag( void )+{+ TheReplayStripDragging = FALSE;+ TheInGameUI->runSpectatorAction( "replay:seek:" + std::to_string( TheReplayStripDragFrame ) );+}++static void setReplaySpeed( Int index )+{+ TheInGameUI->runSpectatorAction( "replay:speed:" + std::to_string( REPLAY_SPEEDS[ index ] ) );+}++//-------------------------------------------------------------------------------------------------+/** One speed up or down from the one lit, for the keys. A speed that is none of the buttons' steps+ * from 1x. */+//-------------------------------------------------------------------------------------------------+void ReplayControlStepSpeed( Int step )+{+ const Int lit = replaySpeedIndex();+ const Int from = lit >= 0 ? lit : 1;+ setReplaySpeed( clamp( 0, from + step, REPLAY_SPEED_COUNT - 1 ) );+}++//-------------------------------------------------------------------------------------------------+/** The strip draws itself and moves itself onto the command bar every frame: the bar is laid out+ * again on a resolution change, and the strip has to follow it. */+//-------------------------------------------------------------------------------------------------+void ReplayControlDraw( GameWindow *window, WinInstanceData *instData )+{+ // let go somewhere off the strip, where the window manager does not tell the strip+ if( TheReplayStripDragging && TheMouse->getMouseStatus()->leftState == MBS_Up )+ endReplayStripDrag();++ // carried from the pointer itself, so a quick move that leaves the strip behind still takes it+ if( TheReplayStripMoving )+ {+ const MouseIO *pointer = TheMouse->getMouseStatus();+ if( pointer->leftState == MBS_Up )+ TheReplayStripMoving = FALSE;+ else+ {+ // a press that has not moved leaves the strip home, still following the command bar+ const IRegion2D now = layOutReplayStrip().strip;+ const ICoord2D corner = { pointer->pos.x - TheReplayStripGrab.x, pointer->pos.y - TheReplayStripGrab.y };+ if( corner.x != now.lo.x || corner.y != now.lo.y )+ {+ TheReplayStripPlaced = TRUE;+ TheReplayStripCorner = corner;+ }+ }+ }++ const ReplayStripLayout layout = layOutReplayStrip();+ const IRegion2D &strip = layout.strip;+ window->winSetPosition( strip.lo.x, strip.lo.y );+ window->winSetSize( strip.hi.x - strip.lo.x, strip.hi.y - strip.lo.y );++ ReplayStripText *text = (ReplayStripText *)window->winGetUserData();+ if( text == NULL )+ {+ text = NEW ReplayStripText;+ text->clock = TheDisplayStringManager->newDisplayString();+ for( Int each = 0; each < REPLAY_BUTTONS; each++ )+ text->buttons[ each ] = TheDisplayStringManager->newDisplayString();+ window->winSetUserData( text );+ }+ GameFont *font = TheWindowManager->winFindFont( TheGlobalLanguageData->m_defaultWindowFont.name,+ REAL_TO_INT_FLOOR( FONT_SIZE * layout.unit + 0.5f ), TRUE );++ const Color white = GameMakeColor( 255, 255, 255, 255 );+ const Color shadow = GameMakeColor( 0, 0, 0, 255 );+ const Color edge = GameMakeColor( 150, 150, 150, 200 );+ const Color lit = GameMakeColor( 170, 125, 30, 235 );+ const Color unlit = GameMakeColor( 55, 55, 55, 220 );++ TheDisplay->drawFillRect( strip.lo.x, strip.lo.y, strip.hi.x - strip.lo.x, strip.hi.y - strip.lo.y, GameMakeColor( 0, 0, 0, 170 ) );+ TheDisplay->drawOpenRect( strip.lo.x, strip.lo.y, strip.hi.x - strip.lo.x, strip.hi.y - strip.lo.y, 1.0f, edge );++ const UnsignedInt frame = TheGameLogic->getFrame();+ const UnsignedInt length = replayLength();+ UnicodeString clock;+ clock.format( u"%s / %s", replayClock( frame ).str(), replayClock( length ).str() );+ text->clock->setFont( font );+ text->clock->setText( clock );+ text->clock->draw( layout.clock.x, layout.clock.y, white, shadow );++ const Bool paused = TheGameLogic->isGamePaused();+ const Int speed = replaySpeedIndex();+ for( Int each = 0; each < REPLAY_BUTTONS; each++ )+ {+ const IRegion2D &button = layout.buttons[ each ];+ const Bool on = each == 0 ? paused : speed == each - 1;+ const Int w = button.hi.x - button.lo.x;+ const Int h = button.hi.y - button.lo.y;+ TheDisplay->drawFillRect( button.lo.x, button.lo.y, w, h, on ? lit : unlit );+ TheDisplay->drawOpenRect( button.lo.x, button.lo.y, w, h, 1.0f, edge );++ DisplayString *label = text->buttons[ each ];+ label->setFont( font );+ label->setText( each == 0 ? TheGameText->fetch( paused ? "GUI:ReplayResume" : "GUI:Pause" ) : UnicodeString( REPLAY_SPEED_LABELS[ each - 1 ] ) );+ Int labelWidth, labelHeight;+ label->getSize( &labelWidth, &labelHeight );+ label->draw( button.lo.x + ( w - labelWidth ) / 2, button.lo.y + ( h - labelHeight ) / 2, white, shadow );+ }++ const IRegion2D &track = layout.track;+ const Int trackWidth = track.hi.x - track.lo.x;+ const Int trackHeight = track.hi.y - track.lo.y;+ TheDisplay->drawFillRect( track.lo.x, track.lo.y, trackWidth, trackHeight, GameMakeColor( 30, 30, 30, 230 ) );+ if( length > 0 )+ TheDisplay->drawFillRect( track.lo.x, track.lo.y, (Int)( (Int64)trackWidth * frame / length ), trackHeight, GameMakeColor( 220, 175, 60, 255 ) );+ TheDisplay->drawOpenRect( track.lo.x, track.lo.y, trackWidth, trackHeight, 1.0f, edge );+ // where the drag will jump to+ if( TheReplayStripDragging && length > 0 )+ {+ const Int marker = REAL_TO_INT_FLOOR( 2.0f * layout.unit );+ const Int at = track.lo.x + (Int)( (Int64)trackWidth * TheReplayStripDragFrame / length ) - marker / 2;+ TheDisplay->drawFillRect( at, track.lo.y - marker, marker, trackHeight + 2 * marker, white );+ }+}++//-------------------------------------------------------------------------------------------------+/** Every press on the strip is the strip's, so none becomes a click on the world under it. *///-------------------------------------------------------------------------------------------------WindowMsgHandledType ReplayControlInput( GameWindow *window, UnsignedInt msg,WindowMsgData mData1, WindowMsgData mData2 ){+ const Int x = (Int)( mData1 & 0xFFFF );+ const Int y = (Int)( mData1 >> 16 );+ switch( msg )+ {+ case GWM_LEFT_DOWN:+ case GWM_LEFT_DOUBLE_CLICK:+ {+ const ReplayStripLayout layout = layOutReplayStrip();+ if( regionHolds( layout.track, x, y ) )+ {+ TheReplayStripDragging = TRUE;+ TheReplayStripDragFrame = replayFrameAt( layout, x );+ break;+ }+ if( regionHolds( layout.buttons[ 0 ], x, y ) )+ {+ TheInGameUI->runSpectatorAction( "replay:pause" );+ break;+ }+ for( Int each = 1; each < REPLAY_BUTTONS; each++ )+ if( regionHolds( layout.buttons[ each ], x, y ) )+ {+ setReplaySpeed( each - 1 );+ return MSG_HANDLED;+ }++ // the strip's ground: a press carries it, a double click sends it home+ if( msg == GWM_LEFT_DOUBLE_CLICK )+ {+ TheReplayStripMoving = FALSE;+ TheReplayStripPlaced = FALSE;+ break;+ }+ TheReplayStripMoving = TRUE;+ TheReplayStripGrab.x = x - layout.strip.lo.x;+ TheReplayStripGrab.y = y - layout.strip.lo.y;+ break;+ }- return MSG_IGNORED;+ case GWM_LEFT_DRAG:+ if( TheReplayStripDragging )+ TheReplayStripDragFrame = replayFrameAt( layOutReplayStrip(), x );+ break;-} // end MapSelectMenuInput+ case GWM_LEFT_UP:+ if( TheReplayStripDragging )+ {+ TheReplayStripDragFrame = replayFrameAt( layOutReplayStrip(), x );+ endReplayStripDrag();+ }+ break;++ case GWM_RIGHT_DOWN:+ case GWM_RIGHT_UP:+ case GWM_MIDDLE_DOWN:+ case GWM_MIDDLE_UP:+ break;++ default:+ return MSG_IGNORED;+ }++ return MSG_HANDLED;++} // end ReplayControlInput//-------------------------------------------------------------------------------------------------/** System callback for the control bar parent */@@ -62,6 +404,20 @@ WindowMsgHandledType ReplayControlSystem( GameWindow *window, UnsignedInt msg,} // end button selected+ //---------------------------------------------------------------------------------------------+ case GWM_DESTROY:+ {+ ReplayStripText *text = (ReplayStripText *)window->winGetUserData();+ if( text == NULL )+ break;+ TheDisplayStringManager->freeDisplayString( text->clock );+ for( Int each = 0; each < REPLAY_BUTTONS; each++ )+ TheDisplayStringManager->freeDisplayString( text->buttons[ each ] );+ delete text;+ window->winSetUserData( NULL );+ break;+ }+//---------------------------------------------------------------------------------------------default:return MSG_IGNORED;diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cppindex a9b84d142..b1e6ea07a 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp@@ -1767,8 +1767,12 @@ static AsciiString TheReplayCheckpointsOf;* message stream, and the click is a message the stream is in the middle of handing round. */static Bool TheReplayRewindWaiting = FALSE;+/// when the seek running now was asked for, for the log line when it lands+static UnsignedInt TheReplaySeekStartMs = 0;+static void seekReplay( UnsignedInt target ){+ TheReplaySeekStartMs = Clock_Milliseconds();TheGameLogic->setGamePaused( FALSE );// the first checkpoint is taken on the first frame, so only frame 0 has none behind itTheReplayRewindWaiting = target <= TheGameLogic->getFrame() && !TheReplayCheckpoints.empty();@@ -1923,7 +1927,11 @@ static void updateReplaySeek( void )const Bool seeking = frame < TheReplaySeekFrame;TheWritableGlobalData->m_TiVOFastMode = seeking;if( !seeking )+ {+ DEBUG_LOG(( "REPLAY SEEK to frame %u landed on %u in %u ms at %d fps\n", TheReplaySeekFrame, frame,+ (UnsignedInt)( Clock_Milliseconds() - TheReplaySeekStartMs ), TheGameEngine->getFramesPerSecondLimit() ));TheReplaySeekFrame = 0;+ }}//-------------------------------------------------------------------------------------------------@@ -6570,6 +6578,9 @@ void InGameUI::createReplayControl( void ){m_replayWindow = TheWindowManager->winCreateFromScript( AsciiString("ReplayControl.wnd") );+ // the parent draws the replay strip itself (ReplayControls.cpp); the layout has it see-through+ m_replayWindow->winClearStatus( WIN_STATUS_SEE_THRU | WIN_STATUS_BORDER );+ m_replayWindow->winSetDrawFunc( ReplayControlDraw );/*// hide all windows created from this layoutdiff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/Input/Mouse.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/Input/Mouse.cppindex 23e7ed417..5e2fee9f4 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/Input/Mouse.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/Input/Mouse.cpp@@ -221,6 +221,7 @@ void Mouse::processMouseEvent( Int index )// Cumulate Wheel Adjustmentsm_currMouse.wheelPos += m_mouseEvents[ index ].wheelPos;+ m_currMouse.sideButton = m_mouseEvents[ index ].sideButton;// Check Left Mouse Stateif( m_mouseEvents[ index ].leftFrame )@@ -839,7 +840,15 @@ void Mouse::createStreamMessages( void )msg->appendRealArgument( (Real)m_currMouse.wheelPos / 120.0f ); // wheel delta, in notchesmsg->appendIntegerArgument( TheKeyboard->getModifierFlags() );} // end if-++ if( m_currMouse.sideButton != 0 )+ {+ msg = TheMessageStream->appendMessage( GameMessage::MSG_RAW_MOUSE_SIDE_BUTTON );+ msg->appendPixelArgument( m_currMouse.pos );+ msg->appendIntegerArgument( m_currMouse.sideButton );+ msg->appendIntegerArgument( TheKeyboard->getModifierFlags() );+ }+} // end for} // end createStreamMessagesdiff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cppindex 010412fb7..df0fa1145 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp@@ -66,6 +66,7 @@#include "GameClient/ParticleSys.h"#include "GameClient/GUICallbacks.h"#include "GameClient/KeyDefs.h"+#include "GameClient/ObserverCamera.h"#include "GameClient/Shell.h"#include "GameClient/ControlBar.h"#include "GameClient/SelectionInfo.h"@@ -3460,6 +3461,13 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessagecancelledSomething = TRUE;}+ // a watcher looking through one player's eyes gets the whole map back, menu shut first+ if( cancelledSomething == FALSE && !TheInGameUI->isQuitMenuVisible() && TheObserverCamera.stopLooking() )+ {+ TheControlBar->watchPlayer( NULL );+ cancelledSomething = TRUE;+ }+if( cancelledSomething == FALSE )ToggleQuitMenu();diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cppindex f3acbd9dd..1c92e4c15 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp@@ -83,6 +83,9 @@ static const Real CTRL_WHEEL_ZOOM_NOTCHES = 5.0f;// Alt+wheel tilts the camera this far a notch.static const Real TILT_PER_NOTCH = 2.0f * PI / 180.0f;+// A mouse side button tilts this far a press: eight presses cross the 20 to 60 degree range.+static const Real TILT_PER_SIDE_BUTTON = 5.0f * PI / 180.0f;+//-----------------------------------------------------------------------------/** The player's tilt keeps the camera between 20 and 60 degrees above the ground. The view's* pitch is an offset from GameData's CameraPitch, and a larger pitch lays the camera flatter,@@ -576,6 +579,19 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessage// m_isScrolling/m_scrollType torn.}+ //-----------------------------------------------------------------------------+ // The side buttons step the tilt: forward (X2) lays the camera flatter, as Alt+wheel forward+ // does, back (X1) stands it up. Not on the Classic mouse, which has no Alt+wheel tilt either.+ case GameMessage::MSG_RAW_MOUSE_SIDE_BUTTON:+ {+ // nor in the menus or a cinematic, where WindowXlat eats the wheel before it gets here+ if (TheGlobalData->isClassicMouse() || TheShell->isShellActive() || !TheInGameUI->getInputEnabled())+ break;+ const Real steps = (Real)msg->getArgument( 1 )->integer;+ TheTacticalView->setPitch( LookAt_clampPlayerPitch( TheTacticalView->getPitch() + steps * TILT_PER_SIDE_BUTTON ) );+ return DESTROY_MESSAGE;+ }+//-----------------------------------------------------------------------------case GameMessage::MSG_META_OPTIONS:diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cppindex d784d18ae..2a8b2c7fe 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp@@ -643,6 +643,29 @@ GameMessageDisposition MetaEventTranslator::translateGameMessage(const GameMessadisp = DESTROY_MESSAGE;}+ // A replay's strip on the keyboard, unless CommandMap.ini gave the key to something else: P+ // pauses and resumes, minus and plus step through the speed buttons. Nobody gives orders in+ // a replay, so the keys are free there.+ if( disp == KEEP_MESSAGE && newModState == NONE && TheGameLogic->isInReplayGame() &&+ ( keyState & KEY_STATE_DOWN ) && !( keyState & KEY_STATE_AUTOREPEAT ) )+ {+ if( key == MK_P )+ {+ TheMessageStream->appendMessage( GameMessage::MSG_META_TOGGLE_PAUSE );+ disp = DESTROY_MESSAGE;+ }+ else if( key == MK_MINUS || key == MK_KPMINUS )+ {+ ReplayControlStepSpeed( -1 );+ disp = DESTROY_MESSAGE;+ }+ else if( key == MK_EQUAL || key == MK_KPPLUS )+ {+ ReplayControlStepSpeed( 1 );+ disp = DESTROY_MESSAGE;+ }+ }+// remember, or forget, that this key is held with these modifiersif( !isModifierKey && newModState != NONE && key >= 0 && key < NUM_MAPPABLE_KEYS ){diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/ObserverCamera.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/ObserverCamera.cppindex 21bc84d57..ed2ead25a 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/ObserverCamera.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/ObserverCamera.cpp@@ -1514,6 +1514,7 @@ ObserverCamera::ObserverCamera()// the timeline is the whole process's, read once and kept across the resets a match start makesm_scoutScanned = 0;m_timelineLoaded = FALSE;+ m_modeBeforeLook = OBSERVER_CAMERA_FREE;reset();}@@ -1882,6 +1883,31 @@ void ObserverCamera::followPlayer( Int playerIndex )m_placeValid = FALSE;}+//-------------------------------------------------------------------------------------------------+/** Picking a second player while looking through the first keeps the camera the watcher had before+ * either, so one Esc always goes back to it. */+//-------------------------------------------------------------------------------------------------+void ObserverCamera::lookThrough( Int playerIndex )+{+ if( m_followed == NO_PLAYER && !m_fog )+ m_modeBeforeLook = m_mode;+ followPlayer( playerIndex );+ m_fog = TRUE;+ setMode( OBSERVER_CAMERA_PLAYER );+}++//-------------------------------------------------------------------------------------------------+Bool ObserverCamera::stopLooking( void )+{+ if( m_followed == NO_PLAYER && !m_fog )+ return FALSE;++ followPlayer( NO_PLAYER );+ m_fog = FALSE;+ setMode( m_modeBeforeLook );+ return TRUE;+}+//-------------------------------------------------------------------------------------------------Int ObserverCamera::getShroudPlayerIndex( void ) const{diff --git a/GeneralsMD/Code/GameEngineDevice/Include/SdlDevice/GameClient/SdlMouse.h b/GeneralsMD/Code/GameEngineDevice/Include/SdlDevice/GameClient/SdlMouse.hindex 0230d2d93..d143d09ff 100644--- a/GeneralsMD/Code/GameEngineDevice/Include/SdlDevice/GameClient/SdlMouse.h+++ b/GeneralsMD/Code/GameEngineDevice/Include/SdlDevice/GameClient/SdlMouse.h@@ -65,7 +65,7 @@ public:/// What SdlInput_dispatch hands over, already in game pixelsenum EventKind { EVENT_NONE = 0, EVENT_MOVE, EVENT_BUTTON_DOWN, EVENT_BUTTON_UP, EVENT_WHEEL };- enum Button { BUTTON_LEFT, BUTTON_MIDDLE, BUTTON_RIGHT };+ enum Button { BUTTON_LEFT, BUTTON_MIDDLE, BUTTON_RIGHT, BUTTON_X1, BUTTON_X2 };void addEvent( EventKind kind, Int x, Int y, Button button, Int clicks, Int wheelDelta, UnsignedInt timeMs );void lostFocus( Bool state ) { m_lostFocus = state; } ///< Win32Mouse's, for the focus handlingdiff --git a/GeneralsMD/Code/GameEngineDevice/Source/SdlDevice/GameClient/SdlInput.cpp b/GeneralsMD/Code/GameEngineDevice/Source/SdlDevice/GameClient/SdlInput.cppindex 7cc745630..2cf14d1c7 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/SdlDevice/GameClient/SdlInput.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/SdlDevice/GameClient/SdlInput.cpp@@ -179,7 +179,9 @@ Bool SdlInput_dispatch( const SDL_Event &event )case SDL_BUTTON_LEFT: button = SdlMouse::BUTTON_LEFT; break;case SDL_BUTTON_MIDDLE: button = SdlMouse::BUTTON_MIDDLE; break;case SDL_BUTTON_RIGHT: button = SdlMouse::BUTTON_RIGHT; break; // a trackpad's secondary click too- default: return TRUE; // X1 and X2: WndProc takes no WM_XBUTTON either+ case SDL_BUTTON_X1: button = SdlMouse::BUTTON_X1; break; // back: a camera tilt step, as WM_XBUTTONDOWN+ case SDL_BUTTON_X2: button = SdlMouse::BUTTON_X2; break;+ default: return TRUE;}if (SdlMouse::active() == NULL)return TRUE;diff --git a/GeneralsMD/Code/GameEngineDevice/Source/SdlDevice/GameClient/SdlMouse.cpp b/GeneralsMD/Code/GameEngineDevice/Source/SdlDevice/GameClient/SdlMouse.cppindex 8342ac151..efe7e4616 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/SdlDevice/GameClient/SdlMouse.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/SdlDevice/GameClient/SdlMouse.cpp@@ -279,7 +279,7 @@ void SdlMouse::translateEvent( UnsignedInt eventIndex, MouseIO *result )result->leftState = result->middleState = result->rightState = MBS_Up;result->leftFrame = result->middleFrame = result->rightFrame = 0;- result->pos.x = result->pos.y = result->wheelPos = 0;+ result->pos.x = result->pos.y = result->wheelPos = result->sideButton = 0;result->time = event.time;result->pos.x = event.x;result->pos.y = event.y;@@ -299,6 +299,9 @@ void SdlMouse::translateEvent( UnsignedInt eventIndex, MouseIO *result )case BUTTON_LEFT: result->leftState = state; result->leftFrame = frame; break;case BUTTON_MIDDLE: result->middleState = state; result->middleFrame = frame; break;case BUTTON_RIGHT: result->rightState = state; result->rightFrame = frame; break;+ // the side buttons are a step on the press alone, as Win32's WM_XBUTTONDOWN+ case BUTTON_X1: result->sideButton = event.kind == EVENT_BUTTON_DOWN ? -1 : 0; break;+ case BUTTON_X2: result->sideButton = event.kind == EVENT_BUTTON_DOWN ? 1 : 0; break;}break;}diff --git a/GeneralsMD/Code/GameEngineDevice/Source/Win32Device/GameClient/Win32DIMouse.cpp b/GeneralsMD/Code/GameEngineDevice/Source/Win32Device/GameClient/Win32DIMouse.cppindex d8b9cb494..7b6e3ebca 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/Win32Device/GameClient/Win32DIMouse.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/Win32Device/GameClient/Win32DIMouse.cpp@@ -203,7 +203,7 @@ UnsignedByte DirectInputMouse::getMouseEvent( MouseIO *result, Bool flush )/* set these to defaults */result->leftState = result->middleState = result->rightState = FALSE;result->leftFrame = result->middleFrame = result->rightFrame = 0;- result->pos.x = result->pos.y = result->wheelPos = 0;+ result->pos.x = result->pos.y = result->wheelPos = result->sideButton = 0;if( m_pMouseDevice ){diff --git a/GeneralsMD/Code/GameEngineDevice/Source/Win32Device/GameClient/Win32Mouse.cpp b/GeneralsMD/Code/GameEngineDevice/Source/Win32Device/GameClient/Win32Mouse.cppindex 96e9fd0a7..3d421a7ac 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/Win32Device/GameClient/Win32Mouse.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/Win32Device/GameClient/Win32Mouse.cpp@@ -140,7 +140,7 @@ void Win32Mouse::translateEvent( UnsignedInt eventIndex, MouseIO *result )// set these to defaultsresult->leftState = result->middleState = result->rightState = MBS_Up;result->leftFrame = result->middleFrame = result->rightFrame = 0;- result->pos.x = result->pos.y = result->wheelPos = 0;+ result->pos.x = result->pos.y = result->wheelPos = result->sideButton = 0;// Time is the same for all eventsresult->time = m_eventBuffer[ eventIndex ].time;@@ -284,6 +284,17 @@ void Win32Mouse::translateEvent( UnsignedInt eventIndex, MouseIO *result )} // end mouse wheel+ // ------------------------------------------------------------------------+ case WM_XBUTTONDOWN:+ {++ result->sideButton = GET_XBUTTON_WPARAM( wParam ) == XBUTTON2 ? 1 : -1;+ result->pos.x = LOWORD( lParam );+ result->pos.y = HIWORD( lParam );+ break;++ } // end side button down+// ------------------------------------------------------------------------default:{diff --git a/GeneralsMD/Code/Main/WinMain.cpp b/GeneralsMD/Code/Main/WinMain.cppindex 3d9095f3d..2a4cd4592 100644--- a/GeneralsMD/Code/Main/WinMain.cpp+++ b/GeneralsMD/Code/Main/WinMain.cpp@@ -672,6 +672,19 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT message,} // end WM_LBUTTONDOWN+ //-------------------------------------------------------------------------+ // the side buttons step the camera's tilt; only the press is an event, and a handled+ // WM_XBUTTON returns TRUE or Windows also sends it on as browser back/forward+ case WM_XBUTTONDOWN:+ {++ if( TheWin32Mouse )+ TheWin32Mouse->addWin32Event( message, wParam, lParam, TheMessageTime );++ return TRUE;++ } // end WM_XBUTTONDOWN+//-------------------------------------------------------------------------case 0x020A: // WM_MOUSEWHEEL{diff --git a/GeneralsMD/Code/Tests/test_sdl_input.cpp b/GeneralsMD/Code/Tests/test_sdl_input.cppindex 8a9b6cb97..f3966a1d2 100644--- a/GeneralsMD/Code/Tests/test_sdl_input.cpp+++ b/GeneralsMD/Code/Tests/test_sdl_input.cpp@@ -32,7 +32,7 @@* '\r' (armed: SDL's text never carries one); the composition and its cursor; nothing detached,* nothing while composing.* - Mouse: positions scaled to the game's pixels and held to its screen; the button states and the- * double click from SDL's click count; X1 and X2 ignored; the wheel at 120 a notch with fractions+ * double click from SDL's click count; X1 and X2 as side-button presses; the wheel at 120 a notch with fractions* carried and the natural-scrolling direction left alone; a full ring drops; the confinement* condition.* - The double-click time on macOS against `defaults read -g com.apple.mouse.doubleClickThreshold`.@@ -614,19 +614,22 @@ TEST(motion_and_buttons_translate_as_win32mouses_messages_did)pushButton( SDL_BUTTON_LEFT, false, 1, 121, 46 );pushButton( SDL_BUTTON_RIGHT, true, 1, 10, 10 ); // a trackpad's secondary click is this toopushButton( SDL_BUTTON_MIDDLE, true, 1, 10, 10 );- pushButton( SDL_BUTTON_X1, true, 1, 10, 10 ); // WndProc takes no WM_XBUTTON+ pushButton( SDL_BUTTON_X1, true, 1, 10, 10 ); // back: WM_XBUTTONDOWN with XBUTTON1+ pushButton( SDL_BUTTON_X2, true, 1, 10, 10 ); // forward: XBUTTON2pushMotion( -40, 9000 );pump();const std::vector<MouseIO> e = mouseEvents( mouse );- CHECK_EQ( (int)e.size(), 6 );- if (e.size() == 6)+ CHECK_EQ( (int)e.size(), 8 );+ if (e.size() == 8){CHECK( e[0].pos.x == 120 && e[0].pos.y == 45 && e[0].leftState == MBS_Up && e[0].wheelPos == 0 );CHECK( e[1].leftState == MBS_Down && e[1].pos.x == 121 && e[1].pos.y == 46 );CHECK( e[2].leftState == MBS_Up );CHECK( e[3].rightState == MBS_Down && e[3].leftState == MBS_Up );- CHECK( e[4].middleState == MBS_Down );- CHECK( e[5].pos.x == 0 && e[5].pos.y == 599 );+ CHECK( e[4].middleState == MBS_Down && e[4].sideButton == 0 );+ CHECK( e[5].sideButton == -1 && e[5].leftState == MBS_Up && e[5].middleState == MBS_Up );+ CHECK( e[6].sideButton == 1 );+ CHECK( e[7].pos.x == 0 && e[7].pos.y == 599 );}}