From 7306bcc35a6aaa2c1304dd6619919b542100e4e4 Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Sun, 25 Aug 2019 12:54:55 +0200 Subject: [PATCH] Fix VerbSystem crash. Fixes #317 --- .../GameObjects/EntitySystems/VerbSystem.cs | 38 +++++++++++-------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/Content.Client/GameObjects/EntitySystems/VerbSystem.cs b/Content.Client/GameObjects/EntitySystems/VerbSystem.cs index a323f581b3..7e2d7cc85f 100644 --- a/Content.Client/GameObjects/EntitySystems/VerbSystem.cs +++ b/Content.Client/GameObjects/EntitySystems/VerbSystem.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using Content.Shared.GameObjects; using Content.Shared.GameObjects.EntitySystemMessages; using Content.Shared.Input; +using JetBrains.Annotations; using Robust.Client.GameObjects.EntitySystems; using Robust.Client.Interfaces.Input; using Robust.Client.Interfaces.State; @@ -23,7 +24,8 @@ using Robust.Shared.Utility; namespace Content.Client.GameObjects.EntitySystems { - public class VerbSystem : EntitySystem + [UsedImplicitly] + public sealed class VerbSystem : EntitySystem { #pragma warning disable 649 [Dependency] private readonly IStateManager _stateManager; @@ -33,7 +35,7 @@ namespace Content.Client.GameObjects.EntitySystems [Dependency] private readonly IUserInterfaceManager _userInterfaceManager; #pragma warning restore 649 - private Popup _currentPopup; + private VerbPopup _currentPopup; private EntityUid _currentEntity; public override void Initialize() @@ -62,16 +64,14 @@ namespace Content.Client.GameObjects.EntitySystems } _currentEntity = entity.Uid; - _currentPopup = new Popup(); + _currentPopup = new VerbPopup(); _currentPopup.UserInterfaceManager.StateRoot.AddChild(_currentPopup); _currentPopup.OnPopupHide += _closeContextMenu; - var vBox = new VBoxContainer(); - _currentPopup.AddChild(vBox); - vBox.AddChild(new Label {Text = "Waiting on Server..."}); + _currentPopup.List.AddChild(new Label {Text = "Waiting on Server..."}); RaiseNetworkEvent(new VerbSystemMessages.RequestVerbsMessage(_currentEntity)); - var size = vBox.CombinedMinimumSize; + var size = _currentPopup.List.CombinedMinimumSize; var box = UIBox2.FromDimensions(screenCoordinates.Position, size); _currentPopup.Open(box); } @@ -91,20 +91,18 @@ namespace Content.Client.GameObjects.EntitySystems var entities = gameScreen.GetEntitiesUnderPosition(args.Coordinates); - _currentPopup = new Popup(); + _currentPopup = new VerbPopup(); _currentPopup.OnPopupHide += _closeContextMenu; - var vBox = new VBoxContainer(); - _currentPopup.AddChild(vBox); foreach (var entity in entities) { var button = new Button {Text = entity.Name}; - vBox.AddChild(button); + _currentPopup.List.AddChild(button); button.OnPressed += _ => OnContextButtonPressed(entity); } _currentPopup.UserInterfaceManager.StateRoot.AddChild(_currentPopup); - var size = vBox.CombinedMinimumSize; + var size = _currentPopup.List.CombinedMinimumSize; var box = UIBox2.FromDimensions(args.ScreenCoordinates.Position, size); _currentPopup.Open(box); } @@ -137,7 +135,7 @@ namespace Content.Client.GameObjects.EntitySystems var buttons = new List