Re-implement chat in content. (#198)
* OOC is a word. * Re-implement chat in content.
This commit is contained in:
committed by
GitHub
parent
51caae7ebe
commit
52af7d27da
157
Content.Client/Chat/ChatBox.cs
Normal file
157
Content.Client/Chat/ChatBox.cs
Normal file
@@ -0,0 +1,157 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using Content.Shared.Chat;
|
||||||
|
using SS14.Client.Console;
|
||||||
|
using SS14.Client.Graphics.Drawing;
|
||||||
|
using SS14.Client.Input;
|
||||||
|
using SS14.Client.UserInterface;
|
||||||
|
using SS14.Client.UserInterface.Controls;
|
||||||
|
using SS14.Shared.Maths;
|
||||||
|
using SS14.Shared.Utility;
|
||||||
|
|
||||||
|
namespace Content.Client.Chat
|
||||||
|
{
|
||||||
|
public class ChatBox : PanelContainer
|
||||||
|
{
|
||||||
|
protected override ResourcePath ScenePath => new ResourcePath("/Scenes/ChatBox/ChatBox.tscn");
|
||||||
|
|
||||||
|
public delegate void TextSubmitHandler(ChatBox chatBox, string text);
|
||||||
|
|
||||||
|
private const int MaxLinePixelLength = 500;
|
||||||
|
|
||||||
|
private readonly IList<string> _inputHistory = new List<string>();
|
||||||
|
|
||||||
|
public LineEdit Input { get; private set; }
|
||||||
|
private OutputPanel contents;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Index while cycling through the input history. -1 means not going through history.
|
||||||
|
/// </summary>
|
||||||
|
private int _inputIndex = -1;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Message that WAS being input before going through history began.
|
||||||
|
/// </summary>
|
||||||
|
private string _inputTemp;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Default formatting string for the ClientChatConsole.
|
||||||
|
/// </summary>
|
||||||
|
public string DefaultChatFormat { get; set; }
|
||||||
|
|
||||||
|
protected override void Initialize()
|
||||||
|
{
|
||||||
|
base.Initialize();
|
||||||
|
|
||||||
|
Input = GetChild<LineEdit>("VBoxContainer/Input");
|
||||||
|
Input.OnKeyDown += InputKeyDown;
|
||||||
|
Input.OnTextEntered += Input_OnTextEntered;
|
||||||
|
GetChild<Control>("VBoxContainer/Contents").Dispose();
|
||||||
|
|
||||||
|
contents = new OutputPanel
|
||||||
|
{
|
||||||
|
SizeFlagsVertical = SizeFlags.FillExpand,
|
||||||
|
};
|
||||||
|
GetChild("VBoxContainer").AddChild(contents);
|
||||||
|
contents.SetPositionInParent(0);
|
||||||
|
|
||||||
|
PanelOverride = new StyleBoxFlat {BackgroundColor = Color.Gray.WithAlpha(0.5f)};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void MouseDown(GUIMouseButtonEventArgs e)
|
||||||
|
{
|
||||||
|
base.MouseDown(e);
|
||||||
|
|
||||||
|
Input.GrabKeyboardFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InputKeyDown(GUIKeyEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Key == Keyboard.Key.Escape)
|
||||||
|
{
|
||||||
|
Input.ReleaseKeyboardFocus();
|
||||||
|
e.Handle();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.Key == Keyboard.Key.Up)
|
||||||
|
{
|
||||||
|
if (_inputIndex == -1 && _inputHistory.Count != 0)
|
||||||
|
{
|
||||||
|
_inputTemp = Input.Text;
|
||||||
|
_inputIndex++;
|
||||||
|
}
|
||||||
|
else if (_inputIndex + 1 < _inputHistory.Count)
|
||||||
|
{
|
||||||
|
_inputIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_inputIndex != -1)
|
||||||
|
{
|
||||||
|
Input.Text = _inputHistory[_inputIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
e.Handle();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.Key == Keyboard.Key.Down)
|
||||||
|
{
|
||||||
|
if (_inputIndex == 0)
|
||||||
|
{
|
||||||
|
Input.Text = _inputTemp;
|
||||||
|
_inputTemp = "";
|
||||||
|
_inputIndex--;
|
||||||
|
}
|
||||||
|
else if (_inputIndex != -1)
|
||||||
|
{
|
||||||
|
_inputIndex--;
|
||||||
|
Input.Text = _inputHistory[_inputIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
e.Handle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
base.Dispose(disposing);
|
||||||
|
|
||||||
|
if (disposing)
|
||||||
|
{
|
||||||
|
TextSubmitted = null;
|
||||||
|
Input = null;
|
||||||
|
contents = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public event TextSubmitHandler TextSubmitted;
|
||||||
|
|
||||||
|
public void AddLine(string message, ChatChannel channel, Color color)
|
||||||
|
{
|
||||||
|
if (Disposed)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var formatted = new FormattedMessage(3);
|
||||||
|
formatted.PushColor(color);
|
||||||
|
formatted.AddText(message);
|
||||||
|
formatted.Pop();
|
||||||
|
contents.AddMessage(formatted);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Input_OnTextEntered(LineEdit.LineEditEventArgs args)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrWhiteSpace(args.Text))
|
||||||
|
{
|
||||||
|
TextSubmitted?.Invoke(this, args.Text);
|
||||||
|
_inputHistory.Insert(0, args.Text);
|
||||||
|
}
|
||||||
|
|
||||||
|
_inputIndex = -1;
|
||||||
|
|
||||||
|
Input.Clear();
|
||||||
|
Input.ReleaseKeyboardFocus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
110
Content.Client/Chat/ChatManager.cs
Normal file
110
Content.Client/Chat/ChatManager.cs
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
using System;
|
||||||
|
using Content.Client.Interfaces.Chat;
|
||||||
|
using Content.Shared.Chat;
|
||||||
|
using SS14.Client.Console;
|
||||||
|
using SS14.Shared.Interfaces.GameObjects;
|
||||||
|
using SS14.Shared.Interfaces.Network;
|
||||||
|
using SS14.Shared.IoC;
|
||||||
|
using SS14.Shared.Log;
|
||||||
|
using SS14.Shared.Maths;
|
||||||
|
using SS14.Shared.Utility;
|
||||||
|
|
||||||
|
namespace Content.Client.Chat
|
||||||
|
{
|
||||||
|
internal sealed class ChatManager : IChatManager
|
||||||
|
{
|
||||||
|
private const char ConCmdSlash = '/';
|
||||||
|
private const char OOCAlias = '[';
|
||||||
|
private const char MeAlias = '@';
|
||||||
|
|
||||||
|
#pragma warning disable 649
|
||||||
|
[Dependency] private readonly IClientNetManager _netManager;
|
||||||
|
[Dependency] private readonly IClientConsole _console;
|
||||||
|
[Dependency] private readonly IEntityManager _entityManager;
|
||||||
|
#pragma warning restore 649
|
||||||
|
|
||||||
|
private ChatBox _currentChatBox;
|
||||||
|
|
||||||
|
public void Initialize()
|
||||||
|
{
|
||||||
|
_netManager.RegisterNetMessage<MsgChatMessage>(MsgChatMessage.NAME, _onChatMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetChatBox(ChatBox chatBox)
|
||||||
|
{
|
||||||
|
if (_currentChatBox != null)
|
||||||
|
{
|
||||||
|
_currentChatBox.TextSubmitted -= _onChatBoxTextSubmitted;
|
||||||
|
}
|
||||||
|
|
||||||
|
_currentChatBox = chatBox;
|
||||||
|
if (_currentChatBox != null)
|
||||||
|
{
|
||||||
|
_currentChatBox.TextSubmitted += _onChatBoxTextSubmitted;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void _onChatMessage(MsgChatMessage message)
|
||||||
|
{
|
||||||
|
Logger.Debug($"{message.Channel}: {message.Message}");
|
||||||
|
|
||||||
|
var color = Color.DarkGray;
|
||||||
|
var messageText = message.Message;
|
||||||
|
if (!string.IsNullOrEmpty(message.MessageWrap))
|
||||||
|
{
|
||||||
|
messageText = string.Format(message.MessageWrap, messageText);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (message.Channel)
|
||||||
|
{
|
||||||
|
case ChatChannel.Server:
|
||||||
|
color = Color.Orange;
|
||||||
|
break;
|
||||||
|
case ChatChannel.OOC:
|
||||||
|
color = Color.LightSkyBlue;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
_currentChatBox?.AddLine(messageText, message.Channel, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void _onChatBoxTextSubmitted(ChatBox chatBox, string text)
|
||||||
|
{
|
||||||
|
DebugTools.Assert(chatBox == _currentChatBox);
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(text))
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch (text[0])
|
||||||
|
{
|
||||||
|
case ConCmdSlash:
|
||||||
|
{
|
||||||
|
// run locally
|
||||||
|
var conInput = text.Substring(1);
|
||||||
|
_console.ProcessCommand(conInput);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case OOCAlias:
|
||||||
|
{
|
||||||
|
var conInput = text.Substring(1);
|
||||||
|
_console.ProcessCommand($"ooc \"{conInput}\"");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MeAlias:
|
||||||
|
{
|
||||||
|
var conInput = text.Substring(1);
|
||||||
|
_console.ProcessCommand($"me \"{conInput}\"");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
var conInput = _currentChatBox.DefaultChatFormat != null
|
||||||
|
? string.Format(_currentChatBox.DefaultChatFormat, text)
|
||||||
|
: text;
|
||||||
|
_console.ProcessCommand(conInput);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -71,6 +71,8 @@
|
|||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Chat\ChatBox.cs" />
|
||||||
|
<Compile Include="Chat\ChatManager.cs" />
|
||||||
<Compile Include="Commands\DebugCommands.cs" />
|
<Compile Include="Commands\DebugCommands.cs" />
|
||||||
<Compile Include="EntryPoint.cs" />
|
<Compile Include="EntryPoint.cs" />
|
||||||
<Compile Include="GameObjects\Components\Actor\CharacterInterface.cs" />
|
<Compile Include="GameObjects\Components\Actor\CharacterInterface.cs" />
|
||||||
@@ -101,6 +103,7 @@
|
|||||||
<Compile Include="Graphics\Overlays\CircleMaskOverlay.cs" />
|
<Compile Include="Graphics\Overlays\CircleMaskOverlay.cs" />
|
||||||
<Compile Include="Graphics\Overlays\GradientCircleMask.cs" />
|
<Compile Include="Graphics\Overlays\GradientCircleMask.cs" />
|
||||||
<Compile Include="Input\ContentContexts.cs" />
|
<Compile Include="Input\ContentContexts.cs" />
|
||||||
|
<Compile Include="Interfaces\Chat\IChatManager.cs" />
|
||||||
<Compile Include="Interfaces\IClientGameTicker.cs" />
|
<Compile Include="Interfaces\IClientGameTicker.cs" />
|
||||||
<Compile Include="Interfaces\IClientNotifyManager.cs" />
|
<Compile Include="Interfaces\IClientNotifyManager.cs" />
|
||||||
<Compile Include="ClientNotifyManager.cs" />
|
<Compile Include="ClientNotifyManager.cs" />
|
||||||
|
|||||||
@@ -25,9 +25,11 @@ using SS14.Shared.Interfaces.GameObjects;
|
|||||||
using SS14.Shared.IoC;
|
using SS14.Shared.IoC;
|
||||||
using SS14.Shared.Prototypes;
|
using SS14.Shared.Prototypes;
|
||||||
using System;
|
using System;
|
||||||
|
using Content.Client.Chat;
|
||||||
using Content.Client.GameObjects.Components;
|
using Content.Client.GameObjects.Components;
|
||||||
using Content.Client.GameObjects.Components.Mobs;
|
using Content.Client.GameObjects.Components.Mobs;
|
||||||
using Content.Client.GameObjects.Components.Sound;
|
using Content.Client.GameObjects.Components.Sound;
|
||||||
|
using Content.Client.Interfaces.Chat;
|
||||||
using Content.Client.UserInterface;
|
using Content.Client.UserInterface;
|
||||||
using Content.Shared.GameObjects.Components.Markers;
|
using Content.Shared.GameObjects.Components.Markers;
|
||||||
using Content.Shared.GameObjects.Components.Mobs;
|
using Content.Shared.GameObjects.Components.Mobs;
|
||||||
@@ -124,6 +126,7 @@ namespace Content.Client
|
|||||||
IoCManager.Register<ISharedNotifyManager, ClientNotifyManager>();
|
IoCManager.Register<ISharedNotifyManager, ClientNotifyManager>();
|
||||||
IoCManager.Register<IClientGameTicker, ClientGameTicker>();
|
IoCManager.Register<IClientGameTicker, ClientGameTicker>();
|
||||||
IoCManager.Register<IParallaxManager, ParallaxManager>();
|
IoCManager.Register<IParallaxManager, ParallaxManager>();
|
||||||
|
IoCManager.Register<IChatManager, ChatManager>();
|
||||||
IoCManager.BuildGraph();
|
IoCManager.BuildGraph();
|
||||||
|
|
||||||
IoCManager.Resolve<IParallaxManager>().LoadParallax();
|
IoCManager.Resolve<IParallaxManager>().LoadParallax();
|
||||||
@@ -181,6 +184,7 @@ namespace Content.Client
|
|||||||
IoCManager.Resolve<IClientNotifyManager>().Initialize();
|
IoCManager.Resolve<IClientNotifyManager>().Initialize();
|
||||||
IoCManager.Resolve<IClientGameTicker>().Initialize();
|
IoCManager.Resolve<IClientGameTicker>().Initialize();
|
||||||
IoCManager.Resolve<IOverlayManager>().AddOverlay(new ParallaxOverlay());
|
IoCManager.Resolve<IOverlayManager>().AddOverlay(new ParallaxOverlay());
|
||||||
|
IoCManager.Resolve<IChatManager>().Initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update(AssemblyLoader.UpdateLevel level, float frameTime)
|
public override void Update(AssemblyLoader.UpdateLevel level, float frameTime)
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using Content.Client.Chat;
|
||||||
using Content.Client.Interfaces;
|
using Content.Client.Interfaces;
|
||||||
|
using Content.Client.Interfaces.Chat;
|
||||||
using Content.Client.UserInterface;
|
using Content.Client.UserInterface;
|
||||||
using Content.Shared;
|
using Content.Shared;
|
||||||
|
using Content.Shared.Input;
|
||||||
using SS14.Client;
|
using SS14.Client;
|
||||||
using SS14.Client.Console;
|
using SS14.Client.Console;
|
||||||
using SS14.Client.Interfaces;
|
using SS14.Client.Interfaces;
|
||||||
using SS14.Client.Interfaces.Input;
|
using SS14.Client.Interfaces.Input;
|
||||||
using SS14.Client.Interfaces.UserInterface;
|
using SS14.Client.Interfaces.UserInterface;
|
||||||
using SS14.Client.UserInterface.CustomControls;
|
|
||||||
using SS14.Shared.Input;
|
using SS14.Shared.Input;
|
||||||
using SS14.Shared.Interfaces.Network;
|
using SS14.Shared.Interfaces.Network;
|
||||||
using SS14.Shared.IoC;
|
using SS14.Shared.IoC;
|
||||||
@@ -21,15 +23,16 @@ namespace Content.Client.GameTicking
|
|||||||
#pragma warning disable 649
|
#pragma warning disable 649
|
||||||
[Dependency] private IClientNetManager _netManager;
|
[Dependency] private IClientNetManager _netManager;
|
||||||
[Dependency] private IUserInterfaceManager _userInterfaceManager;
|
[Dependency] private IUserInterfaceManager _userInterfaceManager;
|
||||||
[Dependency] private IClientChatConsole _chatConsole;
|
|
||||||
[Dependency] private IInputManager _inputManager;
|
[Dependency] private IInputManager _inputManager;
|
||||||
[Dependency] private IBaseClient _baseClient;
|
[Dependency] private IBaseClient _baseClient;
|
||||||
|
[Dependency] private IChatManager _chatManager;
|
||||||
|
[Dependency] private IClientConsole _console;
|
||||||
#pragma warning restore 649
|
#pragma warning restore 649
|
||||||
|
|
||||||
[ViewVariables] private bool _areWeReady;
|
[ViewVariables] private bool _areWeReady;
|
||||||
[ViewVariables] private bool _initialized;
|
[ViewVariables] private bool _initialized;
|
||||||
[ViewVariables] private TickerState _tickerState;
|
[ViewVariables] private TickerState _tickerState;
|
||||||
[ViewVariables] private Chatbox _gameChat;
|
[ViewVariables] private ChatBox _gameChat;
|
||||||
[ViewVariables] private LobbyGui _lobby;
|
[ViewVariables] private LobbyGui _lobby;
|
||||||
[ViewVariables] private bool _gameStarted;
|
[ViewVariables] private bool _gameStarted;
|
||||||
[ViewVariables] private DateTime _startTime;
|
[ViewVariables] private DateTime _startTime;
|
||||||
@@ -135,8 +138,6 @@ namespace Content.Client.GameTicking
|
|||||||
|
|
||||||
if (_gameChat != null)
|
if (_gameChat != null)
|
||||||
{
|
{
|
||||||
_gameChat.TextSubmitted -= _chatConsole.ParseChatMessage;
|
|
||||||
_chatConsole.AddString -= _gameChat.AddLine;
|
|
||||||
_gameChat.Dispose();
|
_gameChat.Dispose();
|
||||||
_gameChat = null;
|
_gameChat = null;
|
||||||
}
|
}
|
||||||
@@ -146,19 +147,21 @@ namespace Content.Client.GameTicking
|
|||||||
_lobby = new LobbyGui();
|
_lobby = new LobbyGui();
|
||||||
_userInterfaceManager.StateRoot.AddChild(_lobby);
|
_userInterfaceManager.StateRoot.AddChild(_lobby);
|
||||||
|
|
||||||
_lobby.Chat.TextSubmitted += _chatConsole.ParseChatMessage;
|
_chatManager.SetChatBox(_lobby.Chat);
|
||||||
_chatConsole.AddString += _lobby.Chat.AddLine;
|
|
||||||
_lobby.Chat.DefaultChatFormat = "ooc \"{0}\"";
|
_lobby.Chat.DefaultChatFormat = "ooc \"{0}\"";
|
||||||
|
|
||||||
_lobby.ServerName.Text = _baseClient.GameInfo.ServerName;
|
_lobby.ServerName.Text = _baseClient.GameInfo.ServerName;
|
||||||
|
|
||||||
_inputManager.SetInputCommand(EngineKeyFunctions.FocusChat,
|
_inputManager.SetInputCommand(ContentKeyFunctions.FocusChat,
|
||||||
InputCmdHandler.FromDelegate(session => { _lobby.Chat.Input.GrabKeyboardFocus(); }));
|
InputCmdHandler.FromDelegate(session =>
|
||||||
|
{
|
||||||
|
_lobby.Chat.Input.IgnoreNext = true;
|
||||||
|
_lobby.Chat.Input.GrabKeyboardFocus();
|
||||||
|
}));
|
||||||
|
|
||||||
_updateLobbyUi();
|
_updateLobbyUi();
|
||||||
|
|
||||||
_lobby.ObserveButton.OnPressed += args => { _chatConsole.ProcessCommand("observe"); };
|
_lobby.ObserveButton.OnPressed += args => _console.ProcessCommand("observe");
|
||||||
|
|
||||||
_lobby.ReadyButton.OnPressed += args =>
|
_lobby.ReadyButton.OnPressed += args =>
|
||||||
{
|
{
|
||||||
if (!_gameStarted)
|
if (!_gameStarted)
|
||||||
@@ -166,7 +169,7 @@ namespace Content.Client.GameTicking
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_chatConsole.ProcessCommand("joingame");
|
_console.ProcessCommand("joingame");
|
||||||
};
|
};
|
||||||
|
|
||||||
_lobby.ReadyButton.OnToggled += args =>
|
_lobby.ReadyButton.OnToggled += args =>
|
||||||
@@ -176,10 +179,10 @@ namespace Content.Client.GameTicking
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_chatConsole.ProcessCommand($"toggleready {args.Pressed}");
|
_console.ProcessCommand($"toggleready {args.Pressed}");
|
||||||
};
|
};
|
||||||
|
|
||||||
_lobby.LeaveButton.OnPressed += args => _chatConsole.ProcessCommand("disconnect");
|
_lobby.LeaveButton.OnPressed += args => _console.ProcessCommand("disconnect");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void _joinGame(MsgTickerJoinGame message)
|
private void _joinGame(MsgTickerJoinGame message)
|
||||||
@@ -193,19 +196,20 @@ namespace Content.Client.GameTicking
|
|||||||
|
|
||||||
if (_lobby != null)
|
if (_lobby != null)
|
||||||
{
|
{
|
||||||
_lobby.Chat.TextSubmitted -= _chatConsole.ParseChatMessage;
|
|
||||||
_chatConsole.AddString -= _lobby.Chat.AddLine;
|
|
||||||
_lobby.Dispose();
|
_lobby.Dispose();
|
||||||
_lobby = null;
|
_lobby = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
_inputManager.SetInputCommand(EngineKeyFunctions.FocusChat,
|
_inputManager.SetInputCommand(ContentKeyFunctions.FocusChat,
|
||||||
InputCmdHandler.FromDelegate(session => { _gameChat.Input.GrabKeyboardFocus(); }));
|
InputCmdHandler.FromDelegate(session =>
|
||||||
|
{
|
||||||
|
_lobby.Chat.Input.IgnoreNext = true;
|
||||||
|
_gameChat.Input.GrabKeyboardFocus();
|
||||||
|
}));
|
||||||
|
|
||||||
_gameChat = new Chatbox();
|
_gameChat = new ChatBox();
|
||||||
_userInterfaceManager.StateRoot.AddChild(_gameChat);
|
_userInterfaceManager.StateRoot.AddChild(_gameChat);
|
||||||
_gameChat.TextSubmitted += _chatConsole.ParseChatMessage;
|
_chatManager.SetChatBox(_gameChat);
|
||||||
_chatConsole.AddString += _gameChat.AddLine;
|
|
||||||
_gameChat.DefaultChatFormat = "say \"{0}\"";
|
_gameChat.DefaultChatFormat = "say \"{0}\"";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ namespace Content.Client.Input
|
|||||||
{
|
{
|
||||||
public static void SetupContexts(IInputContextContainer contexts)
|
public static void SetupContexts(IInputContextContainer contexts)
|
||||||
{
|
{
|
||||||
|
var common = contexts.GetContext("common");
|
||||||
|
common.AddFunction(ContentKeyFunctions.FocusChat);
|
||||||
|
|
||||||
var human = contexts.GetContext("human");
|
var human = contexts.GetContext("human");
|
||||||
human.AddFunction(ContentKeyFunctions.SwapHands);
|
human.AddFunction(ContentKeyFunctions.SwapHands);
|
||||||
human.AddFunction(ContentKeyFunctions.Drop);
|
human.AddFunction(ContentKeyFunctions.Drop);
|
||||||
|
|||||||
11
Content.Client/Interfaces/Chat/IChatManager.cs
Normal file
11
Content.Client/Interfaces/Chat/IChatManager.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
using Content.Client.Chat;
|
||||||
|
|
||||||
|
namespace Content.Client.Interfaces.Chat
|
||||||
|
{
|
||||||
|
public interface IChatManager
|
||||||
|
{
|
||||||
|
void Initialize();
|
||||||
|
|
||||||
|
void SetChatBox(ChatBox chatBox);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using Content.Client.Chat;
|
||||||
using SS14.Client.UserInterface;
|
using SS14.Client.UserInterface;
|
||||||
using SS14.Client.UserInterface.Controls;
|
using SS14.Client.UserInterface.Controls;
|
||||||
using SS14.Client.UserInterface.CustomControls;
|
using SS14.Client.UserInterface.CustomControls;
|
||||||
@@ -20,14 +21,14 @@ namespace Content.Client.UserInterface
|
|||||||
|
|
||||||
public Button LeaveButton => GetChild<Button>("Panel/VBoxContainer/TitleContainer/LeaveButton");
|
public Button LeaveButton => GetChild<Button>("Panel/VBoxContainer/TitleContainer/LeaveButton");
|
||||||
|
|
||||||
public Chatbox Chat { get; private set; }
|
public ChatBox Chat { get; private set; }
|
||||||
|
|
||||||
protected override void Initialize()
|
protected override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
var chatContainer = GetChild("Panel/VBoxContainer/HBoxContainer/LeftVBox");
|
var chatContainer = GetChild("Panel/VBoxContainer/HBoxContainer/LeftVBox");
|
||||||
Chat = new Chatbox();
|
Chat = new ChatBox();
|
||||||
chatContainer.AddChild(Chat);
|
chatContainer.AddChild(Chat);
|
||||||
Chat.SizeFlagsVertical = SizeFlags.FillExpand;
|
Chat.SizeFlagsVertical = SizeFlags.FillExpand;
|
||||||
}
|
}
|
||||||
|
|||||||
43
Content.Server/Chat/ChatCommands.cs
Normal file
43
Content.Server/Chat/ChatCommands.cs
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
using Content.Server.Interfaces.Chat;
|
||||||
|
using SS14.Server.Interfaces.Console;
|
||||||
|
using SS14.Server.Interfaces.Player;
|
||||||
|
using SS14.Shared.Enums;
|
||||||
|
using SS14.Shared.IoC;
|
||||||
|
|
||||||
|
namespace Content.Server.Chat
|
||||||
|
{
|
||||||
|
internal class SayCommand : IClientCommand
|
||||||
|
{
|
||||||
|
public string Command => "say";
|
||||||
|
public string Description => "Send chat messages to the local channel or a specified radio channel.";
|
||||||
|
public string Help => "say <text>";
|
||||||
|
|
||||||
|
public void Execute(IConsoleShell shell, IPlayerSession player, string[] args)
|
||||||
|
{
|
||||||
|
if (player.Status != SessionStatus.InGame || !player.AttachedEntityUid.HasValue)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (args.Length < 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var chat = IoCManager.Resolve<IChatManager>();
|
||||||
|
|
||||||
|
var message = string.Join(" ", args);
|
||||||
|
|
||||||
|
chat.EntitySay(player.AttachedEntity, message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class OOCCommand : IClientCommand
|
||||||
|
{
|
||||||
|
public string Command => "ooc";
|
||||||
|
public string Description => "Send Out of Character chat messages.";
|
||||||
|
public string Help => "ooc <text>";
|
||||||
|
|
||||||
|
public void Execute(IConsoleShell shell, IPlayerSession player, string[] args)
|
||||||
|
{
|
||||||
|
var chat = IoCManager.Resolve<IChatManager>();
|
||||||
|
chat.SendOOC(player, string.Join(" ", args));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
68
Content.Server/Chat/ChatManager.cs
Normal file
68
Content.Server/Chat/ChatManager.cs
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
using System.Linq;
|
||||||
|
using Content.Server.Interfaces.Chat;
|
||||||
|
using Content.Shared.Chat;
|
||||||
|
using SS14.Server.Interfaces.Player;
|
||||||
|
using SS14.Shared.Interfaces.GameObjects;
|
||||||
|
using SS14.Shared.Interfaces.Network;
|
||||||
|
using SS14.Shared.Interfaces.Resources;
|
||||||
|
using SS14.Shared.IoC;
|
||||||
|
|
||||||
|
namespace Content.Server.Chat
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Dispatches chat messages to clients.
|
||||||
|
/// </summary>
|
||||||
|
internal sealed class ChatManager : IChatManager
|
||||||
|
{
|
||||||
|
private const int VoiceRange = 7; // how far voice goes in world units
|
||||||
|
|
||||||
|
#pragma warning disable 649
|
||||||
|
[Dependency] private readonly IServerNetManager _netManager;
|
||||||
|
[Dependency] private readonly IPlayerManager _playerManager;
|
||||||
|
#pragma warning restore 649
|
||||||
|
|
||||||
|
public void Initialize()
|
||||||
|
{
|
||||||
|
_netManager.RegisterNetMessage<MsgChatMessage>(MsgChatMessage.NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DispatchServerAnnouncement(string message)
|
||||||
|
{
|
||||||
|
var msg = _netManager.CreateNetMessage<MsgChatMessage>();
|
||||||
|
msg.Channel = ChatChannel.Server;
|
||||||
|
msg.Message = message;
|
||||||
|
msg.MessageWrap = "SERVER: {0}";
|
||||||
|
_netManager.ServerSendToAll(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DispatchServerMessage(IPlayerSession player, string message)
|
||||||
|
{
|
||||||
|
var msg = _netManager.CreateNetMessage<MsgChatMessage>();
|
||||||
|
msg.Channel = ChatChannel.Server;
|
||||||
|
msg.Message = message;
|
||||||
|
msg.MessageWrap = "SERVER: {0}";
|
||||||
|
_netManager.ServerSendMessage(msg, player.ConnectedClient);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void EntitySay(IEntity source, string message)
|
||||||
|
{
|
||||||
|
var pos = source.Transform.GridPosition;
|
||||||
|
var clients = _playerManager.GetPlayersInRange(pos, VoiceRange).Select(p => p.ConnectedClient);
|
||||||
|
|
||||||
|
var msg = _netManager.CreateNetMessage<MsgChatMessage>();
|
||||||
|
msg.Channel = ChatChannel.Local;
|
||||||
|
msg.Message = message;
|
||||||
|
msg.MessageWrap = $"{source.Name} says, \"{{0}}\"";
|
||||||
|
_netManager.ServerSendToMany(msg, clients.ToList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SendOOC(IPlayerSession player, string message)
|
||||||
|
{
|
||||||
|
var msg = _netManager.CreateNetMessage<MsgChatMessage>();
|
||||||
|
msg.Channel = ChatChannel.OOC;
|
||||||
|
msg.Message = message;
|
||||||
|
msg.MessageWrap = $"OOC: {player.SessionId}: {{0}}";
|
||||||
|
_netManager.ServerSendToAll(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -65,6 +65,8 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Administration\AGhost.cs" />
|
<Compile Include="Administration\AGhost.cs" />
|
||||||
<Compile Include="AI\AimShootLifeProcessor.cs" />
|
<Compile Include="AI\AimShootLifeProcessor.cs" />
|
||||||
|
<Compile Include="Chat\ChatCommands.cs" />
|
||||||
|
<Compile Include="Chat\ChatManager.cs" />
|
||||||
<Compile Include="EntryPoint.cs" />
|
<Compile Include="EntryPoint.cs" />
|
||||||
<Compile Include="GameObjects\Components\CatwalkComponent.cs" />
|
<Compile Include="GameObjects\Components\CatwalkComponent.cs" />
|
||||||
<Compile Include="GameObjects\Components\Damage\DamageThreshold.cs" />
|
<Compile Include="GameObjects\Components\Damage\DamageThreshold.cs" />
|
||||||
@@ -131,6 +133,8 @@
|
|||||||
<Compile Include="GameTicking\GamePreset.cs" />
|
<Compile Include="GameTicking\GamePreset.cs" />
|
||||||
<Compile Include="GameTicking\GamePresets\PresetTraitor.cs" />
|
<Compile Include="GameTicking\GamePresets\PresetTraitor.cs" />
|
||||||
<Compile Include="GameTicking\GameTicker.cs" />
|
<Compile Include="GameTicking\GameTicker.cs" />
|
||||||
|
<Compile Include="Interfaces\Chat\IChatCommand.cs" />
|
||||||
|
<Compile Include="Interfaces\Chat\IChatManager.cs" />
|
||||||
<Compile Include="Interfaces\GameObjects\Components\Items\IHandsComponent.cs" />
|
<Compile Include="Interfaces\GameObjects\Components\Items\IHandsComponent.cs" />
|
||||||
<Compile Include="GameObjects\Components\GUI\ServerHandsComponent.cs" />
|
<Compile Include="GameObjects\Components\GUI\ServerHandsComponent.cs" />
|
||||||
<Compile Include="GameObjects\Components\GUI\InventoryComponent.cs" />
|
<Compile Include="GameObjects\Components\GUI\InventoryComponent.cs" />
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Content.Server.GameObjects;
|
using Content.Server.Chat;
|
||||||
|
using Content.Server.GameObjects;
|
||||||
using Content.Server.GameObjects.Components;
|
using Content.Server.GameObjects.Components;
|
||||||
using Content.Server.GameObjects.Components.Power;
|
using Content.Server.GameObjects.Components.Power;
|
||||||
using Content.Server.GameObjects.Components.Interactable.Tools;
|
using Content.Server.GameObjects.Components.Interactable.Tools;
|
||||||
@@ -6,7 +7,6 @@ using Content.Server.Interfaces.GameObjects;
|
|||||||
using Content.Server.Placement;
|
using Content.Server.Placement;
|
||||||
using SS14.Server;
|
using SS14.Server;
|
||||||
using SS14.Server.Interfaces;
|
using SS14.Server.Interfaces;
|
||||||
using SS14.Server.Interfaces.Chat;
|
|
||||||
using SS14.Server.Interfaces.Maps;
|
using SS14.Server.Interfaces.Maps;
|
||||||
using SS14.Server.Interfaces.Player;
|
using SS14.Server.Interfaces.Player;
|
||||||
using SS14.Server.Player;
|
using SS14.Server.Player;
|
||||||
@@ -48,6 +48,7 @@ using SS14.Server.Interfaces.ServerStatus;
|
|||||||
using SS14.Shared.Timing;
|
using SS14.Shared.Timing;
|
||||||
using Content.Server.GameObjects.Components.Destructible;
|
using Content.Server.GameObjects.Components.Destructible;
|
||||||
using Content.Server.GameObjects.Components.Movement;
|
using Content.Server.GameObjects.Components.Movement;
|
||||||
|
using Content.Server.Interfaces.Chat;
|
||||||
using Content.Server.Interfaces.GameObjects.Components.Movement;
|
using Content.Server.Interfaces.GameObjects.Components.Movement;
|
||||||
|
|
||||||
namespace Content.Server
|
namespace Content.Server
|
||||||
@@ -156,11 +157,13 @@ namespace Content.Server
|
|||||||
IoCManager.Register<ISharedNotifyManager, ServerNotifyManager>();
|
IoCManager.Register<ISharedNotifyManager, ServerNotifyManager>();
|
||||||
IoCManager.Register<IServerNotifyManager, ServerNotifyManager>();
|
IoCManager.Register<IServerNotifyManager, ServerNotifyManager>();
|
||||||
IoCManager.Register<IGameTicker, GameTicker>();
|
IoCManager.Register<IGameTicker, GameTicker>();
|
||||||
|
IoCManager.Register<IChatManager, ChatManager>();
|
||||||
IoCManager.BuildGraph();
|
IoCManager.BuildGraph();
|
||||||
|
|
||||||
_gameTicker = IoCManager.Resolve<IGameTicker>();
|
_gameTicker = IoCManager.Resolve<IGameTicker>();
|
||||||
|
|
||||||
IoCManager.Resolve<IServerNotifyManager>().Initialize();
|
IoCManager.Resolve<IServerNotifyManager>().Initialize();
|
||||||
|
IoCManager.Resolve<IChatManager>().Initialize();
|
||||||
|
|
||||||
var playerManager = IoCManager.Resolve<IPlayerManager>();
|
var playerManager = IoCManager.Resolve<IPlayerManager>();
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ using System;
|
|||||||
using Content.Server.GameObjects.Components.Interactable;
|
using Content.Server.GameObjects.Components.Interactable;
|
||||||
using Content.Server.GameObjects.Components.Sound;
|
using Content.Server.GameObjects.Components.Sound;
|
||||||
using Content.Shared.GameObjects;
|
using Content.Shared.GameObjects;
|
||||||
using SS14.Server.Chat;
|
|
||||||
using SS14.Server.GameObjects.Components.Container;
|
using SS14.Server.GameObjects.Components.Container;
|
||||||
using SS14.Server.GameObjects.EntitySystems;
|
using SS14.Server.GameObjects.EntitySystems;
|
||||||
using SS14.Shared.Interfaces.GameObjects;
|
using SS14.Shared.Interfaces.GameObjects;
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ using System.Text;
|
|||||||
using Content.Shared.GameObjects.EntitySystemMessages;
|
using Content.Shared.GameObjects.EntitySystemMessages;
|
||||||
using Content.Shared.Input;
|
using Content.Shared.Input;
|
||||||
using SS14.Server.GameObjects.EntitySystems;
|
using SS14.Server.GameObjects.EntitySystems;
|
||||||
using SS14.Server.Interfaces.Chat;
|
|
||||||
using SS14.Server.Interfaces.Player;
|
using SS14.Server.Interfaces.Player;
|
||||||
using SS14.Shared.GameObjects;
|
using SS14.Shared.GameObjects;
|
||||||
using SS14.Shared.GameObjects.Systems;
|
using SS14.Shared.GameObjects.Systems;
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ using System.Linq;
|
|||||||
using Content.Server.GameObjects;
|
using Content.Server.GameObjects;
|
||||||
using Content.Server.GameObjects.Components.Markers;
|
using Content.Server.GameObjects.Components.Markers;
|
||||||
using Content.Server.GameTicking.GamePresets;
|
using Content.Server.GameTicking.GamePresets;
|
||||||
|
using Content.Server.Interfaces.Chat;
|
||||||
using Content.Server.Interfaces.GameTicking;
|
using Content.Server.Interfaces.GameTicking;
|
||||||
using Content.Server.Mobs;
|
using Content.Server.Mobs;
|
||||||
using Content.Server.Players;
|
using Content.Server.Players;
|
||||||
using Content.Shared;
|
using Content.Shared;
|
||||||
using Content.Shared.GameObjects.Components.Inventory;
|
using Content.Shared.GameObjects.Components.Inventory;
|
||||||
using SS14.Server.Interfaces.Chat;
|
|
||||||
using SS14.Server.Interfaces.Console;
|
using SS14.Server.Interfaces.Console;
|
||||||
using SS14.Server.Interfaces.Maps;
|
using SS14.Server.Interfaces.Maps;
|
||||||
using SS14.Server.Interfaces.Player;
|
using SS14.Server.Interfaces.Player;
|
||||||
@@ -321,8 +321,7 @@ namespace Content.Server.GameTicking
|
|||||||
// timer time must be > tick length
|
// timer time must be > tick length
|
||||||
Timer.Spawn(0, args.Session.JoinGame);
|
Timer.Spawn(0, args.Session.JoinGame);
|
||||||
|
|
||||||
_chatManager.DispatchMessage(ChatChannel.Server, "Game: Player joined server!",
|
_chatManager.DispatchServerAnnouncement($"Player {args.Session.SessionId} joined server!");
|
||||||
args.Session.SessionId);
|
|
||||||
|
|
||||||
if (LobbyEnabled && _roundStartCountdownHasNotStartedYetDueToNoPlayers)
|
if (LobbyEnabled && _roundStartCountdownHasNotStartedYetDueToNoPlayers)
|
||||||
{
|
{
|
||||||
@@ -360,8 +359,7 @@ namespace Content.Server.GameTicking
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_chatManager.DispatchMessage(ChatChannel.Server, "Game: Player joined Game!",
|
_chatManager.DispatchServerAnnouncement($"Player {args.Session.SessionId} joined game!");
|
||||||
args.Session.SessionId);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -372,7 +370,7 @@ namespace Content.Server.GameTicking
|
|||||||
_playersInLobby.Remove(session);
|
_playersInLobby.Remove(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
_chatManager.DispatchMessage(ChatChannel.Server, "Game: Player left!", args.Session.SessionId);
|
_chatManager.DispatchServerAnnouncement($"Player {args.Session.SessionId} left server!");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
10
Content.Server/Interfaces/Chat/IChatCommand.cs
Normal file
10
Content.Server/Interfaces/Chat/IChatCommand.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
using SS14.Shared.Console;
|
||||||
|
using SS14.Shared.Interfaces.Network;
|
||||||
|
|
||||||
|
namespace Content.Server.Interfaces.Chat
|
||||||
|
{
|
||||||
|
public interface IChatCommand : ICommand
|
||||||
|
{
|
||||||
|
void Execute(IChatManager manager, INetChannel client, params string[] args);
|
||||||
|
}
|
||||||
|
}
|
||||||
21
Content.Server/Interfaces/Chat/IChatManager.cs
Normal file
21
Content.Server/Interfaces/Chat/IChatManager.cs
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
using SS14.Server.Interfaces.Player;
|
||||||
|
using SS14.Shared.Interfaces.GameObjects;
|
||||||
|
|
||||||
|
namespace Content.Server.Interfaces.Chat
|
||||||
|
{
|
||||||
|
public interface IChatManager
|
||||||
|
{
|
||||||
|
void Initialize();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Dispatch a server announcement to every connected player.
|
||||||
|
/// </summary>
|
||||||
|
void DispatchServerAnnouncement(string message);
|
||||||
|
|
||||||
|
void DispatchServerMessage(IPlayerSession player, string message);
|
||||||
|
|
||||||
|
void EntitySay(IEntity source, string message);
|
||||||
|
|
||||||
|
void SendOOC(IPlayerSession player, string message);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
using SS14.Server.Interfaces.Chat;
|
using Content.Server.Interfaces.Chat;
|
||||||
using SS14.Shared.Console;
|
using SS14.Shared.Console;
|
||||||
using SS14.Shared.IoC;
|
using SS14.Shared.IoC;
|
||||||
|
|
||||||
@@ -17,8 +17,9 @@ namespace Content.Server.Mobs.Roles
|
|||||||
base.Greet();
|
base.Greet();
|
||||||
|
|
||||||
var chat = IoCManager.Resolve<IChatManager>();
|
var chat = IoCManager.Resolve<IChatManager>();
|
||||||
chat.DispatchMessage(Mind.Session.ConnectedClient, ChatChannel.Server,
|
chat.DispatchServerMessage(
|
||||||
"You're a traitor. Go fuck something up. Or something. I don't care to be honest.");
|
Mind.Session,
|
||||||
|
"You're a traitor. Go fuck something up. Or something. I don't care to be honest.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
54
Content.Shared/Chat/ChatChannel.cs
Normal file
54
Content.Shared/Chat/ChatChannel.cs
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Content.Shared.Chat
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents chat channels that the player can filter chat tabs by.
|
||||||
|
/// </summary>
|
||||||
|
[Flags]
|
||||||
|
public enum ChatChannel : byte
|
||||||
|
{
|
||||||
|
None = 0,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Chat heard by players within earshot
|
||||||
|
/// </summary>
|
||||||
|
Local = 1,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Messages from the server
|
||||||
|
/// </summary>
|
||||||
|
Server = 2,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Damage messages
|
||||||
|
/// </summary>
|
||||||
|
Damage = 4,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Radio messages
|
||||||
|
/// </summary>
|
||||||
|
Radio = 8,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Out-of-character channel
|
||||||
|
/// </summary>
|
||||||
|
OOC = 16,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Visual events the player can see.
|
||||||
|
/// Basically like visual_message in SS13.
|
||||||
|
/// </summary>
|
||||||
|
Visual = 32,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Emotes
|
||||||
|
/// </summary>
|
||||||
|
Emotes = 64,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Unspecified.
|
||||||
|
/// </summary>
|
||||||
|
Unspecified = 128,
|
||||||
|
}
|
||||||
|
}
|
||||||
74
Content.Shared/Chat/MsgChatMessage.cs
Normal file
74
Content.Shared/Chat/MsgChatMessage.cs
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
using System;
|
||||||
|
using Lidgren.Network;
|
||||||
|
using SS14.Shared.GameObjects;
|
||||||
|
using SS14.Shared.Interfaces.Network;
|
||||||
|
using SS14.Shared.Network;
|
||||||
|
using SS14.Shared.Network.Messages;
|
||||||
|
|
||||||
|
namespace Content.Shared.Chat
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Sent from server to client to notify the client about a new chat message.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class MsgChatMessage : NetMessage
|
||||||
|
{
|
||||||
|
#region REQUIRED
|
||||||
|
|
||||||
|
public const MsgGroups GROUP = MsgGroups.Command;
|
||||||
|
public const string NAME = nameof(MsgChatMessage);
|
||||||
|
public MsgChatMessage(INetChannel channel) : base(NAME, GROUP) { }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The channel the message is on. This can also change whether certain params are used.
|
||||||
|
/// </summary>
|
||||||
|
public ChatChannel Channel { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The actual message contents.
|
||||||
|
/// </summary>
|
||||||
|
public string Message { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// What to "wrap" the message contents with. Example is stuff like 'Joe says: "{0}"'
|
||||||
|
/// </summary>
|
||||||
|
public string MessageWrap { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The sending entity.
|
||||||
|
/// Only applies to <see cref="ChatChannel.Local"/> and <see cref="ChatChannel.Emotes"/>.
|
||||||
|
/// </summary>
|
||||||
|
public EntityUid SenderEntity { get; set; }
|
||||||
|
|
||||||
|
public override void ReadFromBuffer(NetIncomingMessage buffer)
|
||||||
|
{
|
||||||
|
Channel = (ChatChannel) buffer.ReadByte();
|
||||||
|
Message = buffer.ReadString();
|
||||||
|
MessageWrap = buffer.ReadString();
|
||||||
|
|
||||||
|
switch (Channel)
|
||||||
|
{
|
||||||
|
case ChatChannel.Local:
|
||||||
|
case ChatChannel.Emotes:
|
||||||
|
SenderEntity = buffer.ReadEntityUid();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void WriteToBuffer(NetOutgoingMessage buffer)
|
||||||
|
{
|
||||||
|
buffer.Write((byte)Channel);
|
||||||
|
buffer.Write(Message);
|
||||||
|
buffer.Write(MessageWrap);
|
||||||
|
|
||||||
|
switch (Channel)
|
||||||
|
{
|
||||||
|
case ChatChannel.Local:
|
||||||
|
case ChatChannel.Emotes:
|
||||||
|
buffer.Write(SenderEntity);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -63,6 +63,8 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Audio\SoundCollectionPrototype.cs" />
|
<Compile Include="Audio\SoundCollectionPrototype.cs" />
|
||||||
|
<Compile Include="Chat\ChatChannel.cs" />
|
||||||
|
<Compile Include="Chat\MsgChatMessage.cs" />
|
||||||
<Compile Include="EntryPoint.cs" />
|
<Compile Include="EntryPoint.cs" />
|
||||||
<Compile Include="GameObjects\Components\Damage\DamageableComponent.cs" />
|
<Compile Include="GameObjects\Components\Damage\DamageableComponent.cs" />
|
||||||
<Compile Include="GameObjects\Components\Doors\SharedDoorComponent.cs" />
|
<Compile Include="GameObjects\Components\Doors\SharedDoorComponent.cs" />
|
||||||
|
|||||||
@@ -14,5 +14,6 @@ namespace Content.Shared.Input
|
|||||||
public static readonly BoundKeyFunction ActivateItemInWorld = "ActivateItemInWorld"; // default action on world entity
|
public static readonly BoundKeyFunction ActivateItemInWorld = "ActivateItemInWorld"; // default action on world entity
|
||||||
public static readonly BoundKeyFunction ThrowItemInHand = "ThrowItemInHand";
|
public static readonly BoundKeyFunction ThrowItemInHand = "ThrowItemInHand";
|
||||||
public static readonly BoundKeyFunction OpenContextMenu = "OpenContextMenu";
|
public static readonly BoundKeyFunction OpenContextMenu = "OpenContextMenu";
|
||||||
|
public static readonly BoundKeyFunction FocusChat = "FocusChatWindow";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,4 +58,4 @@
|
|||||||
- type: Stack
|
- type: Stack
|
||||||
max: 5
|
max: 5
|
||||||
count: 5
|
count: 5
|
||||||
stacktype: enum.StackType.Brutepack
|
stacktype: enum.StackType.Brutepack
|
||||||
|
|||||||
162
Resources/Scenes/ChatBox/ChatBox.tscn
Normal file
162
Resources/Scenes/ChatBox/ChatBox.tscn
Normal file
@@ -0,0 +1,162 @@
|
|||||||
|
[gd_scene load_steps=5 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Engine/Fonts/CALIBRI.TTF" type="DynamicFontData" id=1]
|
||||||
|
|
||||||
|
[sub_resource type="StyleBoxFlat" id=3]
|
||||||
|
|
||||||
|
content_margin_left = -1.0
|
||||||
|
content_margin_right = -1.0
|
||||||
|
content_margin_top = -1.0
|
||||||
|
content_margin_bottom = -1.0
|
||||||
|
bg_color = Color( 0.501961, 0.501961, 0.501961, 0.501961 )
|
||||||
|
draw_center = true
|
||||||
|
border_width_left = 1
|
||||||
|
border_width_top = 1
|
||||||
|
border_width_right = 1
|
||||||
|
border_width_bottom = 1
|
||||||
|
border_color = Color( 0, 0, 0, 0.501961 )
|
||||||
|
border_blend = false
|
||||||
|
corner_radius_top_left = 0
|
||||||
|
corner_radius_top_right = 0
|
||||||
|
corner_radius_bottom_right = 0
|
||||||
|
corner_radius_bottom_left = 0
|
||||||
|
corner_detail = 8
|
||||||
|
expand_margin_left = 1.0
|
||||||
|
expand_margin_right = 1.0
|
||||||
|
expand_margin_top = 1.0
|
||||||
|
expand_margin_bottom = 1.0
|
||||||
|
shadow_color = Color( 0, 0, 0, 0.6 )
|
||||||
|
shadow_size = 0
|
||||||
|
anti_aliasing = true
|
||||||
|
anti_aliasing_size = 1
|
||||||
|
_sections_unfolded = [ "Anti Aliasing", "Border Width", "Corner Radius", "Expand Margin", "Shadow" ]
|
||||||
|
|
||||||
|
[sub_resource type="DynamicFont" id=1]
|
||||||
|
|
||||||
|
size = 16
|
||||||
|
use_mipmaps = false
|
||||||
|
use_filter = false
|
||||||
|
font_data = ExtResource( 1 )
|
||||||
|
_sections_unfolded = [ "Extra Spacing", "Font/fallback", "Settings" ]
|
||||||
|
|
||||||
|
[sub_resource type="StyleBoxFlat" id=2]
|
||||||
|
|
||||||
|
content_margin_left = 2.0
|
||||||
|
content_margin_right = -1.0
|
||||||
|
content_margin_top = -1.0
|
||||||
|
content_margin_bottom = -1.0
|
||||||
|
bg_color = Color( 0.0234375, 0.0234375, 0.0234375, 0.501961 )
|
||||||
|
draw_center = true
|
||||||
|
border_width_left = 0
|
||||||
|
border_width_top = 0
|
||||||
|
border_width_right = 0
|
||||||
|
border_width_bottom = 0
|
||||||
|
border_color = Color( 0.8, 0.8, 0.8, 1 )
|
||||||
|
border_blend = false
|
||||||
|
corner_radius_top_left = 1
|
||||||
|
corner_radius_top_right = 1
|
||||||
|
corner_radius_bottom_right = 0
|
||||||
|
corner_radius_bottom_left = 0
|
||||||
|
corner_detail = 8
|
||||||
|
expand_margin_left = 0.0
|
||||||
|
expand_margin_right = 0.0
|
||||||
|
expand_margin_top = 0.0
|
||||||
|
expand_margin_bottom = 0.0
|
||||||
|
shadow_color = Color( 0, 0, 0, 0.6 )
|
||||||
|
shadow_size = 0
|
||||||
|
anti_aliasing = true
|
||||||
|
anti_aliasing_size = 1
|
||||||
|
_sections_unfolded = [ "Content Margin", "Corner Radius", "Expand Margin" ]
|
||||||
|
|
||||||
|
[node name="ChatBox" type="PanelContainer" index="0"]
|
||||||
|
|
||||||
|
anchor_left = 1.0
|
||||||
|
anchor_top = 0.0
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 0.0
|
||||||
|
margin_left = -475.0
|
||||||
|
margin_top = 10.0
|
||||||
|
margin_right = -10.0
|
||||||
|
margin_bottom = 185.0
|
||||||
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
|
rect_clip_content = false
|
||||||
|
mouse_filter = 0
|
||||||
|
mouse_default_cursor_shape = 0
|
||||||
|
size_flags_horizontal = 1
|
||||||
|
size_flags_vertical = 1
|
||||||
|
custom_styles/panel = SubResource( 3 )
|
||||||
|
_sections_unfolded = [ "Anchor", "Grow Direction", "Margin", "Rect", "custom_styles" ]
|
||||||
|
|
||||||
|
[node name="VBoxContainer" type="VBoxContainer" parent="." index="0"]
|
||||||
|
|
||||||
|
anchor_left = 0.0
|
||||||
|
anchor_top = 0.0
|
||||||
|
anchor_right = 0.0
|
||||||
|
anchor_bottom = 0.0
|
||||||
|
margin_left = 1.0
|
||||||
|
margin_top = 1.0
|
||||||
|
margin_right = 464.0
|
||||||
|
margin_bottom = 174.0
|
||||||
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
|
rect_clip_content = false
|
||||||
|
mouse_filter = 1
|
||||||
|
mouse_default_cursor_shape = 0
|
||||||
|
size_flags_horizontal = 1
|
||||||
|
size_flags_vertical = 1
|
||||||
|
alignment = 0
|
||||||
|
|
||||||
|
[node name="Contents" type="RichTextLabel" parent="VBoxContainer" index="0"]
|
||||||
|
|
||||||
|
anchor_left = 0.0
|
||||||
|
anchor_top = 0.0
|
||||||
|
anchor_right = 0.0
|
||||||
|
anchor_bottom = 0.0
|
||||||
|
margin_right = 463.0
|
||||||
|
margin_bottom = 153.0
|
||||||
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
|
rect_clip_content = true
|
||||||
|
mouse_filter = 0
|
||||||
|
mouse_default_cursor_shape = 0
|
||||||
|
size_flags_horizontal = 1
|
||||||
|
size_flags_vertical = 3
|
||||||
|
custom_fonts/normal_font = SubResource( 1 )
|
||||||
|
bbcode_enabled = false
|
||||||
|
bbcode_text = ""
|
||||||
|
visible_characters = -1
|
||||||
|
percent_visible = 1.0
|
||||||
|
meta_underlined = true
|
||||||
|
tab_size = 4
|
||||||
|
text = ""
|
||||||
|
scroll_active = true
|
||||||
|
scroll_following = false
|
||||||
|
selection_enabled = false
|
||||||
|
override_selected_font_color = false
|
||||||
|
_sections_unfolded = [ "BBCode", "Size Flags", "custom_fonts" ]
|
||||||
|
|
||||||
|
[node name="Input" type="LineEdit" parent="VBoxContainer" index="1"]
|
||||||
|
|
||||||
|
anchor_left = 0.0
|
||||||
|
anchor_top = 0.0
|
||||||
|
anchor_right = 0.0
|
||||||
|
anchor_bottom = 0.0
|
||||||
|
margin_top = 157.0
|
||||||
|
margin_right = 463.0
|
||||||
|
margin_bottom = 173.0
|
||||||
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
|
rect_clip_content = false
|
||||||
|
focus_mode = 2
|
||||||
|
mouse_filter = 0
|
||||||
|
mouse_default_cursor_shape = 1
|
||||||
|
size_flags_horizontal = 1
|
||||||
|
size_flags_vertical = 1
|
||||||
|
custom_styles/normal = SubResource( 2 )
|
||||||
|
custom_fonts/font = SubResource( 1 )
|
||||||
|
focus_mode = 2
|
||||||
|
context_menu_enabled = true
|
||||||
|
placeholder_alpha = 0.6
|
||||||
|
caret_blink = true
|
||||||
|
caret_blink_speed = 0.5
|
||||||
|
caret_position = 0
|
||||||
|
_sections_unfolded = [ "Margin", "custom_colors", "custom_constants", "custom_fonts", "custom_styles" ]
|
||||||
|
|
||||||
|
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=GL/@EntryIndexedValue">GL</s:String>
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=GL/@EntryIndexedValue">GL</s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=KHR/@EntryIndexedValue">KHR</s:String>
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=KHR/@EntryIndexedValue">KHR</s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=OGL/@EntryIndexedValue">OGL</s:String>
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=OGL/@EntryIndexedValue">OGL</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=OOC/@EntryIndexedValue">OOC</s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=PCM/@EntryIndexedValue">PCM</s:String>
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=PCM/@EntryIndexedValue">PCM</s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=PNG/@EntryIndexedValue">PNG</s:String>
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=PNG/@EntryIndexedValue">PNG</s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=RSI/@EntryIndexedValue">RSI</s:String>
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=RSI/@EntryIndexedValue">RSI</s:String>
|
||||||
|
|||||||
Reference in New Issue
Block a user