Add default resolution to avoid crashing

This commit is contained in:
Dean Herbert 2018-09-07 19:29:51 +09:00
parent cc533a05c5
commit c1cdff8505
1 changed files with 13 additions and 8 deletions

View File

@ -102,13 +102,18 @@ private void load(FrameworkConfigManager config, OsuGameBase game)
}, true); }, true);
} }
private IEnumerable<KeyValuePair<string, Size>> getResolutions() => private IEnumerable<KeyValuePair<string, Size>> getResolutions()
game.Window?.AvailableResolutions? {
.Where(r => r.Width >= 800 && r.Height >= 600) var resolutions = new KeyValuePair<string, Size>("Default", new Size(9999, 9999)).Yield();
.OrderByDescending(r => r.Width)
.ThenByDescending(r => r.Height) if (game.Window != null)
.Select(res => new KeyValuePair<string, Size>($"{res.Width}x{res.Height}", new Size(res.Width, res.Height))) resolutions = resolutions.Concat(game.Window.AvailableResolutions
.Distinct() .Where(r => r.Width >= 800 && r.Height >= 600)
.ToList() ?? new KeyValuePair<string, Size>("Default", new Size(9999, 9999)).Yield(); .OrderByDescending(r => r.Width)
.ThenByDescending(r => r.Height)
.Select(res => new KeyValuePair<string, Size>($"{res.Width}x{res.Height}", new Size(res.Width, res.Height)))
.Distinct()).ToList();
return resolutions;
}
} }
} }