Remove Game.HasInputFocus

This commit is contained in:
abcdefg30
2020-04-07 14:57:29 +02:00
committed by atlimit8
parent 5b34af0f12
commit 3ba86f329f
6 changed files with 17 additions and 6 deletions

View File

@@ -51,7 +51,6 @@ namespace OpenRA
public static Renderer Renderer;
public static Sound Sound;
public static bool HasInputFocus = false;
public static string EngineVersion { get; private set; }
public static LocalPlayerProfile LocalPlayerProfile;

View File

@@ -49,6 +49,7 @@ namespace OpenRA
Size SurfaceSize { get; }
int DisplayCount { get; }
int CurrentDisplay { get; }
bool HasInputFocus { get; }
event Action<float, float, float, float> OnWindowScaleChanged;

View File

@@ -31,6 +31,15 @@ namespace OpenRA
public RgbaColorRenderer RgbaColorRenderer { get; private set; }
public SpriteRenderer SpriteRenderer { get; private set; }
public RgbaSpriteRenderer RgbaSpriteRenderer { get; private set; }
public bool WindowHasInputFocus
{
get
{
return Window.HasInputFocus;
}
}
public IReadOnlyDictionary<string, SpriteFont> Fonts;
internal IPlatformWindow Window { get; private set; }

View File

@@ -192,7 +192,7 @@ namespace OpenRA.Mods.Common.Widgets
else if (!isStandardScrolling)
{
edgeDirections = ScrollDirection.None;
if (Game.Settings.Game.ViewportEdgeScroll && Game.HasInputFocus)
if (Game.Settings.Game.ViewportEdgeScroll && Game.Renderer.WindowHasInputFocus)
edgeDirections = CheckForDirections();
if (keyboardDirections != ScrollDirection.None || edgeDirections != ScrollDirection.None)

View File

@@ -81,11 +81,11 @@ namespace OpenRA.Platforms.Default
switch (e.window.windowEvent)
{
case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_FOCUS_LOST:
Game.HasInputFocus = false;
device.HasInputFocus = false;
break;
case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_FOCUS_GAINED:
Game.HasInputFocus = true;
device.HasInputFocus = true;
break;
// Triggered when moving between displays with different DPI settings

View File

@@ -105,6 +105,8 @@ namespace OpenRA.Platforms.Default
}
}
public bool HasInputFocus { get; internal set; }
public event Action<float, float, float, float> OnWindowScaleChanged = (oldNative, oldEffective, newNative, newEffective) => { };
[DllImport("user32.dll")]
@@ -221,11 +223,11 @@ namespace OpenRA.Platforms.Default
switch (e.window.windowEvent)
{
case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_FOCUS_LOST:
Game.HasInputFocus = false;
HasInputFocus = false;
break;
case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_FOCUS_GAINED:
Game.HasInputFocus = true;
HasInputFocus = true;
break;
}
}