Codestyle fix #1262
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
|
// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using FlaxEngine;
|
using FlaxEngine;
|
||||||
using FlaxEngine.GUI;
|
using FlaxEngine.GUI;
|
||||||
@@ -13,31 +13,24 @@ namespace FlaxEditor.CustomEditors.Editors
|
|||||||
public class InputEventEditor : CustomEditor
|
public class InputEventEditor : CustomEditor
|
||||||
{
|
{
|
||||||
private Dropdown _dropdown;
|
private Dropdown _dropdown;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override DisplayStyle Style => DisplayStyle.Inline;
|
public override DisplayStyle Style => DisplayStyle.Inline;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void Initialize(LayoutElementsContainer layout)
|
public override void Initialize(LayoutElementsContainer layout)
|
||||||
{
|
{
|
||||||
var dropdownElement = layout.Custom<Dropdown>();
|
var dropdownElement = layout.Custom<Dropdown>();
|
||||||
_dropdown = dropdownElement.CustomControl;
|
_dropdown = dropdownElement.CustomControl;
|
||||||
var eventNames = new List<LocalizedString>();
|
var names = new List<LocalizedString>();
|
||||||
foreach (var mapping in Input.ActionMappings)
|
foreach (var mapping in Input.ActionMappings)
|
||||||
{
|
{
|
||||||
if (eventNames.Contains(mapping.Name))
|
if (!names.Contains(mapping.Name))
|
||||||
continue;
|
names.Add(mapping.Name);
|
||||||
eventNames.Add(mapping.Name);
|
|
||||||
}
|
}
|
||||||
_dropdown.Items = eventNames;
|
_dropdown.Items = names;
|
||||||
if (Values[0] is InputEvent value)
|
if (Values[0] is InputEvent inputEvent && names.Contains(inputEvent.Name))
|
||||||
{
|
_dropdown.SelectedItem = inputEvent.Name;
|
||||||
if (eventNames.Contains(value.Name))
|
|
||||||
{
|
|
||||||
_dropdown.SelectedItem = value.Name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_dropdown.SelectedIndexChanged += OnSelectedIndexChanged;
|
_dropdown.SelectedIndexChanged += OnSelectedIndexChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,7 +38,7 @@ namespace FlaxEditor.CustomEditors.Editors
|
|||||||
{
|
{
|
||||||
SetValue(new InputEvent(dropdown.SelectedItem));
|
SetValue(new InputEvent(dropdown.SelectedItem));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void Refresh()
|
public override void Refresh()
|
||||||
{
|
{
|
||||||
@@ -53,17 +46,11 @@ namespace FlaxEditor.CustomEditors.Editors
|
|||||||
|
|
||||||
if (HasDifferentValues)
|
if (HasDifferentValues)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (Values[0] is InputEvent eventValue)
|
if (Values[0] is InputEvent inputEvent && _dropdown.Items.Contains(inputEvent.Name))
|
||||||
{
|
_dropdown.SelectedItem = inputEvent.Name;
|
||||||
if (_dropdown.Items.Contains(eventValue.Name) && string.Equals(_dropdown.SelectedItem, eventValue.Name, StringComparison.Ordinal))
|
|
||||||
{
|
|
||||||
_dropdown.SelectedItem = eventValue.Name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,10 +60,9 @@ namespace FlaxEditor.CustomEditors.Editors
|
|||||||
if (_dropdown != null)
|
if (_dropdown != null)
|
||||||
_dropdown.SelectedIndexChanged -= OnSelectedIndexChanged;
|
_dropdown.SelectedIndexChanged -= OnSelectedIndexChanged;
|
||||||
_dropdown = null;
|
_dropdown = null;
|
||||||
base.Deinitialize();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Default implementation of the inspector used to edit input axis properties.
|
/// Default implementation of the inspector used to edit input axis properties.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -84,7 +70,7 @@ namespace FlaxEditor.CustomEditors.Editors
|
|||||||
public class InputAxisEditor : CustomEditor
|
public class InputAxisEditor : CustomEditor
|
||||||
{
|
{
|
||||||
private Dropdown _dropdown;
|
private Dropdown _dropdown;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override DisplayStyle Style => DisplayStyle.Inline;
|
public override DisplayStyle Style => DisplayStyle.Inline;
|
||||||
|
|
||||||
@@ -93,21 +79,15 @@ namespace FlaxEditor.CustomEditors.Editors
|
|||||||
{
|
{
|
||||||
var dropdownElement = layout.Custom<Dropdown>();
|
var dropdownElement = layout.Custom<Dropdown>();
|
||||||
_dropdown = dropdownElement.CustomControl;
|
_dropdown = dropdownElement.CustomControl;
|
||||||
var axisNames = new List<LocalizedString>();
|
var names = new List<LocalizedString>();
|
||||||
foreach (var mapping in Input.AxisMappings)
|
foreach (var mapping in Input.AxisMappings)
|
||||||
{
|
{
|
||||||
if (axisNames.Contains(mapping.Name))
|
if (!names.Contains(mapping.Name))
|
||||||
continue;
|
names.Add(mapping.Name);
|
||||||
axisNames.Add(mapping.Name);
|
|
||||||
}
|
|
||||||
_dropdown.Items = axisNames;
|
|
||||||
if (Values[0] is InputAxis value)
|
|
||||||
{
|
|
||||||
if (axisNames.Contains(value.Name))
|
|
||||||
{
|
|
||||||
_dropdown.SelectedItem = value.Name;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
_dropdown.Items = names;
|
||||||
|
if (Values[0] is InputAxis inputAxis && names.Contains(inputAxis.Name))
|
||||||
|
_dropdown.SelectedItem = inputAxis.Name;
|
||||||
_dropdown.SelectedIndexChanged += OnSelectedIndexChanged;
|
_dropdown.SelectedIndexChanged += OnSelectedIndexChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,27 +103,20 @@ namespace FlaxEditor.CustomEditors.Editors
|
|||||||
|
|
||||||
if (HasDifferentValues)
|
if (HasDifferentValues)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (Values[0] is InputAxis axisValue)
|
if (Values[0] is InputAxis inputAxis && _dropdown.Items.Contains(inputAxis.Name))
|
||||||
{
|
_dropdown.SelectedItem = inputAxis.Name;
|
||||||
if (_dropdown.Items.Contains(axisValue.Name) && string.Equals(_dropdown.SelectedItem, axisValue.Name, StringComparison.Ordinal))
|
|
||||||
{
|
|
||||||
_dropdown.SelectedItem = axisValue.Name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void Deinitialize()
|
protected override void Deinitialize()
|
||||||
{
|
{
|
||||||
if (_dropdown != null)
|
if (_dropdown != null)
|
||||||
_dropdown.SelectedIndexChanged -= OnSelectedIndexChanged;
|
_dropdown.SelectedIndexChanged -= OnSelectedIndexChanged;
|
||||||
_dropdown = null;
|
_dropdown = null;
|
||||||
base.Deinitialize();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -282,7 +282,7 @@ namespace FlaxEngine
|
|||||||
[EditorOrder(530), EditorDisplay("Navigation", "Navigate Left")]
|
[EditorOrder(530), EditorDisplay("Navigation", "Navigate Left")]
|
||||||
[Tooltip("The input action for performing UI navigation Left (from Input Settings).")]
|
[Tooltip("The input action for performing UI navigation Left (from Input Settings).")]
|
||||||
public InputEvent NavigateLeft { get; set; } = new InputEvent("NavigateLeft");
|
public InputEvent NavigateLeft { get; set; } = new InputEvent("NavigateLeft");
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The input action for performing UI navigation Right (from Input Settings).
|
/// The input action for performing UI navigation Right (from Input Settings).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -775,7 +775,7 @@ namespace FlaxEngine
|
|||||||
jsonWriter.WriteValue(NavigateSubmit.Name);
|
jsonWriter.WriteValue(NavigateSubmit.Name);
|
||||||
jsonWriter.WriteEndObject();
|
jsonWriter.WriteEndObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
jsonWriter.WriteEndObject();
|
jsonWriter.WriteEndObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user