Chat improvements:
Improved chat box styling. "All" button now works as a toggle for.. all buttons! Also improved persistence of the chat box when switching to/from lobby.
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using Content.Shared.Chat;
|
using Content.Shared.Chat;
|
||||||
using Robust.Client.Graphics.Drawing;
|
using Robust.Client.Graphics.Drawing;
|
||||||
using Robust.Client.Input;
|
using Robust.Client.Input;
|
||||||
@@ -10,14 +9,13 @@ using Robust.Shared.Utility;
|
|||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
|
|
||||||
|
|
||||||
namespace Content.Client.Chat
|
namespace Content.Client.Chat
|
||||||
{
|
{
|
||||||
public class ChatBox : PanelContainer
|
public class ChatBox : MarginContainer
|
||||||
{
|
{
|
||||||
public delegate void TextSubmitHandler(ChatBox chatBox, string text);
|
public delegate void TextSubmitHandler(ChatBox chatBox, string text);
|
||||||
|
|
||||||
public delegate void FilterToggledHandler(ChatBox chatBox, Button.ButtonToggledEventArgs e);
|
public delegate void FilterToggledHandler(ChatBox chatBox, BaseButton.ButtonToggledEventArgs e);
|
||||||
|
|
||||||
private const int MaxLinePixelLength = 500;
|
private const int MaxLinePixelLength = 500;
|
||||||
|
|
||||||
@@ -30,6 +28,7 @@ namespace Content.Client.Chat
|
|||||||
|
|
||||||
// Buttons for filtering
|
// Buttons for filtering
|
||||||
public Button AllButton;
|
public Button AllButton;
|
||||||
|
public Button LocalButton;
|
||||||
public Button OOCButton;
|
public Button OOCButton;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -56,41 +55,59 @@ namespace Content.Client.Chat
|
|||||||
MarginLeft = -475.0f;
|
MarginLeft = -475.0f;
|
||||||
MarginTop = 10.0f;
|
MarginTop = 10.0f;
|
||||||
MarginRight = -10.0f;
|
MarginRight = -10.0f;
|
||||||
MarginBottom = 185.0f;
|
MarginBottom = 235.0f;
|
||||||
|
|
||||||
AnchorLeft = 1.0f;
|
AnchorLeft = 1.0f;
|
||||||
AnchorRight = 1.0f;
|
AnchorRight = 1.0f;
|
||||||
|
|
||||||
var vBox = new VBoxContainer("VBoxContainer");
|
var outerVBox = new VBoxContainer();
|
||||||
var hBox = new HBoxContainer("FilterButtonsContainer");
|
|
||||||
|
var panelContainer = new PanelContainer
|
||||||
|
{
|
||||||
|
PanelOverride = new StyleBoxFlat {BackgroundColor = Color.FromHex("#25252aaa")},
|
||||||
|
SizeFlagsVertical = SizeFlags.FillExpand
|
||||||
|
};
|
||||||
|
var vBox = new VBoxContainer();
|
||||||
|
panelContainer.AddChild(vBox);
|
||||||
|
var hBox = new HBoxContainer();
|
||||||
|
|
||||||
|
outerVBox.AddChild(panelContainer);
|
||||||
|
outerVBox.AddChild(hBox);
|
||||||
|
|
||||||
contents = new OutputPanel {SizeFlagsVertical = SizeFlags.FillExpand};
|
contents = new OutputPanel {SizeFlagsVertical = SizeFlags.FillExpand};
|
||||||
vBox.AddChild(contents);
|
vBox.AddChild(contents);
|
||||||
|
|
||||||
Input = new LineEdit("Input");
|
Input = new LineEdit();
|
||||||
Input.OnKeyDown += InputKeyDown;
|
Input.OnKeyDown += InputKeyDown;
|
||||||
Input.OnTextEntered += Input_OnTextEntered;
|
Input.OnTextEntered += Input_OnTextEntered;
|
||||||
vBox.AddChild(Input);
|
vBox.AddChild(Input);
|
||||||
|
|
||||||
vBox.AddChild(hBox);
|
AllButton = new Button
|
||||||
|
|
||||||
AllButton = new Button()
|
|
||||||
{
|
{
|
||||||
Text = localize.GetString("All"),
|
Text = localize.GetString("All"),
|
||||||
Name = "ALL",
|
Name = "ALL",
|
||||||
TextAlign = Button.AlignMode.Left,
|
TextAlign = Button.AlignMode.Left,
|
||||||
SizeFlagsHorizontal = SizeFlags.Fill,
|
SizeFlagsHorizontal = SizeFlags.ShrinkEnd | SizeFlags.Expand,
|
||||||
SizeFlagsStretchRatio = 1,
|
SizeFlagsStretchRatio = 1,
|
||||||
ToggleMode = true,
|
ToggleMode = true,
|
||||||
Pressed = true
|
Pressed = true
|
||||||
};
|
};
|
||||||
|
|
||||||
OOCButton = new Button()
|
LocalButton = new Button
|
||||||
|
{
|
||||||
|
Text = localize.GetString("Local"),
|
||||||
|
Name = "Local",
|
||||||
|
TextAlign = Button.AlignMode.Left,
|
||||||
|
SizeFlagsStretchRatio = 1,
|
||||||
|
ToggleMode = true,
|
||||||
|
Pressed = true
|
||||||
|
};
|
||||||
|
|
||||||
|
OOCButton = new Button
|
||||||
{
|
{
|
||||||
Text = localize.GetString("OOC"),
|
Text = localize.GetString("OOC"),
|
||||||
Name = "OOC",
|
Name = "OOC",
|
||||||
TextAlign = Button.AlignMode.Left,
|
TextAlign = Button.AlignMode.Left,
|
||||||
SizeFlagsHorizontal = SizeFlags.Fill,
|
|
||||||
SizeFlagsStretchRatio = 1,
|
SizeFlagsStretchRatio = 1,
|
||||||
ToggleMode = true,
|
ToggleMode = true,
|
||||||
Pressed = true
|
Pressed = true
|
||||||
@@ -102,9 +119,7 @@ namespace Content.Client.Chat
|
|||||||
hBox.AddChild(AllButton);
|
hBox.AddChild(AllButton);
|
||||||
hBox.AddChild(OOCButton);
|
hBox.AddChild(OOCButton);
|
||||||
|
|
||||||
AddChild(vBox);
|
AddChild(outerVBox);
|
||||||
|
|
||||||
PanelOverride = new StyleBoxFlat { BackgroundColor = Color.Gray.WithAlpha(0.5f) };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void MouseDown(GUIMouseButtonEventArgs e)
|
protected override void MouseDown(GUIMouseButtonEventArgs e)
|
||||||
@@ -210,7 +225,7 @@ namespace Content.Client.Chat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnFilterToggled(Button.ButtonToggledEventArgs args)
|
private void OnFilterToggled(BaseButton.ButtonToggledEventArgs args)
|
||||||
{
|
{
|
||||||
FilterToggled?.Invoke(this, args);
|
FilterToggled?.Invoke(this, args);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,62 +0,0 @@
|
|||||||
using Robust.Client.Graphics;
|
|
||||||
using Robust.Client.Graphics.Drawing;
|
|
||||||
using Robust.Client.Interfaces.Graphics;
|
|
||||||
using Robust.Client.UserInterface.Controls;
|
|
||||||
using Robust.Client.UserInterface.CustomControls;
|
|
||||||
using Robust.Client.Utility;
|
|
||||||
using Robust.Shared.IoC;
|
|
||||||
using Robust.Shared.Log;
|
|
||||||
using Robust.Shared.Maths;
|
|
||||||
using Robust.Shared.ViewVariables;
|
|
||||||
|
|
||||||
using Content.Client.Chat;
|
|
||||||
|
|
||||||
namespace Content.Client.Chat
|
|
||||||
{
|
|
||||||
public class ChatFilterUI : SS14Window
|
|
||||||
{
|
|
||||||
protected override void Initialize()
|
|
||||||
{
|
|
||||||
base.Initialize();
|
|
||||||
|
|
||||||
Title = "Filter Channels";
|
|
||||||
|
|
||||||
var margin = new MarginContainer()
|
|
||||||
{
|
|
||||||
MarginTop = 5f,
|
|
||||||
MarginLeft = 5f,
|
|
||||||
MarginRight = -5f,
|
|
||||||
MarginBottom = -5f,
|
|
||||||
};
|
|
||||||
|
|
||||||
margin.SetAnchorAndMarginPreset(LayoutPreset.TopRight);
|
|
||||||
|
|
||||||
var vbox = new VBoxContainer();
|
|
||||||
|
|
||||||
vbox.SetAnchorAndMarginPreset(LayoutPreset.TopRight);
|
|
||||||
|
|
||||||
var descMargin = new MarginContainer()
|
|
||||||
{
|
|
||||||
MarginTop = 5f,
|
|
||||||
MarginLeft = 5f,
|
|
||||||
MarginRight = -5f,
|
|
||||||
MarginBottom = -5f,
|
|
||||||
SizeFlagsHorizontal = SizeFlags.Fill,
|
|
||||||
SizeFlagsStretchRatio = 2,
|
|
||||||
};
|
|
||||||
|
|
||||||
var hbox = new HBoxContainer()
|
|
||||||
{
|
|
||||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
|
||||||
};
|
|
||||||
|
|
||||||
var vboxInfo = new VBoxContainer()
|
|
||||||
{
|
|
||||||
SizeFlagsVertical = SizeFlags.FillExpand,
|
|
||||||
SizeFlagsStretchRatio = 3,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,4 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Net;
|
|
||||||
using Content.Client.Interfaces.Chat;
|
using Content.Client.Interfaces.Chat;
|
||||||
using Content.Shared.Chat;
|
using Content.Shared.Chat;
|
||||||
using Robust.Client.Console;
|
using Robust.Client.Console;
|
||||||
@@ -22,9 +20,9 @@ namespace Content.Client.Chat
|
|||||||
public List<StoredChatMessage> filteredHistory = new List<StoredChatMessage>();
|
public List<StoredChatMessage> filteredHistory = new List<StoredChatMessage>();
|
||||||
|
|
||||||
// Filter Button States
|
// Filter Button States
|
||||||
private bool _ALLstate;
|
private bool _allState;
|
||||||
private bool _Localstate;
|
private bool _localState;
|
||||||
private bool _OOCstate;
|
private bool _oocState;
|
||||||
|
|
||||||
// Flag Enums for holding filtered channels
|
// Flag Enums for holding filtered channels
|
||||||
private ChatChannel _filteredChannels;
|
private ChatChannel _filteredChannels;
|
||||||
@@ -55,6 +53,11 @@ namespace Content.Client.Chat
|
|||||||
_currentChatBox.TextSubmitted += _onChatBoxTextSubmitted;
|
_currentChatBox.TextSubmitted += _onChatBoxTextSubmitted;
|
||||||
_currentChatBox.FilterToggled += _onFilterButtonToggled;
|
_currentChatBox.FilterToggled += _onFilterButtonToggled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RepopulateChat(filteredHistory);
|
||||||
|
_currentChatBox.AllButton.Pressed = !_allState;
|
||||||
|
_currentChatBox.LocalButton.Pressed = !_localState;
|
||||||
|
_currentChatBox.OOCButton.Pressed = !_oocState;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void WriteChatMessage(StoredChatMessage message)
|
private void WriteChatMessage(StoredChatMessage message)
|
||||||
@@ -127,14 +130,13 @@ namespace Content.Client.Chat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void _onFilterButtonToggled(ChatBox chatBox, Button.ButtonToggledEventArgs e)
|
private void _onFilterButtonToggled(ChatBox chatBox, BaseButton.ButtonToggledEventArgs e)
|
||||||
{
|
{
|
||||||
// TODO make toggled ALL button flip all button states programatically + visually
|
|
||||||
switch (e.Button.Name)
|
switch (e.Button.Name)
|
||||||
{
|
{
|
||||||
case "Local":
|
case "Local":
|
||||||
_Localstate = !_Localstate;
|
_localState = !_localState;
|
||||||
if (_Localstate)
|
if (_localState)
|
||||||
{
|
{
|
||||||
_filteredChannels |= ChatChannel.Local;
|
_filteredChannels |= ChatChannel.Local;
|
||||||
break;
|
break;
|
||||||
@@ -146,8 +148,8 @@ namespace Content.Client.Chat
|
|||||||
}
|
}
|
||||||
|
|
||||||
case "OOC":
|
case "OOC":
|
||||||
_OOCstate = !_OOCstate;
|
_oocState = !_oocState;
|
||||||
if (_OOCstate)
|
if (_oocState)
|
||||||
{
|
{
|
||||||
_filteredChannels |= ChatChannel.OOC;
|
_filteredChannels |= ChatChannel.OOC;
|
||||||
break;
|
break;
|
||||||
@@ -158,36 +160,24 @@ namespace Content.Client.Chat
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
case "ALL":
|
||||||
_ALLstate = !_ALLstate;
|
chatBox.LocalButton.Pressed ^= true;
|
||||||
if (_ALLstate)
|
chatBox.OOCButton.Pressed ^= true;
|
||||||
{
|
_allState = !_allState;
|
||||||
_filteredChannels = ChatChannel.OOC | ChatChannel.Local;
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_filteredChannels &= ~ChatChannel.OOC;
|
|
||||||
_filteredChannels &= ~ChatChannel.Local;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RepopulateChat(filteredHistory);
|
RepopulateChat(filteredHistory);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RepopulateChat(List<StoredChatMessage> filteredMessages)
|
private void RepopulateChat(IEnumerable<StoredChatMessage> filteredMessages)
|
||||||
{
|
{
|
||||||
_currentChatBox.contents.Clear();
|
_currentChatBox.contents.Clear();
|
||||||
|
|
||||||
// Copy list for enumeration
|
foreach (var msg in filteredMessages)
|
||||||
List<StoredChatMessage> filteredMessagesCopy = new List<StoredChatMessage>(filteredMessages);
|
|
||||||
|
|
||||||
foreach (StoredChatMessage msg in filteredMessagesCopy)
|
|
||||||
{
|
{
|
||||||
WriteChatMessage(msg);
|
WriteChatMessage(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void _onChatMessage(MsgChatMessage msg)
|
private void _onChatMessage(MsgChatMessage msg)
|
||||||
@@ -202,14 +192,8 @@ namespace Content.Client.Chat
|
|||||||
|
|
||||||
private bool IsFiltered(ChatChannel channel)
|
private bool IsFiltered(ChatChannel channel)
|
||||||
{
|
{
|
||||||
if (_filteredChannels.HasFlag(channel))
|
// _ALLstate works as inverter.
|
||||||
{
|
return _allState ^ _filteredChannels.HasFlag(channel);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,4 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Content.Client.Interfaces.Chat;
|
|
||||||
using Content.Shared.Chat;
|
using Content.Shared.Chat;
|
||||||
using Robust.Client.Console;
|
|
||||||
using Robust.Shared.Interfaces.Network;
|
|
||||||
using Robust.Shared.IoC;
|
|
||||||
using Robust.Shared.Log;
|
|
||||||
using Robust.Shared.Maths;
|
|
||||||
using Robust.Shared.Utility;
|
|
||||||
using Robust.Client.UserInterface.Controls;
|
|
||||||
|
|
||||||
namespace Content.Client.Chat
|
namespace Content.Client.Chat
|
||||||
{
|
{
|
||||||
@@ -18,7 +8,7 @@ namespace Content.Client.Chat
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Client's own copies of chat messages used in filtering locally
|
/// Client's own copies of chat messages used in filtering locally
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Actual Message contents, i.e. words
|
/// Actual Message contents, i.e. words
|
||||||
@@ -30,20 +20,19 @@ namespace Content.Client.Chat
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public ChatChannel Channel { get; set; }
|
public ChatChannel Channel { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// What to "wrap" the message contents with. Example is stuff like 'Joe says: "{0}"'
|
/// What to "wrap" the message contents with. Example is stuff like 'Joe says: "{0}"'
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string MessageWrap { get; set; }
|
public string MessageWrap { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor to copy a net message into stored client variety
|
||||||
|
/// </summary>
|
||||||
public StoredChatMessage(MsgChatMessage netMsg)
|
public StoredChatMessage(MsgChatMessage netMsg)
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Constructor to copy a net message into stored client variety
|
|
||||||
/// </summary>
|
|
||||||
|
|
||||||
Message = netMsg.Message;
|
Message = netMsg.Message;
|
||||||
Channel = netMsg.Channel;
|
Channel = netMsg.Channel;
|
||||||
MessageWrap = netMsg.MessageWrap;
|
MessageWrap = netMsg.MessageWrap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace Content.Client.UserInterface
|
|||||||
});
|
});
|
||||||
|
|
||||||
SetAnchorAndMarginPreset(LayoutPreset.TopRight);
|
SetAnchorAndMarginPreset(LayoutPreset.TopRight);
|
||||||
MarginTop = 200;
|
MarginTop = 250;
|
||||||
MarginRight = 10;
|
MarginRight = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user