Unhardcode map editor zooming hotkey.

This commit is contained in:
Paul Chote
2017-07-23 21:58:45 +01:00
committed by reaperrr
parent 9a5b5d9b6f
commit 0525408664
3 changed files with 12 additions and 2 deletions

View File

@@ -10,18 +10,26 @@
#endregion #endregion
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Mods.Common.Lint;
using OpenRA.Mods.Common.Traits; using OpenRA.Mods.Common.Traits;
using OpenRA.Widgets; using OpenRA.Widgets;
namespace OpenRA.Mods.Common.Widgets.Logic namespace OpenRA.Mods.Common.Widgets.Logic
{ {
[ChromeLogicArgsHotkeys("ChangeZoomKey")]
public class MapEditorLogic : ChromeLogic public class MapEditorLogic : ChromeLogic
{ {
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public MapEditorLogic(Widget widget, World world, WorldRenderer worldRenderer) public MapEditorLogic(Widget widget, World world, WorldRenderer worldRenderer, Dictionary<string, MiniYaml> 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<EditorViewportControllerWidget>("MAP_EDITOR"); var editorViewport = widget.Get<EditorViewportControllerWidget>("MAP_EDITOR");
var gridButton = widget.GetOrNull<ButtonWidget>("GRID_BUTTON"); var gridButton = widget.GetOrNull<ButtonWidget>("GRID_BUTTON");
@@ -65,7 +73,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
zoomDropdown.OnKeyPress = e => zoomDropdown.OnKeyPress = e =>
{ {
var key = Hotkey.FromKeyInput(e); var key = Hotkey.FromKeyInput(e);
if (key != Game.Settings.Keys.TogglePixelDoubleKey) if (key != changeZoomKey.GetValue())
return; return;
var selected = (options.IndexOf(float.Parse(selectedZoom)) + 1) % options.Length; var selected = (options.IndexOf(float.Parse(selectedZoom)) + 1) % options.Length;

View File

@@ -205,6 +205,7 @@ Container@EDITOR_ROOT:
Container@EDITOR_WORLD_ROOT: Container@EDITOR_WORLD_ROOT:
Logic: LoadIngamePerfLogic, MapEditorLogic Logic: LoadIngamePerfLogic, MapEditorLogic
ChangeZoomKey: TogglePixelDouble
Children: Children:
Container@PERF_ROOT: Container@PERF_ROOT:
EditorViewportController@MAP_EDITOR: EditorViewportController@MAP_EDITOR:

View File

@@ -196,6 +196,7 @@ Container@EDITOR_ROOT:
Container@EDITOR_WORLD_ROOT: Container@EDITOR_WORLD_ROOT:
Logic: LoadIngamePerfLogic, MapEditorLogic Logic: LoadIngamePerfLogic, MapEditorLogic
ChangeZoomKey: TogglePixelDouble
Children: Children:
Container@PERF_ROOT: Container@PERF_ROOT:
EditorViewportController@MAP_EDITOR: EditorViewportController@MAP_EDITOR: