diff --git a/OpenRA.Game/Widgets/ChatDisplayWidget.cs b/OpenRA.Game/Widgets/ChatDisplayWidget.cs index 6a0a7d889c..f5f5aebec8 100644 --- a/OpenRA.Game/Widgets/ChatDisplayWidget.cs +++ b/OpenRA.Game/Widgets/ChatDisplayWidget.cs @@ -16,9 +16,12 @@ namespace OpenRA.Widgets { class ChatDisplayWidget : Widget { + public readonly int RemoveTime = 0; + const int logLength = 9; public string Notification = ""; public bool DrawBackground = true; + int ticksUntilRemove = 0; public List recentLines = new List(); @@ -52,16 +55,35 @@ namespace OpenRA.Widgets Game.Renderer.RgbaSpriteRenderer.Flush(); Game.Renderer.Device.DisableScissor(); } - + public void AddLine(Color c, string from, string text) { recentLines.Add(new ChatLine { Color = c, Owner = from, Text = text }); - + ticksUntilRemove = RemoveTime; + if (Notification != null) Sound.Play(Notification); while (recentLines.Count > logLength) recentLines.RemoveAt(0); } + + public void RemoveLine() + { + if (recentLines.Count > 0) recentLines.RemoveAt(0); + } + + public void ClearChat() + { + recentLines = new List(); + } + + public override void Tick (World world) + { + if (RemoveTime == 0) return; + if (--ticksUntilRemove > 0) return; + ticksUntilRemove = RemoveTime; + RemoveLine(); + } public override Widget Clone() { return new ChatDisplayWidget(this); } } diff --git a/OpenRA.Game/Widgets/Delegates/ConnectionDialogsDelegate.cs b/OpenRA.Game/Widgets/Delegates/ConnectionDialogsDelegate.cs index 98bb05b703..f519ab41e7 100644 --- a/OpenRA.Game/Widgets/Delegates/ConnectionDialogsDelegate.cs +++ b/OpenRA.Game/Widgets/Delegates/ConnectionDialogsDelegate.cs @@ -54,6 +54,7 @@ namespace OpenRA.Widgets.Delegates break; case ConnectionState.Connected: r.OpenWindow("SERVER_LOBBY"); + r.GetWidget("SERVER_LOBBY").GetWidget("CHAT_DISPLAY").ClearChat(); break; } }; diff --git a/mods/cnc/chrome/ingame.yaml b/mods/cnc/chrome/ingame.yaml index 68e725f079..61e3dda39a 100644 --- a/mods/cnc/chrome/ingame.yaml +++ b/mods/cnc/chrome/ingame.yaml @@ -181,6 +181,7 @@ Container@ROOT: Height: 200 ClickThrough: True DrawBackground: False + RemoveTime:250 ChatEntry@CHAT_ENTRY: Id:CHAT_ENTRY X:250 diff --git a/mods/ra/chrome/ingame.yaml b/mods/ra/chrome/ingame.yaml index 55595b4351..f80de4bdb7 100644 --- a/mods/ra/chrome/ingame.yaml +++ b/mods/ra/chrome/ingame.yaml @@ -188,6 +188,7 @@ Container@ROOT: Height: 200 ClickThrough: True DrawBackground: False + RemoveTime:250 ChatEntry@CHAT_ENTRY: Id:CHAT_ENTRY X:250