using Robust.Shared.Map;
using Robust.Shared.Player;
using Robust.Shared.Serialization;
namespace Content.Shared.Popups
{
///
/// System for displaying small text popups on users' screens.
///
public abstract class SharedPopupSystem : EntitySystem
{
///
/// Shows a popup at the local users' cursor. Does nothing on the server.
///
/// The message to display.
/// Used to customize how this popup should appear visually.
public abstract void PopupCursor(string message, PopupType type = PopupType.Small);
///
/// Shows a popup at a users' cursor.
///
/// The message to display.
/// Client that will see this popup.
/// Used to customize how this popup should appear visually.
public abstract void PopupCursor(string message, ICommonSession recipient, PopupType type = PopupType.Small);
///
/// Shows a popup at a users' cursor.
///
/// The message to display.
/// Client that will see this popup.
/// Used to customize how this popup should appear visually.
public abstract void PopupCursor(string message, EntityUid recipient, PopupType type = PopupType.Small);
///
/// Shows a popup at a world location to every entity in PVS range.
///
/// The message to display.
/// The coordinates where to display the message.
/// Used to customize how this popup should appear visually.
public abstract void PopupCoordinates(string message, EntityCoordinates coordinates, PopupType type = PopupType.Small);
///
/// Filtered variant of , which should only be used
/// if the filtering has to be more specific than simply PVS range based.
///
/// Filter for the players that will see the popup.
/// If true, this pop-up will be considered as a globally visible pop-up that gets shown during replays.
public abstract void PopupCoordinates(string message, EntityCoordinates coordinates, Filter filter, bool recordReplay, PopupType type = PopupType.Small);
///
/// Variant of that sends a pop-up to the player attached to some entity.
///
public abstract void PopupCoordinates(string message, EntityCoordinates coordinates, EntityUid recipient, PopupType type = PopupType.Small);
///
/// Variant of that sends a pop-up to a specific player.
///
public abstract void PopupCoordinates(string message, EntityCoordinates coordinates, ICommonSession recipient, PopupType type = PopupType.Small);
///
/// Shows a popup above an entity for every player in pvs range.
///
/// The message to display.
/// The UID of the entity.
/// Used to customize how this popup should appear visually.
public abstract void PopupEntity(string message, EntityUid uid, PopupType type=PopupType.Small);
///
/// Variant of that shows the popup only to some specific client.
///
public abstract void PopupEntity(string message, EntityUid uid, EntityUid recipient, PopupType type = PopupType.Small);
///
/// Variant of that shows the popup only to some specific client.
///
public abstract void PopupEntity(string message, EntityUid uid, ICommonSession recipient, PopupType type = PopupType.Small);
///
/// Filtered variant of , which should only be used
/// if the filtering has to be more specific than simply PVS range based.
///
public abstract void PopupEntity(string message, EntityUid uid, Filter filter, bool recordReplay, PopupType type = PopupType.Small);
///
/// Variant of that only runs on the client, outside of prediction.
/// Useful for shared code that is always ran by both sides to avoid duplicate popups.
///
public abstract void PopupClient(string message, EntityUid uid, EntityUid recipient, PopupType type = PopupType.Small);
}
///
/// Common base for all popup network events.
///
[Serializable, NetSerializable]
public abstract class PopupEvent : EntityEventArgs
{
public string Message { get; }
public PopupType Type { get; }
protected PopupEvent(string message, PopupType type)
{
Message = message;
Type = type;
}
}
///
/// Network event for displaying a popup on the user's cursor.
///
[Serializable, NetSerializable]
public sealed class PopupCursorEvent : PopupEvent
{
public PopupCursorEvent(string message, PopupType type) : base(message, type)
{
}
}
///
/// Network event for displaying a popup at a world location.
///
[Serializable, NetSerializable]
public sealed class PopupCoordinatesEvent : PopupEvent
{
public NetCoordinates Coordinates { get; }
public PopupCoordinatesEvent(string message, PopupType type, NetCoordinates coordinates) : base(message, type)
{
Coordinates = coordinates;
}
}
///
/// Network event for displaying a popup above an entity.
///
[Serializable, NetSerializable]
public sealed class PopupEntityEvent : PopupEvent
{
public NetEntity Uid { get; }
public PopupEntityEvent(string message, PopupType type, NetEntity uid) : base(message, type)
{
Uid = uid;
}
}
///
/// Used to determine how a popup should appear visually to the client. Caution variants simply have a red color.
///
///
/// Actions which can fail or succeed should use a smaller popup for failure and a larger popup for success.
/// Actions which have different popups for the user vs. others should use a larger popup for the user and a smaller popup for others.
/// Actions which result in harm or are otherwise dangerous should always show as the caution variant.
///
[Serializable, NetSerializable]
public enum PopupType : byte
{
///
/// Small popups are the default, and denote actions that may be spammable or are otherwise unimportant.
///
Small,
SmallCaution,
///
/// Medium popups should be used for actions which are not spammable but may not be particularly important.
///
Medium,
MediumCaution,
///
/// Large popups should be used for actions which may be important or very important to one or more users,
/// but is not life-threatening.
///
Large,
LargeCaution
}
}