Unhardcode spectator combined/world view hotkeys.
This commit is contained in:
@@ -232,8 +232,8 @@ namespace OpenRA
|
||||
public Hotkey StanceAttackAnythingKey = new Hotkey(Keycode.A, Modifiers.Alt);
|
||||
public Hotkey GuardKey = new Hotkey(Keycode.D, Modifiers.None);
|
||||
|
||||
public Hotkey ObserverCombinedView = new Hotkey(Keycode.MINUS, Modifiers.None);
|
||||
public Hotkey ObserverWorldView = new Hotkey(Keycode.EQUALS, Modifiers.None);
|
||||
public Hotkey ObserverCombinedViewKey = new Hotkey(Keycode.MINUS, Modifiers.None);
|
||||
public Hotkey ObserverWorldViewKey = new Hotkey(Keycode.EQUALS, Modifiers.None);
|
||||
|
||||
public Hotkey CycleStatusBarsKey = new Hotkey(Keycode.COMMA, Modifiers.None);
|
||||
public Hotkey TogglePixelDoubleKey = new Hotkey(Keycode.PERIOD, Modifiers.None);
|
||||
|
||||
@@ -13,17 +13,22 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.Common.Lint;
|
||||
using OpenRA.Network;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
[ChromeLogicArgsHotkeys("CombinedViewKey", "WorldViewKey")]
|
||||
public class ObserverShroudSelectorLogic : ChromeLogic
|
||||
{
|
||||
readonly CameraOption combined, disableShroud;
|
||||
readonly IOrderedEnumerable<IGrouping<int, CameraOption>> teams;
|
||||
readonly bool limitViews;
|
||||
|
||||
readonly NamedHotkey combinedViewKey = new NamedHotkey();
|
||||
readonly NamedHotkey worldViewKey = new NamedHotkey();
|
||||
|
||||
CameraOption selected;
|
||||
|
||||
class CameraOption
|
||||
@@ -57,8 +62,16 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
}
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public ObserverShroudSelectorLogic(Widget widget, World world)
|
||||
public ObserverShroudSelectorLogic(Widget widget, World world, Dictionary<string, MiniYaml> logicArgs)
|
||||
{
|
||||
MiniYaml yaml;
|
||||
var ks = Game.Settings.Keys;
|
||||
if (logicArgs.TryGetValue("CombinedViewKey", out yaml))
|
||||
combinedViewKey = new NamedHotkey(yaml.Value, ks);
|
||||
|
||||
if (logicArgs.TryGetValue("WorldViewKey", out yaml))
|
||||
worldViewKey = new NamedHotkey(yaml.Value, ks);
|
||||
|
||||
limitViews = world.Map.Visibility.HasFlag(MapVisibility.MissionSelector);
|
||||
|
||||
var groups = new Dictionary<string, IEnumerable<CameraOption>>();
|
||||
@@ -136,7 +149,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
if (e.Event == KeyInputEvent.Down && !e.IsRepeat)
|
||||
{
|
||||
var h = Hotkey.FromKeyInput(e);
|
||||
if (h == Game.Settings.Keys.ObserverCombinedView && !limitViews)
|
||||
if (h == combinedViewKey.GetValue() && !limitViews)
|
||||
{
|
||||
selected = combined;
|
||||
selected.OnClick();
|
||||
@@ -144,7 +157,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
return true;
|
||||
}
|
||||
|
||||
if (h == Game.Settings.Keys.ObserverWorldView && !limitViews)
|
||||
if (h == worldViewKey.GetValue() && !limitViews)
|
||||
{
|
||||
selected = disableShroud;
|
||||
selected.OnClick();
|
||||
|
||||
@@ -495,8 +495,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
var hotkeys = new Dictionary<string, string>()
|
||||
{
|
||||
{ "ObserverCombinedView", "All Players" },
|
||||
{ "ObserverWorldView", "Disable Shroud" },
|
||||
{ "ObserverCombinedViewKey", "All Players" },
|
||||
{ "ObserverWorldViewKey", "Disable Shroud" },
|
||||
{ "PauseKey", "Pause/Play" },
|
||||
{ "ReplaySpeedSlowKey", "Slow speed" },
|
||||
{ "ReplaySpeedRegularKey", "Regular speed" },
|
||||
|
||||
@@ -224,6 +224,8 @@ Container@OBSERVER_WIDGETS:
|
||||
Font: TinyBold
|
||||
DropDownButton@SHROUD_SELECTOR:
|
||||
Logic: ObserverShroudSelectorLogic
|
||||
CombinedViewKey: ObserverCombinedView
|
||||
WorldViewKey: ObserverWorldView
|
||||
X: WINDOW_RIGHT - WIDTH - 5
|
||||
Y: 260
|
||||
Width: 256
|
||||
|
||||
@@ -60,6 +60,8 @@ Container@OBSERVER_WIDGETS:
|
||||
Children:
|
||||
DropDownButton@SHROUD_SELECTOR:
|
||||
Logic: ObserverShroudSelectorLogic
|
||||
CombinedViewKey: ObserverCombinedView
|
||||
WorldViewKey: ObserverWorldView
|
||||
X: 15
|
||||
Y: 15
|
||||
Width: 220
|
||||
|
||||
@@ -78,6 +78,8 @@ Container@OBSERVER_WIDGETS:
|
||||
Height: 220
|
||||
DropDownButton@SHROUD_SELECTOR:
|
||||
Logic: ObserverShroudSelectorLogic
|
||||
CombinedViewKey: ObserverCombinedView
|
||||
WorldViewKey: ObserverWorldView
|
||||
X: 6
|
||||
Y: 262
|
||||
Width: 226
|
||||
|
||||
@@ -60,6 +60,8 @@ Container@OBSERVER_WIDGETS:
|
||||
Children:
|
||||
DropDownButton@SHROUD_SELECTOR:
|
||||
Logic: ObserverShroudSelectorLogic
|
||||
CombinedViewKey: ObserverCombinedView
|
||||
WorldViewKey: ObserverWorldView
|
||||
X: 15
|
||||
Y: 15
|
||||
Width: 220
|
||||
|
||||
Reference in New Issue
Block a user