Use PopupContainer for verbs & examine popups.

Fixes #501
This commit is contained in:
Pieter-Jan Briers
2020-01-25 17:28:39 +01:00
parent 821058740f
commit daf3c28929
2 changed files with 4 additions and 10 deletions

View File

@@ -73,15 +73,14 @@ namespace Content.Client.GameObjects.EntitySystems
public async void DoExamine(IEntity entity) public async void DoExamine(IEntity entity)
{ {
const float minWidth = 300;
CloseTooltip(); CloseTooltip();
var popupPos = _inputManager.MouseScreenPosition; var popupPos = _inputManager.MouseScreenPosition;
// Actually open the tooltip. // Actually open the tooltip.
_examineTooltipOpen = new Popup(); _examineTooltipOpen = new Popup();
_userInterfaceManager.StateRoot.AddChild(_examineTooltipOpen); _userInterfaceManager.ModalRoot.AddChild(_examineTooltipOpen);
var panel = new PanelContainer(); var panel = new PanelContainer();
panel.AddStyleClass(StyleClassEntityTooltip); panel.AddStyleClass(StyleClassEntityTooltip);
panel.ModulateSelfOverride = Color.LightGray.WithAlpha(0.90f); panel.ModulateSelfOverride = Color.LightGray.WithAlpha(0.90f);
@@ -89,7 +88,7 @@ namespace Content.Client.GameObjects.EntitySystems
//panel.SetAnchorAndMarginPreset(Control.LayoutPreset.Wide); //panel.SetAnchorAndMarginPreset(Control.LayoutPreset.Wide);
var vBox = new VBoxContainer(); var vBox = new VBoxContainer();
panel.AddChild(vBox); panel.AddChild(vBox);
var hBox = new HBoxContainer { SeparationOverride = 5}; var hBox = new HBoxContainer {SeparationOverride = 5};
vBox.AddChild(hBox); vBox.AddChild(hBox);
if (entity.TryGetComponent(out ISpriteComponent sprite)) if (entity.TryGetComponent(out ISpriteComponent sprite))
{ {
@@ -102,11 +101,8 @@ namespace Content.Client.GameObjects.EntitySystems
SizeFlagsHorizontal = Control.SizeFlags.FillExpand, SizeFlagsHorizontal = Control.SizeFlags.FillExpand,
}); });
const float minWidth = 300;
var size = Vector2.ComponentMax((minWidth, 0), panel.CombinedMinimumSize); var size = Vector2.ComponentMax((minWidth, 0), panel.CombinedMinimumSize);
popupPos += Vector2.ComponentMin(Vector2.Zero, _userInterfaceManager.StateRoot.Size - (size + popupPos));
_examineTooltipOpen.Open(UIBox2.FromDimensions(popupPos, size)); _examineTooltipOpen.Open(UIBox2.FromDimensions(popupPos, size));
if (entity.Uid.IsClientSide()) if (entity.Uid.IsClientSide())
@@ -144,8 +140,6 @@ namespace Content.Client.GameObjects.EntitySystems
break; break;
} }
} }
//_examineTooltipOpen.Position += Vector2.ComponentMin(Vector2.Zero,_userInterfaceManager.StateRoot.Size - (panel.Size + _examineTooltipOpen.Position));
} }
public void CloseTooltip() public void CloseTooltip()

View File

@@ -67,7 +67,7 @@ namespace Content.Client.GameObjects.EntitySystems
_currentEntity = entity.Uid; _currentEntity = entity.Uid;
_currentPopup = new VerbPopup(); _currentPopup = new VerbPopup();
_currentPopup.UserInterfaceManager.StateRoot.AddChild(_currentPopup); _currentPopup.UserInterfaceManager.ModalRoot.AddChild(_currentPopup);
_currentPopup.OnPopupHide += _closeContextMenu; _currentPopup.OnPopupHide += _closeContextMenu;
_currentPopup.List.AddChild(new Label {Text = "Waiting on Server..."}); _currentPopup.List.AddChild(new Label {Text = "Waiting on Server..."});