mirror of
https://github.com/ppy/osu.git
synced 2025-01-27 19:23:21 +08:00
Centralise the maximum chat history variable.
This commit is contained in:
parent
24771a62cf
commit
1c0b769451
@ -30,6 +30,8 @@ namespace osu.Game.Online.Chat
|
|||||||
|
|
||||||
//internal bool Joined;
|
//internal bool Joined;
|
||||||
|
|
||||||
|
public const int MAX_HISTORY = 100;
|
||||||
|
|
||||||
[JsonConstructor]
|
[JsonConstructor]
|
||||||
public Channel()
|
public Channel()
|
||||||
{
|
{
|
||||||
@ -47,13 +49,9 @@ namespace osu.Game.Online.Chat
|
|||||||
|
|
||||||
private void purgeOldMessages()
|
private void purgeOldMessages()
|
||||||
{
|
{
|
||||||
const int max_history = 50;
|
|
||||||
|
|
||||||
int messageCount = Messages.Count;
|
int messageCount = Messages.Count;
|
||||||
if (messageCount > 50)
|
if (messageCount > MAX_HISTORY)
|
||||||
{
|
Messages.RemoveRange(0, messageCount - MAX_HISTORY);
|
||||||
Messages.RemoveRange(0, messageCount - max_history);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,13 +67,13 @@ namespace osu.Game.Online.Chat.Display
|
|||||||
{
|
{
|
||||||
if (!IsLoaded) return;
|
if (!IsLoaded) return;
|
||||||
|
|
||||||
var displayMessages = newMessages.Skip(Math.Max(0, newMessages.Count() - 20));
|
var displayMessages = newMessages.Skip(Math.Max(0, newMessages.Count() - Channel.MAX_HISTORY));
|
||||||
|
|
||||||
//up to last 20 messages
|
//up to last Channel.MAX_HISTORY messages
|
||||||
foreach (Message m in displayMessages)
|
foreach (Message m in displayMessages)
|
||||||
flow.Add(new ChatLine(m));
|
flow.Add(new ChatLine(m));
|
||||||
|
|
||||||
while (flow.Children.Count() > 20)
|
while (flow.Children.Count() > Channel.MAX_HISTORY)
|
||||||
flow.Remove(flow.Children.First());
|
flow.Remove(flow.Children.First());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user