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: camera jumps, production cancellation and destination markers

T0T0W3fd95e0af3de
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 188d6375b..c6f2dcbbc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,18 @@ found and fixed — EA's own, not port damage.**
---
+## Camera, production and destination corrections (2026-09-13)
+
+- Advance each view's pan clock during stationary frames, avoiding an initial jump after idle.
+- Allow a finite 200-unit margin beyond map edges, independent of zoom and angle, with Release
+ constraints and Options.ini settings for the margin and enabling constraints.
+- Remove wheel cursor anchoring and default ZoomToCursor to off; retain upstream height easing.
+- Right-click cancels one item from the global production strip and works on disabled queued-unit
+ buttons. Consume associated raw/logical clicks and releases so cancellation cannot issue orders.
+- Replace destination arrows with an embedded antialiased dot, green for movement, preserving
+ other order colours and arrival animation.
+- Add regression coverage for pan timing, map corners, cursor-independent zoom and GUI cancellation.
+
## The frame rate cap is gone
- The picture now runs uncapped; the rules keep their own steady clock.
diff --git a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h
index 7598b5f1d..0c6a1172f 100644
--- a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h
+++ b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h
@@ -366,6 +366,8 @@ public:
Real m_scrollAmountCutoff; ///< Scroll speed to not adjust camera height
Real m_cameraAdjustSpeed; ///< Rate at which we adjust camera height
Bool m_enforceMaxCameraHeight; ///< Enfoce max camera height while scrolling?
+ Bool m_useCameraConstraints; ///< constrain camera movement to the map and its configured margin
+ Int m_cameraBoundaryMargin; ///< world units permitted beyond the map; 0 uses the original framing limit
Bool m_edgeScrollInWindowedMode; ///< allow screen-edge scrolling while running in a window
Bool m_snapBuildPlacementTo45; ///< quantize the drag-to-rotate build placement angle to 45 degrees
Bool m_snapCameraRotateTo45; ///< quantize the camera heading to 45 degrees when a middle-drag rotate ends
@@ -579,7 +581,6 @@ public:
#if defined(_DEBUG) || defined(_INTERNAL)
Bool m_wireframe;
Bool m_stateMachineDebug;
- Bool m_useCameraConstraints;
Bool m_shroudOn;
Bool m_fogOfWarOn;
Bool m_jabberOn;
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/CameraBoundary.h b/GeneralsMD/Code/GameEngine/Include/GameClient/CameraBoundary.h
new file mode 100644
index 000000000..8f25292c3
--- /dev/null
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/CameraBoundary.h
@@ -0,0 +1,28 @@
+/* Command & Conquer Generals Zero Hour - GPL-3.0-or-later */
+#ifndef CAMERA_BOUNDARY_H
+#define CAMERA_BOUNDARY_H
+
+#include "Lib/BaseType.h"
+
+// The camera target can cross an edge, but stays within a finite distance of the actual map.
+inline Region2D cameraBoundaryFromMap(const Region3D& map, Real margin)
+{
+ if (margin < 0.0f) margin = 0.0f;
+ Region2D boundary;
+ boundary.lo.x = map.lo.x - margin;
+ boundary.lo.y = map.lo.y - margin;
+ boundary.hi.x = map.hi.x + margin;
+ boundary.hi.y = map.hi.y + margin;
+ return boundary;
+}
+
+inline Coord3D constrainCameraPosition(Coord3D pos, const Region2D& boundary)
+{
+ if (pos.x < boundary.lo.x) pos.x = boundary.lo.x;
+ if (pos.x > boundary.hi.x) pos.x = boundary.hi.x;
+ if (pos.y < boundary.lo.y) pos.y = boundary.lo.y;
+ if (pos.y > boundary.hi.y) pos.y = boundary.hi.y;
+ return pos;
+}
+
+#endif
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/CameraScrollClock.h b/GeneralsMD/Code/GameEngine/Include/GameClient/CameraScrollClock.h
new file mode 100644
index 000000000..8e039af81
--- /dev/null
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/CameraScrollClock.h
@@ -0,0 +1,31 @@
+/* Command & Conquer Generals Zero Hour - GPL-3.0-or-later */
+#ifndef CAMERA_SCROLL_CLOCK_H
+#define CAMERA_SCROLL_CLOCK_H
+
+#include <stdint.h>
+
+// Sample once per render tick, even when the camera is stationary. Each view owns its clock.
+class CameraScrollClock
+{
+public:
+ CameraScrollClock() : m_previousTime(0), m_started(false) {}
+
+ float sample(uint32_t now, int tickMilliseconds)
+ {
+ const uint32_t elapsed = now - m_previousTime;
+ m_previousTime = now;
+ if (!m_started)
+ {
+ m_started = true;
+ return 0.0f;
+ }
+ const float factor = elapsed / (float)tickMilliseconds;
+ return factor > 3.0f ? 3.0f : factor;
+ }
+
+private:
+ uint32_t m_previousTime;
+ bool m_started;
+};
+
+#endif
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/GameWindow.h b/GeneralsMD/Code/GameEngine/Include/GameClient/GameWindow.h
index d750045ec..abf56f2cd 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/GameWindow.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/GameWindow.h
@@ -184,6 +184,7 @@ enum
WIN_STATUS_ALWAYS_COLOR = 0x01000000, // Never render these buttons using greyscale renderer when button disabled.
WIN_STATUS_ON_MOUSE_DOWN = 0x02000000, // Pushbutton triggers on mouse down.
WIN_STATUS_SHORTCUT_BUTTON = 0x04000000, // Oh god... this is a total hack for shortcut buttons to handle rendering text top left corner...
+ WIN_STATUS_CANCEL_WHEN_DISABLED = 0x08000000, // Queued production may still receive right clicks while buying is disabled.
// when you edit this, remember to edit WindowStatusNames[]
};
@@ -361,7 +362,7 @@ public:
/** given a piont, return the child window which contains the mouse pointer,
if the point is not in a chilc, the function returns the 'window' paramater
back to the caller */
- GameWindow *winPointInChild( Int x, Int y, Bool ignoreEnableCheck = FALSE, Bool playDisabledSound = FALSE );
+ GameWindow *winPointInChild( Int x, Int y, Bool ignoreEnableCheck = FALSE, Bool playDisabledSound = FALSE, Bool allowDisabledCancel = FALSE );
/** finds the child which contains the mouse pointer - reguardless of
the enabled status of the child */
GameWindow *winPointInAnyChild( Int x, Int y, Bool ignoreHidden, Bool ignoreEnableCheck = FALSE );
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/LookAtXlat.h b/GeneralsMD/Code/GameEngine/Include/GameClient/LookAtXlat.h
index eda4a0d0d..df67d29b2 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/LookAtXlat.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/LookAtXlat.h
@@ -47,23 +47,6 @@ public:
void resetModes(); //Used when disabling input, so when we reenable it we aren't stuck in a mode.
private:
- //
- // ZoomToCursor: the wheel only moves the camera's *desired* height, and W3DView::update eases
- // the real zoom towards it over the frames that follow, so the world point under the cursor is
- // held in place by re-measuring it every frame for as long as that easing lasts.
- //
- enum
- {
- ZOOM_ANCHOR_MAX_TICKS = 240, ///< hard budget, so a stalled camera cannot pin the view forever
- ZOOM_ANCHOR_GRACE_TICKS = 4 ///< ticks before a still zoom is allowed to end the pin
- };
- void updateZoomToCursor( void ); ///< keep the anchored world point under its pixel
- Bool m_zoomAnchorValid; ///< a wheel zoom is being followed
- ICoord2D m_zoomAnchorPixel; ///< the pixel the wheel was spun over
- Coord3D m_zoomAnchorWorld; ///< the terrain point that has to stay under it
- Real m_zoomAnchorZoom; ///< last zoom seen, to tell whether the camera is still easing
- Int m_zoomAnchorTicks; ///< ticks left in the budget
-
enum
{
MAX_VIEW_LOCS = 8
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/PlaceEventTranslator.h b/GeneralsMD/Code/GameEngine/Include/GameClient/PlaceEventTranslator.h
index 2a2e357ea..246f58804 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/PlaceEventTranslator.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/PlaceEventTranslator.h
@@ -38,6 +38,7 @@ class PlaceEventTranslator : public GameMessageTranslator
private:
UnsignedInt m_frameOfUpButton;
Bool m_stripClickTaken; ///< the down went to the global production strip, so its up belongs there too
+ Bool m_stripRightClickTaken; ///< keep a strip cancellation out of world orders and drags
public:
PlaceEventTranslator();
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/WindowXlat.h b/GeneralsMD/Code/GameEngine/Include/GameClient/WindowXlat.h
index c3bfb7967..2878da648 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/WindowXlat.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/WindowXlat.h
@@ -36,7 +36,7 @@
class WindowTranslator : public GameMessageTranslator
{
private:
- // nothing
+ Bool m_rightClickTaken; ///< a GUI right press owns its drag/release even outside the window
public:
WindowTranslator();
~WindowTranslator();
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp
index e5d2c6f9d..e2319722c 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp
@@ -190,6 +190,8 @@ GlobalData* GlobalData::m_theOriginal = NULL;
{ "CameraYaw", INI::parseReal, NULL, offsetof( GlobalData, m_cameraYaw ) },
{ "CameraHeight", INI::parseReal, NULL, offsetof( GlobalData, m_cameraHeight ) },
{ "MaxCameraHeight", INI::parseReal, NULL, offsetof( GlobalData, m_maxCameraHeight ) },
+ { "UseCameraConstraints", INI::parseBool, NULL, offsetof( GlobalData, m_useCameraConstraints ) },
+ { "CameraBoundaryMargin", INI::parseInt, NULL, offsetof( GlobalData, m_cameraBoundaryMargin ) },
{ "EdgeScrollInWindowedMode", INI::parseBool, NULL, offsetof( GlobalData, m_edgeScrollInWindowedMode ) },
{ "SnapBuildPlacementTo45", INI::parseBool, NULL, offsetof( GlobalData, m_snapBuildPlacementTo45 ) },
{ "SnapCameraRotateTo45", INI::parseBool, NULL, offsetof( GlobalData, m_snapCameraRotateTo45 ) },
@@ -531,7 +533,6 @@ GlobalData* GlobalData::m_theOriginal = NULL;
{ "CheckMemoryLeaks", INI::parseBool, NULL, offsetof(GlobalData, m_checkForLeaks) },
{ "Wireframe", INI::parseBool, NULL, offsetof( GlobalData, m_wireframe ) },
{ "StateMachineDebug", INI::parseBool, NULL, offsetof( GlobalData, m_stateMachineDebug ) },
- { "UseCameraConstraints", INI::parseBool, NULL, offsetof( GlobalData, m_useCameraConstraints ) },
{ "ShroudOn", INI::parseBool, NULL, offsetof( GlobalData, m_shroudOn ) },
{ "FogOfWarOn", INI::parseBool, NULL, offsetof( GlobalData, m_fogOfWarOn ) },
{ "ShowCollisionExtents", INI::parseBool, NULL, offsetof( GlobalData, m_showCollisionExtents ) },
@@ -592,7 +593,6 @@ GlobalData::GlobalData()
#if defined(_DEBUG) || defined(_INTERNAL)
m_wireframe = 0;
m_stateMachineDebug = FALSE;
- m_useCameraConstraints = TRUE;
m_shroudOn = TRUE;
m_fogOfWarOn = FALSE;
m_jabberOn = FALSE;
@@ -1097,9 +1097,11 @@ GlobalData::GlobalData()
// controls that used to set them, and what is written here is what every game gets. GameData.ini
// remains the way to change one, because the field table above still names it.
//
+ m_useCameraConstraints = TRUE;
+ m_cameraBoundaryMargin = 200;
m_edgeScrollInWindowedMode = TRUE;
m_snapCameraRotateTo45 = TRUE;
- m_zoomToCursor = TRUE;
+ m_zoomToCursor = FALSE;
// the right button no longer scrolls, so a right-drag is free to mean something
m_formationDrag = TRUE;
m_showAllyCursors = TRUE;
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cpp b/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cpp
index 4004ab145..0ac8b6e0c 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cpp
@@ -26,6 +26,7 @@
#include "Common/GlobalData.h"
#include "Common/UserPreferences.h"
#include "GameClient/PlayerColorScheme.h"
+#include "GameClient/View.h"
//-----------------------------------------------------------------------------
// The accessors. Each is two lines and exists only because a member pointer cannot span Bool and
@@ -41,6 +42,18 @@
static Int get_##field( void ) { return TheGlobalData->field; } \
static void set_##field( Int value ) { TheWritableGlobalData->field = value; }
+OPTION_BOOL_ACCESSORS( m_useCameraConstraints )
+
+static Int get_m_cameraBoundaryMargin( void ) { return TheGlobalData->m_cameraBoundaryMargin; }
+static void set_m_cameraBoundaryMargin( Int value )
+{
+ TheWritableGlobalData->m_cameraBoundaryMargin = value;
+ if (TheTacticalView)
+ {
+ TheTacticalView->forceCameraConstraintRecalc();
+ TheTacticalView->forceRedraw();
+ }
+}
OPTION_BOOL_ACCESSORS( m_edgeScrollInWindowedMode )
OPTION_BOOL_ACCESSORS( m_snapCameraRotateTo45 )
OPTION_BOOL_ACCESSORS( m_zoomToCursor )
@@ -160,6 +173,14 @@ const OptionDef TheOptionCatalog[] =
// loads, clamps and saves each one and a player who wants the old behaviour can put the key
// back by hand. The defaults in GlobalData are what everybody else gets.
+ { "UseCameraConstraints", "", "",
+ OPTION_BOOL, APPLY_LIVE, 0, 1,
+ get_m_useCameraConstraints, set_m_useCameraConstraints },
+
+ { "CameraBoundaryMargin", "", "",
+ OPTION_INT, APPLY_LIVE, 0, 1000,
+ get_m_cameraBoundaryMargin, set_m_cameraBoundaryMargin },
+
// Retail refuses to edge-scroll in a window because the cursor can legitimately sit on the
// border while you reach for something else; on a second monitor, or borderless, that is
// exactly the behaviour you want back.
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
index aea6cb2e7..a77faab28 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
@@ -3498,9 +3498,8 @@ CommandSet *ControlBar::newCommandSetOverride( CommandSet *setToOverride )
//-------------------------------------------------------------------------------------------------
/** How many units this click on a build button is worth. Three rungs, taken from Beyond All
Reason's build menu, which is the only RTS that treats the batch size as a first class thing:
- shift is a squad, control is a queue, both together is everything the bank will pay for. The
- same number runs the right button, so whatever a click queued, one right-click of the same
- shape takes back out. */
+ shift is a squad, control is a queue, both together is everything the bank will pay for.
+ Right-click cancellation removes one item independently of these build modifiers. */
//-------------------------------------------------------------------------------------------------
Int getBuildBatchCount( void )
{
@@ -3538,10 +3537,8 @@ CBCommandStatus ControlBar::processContextSensitiveButtonClick( GameWindow *butt
if( command->getCommandType() == GUI_COMMAND_UNIT_BUILD )
{
- // a modifier takes the same batch back out that it would have queued
- Int wanted = getBuildBatchCount();
- while( wanted-- > 0 && cancelLastQueuedUnit( command->getThingTemplate() ) )
- ;
+ // One right click cancels one unit, independently of held build modifiers.
+ cancelLastQueuedUnit( command->getThingTemplate() );
return CBC_COMMAND_USED;
}
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp
index 90da9bb37..f426ebe25 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp
@@ -778,6 +778,7 @@ void ControlBar::updateContextCommand( void )
// whatever is still running below puts its own clock back on
//
GadgetButtonClearClock( win );
+ win->winClearStatus( WIN_STATUS_CANCEL_WHEN_DISABLED );
//
// a unit build button wears its own queue: a radial fill over the cameo while its unit
@@ -804,6 +805,8 @@ void ControlBar::updateContextCommand( void )
p->getProductionObject() == command->getThingTemplate() )
queued++;
GadgetButtonSetCount( win, queued );
+ if( queued > 0 && obj->isLocallyControlled() )
+ win->winSetStatus( WIN_STATUS_CANCEL_WHEN_DISABLED );
const ProductionEntry *first = pu->firstProduction();
if( first && first->getProductionType() == PRODUCTION_UNIT &&
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetPushButton.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetPushButton.cpp
index 2791fa1ca..1cca79925 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetPushButton.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetPushButton.cpp
@@ -831,6 +831,8 @@ void GadgetButtonSetData(GameWindow *g, void *data)
pData = getNewPushButtonData();
}
pData->userData = data;
+ // Reused command windows must not keep another command's cancellation permission.
+ g->winClearStatus( WIN_STATUS_CANCEL_WHEN_DISABLED );
g->winSetUserData(pData);
}
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindow.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindow.cpp
index f8b401fa9..949643b93 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindow.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindow.cpp
@@ -1389,7 +1389,7 @@ Int GameWindow::winDrawWindow( void )
* window which contains the mouse pointer. Child windows are
* relative to their parents */
//=============================================================================
-GameWindow *GameWindow::winPointInChild( Int x, Int y, Bool ignoreEnableCheck, Bool playDisabledSound )
+GameWindow *GameWindow::winPointInChild( Int x, Int y, Bool ignoreEnableCheck, Bool playDisabledSound, Bool allowDisabledCancel )
{
GameWindow *parent;
GameWindow *child;
@@ -1414,12 +1414,13 @@ GameWindow *GameWindow::winPointInChild( Int x, Int y, Bool ignoreEnableCheck, B
y >= origin.y && y <= origin.y + child->m_size.y )
{
Bool enabled = ignoreEnableCheck || BitTest( child->m_status, WIN_STATUS_ENABLED );
+ Bool cancellable = allowDisabledCancel && BitTest( child->m_status, WIN_STATUS_CANCEL_WHEN_DISABLED );
Bool hidden = BitTest( child->m_status, WIN_STATUS_HIDDEN );
if( !hidden )
{
- if( enabled )
+ if( enabled || cancellable )
{
- return child->winPointInChild( x, y, ignoreEnableCheck, playDisabledSound );
+ return child->winPointInChild( x, y, ignoreEnableCheck, playDisabledSound, allowDisabledCancel );
}
else if( playDisabledSound )
{
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowManager.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowManager.cpp
index 89634293e..dac7cc0b5 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowManager.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowManager.cpp
@@ -851,6 +851,9 @@ WinInputReturnCode GameWindowManager::winProcessMouseEvent( GameWindowMessage ms
GameWindow *childWindow;
Int dx, dy;
Bool clearGrabWindow = FALSE;
+ // Only right-button events may reach disabled production buttons. Left clicks and
+ // hotkeys still obey the normal availability check.
+ Bool allowDisabledCancel = msg == GWM_RIGHT_DOWN || msg == GWM_RIGHT_UP;
// pack mouse coords into one entity for message passing
packedMouseCoords = SHORTTOLONG( mousePos->x, mousePos->y );
@@ -866,7 +869,7 @@ WinInputReturnCode GameWindowManager::winProcessMouseEvent( GameWindowMessage ms
m_grabWindow = NULL;
// what what window within the captured window are we in
- window = m_mouseCaptor->winPointInChild( mousePos->x, mousePos->y );
+ window = m_mouseCaptor->winPointInChild( mousePos->x, mousePos->y, FALSE, FALSE, allowDisabledCancel );
//
// send buttons, drags, wheels to the windows, we don't continually
@@ -1013,7 +1016,7 @@ WinInputReturnCode GameWindowManager::winProcessMouseEvent( GameWindowMessage ms
if( m_modalHead && m_modalHead->window )
{
- window = m_modalHead->window->winPointInChild( mousePos->x, mousePos->y );
+ window = m_modalHead->window->winPointInChild( mousePos->x, mousePos->y, FALSE, FALSE, allowDisabledCancel );
}
else
{
@@ -1045,7 +1048,7 @@ WinInputReturnCode GameWindowManager::winProcessMouseEvent( GameWindowMessage ms
if( BitTest( window->m_status, WIN_STATUS_ENABLED ) )
{
// determine which child window the mouse is in
- window = window->winPointInChild( mousePos->x, mousePos->y );
+ window = window->winPointInChild( mousePos->x, mousePos->y, FALSE, FALSE, allowDisabledCancel );
break; // exit for
}
@@ -1081,7 +1084,7 @@ WinInputReturnCode GameWindowManager::winProcessMouseEvent( GameWindowMessage ms
if( BitTest( window->m_status, WIN_STATUS_ENABLED ))
{
// determine which child window the mouse is in
- window = window->winPointInChild( mousePos->x, mousePos->y );
+ window = window->winPointInChild( mousePos->x, mousePos->y, FALSE, FALSE, allowDisabledCancel );
break; // exit for
}
}
@@ -1115,7 +1118,7 @@ WinInputReturnCode GameWindowManager::winProcessMouseEvent( GameWindowMessage ms
if( BitTest( window->m_status, WIN_STATUS_ENABLED ))
{
// determine which child window the mouse is in
- window = window->winPointInChild( mousePos->x, mousePos->y );
+ window = window->winPointInChild( mousePos->x, mousePos->y, FALSE, FALSE, allowDisabledCancel );
break; // exit for
}
}
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowManagerScript.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowManagerScript.cpp
index ad462b895..a30dc5dc5 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowManagerScript.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowManagerScript.cpp
@@ -150,6 +150,7 @@ const char *WindowStatusNames[] = { "ACTIVE", "TOGGLE", "DRAGABLE", "ENABLED", "
"RIGHT_CLICK", "WRAP_CENTERED", "CHECK_LIKE","HOTKEY_TEXT",
"USE_OVERLAY_STATES", "NOT_READY", "FLASHING", "ALWAYS_COLOR",
"ON_MOUSE_DOWN",
+ "SHORTCUT_BUTTON", "CANCEL_WHEN_DISABLED",
NULL };
const char *WindowStyleNames[] = { "PUSHBUTTON", "RADIOBUTTON", "CHECKBOX",
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
index 3849ebf07..de437a7b9 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
@@ -7370,7 +7370,7 @@ void InGameUI::drawHudOverlay( void )
// PRODUCTION_STRIP_ROW_MAX cameos and closes with a sixth cell wearing a "+N" for whatever else is
// queued. Units and upgrades wear the same two border colours the command bar uses. The item a
// building is actually working on wears a radial fill. A click takes the camera to the building an
-// item is queued on; ctrl-click cancels it.
+// item is queued on; right-click (or Ctrl-click) cancels one queued item.
//-------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp
index 7fb6abc72..607255c81 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp
@@ -82,6 +82,9 @@ void LookAtTranslator::setScrolling(Int x)
TheInGameUI->setScrolling( TRUE );
TheTacticalView->setMouseLock( TRUE );
m_scrollType = x;
+ // A manual pan restores map constraints widened by scripted camera paths.
+ if (TheGlobalData->m_useCameraConstraints && TheGlobalData->m_cameraBoundaryMargin > 0)
+ TheTacticalView->forceCameraConstraintRecalc();
if(TheStatsCollector)
TheStatsCollector->startScrollTime();
}
@@ -111,13 +114,8 @@ LookAtTranslator::LookAtTranslator() :
m_timestamp(0),
m_lastPlaneID(INVALID_DRAWABLE_ID),
m_lastMouseMoveFrame(0),
- m_scrollType(SCROLL_NONE),
- m_zoomAnchorValid(FALSE),
- m_zoomAnchorZoom(0.0f),
- m_zoomAnchorTicks(0)
+ m_scrollType(SCROLL_NONE)
{
- m_zoomAnchorPixel.x = m_zoomAnchorPixel.y = 0;
- m_zoomAnchorWorld.zero();
//Added By Sadullah Nader
//Initializations misssing and needed
@@ -162,65 +160,6 @@ void LookAtTranslator::setCurrentPos( const ICoord2D& pos )
m_currentPos = pos;
}
-//-----------------------------------------------------------------------------
-/**
- * Keep the terrain point the wheel was spun over sitting under that same pixel while the camera
- * eases towards the zoom it was asked for. Re-measuring rather than projecting means the pin is
- * right at any pitch or field of view, and it converges: each frame's leftover error is the next
- * frame's correction. The pin ends when the zoom stops moving, when something else takes the
- * camera, or when its tick budget runs out.
- */
-void LookAtTranslator::updateZoomToCursor( void )
-{
- if (!m_zoomAnchorValid)
- return;
-
- // anything that moves the camera on purpose wins over the pin
- if (m_isScrolling || !TheInGameUI->getInputEnabled())
- {
- m_zoomAnchorValid = FALSE;
- return;
- }
-
- const Real zoom = TheTacticalView->getZoom();
- const Bool stillEasing = fabs( zoom - m_zoomAnchorZoom ) > 0.00001f;
- m_zoomAnchorZoom = zoom;
-
- Coord3D world;
- world.zero();
- TheTacticalView->screenToTerrain( &m_zoomAnchorPixel, &world );
-
- //
- // Move the camera by the world-space residual itself. scrollBy() is not the way to do it:
- // its delta is a *screen* delta that it pushes through Device_To_World_Space with a fixed
- // 250 unit resolution and then scales by frame time, so a world offset handed to it comes
- // out as some other distance entirely and the anchor never lands. lookAt is the exact move:
- // given a z on the ground it is a plain setPosition plus setCameraTransform, so the camera is
- // still clamped to the map the same way scrolling is.
- //
- const Real shiftX = m_zoomAnchorWorld.x - world.x;
- const Real shiftY = m_zoomAnchorWorld.y - world.y;
- if (shiftX != 0.0f || shiftY != 0.0f)
- {
- Coord3D pos;
- TheTacticalView->getPosition( &pos );
- pos.x += shiftX;
- pos.y += shiftY;
- pos.z = 0.0f;
- TheTacticalView->lookAt( &pos );
- }
-
- //
- // The first few ticks are a grace period: the wheel is handled in the message stream, which
- // runs before the view updates, so a zoom that has not started moving yet is not a zoom that
- // has finished.
- //
- const Bool grace = (m_zoomAnchorTicks > ZOOM_ANCHOR_MAX_TICKS - ZOOM_ANCHOR_GRACE_TICKS);
- if (--m_zoomAnchorTicks <= 0 || (!stillEasing && !grace))
- m_zoomAnchorValid = FALSE;
-
-} // end updateZoomToCursor
-
//-----------------------------------------------------------------------------
/**
* The LookAt Translator is responsible for camera movements. It is directly responsible for
@@ -462,26 +401,6 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessage
if (TheKeyboard->isCtrl() && rotateSteps != 0 && TheInGameUI->rotatePendingPlacement( rotateSteps ))
return DESTROY_MESSAGE;
- //
- // ZoomToCursor: remember the world point under the cursor and keep it there while the
- // camera moves. Measuring it again right after the zoom call - which is what this used
- // to do - always measured a camera that had not moved yet: zoomIn()/zoomOut() only
- // change the *desired* height above ground, and W3DView::update eases the actual zoom
- // towards it over the frames that follow. The shift therefore came out zero every time
- // and the feature did nothing at all. The anchor is now followed frame by frame in
- // updateZoomToCursor() for as long as that easing lasts, which also keeps it correct
- // whatever the pitch and the field of view are.
- //
- if (TheGlobalData->m_zoomToCursor && TheInGameUI->getInputEnabled())
- {
- m_zoomAnchorPixel = msg->getArgument( 0 )->pixel;
- m_zoomAnchorWorld.zero();
- TheTacticalView->screenToTerrain( &m_zoomAnchorPixel, &m_zoomAnchorWorld );
- m_zoomAnchorZoom = TheTacticalView->getZoom();
- m_zoomAnchorTicks = ZOOM_ANCHOR_MAX_TICKS;
- m_zoomAnchorValid = TRUE;
- }
-
if (spin > 0.0f)
TheTacticalView->zoomIn( spin );
else if (spin < 0.0f)
@@ -508,9 +427,6 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessage
{
Coord2D offset = {0, 0};
- // hold whatever the wheel was spun over under the cursor while the zoom eases
- updateZoomToCursor();
-
// If we've been forced to stop scrolling (script action?) then stop
if (m_isScrolling && !TheInGameUI->isScrolling())
{
@@ -601,11 +517,13 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessage
}
TheInGameUI->setScrollAmount(offset);
- TheTacticalView->scrollBy( &offset );
}
else //not scrolling so reset amount
TheInGameUI->setScrollAmount(offset);
+ // Advance the pan clock even while stationary, so restarting does not include idle time.
+ TheTacticalView->scrollBy( &offset );
+
//if (TheGlobalData->m_saveCameraInReplay /*&& TheRecorder->getMode() != RECORDERMODETYPE_PLAYBACK *//**/&& (TheGameLogic->isInSinglePlayerGame() || TheGameLogic->isInSkirmishGame())/**/)
//if (TheGlobalData->m_saveCameraInReplay && (TheGameLogic->isInMultiplayerGame() || TheGameLogic->isInSinglePlayerGame() || TheGameLogic->isInSkirmishGame()))
if (TheGlobalData->m_saveCameraInReplay && (TheGameLogic->isInSinglePlayerGame() || TheGameLogic->isInSkirmishGame()))
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/PlaceEventTranslator.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/PlaceEventTranslator.cpp
index 60fb66061..2a8853246 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/PlaceEventTranslator.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/PlaceEventTranslator.cpp
@@ -107,7 +107,7 @@ static Object *resolvePlacementBuilder( void )
}
//-------------------------------------------------------------------------------------------------
-PlaceEventTranslator::PlaceEventTranslator() : m_frameOfUpButton(-1), m_stripClickTaken(FALSE)
+PlaceEventTranslator::PlaceEventTranslator() : m_frameOfUpButton(-1), m_stripClickTaken(FALSE), m_stripRightClickTaken(FALSE)
{
}
@@ -123,15 +123,43 @@ GameMessageDisposition PlaceEventTranslator::translateGameMessage(const GameMess
{
GameMessageDisposition disp = KEEP_MESSAGE;
- // the up that closes a click the strip took is not a selection either
- if( m_stripClickTaken && msg->getType() == GameMessage::MSG_RAW_MOUSE_LEFT_BUTTON_UP )
+ // MetaEvent runs before us and inserts a logical click after the raw release.
+ // Consume both: otherwise cancelling on the strip can also issue a world order.
+ if( m_stripClickTaken && (msg->getType() == GameMessage::MSG_MOUSE_LEFT_CLICK ||
+ msg->getType() == GameMessage::MSG_MOUSE_LEFT_DOUBLE_CLICK) )
{
m_stripClickTaken = FALSE;
return DESTROY_MESSAGE;
}
+ if( m_stripClickTaken && (msg->getType() == GameMessage::MSG_RAW_MOUSE_LEFT_BUTTON_UP ||
+ msg->getType() == GameMessage::MSG_RAW_MOUSE_LEFT_DRAG) )
+ return DESTROY_MESSAGE;
+ if( m_stripRightClickTaken )
+ {
+ if( msg->getType() == GameMessage::MSG_MOUSE_RIGHT_CLICK ||
+ msg->getType() == GameMessage::MSG_MOUSE_RIGHT_DOUBLE_CLICK )
+ {
+ m_stripRightClickTaken = FALSE;
+ return DESTROY_MESSAGE;
+ }
+ if( msg->getType() == GameMessage::MSG_RAW_MOUSE_RIGHT_BUTTON_UP ||
+ msg->getType() == GameMessage::MSG_RAW_MOUSE_RIGHT_DRAG )
+ return DESTROY_MESSAGE;
+ }
switch(msg->getType())
{
+ case GameMessage::MSG_RAW_MOUSE_RIGHT_BUTTON_DOWN:
+ case GameMessage::MSG_RAW_MOUSE_RIGHT_DOUBLE_CLICK:
+ {
+ m_stripRightClickTaken = FALSE;
+ if( TheInGameUI->handleProductionStripClick( &msg->getArgument(0)->pixel, TRUE ) )
+ {
+ m_stripRightClickTaken = TRUE;
+ return DESTROY_MESSAGE;
+ }
+ break;
+ }
//---------------------------------------------------------------------------------------------
//
@@ -145,10 +173,11 @@ GameMessageDisposition PlaceEventTranslator::translateGameMessage(const GameMess
case GameMessage::MSG_RAW_MOUSE_LEFT_BUTTON_DOWN:
case GameMessage::MSG_RAW_MOUSE_LEFT_DOUBLE_CLICK:
{
+ m_stripClickTaken = FALSE;
//
// The global production strip lies over the world rather than inside a window, so
// nothing above us has claimed a click on it. Take it here, before placement and long
- // before selection turns it into a move order. Ctrl cancels the item, a plain click
+ // before selection turns it into a move order. Right-click (or Ctrl-click) cancels one, a plain click
// takes the camera to the building it is queued on.
//
if( TheInGameUI->handleProductionStripClick( &msg->getArgument(0)->pixel,
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/WindowXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/WindowXlat.cpp
index 6b1ac34e2..2b121dcbd 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/WindowXlat.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/WindowXlat.cpp
@@ -157,7 +157,7 @@ static GameWindowMessage rawMouseToWindowMessage( const GameMessage *msg )
///////////////////////////////////////////////////////////////////////////////
//=============================================================================
-WindowTranslator::WindowTranslator()
+WindowTranslator::WindowTranslator() : m_rightClickTaken(FALSE)
{
}
@@ -175,6 +175,23 @@ GameMessageDisposition WindowTranslator::translateGameMessage(const GameMessage
GameMessageDisposition disp = KEEP_MESSAGE;
Bool forceKeepMessage = FALSE;
WinInputReturnCode returnCode = WIN_INPUT_NOT_USED;
+ if( msg->getType() == GameMessage::MSG_RAW_MOUSE_RIGHT_BUTTON_DOWN ||
+ msg->getType() == GameMessage::MSG_RAW_MOUSE_RIGHT_DOUBLE_CLICK )
+ m_rightClickTaken = FALSE;
+ if( m_rightClickTaken && msg->getType() == GameMessage::MSG_RAW_MOUSE_RIGHT_DRAG )
+ return DESTROY_MESSAGE;
+ if( m_rightClickTaken && msg->getType() == GameMessage::MSG_RAW_MOUSE_RIGHT_BUTTON_UP )
+ {
+ m_rightClickTaken = FALSE;
+ // Update the button's visual state, then swallow the release before MetaEvent can
+ // turn it into a world click if the cursor moved away from the cancellation button.
+ if( TheWindowManager )
+ {
+ ICoord2D mousePos = msg->getArgument(0)->pixel;
+ TheWindowManager->winProcessMouseEvent(GWM_RIGHT_UP, &mousePos, NULL);
+ }
+ return DESTROY_MESSAGE;
+ }
if (TheTacticalView && TheTacticalView->isMouseLocked())
{
@@ -366,6 +383,9 @@ GameMessageDisposition WindowTranslator::translateGameMessage(const GameMessage
// If TheShell doesn't exist, then well, we're not in RTS, we're in GUIEdit
if( returnCode == WIN_INPUT_USED && !forceKeepMessage )// || (TheShell && TheShell->isShellActive()))
{
+ if( msg->getType() == GameMessage::MSG_RAW_MOUSE_RIGHT_BUTTON_DOWN ||
+ msg->getType() == GameMessage::MSG_RAW_MOUSE_RIGHT_DOUBLE_CLICK )
+ m_rightClickTaken = TRUE;
disp = DESTROY_MESSAGE;
}
diff --git a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DInGameUI.h b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DInGameUI.h
index 91dd48627..c3ca4c47b 100644
--- a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DInGameUI.h
+++ b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DInGameUI.h
@@ -81,12 +81,14 @@ protected:
virtual void drawAttackCircleFill( void ); ///< the wash on the ground inside an attack circle
virtual void drawFormationLine( void ); ///< the line a right drag is spreading the selection along
virtual void drawOrderHints( void ); ///< a line from each selected unit to where its order sends it
+ const Image *getOrderDestinationImage(); ///< shared antialiased fist marker
virtual void drawAttackCircle( void ); ///< the circle a left drag is sweeping targets out of
virtual void drawAllyCursorLights( void ); ///< the patch of an ally's colour lying under their cursor
void drawAllyCursors( void ); ///< each ally's pointer and name, over the world
RenderObjClass *m_buildingPlacementAnchor;
RenderObjClass *m_buildingPlacementArrow;
+ Image *m_orderDestinationImage; ///< UI-owned marker image and raw texture
/// One name plate per player, built the first time that ally's cursor is drawn and kept, because
/// laying out the same string every frame for every ally is work nobody sees.
diff --git a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DView.h b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DView.h
index a9ad75717..fcfec2e88 100644
--- a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DView.h
+++ b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DView.h
@@ -43,6 +43,7 @@
#include "Common/STLTypedefs.h"
#include "GameClient/ParabolicEase.h"
#include "GameClient/View.h"
+#include "GameClient/CameraScrollClock.h"
#include "WW3D2/Camera.h"
// FORWARD REFERENCES /////////////////////////////////////////////////////////////////////////////
@@ -276,6 +277,7 @@ private:
Coord3D m_cameraOffset; ///< offset for camera from view center
Coord3D m_previousLookAtPosition; ///< offset for camera from view center
Coord2D m_scrollAmount; ///< scroll speed
+ CameraScrollClock m_scrollClock; ///< elapsed render time, also sampled while idle
Real m_scrollAmountCutoff; ///< scroll speed at which we do not adjust height
Real m_groundLevel; ///< height of ground.
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/DestinationDotIcon.h b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/DestinationDotIcon.h
new file mode 100644
index 000000000..5b3736c44
--- /dev/null
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/DestinationDotIcon.h
@@ -0,0 +1,139 @@
+/* Command & Conquer Generals Zero Hour - GPL-3.0-or-later */
+#ifndef DESTINATION_DOT_ICON_H
+#define DESTINATION_DOT_ICON_H
+
+// Original vector art, rasterized with antialiasing. See DestinationDotIcon.svg.
+// Neutral colour lets the renderer preserve each order's existing green/red/blue tint.
+enum { DESTINATION_DOT_SIZE = 32, DESTINATION_DOT_HOTSPOT_X = 16, DESTINATION_DOT_HOTSPOT_Y = 16 };
+static const unsigned int DestinationDotPixels[DESTINATION_DOT_SIZE * DESTINATION_DOT_SIZE] = {
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x01000000u, 0x03000000u,
+ 0x03000000u, 0x01000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x01000000u, 0x03000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x03000000u, 0x01000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x01000000u, 0x00000000u, 0x00000000u, 0x153C3C3Cu, 0x3C222222u,
+ 0x3F202020u, 0x1A3A3A3Au, 0x00000000u, 0x00000000u, 0x02000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x01000000u, 0x00000000u, 0x09383838u, 0x8C191919u, 0xEC080808u, 0xFF0E0E0Eu,
+ 0xFF0F0F0Fu, 0xF2080808u, 0x9C161616u, 0x14262626u, 0x00000000u, 0x01000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x01000000u, 0x02000000u, 0x0B2E2E2Eu, 0xBE151515u, 0xFF161616u, 0xFF6F6F6Fu, 0xFDB7B7B7u,
+ 0xFDBABABAu, 0xFF7B7B7Bu, 0xFF1C1C1Cu, 0xD4131313u, 0x172C2C2Cu, 0x02000000u, 0x02000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x03000000u, 0x00000000u, 0x8C191919u, 0xFF161616u, 0xF8ABABABu, 0xFEFFFFFFu, 0xFFFFFFFFu,
+ 0xFFFFFFFFu, 0xFEFFFFFFu, 0xF8C2C2C2u, 0xFF1E1E1Eu, 0xAD141414u, 0x00010101u, 0x03000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x01000000u, 0x00000000u, 0x143F3F3Fu, 0xF3080808u, 0xFD6F6F6Fu, 0xFEFFFFFFu, 0xFFF0F0F0u, 0xFFF2F2F2u,
+ 0xFFF2F2F2u, 0xFFEEEEEEu, 0xFEFFFFFFu, 0xFC8C8C8Cu, 0xFF090909u, 0x292B2B2Bu, 0x00000000u, 0x02000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x03000000u, 0x00000000u, 0x3E202020u, 0xFF0E0E0Eu, 0xFDB7B7B7u, 0xFFFDFDFDu, 0xFFF2F2F2u, 0xFFF5F5F5u,
+ 0xFFF5F5F5u, 0xFFF3F3F3u, 0xFFFCFCFCu, 0xFBD1D1D1u, 0xFF171717u, 0x5C181818u, 0x00000000u, 0x04000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x03000000u, 0x00000000u, 0x411F1F1Fu, 0xFF0F0F0Fu, 0xFDBBBBBBu, 0xFFFDFDFDu, 0xFFF2F2F2u, 0xFFF5F5F5u,
+ 0xFFF5F5F5u, 0xFFF3F3F3u, 0xFFFCFCFCu, 0xFBD4D4D4u, 0xFE191919u, 0x5F181818u, 0x00000000u, 0x04000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x01000000u, 0x00000000u, 0x193D3D3Du, 0xF8080808u, 0xFD7C7C7Cu, 0xFEFFFFFFu, 0xFFEEEEEEu, 0xFFF3F3F3u,
+ 0xFFF3F3F3u, 0xFFEEEEEEu, 0xFFFFFFFFu, 0xFD999999u, 0xFF090909u, 0x31292929u, 0x00000000u, 0x02000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x03000000u, 0x00000000u, 0x9E161616u, 0xFF1C1C1Cu, 0xF8C2C2C2u, 0xFFFFFFFFu, 0xFFFCFCFCu,
+ 0xFFFCFCFCu, 0xFFFFFFFFu, 0xF9D6D6D6u, 0xFF272727u, 0xBE121212u, 0x00010101u, 0x02000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x02000000u, 0x02000000u, 0x15303030u, 0xD4121212u, 0xFF1E1E1Eu, 0xFE8A8A8Au, 0xFCD0D0D0u,
+ 0xFCD3D3D3u, 0xFD989898u, 0xFF272727u, 0xE6101010u, 0x25292929u, 0x01000000u, 0x02000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x02000000u, 0x00000000u, 0x172C2C2Cu, 0xAA161616u, 0xFC090909u, 0xFF171717u,
+ 0xFF191919u, 0xFF0A0A0Au, 0xB9131313u, 0x26282828u, 0x00000000u, 0x02000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x01000000u, 0x00000000u, 0x00000000u, 0x2B292929u, 0x59191919u,
+ 0x5C181818u, 0x31292929u, 0x00000000u, 0x00000000u, 0x02000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x01000000u, 0x02000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x01000000u, 0x02000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x02000000u, 0x04000000u,
+ 0x04000000u, 0x02000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+ 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
+};
+
+#endif
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/DestinationDotIcon.svg b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/DestinationDotIcon.svg
new file mode 100644
index 000000000..241df6e77
--- /dev/null
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/DestinationDotIcon.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
+<!-- Original artwork. GPL-3.0-or-later. -->
+<circle cx="16" cy="16" r="4.5" fill="#5EDC81" stroke="#091609" stroke-width="1.5"/>
+</svg>
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/GenerateDestinationDot.py b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/GenerateDestinationDot.py
new file mode 100644
index 000000000..084f085cd
--- /dev/null
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/GenerateDestinationDot.py
@@ -0,0 +1,32 @@
+# Original artwork and generator. GPL-3.0-or-later.
+# Run with Python and Pillow to regenerate the embedded texture from the adjacent SVG.
+from pathlib import Path
+from PIL import Image, ImageDraw
+import xml.etree.ElementTree as ET
+
+asset_dir = Path(__file__).resolve().parent
+size, supersample = 32, 8
+circle = ET.parse(asset_dir / 'DestinationDotIcon.svg').getroot().find('{http://www.w3.org/2000/svg}circle')
+x, y, r = (float(circle.attrib[key]) for key in ('cx', 'cy', 'r'))
+stroke = float(circle.attrib['stroke-width'])
+canvas = Image.new('RGBA', (size * supersample, size * supersample))
+draw = ImageDraw.Draw(canvas)
+for radius, color in ((r + stroke / 2, (24, 24, 24, 255)), (r - stroke / 2, (245, 245, 245, 255))):
+ draw.ellipse(tuple(round(value * supersample) for value in (x-radius, y-radius, x+radius, y+radius)), fill=color)
+pixels = canvas.resize((size, size), Image.Resampling.LANCZOS)
+argb = [(a << 24) | (r << 16) | (g << 8) | b for r, g, b, a in pixels.get_flattened_data()]
+header = '''/* Command & Conquer Generals Zero Hour - GPL-3.0-or-later */
+#ifndef DESTINATION_DOT_ICON_H
+#define DESTINATION_DOT_ICON_H
+
+// Original vector art, rasterized with antialiasing. See DestinationDotIcon.svg.
+// Neutral colour lets the renderer preserve each order's existing green/red/blue tint.
+enum { DESTINATION_DOT_SIZE = 32, DESTINATION_DOT_HOTSPOT_X = 16, DESTINATION_DOT_HOTSPOT_Y = 16 };
+static const unsigned int DestinationDotPixels[DESTINATION_DOT_SIZE * DESTINATION_DOT_SIZE] = {
+'''
+header += '\n'.join('\t' + ', '.join(f'0x{p:08X}u' for p in argb[i:i+8]) + ',' for i in range(0, len(argb), 8))
+header += '\n};\n\n#endif\n'
+target = asset_dir / 'DestinationDotIcon.h'
+if not target.exists() or target.read_text(encoding='utf-8') != header:
+ target.write_text(header, encoding='utf-8', newline='\n')
+print('DestinationDotIcon.h matches the SVG rasterization.')
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp
index bb21c803f..5f6c4ef3a 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp
@@ -53,6 +53,7 @@
#include "W3DDevice/GameClient/W3DAssetManager.h"
#include "W3DDevice/GameClient/W3DGUICallbacks.h"
#include "W3DDevice/GameClient/W3DInGameUI.h"
+#include "DestinationDotIcon.h"
#include "W3DDevice/GameClient/W3DDisplay.h"
#include "W3DDevice/GameClient/W3DScene.h"
#include "W3DDevice/Common/W3DConvert.h"
@@ -287,6 +288,7 @@ W3DInGameUI::W3DInGameUI()
{
m_buildingPlacementAnchor = NULL;
m_buildingPlacementArrow = NULL;
+ m_orderDestinationImage = NULL;
for( Int i = 0; i < MAX_PLAYER_COUNT; ++i )
m_allyCursorNames[ i ] = NULL;
@@ -299,6 +301,13 @@ W3DInGameUI::~W3DInGameUI()
{
REF_PTR_RELEASE( m_buildingPlacementAnchor );
REF_PTR_RELEASE( m_buildingPlacementArrow );
+ if (m_orderDestinationImage)
+ {
+ TextureClass *texture = (TextureClass*)m_orderDestinationImage->getRawTextureData();
+ REF_PTR_RELEASE(texture);
+ m_orderDestinationImage->deleteInstance();
+ m_orderDestinationImage = NULL;
+ }
for( Int i = 0; i < MAX_PLAYER_COUNT; ++i )
if( m_allyCursorNames[ i ] )
@@ -928,19 +937,7 @@ void W3DInGameUI::drawAttackCircle( void )
} // end drawAttackCircle
//-------------------------------------------------------------------------------------------------
-/** The marker on a destination is the cursor the player would be holding if they were pointing at
- * it: the move cursor for a move, the attack-move one for an attack-move, the attack one for an
- * attack. Same art, out of Mouse.ini, so nothing here has to invent a second visual language. */
-//-------------------------------------------------------------------------------------------------
-//-------------------------------------------------------------------------------------------------
-/** One cursor per order, out of the set the game already draws under the hand. A unit told to
- * garrison shows the garrison cursor where it is going, one sent to a repair bay shows that one,
- * and a group given four different jobs reads as four different markers rather than four arrows. */
-//-------------------------------------------------------------------------------------------------
-/** The thread is coloured by what it is for: anything that ends in a shot is red, an attack move
- * is pink, a post to be held is blue, everything else is green. The marker on the end of it is
- * the plain pointer in the same colour - one shape for every order, so the colour is the whole
- * message. */
+// Order lines keep their semantic colours; destinations use a small dot with a dark outline.
//-------------------------------------------------------------------------------------------------
static UnsignedInt orderHintLineColor( InGameUI::OrderHintKind kind )
{
@@ -961,143 +958,57 @@ static UnsignedInt orderHintLineColor( InGameUI::OrderHintKind kind )
static UnsignedInt orderHintMarkerColor( InGameUI::OrderHintKind kind )
{
- return orderHintLineColor( kind ) | 0xFF000000;
+ const UnsignedInt rgb = orderHintLineColor(kind) & 0x00FFFFFF;
+ return rgb == 0x55FF55 ? 0xFF62E686 : rgb | 0xFF000000;
}
-struct OrderCursorArt
-{
- const Image *image;
- ICoord2D hotSpot;
- Bool tried;
-};
-static OrderCursorArt s_orderCursorArt[ Mouse::NUM_MOUSE_CURSORS ];
-
//-------------------------------------------------------------------------------------------------
-/** Turn one Windows cursor into something the 2D renderer can draw. Mouse.ini's Image entries
- * name mapped images that do not exist in the shipped data, and the Texture entries name .ANI
- * files rather than textures - so the art the player is actually holding only exists as an HCURSOR.
- * Pull the first frame's bits out of it and keep them as a texture. */
-//-------------------------------------------------------------------------------------------------
-static const Image *loadOrderCursorImage( Mouse::MouseCursor cursor, ICoord2D *hotSpot )
+// The marker owns its artwork rather than extracting the mouse pointer from a Windows cursor.
+// Upload once per UI instance; every unit's destination shares this small antialiased texture.
+const Image *W3DInGameUI::getOrderDestinationImage()
{
- const AsciiString& name = TheMouse->m_cursorInfo[ cursor ].textureName;
- if( name.isEmpty() )
- return NULL;
-
- char path[ 256 ];
- snprintf( path, ARRAY_SIZE(path), "data\\cursors\\%s.ANI", name.str() );
-
- HCURSOR hcursor = LoadCursorFromFile( path );
- if( hcursor == NULL )
- return NULL;
-
- ICONINFO info;
- if( GetIconInfo( hcursor, &info ) == FALSE )
- return NULL;
+ if (m_orderDestinationImage)
+ return m_orderDestinationImage;
- const Image *result = NULL;
-
- BITMAP bm;
- if( info.hbmColor && GetObject( info.hbmColor, sizeof( BITMAP ), &bm ) )
+ const Int size = DESTINATION_DOT_SIZE;
+ TextureClass *texture = MSGNEW("TextureClass") TextureClass(size, size, WW3D_FORMAT_A8R8G8B8, MIP_LEVELS_1);
+ SurfaceClass *surface = texture->Get_Surface_Level();
+ if (!surface)
{
- const Int w = bm.bmWidth;
- const Int h = bm.bmHeight;
-
- BITMAPINFO bi;
- memset( &bi, 0, sizeof( bi ) );
- bi.bmiHeader.biSize = sizeof( BITMAPINFOHEADER );
- bi.bmiHeader.biWidth = w;
- bi.bmiHeader.biHeight = -h; // negative means top down, which is the order a texture wants
- bi.bmiHeader.biPlanes = 1;
- bi.bmiHeader.biBitCount = 32;
- bi.bmiHeader.biCompression = BI_RGB;
-
- UnsignedInt *color = NEW UnsignedInt[ w * h ];
- UnsignedInt *mask = NEW UnsignedInt[ w * h ];
-
- HDC dc = GetDC( NULL );
- GetDIBits( dc, info.hbmColor, 0, h, color, &bi, DIB_RGB_COLORS );
- GetDIBits( dc, info.hbmMask, 0, h, mask, &bi, DIB_RGB_COLORS );
- ReleaseDC( NULL, dc );
-
- //
- // a 32-bit cursor carries its own alpha; an older one leaves it zero and says what is
- // transparent in the AND mask instead, where a white pixel is a hole
- //
- Bool hasAlpha = FALSE;
- for( Int i = 0; i < w * h; ++i )
- if( color[ i ] & 0xFF000000 )
- {
- hasAlpha = TRUE;
- break;
- }
-
- if( hasAlpha == FALSE )
- for( Int i = 0; i < w * h; ++i )
- color[ i ] |= (mask[ i ] & 0x00FFFFFF) ? 0x00000000 : 0xFF000000;
-
- TextureClass *texture = MSGNEW("TextureClass") TextureClass( w, h, WW3D_FORMAT_A8R8G8B8, MIP_LEVELS_1 );
- SurfaceClass *surface = texture->Get_Surface_Level();
- Int pitch;
- UnsignedByte *bits = (UnsignedByte *)surface->Lock( &pitch );
- for( Int row = 0; row < h; ++row )
- memcpy( bits + row * pitch, color + row * w, w * sizeof( UnsignedInt ) );
- surface->Unlock();
- REF_PTR_RELEASE( surface );
-
- delete [] color;
- delete [] mask;
-
- Image *image = newInstance(Image);
- Region2D uv;
- uv.lo.x = 0.0f;
- uv.lo.y = 0.0f;
- uv.hi.x = 1.0f;
- uv.hi.y = 1.0f;
- image->setStatus( IMAGE_STATUS_RAW_TEXTURE );
- image->setRawTextureData( texture );
- image->setUV( &uv );
- image->setTextureWidth( w );
- image->setTextureHeight( h );
- ICoord2D size;
- size.x = w;
- size.y = h;
- image->setImageSize( &size );
-
- hotSpot->x = info.xHotspot;
- hotSpot->y = info.yHotspot;
- result = image;
+ REF_PTR_RELEASE(texture);
+ return NULL;
}
-
- if( info.hbmColor )
- DeleteObject( info.hbmColor );
- if( info.hbmMask )
- DeleteObject( info.hbmMask );
-
- return result;
-}
-
-//-------------------------------------------------------------------------------------------------
-/** The marker on a destination is the cursor the player would be holding if they were pointing at
- * it: the move cursor for a move, the attack-move one for an attack-move, the attack one for an
- * attack. Same art, so nothing here has to invent a second visual language. Built once. */
-//-------------------------------------------------------------------------------------------------
-static const Image *orderCursorImage( Mouse::MouseCursor cursor, ICoord2D *hotSpot )
-{
- OrderCursorArt& art = s_orderCursorArt[ cursor ];
- if( art.tried == FALSE )
+ Int pitch;
+ UnsignedByte *bits = (UnsignedByte*)surface->Lock(&pitch);
+ if (!bits)
{
- art.image = loadOrderCursorImage( cursor, &art.hotSpot );
- art.tried = TRUE;
+ REF_PTR_RELEASE(surface);
+ REF_PTR_RELEASE(texture);
+ return NULL;
}
-
- *hotSpot = art.hotSpot;
- return art.image;
+ for (Int row = 0; row < size; ++row)
+ memcpy(bits + row * pitch, DestinationDotPixels + row * size, size * sizeof(UnsignedInt));
+ surface->Unlock();
+ REF_PTR_RELEASE(surface);
+
+ Image *image = newInstance(Image);
+ Region2D uv;
+ uv.lo.x = uv.lo.y = 0.0f;
+ uv.hi.x = uv.hi.y = 1.0f;
+ image->setStatus(IMAGE_STATUS_RAW_TEXTURE);
+ image->setRawTextureData(texture);
+ image->setUV(&uv);
+ image->setTextureWidth(size);
+ image->setTextureHeight(size);
+ ICoord2D dimensions = {size, size};
+ image->setImageSize(&dimensions);
+ m_orderDestinationImage = image;
+ return image;
}
//-------------------------------------------------------------------------------------------------
/** One faint line per selected unit, from where it stands to where it is going, with the order's
- * own cursor sitting on the destination. Green for a move, pink for an attack-move, red for an
+ * dot marker sitting on the destination. Green for a move, pink for an attack-move, red for an
* attack. The goals are read off the units every frame, so the lines last as long as the orders
* do and go when the units arrive or the selection changes. */
//-------------------------------------------------------------------------------------------------
@@ -1141,19 +1052,15 @@ void W3DInGameUI::drawOrderHints( void )
TheDisplay->drawLine( from.x, from.y, to.x, to.y, width, lineColor );
- // the marker is the plain pointer, tinted: its white body takes the order colour and the
- // dark outline stays. The hot spot is the pixel the player aims with, so that is the pixel
- // that goes on the destination - a pointer hung by its top left corner points at the wrong
- // ground
- ICoord2D hotSpot;
- const Image *image = orderCursorImage( Mouse::ARROW, &hotSpot );
+ // Centre the dot on the actual goal; keep the existing arrival slide and fade.
+ const Image *image = getOrderDestinationImage();
if( image )
{
const Int w = image->getImageWidth();
const Int h = image->getImageHeight();
const Int slide = REAL_TO_INT_FLOOR( ( 1.0f - eased ) * MARKER_SLIDE_PIXELS );
- const Int x = to.x - hotSpot.x + slide;
- const Int y = to.y - hotSpot.y + slide;
+ const Int x = to.x - DESTINATION_DOT_HOTSPOT_X + slide;
+ const Int y = to.y - DESTINATION_DOT_HOTSPOT_Y + slide;
// the tint carries the fade as well as the order's colour
const UnsignedInt markerColor = ( orderHintMarkerColor( it->kind ) & 0x00FFFFFF )
@@ -1459,4 +1366,3 @@ void W3DInGameUI::drawPlaceAngle( View *view )
//TheDisplay->drawLine( start.x, start.y, end.x, end.y, width, color );
} // end drawPlaceAngle
-
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp
index 70e6afc06..bab0a2f89 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp
@@ -49,6 +49,7 @@
#include "Common/Player.h"
#include "GameClient/Color.h"
+#include "GameClient/CameraBoundary.h"
#include "GameClient/CommandXlat.h"
#include "GameClient/Drawable.h"
#include "GameClient/GameClient.h"
@@ -177,6 +178,10 @@ W3DView::W3DView()
m_FXPitch = 1.0f;
m_freezeTimeForCameraMovement = false;
m_cameraHasMovedSinceRequest = true;
+ // Scripted pans may expand this region even while map constraints are disabled.
+ m_cameraConstraint.lo.x = m_cameraConstraint.lo.y = 0.0f;
+ m_cameraConstraint.hi.x = m_cameraConstraint.hi.y = 0.0f;
+ m_cameraConstraintValid = false;
m_locationRequests.clear();
m_locationRequests.reserve(MAX_REQUEST_CACHE_SIZE + 10); // This prevents the vector from ever re-allocing
@@ -295,12 +300,9 @@ void W3DView::buildCameraTransform( Matrix3D *transform )
pos.x += m_shakeOffset.x;
pos.y += m_shakeOffset.y;
- if (m_cameraConstraintValid)
+ if (TheGlobalData->m_useCameraConstraints && m_cameraConstraintValid)
{
- pos.x = maxf(m_cameraConstraint.lo.x, pos.x);
- pos.x = minf(m_cameraConstraint.hi.x, pos.x);
- pos.y = maxf(m_cameraConstraint.lo.y, pos.y);
- pos.y = minf(m_cameraConstraint.hi.y, pos.y);
+ pos = constrainCameraPosition(pos, m_cameraConstraint);
}
// set position of camera itself
@@ -530,6 +532,13 @@ void W3DView::calcCameraConstraints()
{
Region3D mapRegion;
TheTerrainLogic->getExtent( &mapRegion );
+ if (TheGlobalData->m_cameraBoundaryMargin > 0)
+ {
+ // A fixed margin follows the map rather than shrinking with zoom or camera angle.
+ m_cameraConstraint = cameraBoundaryFromMap(mapRegion, (Real)TheGlobalData->m_cameraBoundaryMargin);
+ m_cameraConstraintValid = true;
+ return;
+ }
/*
Note the following restrictions on camera constraints!
@@ -672,9 +681,7 @@ void W3DView::setCameraTransform( void )
}
m_3DCamera->Set_Clip_Planes(nearZ, farZ);
-#if defined(_DEBUG) || defined(_INTERNAL)
if (TheGlobalData->m_useCameraConstraints)
-#endif
{
if (!m_cameraConstraintValid)
{
@@ -686,11 +693,7 @@ void W3DView::setCameraTransform( void )
if (m_cameraConstraintValid)
{
- Coord3D pos = *getPosition();
- pos.x = maxf(m_cameraConstraint.lo.x, pos.x);
- pos.x = minf(m_cameraConstraint.hi.x, pos.x);
- pos.y = maxf(m_cameraConstraint.lo.y, pos.y);
- pos.y = minf(m_cameraConstraint.hi.y, pos.y);
+ Coord3D pos = constrainCameraPosition(*getPosition(), m_cameraConstraint);
setPosition(&pos);
}
}
@@ -2097,27 +2100,19 @@ void W3DView::setSnapMode( CameraLockType lockType, Real lockDist )
//-------------------------------------------------------------------------------------------------
void W3DView::scrollBy( Coord2D *delta )
{
- // if we haven't moved, ignore
+ // Sample every render tick, including zero movement. Measuring only nonzero scrolls
+ // includes all the idle time in the first move and produces a jump on every restart.
+ const Real scrollDtFactor = m_scrollClock.sample(timeGetTime(), TheW3DFrameLengthInMsec);
+ if (delta)
+ m_scrollAmount = *delta;
+
if( delta && (delta->x != 0 || delta->y != 0) )
{
const Real SCROLL_RESOLUTION = 250.0f;
- // The scroll offsets are tuned as per-30Hz-tick amounts but arrive once per render
- // frame, so scale the applied movement by real elapsed time to keep scroll speed
- // framerate-independent. m_scrollAmount stays unscaled - the height-adjust cutoff
- // in update() compares it against per-tick thresholds.
- static DWORD prevScrollTime = timeGetTime();
- DWORD nowScrollTime = timeGetTime();
- Real scrollDtFactor = (nowScrollTime - prevScrollTime) / (Real)TheW3DFrameLengthInMsec;
- prevScrollTime = nowScrollTime;
- if (scrollDtFactor > 3.0f)
- scrollDtFactor = 3.0f; // after a hitch or idle, don't teleport the camera
-
Vector3 world, worldStart, worldEnd;
Vector2 screen, start, end;
- m_scrollAmount = *delta;
-
screen.X = delta->x;
screen.Y = delta->y;
diff --git a/GeneralsMD/Code/Tests/test_camera_behavior.inc b/GeneralsMD/Code/Tests/test_camera_behavior.inc
new file mode 100644
index 000000000..aa3dec213
--- /dev/null
+++ b/GeneralsMD/Code/Tests/test_camera_behavior.inc
@@ -0,0 +1,231 @@
+// Exercise upstream camera input and GUI routing with lightweight subsystem fixtures.
+#include "GameClient/LookAtXlat.h"
+#include "GameClient/CameraBoundary.h"
+#include "GameClient/MetaEvent.h"
+#include "GameClient/Keyboard.h"
+#include "GameClient/KeyDefs.h"
+#include "GameClient/Shell.h"
+#include "GameClient/GameWindowManager.h"
+#include "Common/StatsCollector.h"
+#include "Common/PlayerList.h"
+#include "GameLogic/RankInfo.h"
+#include "GameLogic/GameLogic.h"
+
+namespace
+{
+class CameraTestKeyboard : public Keyboard
+{
+public:
+ Bool getCapsState() { return FALSE; }
+ void getKey(KeyboardIO *key) { key->key = KEY_NONE; }
+ void modifiers(Int flags) { m_modifiers = flags; }
+};
+
+class CameraTestMouse : public Mouse
+{
+public:
+ Int cursorChanges = 0, captures = 0, releases = 0;
+ void initCursorResources() {}
+ void setCursor(MouseCursor cursor) { m_currentCursor = cursor; ++cursorChanges; }
+ void capture() { ++captures; }
+ void releaseCapture() { ++releases; }
+ UnsignedByte getMouseEvent(MouseIO*, Bool) { return 0; }
+};
+
+class CameraTestUI : public InGameUI
+{
+public:
+ void draw() {}
+ View *createView() { return NULL; }
+ Bool scrolling = FALSE, selecting = FALSE, enabled = TRUE;
+ void setScrolling(Bool value) { InGameUI::setScrolling(value); scrolling = value; }
+ Bool isScrolling() { return scrolling; }
+ Bool isSelecting() { return selecting; }
+ Bool getInputEnabled() { return enabled; }
+};
+
+class CameraTestView : public View
+{
+public:
+ using View::getPosition;
+ using View::setPosition;
+ Coord2D last = {0, 0};
+ Int samples = 0;
+ Int constraintRecalcs = 0;
+ Bool terrainHit = FALSE;
+ Coord3D terrainPoint = {0, 0, 0};
+ Int terrainPicks = 0;
+ Int lookAtCalls = 0;
+ void lookAt(const Coord3D *pos) { ++lookAtCalls; setPosition(pos); }
+ void forceCameraConstraintRecalc() { ++constraintRecalcs; }
+ void scrollBy(Coord2D *delta) { last = *delta; ++samples; }
+ Drawable *pickDrawable(const ICoord2D*, Bool, PickType) { return NULL; }
+ Int iterateDrawablesInRegion(IRegion2D*, Bool (*)(Drawable*, void*), void*) { return 0; }
+ void forceRedraw() {}
+ const Coord3D& get3DCameraPosition() const { return m_pos; }
+ WorldToScreenReturn worldToScreenTriReturn(const Coord3D*, ICoord2D*) { return WTS_INSIDE_FRUSTUM; }
+ void screenToWorld(const ICoord2D*, Coord3D*) {}
+ Bool screenToTerrain(const ICoord2D*, Coord3D *world)
+ { ++terrainPicks; *world = terrainPoint; return terrainHit; }
+ void screenToWorldAtZ(const ICoord2D*, Coord3D *world, Real z)
+ { *world = terrainPoint; world->z = z; }
+ void drawView() {}
+ void updateView() {}
+ void setGuardBandBias(const Coord2D*) {}
+};
+
+struct CameraInputFixture
+{
+ GlobalData *savedGlobal = TheWritableGlobalData;
+ InGameUI *savedUI = TheInGameUI;
+ View *savedView = TheTacticalView;
+ Keyboard *savedKeyboard = TheKeyboard;
+ Mouse *savedMouse = TheMouse;
+ Shell *savedShell = TheShell;
+ GameWindowManager *savedWindows = TheWindowManager;
+ StatsCollector *savedStats = TheStatsCollector;
+ PlayerList *savedPlayers = ThePlayerList;
+ RankInfoStore *savedRanks = TheRankInfoStore;
+ GameLogic *savedLogic = TheGameLogic;
+ GlobalData *global;
+ CameraTestUI *ui;
+ CameraTestView view;
+ CameraTestKeyboard keyboard;
+ CameraTestMouse mouse;
+ LookAtTranslator camera;
+
+ CameraInputFixture()
+ {
+ global = NEW GlobalData;
+ TheWritableGlobalData = global;
+ // Like bootOnce's subsystems, keep one UI until process exit. Its production destructor
+ // requires a fully built control bar and a device, which this input test does not create.
+ static CameraTestUI *testUI = NEW CameraTestUI;
+ ui = testUI;
+ ui->scrolling = ui->selecting = FALSE;
+ ui->enabled = TRUE;
+ TheInGameUI = ui;
+ TheTacticalView = &view;
+ TheKeyboard = &keyboard;
+ TheMouse = &mouse;
+ TheShell = NULL;
+ TheWindowManager = NULL;
+ TheStatsCollector = NULL;
+ static RankInfoStore *ranks = NEW RankInfoStore;
+ TheRankInfoStore = ranks;
+ static PlayerList *players = NEW PlayerList;
+ ThePlayerList = players;
+ static GameLogic *logic = NEW GameLogic;
+ TheGameLogic = logic;
+ global->m_saveCameraInReplay = FALSE;
+ }
+ ~CameraInputFixture()
+ {
+ camera.resetModes();
+ TheInGameUI = savedUI;
+ TheTacticalView = savedView;
+ TheKeyboard = savedKeyboard;
+ TheMouse = savedMouse;
+ TheShell = savedShell;
+ TheWindowManager = savedWindows;
+ TheStatsCollector = savedStats;
+ ThePlayerList = savedPlayers;
+ TheRankInfoStore = savedRanks;
+ TheGameLogic = savedLogic;
+ TheWritableGlobalData = savedGlobal;
+ delete global;
+ }
+ void logicTick()
+ {
+ GameMessage *message = newInstance(GameMessage)(GameMessage::MSG_FRAME_TICK);
+ camera.translateGameMessage(message);
+ message->deleteInstance();
+ }
+ void tick() { logicTick(); }
+ GameMessageDisposition wheel(Real spin)
+ {
+ GameMessage *message = newInstance(GameMessage)(GameMessage::MSG_RAW_MOUSE_WHEEL);
+ ICoord2D pixel = {100, 100};
+ message->appendPixelArgument(pixel);
+ message->appendRealArgument(spin);
+ GameMessageDisposition disposition = camera.translateGameMessage(message);
+ message->deleteInstance();
+ return disposition;
+ }
+};
+}
+
+TEST(camera_margin_allows_map_corners_but_bounds_large_pans)
+{
+ const Region3D maps[] = {
+ {{0, 0, 0}, {3000, 2000, 100}},
+ {{-500, 700, -20}, {-450, 730, 80}} // small map with a nonzero origin
+ };
+ for (Int m = 0; m < 2; ++m)
+ {
+ const Region3D& map = maps[m];
+ const Region2D boundary = cameraBoundaryFromMap(map, 200.0f);
+ for (Int x = 0; x < 2; ++x)
+ for (Int y = 0; y < 2; ++y)
+ {
+ Coord3D corner = {x ? map.hi.x : map.lo.x, y ? map.hi.y : map.lo.y, 42.0f};
+ Coord3D allowed = constrainCameraPosition(corner, boundary);
+ CHECK(allowed == corner); // every map corner must remain reachable
+ corner.x += x ? 100.0f : -100.0f;
+ corner.y += y ? 100.0f : -100.0f;
+ allowed = constrainCameraPosition(corner, boundary);
+ CHECK(allowed == corner); // there is useful room outside both edges
+ Coord3D outsideMap = {x ? 1e7f : -1e7f, y ? 1e7f : -1e7f, corner.z};
+ Coord3D limited = constrainCameraPosition(outsideMap, boundary);
+ CHECK_NEAR(limited.x, (x ? map.hi.x + 200.0f : map.lo.x - 200.0f), 0.00001f);
+ CHECK_NEAR(limited.y, (y ? map.hi.y + 200.0f : map.lo.y - 200.0f), 0.00001f);
+ CHECK_EQ(limited.z, corner.z);
+ Coord3D inward = limited;
+ inward.x += x ? -10.0f : 10.0f;
+ inward.y += y ? -10.0f : 10.0f;
+ allowed = constrainCameraPosition(inward, boundary);
+ CHECK(allowed == inward); // reaching a corner must not trap the camera
+ }
+ }
+}
+
+TEST(camera_margin_preferences_load_and_rebuild_constraints)
+{
+ CHECK(bootOnce());
+ CameraInputFixture f;
+ UserPreferences pref;
+ pref[AsciiString("UseCameraConstraints")] = AsciiString("Yes");
+ pref[AsciiString("CameraBoundaryMargin")] = AsciiString("300");
+ loadOptionsFromPreferences(pref);
+ CHECK(f.global->m_useCameraConstraints);
+ CHECK_EQ(f.global->m_cameraBoundaryMargin, 300);
+ CHECK_EQ(f.view.constraintRecalcs, 1);
+}
+
+TEST(camera_wheel_zoom_never_recenters_on_the_cursor)
+{
+ CHECK(bootOnce());
+ CameraInputFixture f;
+ Coord3D start = {1500, 1000, 0};
+ f.view.setPosition(&start);
+ f.view.setHeightAboveGround(300.0f);
+ // Even an old preference requesting cursor zoom cannot revive the removed pin.
+ f.global->m_zoomToCursor = TRUE;
+ for (Bool terrainHit : {FALSE, TRUE})
+ {
+ f.view.terrainHit = terrainHit;
+ f.view.terrainPoint.set(0, 0, 120);
+ CHECK_EQ(f.wheel(1.0f), KEEP_MESSAGE);
+ CHECK_EQ(f.view.getHeightAboveGround(), 240.0f);
+ f.view.setZoom(0.1f);
+ for (Int frame = 0; frame < 8; ++frame) f.tick();
+ CHECK_EQ(f.wheel(-1.0f), KEEP_MESSAGE);
+ CHECK_EQ(f.view.getHeightAboveGround(), 300.0f);
+ f.view.setZoom(1.0f);
+ for (Int frame = 0; frame < 8; ++frame) f.tick();
+ CHECK_EQ(f.view.getPosition()->x, start.x);
+ CHECK_EQ(f.view.getPosition()->y, start.y);
+ CHECK_EQ(f.view.lookAtCalls, 0);
+ CHECK_EQ(f.view.terrainPicks, 0);
+ }
+}
diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cpp
index 706278c7b..df45f38f3 100644
--- a/GeneralsMD/Code/Tests/test_gameengine.cpp
+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp
@@ -11859,3 +11859,63 @@ TEST(button_flash_draws_nothing_for_a_button_the_layout_lacks)
CHECK_EQ( flash.drawState(), (Int)ButtonFlashWithoutWindow::NOTHING_TO_DRAW );
}
}
+
+
+// Camera scroll timing must advance during stationary frames as well as moving frames.
+#include "GameClient/CameraScrollClock.h"
+
+TEST(camera_scroll_restarts_after_idle_without_a_jump)
+{
+ CameraScrollClock clock;
+ CHECK_NEAR(clock.sample(1000, 33), 0.0f, 0.00001f);
+ for (uint32_t now = 1016; now <= 17000; now += 16)
+ clock.sample(now, 33); // stationary render frames
+ CHECK_NEAR(clock.sample(17016, 33), 16.0f / 33.0f, 0.00001f);
+ CHECK_NEAR(clock.sample(17032, 33), 16.0f / 33.0f, 0.00001f);
+}
+
+TEST(camera_scroll_elapsed_time_is_independent_of_render_rate)
+{
+ const int rates[] = {30, 60, 144, 240};
+ for (int r = 0; r < 4; ++r)
+ {
+ CameraScrollClock clock;
+ clock.sample(1000, 33);
+ float distance = 0.0f;
+ for (int frame = 1; frame <= rates[r]; ++frame)
+ distance += clock.sample(1000 + frame * 1000 / rates[r], 33);
+ CHECK_NEAR(distance, 1000.0f / 33.0f, 0.0001f);
+ }
+}
+
+TEST(camera_scroll_clocks_are_independent_and_handle_timer_wrap)
+{
+ CameraScrollClock first, second;
+ first.sample(0xfffffff0u, 33);
+ second.sample(2000, 33);
+ CHECK_NEAR(first.sample(0u, 33), 16.0f / 33.0f, 0.00001f);
+ CHECK_NEAR(second.sample(2033, 33), 1.0f, 0.00001f);
+ CHECK_NEAR(second.sample(9000, 33), 3.0f, 0.00001f);
+}
+
+TEST(camera_preferences_default_to_a_finite_map_margin_without_cursor_zoom)
+{
+ CHECK(bootOnce());
+ GlobalData *saved = TheWritableGlobalData;
+ GlobalData *scratch = NEW GlobalData;
+ TheWritableGlobalData = scratch;
+ CHECK(scratch->m_useCameraConstraints);
+ CHECK_EQ(scratch->m_cameraBoundaryMargin, 200);
+ CHECK(!scratch->m_zoomToCursor);
+ const OptionDef *bounds = findOptionDef("UseCameraConstraints");
+ CHECK(bounds != NULL);
+ if (bounds)
+ {
+ bounds->set(0);
+ CHECK(!scratch->m_useCameraConstraints);
+ }
+ TheWritableGlobalData = saved;
+ delete scratch;
+}
+#include "test_camera_behavior.inc"
+#include "test_production_input.inc"
diff --git a/GeneralsMD/Code/Tests/test_production_input.inc b/GeneralsMD/Code/Tests/test_production_input.inc
new file mode 100644
index 000000000..ccaecd6e8
--- /dev/null
+++ b/GeneralsMD/Code/Tests/test_production_input.inc
@@ -0,0 +1,295 @@
+// Exercise the actual GUI hit testing/button callbacks and strip input translator.
+#include "GameClient/PlaceEventTranslator.h"
+#include "GameClient/GadgetPushButton.h"
+#include "GameClient/WindowXlat.h"
+
+namespace
+{
+class ProductionInputWindow : public GameWindow
+{
+ MEMORY_POOL_GLUE_WITH_EXPLICIT_CREATE(ProductionInputWindow, "ProductionInputWindow", 16, 16)
+public:
+ void winDrawBorder() {}
+ void winSetFont(GameFont*) {}
+};
+ProductionInputWindow::~ProductionInputWindow() {}
+
+class ProductionInputWindows : public GameWindowManager
+{
+public:
+ GameWindow *allocateNewWindow() { return newInstance(ProductionInputWindow)(); }
+ GameFont *winFindFont(AsciiString, Int, Bool) { return NULL; }
+ GameWinDrawFunc getPushButtonImageDrawFunc() { return NULL; }
+ GameWinDrawFunc getPushButtonDrawFunc() { return NULL; }
+ GameWinDrawFunc getCheckBoxImageDrawFunc() { return NULL; }
+ GameWinDrawFunc getCheckBoxDrawFunc() { return NULL; }
+ GameWinDrawFunc getRadioButtonImageDrawFunc() { return NULL; }
+ GameWinDrawFunc getRadioButtonDrawFunc() { return NULL; }
+ GameWinDrawFunc getTabControlImageDrawFunc() { return NULL; }
+ GameWinDrawFunc getTabControlDrawFunc() { return NULL; }
+ GameWinDrawFunc getListBoxImageDrawFunc() { return NULL; }
+ GameWinDrawFunc getListBoxDrawFunc() { return NULL; }
+ GameWinDrawFunc getComboBoxImageDrawFunc() { return NULL; }
+ GameWinDrawFunc getComboBoxDrawFunc() { return NULL; }
+ GameWinDrawFunc getHorizontalSliderImageDrawFunc() { return NULL; }
+ GameWinDrawFunc getHorizontalSliderDrawFunc() { return NULL; }
+ GameWinDrawFunc getVerticalSliderImageDrawFunc() { return NULL; }
+ GameWinDrawFunc getVerticalSliderDrawFunc() { return NULL; }
+ GameWinDrawFunc getProgressBarImageDrawFunc() { return NULL; }
+ GameWinDrawFunc getProgressBarDrawFunc() { return NULL; }
+ GameWinDrawFunc getStaticTextImageDrawFunc() { return NULL; }
+ GameWinDrawFunc getStaticTextDrawFunc() { return NULL; }
+ GameWinDrawFunc getTextEntryImageDrawFunc() { return NULL; }
+ GameWinDrawFunc getTextEntryDrawFunc() { return NULL; }
+};
+
+struct ProductionClickCount
+{
+ Int left = 0, right = 0;
+ static WindowMsgHandledType system(GameWindow *window, UnsignedInt msg, WindowMsgData, WindowMsgData)
+ {
+ ProductionClickCount *count = (ProductionClickCount*)window->winGetUserData();
+ if(msg == GBM_SELECTED) ++count->left;
+ if(msg == GBM_SELECTED_RIGHT) ++count->right;
+ return MSG_HANDLED;
+ }
+};
+
+struct ProductionButtonFixture
+{
+ CameraInputFixture engine;
+ ProductionInputWindows windows;
+ ProductionClickCount count;
+ GameWindow *parent, *button;
+ ICoord2D pixel = {30, 30};
+ ProductionButtonFixture(UnsignedInt layer = 0)
+ {
+ TheWindowManager = &windows;
+ parent = windows.winCreate(NULL, WIN_STATUS_ENABLED | layer, 0, 0, 200, 200,
+ ProductionClickCount::system);
+ parent->winSetUserData(&count);
+ button = windows.winCreate(parent, WIN_STATUS_RIGHT_CLICK | WIN_STATUS_CANCEL_WHEN_DISABLED,
+ 20, 20, 40, 40, GadgetPushButtonSystem);
+ button->winSetInputFunc(GadgetPushButtonInput);
+ button->winSetOwner(parent);
+ button->winGetInstanceData()->m_status |= WIN_STATUS_RIGHT_CLICK;
+ }
+ ~ProductionButtonFixture()
+ {
+ // Dispose of windows while their global manager and mouse are still installed.
+ windows.winDestroyAll();
+ }
+ WinInputReturnCode click(GameWindowMessage msg) { return windows.winProcessMouseEvent(msg, &pixel, NULL); }
+};
+
+class ProductionStripTestUI : public CameraTestUI
+{
+public:
+ void staleCameo()
+ {
+ for(Int row = 0; row < PRODUCTION_STRIP_ROWS; ++row) m_productionStripCount[row] = 0;
+ m_productionStripCameoW = m_productionStripCameoH = 40;
+ m_productionStripCount[0] = 1;
+ ProductionStripSlot &slot = m_productionStrip[0][0];
+ slot.producer = INVALID_ID; // producer died after the last draw; the strip still owns the click
+ slot.pos.x = slot.pos.y = 20;
+ }
+};
+
+struct ProductionStripFixture
+{
+ CameraInputFixture engine;
+ PlaceEventTranslator strip;
+ ProductionStripFixture()
+ {
+ static ProductionStripTestUI *ui = NEW ProductionStripTestUI;
+ ui->staleCameo();
+ TheInGameUI = ui;
+ }
+ GameMessageDisposition event(GameMessage::Type type, Int x = 30, Int y = 30)
+ {
+ GameMessage *message = newInstance(GameMessage)(type);
+ ICoord2D pixel = {x, y};
+ message->appendPixelArgument(pixel);
+ GameMessageDisposition result = strip.translateGameMessage(message);
+ message->deleteInstance();
+ return result;
+ }
+};
+
+struct ProductionMessageFixture
+{
+ MessageStream stream;
+ CommandList commands;
+ MessageStream *savedStream = TheMessageStream;
+ CommandList *savedCommands = TheCommandList;
+ ProductionMessageFixture()
+ {
+ TheMessageStream = &stream;
+ TheCommandList = &commands;
+ stream.attachTranslator(NEW MetaEventTranslator, 20);
+ stream.attachTranslator(NEW PlaceEventTranslator, 30);
+ }
+ ~ProductionMessageFixture()
+ {
+ TheMessageStream = savedStream;
+ TheCommandList = savedCommands;
+ }
+ void append(GameMessage::Type type, Int x, Int y)
+ {
+ GameMessage *message = stream.appendMessage(type);
+ ICoord2D pixel = {x, y};
+ message->appendPixelArgument(pixel);
+ if(type == GameMessage::MSG_RAW_MOUSE_RIGHT_DRAG)
+ message->appendPixelArgument(pixel);
+ else
+ message->appendIntegerArgument(0); // modifiers
+ message->appendIntegerArgument(100); // event time
+ }
+};
+}
+
+TEST(production_cancel_disabled_button_accepts_only_right_click_once)
+{
+ CHECK(bootOnce());
+ ProductionButtonFixture f;
+ CHECK(!(f.button->winGetStatus() & WIN_STATUS_ENABLED));
+ CHECK(f.click(GWM_RIGHT_DOWN) == WIN_INPUT_USED);
+ CHECK(f.count.right == 1 && f.count.left == 0);
+ CHECK(f.click(GWM_RIGHT_UP) == WIN_INPUT_USED);
+ CHECK(f.count.right == 1 && f.count.left == 0);
+ f.click(GWM_LEFT_DOWN);
+ f.click(GWM_LEFT_UP);
+ CHECK(f.count.right == 1 && f.count.left == 0);
+ CHECK(!(f.button->winGetStatus() & WIN_STATUS_ENABLED));
+}
+
+TEST(production_cancel_respects_hidden_disabled_parents_and_ordinary_buttons)
+{
+ CHECK(bootOnce());
+ ProductionButtonFixture f;
+ f.button->winClearStatus(WIN_STATUS_CANCEL_WHEN_DISABLED);
+ f.click(GWM_RIGHT_DOWN); f.click(GWM_RIGHT_UP);
+ CHECK(f.count.right == 0);
+ f.button->winSetStatus(WIN_STATUS_CANCEL_WHEN_DISABLED);
+ f.button->winHide(TRUE);
+ f.click(GWM_RIGHT_DOWN); f.click(GWM_RIGHT_UP);
+ CHECK(f.count.right == 0);
+ f.button->winHide(FALSE);
+ f.parent->winEnable(FALSE);
+ f.click(GWM_RIGHT_DOWN); f.click(GWM_RIGHT_UP);
+ CHECK(f.count.right == 0);
+ f.parent->winEnable(TRUE);
+ f.click(GWM_RIGHT_DOWN); f.click(GWM_RIGHT_UP);
+ CHECK(f.count.right == 1);
+}
+
+TEST(production_cancel_works_in_above_below_modal_and_captured_windows)
+{
+ CHECK(bootOnce());
+ for(UnsignedInt layer : {WIN_STATUS_ABOVE, WIN_STATUS_BELOW})
+ {
+ ProductionButtonFixture f(layer);
+ CHECK(f.click(GWM_RIGHT_DOWN) == WIN_INPUT_USED);
+ f.click(GWM_RIGHT_UP);
+ CHECK(f.count.right == 1);
+ }
+ ProductionButtonFixture f;
+ f.windows.winSetModal(f.parent);
+ CHECK(f.click(GWM_RIGHT_DOWN) == WIN_INPUT_USED);
+ f.click(GWM_RIGHT_UP);
+ CHECK(f.count.right == 1);
+ f.windows.winUnsetModal(f.parent);
+ f.windows.winCapture(f.parent);
+ CHECK(f.click(GWM_RIGHT_DOWN) == WIN_INPUT_USED);
+ f.click(GWM_RIGHT_UP);
+ CHECK(f.count.right == 2);
+}
+
+TEST(production_cancel_reusing_a_button_clears_disabled_cancellation)
+{
+ CHECK(bootOnce());
+ ProductionButtonFixture f;
+ GadgetButtonSetData(f.button, &f.count);
+ CHECK(!(f.button->winGetStatus() & WIN_STATUS_CANCEL_WHEN_DISABLED));
+ f.click(GWM_RIGHT_DOWN); f.click(GWM_RIGHT_UP);
+ CHECK(f.count.right == 0);
+}
+
+TEST(production_cancel_strip_consumes_press_drag_release_and_double_click)
+{
+ CHECK(bootOnce());
+ ProductionStripFixture f;
+ CHECK(f.event(GameMessage::MSG_RAW_MOUSE_RIGHT_BUTTON_DOWN) == DESTROY_MESSAGE);
+ CHECK(f.event(GameMessage::MSG_RAW_MOUSE_RIGHT_DRAG, 100, 100) == DESTROY_MESSAGE);
+ CHECK(f.event(GameMessage::MSG_RAW_MOUSE_RIGHT_BUTTON_UP, 100, 100) == DESTROY_MESSAGE);
+ CHECK(f.event(GameMessage::MSG_MOUSE_RIGHT_CLICK) == DESTROY_MESSAGE);
+ CHECK(f.event(GameMessage::MSG_RAW_MOUSE_RIGHT_BUTTON_UP, 100, 100) == KEEP_MESSAGE);
+ CHECK(f.event(GameMessage::MSG_RAW_MOUSE_RIGHT_DOUBLE_CLICK) == DESTROY_MESSAGE);
+ CHECK(f.event(GameMessage::MSG_RAW_MOUSE_RIGHT_BUTTON_UP) == DESTROY_MESSAGE);
+ CHECK(f.event(GameMessage::MSG_MOUSE_RIGHT_DOUBLE_CLICK) == DESTROY_MESSAGE);
+ CHECK(f.event(GameMessage::MSG_MOUSE_RIGHT_CLICK) == KEEP_MESSAGE);
+ CHECK(f.event(GameMessage::MSG_RAW_MOUSE_RIGHT_BUTTON_DOWN, 60, 30) == KEEP_MESSAGE);
+ CHECK(!TheInGameUI->handleProductionStripClick(NULL, TRUE));
+}
+
+TEST(production_cancel_strip_preserves_left_click_and_independent_button_releases)
+{
+ CHECK(bootOnce());
+ ProductionStripFixture f;
+ CHECK(f.event(GameMessage::MSG_RAW_MOUSE_LEFT_BUTTON_DOWN) == DESTROY_MESSAGE);
+ CHECK(f.event(GameMessage::MSG_RAW_MOUSE_RIGHT_BUTTON_DOWN) == DESTROY_MESSAGE);
+ CHECK(f.event(GameMessage::MSG_RAW_MOUSE_LEFT_BUTTON_UP, 100, 100) == DESTROY_MESSAGE);
+ CHECK(f.event(GameMessage::MSG_MOUSE_LEFT_CLICK) == DESTROY_MESSAGE);
+ CHECK(f.event(GameMessage::MSG_RAW_MOUSE_RIGHT_BUTTON_UP, 100, 100) == DESTROY_MESSAGE);
+ CHECK(f.event(GameMessage::MSG_MOUSE_RIGHT_CLICK) == DESTROY_MESSAGE);
+ CHECK(f.event(GameMessage::MSG_RAW_MOUSE_LEFT_BUTTON_UP) == KEEP_MESSAGE);
+ CHECK(f.event(GameMessage::MSG_RAW_MOUSE_LEFT_DOUBLE_CLICK) == DESTROY_MESSAGE);
+ CHECK(f.event(GameMessage::MSG_RAW_MOUSE_LEFT_BUTTON_UP) == DESTROY_MESSAGE);
+ CHECK(f.event(GameMessage::MSG_MOUSE_LEFT_DOUBLE_CLICK) == DESTROY_MESSAGE);
+}
+
+TEST(production_cancel_strip_new_press_recovers_when_gui_consumed_the_previous_release)
+{
+ CHECK(bootOnce());
+ ProductionStripFixture f;
+ CHECK(f.event(GameMessage::MSG_RAW_MOUSE_RIGHT_BUTTON_DOWN) == DESTROY_MESSAGE);
+ // The player released over a window, so WindowTranslator consumed the release before us.
+ CHECK(f.event(GameMessage::MSG_RAW_MOUSE_RIGHT_BUTTON_DOWN, 100, 100) == KEEP_MESSAGE);
+ CHECK(f.event(GameMessage::MSG_RAW_MOUSE_RIGHT_BUTTON_UP, 100, 100) == KEEP_MESSAGE);
+ CHECK(f.event(GameMessage::MSG_MOUSE_RIGHT_CLICK) == KEEP_MESSAGE);
+}
+
+TEST(production_cancel_strip_filters_real_meta_clicks_without_blocking_world_clicks)
+{
+ CHECK(bootOnce());
+ ProductionStripFixture engine;
+ ProductionMessageFixture f;
+ f.append(GameMessage::MSG_RAW_MOUSE_RIGHT_BUTTON_DOWN, 30, 30);
+ f.append(GameMessage::MSG_RAW_MOUSE_RIGHT_BUTTON_UP, 30, 30);
+ f.append(GameMessage::MSG_RAW_MOUSE_RIGHT_DOUBLE_CLICK, 30, 30);
+ f.append(GameMessage::MSG_RAW_MOUSE_RIGHT_BUTTON_UP, 30, 30);
+ f.stream.propagateMessages();
+ CHECK(f.commands.getFirstMessage() == NULL);
+ f.append(GameMessage::MSG_RAW_MOUSE_RIGHT_BUTTON_DOWN, 100, 100);
+ f.append(GameMessage::MSG_RAW_MOUSE_RIGHT_BUTTON_UP, 100, 100);
+ f.stream.propagateMessages();
+ Int worldClicks = 0;
+ for(GameMessage *m = f.commands.getFirstMessage(); m; m = m->next())
+ if(m->getType() == GameMessage::MSG_MOUSE_RIGHT_CLICK) ++worldClicks;
+ CHECK(worldClicks == 1);
+}
+
+TEST(production_cancel_disabled_button_release_outside_does_not_create_world_click)
+{
+ CHECK(bootOnce());
+ ProductionButtonFixture engine;
+ ProductionMessageFixture f;
+ f.stream.attachTranslator(NEW WindowTranslator, 10);
+ f.append(GameMessage::MSG_RAW_MOUSE_RIGHT_BUTTON_DOWN, 30, 30);
+ f.append(GameMessage::MSG_RAW_MOUSE_RIGHT_DRAG, 300, 300);
+ f.append(GameMessage::MSG_RAW_MOUSE_RIGHT_BUTTON_UP, 300, 300);
+ f.stream.propagateMessages();
+ CHECK(engine.count.right == 1 && engine.count.left == 0);
+ CHECK(f.commands.getFirstMessage() == NULL);
+}
diff --git a/README.md b/README.md
index 5e35fc8bc..bd4353f18 100644
--- a/README.md
+++ b/README.md
@@ -57,8 +57,8 @@ You need to own the game; no game data ships here. Nothing changes unit stats, w
there.
- **Soldiers cast real shadows**, built from the pose instead of a flat blob. Scud trails, falling
bombs, smoke clouds and all 128 tree types cast too — the tree shadows had never been drawn at all.
-- **It fits your monitor.** Widescreen resolutions are back in the options menu, zoom-to-cursor
- works, and buildings snap to the pathfinder's own grid with the blocked squares crossed out.
+- **It fits your monitor.** Widescreen resolutions are back in the options menu, zoom changes the current view without following the pointer,
+ and buildings snap to the pathfinder's own grid with the blocked squares crossed out.
- **It does not crash.** Poison clouds, mine clearing, garrison kills, full transports blowing up,
and quitting the game — all traced and fixed.
@@ -128,6 +128,23 @@ restores the retail opening view.
</details>
+## Camera and production corrections
+
+Camera pans restart smoothly after idle. The camera target can move up to 200 world units beyond
+each map edge, with a finite limit independent of zoom and rotation. `CameraBoundaryMargin` in
+Options.ini adjusts this margin (1–1000); 0 restores the original framing limit.
+`UseCameraConstraints = No` permits unlimited camera movement.
+Wheel zoom changes the current view's height without following the pointer; cursor anchoring is
+removed and ZoomToCursor defaults to No. Height easing remains the upstream implementation.
+
+Right-clicking the global production strip cancels one queued item and refunds its cost;
+left-click still jumps to the producer. Queued unit buttons also accept cancellation while
+greyed out by insufficient money or a full queue. Right-click cancels one item with modifiers
+held, and consumed GUI clicks do not issue world orders.
+
+Order destination arrows use a small antialiased green dot for movement; other orders keep
+their semantic colours. The artwork is embedded, so no external cursor artwork is required.
+
## Not there yet
- Random maps generate and play, but have no menu entry and no reroll button yet.