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);
}
private IEnumerable<KeyValuePair<string, Size>> getResolutions() =>
game.Window?.AvailableResolutions?
.Where(r => r.Width >= 800 && r.Height >= 600)
.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() ?? new KeyValuePair<string, Size>("Default", new Size(9999, 9999)).Yield();
private IEnumerable<KeyValuePair<string, Size>> getResolutions()
{
var resolutions = new KeyValuePair<string, Size>("Default", new Size(9999, 9999)).Yield();
if (game.Window != null)
resolutions = resolutions.Concat(game.Window.AvailableResolutions
.Where(r => r.Width >= 800 && r.Height >= 600)
.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;
}
}
}