Skip to content

Commit 2677c39

Browse files
authored
feat(view): Add ability to rotate the camera in 45 degree increments using the numpad (#1846)
The view can be rotated in 45 degree increments by holding the CTRL modifier key while pressing the NumPad4 and NumPad6 keys
1 parent b3d7bcb commit 2677c39

File tree

6 files changed

+56
-0
lines changed

6 files changed

+56
-0
lines changed

Generals/Code/GameEngine/Include/Common/MessageStream.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,10 @@ class GameMessage : public MemoryPoolObject
263263

264264
MSG_META_BEGIN_CAMERA_ROTATE_LEFT,
265265
MSG_META_END_CAMERA_ROTATE_LEFT,
266+
MSG_META_ALT_CAMERA_ROTATE_LEFT, ///< TheSuperHackers @feature Rotate camera in 45 degree increments
266267
MSG_META_BEGIN_CAMERA_ROTATE_RIGHT,
267268
MSG_META_END_CAMERA_ROTATE_RIGHT,
269+
MSG_META_ALT_CAMERA_ROTATE_RIGHT, ///< TheSuperHackers @feature Rotate camera in 45 degree increments
268270
MSG_META_BEGIN_CAMERA_ZOOM_IN,
269271
MSG_META_END_CAMERA_ZOOM_IN,
270272
MSG_META_BEGIN_CAMERA_ZOOM_OUT,

Generals/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3271,6 +3271,10 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage
32713271
DEBUG_ASSERTCRASH(TheInGameUI->isCameraRotatingLeft(), ("Clearing rotate camera left, but it's already clear!"));
32723272
TheInGameUI->setCameraRotateLeft( false );
32733273
break;
3274+
case GameMessage::MSG_META_ALT_CAMERA_ROTATE_LEFT:
3275+
if (TheTacticalView->isCameraMovementFinished())
3276+
TheTacticalView->rotateCamera(-1.0f / 8.0f, 500);
3277+
break;
32743278
case GameMessage::MSG_META_BEGIN_CAMERA_ROTATE_RIGHT:
32753279
DEBUG_ASSERTCRASH(!TheInGameUI->isCameraRotatingRight(), ("Setting rotate camera right, but it's already set!"));
32763280
TheInGameUI->setCameraRotateRight( true );
@@ -3279,6 +3283,10 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage
32793283
DEBUG_ASSERTCRASH(TheInGameUI->isCameraRotatingRight(), ("Clearing rotate camera right, but it's already clear!"));
32803284
TheInGameUI->setCameraRotateRight( false );
32813285
break;
3286+
case GameMessage::MSG_META_ALT_CAMERA_ROTATE_RIGHT:
3287+
if (TheTacticalView->isCameraMovementFinished())
3288+
TheTacticalView->rotateCamera(1.0f / 8.0f, 500);
3289+
break;
32823290
case GameMessage::MSG_META_BEGIN_CAMERA_ZOOM_IN:
32833291
DEBUG_ASSERTCRASH(!TheInGameUI->isCameraZoomingIn(), ("Setting zoom camera in, but it's already set!"));
32843292
TheInGameUI->setCameraZoomIn( true );

Generals/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,24 @@ MetaMapRec *MetaMap::getMetaMapRec(GameMessage::Type t)
793793
map->m_displayName = TheGameText->FETCH_OR_SUBSTITUTE("GUI:SelectNextIdleWorker", L"Next Idle Worker");
794794
}
795795
}
796+
{
797+
MetaMapRec* map = TheMetaMap->getMetaMapRec(GameMessage::MSG_META_ALT_CAMERA_ROTATE_LEFT);
798+
if (map->m_key == MK_NONE) {
799+
map->m_key = MK_KP4;
800+
map->m_transition = DOWN;
801+
map->m_modState = CTRL;
802+
map->m_usableIn = COMMANDUSABLE_GAME;
803+
}
804+
}
805+
{
806+
MetaMapRec* map = TheMetaMap->getMetaMapRec(GameMessage::MSG_META_ALT_CAMERA_ROTATE_RIGHT);
807+
if (map->m_key == MK_NONE) {
808+
map->m_key = MK_KP6;
809+
map->m_transition = DOWN;
810+
map->m_modState = CTRL;
811+
map->m_usableIn = COMMANDUSABLE_GAME;
812+
}
813+
}
796814

797815
#if defined(RTS_DEBUG)
798816
{

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,10 @@ class GameMessage : public MemoryPoolObject
263263

264264
MSG_META_BEGIN_CAMERA_ROTATE_LEFT,
265265
MSG_META_END_CAMERA_ROTATE_LEFT,
266+
MSG_META_ALT_CAMERA_ROTATE_LEFT, ///< TheSuperHackers @feature Rotate camera in 45 degree increments
266267
MSG_META_BEGIN_CAMERA_ROTATE_RIGHT,
267268
MSG_META_END_CAMERA_ROTATE_RIGHT,
269+
MSG_META_ALT_CAMERA_ROTATE_RIGHT, ///< TheSuperHackers @feature Rotate camera in 45 degree increments
268270
MSG_META_BEGIN_CAMERA_ZOOM_IN,
269271
MSG_META_END_CAMERA_ZOOM_IN,
270272
MSG_META_BEGIN_CAMERA_ZOOM_OUT,

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3416,6 +3416,10 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage
34163416
DEBUG_ASSERTCRASH(TheInGameUI->isCameraRotatingLeft(), ("Clearing rotate camera left, but it's already clear!"));
34173417
TheInGameUI->setCameraRotateLeft( false );
34183418
break;
3419+
case GameMessage::MSG_META_ALT_CAMERA_ROTATE_LEFT:
3420+
if (TheTacticalView->isCameraMovementFinished())
3421+
TheTacticalView->rotateCamera(-1.0f / 8.0f, 500, 100, 400);
3422+
break;
34193423
case GameMessage::MSG_META_BEGIN_CAMERA_ROTATE_RIGHT:
34203424
DEBUG_ASSERTCRASH(!TheInGameUI->isCameraRotatingRight(), ("Setting rotate camera right, but it's already set!"));
34213425
TheInGameUI->setCameraRotateRight( true );
@@ -3424,6 +3428,10 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage
34243428
DEBUG_ASSERTCRASH(TheInGameUI->isCameraRotatingRight(), ("Clearing rotate camera right, but it's already clear!"));
34253429
TheInGameUI->setCameraRotateRight( false );
34263430
break;
3431+
case GameMessage::MSG_META_ALT_CAMERA_ROTATE_RIGHT:
3432+
if (TheTacticalView->isCameraMovementFinished())
3433+
TheTacticalView->rotateCamera(1.0f / 8.0f, 500, 100, 400);
3434+
break;
34273435
case GameMessage::MSG_META_BEGIN_CAMERA_ZOOM_IN:
34283436
DEBUG_ASSERTCRASH(!TheInGameUI->isCameraZoomingIn(), ("Setting zoom camera in, but it's already set!"));
34293437
TheInGameUI->setCameraZoomIn( true );

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,24 @@ MetaMapRec *MetaMap::getMetaMapRec(GameMessage::Type t)
851851
map->m_displayName = TheGameText->FETCH_OR_SUBSTITUTE("GUI:SelectNextIdleWorker", L"Next Idle Worker");
852852
}
853853
}
854+
{
855+
MetaMapRec* map = TheMetaMap->getMetaMapRec(GameMessage::MSG_META_ALT_CAMERA_ROTATE_LEFT);
856+
if (map->m_key == MK_NONE) {
857+
map->m_key = MK_KP4;
858+
map->m_transition = DOWN;
859+
map->m_modState = CTRL;
860+
map->m_usableIn = COMMANDUSABLE_GAME;
861+
}
862+
}
863+
{
864+
MetaMapRec* map = TheMetaMap->getMetaMapRec(GameMessage::MSG_META_ALT_CAMERA_ROTATE_RIGHT);
865+
if (map->m_key == MK_NONE) {
866+
map->m_key = MK_KP6;
867+
map->m_transition = DOWN;
868+
map->m_modState = CTRL;
869+
map->m_usableIn = COMMANDUSABLE_GAME;
870+
}
871+
}
854872

855873
#if defined(RTS_DEBUG)
856874
{

0 commit comments

Comments
 (0)