Move hardcoded screenshot hotkey into yaml.
This commit is contained in:
@@ -60,6 +60,7 @@ namespace OpenRA
|
||||
public static string EngineVersion { get; private set; }
|
||||
|
||||
static Task discoverNat;
|
||||
static bool takeScreenshot = false;
|
||||
|
||||
public static OrderManager JoinServer(string host, int port, string password, bool recordReplay = true)
|
||||
{
|
||||
@@ -630,7 +631,10 @@ namespace OpenRA
|
||||
InnerLogicTick(worldRenderer.World.OrderManager);
|
||||
}
|
||||
|
||||
public static bool TakeScreenshot = false;
|
||||
public static void TakeScreenshot()
|
||||
{
|
||||
takeScreenshot = true;
|
||||
}
|
||||
|
||||
static void RenderTick()
|
||||
{
|
||||
@@ -666,9 +670,9 @@ namespace OpenRA
|
||||
using (new PerfSample("render_flip"))
|
||||
Renderer.EndFrame(new DefaultInputHandler(OrderManager.World));
|
||||
|
||||
if (TakeScreenshot)
|
||||
if (takeScreenshot)
|
||||
{
|
||||
TakeScreenshot = false;
|
||||
takeScreenshot = false;
|
||||
TakeScreenshotInner();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,12 +143,6 @@ namespace OpenRA.Widgets
|
||||
Root.Visible ^= true;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (hk == Game.Settings.Keys.TakeScreenshotKey)
|
||||
{
|
||||
Game.TakeScreenshot = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (KeyboardFocusWidget != null)
|
||||
|
||||
@@ -822,6 +822,7 @@
|
||||
<Compile Include="Lint\CheckChromeHotkeys.cs" />
|
||||
<Compile Include="UtilityCommands\LintInterfaces.cs" />
|
||||
<Compile Include="Widgets\Logic\SingleHotkeyBaseLogic.cs" />
|
||||
<Compile Include="Widgets\Logic\ScreenshotHotkeyLogic.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Target Name="AfterBuild">
|
||||
|
||||
31
OpenRA.Mods.Common/Widgets/Logic/ScreenshotHotkeyLogic.cs
Normal file
31
OpenRA.Mods.Common/Widgets/Logic/ScreenshotHotkeyLogic.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
#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 System.Collections.Generic;
|
||||
using OpenRA.Mods.Common.Lint;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
[ChromeLogicArgsHotkeys("TakeScreenshotKey")]
|
||||
public class ScreenshotHotkeyLogic : SingleHotkeyBaseLogic
|
||||
{
|
||||
[ObjectCreator.UseCtor]
|
||||
public ScreenshotHotkeyLogic(Widget widget, Dictionary<string, MiniYaml> logicArgs)
|
||||
: base(widget, "TakeScreenshotKey", "GLOBAL_KEYHANDLER", logicArgs) { }
|
||||
|
||||
protected override bool OnHotkeyActivated(KeyInput e)
|
||||
{
|
||||
Game.TakeScreenshot();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -192,11 +192,12 @@ Container@EDITOR_ROOT:
|
||||
Logic: LoadMapEditorLogic
|
||||
Children:
|
||||
LogicKeyListener@GLOBAL_KEYHANDLER:
|
||||
Logic: MusicHotkeyLogic
|
||||
Logic: MusicHotkeyLogic, ScreenshotHotkeyLogic
|
||||
StopMusicKey: StopMusic
|
||||
PauseMusicKey: PauseMusic
|
||||
PrevMusicKey: PrevMusic
|
||||
NextMusicKey: NextMusic
|
||||
TakeScreenshotKey: TakeScreenshot
|
||||
Container@WORLD_ROOT:
|
||||
Container@MENU_ROOT:
|
||||
TooltipContainer@TOOLTIP_CONTAINER:
|
||||
|
||||
@@ -2,11 +2,12 @@ Container@INGAME_ROOT:
|
||||
Logic: LoadIngamePlayerOrObserverUILogic
|
||||
Children:
|
||||
LogicKeyListener@GLOBAL_KEYHANDLER:
|
||||
Logic: MusicHotkeyLogic
|
||||
Logic: MusicHotkeyLogic, ScreenshotHotkeyLogic
|
||||
StopMusicKey: StopMusic
|
||||
PauseMusicKey: PauseMusic
|
||||
PrevMusicKey: PrevMusic
|
||||
NextMusicKey: NextMusic
|
||||
TakeScreenshotKey: TakeScreenshot
|
||||
Container@WORLD_ROOT:
|
||||
Logic: LoadIngamePerfLogic
|
||||
Children:
|
||||
|
||||
@@ -4,11 +4,12 @@ Container@MENU_BACKGROUND:
|
||||
Logic: MainMenuLogic
|
||||
Children:
|
||||
LogicKeyListener@GLOBAL_KEYHANDLER:
|
||||
Logic: MusicHotkeyLogic
|
||||
Logic: MusicHotkeyLogic, ScreenshotHotkeyLogic
|
||||
StopMusicKey: StopMusic
|
||||
PauseMusicKey: PauseMusic
|
||||
PrevMusicKey: PrevMusic
|
||||
NextMusicKey: NextMusic
|
||||
TakeScreenshotKey: TakeScreenshot
|
||||
Container@SHELLMAP_DECORATIONS:
|
||||
Children:
|
||||
Image@NOD:
|
||||
|
||||
@@ -183,11 +183,12 @@ Container@EDITOR_ROOT:
|
||||
Logic: LoadMapEditorLogic
|
||||
Children:
|
||||
LogicKeyListener@GLOBAL_KEYHANDLER:
|
||||
Logic: MusicHotkeyLogic
|
||||
Logic: MusicHotkeyLogic, ScreenshotHotkeyLogic
|
||||
StopMusicKey: StopMusic
|
||||
PauseMusicKey: PauseMusic
|
||||
PrevMusicKey: PrevMusic
|
||||
NextMusicKey: NextMusic
|
||||
TakeScreenshotKey: TakeScreenshot
|
||||
Container@WORLD_ROOT:
|
||||
Container@MENU_ROOT:
|
||||
TooltipContainer@TOOLTIP_CONTAINER:
|
||||
|
||||
@@ -2,11 +2,12 @@ Container@INGAME_ROOT:
|
||||
Logic: LoadIngamePlayerOrObserverUILogic
|
||||
Children:
|
||||
LogicKeyListener@GLOBAL_KEYHANDLER:
|
||||
Logic: MusicHotkeyLogic
|
||||
Logic: MusicHotkeyLogic, ScreenshotHotkeyLogic
|
||||
StopMusicKey: StopMusic
|
||||
PauseMusicKey: PauseMusic
|
||||
PrevMusicKey: PrevMusic
|
||||
NextMusicKey: NextMusic
|
||||
TakeScreenshotKey: TakeScreenshot
|
||||
Container@WORLD_ROOT:
|
||||
Logic: LoadIngamePerfLogic
|
||||
Children:
|
||||
|
||||
@@ -2,11 +2,12 @@ Container@MAINMENU:
|
||||
Logic: MainMenuLogic
|
||||
Children:
|
||||
LogicKeyListener@GLOBAL_KEYHANDLER:
|
||||
Logic: MusicHotkeyLogic
|
||||
Logic: MusicHotkeyLogic, ScreenshotHotkeyLogic
|
||||
StopMusicKey: StopMusic
|
||||
PauseMusicKey: PauseMusic
|
||||
PrevMusicKey: PrevMusic
|
||||
NextMusicKey: NextMusic
|
||||
TakeScreenshotKey: TakeScreenshot
|
||||
Background@BORDER:
|
||||
Background: mainmenu-border
|
||||
X: 0 - 15
|
||||
|
||||
@@ -2,11 +2,12 @@ Container@MAINMENU:
|
||||
Logic: MainMenuLogic
|
||||
Children:
|
||||
LogicKeyListener@GLOBAL_KEYHANDLER:
|
||||
Logic: MusicHotkeyLogic
|
||||
Logic: MusicHotkeyLogic, ScreenshotHotkeyLogic
|
||||
StopMusicKey: StopMusic
|
||||
PauseMusicKey: PauseMusic
|
||||
PrevMusicKey: PrevMusic
|
||||
NextMusicKey: NextMusic
|
||||
TakeScreenshotKey: TakeScreenshot
|
||||
Label@VERSION_LABEL:
|
||||
X: WINDOW_RIGHT - 10
|
||||
Y: WINDOW_BOTTOM - 20
|
||||
|
||||
Reference in New Issue
Block a user