PopupSystem public methods rejig (#12830)
This commit is contained in:
@@ -9,6 +9,7 @@ using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
@@ -35,38 +36,6 @@ namespace Content.Client.Popups
|
||||
SubscribeNetworkEvent<RoundRestartCleanupEvent>(OnRoundRestart);
|
||||
}
|
||||
|
||||
#region Actual Implementation
|
||||
|
||||
public void PopupCursor(string message, PopupType type=PopupType.Small)
|
||||
{
|
||||
var label = new CursorPopupLabel(_inputManager.MouseScreenPosition)
|
||||
{
|
||||
Text = message,
|
||||
StyleClasses = { GetStyleClass(type) },
|
||||
};
|
||||
_userInterfaceManager.PopupRoot.AddChild(label);
|
||||
_aliveCursorLabels.Add(label);
|
||||
}
|
||||
|
||||
public void PopupCoordinates(string message, EntityCoordinates coordinates, PopupType type=PopupType.Small)
|
||||
{
|
||||
if (_eyeManager.CurrentMap != Transform(coordinates.EntityId).MapID)
|
||||
return;
|
||||
PopupMessage(message, type, coordinates, null);
|
||||
}
|
||||
|
||||
public void PopupEntity(string message, EntityUid uid, PopupType type=PopupType.Small)
|
||||
{
|
||||
if (!EntityManager.EntityExists(uid))
|
||||
return;
|
||||
|
||||
var transform = EntityManager.GetComponent<TransformComponent>(uid);
|
||||
if (_eyeManager.CurrentMap != transform.MapID)
|
||||
return; // TODO: entity may be outside of PVS, but enter PVS at a later time. So the pop-up should still get tracked?
|
||||
|
||||
PopupMessage(message, type, transform.Coordinates, uid);
|
||||
}
|
||||
|
||||
private void PopupMessage(string message, PopupType type, EntityCoordinates coordinates, EntityUid? entity = null)
|
||||
{
|
||||
var label = new WorldPopupLabel(_eyeManager, EntityManager)
|
||||
@@ -83,32 +52,77 @@ namespace Content.Client.Popups
|
||||
_aliveWorldLabels.Add(label);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Abstract Method Implementations
|
||||
|
||||
public override void PopupCursor(string message, Filter filter, PopupType type=PopupType.Small)
|
||||
public override void PopupCoordinates(string message, EntityCoordinates coordinates, PopupType type = PopupType.Small)
|
||||
{
|
||||
if (!filter.CheckPrediction)
|
||||
return;
|
||||
|
||||
PopupCursor(message, type);
|
||||
PopupMessage(message, type, coordinates, null);
|
||||
}
|
||||
|
||||
public override void PopupCoordinates(string message, EntityCoordinates coordinates, Filter filter, PopupType type=PopupType.Small)
|
||||
public override void PopupCoordinates(string message, EntityCoordinates coordinates, ICommonSession recipient, PopupType type = PopupType.Small)
|
||||
{
|
||||
if (!filter.CheckPrediction)
|
||||
return;
|
||||
if (_playerManager.LocalPlayer?.Session == recipient)
|
||||
PopupMessage(message, type, coordinates, null);
|
||||
}
|
||||
|
||||
public override void PopupCoordinates(string message, EntityCoordinates coordinates, EntityUid recipient, PopupType type = PopupType.Small)
|
||||
{
|
||||
if (_playerManager.LocalPlayer?.ControlledEntity == recipient)
|
||||
PopupMessage(message, type, coordinates, null);
|
||||
}
|
||||
|
||||
public override void PopupCursor(string message, PopupType type = PopupType.Small)
|
||||
{
|
||||
var label = new CursorPopupLabel(_inputManager.MouseScreenPosition)
|
||||
{
|
||||
Text = message,
|
||||
StyleClasses = { GetStyleClass(type) },
|
||||
};
|
||||
_userInterfaceManager.PopupRoot.AddChild(label);
|
||||
_aliveCursorLabels.Add(label);
|
||||
}
|
||||
|
||||
public override void PopupCursor(string message, ICommonSession recipient, PopupType type = PopupType.Small)
|
||||
{
|
||||
if (_playerManager.LocalPlayer?.Session == recipient)
|
||||
PopupCursor(message, type);
|
||||
}
|
||||
|
||||
public override void PopupCursor(string message, EntityUid recipient, PopupType type = PopupType.Small)
|
||||
{
|
||||
if (_playerManager.LocalPlayer?.ControlledEntity == recipient)
|
||||
PopupCursor(message, type);
|
||||
}
|
||||
|
||||
public override void PopupCoordinates(string message, EntityCoordinates coordinates, Filter filter, bool replayRecord, PopupType type = PopupType.Small)
|
||||
{
|
||||
PopupCoordinates(message, coordinates, type);
|
||||
}
|
||||
|
||||
public override void PopupEntity(string message, EntityUid uid, Filter filter, PopupType type=PopupType.Small)
|
||||
public override void PopupEntity(string message, EntityUid uid, EntityUid recipient, PopupType type = PopupType.Small)
|
||||
{
|
||||
if (!filter.CheckPrediction)
|
||||
if (_playerManager.LocalPlayer?.ControlledEntity == recipient)
|
||||
PopupCursor(message, type);
|
||||
}
|
||||
|
||||
public override void PopupEntity(string message, EntityUid uid, ICommonSession recipient, PopupType type = PopupType.Small)
|
||||
{
|
||||
if (_playerManager.LocalPlayer?.Session == recipient)
|
||||
PopupCursor(message, type);
|
||||
}
|
||||
|
||||
public override void PopupEntity(string message, EntityUid uid, Filter filter, bool recordReplay, PopupType type=PopupType.Small)
|
||||
{
|
||||
PopupEntity(message, uid, type);
|
||||
}
|
||||
|
||||
public override void PopupEntity(string message, EntityUid uid, PopupType type = PopupType.Small)
|
||||
{
|
||||
if (!EntityManager.EntityExists(uid))
|
||||
return;
|
||||
|
||||
PopupEntity(message, uid, type);
|
||||
var transform = EntityManager.GetComponent<TransformComponent>(uid);
|
||||
|
||||
PopupMessage(message, type, transform.Coordinates, uid);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -239,7 +239,7 @@ public sealed partial class MeleeWeaponSystem : SharedMeleeWeaponSystem
|
||||
return true;
|
||||
|
||||
if (Timing.IsFirstTimePredicted && HasComp<MobStateComponent>(ev.Target.Value))
|
||||
PopupSystem.PopupEntity(Loc.GetString("disarm-action-disarmable", ("targetName", ev.Target.Value)), ev.Target.Value, Filter.Local());
|
||||
PopupSystem.PopupEntity(Loc.GetString("disarm-action-disarmable", ("targetName", ev.Target.Value)), ev.Target.Value);
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -252,7 +252,7 @@ public sealed partial class MeleeWeaponSystem : SharedMeleeWeaponSystem
|
||||
if (!Timing.IsFirstTimePredicted || uid == null)
|
||||
return;
|
||||
|
||||
PopupSystem.PopupEntity(message, uid.Value, Filter.Local());
|
||||
PopupSystem.PopupEntity(message, uid.Value);
|
||||
}
|
||||
|
||||
private void OnMeleeLunge(MeleeLungeEvent ev)
|
||||
|
||||
@@ -227,7 +227,7 @@ public sealed partial class GunSystem : SharedGunSystem
|
||||
protected override void Popup(string message, EntityUid? uid, EntityUid? user)
|
||||
{
|
||||
if (uid == null || user == null || !Timing.IsFirstTimePredicted) return;
|
||||
PopupSystem.PopupEntity(message, uid.Value, Filter.Entities(user.Value));
|
||||
PopupSystem.PopupEntity(message, uid.Value, user.Value);
|
||||
}
|
||||
|
||||
protected override void CreateEffect(EntityUid uid, MuzzleFlashEvent message, EntityUid? user = null)
|
||||
|
||||
Reference in New Issue
Block a user