forked from electronicarts/CnC_Generals_Zero_Hour
-
Notifications
You must be signed in to change notification settings - Fork 151
bugfix(ui): Fix window animations to scale with display resolution #2210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tophroxx
wants to merge
7
commits into
TheSuperHackers:main
Choose a base branch
from
tophroxx:use-scaled-pixel-constants-in-window-animations
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
14ebc3a
feat(display): Add scaled constant methods to Display
tophroxx 590536a
bugfix(ui): Use scaled constants instead of plain for window animations
tophroxx e6d01cc
fix(ui): use horizontal constants in horizontal animations instead of…
tophroxx ace4181
fix(ui): Move scaled constant methods from display into animation code
tophroxx 8ff4328
refactor(ui): Remove inline modifier for scaled constant functions
tophroxx 5599f77
chore(ui): Restore original comments in animation class constructors
tophroxx f62fe20
fix(ui): Replicate animation scaling fix to vanilla Generals, update …
tophroxx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,20 +68,26 @@ | |
| // PRIVATE FUNCTIONS ////////////////////////////////////////////////////////// | ||
| //----------------------------------------------------------------------------- | ||
|
|
||
| static UnsignedInt scaleHorizontalConstant(UnsignedInt x) { | ||
| return (static_cast<Real>(x) / DEFAULT_DISPLAY_WIDTH) * TheDisplay->getWidth(); | ||
| } | ||
|
|
||
| static UnsignedInt scaleVerticalConstant(UnsignedInt y) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps call these scaleByDisplayWidth ? Would be a bit more specific to what they do. Also how about not modify a value in the functions, but simply return the scaler value. So do This would be a tiny bit simpler to read. |
||
| return (static_cast<Real>(y) / DEFAULT_DISPLAY_HEIGHT) * TheDisplay->getHeight(); | ||
| } | ||
|
|
||
| //----------------------------------------------------------------------------- | ||
| // ProcessAnimateWindowSlideFromRight PUBLIC FUNCTIONS //////////////////////// | ||
| //----------------------------------------------------------------------------- | ||
|
|
||
| ProcessAnimateWindowSlideFromRight::ProcessAnimateWindowSlideFromRight( void ) | ||
| { | ||
| m_maxVel.x = -40.0f; // top speed windows travel in x and y | ||
| m_maxVel.x = 0.0f; // top speed windows travel in x and y | ||
| m_maxVel.y = 0.0f; | ||
| m_slowDownThreshold = 80; // when windows get this close to their resting | ||
| // positions they start to slow down | ||
| m_slowDownThreshold = 0; // when windows get this close to their resting positions they start to slow down | ||
|
|
||
| m_slowDownRatio = 0.67f; // how fast the windows slow down (smaller slows quicker) | ||
| m_speedUpRatio = 2.0f - m_slowDownRatio; // how fast the windows speed up | ||
|
|
||
| } | ||
|
|
||
| //----------------------------------------------------------------------------- | ||
|
|
@@ -141,6 +147,11 @@ void ProcessAnimateWindowSlideFromRight::initAnimateWindow( wnd::AnimateWindow * | |
| //set the window's position to the new start positions. | ||
| win->winSetPosition(startPos.x, startPos.y); | ||
|
|
||
| // TheSuperHackers @bugfix tophroxx 30/01/2026 Use scaled pixel constants | ||
| // for slowdown threshold and velocity. | ||
| m_maxVel.x = -static_cast<Real>(scaleHorizontalConstant(40)); | ||
| m_slowDownThreshold = scaleHorizontalConstant(80); | ||
|
|
||
| //Now initialize the velocities | ||
| vel.x = m_maxVel.x; | ||
| vel.y = 0.0f; | ||
|
|
@@ -261,13 +272,12 @@ Bool ProcessAnimateWindowSlideFromRight::reverseAnimateWindow( wnd::AnimateWindo | |
|
|
||
| ProcessAnimateWindowSlideFromLeft::ProcessAnimateWindowSlideFromLeft( void ) | ||
| { | ||
| m_maxVel.x = 40.0f; // top speed windows travel in x and y | ||
| m_maxVel.x = 0.0f; // top speed windows travel in x and y | ||
| m_maxVel.y = 0.0f; | ||
| m_slowDownThreshold = 80; // when windows get this close to their resting | ||
| // positions they start to slow down | ||
| m_slowDownThreshold = 0; // when windows get this close to their resting positions they start to slow down | ||
|
|
||
| m_slowDownRatio = 0.67f; // how fast the windows slow down (smaller slows quicker) | ||
| m_speedUpRatio = 2.0f - m_slowDownRatio; // how fast the windows speed up | ||
|
|
||
| } | ||
|
|
||
| ProcessAnimateWindowSlideFromLeft::~ProcessAnimateWindowSlideFromLeft( void ) { } | ||
|
|
@@ -322,6 +332,11 @@ void ProcessAnimateWindowSlideFromLeft::initAnimateWindow( wnd::AnimateWindow *a | |
| //set the window's position to the new start positions. | ||
| win->winSetPosition(startPos.x, startPos.y); | ||
|
|
||
| // TheSuperHackers @bugfix tophroxx 30/01/2026 Use scaled pixel constants | ||
| // for slowdown threshold and velocity. | ||
| m_maxVel.x = static_cast<Real>(scaleHorizontalConstant(40)); | ||
| m_slowDownThreshold = scaleHorizontalConstant(80); | ||
|
|
||
| //Now initialize the velocities | ||
| vel = m_maxVel; | ||
|
|
||
|
|
@@ -439,13 +454,12 @@ Bool ProcessAnimateWindowSlideFromLeft::reverseAnimateWindow( wnd::AnimateWindow | |
|
|
||
| ProcessAnimateWindowSlideFromTop::ProcessAnimateWindowSlideFromTop( void ) | ||
| { | ||
| m_maxVel.y = 40.0f; // top speed windows travel in x and y | ||
| m_maxVel.x = 0.0f; | ||
| m_slowDownThreshold = 80; // when windows get this close to their resting | ||
| // positions they start to slow down | ||
| m_maxVel.x = 0.0f; // top speed windows travel in x and y | ||
| m_maxVel.y = 0.0f; | ||
| m_slowDownThreshold = 0; // when windows get this close to their resting positions they start to slow down | ||
|
|
||
| m_slowDownRatio = 0.67f; // how fast the windows slow down (smaller slows quicker) | ||
| m_speedUpRatio = 2.0f - m_slowDownRatio; // how fast the windows speed up | ||
|
|
||
| } | ||
|
|
||
| ProcessAnimateWindowSlideFromTop::~ProcessAnimateWindowSlideFromTop( void ) { } | ||
|
|
@@ -500,6 +514,11 @@ void ProcessAnimateWindowSlideFromTop::initAnimateWindow( wnd::AnimateWindow *an | |
| //set the window's position to the new start positions. | ||
| win->winSetPosition(startPos.x, startPos.y); | ||
|
|
||
| // TheSuperHackers @bugfix tophroxx 30/01/2026 Use scaled pixel constants | ||
| // for slowdown threshold and velocity. | ||
| m_maxVel.y = static_cast<Real>(scaleVerticalConstant(40)); | ||
| m_slowDownThreshold = scaleVerticalConstant(80); | ||
|
|
||
| //Now initialize the velocities | ||
| vel = m_maxVel; | ||
|
|
||
|
|
@@ -618,13 +637,12 @@ Bool ProcessAnimateWindowSlideFromTop::reverseAnimateWindow( wnd::AnimateWindow | |
|
|
||
| ProcessAnimateWindowSlideFromBottom::ProcessAnimateWindowSlideFromBottom( void ) | ||
| { | ||
| m_maxVel.y = -40.0f; // top speed windows travel in x and y | ||
| m_maxVel.x = 0.0f; | ||
| m_slowDownThreshold = 80; // when windows get this close to their resting | ||
| // positions they start to slow down | ||
| m_maxVel.x = 0.0f; // top speed windows travel in x and y | ||
| m_maxVel.y = 0.0f; | ||
| m_slowDownThreshold = 0; // when windows get this close to their resting positions they start to slow down | ||
|
|
||
| m_slowDownRatio = 0.67f; // how fast the windows slow down (smaller slows quicker) | ||
| m_speedUpRatio = 2.0f - m_slowDownRatio; // how fast the windows speed up | ||
|
|
||
| } | ||
|
|
||
| ProcessAnimateWindowSlideFromBottom::~ProcessAnimateWindowSlideFromBottom( void ) { } | ||
|
|
@@ -680,6 +698,11 @@ void ProcessAnimateWindowSlideFromBottom::initAnimateWindow( wnd::AnimateWindow | |
| //set the window's position to the new start positions. | ||
| win->winSetPosition(startPos.x, startPos.y); | ||
|
|
||
| // TheSuperHackers @bugfix tophroxx 30/01/2026 Use scaled pixel constants | ||
| // for slowdown threshold and velocity. | ||
| m_maxVel.y = -static_cast<Real>(scaleVerticalConstant(40)); | ||
| m_slowDownThreshold = scaleVerticalConstant(80); | ||
|
|
||
| //Now initialize the velocities | ||
| vel = m_maxVel; | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor style: Use