Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Core/GameEngine/Include/Common/OptionPreferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ class OptionPreferences : public UserPreferences
Bool getShowMoneyPerMinute() const;

Real getGameWindowTransitionSpeedMultiplier() const;
Real getCameraRotateSpeedMultiplier() const;
Real getCameraPitchSpeedMultiplier() const;

Int getObserverStatsFontSize(void);
Int getObserverNotificationFontSize(void);
Expand Down
20 changes: 20 additions & 0 deletions Core/GameEngine/Source/Common/OptionPreferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -977,3 +977,23 @@ Real OptionPreferences::getGameWindowTransitionSpeedMultiplier() const
Real speed = (Real) atof(it->second.str());
return clamp(1.0f, speed, 1000.0f);
}

Real OptionPreferences::getCameraRotateSpeedMultiplier() const
{
OptionPreferences::const_iterator it = find("CameraRotateSpeedMultiplier");
if (it == end())
return 1.0f;

Real multiplier = (Real) atof(it->second.str());
return clamp(0.1f, multiplier, 10.0f);
}

Real OptionPreferences::getCameraPitchSpeedMultiplier() const
{
OptionPreferences::const_iterator it = find("CameraPitchSpeedMultiplier");
if (it == end())
return 1.0f;

Real multiplier = (Real) atof(it->second.str());
return clamp(0.1f, multiplier, 10.0f);
}
20 changes: 20 additions & 0 deletions Core/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3552,9 +3552,29 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage
DEBUG_ASSERTCRASH(TheInGameUI->isCameraZoomingOut(), ("Clearing zoom camera out, but it's already clear!"));
TheInGameUI->setCameraZoomOut( false );
break;
case GameMessage::MSG_META_BEGIN_CAMERA_PITCH_UP:
case GameMessage::MSG_META_ALT_BEGIN_CAMERA_PITCH_UP:
TheInGameUI->setCameraPitchUp( true );
break;
case GameMessage::MSG_META_END_CAMERA_PITCH_UP:
case GameMessage::MSG_META_ALT_END_CAMERA_PITCH_UP:
TheInGameUI->setCameraPitchUp( false );
break;
case GameMessage::MSG_META_BEGIN_CAMERA_PITCH_DOWN:
case GameMessage::MSG_META_ALT_BEGIN_CAMERA_PITCH_DOWN:
TheInGameUI->setCameraPitchDown( true );
break;
case GameMessage::MSG_META_END_CAMERA_PITCH_DOWN:
case GameMessage::MSG_META_ALT_END_CAMERA_PITCH_DOWN:
TheInGameUI->setCameraPitchDown( false );
break;
case GameMessage::MSG_META_CAMERA_RESET:
TheInGameUI->resetCamera();
break;
case GameMessage::MSG_META_CAMERA_PITCH_RESET:
case GameMessage::MSG_META_ALT_CAMERA_PITCH_RESET:
TheTacticalView->userSetPitchToDefault();
break;
case GameMessage::MSG_META_TOGGLE_CAMERA_TRACKING_DRAWABLE:
TheInGameUI->setCameraTrackingDrawable( true );
break;
Expand Down
100 changes: 100 additions & 0 deletions Core/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,17 @@ static const LookupListRec GameMessageMetaTypeNames[] =
{ "END_CAMERA_ZOOM_IN", GameMessage::MSG_META_END_CAMERA_ZOOM_IN },
{ "BEGIN_CAMERA_ZOOM_OUT", GameMessage::MSG_META_BEGIN_CAMERA_ZOOM_OUT },
{ "END_CAMERA_ZOOM_OUT", GameMessage::MSG_META_END_CAMERA_ZOOM_OUT },
{ "BEGIN_CAMERA_PITCH_UP", GameMessage::MSG_META_BEGIN_CAMERA_PITCH_UP },
{ "END_CAMERA_PITCH_UP", GameMessage::MSG_META_END_CAMERA_PITCH_UP },
{ "ALT_BEGIN_CAMERA_PITCH_UP", GameMessage::MSG_META_ALT_BEGIN_CAMERA_PITCH_UP },
{ "ALT_END_CAMERA_PITCH_UP", GameMessage::MSG_META_ALT_END_CAMERA_PITCH_UP },
{ "BEGIN_CAMERA_PITCH_DOWN", GameMessage::MSG_META_BEGIN_CAMERA_PITCH_DOWN },
{ "END_CAMERA_PITCH_DOWN", GameMessage::MSG_META_END_CAMERA_PITCH_DOWN },
{ "ALT_BEGIN_CAMERA_PITCH_DOWN", GameMessage::MSG_META_ALT_BEGIN_CAMERA_PITCH_DOWN },
{ "ALT_END_CAMERA_PITCH_DOWN", GameMessage::MSG_META_ALT_END_CAMERA_PITCH_DOWN },
{ "CAMERA_RESET", GameMessage::MSG_META_CAMERA_RESET },
{ "CAMERA_PITCH_RESET", GameMessage::MSG_META_CAMERA_PITCH_RESET },
{ "ALT_CAMERA_PITCH_RESET", GameMessage::MSG_META_ALT_CAMERA_PITCH_RESET },
{ "TOGGLE_CAMERA_TRACKING_DRAWABLE", GameMessage::MSG_META_TOGGLE_CAMERA_TRACKING_DRAWABLE },
{ "TOGGLE_FAST_FORWARD_REPLAY", GameMessage::MSG_META_TOGGLE_FAST_FORWARD_REPLAY },
{ "TOGGLE_PAUSE", GameMessage::MSG_META_TOGGLE_PAUSE },
Expand Down Expand Up @@ -992,6 +1002,96 @@ void MetaMap::generateMetaMap()
map->m_usableIn = COMMANDUSABLE_GAME;
}
}
{
MetaMapRec *map = getMetaMapRec(GameMessage::MSG_META_BEGIN_CAMERA_PITCH_UP);
if (map->m_key == MK_NONE) {
map->m_key = MK_KP9;
map->m_transition = DOWN;
map->m_modState = NONE;
map->m_usableIn = COMMANDUSABLE_GAME;
}
}
{
MetaMapRec *map = getMetaMapRec(GameMessage::MSG_META_END_CAMERA_PITCH_UP);
if (map->m_key == MK_NONE) {
map->m_key = MK_KP9;
map->m_transition = UP;
map->m_modState = NONE;
map->m_usableIn = COMMANDUSABLE_GAME;
}
}
{
MetaMapRec *map = getMetaMapRec(GameMessage::MSG_META_ALT_BEGIN_CAMERA_PITCH_UP);
if (map->m_key == MK_NONE) {
map->m_key = MK_PGUP;
map->m_transition = DOWN;
map->m_modState = NONE;
map->m_usableIn = COMMANDUSABLE_GAME;
}
}
{
MetaMapRec *map = getMetaMapRec(GameMessage::MSG_META_ALT_END_CAMERA_PITCH_UP);
if (map->m_key == MK_NONE) {
map->m_key = MK_PGUP;
map->m_transition = UP;
map->m_modState = NONE;
map->m_usableIn = COMMANDUSABLE_GAME;
}
}
{
MetaMapRec *map = getMetaMapRec(GameMessage::MSG_META_BEGIN_CAMERA_PITCH_DOWN);
if (map->m_key == MK_NONE) {
map->m_key = MK_KP3;
map->m_transition = DOWN;
map->m_modState = NONE;
map->m_usableIn = COMMANDUSABLE_GAME;
}
}
{
MetaMapRec *map = getMetaMapRec(GameMessage::MSG_META_END_CAMERA_PITCH_DOWN);
if (map->m_key == MK_NONE) {
map->m_key = MK_KP3;
map->m_transition = UP;
map->m_modState = NONE;
map->m_usableIn = COMMANDUSABLE_GAME;
}
}
{
MetaMapRec *map = getMetaMapRec(GameMessage::MSG_META_ALT_BEGIN_CAMERA_PITCH_DOWN);
if (map->m_key == MK_NONE) {
map->m_key = MK_PGDN;
map->m_transition = DOWN;
map->m_modState = NONE;
map->m_usableIn = COMMANDUSABLE_GAME;
}
}
{
MetaMapRec *map = getMetaMapRec(GameMessage::MSG_META_ALT_END_CAMERA_PITCH_DOWN);
if (map->m_key == MK_NONE) {
map->m_key = MK_PGDN;
map->m_transition = UP;
map->m_modState = NONE;
map->m_usableIn = COMMANDUSABLE_GAME;
}
}
{
MetaMapRec *map = getMetaMapRec(GameMessage::MSG_META_CAMERA_PITCH_RESET);
if (map->m_key == MK_NONE) {
map->m_key = MK_KP7;
map->m_transition = DOWN;
map->m_modState = NONE;
map->m_usableIn = COMMANDUSABLE_GAME;
}
}
{
MetaMapRec *map = getMetaMapRec(GameMessage::MSG_META_ALT_CAMERA_PITCH_RESET);
if (map->m_key == MK_NONE) {
map->m_key = MK_HOME;
map->m_transition = DOWN;
map->m_modState = NONE;
map->m_usableIn = COMMANDUSABLE_GAME;
}
}
{
MetaMapRec *map = TheMetaMap->getMetaMapRec(GameMessage::MSG_META_TAKE_SCREENSHOT);
if (map->m_key == MK_NONE)
Expand Down
6 changes: 5 additions & 1 deletion Core/GameEngine/Source/GameClient/View.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "GameClient/Drawable.h"
#include "GameClient/GameClient.h"
#include "GameClient/View.h"
#include "GameLogic/GameLogic.h"

UnsignedInt View::m_idNext = 1;

Expand Down Expand Up @@ -166,7 +167,10 @@ void View::setAngle(Real radians)
void View::setPitch(Real radians)
{
#if CLAMP_VIEW_PITCH
m_pitch = clamp(DEG_TO_RADF(0.1f), radians, DEG_TO_RADF(89.9f));
// Raised floor in matches prevents flat-camera sightlines; relaxed in replays.
const Bool inReplay = TheGameLogic != nullptr && TheGameLogic->isInReplayGame();
const Real minPitchDegrees = inReplay ? 16.5f : 37.5f;
m_pitch = clamp(DEG_TO_RADF(minPitchDegrees), radians, DEG_TO_RADF(89.9f));
#else
m_pitch = WWMath::Normalize_Angle(radians);
#endif
Expand Down
2 changes: 2 additions & 0 deletions GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,8 @@ class GlobalData : public SubsystemInterface
UnsignedInt m_networkDisconnectScreenNotifyTime; ///< The number of milliseconds between when the disconnect screen comes up and when the other players are notified that we are on the disconnect screen.

Real m_keyboardCameraRotateSpeed; ///< How fast the camera rotates when rotated via keyboard controls.
Real m_cameraRotateSpeedMultiplier; ///< User scale for keyboard camera rotate speed, from Options.ini.
Real m_cameraPitchSpeedMultiplier; ///< User scale for keyboard camera pitch speed, from Options.ini.
Int m_playStats; ///< Int whether we want to log play stats or not, if <= 0 then we don't log

#if defined(RTS_DEBUG) || defined(_ALLOW_DEBUG_CHEATS_IN_RELEASE)
Expand Down
10 changes: 10 additions & 0 deletions GeneralsMD/Code/GameEngine/Include/Common/MessageStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,17 @@ class GameMessage : public MemoryPoolObject
MSG_META_END_CAMERA_ZOOM_IN,
MSG_META_BEGIN_CAMERA_ZOOM_OUT,
MSG_META_END_CAMERA_ZOOM_OUT,
MSG_META_BEGIN_CAMERA_PITCH_UP,
MSG_META_END_CAMERA_PITCH_UP,
MSG_META_ALT_BEGIN_CAMERA_PITCH_UP,
MSG_META_ALT_END_CAMERA_PITCH_UP,
MSG_META_BEGIN_CAMERA_PITCH_DOWN,
MSG_META_END_CAMERA_PITCH_DOWN,
MSG_META_ALT_BEGIN_CAMERA_PITCH_DOWN,
MSG_META_ALT_END_CAMERA_PITCH_DOWN,
MSG_META_CAMERA_RESET,
MSG_META_CAMERA_PITCH_RESET,
MSG_META_ALT_CAMERA_PITCH_RESET,
MSG_META_TOGGLE_CAMERA_TRACKING_DRAWABLE,
MSG_META_TOGGLE_FAST_FORWARD_REPLAY, ///< Toggle the fast forward feature
MSG_META_TOGGLE_PAUSE, ///< TheSuperHackers @feature Toggle game pause
Expand Down
6 changes: 6 additions & 0 deletions GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -564,11 +564,15 @@ class InGameUI : public SubsystemInterface, public Snapshot
void setCameraRotateRight(Bool set) { m_cameraRotatingRight = set; }
void setCameraZoomIn(Bool set) { m_cameraZoomingIn = set; }
void setCameraZoomOut(Bool set) { m_cameraZoomingOut = set; }
void setCameraPitchUp(Bool set) { m_cameraPitchingUp = set; }
void setCameraPitchDown(Bool set) { m_cameraPitchingDown = set; }
void setCameraTrackingDrawable(Bool set) { m_cameraTrackingDrawable = set; }
Bool isCameraRotatingLeft() const { return m_cameraRotatingLeft; }
Bool isCameraRotatingRight() const { return m_cameraRotatingRight; }
Bool isCameraZoomingIn() const { return m_cameraZoomingIn; }
Bool isCameraZoomingOut() const { return m_cameraZoomingOut; }
Bool isCameraPitchingUp() const { return m_cameraPitchingUp; }
Bool isCameraPitchingDown() const { return m_cameraPitchingDown; }
Bool isCameraTrackingDrawable() const { return m_cameraTrackingDrawable; }
void resetCamera();

Expand Down Expand Up @@ -1041,6 +1045,8 @@ class InGameUI : public SubsystemInterface, public Snapshot
Bool m_cameraZoomingIn;
Bool m_cameraTrackingDrawable;
Bool m_cameraZoomingOut;
Bool m_cameraPitchingUp;
Bool m_cameraPitchingDown;

Bool m_drawRMBScrollAnchor;
Bool m_moveRMBScrollAnchor;
Expand Down
4 changes: 4 additions & 0 deletions GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1064,6 +1064,8 @@ GlobalData::GlobalData()
m_forceBenchmark = FALSE; ///<forces running of CPU detection benchmark, even on known cpu's.

m_keyboardCameraRotateSpeed = 0.1f;
m_cameraRotateSpeedMultiplier = 1.0f;
m_cameraPitchSpeedMultiplier = 1.0f;

#if defined(USE_MAULLER_ONEDRIVE_FIX)
// Set user data directory based on registry settings instead of INI parameters.
Expand Down Expand Up @@ -1274,6 +1276,8 @@ void GlobalData::parseGameDataDefinition( INI* ini )
TheWritableGlobalData->m_playerInfoListFontSize = optionPref.getPlayerInfoListFontSize();
TheWritableGlobalData->m_showMoneyPerMinute = optionPref.getShowMoneyPerMinute();
TheWritableGlobalData->m_gameWindowTransitionSpeedMultiplier = optionPref.getGameWindowTransitionSpeedMultiplier();
TheWritableGlobalData->m_cameraRotateSpeedMultiplier = optionPref.getCameraRotateSpeedMultiplier();
TheWritableGlobalData->m_cameraPitchSpeedMultiplier = optionPref.getCameraPitchSpeedMultiplier();
TheWritableGlobalData->m_observerStatsFontSize = optionPref.getObserverStatsFontSize();
TheWritableGlobalData->m_observerNotificationFontSize = optionPref.getObserverNotificationFontSize();
TheWritableGlobalData->m_observerNotificationSpecialPowerUsage = optionPref.getObserverNotificationSpecialPowerUsage();
Expand Down
10 changes: 10 additions & 0 deletions GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,17 @@ const char *GameMessage::getCommandTypeAsString(GameMessage::Type t)
CASE_LABEL(MSG_META_END_CAMERA_ZOOM_IN)
CASE_LABEL(MSG_META_BEGIN_CAMERA_ZOOM_OUT)
CASE_LABEL(MSG_META_END_CAMERA_ZOOM_OUT)
CASE_LABEL(MSG_META_BEGIN_CAMERA_PITCH_UP)
CASE_LABEL(MSG_META_END_CAMERA_PITCH_UP)
CASE_LABEL(MSG_META_ALT_BEGIN_CAMERA_PITCH_UP)
CASE_LABEL(MSG_META_ALT_END_CAMERA_PITCH_UP)
CASE_LABEL(MSG_META_BEGIN_CAMERA_PITCH_DOWN)
CASE_LABEL(MSG_META_END_CAMERA_PITCH_DOWN)
CASE_LABEL(MSG_META_ALT_BEGIN_CAMERA_PITCH_DOWN)
CASE_LABEL(MSG_META_ALT_END_CAMERA_PITCH_DOWN)
CASE_LABEL(MSG_META_CAMERA_RESET)
CASE_LABEL(MSG_META_CAMERA_PITCH_RESET)
CASE_LABEL(MSG_META_ALT_CAMERA_PITCH_RESET)
CASE_LABEL(MSG_META_TOGGLE_CAMERA_TRACKING_DRAWABLE)
CASE_LABEL(MSG_META_TOGGLE_FAST_FORWARD_REPLAY)
CASE_LABEL(MSG_META_TOGGLE_PAUSE)
Expand Down
21 changes: 19 additions & 2 deletions GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2158,11 +2158,15 @@ void InGameUI::update()
layout->runUpdate();
}

if (m_cameraRotatingLeft || m_cameraRotatingRight || m_cameraZoomingIn || m_cameraZoomingOut)
if (m_cameraRotatingLeft || m_cameraRotatingRight || m_cameraZoomingIn || m_cameraZoomingOut
|| m_cameraPitchingUp || m_cameraPitchingDown)
{
// TheSuperHackers @tweak The camera rotation and zoom are now decoupled from the render update.
const Real fpsRatio = TheFramePacer->getBaseOverUpdateFpsRatio();
const Real rotateAngle = TheGlobalData->m_keyboardCameraRotateSpeed * fpsRatio;
// Pitch at half speed feels alike: shorter range, larger view change per degree.
const Real turnAngle = TheGlobalData->m_keyboardCameraRotateSpeed * 0.6f * fpsRatio;
const Real rotateAngle = turnAngle * TheGlobalData->m_cameraRotateSpeedMultiplier;
const Real pitchAngle = turnAngle * 0.5f * TheGlobalData->m_cameraPitchSpeedMultiplier;
const Real zoomHeight = (Real)View::ZoomHeightPerSecond * fpsRatio;

if (m_cameraRotatingLeft && !m_cameraRotatingRight)
Expand All @@ -2182,6 +2186,15 @@ void InGameUI::update()
{
TheTacticalView->userZoom(+zoomHeight);
}

if (m_cameraPitchingUp && !m_cameraPitchingDown)
{
TheTacticalView->userSetPitch(TheTacticalView->getPitch() + pitchAngle);
}
else if (m_cameraPitchingDown && !m_cameraPitchingUp)
{
TheTacticalView->userSetPitch(TheTacticalView->getPitch() - pitchAngle);
}
}


Expand Down Expand Up @@ -2298,6 +2311,8 @@ void InGameUI::reset()
setCameraRotateRight(false);
setCameraZoomIn(false);
setCameraZoomOut(false);
setCameraPitchUp(false);
setCameraPitchDown(false);
setCameraTrackingDrawable(false);

m_windowLayouts.clear();
Expand Down Expand Up @@ -3825,6 +3840,8 @@ void InGameUI::setInputEnabled(Bool enable)
setCameraRotateRight(false); // KP6
setCameraZoomIn(false); // KP8
setCameraZoomOut(false); // KP2
setCameraPitchUp(false); // KP9
setCameraPitchDown(false); // KP3
}
}

Expand Down
Loading