-
Notifications
You must be signed in to change notification settings - Fork 395
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: wrexbe <[email protected]>
- Loading branch information
Showing
2 changed files
with
41 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
Robust.Client/ViewVariables/Editors/VVPropEditorNullableEntProtoId.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using Robust.Client.UserInterface; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Robust.Client.ViewVariables.Editors; | ||
|
||
internal sealed class VVPropEditorNullableEntProtoId : VVPropEditor | ||
{ | ||
protected override Control MakeUI(object? value) | ||
{ | ||
var lineEdit = new LineEdit | ||
{ | ||
Text = value is EntProtoId protoId ? protoId.Id : "", | ||
Editable = !ReadOnly, | ||
HorizontalExpand = true, | ||
}; | ||
|
||
if (!ReadOnly) | ||
{ | ||
lineEdit.OnTextEntered += e => | ||
{ | ||
if (string.IsNullOrWhiteSpace(e.Text)) | ||
{ | ||
ValueChanged(null); | ||
} | ||
else | ||
{ | ||
ValueChanged((EntProtoId) e.Text); | ||
} | ||
}; | ||
} | ||
|
||
return lineEdit; | ||
} | ||
} |