Пример #1
0
        public void PopulateList()
        {
            m_listPanel.ItemWidgetFactory = delegate(object item)
            {
                string text  = (item != null) ? item.ToString() : string.Empty;
                Color  color = Color.Gray;
                if (text.Contains("ERROR:"))
                {
                    color = Color.Red;
                }
                else if (text.Contains("WARNING:"))
                {
                    color = Color.DarkYellow;
                }
                else if (text.Contains("INFO:"))
                {
                    color = Color.LightGray;
                }
                return(new LabelWidget
                {
                    Text = text,
                    Font = BitmapFont.DebugFont,
                    HorizontalAlignment = WidgetAlignment.Near,
                    VerticalAlignment = WidgetAlignment.Center,
                    Color = color
                });
            };
            List <string> recentLogLines = GameLogSink.GetRecentLogLines(131072);

            m_listPanel.ClearItems();
            if (recentLogLines.Count > 1000)
            {
                recentLogLines.RemoveRange(0, recentLogLines.Count - 1000);
            }
            foreach (string item in recentLogLines)
            {
                if (m_filter == LogType.Warning)
                {
                    if (!item.Contains("WARNING:") && !item.Contains("ERROR:"))
                    {
                        continue;
                    }
                }
                else if (m_filter == LogType.Error && !item.Contains("ERROR:"))
                {
                    continue;
                }
                m_listPanel.AddItem(item);
            }
            m_listPanel.ScrollPosition = (float)m_listPanel.Items.Count * m_listPanel.ItemSize;
        }
Пример #2
0
 public override void Update()
 {
     if (m_copyButton.IsClicked)
     {
         ClipboardManager.ClipboardString = GameLogSink.GetRecentLog(131072);
     }
     if (m_filterButton.IsClicked)
     {
         if (m_filter < LogType.Warning)
         {
             m_filter = LogType.Warning;
         }
         else if (m_filter < LogType.Error)
         {
             m_filter = LogType.Error;
         }
         else
         {
             m_filter = LogType.Debug;
         }
         PopulateList();
     }
     if (base.Input.Cancel || m_closeButton.IsClicked)
     {
         DialogsManager.HideDialog(this);
     }
     if (m_filter == LogType.Debug)
     {
         m_filterButton.Text = "All";
     }
     else if (m_filter == LogType.Warning)
     {
         m_filterButton.Text = "Warnings";
     }
     else if (m_filter == LogType.Error)
     {
         m_filterButton.Text = "Errors";
     }
 }