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
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<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 gridButton = widget.GetOrNull<ButtonWidget>("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;

View File

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

View File

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