Fixed title screen FPS cap not being applied correctly when background FPS is set to unlimited

This commit is contained in:
Ben Wallis 2022-06-19 14:01:47 +01:00
parent 479affe127
commit be02e3ced0
2 changed files with 16 additions and 7 deletions

View File

@ -56,6 +56,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed an error where '{amount} Exp' floater did not use existing localizations - Fixed an error where '{amount} Exp' floater did not use existing localizations
- Fix villagers seeing cultists and familiar enemies through objects. - Fix villagers seeing cultists and familiar enemies through objects.
- Menacing agents are now less spammy with their menacing messages - Menacing agents are now less spammy with their menacing messages
- Fixed the title screen FPS cap not applying when the background FPS limit was set higher than 60 FPS
## [0.12.0] - 2022-02-19 ## [0.12.0] - 2022-02-19

View File

@ -238,14 +238,22 @@ fn handle_main_events_cleared(
// running at hundreds/thousands of FPS resulting in high GPU usage for // running at hundreds/thousands of FPS resulting in high GPU usage for
// effectively doing nothing. // effectively doing nothing.
let max_fps = get_fps(global_state.settings.graphics.max_fps); let max_fps = get_fps(global_state.settings.graphics.max_fps);
let max_background_fps = get_fps(global_state.settings.graphics.max_background_fps); let max_background_fps = u32::min(
const TITLE_SCREEN_FPS_CAP: u32 = 60; max_fps,
let target_fps = if !global_state.window.focused { get_fps(global_state.settings.graphics.max_background_fps),
u32::min(max_background_fps, max_fps) );
} else if capped_fps { let max_fps_focus_adjusted = if global_state.window.focused {
u32::min(TITLE_SCREEN_FPS_CAP, max_fps)
} else {
max_fps max_fps
} else {
max_background_fps
};
const TITLE_SCREEN_FPS_CAP: u32 = 60;
let target_fps = if capped_fps {
u32::min(TITLE_SCREEN_FPS_CAP, max_fps_focus_adjusted)
} else {
max_fps_focus_adjusted
}; };
global_state global_state