Unhardcode map editor zooming hotkey.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -205,6 +205,7 @@ Container@EDITOR_ROOT:
|
||||
|
||||
Container@EDITOR_WORLD_ROOT:
|
||||
Logic: LoadIngamePerfLogic, MapEditorLogic
|
||||
ChangeZoomKey: TogglePixelDouble
|
||||
Children:
|
||||
Container@PERF_ROOT:
|
||||
EditorViewportController@MAP_EDITOR:
|
||||
|
||||
@@ -196,6 +196,7 @@ Container@EDITOR_ROOT:
|
||||
|
||||
Container@EDITOR_WORLD_ROOT:
|
||||
Logic: LoadIngamePerfLogic, MapEditorLogic
|
||||
ChangeZoomKey: TogglePixelDouble
|
||||
Children:
|
||||
Container@PERF_ROOT:
|
||||
EditorViewportController@MAP_EDITOR:
|
||||
|
||||
Reference in New Issue
Block a user