Take screenshot in dialogs #13184

This commit is contained in:
rob-v
2017-04-24 16:41:11 +02:00
parent 12f2fc3410
commit 382fefebfe
3 changed files with 26 additions and 59 deletions

View File

@@ -239,7 +239,6 @@
<Compile Include="Support\PerfSample.cs" />
<Compile Include="Graphics\SpriteRenderable.cs" />
<Compile Include="Widgets\Widget.cs" />
<Compile Include="Widgets\RootWidget.cs" />
<Compile Include="Widgets\WidgetLoader.cs" />
<Compile Include="Widgets\ChromeMetrics.cs" />
<Compile Include="Widgets\WidgetUtils.cs" />
@@ -351,5 +350,5 @@
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -1,55 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2017 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version. For more
* information, see COPYING.
*/
#endregion
using OpenRA.Graphics;
namespace OpenRA.Widgets
{
public class RootWidget : ContainerWidget
{
public RootWidget()
{
IgnoreMouseOver = true;
}
public override bool HandleKeyPress(KeyInput e)
{
if (e.Event == KeyInputEvent.Down)
{
var hk = Hotkey.FromKeyInput(e);
if (hk == Game.Settings.Keys.DevReloadChromeKey)
{
ChromeProvider.Initialize(Game.ModData);
return true;
}
if (hk == Game.Settings.Keys.HideUserInterfaceKey)
{
foreach (var child in Children)
child.Visible ^= true;
return true;
}
if (hk == Game.Settings.Keys.TakeScreenshotKey)
{
if (e.Event == KeyInputEvent.Down)
Game.TakeScreenshot = true;
return true;
}
}
return base.HandleKeyPress(e);
}
}
}

View File

@@ -20,7 +20,7 @@ namespace OpenRA.Widgets
{
public static class Ui
{
public static Widget Root = new RootWidget();
public static Widget Root = new ContainerWidget();
public static long LastTickTime = Game.RunTime;
@@ -128,6 +128,29 @@ namespace OpenRA.Widgets
/// <param name="e">Key input data</param>
public static bool HandleKeyPress(KeyInput e)
{
if (e.Event == KeyInputEvent.Down)
{
var hk = Hotkey.FromKeyInput(e);
if (hk == Game.Settings.Keys.DevReloadChromeKey)
{
ChromeProvider.Initialize(Game.ModData);
return true;
}
if (hk == Game.Settings.Keys.HideUserInterfaceKey)
{
Root.Visible ^= true;
return true;
}
if (hk == Game.Settings.Keys.TakeScreenshotKey)
{
Game.TakeScreenshot = true;
return true;
}
}
if (KeyboardFocusWidget != null)
return KeyboardFocusWidget.HandleKeyPressOuter(e);