Use out var syntax

This commit is contained in:
teinarss
2020-08-16 10:49:33 +02:00
committed by Paul Chote
parent d52e4793fe
commit 27f1a7ab27
193 changed files with 395 additions and 826 deletions

View File

@@ -167,16 +167,14 @@ namespace OpenRA.Platforms.Default
if (videoDisplay < 0 || videoDisplay >= DisplayCount)
videoDisplay = 0;
SDL.SDL_DisplayMode display;
SDL.SDL_GetCurrentDisplayMode(videoDisplay, out display);
SDL.SDL_GetCurrentDisplayMode(videoDisplay, out var display);
// Windows and Linux define window sizes in native pixel units.
// Query the display/dpi scale so we can convert our requested effective size to pixels.
// This is not necessary on macOS, which defines window sizes in effective units ("points").
if (Platform.CurrentPlatform == PlatformType.Windows)
{
float ddpi, hdpi, vdpi;
if (SDL.SDL_GetDisplayDPI(videoDisplay, out ddpi, out hdpi, out vdpi) == 0)
if (SDL.SDL_GetDisplayDPI(videoDisplay, out var ddpi, out var hdpi, out var vdpi) == 0)
windowScale = ddpi / 96;
}
else if (Platform.CurrentPlatform != PlatformType.OSX)
@@ -195,9 +193,8 @@ namespace OpenRA.Platforms.Default
var p = Process.Start(psi);
var lines = p.StandardOutput.ReadToEnd().Split('\n');
int dpi;
foreach (var line in lines)
if (line.StartsWith("Xft.dpi") && int.TryParse(line.Substring(8), out dpi))
if (line.StartsWith("Xft.dpi") && int.TryParse(line.Substring(8), out var dpi))
windowScale = dpi / 96f;
}
catch { }
@@ -228,8 +225,7 @@ namespace OpenRA.Platforms.Default
// (if dark mode is enabled) unless we drain the event queue before initializing GL
if (Platform.CurrentPlatform == PlatformType.OSX)
{
SDL.SDL_Event e;
while (SDL.SDL_PollEvent(out e) != 0)
while (SDL.SDL_PollEvent(out var e) != 0)
{
// We can safely ignore all mouse/keyboard events and window size changes
// (these will be caught in the window setup below), but do need to process focus
@@ -254,9 +250,7 @@ namespace OpenRA.Platforms.Default
{
// OSX defines the window size in "points", with a device-dependent number of pixels per point.
// The window scale is simply the ratio of GL pixels / window points.
int width, height;
SDL.SDL_GL_GetDrawableSize(Window, out width, out height);
SDL.SDL_GL_GetDrawableSize(Window, out var width, out var height);
surfaceSize = new Size(width, height);
windowScale = width * 1f / windowSize.Width;
}
@@ -282,8 +276,7 @@ namespace OpenRA.Platforms.Default
// This is usually not what the player wants, but is the best we can consistently do.
if (Platform.CurrentPlatform == PlatformType.OSX)
{
int width, height;
SDL.SDL_GetWindowSize(Window, out width, out height);
SDL.SDL_GetWindowSize(Window, out var width, out var height);
windowSize = surfaceSize = new Size(width, height);
windowScale = 1;
}
@@ -380,8 +373,7 @@ namespace OpenRA.Platforms.Default
{
if (mode)
{
int x, y;
SDL.SDL_GetMouseState(out x, out y);
SDL.SDL_GetMouseState(out var x, out var y);
lockedMousePosition = new int2(x, y);
}
else
@@ -399,8 +391,7 @@ namespace OpenRA.Platforms.Default
// We need to recalculate our scale to account for the potential change in the actual rendered area
if (Platform.CurrentPlatform == PlatformType.OSX)
{
int width, height;
SDL.SDL_GL_GetDrawableSize(Window, out width, out height);
SDL.SDL_GL_GetDrawableSize(Window, out var width, out var height);
if (width != SurfaceSize.Width || height != SurfaceSize.Height)
{