1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 13:22:55 +08:00

Attempt to preserve old resolution when switching displays

This commit is contained in:
Bartłomiej Dach 2023-05-16 21:14:09 +02:00
parent 88ce627c8e
commit 0dcf1b540e
No known key found for this signature in database

View File

@ -193,6 +193,12 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics
currentDisplay.BindValueChanged(display => Schedule(() =>
{
// there is no easy way to perform an atomic swap on the `resolutions` list, which is bound to the dropdown via `ItemSource`.
// this means, if the old resolution isn't saved, the `RemoveRange()` call below will cause `resolutionDropdown.Current` to reset value,
// therefore making it impossible to select any dropdown value other than "Default".
// to circumvent this locally, store the old value here, so that we can attempt to restore it later.
var oldResolution = resolutionDropdown.Current.Value;
resolutions.RemoveRange(1, resolutions.Count - 1);
if (display.NewValue != null)
@ -204,6 +210,9 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics
.Distinct());
}
if (resolutions.Contains(oldResolution))
resolutionDropdown.Current.Value = oldResolution;
updateDisplaySettingsVisibility();
}), true);