-
Notifications
You must be signed in to change notification settings - Fork 394
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix VV for entity prototypes (#4956)
* Fix VV for entity prototypes * Fix ProtoId
- Loading branch information
1 parent
15f4da5
commit 5aaf6d0
Showing
4 changed files
with
83 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,7 +43,7 @@ END TEMPLATE--> | |
|
||
### Bugfixes | ||
|
||
*None yet* | ||
* Fix VV for prototype structs. | ||
|
||
### Other | ||
|
||
|
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
28 changes: 28 additions & 0 deletions
28
Robust.Client/ViewVariables/Editors/VVPropEditorEntProtoId.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,28 @@ | ||
using Robust.Client.UserInterface; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Robust.Client.ViewVariables.Editors; | ||
|
||
internal sealed class VVPropEditorEntProtoId : VVPropEditor | ||
{ | ||
protected override Control MakeUI(object? value) | ||
{ | ||
var lineEdit = new LineEdit | ||
{ | ||
Text = (EntProtoId) (value ?? ""), | ||
Editable = !ReadOnly, | ||
HorizontalExpand = true, | ||
}; | ||
|
||
if (!ReadOnly) | ||
{ | ||
lineEdit.OnTextEntered += e => | ||
{ | ||
ValueChanged((EntProtoId) e.Text); | ||
}; | ||
} | ||
|
||
return lineEdit; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
Robust.Client/ViewVariables/Editors/VVPropEditorProtoId.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,38 @@ | ||
using Robust.Client.UserInterface; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Shared.IoC; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Robust.Client.ViewVariables.Editors; | ||
|
||
internal sealed class VVPropEditorProtoId<T> : VVPropEditor where T : class, IPrototype | ||
{ | ||
[Dependency] private readonly IPrototypeManager _protoManager = default!; | ||
|
||
protected override Control MakeUI(object? value) | ||
{ | ||
var lineEdit = new LineEdit | ||
{ | ||
Text = (ProtoId<T>) (value ?? ""), | ||
Editable = !ReadOnly, | ||
HorizontalExpand = true, | ||
}; | ||
|
||
if (!ReadOnly) | ||
{ | ||
lineEdit.OnTextEntered += e => | ||
{ | ||
var id = (ProtoId<T>)e.Text; | ||
if (!_protoManager.HasIndex(id)) | ||
{ | ||
return; | ||
} | ||
ValueChanged(id); | ||
}; | ||
} | ||
|
||
return lineEdit; | ||
} | ||
} |