diff --git a/Generals/Code/GameEngine/Include/Common/UserPreferences.h b/Generals/Code/GameEngine/Include/Common/UserPreferences.h index 22c6cdbc35..35393244ba 100644 --- a/Generals/Code/GameEngine/Include/Common/UserPreferences.h +++ b/Generals/Code/GameEngine/Include/Common/UserPreferences.h @@ -39,6 +39,7 @@ #include "Common/STLTypedefs.h" enum CursorCaptureMode CPP_11(: Int); +typedef UnsignedInt ScreenEdgeScrollMode; //----------------------------------------------------------------------------- // PUBLIC TYPES /////////////////////////////////////////////////////////////// @@ -95,6 +96,9 @@ class OptionPreferences : public UserPreferences Bool getDrawScrollAnchor(void); Bool getMoveScrollAnchor(void); CursorCaptureMode getCursorCaptureMode() const; + Bool getScreenEdgeScrollEnabledInWindowedApp() const; + Bool getScreenEdgeScrollEnabledInFullscreenApp() const; + ScreenEdgeScrollMode getScreenEdgeScrollMode() const; Bool getSendDelay(void); // convenience function Int getFirewallBehavior(void); // convenience function Short getFirewallPortAllocationDelta(void); // convenience function diff --git a/Generals/Code/GameEngine/Include/GameClient/LookAtXlat.h b/Generals/Code/GameEngine/Include/GameClient/LookAtXlat.h index 4b4ec7fd64..6cafbab541 100644 --- a/Generals/Code/GameEngine/Include/GameClient/LookAtXlat.h +++ b/Generals/Code/GameEngine/Include/GameClient/LookAtXlat.h @@ -32,16 +32,30 @@ #include "GameClient/InGameUI.h" +//----------------------------------------------------------------------------- +// TheSuperHackers @feature The Screen Edge Scrolling can now be enabled or +// disabled depending on the App being Windowed or Fullscreen. +typedef UnsignedInt ScreenEdgeScrollMode; +enum ScreenEdgeScrollMode_ CPP_11(: ScreenEdgeScrollMode) +{ + ScreenEdgeScrollMode_EnabledInWindowedApp = 1<<0, // Scroll when touching the edge while the app is windowed + ScreenEdgeScrollMode_EnabledInFullscreenApp = 1<<1, // Scroll when touching the edge while the app is fullscreen + + ScreenEdgeScrollMode_Default = ScreenEdgeScrollMode_EnabledInFullscreenApp, // Default based on original game behavior +}; + //----------------------------------------------------------------------------- class LookAtTranslator : public GameMessageTranslator { public: LookAtTranslator(); ~LookAtTranslator(); + virtual GameMessageDisposition translateGameMessage(const GameMessage *msg); virtual const ICoord2D* getRMBScrollAnchor(void); // get m_anchor ICoord2D if we're RMB scrolling Bool hasMouseMovedRecently( void ); void setCurrentPos( const ICoord2D& pos ); + void setScreenEdgeScrollMode(ScreenEdgeScrollMode mode); void resetModes(); //Used when disabling input, so when we reenable it we aren't stuck in a mode. @@ -50,7 +64,7 @@ class LookAtTranslator : public GameMessageTranslator { MAX_VIEW_LOCS = 8 }; - enum + enum ScrollType { SCROLL_NONE = 0, SCROLL_RMB, @@ -67,10 +81,13 @@ class LookAtTranslator : public GameMessageTranslator UnsignedInt m_timestamp; // set when button goes down DrawableID m_lastPlaneID; ViewLocation m_viewLocation[ MAX_VIEW_LOCS ]; - Int m_scrollType; - void setScrolling( Int ); - void stopScrolling( void ); + ScrollType m_scrollType; + ScreenEdgeScrollMode m_screenEdgeScrollMode; UnsignedInt m_lastMouseMoveFrame; + + void setScrolling( ScrollType scrollType ); + void stopScrolling( void ); + Bool canScrollAtScreenEdge() const; }; extern LookAtTranslator *TheLookAtTranslator; diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp index b6d74b6f24..c46a4967ad 100644 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp @@ -44,6 +44,7 @@ #include "GameClient/ClientInstance.h" #include "GameClient/GameClient.h" #include "GameClient/InGameUI.h" +#include "GameClient/LookAtXlat.h" #include "GameClient/WindowLayout.h" #include "GameClient/Gadget.h" #include "GameClient/GadgetCheckBox.h" @@ -390,6 +391,38 @@ CursorCaptureMode OptionPreferences::getCursorCaptureMode() const return mode; } +Bool OptionPreferences::getScreenEdgeScrollEnabledInWindowedApp() const +{ + OptionPreferences::const_iterator it = find("ScreenEdgeScrollEnabledInWindowedApp"); + if (it == end()) + return (ScreenEdgeScrollMode_Default & ScreenEdgeScrollMode_EnabledInWindowedApp) != 0; + + if (stricmp(it->second.str(), "yes") == 0) + return TRUE; + + return FALSE; +} + +Bool OptionPreferences::getScreenEdgeScrollEnabledInFullscreenApp() const +{ + OptionPreferences::const_iterator it = find("ScreenEdgeScrollEnabledInFullscreenApp"); + if (it == end()) + return (ScreenEdgeScrollMode_Default & ScreenEdgeScrollMode_EnabledInFullscreenApp) != 0; + + if (stricmp(it->second.str(), "yes") == 0) + return TRUE; + + return FALSE; +} + +ScreenEdgeScrollMode OptionPreferences::getScreenEdgeScrollMode() const +{ + ScreenEdgeScrollMode mode = 0; + mode |= getScreenEdgeScrollEnabledInWindowedApp() ? ScreenEdgeScrollMode_EnabledInWindowedApp : 0; + mode |= getScreenEdgeScrollEnabledInFullscreenApp() ? ScreenEdgeScrollMode_EnabledInFullscreenApp : 0; + return mode; +} + Bool OptionPreferences::usesSystemMapDir(void) { OptionPreferences::const_iterator it = find("UseSystemMapDir"); @@ -1191,6 +1224,14 @@ static void saveOptions( void ) TheMouse->setCursorCaptureMode(mode); } + // TheSuperHackers @todo Add combo box ? + { + ScreenEdgeScrollMode mode = pref->getScreenEdgeScrollMode(); + (*pref)["ScreenEdgeScrollEnabledInWindowedApp"] = (mode & ScreenEdgeScrollMode_EnabledInWindowedApp) ? "yes" : "no"; + (*pref)["ScreenEdgeScrollEnabledInFullscreenApp"] = (mode & ScreenEdgeScrollMode_EnabledInFullscreenApp) ? "yes" : "no"; + TheLookAtTranslator->setScreenEdgeScrollMode(mode); + } + //------------------------------------------------------------------------------------------------- // scroll speed val val = GadgetSliderGetPosition(sliderScrollSpeed); diff --git a/Generals/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp b/Generals/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp index 6a7235583f..d2e09ed435 100644 --- a/Generals/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp @@ -35,6 +35,7 @@ #include "Common/PlayerList.h" #include "Common/Recorder.h" #include "Common/StatsCollector.h" +#include "Common/UserPreferences.h" #include "GameLogic/Object.h" #include "GameLogic/PartitionManager.h" #include "GameClient/Display.h" @@ -80,7 +81,7 @@ static const Int edgeScrollSize = 3; static Mouse::MouseCursor prevCursor = Mouse::ARROW; //----------------------------------------------------------------------------- -void LookAtTranslator::setScrolling(Int x) +void LookAtTranslator::setScrolling(ScrollType scrollType) { if (!TheInGameUI->getInputEnabled()) return; @@ -89,7 +90,7 @@ void LookAtTranslator::setScrolling(Int x) m_isScrolling = true; TheInGameUI->setScrolling( TRUE ); TheTacticalView->setMouseLock( TRUE ); - m_scrollType = x; + m_scrollType = scrollType; if(TheStatsCollector) TheStatsCollector->startScrollTime(); } @@ -103,12 +104,32 @@ void LookAtTranslator::stopScrolling( void ) TheMouse->setCursor(prevCursor); m_scrollType = SCROLL_NONE; - // if we have a stats collectore increment the stats + // increment the stats if we have a stats collector if(TheStatsCollector) TheStatsCollector->endScrollTime(); } +//----------------------------------------------------------------------------- +Bool LookAtTranslator::canScrollAtScreenEdge() const +{ + if (!TheMouse->isCursorCaptured()) + return false; + + if (TheDisplay->getWindowed()) + { + if ((m_screenEdgeScrollMode & ScreenEdgeScrollMode_EnabledInWindowedApp) == 0) + return false; + } + else + { + if ((m_screenEdgeScrollMode & ScreenEdgeScrollMode_EnabledInFullscreenApp) == 0) + return false; + } + + return true; +} + //----------------------------------------------------------------------------- LookAtTranslator::LookAtTranslator() : m_isScrolling(false), @@ -121,12 +142,15 @@ LookAtTranslator::LookAtTranslator() : m_scrollType(SCROLL_NONE) { //Added By Sadullah Nader - //Initializations misssing and needed + //Initializations missing and needed m_anchor.x = m_anchor.y = 0; m_currentPos.x = m_currentPos.y = 0; m_originalAnchor.x = m_originalAnchor.y = 0; // + OptionPreferences prefs; + m_screenEdgeScrollMode = prefs.getScreenEdgeScrollMode(); + DEBUG_ASSERTCRASH(!TheLookAtTranslator, ("Already have a LookAtTranslator - why do you need two?")); TheLookAtTranslator = this; } @@ -163,6 +187,11 @@ void LookAtTranslator::setCurrentPos( const ICoord2D& pos ) m_currentPos = pos; } +void LookAtTranslator::setScreenEdgeScrollMode(ScreenEdgeScrollMode mode) +{ + m_screenEdgeScrollMode = mode; +} + //----------------------------------------------------------------------------- /** * The LookAt Translator is responsible for camera movements. It is directly responsible for @@ -308,8 +337,7 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessage break; } - // TheSuperHackers @tweak Ayumi/xezon 26/07/2025 Enables edge scrolling in windowed mode. - if (TheMouse->isCursorCaptured()) + if (canScrollAtScreenEdge()) { if (m_isScrolling) { diff --git a/GeneralsMD/Code/GameEngine/Include/Common/UserPreferences.h b/GeneralsMD/Code/GameEngine/Include/Common/UserPreferences.h index ac2c7e8cba..7003107e15 100644 --- a/GeneralsMD/Code/GameEngine/Include/Common/UserPreferences.h +++ b/GeneralsMD/Code/GameEngine/Include/Common/UserPreferences.h @@ -40,6 +40,7 @@ class Money; enum CursorCaptureMode CPP_11(: Int); +typedef UnsignedInt ScreenEdgeScrollMode; //----------------------------------------------------------------------------- // PUBLIC TYPES /////////////////////////////////////////////////////////////// @@ -98,6 +99,9 @@ class OptionPreferences : public UserPreferences Bool getDrawScrollAnchor(void); Bool getMoveScrollAnchor(void); CursorCaptureMode getCursorCaptureMode() const; + Bool getScreenEdgeScrollEnabledInWindowedApp() const; + Bool getScreenEdgeScrollEnabledInFullscreenApp() const; + ScreenEdgeScrollMode getScreenEdgeScrollMode() const; Bool getSendDelay(void); // convenience function Int getFirewallBehavior(void); // convenience function Short getFirewallPortAllocationDelta(void); // convenience function diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/LookAtXlat.h b/GeneralsMD/Code/GameEngine/Include/GameClient/LookAtXlat.h index d23c58aa8e..6f9611154f 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameClient/LookAtXlat.h +++ b/GeneralsMD/Code/GameEngine/Include/GameClient/LookAtXlat.h @@ -32,16 +32,30 @@ #include "GameClient/InGameUI.h" +//----------------------------------------------------------------------------- +// TheSuperHackers @feature The Screen Edge Scrolling can now be enabled or +// disabled depending on the App being Windowed or Fullscreen. +typedef UnsignedInt ScreenEdgeScrollMode; +enum ScreenEdgeScrollMode_ CPP_11(: ScreenEdgeScrollMode) +{ + ScreenEdgeScrollMode_EnabledInWindowedApp = 1<<0, // Scroll when touching the edge while the app is windowed + ScreenEdgeScrollMode_EnabledInFullscreenApp = 1<<1, // Scroll when touching the edge while the app is fullscreen + + ScreenEdgeScrollMode_Default = ScreenEdgeScrollMode_EnabledInFullscreenApp, // Default based on original game behavior +}; + //----------------------------------------------------------------------------- class LookAtTranslator : public GameMessageTranslator { public: LookAtTranslator(); ~LookAtTranslator(); + virtual GameMessageDisposition translateGameMessage(const GameMessage *msg); virtual const ICoord2D* getRMBScrollAnchor(void); // get m_anchor ICoord2D if we're RMB scrolling Bool hasMouseMovedRecently( void ); void setCurrentPos( const ICoord2D& pos ); + void setScreenEdgeScrollMode(ScreenEdgeScrollMode mode); void resetModes(); //Used when disabling input, so when we reenable it we aren't stuck in a mode. @@ -50,7 +64,7 @@ class LookAtTranslator : public GameMessageTranslator { MAX_VIEW_LOCS = 8 }; - enum + enum ScrollType { SCROLL_NONE = 0, SCROLL_RMB, @@ -67,10 +81,13 @@ class LookAtTranslator : public GameMessageTranslator UnsignedInt m_timestamp; // set when button goes down DrawableID m_lastPlaneID; ViewLocation m_viewLocation[ MAX_VIEW_LOCS ]; - Int m_scrollType; - void setScrolling( Int ); - void stopScrolling( void ); + ScrollType m_scrollType; + ScreenEdgeScrollMode m_screenEdgeScrollMode; UnsignedInt m_lastMouseMoveFrame; + + void setScrolling( ScrollType scrollType ); + void stopScrolling( void ); + Bool canScrollAtScreenEdge() const; }; extern LookAtTranslator *TheLookAtTranslator; diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp index b671e5c5fe..f7e96138bc 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp @@ -44,6 +44,7 @@ #include "GameClient/ClientInstance.h" #include "GameClient/GameClient.h" #include "GameClient/InGameUI.h" +#include "GameClient/LookAtXlat.h" #include "GameClient/WindowLayout.h" #include "GameClient/Gadget.h" #include "GameClient/GadgetCheckBox.h" @@ -422,6 +423,38 @@ CursorCaptureMode OptionPreferences::getCursorCaptureMode() const return mode; } +Bool OptionPreferences::getScreenEdgeScrollEnabledInWindowedApp() const +{ + OptionPreferences::const_iterator it = find("ScreenEdgeScrollEnabledInWindowedApp"); + if (it == end()) + return (ScreenEdgeScrollMode_Default & ScreenEdgeScrollMode_EnabledInWindowedApp) != 0; + + if (stricmp(it->second.str(), "yes") == 0) + return TRUE; + + return FALSE; +} + +Bool OptionPreferences::getScreenEdgeScrollEnabledInFullscreenApp() const +{ + OptionPreferences::const_iterator it = find("ScreenEdgeScrollEnabledInFullscreenApp"); + if (it == end()) + return (ScreenEdgeScrollMode_Default & ScreenEdgeScrollMode_EnabledInFullscreenApp) != 0; + + if (stricmp(it->second.str(), "yes") == 0) + return TRUE; + + return FALSE; +} + +ScreenEdgeScrollMode OptionPreferences::getScreenEdgeScrollMode() const +{ + ScreenEdgeScrollMode mode = 0; + mode |= getScreenEdgeScrollEnabledInWindowedApp() ? ScreenEdgeScrollMode_EnabledInWindowedApp : 0; + mode |= getScreenEdgeScrollEnabledInFullscreenApp() ? ScreenEdgeScrollMode_EnabledInFullscreenApp : 0; + return mode; +} + Bool OptionPreferences::usesSystemMapDir(void) { OptionPreferences::const_iterator it = find("UseSystemMapDir"); @@ -1251,6 +1284,14 @@ static void saveOptions( void ) TheMouse->setCursorCaptureMode(mode); } + // TheSuperHackers @todo Add combo box ? + { + ScreenEdgeScrollMode mode = pref->getScreenEdgeScrollMode(); + (*pref)["ScreenEdgeScrollEnabledInWindowedApp"] = (mode & ScreenEdgeScrollMode_EnabledInWindowedApp) ? "yes" : "no"; + (*pref)["ScreenEdgeScrollEnabledInFullscreenApp"] = (mode & ScreenEdgeScrollMode_EnabledInFullscreenApp) ? "yes" : "no"; + TheLookAtTranslator->setScreenEdgeScrollMode(mode); + } + //------------------------------------------------------------------------------------------------- // scroll speed val val = GadgetSliderGetPosition(sliderScrollSpeed); diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp index 762d617e91..c106cdddf8 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp @@ -35,6 +35,7 @@ #include "Common/PlayerList.h" #include "Common/Recorder.h" #include "Common/StatsCollector.h" +#include "Common/UserPreferences.h" #include "GameLogic/Object.h" #include "GameLogic/PartitionManager.h" #include "GameClient/Display.h" @@ -80,7 +81,7 @@ static const Int edgeScrollSize = 3; static Mouse::MouseCursor prevCursor = Mouse::ARROW; //----------------------------------------------------------------------------- -void LookAtTranslator::setScrolling(Int x) +void LookAtTranslator::setScrolling(ScrollType scrollType) { if (!TheInGameUI->getInputEnabled()) return; @@ -89,7 +90,7 @@ void LookAtTranslator::setScrolling(Int x) m_isScrolling = true; TheInGameUI->setScrolling( TRUE ); TheTacticalView->setMouseLock( TRUE ); - m_scrollType = x; + m_scrollType = scrollType; if(TheStatsCollector) TheStatsCollector->startScrollTime(); } @@ -103,12 +104,32 @@ void LookAtTranslator::stopScrolling( void ) TheMouse->setCursor(prevCursor); m_scrollType = SCROLL_NONE; - // if we have a stats collectore increment the stats + // increment the stats if we have a stats collector if(TheStatsCollector) TheStatsCollector->endScrollTime(); } +//----------------------------------------------------------------------------- +Bool LookAtTranslator::canScrollAtScreenEdge() const +{ + if (!TheMouse->isCursorCaptured()) + return false; + + if (TheDisplay->getWindowed()) + { + if ((m_screenEdgeScrollMode & ScreenEdgeScrollMode_EnabledInWindowedApp) == 0) + return false; + } + else + { + if ((m_screenEdgeScrollMode & ScreenEdgeScrollMode_EnabledInFullscreenApp) == 0) + return false; + } + + return true; +} + //----------------------------------------------------------------------------- LookAtTranslator::LookAtTranslator() : m_isScrolling(false), @@ -121,12 +142,15 @@ LookAtTranslator::LookAtTranslator() : m_scrollType(SCROLL_NONE) { //Added By Sadullah Nader - //Initializations misssing and needed + //Initializations missing and needed m_anchor.x = m_anchor.y = 0; m_currentPos.x = m_currentPos.y = 0; m_originalAnchor.x = m_originalAnchor.y = 0; // + OptionPreferences prefs; + m_screenEdgeScrollMode = prefs.getScreenEdgeScrollMode(); + DEBUG_ASSERTCRASH(!TheLookAtTranslator, ("Already have a LookAtTranslator - why do you need two?")); TheLookAtTranslator = this; } @@ -163,6 +187,11 @@ void LookAtTranslator::setCurrentPos( const ICoord2D& pos ) m_currentPos = pos; } +void LookAtTranslator::setScreenEdgeScrollMode(ScreenEdgeScrollMode mode) +{ + m_screenEdgeScrollMode = mode; +} + //----------------------------------------------------------------------------- /** * The LookAt Translator is responsible for camera movements. It is directly responsible for @@ -307,8 +336,7 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessage break; } - // TheSuperHackers @tweak Ayumi/xezon 26/07/2025 Enables edge scrolling in windowed mode. - if (TheMouse->isCursorCaptured()) + if (canScrollAtScreenEdge()) { if (m_isScrolling) {