Skip to content

Conversation

@tophroxx
Copy link

@tophroxx tophroxx commented Jan 28, 2026

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 local helper functions 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 properly with display resolution by introducing resolution-aware scaling for animation constants.

Key Changes:

  • Added two static helper functions (scaleHorizontalConstant and scaleVerticalConstant) that scale pixel values based on the ratio between the current resolution and the default 800x600 resolution
  • Modified constructors for SlideFromRight, SlideFromLeft, SlideFromTop, and SlideFromBottom animation classes to initialize m_maxVel and m_slowDownThreshold to 0
  • Moved velocity and slowdown threshold initialization from constructors into initAnimateWindow methods, where they're now computed using the scaling functions
  • This ensures animations adapt properly when users change resolution at runtime

Technical Details:
The fix uses the pattern (constant / DEFAULT_RESOLUTION) * TheDisplay->getCurrentResolution() to scale hardcoded pixel constants (40 for velocity, 80 for slowdown threshold) proportionally to the display size. This maintains the same visual animation speed and smoothness across different resolutions that was originally designed for 800x600.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The implementation is straightforward and mathematically sound. The scaling logic follows established patterns used elsewhere in the codebase (e.g., GlobalLanguage.cpp, ControlBarResizer.cpp). The previous issue with incorrect horizontal/vertical constant usage has been resolved. Changes are minimal, focused, and maintain backward compatibility.
  • No files require special attention

Important Files Changed

Filename Overview
Generals/Code/GameEngine/Source/GameClient/GUI/ProcessAnimateWindow.cpp Added resolution scaling for window animation velocities and slowdown thresholds using helper functions
GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ProcessAnimateWindow.cpp Added resolution scaling for window animation velocities and slowdown thresholds using helper functions

Sequence Diagram

sequenceDiagram
    participant User
    participant AnimWin as AnimateWindow
    participant Processor as ProcessAnimateWindowSlide*
    participant Display as TheDisplay
    participant Window as GameWindow

    User->>AnimWin: Create animation
    AnimWin->>Processor: initAnimateWindow(animWin)
    Processor->>Display: getWidth()/getHeight()
    Display-->>Processor: Current resolution
    Processor->>Processor: scaleHorizontalConstant(40)
    Note over Processor: Scales: (40/800)*currentWidth
    Processor->>Processor: scaleVerticalConstant(80)
    Note over Processor: Scales: (80/600)*currentHeight
    Processor->>Processor: Set m_maxVel with scaled value
    Processor->>Processor: Set m_slowDownThreshold with scaled value
    Processor->>Window: winSetPosition(startPos)
    Processor->>AnimWin: setAnimData(...)
    
    loop Each frame
        AnimWin->>Processor: updateAnimateWindow(animWin)
        Processor->>Processor: Calculate new position
        Processor->>Window: winSetPosition(curPos)
        Note over Processor: Uses scaled velocity and threshold
        Processor-->>AnimWin: Animation status
    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

@xezon xezon added Bug Something is not working right, typically is user facing GUI For graphical user interface Minor Severity: Minor < Major < Critical < Blocker Gen Relates to Generals ZH Relates to Zero Hour labels Jan 29, 2026
@tophroxx
Copy link
Author

Done all requested changes and replicated the fix for vanilla Generals. Works there as well.

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

Labels

Bug Something is not working right, typically is user facing Gen Relates to Generals GUI For graphical user interface Minor Severity: Minor < Major < Critical < Blocker ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Diplomacy screen slow to open/close at high resolution

2 participants