Skip to content

Conversation

@tophroxx
Copy link

This fixes window animation speeds and smoothing on different display resolutions. Closes #2130

I've made a quick video showcasing new behavior and retail behavior side-by-side. Unfortunately it was too big for GitHub, so i uploaded it to YouTube.

https://youtu.be/wDQdis7Z1L4

Pay attention to how fast the control bar slides from the bottom when i'm loading into a match, and also how fast the diplomacy screen slides from the top.

This PR adds 2 new methods to the Display class and changes 4 children of the ProcessAnimateWindow class - SlideFromLeft, SlideFromRight, SlideFromTop and SlideFromBottom, making them benefit from these new methods.
It also moves velocity and slowdown threshold initialization from the constructor into initAnimateWindow, which means that these values will scale properly even if user changes their resolution in runtime.
I've made little changes to minimize the possibility of new issues appearing while still fixing the issue.

@greptile-apps
Copy link

greptile-apps bot commented Jan 28, 2026

Greptile Overview

Greptile Summary

This PR fixes window animation speeds to scale correctly with display resolution by introducing two new scaling methods to the Display class and refactoring four animation classes to use them. The changes move velocity and slowdown threshold initialization from constructors into initAnimateWindow methods, ensuring values scale dynamically based on current resolution. This allows animations to maintain consistent visual speed whether running at 800x600 or higher resolutions like 1920x1080.

Key Changes:

  • Added scaleHorizontalConstant() and scaleVerticalConstant() methods to Display class that scale pixel values proportionally to current resolution vs default 800x600
  • Modified ProcessAnimateWindowSlideFromRight, SlideFromLeft, SlideFromTop, and SlideFromBottom classes to initialize scaled velocities and thresholds in initAnimateWindow instead of constructors
  • Fixed horizontal animations to use scaleHorizontalConstant instead of incorrectly using scaleVerticalConstant (corrected in follow-up commit)

The implementation is minimal and focused, addressing runtime resolution changes correctly since initAnimateWindow is called each time an animation starts.

Confidence Score: 5/5

  • This PR is safe to merge with no issues found
  • The implementation is sound with proper resolution scaling math, minimal scope changes, and the horizontal/vertical constant bug was already fixed in a follow-up commit within the PR
  • No files require special attention

Important Files Changed

Filename Overview
GeneralsMD/Code/GameEngine/Include/GameClient/Display.h Added two scaling methods to scale pixel constants based on current display resolution relative to default 800x600
GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ProcessAnimateWindow.cpp Moved velocity and threshold initialization from constructors to initAnimateWindow methods, applying resolution scaling for proper animation speeds across different resolutions

Sequence Diagram

sequenceDiagram
    participant AM as AnimateWindowManager
    participant PA as ProcessAnimateWindow
    participant D as Display
    participant W as GameWindow
    
    Note over AM,W: Animation Initialization
    AM->>PA: initAnimateWindow(animWin)
    PA->>W: winGetPosition(&x, &y)
    W-->>PA: rest position
    
    Note over PA,D: Resolution Scaling (NEW)
    PA->>D: scaleHorizontalConstant(40)
    D-->>PA: scaled velocity value
    PA->>D: scaleHorizontalConstant(80)
    D-->>PA: scaled threshold value
    
    Note over PA: Set m_maxVel with scaled values
    Note over PA: Set m_slowDownThreshold with scaled values
    
    PA->>W: winSetPosition(startX, startY)
    
    Note over AM,W: Animation Update Loop
    loop Each Frame
        AM->>PA: updateAnimateWindow(animWin)
        PA->>PA: Calculate new position with velocity
        PA->>PA: Check distance to end position
        alt Within slowdown threshold
            PA->>PA: Apply slowdown (vel *= m_slowDownRatio)
        end
        PA->>W: winSetPosition(curX, curY)
        PA-->>AM: Animation continue/finished
    end
Loading

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Diplomacy screen slow to open/close at high resolution

1 participant