diff --git a/OpenRA.Game/Chat.cs b/OpenRA.Game/Chat.cs
deleted file mode 100644
index 5cb48c8ddc..0000000000
--- a/OpenRA.Game/Chat.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-#region Copyright & License Information
-/*
- * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
- * This file is part of OpenRA.
- *
- * OpenRA is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * OpenRA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with OpenRA. If not, see .
- */
-#endregion
-
-using System.Collections.Generic;
-using System.Drawing;
-using OpenRA.FileFormats;
-using OpenRA.Traits;
-using System.Text;
-
-namespace OpenRA
-{
- class Chat
- {
- const int logLength = 10;
- public List recentLines = new List();
-
- public void AddLine(Session.Client p, string text)
- {
- AddLine(Game.world.PlayerColors()[p.PaletteIndex].Color, p.Name, text);
- }
-
- public void AddLine(Color c, string from, string text)
- {
- var sizeOwner = Game.chrome.renderer.RegularFont.Measure(from);
- var sizeText = Game.chrome.renderer.RegularFont.Measure(text);
-
- if (sizeOwner.X + sizeText.X + 10 <= Chrome.ChatWidth)
- recentLines.Add(new ChatLine { Color = c, Owner = from, Text = text });
- else
- {
- StringBuilder sb = new StringBuilder();
- foreach (var w in text.Split(' '))
- {
- if ( Game.chrome.renderer.RegularFont.Measure(sb.ToString() + ' ' + w).X > Chrome.ChatWidth )
- {
- recentLines.Add(new ChatLine { Color = c, Owner = from, Text = sb.ToString() } );
- sb = new StringBuilder();
- sb.Append(w);
- }
- else
- sb.Append( ' ' + w);
- }
- if (sb.Length != 0)
- recentLines.Add(new ChatLine { Color = c, Owner = from, Text = sb.ToString() } );
- }
-
- var eva = Rules.Info["world"].Traits.Get();
- Sound.Play(eva.ChatBeep);
- while (recentLines.Count > logLength) recentLines.RemoveAt(0);
- }
- }
-
- class ChatLine { public Color Color = Color.White; public string Owner, Text; public bool wrapped = false; }
-}
diff --git a/OpenRA.Game/Chrome.cs b/OpenRA.Game/Chrome.cs
index 2c472e159c..f9fbdd538c 100644
--- a/OpenRA.Game/Chrome.cs
+++ b/OpenRA.Game/Chrome.cs
@@ -61,6 +61,7 @@ namespace OpenRA
public static Widget rootWidget = null;
public static Widget selectedWidget;
+ public static ChatDisplayWidget chatWidget;
public void Tick(World world)
{
@@ -75,10 +76,6 @@ namespace OpenRA
{
buttons.Clear();
renderer.Device.DisableScissor();
-
- var typingArea = new Rectangle(240, Game.viewport.Height - 30, Game.viewport.Width - 420, 30);
- var chatLogArea = new Rectangle(240, Game.viewport.Height - 500, Game.viewport.Width - 420, 500 - 40);
- DrawChat(typingArea, chatLogArea);
}
void AddUiButton(int2 pos, string text, Action a)
@@ -165,17 +162,6 @@ namespace OpenRA
currentMap = null;
else
currentMap = Game.AvailableMaps[ Game.LobbyInfo.GlobalSettings.Map ];
-
- var w = 800;
- var h = 600;
- var r = new Rectangle( (Game.viewport.Width - w) / 2, (Game.viewport.Height - h) / 2, w, h );
-
- var typingBox = new Rectangle(r.Left + 20, r.Bottom - 77, r.Width - 40, 27);
- var chatBox = new Rectangle(r.Left + 20, r.Bottom - 269, r.Width - 40, 190);
-
- DrawDialogBackground(chatBox, "dialog3");
-
- DrawChat(typingBox, chatBox);
}
void AddButton(RectangleF r, Action b) { buttons.Add(Pair.New(r, b)); }
@@ -185,30 +171,6 @@ namespace OpenRA
WidgetUtils.DrawPanel(collection, r);
}
- void DrawChat(Rectangle typingArea, Rectangle chatLogArea)
- {
-
- var chatpos = new int2(chatLogArea.X + 10, chatLogArea.Bottom - 6);
- ChatWidth = chatLogArea.Width - 10;
-
- renderer.Device.EnableScissor(chatLogArea.Left, chatLogArea.Top, chatLogArea.Width, chatLogArea.Height);
- foreach (var line in Game.chat.recentLines.AsEnumerable().Reverse())
- {
- chatpos.Y -= 20;
- RenderChatLine(line, chatpos);
- }
-
- rgbaRenderer.Flush();
- renderer.Device.DisableScissor();
- }
-
- void RenderChatLine(ChatLine line, int2 p)
- {
- var size = renderer.RegularFont.Measure(line.Owner);
- renderer.RegularFont.DrawText(line.Owner, p, line.Color);
- renderer.RegularFont.DrawText(line.Text, p + new int2(size.X + 10, 0), Color.White);
- }
-
public int ticksSinceLastMove = 0;
public int2 lastMousePos;
public bool HandleInput(World world, MouseInput mi)
diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs
index 94b7e8d8fb..4ac8770c17 100644
--- a/OpenRA.Game/Game.cs
+++ b/OpenRA.Game/Game.cs
@@ -201,9 +201,6 @@ namespace OpenRA
}
internal static int RenderFrame = 0;
-
- internal static Chat chat = new Chat();
-
internal static int LocalTick = 0;
const int NetTickScale = 3; // 120ms net tick for 40ms local tick
@@ -618,7 +615,7 @@ namespace OpenRA
public static void Exit() { quit = true; }
- public static void Debug(string s) { chat.AddLine(Color.White, "Debug", s); }
+ public static void Debug(string s) { Chrome.chatWidget.AddLine(Color.White, "Debug", s); }
public static void Disconnect()
{
diff --git a/OpenRA.Game/Network/UnitOrders.cs b/OpenRA.Game/Network/UnitOrders.cs
index d07e9624c5..16ec3058f1 100755
--- a/OpenRA.Game/Network/UnitOrders.cs
+++ b/OpenRA.Game/Network/UnitOrders.cs
@@ -33,27 +33,29 @@ namespace OpenRA.Network
case "Chat":
{
var client = Game.LobbyInfo.Clients.FirstOrDefault(c => c.Index == clientId);
- if (client != null)
- Game.chat.AddLine(client, order.TargetString);
+ if (client != null && Chrome.chatWidget != null)
+ Chrome.chatWidget.AddLine(client, order.TargetString);
break;
}
case "TeamChat":
{
var client = Game.LobbyInfo.Clients.FirstOrDefault(c => c.Index == clientId);
- if (client != null)
+ if (client != null && Chrome.chatWidget != null)
{
var player = Game.world.players.Values.FirstOrDefault(p => p.Index == client.Index);
var isAlly = player != null && Game.world.LocalPlayer != null
&& player.Stances[Game.world.LocalPlayer] == Stance.Ally;
if (isAlly)
- Game.chat.AddLine(client, "(Team) " + order.TargetString);
+ Chrome.chatWidget.AddLine(client, "(Team) " + order.TargetString);
}
break;
}
case "StartGame":
{
- Game.chat.AddLine(Color.White, "Server", "The game has started.");
+ if (Chrome.chatWidget != null)
+ Chrome.chatWidget.AddLine(Color.White, "Server", "The game has started.");
+
Game.StartGame();
break;
}
diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj
index 6568d9cb6f..9571577514 100755
--- a/OpenRA.Game/OpenRA.Game.csproj
+++ b/OpenRA.Game/OpenRA.Game.csproj
@@ -75,7 +75,6 @@
-
@@ -226,6 +225,7 @@
+
diff --git a/OpenRA.Game/Traits/Player/EvaAlerts.cs b/OpenRA.Game/Traits/Player/EvaAlerts.cs
index ffc8074689..239247d8ee 100644
--- a/OpenRA.Game/Traits/Player/EvaAlerts.cs
+++ b/OpenRA.Game/Traits/Player/EvaAlerts.cs
@@ -25,8 +25,6 @@ namespace OpenRA.Traits
{
// Sound effects
public readonly string TabClick = "ramenu1.aud";
-
- public readonly string ChatBeep = "rabeep1.aud";
public readonly string RadarUp = "radaron2.aud";
public readonly string RadarDown = "radardn1.aud";
diff --git a/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs b/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs
index f13592fbfd..19ac6c76b3 100644
--- a/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs
+++ b/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs
@@ -68,6 +68,7 @@ namespace OpenRA.Widgets.Delegates
};
Game.LobbyInfoChanged += UpdatePlayerList;
+ Chrome.chatWidget = lobby.GetWidget("CHAT_DISPLAY") as ChatDisplayWidget;
}
void UpdatePlayerList()
diff --git a/OpenRA.Game/Widgets/TextFieldWidget.cs b/OpenRA.Game/Widgets/TextFieldWidget.cs
index dfaf74d547..8eec9f997f 100644
--- a/OpenRA.Game/Widgets/TextFieldWidget.cs
+++ b/OpenRA.Game/Widgets/TextFieldWidget.cs
@@ -102,7 +102,6 @@ namespace OpenRA.Widgets
TextBuffer += c;
}
-
int blinkCycle = 10;
bool showCursor = true;
public override void Tick(World world)
@@ -133,7 +132,7 @@ namespace OpenRA.Widgets
// Right align and scissor when the text overflows
if (textSize.X > Bounds.Width - 2*margin)
{
- textPos += new int2(Bounds.Width - 2*margin - textSize.X,0);
+ textPos += new int2(Bounds.Width - 2*margin - textSize.X,0);
Game.chrome.renderer.Device.EnableScissor(pos.X + margin, pos.Y, Bounds.Width - 2*margin, Bounds.Bottom);
}
diff --git a/mods/cnc/menus.yaml b/mods/cnc/menus.yaml
index 682e24bca7..5d9712079f 100644
--- a/mods/cnc/menus.yaml
+++ b/mods/cnc/menus.yaml
@@ -491,6 +491,15 @@ Container:
Width:120
Height:25
Text:Change Map
+ ChatDisplay@CHAT_DISPLAY:
+ Id:CHAT_DISPLAY
+ Visible:true
+ X:20
+ Y:PARENT_BOTTOM - 269
+ Width:PARENT_RIGHT - 40
+ Height:190
+ Notification: beepy2.aud
+#rabeep1.aud for ra
Label@LABEL_LOBBY_TEAM:
Id:LABEL_LOBBY_TEAM
Width:70
diff --git a/mods/cnc/system.yaml b/mods/cnc/system.yaml
index 2cf68c1b75..a23d85604b 100644
--- a/mods/cnc/system.yaml
+++ b/mods/cnc/system.yaml
@@ -205,7 +205,6 @@ World:
SpawnDefaultUnits:
EvaAlerts:
TabClick: button.aud
- ChatBeep: beepy2.aud
RadarUp: comcntr1.aud
RadarDown: powrdn1.aud
BuildPaletteOpen: appear1.aud