New chat display
This commit is contained in:
@@ -23,6 +23,9 @@ namespace OpenRA.Mods.Cnc.Widgets
|
||||
public class CncLobbyLogic : IWidgetDelegate
|
||||
{
|
||||
Widget LocalPlayerTemplate, RemotePlayerTemplate, EmptySlotTemplate, EmptySlotTemplateHost;
|
||||
ScrollPanelWidget chatPanel;
|
||||
Widget chatTemplate;
|
||||
|
||||
ScrollPanelWidget Players;
|
||||
Dictionary<string, string> CountryNames;
|
||||
string MapUid;
|
||||
@@ -56,7 +59,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
||||
lobbyLogic.onGameStart();
|
||||
break;
|
||||
case StaticCrap.AddChatLine:
|
||||
panel.GetWidget<ChatDisplayWidget>("CHAT_DISPLAY").AddLine(a,b,c);
|
||||
lobbyLogic.AddChatLine(a,b,c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -160,7 +163,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
||||
gameStarting = true;
|
||||
orderManager.IssueOrder(Order.Command("startgame"));
|
||||
};
|
||||
|
||||
|
||||
bool teamChat = false;
|
||||
var chatLabel = lobby.GetWidget<LabelWidget>("LABEL_CHATTYPE");
|
||||
var chatTextField = lobby.GetWidget<TextFieldWidget>("CHAT_TEXTFIELD");
|
||||
@@ -181,6 +184,40 @@ namespace OpenRA.Mods.Cnc.Widgets
|
||||
chatLabel.Text = (teamChat) ? "Team:" : "Chat:";
|
||||
return true;
|
||||
};
|
||||
|
||||
chatPanel = lobby.GetWidget<ScrollPanelWidget>("CHAT_DISPLAY");
|
||||
chatTemplate = chatPanel.GetWidget("CHAT_TEMPLATE");
|
||||
}
|
||||
|
||||
public void AddChatLine(Color c, string from, string text)
|
||||
{
|
||||
var name = from+":";
|
||||
var font = Game.Renderer.RegularFont;
|
||||
var nameSize = font.Measure(from);
|
||||
|
||||
var template = chatTemplate.Clone() as ContainerWidget;
|
||||
template.IsVisible = () => true;
|
||||
|
||||
var time = System.DateTime.Now;
|
||||
template.GetWidget<LabelWidget>("TIME").GetText = () => "[{0:D2}:{1:D2}]".F(time.Hour, time.Minute);
|
||||
|
||||
var p = template.GetWidget<LabelWidget>("NAME");
|
||||
p.Color = c;
|
||||
p.GetText = () => name;
|
||||
p.Bounds.Width = nameSize.X;
|
||||
|
||||
var t = template.GetWidget<LabelWidget>("TEXT");
|
||||
t.Bounds.X += nameSize.X;
|
||||
t.Bounds.Width -= nameSize.X;
|
||||
|
||||
// Hack around our hacky wordwrap behavior: need to resize the widget to fit the text
|
||||
text = WidgetUtils.WrapText(text, t.Bounds.Width, font);
|
||||
t.GetText = () => text;
|
||||
var oldHeight = t.Bounds.Height;
|
||||
t.Bounds.Height = font.Measure(text).Y;
|
||||
template.Bounds.Height += (t.Bounds.Height - oldHeight);
|
||||
|
||||
chatPanel.AddChild(template);
|
||||
}
|
||||
|
||||
void UpdatePlayerColor(float hf, float sf, float lf, float r)
|
||||
|
||||
@@ -185,7 +185,7 @@ button: uibuttons.png
|
||||
corner-bl: 0,126,2,2
|
||||
corner-br: 62,126,2,2
|
||||
|
||||
dialog3: uibuttons.png
|
||||
dialog2: uibuttons.png
|
||||
background: 2,2,60,60
|
||||
border-r: 62,2,2,60
|
||||
border-l: 0,2,2,60
|
||||
@@ -196,7 +196,7 @@ dialog3: uibuttons.png
|
||||
corner-bl: 0,62,2,2
|
||||
corner-br: 62,62,2,2
|
||||
|
||||
dialog2: uibuttons.png
|
||||
dialog3: uibuttons.png
|
||||
background: 2,66,60,60
|
||||
border-r: 62,66,2,60
|
||||
border-l: 0,66,2,60
|
||||
|
||||
@@ -307,20 +307,14 @@ Container@SERVER_LOBBY:
|
||||
Text:Ready
|
||||
Align:Left
|
||||
Bold:True
|
||||
ChatDisplay@CHAT_DISPLAY:
|
||||
Id:CHAT_DISPLAY
|
||||
X:15
|
||||
Y:285
|
||||
Width:PARENT_RIGHT - 30
|
||||
Height:PARENT_BOTTOM - 55 - 275
|
||||
Notification: beepy2.aud
|
||||
TextField@CHAT_TEXTFIELD:
|
||||
Id:CHAT_TEXTFIELD
|
||||
X:15
|
||||
Y:PARENT_BOTTOM - 15 - HEIGHT
|
||||
LeftMargin:50
|
||||
Y:PARENT_BOTTOM - HEIGHT - 15
|
||||
Width:PARENT_RIGHT - 30
|
||||
Height:25
|
||||
LeftMargin:50
|
||||
Background: panel-darkred
|
||||
Children:
|
||||
Label@LABEL_CHATTYPE:
|
||||
Id:LABEL_CHATTYPE
|
||||
@@ -329,6 +323,38 @@ Container@SERVER_LOBBY:
|
||||
Height:25
|
||||
Align:Right
|
||||
Text:Chat:
|
||||
ScrollPanel@CHAT_DISPLAY:
|
||||
Id:CHAT_DISPLAY
|
||||
X:15
|
||||
Y:285
|
||||
Width:PARENT_RIGHT - 30
|
||||
Height:PARENT_BOTTOM - 324
|
||||
ItemSpacing:2
|
||||
Children:
|
||||
Container@CHAT_TEMPLATE:
|
||||
Id:CHAT_TEMPLATE
|
||||
Width:PARENT_RIGHT-28
|
||||
Height:14
|
||||
X:2
|
||||
Y:0
|
||||
Visible:false
|
||||
Children:
|
||||
Label@TIME:
|
||||
Id:TIME
|
||||
X:5
|
||||
Width:50
|
||||
Height:14
|
||||
Label@NAME:
|
||||
Id:NAME
|
||||
X:55
|
||||
Width:50
|
||||
Height:14
|
||||
Label@TEXT:
|
||||
Id:TEXT
|
||||
X:65
|
||||
Height:14
|
||||
Width:PARENT_RIGHT - 100 - 10
|
||||
WordWrap:true
|
||||
CncMenuButton@START_GAME_BUTTON:
|
||||
Id:START_GAME_BUTTON
|
||||
X:0
|
||||
|
||||
Reference in New Issue
Block a user