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
4 changes: 4 additions & 0 deletions Generals/Code/GameEngine/Include/Common/UserPreferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "Common/STLTypedefs.h"

enum CursorCaptureMode CPP_11(: Int);
typedef UnsignedInt ScreenEdgeScrollMode;

//-----------------------------------------------------------------------------
// PUBLIC TYPES ///////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -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
Expand Down
25 changes: 21 additions & 4 deletions Generals/Code/GameEngine/Include/GameClient/LookAtXlat.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -50,7 +64,7 @@ class LookAtTranslator : public GameMessageTranslator
{
MAX_VIEW_LOCS = 8
};
enum
enum ScrollType
{
SCROLL_NONE = 0,
SCROLL_RMB,
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand All @@ -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();
}
Expand All @@ -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),
Expand All @@ -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;
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
{
Expand Down
4 changes: 4 additions & 0 deletions GeneralsMD/Code/GameEngine/Include/Common/UserPreferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

class Money;
enum CursorCaptureMode CPP_11(: Int);
typedef UnsignedInt ScreenEdgeScrollMode;

//-----------------------------------------------------------------------------
// PUBLIC TYPES ///////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -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
Expand Down
25 changes: 21 additions & 4 deletions GeneralsMD/Code/GameEngine/Include/GameClient/LookAtXlat.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -50,7 +64,7 @@ class LookAtTranslator : public GameMessageTranslator
{
MAX_VIEW_LOCS = 8
};
enum
enum ScrollType
{
SCROLL_NONE = 0,
SCROLL_RMB,
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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);
Expand Down
Loading
Loading