Improve on disposal routing code (#1795)
Co-authored-by: Julian Giebel <j.giebel@netrocks.info>
This commit is contained in:
@@ -23,15 +23,13 @@ namespace Content.Client.GameObjects.Components.Disposal
|
||||
{
|
||||
base.Open();
|
||||
|
||||
_window = new DisposalRouterWindow
|
||||
{
|
||||
Title = Loc.GetString("Disposal Router"),
|
||||
};
|
||||
_window = new DisposalRouterWindow();
|
||||
|
||||
_window.OpenCentered();
|
||||
_window.OnClose += Close;
|
||||
|
||||
_window.Confirm.OnPressed += _ => ButtonPressed(UiAction.Ok, _window.TagInput.Text);
|
||||
_window.TagInput.OnTextEntered += args => ButtonPressed(UiAction.Ok, args.Text);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text.RegularExpressions;
|
||||
using Content.Shared.GameObjects.Components.Disposal;
|
||||
using Robust.Client.Graphics.Drawing;
|
||||
using Content.Shared.GameObjects.Components.Disposal;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
@@ -21,11 +18,9 @@ namespace Content.Client.GameObjects.Components.Disposal
|
||||
|
||||
protected override Vector2? CustomSize => (400, 80);
|
||||
|
||||
private Regex _tagRegex;
|
||||
|
||||
public DisposalRouterWindow()
|
||||
{
|
||||
_tagRegex = new Regex("^[a-zA-Z0-9, ]*$", RegexOptions.Compiled);
|
||||
Title = Loc.GetString("Disposal Router");
|
||||
|
||||
Contents.AddChild(new VBoxContainer
|
||||
{
|
||||
@@ -38,7 +33,7 @@ namespace Content.Client.GameObjects.Components.Disposal
|
||||
Children =
|
||||
{
|
||||
(TagInput = new LineEdit {SizeFlagsHorizontal = SizeFlags.Expand, CustomMinimumSize = (320, 0),
|
||||
ToolTip = Loc.GetString("A comma separated list of tags"), IsValid = tags => _tagRegex.IsMatch(tags)}),
|
||||
ToolTip = Loc.GetString("A comma separated list of tags"), IsValid = tags => TagRegex.IsMatch(tags)}),
|
||||
new Control {CustomMinimumSize = (10, 0)},
|
||||
(Confirm = new Button {Text = Loc.GetString("Confirm")})
|
||||
}
|
||||
|
||||
@@ -23,15 +23,13 @@ namespace Content.Client.GameObjects.Components.Disposal
|
||||
{
|
||||
base.Open();
|
||||
|
||||
_window = new DisposalTaggerWindow
|
||||
{
|
||||
Title = Loc.GetString("Disposal Tagger"),
|
||||
};
|
||||
_window = new DisposalTaggerWindow();
|
||||
|
||||
_window.OpenCentered();
|
||||
_window.OnClose += Close;
|
||||
|
||||
_window.Confirm.OnPressed += _ => ButtonPressed(UiAction.Ok, _window.TagInput.Text);
|
||||
_window.TagInput.OnTextEntered += args => ButtonPressed(UiAction.Ok, args.Text);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text.RegularExpressions;
|
||||
using Content.Shared.GameObjects.Components.Disposal;
|
||||
using Robust.Client.Graphics.Drawing;
|
||||
using Content.Shared.GameObjects.Components.Disposal;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
@@ -21,11 +18,9 @@ namespace Content.Client.GameObjects.Components.Disposal
|
||||
|
||||
protected override Vector2? CustomSize => (400, 80);
|
||||
|
||||
private Regex _tagRegex;
|
||||
|
||||
public DisposalTaggerWindow()
|
||||
{
|
||||
_tagRegex = new Regex("^[a-zA-Z0-9 ]*$", RegexOptions.Compiled);
|
||||
Title = Loc.GetString("Disposal Tagger");
|
||||
|
||||
Contents.AddChild(new VBoxContainer
|
||||
{
|
||||
@@ -38,7 +33,7 @@ namespace Content.Client.GameObjects.Components.Disposal
|
||||
Children =
|
||||
{
|
||||
(TagInput = new LineEdit {SizeFlagsHorizontal = SizeFlags.Expand, CustomMinimumSize = (320, 0),
|
||||
IsValid = tag => _tagRegex.IsMatch(tag)}),
|
||||
IsValid = tag => TagRegex.IsMatch(tag)}),
|
||||
new Control {CustomMinimumSize = (10, 0)},
|
||||
(Confirm = new Button {Text = Loc.GetString("Confirm")})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user