Having a hidden child in a listbox doesn't prevent successive children from being rendered, server log can be filtered by message type
This commit is contained in:
@@ -406,7 +406,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
private bool IsChildVisible(GUIComponent child)
|
private bool IsChildVisible(GUIComponent child)
|
||||||
{
|
{
|
||||||
if (child == null || !child.Visible) return false;
|
if (child == null) return false;
|
||||||
|
|
||||||
if (scrollBar.IsHorizontal)
|
if (scrollBar.IsHorizontal)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -54,6 +54,12 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Color TextColor
|
||||||
|
{
|
||||||
|
get { return text.TextColor; }
|
||||||
|
set { text.TextColor = value; }
|
||||||
|
}
|
||||||
|
|
||||||
public override Rectangle MouseRect
|
public override Rectangle MouseRect
|
||||||
{
|
{
|
||||||
get { return box.Rect; }
|
get { return box.Rect; }
|
||||||
|
|||||||
@@ -52,6 +52,9 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
private int unsavedLineCount;
|
private int unsavedLineCount;
|
||||||
|
|
||||||
|
private string msgFilter;
|
||||||
|
private bool[] msgTypeHidden = new bool[Enum.GetValues(typeof(MessageType)).Length];
|
||||||
|
|
||||||
public int LinesPerFile
|
public int LinesPerFile
|
||||||
{
|
{
|
||||||
get { return linesPerFile; }
|
get { return linesPerFile; }
|
||||||
@@ -99,21 +102,43 @@ namespace Barotrauma.Networking
|
|||||||
{
|
{
|
||||||
LogFrame = new GUIFrame(new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.Black * 0.5f);
|
LogFrame = new GUIFrame(new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.Black * 0.5f);
|
||||||
|
|
||||||
GUIFrame innerFrame = new GUIFrame(new Rectangle(0, 0, 500, 420), null, Alignment.Center, "", LogFrame);
|
GUIFrame innerFrame = new GUIFrame(new Rectangle(0, 0, 600, 420), null, Alignment.Center, "", LogFrame);
|
||||||
innerFrame.Padding = new Vector4(10.0f, 20.0f, 10.0f, 20.0f);
|
innerFrame.Padding = new Vector4(10.0f, 20.0f, 10.0f, 20.0f);
|
||||||
|
|
||||||
new GUITextBlock(new Rectangle(-200, 0, 100, 15), "Filter", "", Alignment.TopRight, Alignment.CenterRight, innerFrame, false, GUI.SmallFont);
|
new GUITextBlock(new Rectangle(-200, 0, 100, 15), "Filter", "", Alignment.TopRight, Alignment.CenterRight, innerFrame, false, GUI.SmallFont);
|
||||||
|
|
||||||
GUITextBox searchBox = new GUITextBox(new Rectangle(-20, 0, 180, 15), Alignment.TopRight, "", innerFrame);
|
GUITextBox searchBox = new GUITextBox(new Rectangle(-20, 0, 180, 15), Alignment.TopRight, "", innerFrame);
|
||||||
searchBox.Font = GUI.SmallFont;
|
searchBox.Font = GUI.SmallFont;
|
||||||
searchBox.OnTextChanged = FilterMessages;
|
searchBox.OnTextChanged = (textBox, text) =>
|
||||||
|
{
|
||||||
|
msgFilter = text;
|
||||||
|
FilterMessages();
|
||||||
|
return true;
|
||||||
|
};
|
||||||
GUIComponent.KeyboardDispatcher.Subscriber = searchBox;
|
GUIComponent.KeyboardDispatcher.Subscriber = searchBox;
|
||||||
|
|
||||||
var clearButton = new GUIButton(new Rectangle(0, 0, 15, 15), "x", Alignment.TopRight, "", innerFrame);
|
var clearButton = new GUIButton(new Rectangle(0, 0, 15, 15), "x", Alignment.TopRight, "", innerFrame);
|
||||||
clearButton.OnClicked = ClearFilter;
|
clearButton.OnClicked = ClearFilter;
|
||||||
clearButton.UserData = searchBox;
|
clearButton.UserData = searchBox;
|
||||||
|
|
||||||
listBox = new GUIListBox(new Rectangle(0, 30, 0, 340), "", innerFrame);
|
listBox = new GUIListBox(new Rectangle(0, 30, 450, 340), "", Alignment.TopRight, innerFrame);
|
||||||
|
|
||||||
|
int y = 30;
|
||||||
|
foreach (MessageType msgType in Enum.GetValues(typeof(MessageType)))
|
||||||
|
{
|
||||||
|
var tickBox = new GUITickBox(new Rectangle(0,y,20,20), msgType.ToString(), Alignment.TopLeft, GUI.SmallFont, innerFrame);
|
||||||
|
tickBox.Selected = true;
|
||||||
|
tickBox.TextColor = MessageColor[(int)msgType];
|
||||||
|
|
||||||
|
tickBox.OnSelected += (GUITickBox tb) =>
|
||||||
|
{
|
||||||
|
msgTypeHidden[(int)msgType] = !tb.Selected;
|
||||||
|
FilterMessages();
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
y += 20;
|
||||||
|
}
|
||||||
|
|
||||||
var currLines = lines.ToList();
|
var currLines = lines.ToList();
|
||||||
|
|
||||||
@@ -132,6 +157,8 @@ namespace Barotrauma.Networking
|
|||||||
LogFrame = null;
|
LogFrame = null;
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
msgFilter = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddLine(LogMessage line)
|
private void AddLine(LogMessage line)
|
||||||
@@ -139,30 +166,32 @@ namespace Barotrauma.Networking
|
|||||||
float prevSize = listBox.BarSize;
|
float prevSize = listBox.BarSize;
|
||||||
|
|
||||||
var textBlock = new GUITextBlock(new Rectangle(0, 0, 0, 0), line.Text, "", Alignment.TopLeft, Alignment.TopLeft, listBox, true, GUI.SmallFont);
|
var textBlock = new GUITextBlock(new Rectangle(0, 0, 0, 0), line.Text, "", Alignment.TopLeft, Alignment.TopLeft, listBox, true, GUI.SmallFont);
|
||||||
textBlock.Rect = new Rectangle(textBlock.Rect.X, textBlock.Rect.Y, textBlock.Rect.Width, Math.Max(13, textBlock.Rect.Height));
|
textBlock.Rect = new Rectangle(textBlock.Rect.X, textBlock.Rect.Y, textBlock.Rect.Width, Math.Max(13, textBlock.Rect.Height));
|
||||||
|
|
||||||
textBlock.TextColor = MessageColor[(int)line.Type];
|
textBlock.TextColor = MessageColor[(int)line.Type];
|
||||||
textBlock.CanBeFocused = false;
|
textBlock.CanBeFocused = false;
|
||||||
|
textBlock.UserData = line;
|
||||||
|
|
||||||
if ((prevSize == 1.0f && listBox.BarScroll == 0.0f) || (prevSize < 1.0f && listBox.BarScroll == 1.0f)) listBox.BarScroll = 1.0f;
|
if ((prevSize == 1.0f && listBox.BarScroll == 0.0f) || (prevSize < 1.0f && listBox.BarScroll == 1.0f)) listBox.BarScroll = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool FilterMessages(GUITextBox textBox, string text)
|
private bool FilterMessages()
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(text))
|
string filter = msgFilter == null ? "" : msgFilter.ToLower();
|
||||||
{
|
|
||||||
listBox.children.ForEach( c => c.Visible = true);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
text = text.ToLower();
|
|
||||||
|
|
||||||
foreach (GUIComponent child in listBox.children)
|
foreach (GUIComponent child in listBox.children)
|
||||||
{
|
{
|
||||||
var textBlock = child as GUITextBlock;
|
var textBlock = child as GUITextBlock;
|
||||||
if (textBlock == null) continue;
|
if (textBlock == null) continue;
|
||||||
|
|
||||||
textBlock.Visible = textBlock.Text.ToLower().Contains(text);
|
child.Visible = true;
|
||||||
|
|
||||||
|
if (msgTypeHidden[(int)((LogMessage)child.UserData).Type])
|
||||||
|
{
|
||||||
|
child.Visible = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
textBlock.Visible = string.IsNullOrEmpty(filter) || textBlock.Text.ToLower().Contains(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
listBox.BarScroll = 0.0f;
|
listBox.BarScroll = 0.0f;
|
||||||
@@ -172,11 +201,12 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
public bool ClearFilter(GUIComponent button, object obj)
|
public bool ClearFilter(GUIComponent button, object obj)
|
||||||
{
|
{
|
||||||
FilterMessages(null, "");
|
|
||||||
|
|
||||||
var searchBox = button.UserData as GUITextBox;
|
var searchBox = button.UserData as GUITextBox;
|
||||||
if (searchBox != null) searchBox.Text = "";
|
if (searchBox != null) searchBox.Text = "";
|
||||||
|
|
||||||
|
msgFilter = "";
|
||||||
|
FilterMessages();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user