Tweak lobby chat panel
This commit is contained in:
@@ -219,7 +219,8 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
|
|
||||||
chatPanel = lobby.GetWidget<ScrollPanelWidget>("CHAT_DISPLAY");
|
chatPanel = lobby.GetWidget<ScrollPanelWidget>("CHAT_DISPLAY");
|
||||||
chatTemplate = chatPanel.GetWidget("CHAT_TEMPLATE");
|
chatTemplate = chatPanel.GetWidget("CHAT_TEMPLATE");
|
||||||
|
chatPanel.RemoveChildren();
|
||||||
|
|
||||||
lobby.GetWidget<ButtonWidget>("MUSIC_BUTTON").OnClick = () =>
|
lobby.GetWidget<ButtonWidget>("MUSIC_BUTTON").OnClick = () =>
|
||||||
{
|
{
|
||||||
Widget.OpenWindow("MUSIC_PANEL", new WidgetArgs()
|
Widget.OpenWindow("MUSIC_PANEL", new WidgetArgs()
|
||||||
@@ -241,32 +242,33 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
|
|
||||||
public void AddChatLine(Color c, string from, string text)
|
public void AddChatLine(Color c, string from, string text)
|
||||||
{
|
{
|
||||||
var name = from+":";
|
|
||||||
var font = Game.Renderer.Fonts["Regular"];
|
|
||||||
var nameSize = font.Measure(from);
|
|
||||||
|
|
||||||
var template = chatTemplate.Clone() as ContainerWidget;
|
var template = chatTemplate.Clone() as ContainerWidget;
|
||||||
template.IsVisible = () => true;
|
var nameLabel = template.GetWidget<LabelWidget>("NAME");
|
||||||
|
var timeLabel = template.GetWidget<LabelWidget>("TIME");
|
||||||
|
var textLabel = template.GetWidget<LabelWidget>("TEXT");
|
||||||
|
|
||||||
|
var name = from+":";
|
||||||
|
var font = Game.Renderer.Fonts[nameLabel.Font];
|
||||||
|
var nameSize = font.Measure(from);
|
||||||
|
|
||||||
var time = System.DateTime.Now;
|
var time = System.DateTime.Now;
|
||||||
template.GetWidget<LabelWidget>("TIME").GetText = () => "[{0:D2}:{1:D2}]".F(time.Hour, time.Minute);
|
timeLabel.GetText = () => "{0:D2}:{1:D2}".F(time.Hour, time.Minute);
|
||||||
|
|
||||||
var p = template.GetWidget<LabelWidget>("NAME");
|
nameLabel.GetColor = () => c;
|
||||||
p.GetColor = () => c;
|
nameLabel.GetText = () => name;
|
||||||
p.GetText = () => name;
|
nameLabel.Bounds.Width = nameSize.X;
|
||||||
p.Bounds.Width = nameSize.X;
|
textLabel.Bounds.X += nameSize.X;
|
||||||
|
textLabel.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
|
// Hack around our hacky wordwrap behavior: need to resize the widget to fit the text
|
||||||
text = WidgetUtils.WrapText(text, t.Bounds.Width, font);
|
text = WidgetUtils.WrapText(text, textLabel.Bounds.Width, font);
|
||||||
t.GetText = () => text;
|
textLabel.GetText = () => text;
|
||||||
var oldHeight = t.Bounds.Height;
|
var oldHeight = textLabel.Bounds.Height;
|
||||||
t.Bounds.Height = font.Measure(text).Y;
|
textLabel.Bounds.Height = font.Measure(text).Y;
|
||||||
template.Bounds.Height += (t.Bounds.Height - oldHeight);
|
var dh = textLabel.Bounds.Height - oldHeight;
|
||||||
|
if (dh > 0)
|
||||||
|
template.Bounds.Height += dh;
|
||||||
|
|
||||||
chatPanel.AddChild(template);
|
chatPanel.AddChild(template);
|
||||||
chatPanel.ScrollToBottom();
|
chatPanel.ScrollToBottom();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -397,32 +397,34 @@ Container@SERVER_LOBBY:
|
|||||||
Y:285
|
Y:285
|
||||||
Width:PARENT_RIGHT - 30
|
Width:PARENT_RIGHT - 30
|
||||||
Height:PARENT_BOTTOM - 324
|
Height:PARENT_BOTTOM - 324
|
||||||
ItemSpacing:2
|
ItemSpacing:1
|
||||||
Children:
|
Children:
|
||||||
Container@CHAT_TEMPLATE:
|
Container@CHAT_TEMPLATE:
|
||||||
Id:CHAT_TEMPLATE
|
Id:CHAT_TEMPLATE
|
||||||
Width:PARENT_RIGHT-27
|
Width:PARENT_RIGHT-27
|
||||||
Height:14
|
Height:16
|
||||||
X:2
|
X:2
|
||||||
Y:0
|
Y:0
|
||||||
Visible:false
|
|
||||||
Children:
|
Children:
|
||||||
Label@TIME:
|
Label@TIME:
|
||||||
Id:TIME
|
Id:TIME
|
||||||
X:5
|
X:3
|
||||||
Width:50
|
Width:50
|
||||||
Height:14
|
Height:15
|
||||||
|
VAlign:Top
|
||||||
Label@NAME:
|
Label@NAME:
|
||||||
Id:NAME
|
Id:NAME
|
||||||
X:55
|
X:45
|
||||||
Width:50
|
Width:50
|
||||||
Height:14
|
Height:15
|
||||||
|
VAlign:Top
|
||||||
Label@TEXT:
|
Label@TEXT:
|
||||||
Id:TEXT
|
Id:TEXT
|
||||||
X:65
|
X:55
|
||||||
Height:14
|
Width:PARENT_RIGHT - 60
|
||||||
Width:PARENT_RIGHT - 100 - 10
|
Height:15
|
||||||
WordWrap:true
|
WordWrap:true
|
||||||
|
VAlign:Top
|
||||||
TextField@CHAT_TEXTFIELD:
|
TextField@CHAT_TEXTFIELD:
|
||||||
Id:CHAT_TEXTFIELD
|
Id:CHAT_TEXTFIELD
|
||||||
X:15
|
X:15
|
||||||
|
|||||||
Reference in New Issue
Block a user