From 0525408664c2dc234ac972089cc7d53205b7150b Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sun, 23 Jul 2017 21:58:45 +0100 Subject: [PATCH] Unhardcode map editor zooming hotkey. --- .../Widgets/Logic/Editor/MapEditorLogic.cs | 12 ++++++++++-- mods/cnc/chrome/editor.yaml | 1 + mods/common/chrome/editor.yaml | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Widgets/Logic/Editor/MapEditorLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Editor/MapEditorLogic.cs index ac0606156e..5243b269cc 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Editor/MapEditorLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Editor/MapEditorLogic.cs @@ -10,18 +10,26 @@ #endregion using System; +using System.Collections.Generic; using System.Linq; using OpenRA.Graphics; +using OpenRA.Mods.Common.Lint; using OpenRA.Mods.Common.Traits; using OpenRA.Widgets; namespace OpenRA.Mods.Common.Widgets.Logic { + [ChromeLogicArgsHotkeys("ChangeZoomKey")] public class MapEditorLogic : ChromeLogic { [ObjectCreator.UseCtor] - public MapEditorLogic(Widget widget, World world, WorldRenderer worldRenderer) + public MapEditorLogic(Widget widget, World world, WorldRenderer worldRenderer, Dictionary logicArgs) { + MiniYaml yaml; + var changeZoomKey = new NamedHotkey(); + if (logicArgs.TryGetValue("ChangeZoomKey", out yaml)) + changeZoomKey = new NamedHotkey(yaml.Value, Game.Settings.Keys); + var editorViewport = widget.Get("MAP_EDITOR"); var gridButton = widget.GetOrNull("GRID_BUTTON"); @@ -65,7 +73,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic zoomDropdown.OnKeyPress = e => { var key = Hotkey.FromKeyInput(e); - if (key != Game.Settings.Keys.TogglePixelDoubleKey) + if (key != changeZoomKey.GetValue()) return; var selected = (options.IndexOf(float.Parse(selectedZoom)) + 1) % options.Length; diff --git a/mods/cnc/chrome/editor.yaml b/mods/cnc/chrome/editor.yaml index 2e22df6c1e..c7634b3fc6 100644 --- a/mods/cnc/chrome/editor.yaml +++ b/mods/cnc/chrome/editor.yaml @@ -205,6 +205,7 @@ Container@EDITOR_ROOT: Container@EDITOR_WORLD_ROOT: Logic: LoadIngamePerfLogic, MapEditorLogic + ChangeZoomKey: TogglePixelDouble Children: Container@PERF_ROOT: EditorViewportController@MAP_EDITOR: diff --git a/mods/common/chrome/editor.yaml b/mods/common/chrome/editor.yaml index e221aca548..b413baca79 100644 --- a/mods/common/chrome/editor.yaml +++ b/mods/common/chrome/editor.yaml @@ -196,6 +196,7 @@ Container@EDITOR_ROOT: Container@EDITOR_WORLD_ROOT: Logic: LoadIngamePerfLogic, MapEditorLogic + ChangeZoomKey: TogglePixelDouble Children: Container@PERF_ROOT: EditorViewportController@MAP_EDITOR: