mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
* Fixes right click menu stopping input Removed a flag change when the modal stack was showing, which preventing the click from getting passed to the next function. * Added parsing for mod2 and mod3 from Keybind YAML * Fixes a crash on context change when a keybind is not defined in keybinds.yml * Implemented ShowDebugConsole Hotkey * Refactored input system Refactored input system to run Key and Mouse input through the InputManager before doing stuff. * Upgraded LineEdit and classes that use it. Fixed input while KeyboardFocused. Upgraded LineEdit to use Keybinds. Upgraded DebugConsole to use Keybinds. Replaced all references to MouseDown, MouseUp, KeyDown, and KeyUp with KeyBindUp and KeyBindDown. Moved UserInterfaceManager call from GameController.Input to InputManager event. Stopped input going to simulation while a control has focus in UserInterfaceManager. * Some fixes for input system Fixed keybinds getting stuck when selecting a LineEdit. Changed MenuBar to not error. Fixed a few cases where LineEdit would eat input if you hovered over it and where mouse input got eaten when clicking in the world while a LineEdit was selected. * Removed extra dependencies * Added GUIBoundKeyEventArgs to ButtonEventArgs * Fixes for input with LineEdit selected Fixed multiple keybinds mapped to the same key not triggering. Fixed keybind input not getting to LineEdit when hovering over a control. * Implemented Key Repeat for LineEdit * Fix for input on Robust.Lite Launcher * Renames NonFocusKeybinds to EnableAllKeybinds Renamed NonFocusKeybinds to EnableAllKeybinds and added comment to clarify usage * Adds repeating keybinds Used for TextBackspace, TextCursorLeft, and TextCursorRight Reverts a change to LineEdit that implemented repeating keys Adds some documentation comments
157 lines
5.5 KiB
C#
157 lines
5.5 KiB
C#
using System;
|
|
using Robust.Client.Graphics;
|
|
using Robust.Client.Graphics.Drawing;
|
|
using Robust.Client.Interfaces.ResourceManagement;
|
|
using Robust.Client.ResourceManagement;
|
|
using Robust.Client.UserInterface;
|
|
using Robust.Client.UserInterface.Controls;
|
|
using Robust.Client.ViewVariables.Editors;
|
|
using Robust.Shared.Maths;
|
|
using Robust.Shared.Utility;
|
|
using Robust.Shared.ViewVariables;
|
|
|
|
namespace Robust.Client.ViewVariables
|
|
{
|
|
internal class ViewVariablesPropertyControl : PanelContainer
|
|
{
|
|
public VBoxContainer VBox { get; private set; }
|
|
public HBoxContainer TopContainer { get; private set; }
|
|
public HBoxContainer BottomContainer { get; private set; }
|
|
public Label NameLabel { get; private set; }
|
|
|
|
private Label _bottomLabel;
|
|
|
|
private readonly IViewVariablesManagerInternal _viewVariablesManager;
|
|
private readonly IResourceCache _resourceCache;
|
|
|
|
public ViewVariablesPropertyControl(IViewVariablesManagerInternal viewVars, IResourceCache resourceCache)
|
|
{
|
|
_viewVariablesManager = viewVars;
|
|
_resourceCache = resourceCache;
|
|
|
|
PerformLayout();
|
|
}
|
|
|
|
private void PerformLayout()
|
|
{
|
|
MouseFilter = MouseFilterMode.Stop;
|
|
ToolTip = "Click to expand";
|
|
CustomMinimumSize = new Vector2(0, 25);
|
|
|
|
VBox = new VBoxContainer {SeparationOverride = 0};
|
|
AddChild(VBox);
|
|
|
|
TopContainer = new HBoxContainer {SizeFlagsVertical = SizeFlags.FillExpand};
|
|
VBox.AddChild(TopContainer);
|
|
|
|
BottomContainer = new HBoxContainer
|
|
{
|
|
Visible = false
|
|
};
|
|
VBox.AddChild(BottomContainer);
|
|
|
|
//var smallFont = new VectorFont(_resourceCache.GetResource<FontResource>("/Fonts/CALIBRI.TTF"), 10);
|
|
|
|
_bottomLabel = new Label
|
|
{
|
|
// FontOverride = smallFont,
|
|
FontColorOverride = Color.DarkGray
|
|
};
|
|
BottomContainer.AddChild(_bottomLabel);
|
|
|
|
NameLabel = new Label();
|
|
TopContainer.AddChild(NameLabel);
|
|
}
|
|
|
|
public ViewVariablesPropertyEditor SetProperty(ViewVariablesBlobMembers.MemberData member)
|
|
{
|
|
NameLabel.Text = member.Name;
|
|
var type = Type.GetType(member.Type);
|
|
|
|
_bottomLabel.Text = $"Type: {member.TypePretty}";
|
|
ViewVariablesPropertyEditor editor;
|
|
if (type == null)
|
|
{
|
|
// Type is server-side only.
|
|
// Info whether it's reference or value type can be figured out from the sent value.
|
|
if (member.Value is ViewVariablesBlobMembers.ServerValueTypeToken)
|
|
{
|
|
// Value type, just display it stringified read-only.
|
|
editor = new ViewVariablesPropertyEditorDummy();
|
|
}
|
|
else
|
|
{
|
|
// Has to be a reference type at this point.
|
|
DebugTools.Assert(member.Value is ViewVariablesBlobMembers.ReferenceToken || member.Value == null);
|
|
editor = _viewVariablesManager.PropertyFor(typeof(object));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
editor = _viewVariablesManager.PropertyFor(type);
|
|
}
|
|
|
|
var view = editor.Initialize(member.Value, !member.Editable);
|
|
if (view.SizeFlagsHorizontal != SizeFlags.FillExpand)
|
|
{
|
|
NameLabel.SizeFlagsHorizontal = SizeFlags.FillExpand;
|
|
}
|
|
|
|
NameLabel.CustomMinimumSize = new Vector2(150, 0);
|
|
TopContainer.AddChild(view);
|
|
/*
|
|
_beingEdited = obj;
|
|
_editedProperty = propertyInfo;
|
|
DebugTools.Assert(propertyInfo.DeclaringType != null);
|
|
DebugTools.Assert(propertyInfo.DeclaringType.IsInstanceOfType(obj));
|
|
|
|
var attr = propertyInfo.GetCustomAttribute<ViewVariablesAttribute>();
|
|
DebugTools.Assert(attr != null);
|
|
NameLabel.Text = propertyInfo.Name;
|
|
|
|
_bottomLabel.Text = $"Type: {propertyInfo.PropertyType.FullName}";
|
|
|
|
var editor = vvm.PropertyFor(propertyInfo.PropertyType);
|
|
var value = propertyInfo.GetValue(obj);
|
|
|
|
var view = editor.Initialize(value, attr.Access != VVAccess.ReadWrite);
|
|
if (view.SizeFlagsHorizontal != SizeFlags.FillExpand)
|
|
{
|
|
NameLabel.SizeFlagsHorizontal = SizeFlags.FillExpand;
|
|
}
|
|
NameLabel.CustomMinimumSize = new Vector2(150, 0);
|
|
TopContainer.AddChild(view);
|
|
editor.OnValueChanged += v => { propertyInfo.SetValue(obj, v); };
|
|
*/
|
|
return editor;
|
|
}
|
|
|
|
public void SetStyle(bool other)
|
|
{
|
|
PanelOverride = GetAlternatingStyleBox(other);
|
|
}
|
|
|
|
public static StyleBox GetAlternatingStyleBox(bool other)
|
|
{
|
|
var box = new StyleBoxFlat();
|
|
box.BackgroundColor = other ? Color.Transparent : Color.Black.WithAlpha(0.25f);
|
|
box.SetContentMarginOverride(StyleBox.Margin.Vertical, 1);
|
|
box.SetContentMarginOverride(StyleBox.Margin.Horizontal, 5);
|
|
return box;
|
|
}
|
|
|
|
protected internal override void KeyBindDown(GUIBoundKeyEventArgs args)
|
|
{
|
|
base.KeyBindDown(args);
|
|
|
|
if (!args.CanFocus)
|
|
{
|
|
return;
|
|
}
|
|
|
|
BottomContainer.Visible = !BottomContainer.Visible;
|
|
args.Handle();
|
|
}
|
|
}
|
|
}
|