Popup message notifications. (#125)

* Popup message system v1

* Networking for the popup notifications.

Ship it.
This commit is contained in:
Pieter-Jan Briers
2018-11-21 21:11:30 +01:00
committed by GitHub
parent b0f212bad5
commit f91488fa27
13 changed files with 324 additions and 1 deletions

View File

@@ -116,6 +116,7 @@
<Compile Include="GameObjects\Components\Damage\ResistanceSet.cs" />
<Compile Include="GameObjects\Components\Temperature\TemperatureComponent.cs" />
<Compile Include="Interfaces\GameObjects\IOnDamageBehavior.cs" />
<Compile Include="Interfaces\IServerNotifyManager.cs" />
<Compile Include="Mobs\Commands.cs" />
<Compile Include="Mobs\Mind.cs" />
<Compile Include="Mobs\Role.cs" />
@@ -127,6 +128,7 @@
<Compile Include="Interfaces\GameObjects\Components\Damage\IDamageableComponent.cs" />
<Compile Include="GameObjects\Components\Power\PoweredLightComponent.cs" />
<Compile Include="GameObjects\Components\Power\PowerDebugTool.cs" />
<Compile Include="ServerNotifyManager.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Content.Shared\Content.Shared.csproj">

View File

@@ -34,7 +34,9 @@ using Content.Server.GameObjects.EntitySystems;
using Content.Server.Mobs;
using Content.Server.Players;
using Content.Server.GameObjects.Components.Interactable;
using Content.Server.Interfaces;
using Content.Shared.GameObjects.Components.Inventory;
using Content.Shared.Interfaces;
namespace Content.Server
{
@@ -125,6 +127,12 @@ namespace Content.Server
factory.RegisterIgnore("ConstructionGhost");
factory.Register<MindComponent>();
IoCManager.Register<ISharedNotifyManager, ServerNotifyManager>();
IoCManager.Register<IServerNotifyManager, ServerNotifyManager>();
IoCManager.BuildGraph();
IoCManager.Resolve<IServerNotifyManager>().Initialize();
}
/// <inheritdoc />

View File

@@ -0,0 +1,9 @@
using Content.Shared.Interfaces;
namespace Content.Server.Interfaces
{
public interface IServerNotifyManager : ISharedNotifyManager
{
void Initialize();
}
}

View File

@@ -0,0 +1,63 @@
using Content.Server.Interfaces;
using Content.Shared;
using Content.Shared.Interfaces;
using SS14.Server.Interfaces.Console;
using SS14.Server.Interfaces.GameObjects;
using SS14.Server.Interfaces.Player;
using SS14.Shared.GameObjects;
using SS14.Shared.Interfaces.GameObjects;
using SS14.Shared.Interfaces.Network;
using SS14.Shared.IoC;
using SS14.Shared.Map;
using SS14.Shared.Utility;
namespace Content.Server
{
public class ServerNotifyManager : SharedNotifyManager, IServerNotifyManager
{
#pragma warning disable 649
[Dependency] private IServerNetManager _netManager;
#pragma warning restore 649
private bool _initialized;
public void Initialize()
{
DebugTools.Assert(!_initialized);
_netManager.RegisterNetMessage<MsgDoNotify>(nameof(MsgDoNotify));
_initialized = true;
}
public override void PopupMessage(GridLocalCoordinates coordinates, IEntity viewer, string message)
{
if (!viewer.TryGetComponent(out IActorComponent actor))
{
return;
}
var netMessage = _netManager.CreateNetMessage<MsgDoNotify>();
netMessage.Coordinates = coordinates;
netMessage.Message = message;
_netManager.ServerSendMessage(netMessage, actor.playerSession.ConnectedClient);
}
public class PopupMsgCommand : IClientCommand
{
public string Command => "srvpopupmsg";
public string Description => "";
public string Help => "";
public void Execute(IConsoleShell shell, IPlayerSession player, string[] args)
{
var entityMgr = IoCManager.Resolve<IEntityManager>();
var source = EntityUid.Parse(args[0]);
var viewer = EntityUid.Parse(args[1]);
var msg = args[2];
entityMgr.GetEntity(source).PopupMessage(entityMgr.GetEntity(viewer), msg);
}
}
}
}