Number of children in the debugconsole listbox limited to 200 (prevents framerate drop if adding tons of messages)

This commit is contained in:
Regalis
2016-11-07 20:45:23 +02:00
parent f412a8334b
commit cd5c72eff2

View File

@@ -27,7 +27,7 @@ namespace Barotrauma
static class DebugConsole
{
const int MaxMessages = 100;
const int MaxMessages = 200;
public static List<ColoredText> Messages = new List<ColoredText>();
@@ -769,6 +769,11 @@ namespace Barotrauma
//listbox not created yet, don't attempt to add
if (listBox == null) return;
if (listBox.children.Count > MaxMessages)
{
listBox.children.RemoveRange(0, listBox.children.Count - MaxMessages);
}
try
{
var textBlock = new GUITextBlock(new Rectangle(0, 0, listBox.Rect.Width, 0), msg, GUI.Style, Alignment.TopLeft, Alignment.Left, null, true, GUI.SmallFont);