Unhardcode map editor zooming hotkey.
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
@@ -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:
|
||||||
|
|||||||
@@ -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:
|
||||||
|
|||||||
Reference in New Issue
Block a user