Merge pull request #9877 from pchote/lobby-unread
Show unread message count on lobby chat tabs.
This commit is contained in:
@@ -143,6 +143,7 @@ namespace OpenRA.Widgets
|
|||||||
public class ChromeLogic : IDisposable
|
public class ChromeLogic : IDisposable
|
||||||
{
|
{
|
||||||
public void Dispose() { Dispose(true); GC.SuppressFinalize(this); }
|
public void Dispose() { Dispose(true); GC.SuppressFinalize(this); }
|
||||||
|
public virtual void Tick() { }
|
||||||
protected virtual void Dispose(bool disposing) { }
|
protected virtual void Dispose(bool disposing) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -436,6 +437,10 @@ namespace OpenRA.Widgets
|
|||||||
Tick();
|
Tick();
|
||||||
foreach (var child in Children)
|
foreach (var child in Children)
|
||||||
child.TickOuter();
|
child.TickOuter();
|
||||||
|
|
||||||
|
if (LogicObjects != null)
|
||||||
|
foreach (var l in LogicObjects)
|
||||||
|
l.Tick();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,6 +62,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
readonly LabelWidget chatLabel;
|
readonly LabelWidget chatLabel;
|
||||||
bool teamChat;
|
bool teamChat;
|
||||||
|
|
||||||
|
int lobbyChatUnreadMessages;
|
||||||
|
int globalChatLastReadMessages;
|
||||||
|
int globalChatUnreadMessages;
|
||||||
|
|
||||||
// Listen for connection failures
|
// Listen for connection failures
|
||||||
void ConnectionStateChanged(OrderManager om)
|
void ConnectionStateChanged(OrderManager om)
|
||||||
{
|
{
|
||||||
@@ -583,6 +587,17 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
globalChatInput.TakeKeyboardFocus();
|
globalChatInput.TakeKeyboardFocus();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var globalChatLabel = globalChatTab.Text;
|
||||||
|
globalChatTab.GetText = () =>
|
||||||
|
{
|
||||||
|
if (globalChatUnreadMessages == 0)
|
||||||
|
return globalChatLabel;
|
||||||
|
|
||||||
|
return globalChatLabel + " ({0})".F(globalChatUnreadMessages);
|
||||||
|
};
|
||||||
|
|
||||||
|
globalChatLastReadMessages = Game.GlobalChat.History.Count;
|
||||||
|
|
||||||
var lobbyChat = lobby.Get("LOBBYCHAT");
|
var lobbyChat = lobby.Get("LOBBYCHAT");
|
||||||
lobbyChat.IsVisible = () => chatPanel == ChatPanelType.Lobby;
|
lobbyChat.IsVisible = () => chatPanel == ChatPanelType.Lobby;
|
||||||
|
|
||||||
@@ -624,6 +639,15 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
chatTextField.TakeKeyboardFocus();
|
chatTextField.TakeKeyboardFocus();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var lobbyChatLabel = lobbyChatTab.Text;
|
||||||
|
lobbyChatTab.GetText = () =>
|
||||||
|
{
|
||||||
|
if (lobbyChatUnreadMessages == 0)
|
||||||
|
return lobbyChatLabel;
|
||||||
|
|
||||||
|
return lobbyChatLabel + " ({0})".F(lobbyChatUnreadMessages);
|
||||||
|
};
|
||||||
|
|
||||||
lobbyChatPanel = lobby.Get<ScrollPanelWidget>("CHAT_DISPLAY");
|
lobbyChatPanel = lobby.Get<ScrollPanelWidget>("CHAT_DISPLAY");
|
||||||
chatTemplate = lobbyChatPanel.Get("CHAT_TEMPLATE");
|
chatTemplate = lobbyChatPanel.Get("CHAT_TEMPLATE");
|
||||||
lobbyChatPanel.RemoveChildren();
|
lobbyChatPanel.RemoveChildren();
|
||||||
@@ -652,8 +676,23 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void Tick()
|
||||||
|
{
|
||||||
|
var newMessages = Game.GlobalChat.History.Count;
|
||||||
|
globalChatUnreadMessages += newMessages - globalChatLastReadMessages;
|
||||||
|
globalChatLastReadMessages = newMessages;
|
||||||
|
|
||||||
|
if (chatPanel == ChatPanelType.Lobby)
|
||||||
|
lobbyChatUnreadMessages = 0;
|
||||||
|
|
||||||
|
if (chatPanel == ChatPanelType.Global)
|
||||||
|
globalChatUnreadMessages = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void AddChatLine(Color c, string from, string text)
|
void AddChatLine(Color c, string from, string text)
|
||||||
{
|
{
|
||||||
|
lobbyChatUnreadMessages += 1;
|
||||||
|
|
||||||
var template = chatTemplate.Clone();
|
var template = chatTemplate.Clone();
|
||||||
var nameLabel = template.Get<LabelWidget>("NAME");
|
var nameLabel = template.Get<LabelWidget>("NAME");
|
||||||
var timeLabel = template.Get<LabelWidget>("TIME");
|
var timeLabel = template.Get<LabelWidget>("TIME");
|
||||||
|
|||||||
Reference in New Issue
Block a user