Skip to content

feat(ui): add resolution-aware scaling to main menu layout #23

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
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Alexbeav
Copy link

@Alexbeav Alexbeav commented Apr 4, 2025

Implemented dynamic scaling logic in MainMenu::render() to make the main menu UI adapt to various screen resolutions. Scaling factors are now calculated based on a 1024x768 baseline, with optional caps for layout and font scaling. This improves usability at 1080p, 1440p, and 4K without breaking existing layout behavior.

Alexbeav added 2 commits April 5, 2025 00:42
Implemented dynamic scaling logic in MainMenu::render() to make the main menu UI adapt to various screen resolutions. 
Scaling factors are now calculated based on a 1024x768 baseline, with optional caps for layout and font scaling. 
This improves usability at 1080p, 1440p, and 4K without breaking existing layout behavior.
- Manually center and scale copyright text based on resolution
- Prevent duplicate rendering by disabling default GUI window draw
- Ensures proper alignment at all resolutions, including 4K
@@ -770,8 +776,13 @@ void MainMenu::render()
}
}

GUI_RECT rect = { 0, 0, Environment.screenWidth, Environment.screenHeight };
drawRect( rect, color );
GUI_RECT rect = {
Copy link
Owner

Choose a reason for hiding this comment

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

there is no need to modify it:
1024 * scaleX = 1024 * (Environment.screenWidth / 1024.0f) = Environment.screenWidth
(same for height)

@@ -26,6 +26,7 @@ struct DDSURFACEDESC2 {
#include"gamesound.h"
#include"aanimobject.h"
#include"multplyr.h"
#include <algorithm>
Copy link
Owner

Choose a reason for hiding this comment

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

let's not add dependency for something which can just be a one ternary operator

@@ -716,6 +717,11 @@ void MainMenu::update()
void MainMenu::render()
{

// Calculate scale factors relative to 1024x768 base resolution
float scaleX = Environment.screenWidth / 1024.0f;
Copy link
Owner

Choose a reason for hiding this comment

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

this can be moved closer to drawShadowText

@Alexbeav
Copy link
Author

Thank you for your feedback! I'm not an experienced coder and I'm trying to help out however I can. I'll apply your suggestions and reupload!

Copy link
Author

@Alexbeav Alexbeav left a comment

Choose a reason for hiding this comment

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

I agree with your proposed changes. Do you want to conclude the review and merge this PR?

Cheers!

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.

2 participants