Client LuaCsForBarotrauma
BarotraumaClient/ClientSource/LuaCs/LuaCsLogger.cs
1 using Microsoft.Xna.Framework;
2 
3 namespace Barotrauma
4 {
5  partial class LuaCsLogger
6  {
7  private static GUIFrame overlayFrame;
8  private static GUITextBlock textBlock;
9  private static double showTimer = 0;
10 
11  private static void CreateOverlay(string message)
12  {
13  overlayFrame = new GUIFrame(new RectTransform(new Vector2(0.4f, 0.03f), null), null, new Color(50, 50, 50, 100))
14  {
15  CanBeFocused = false
16  };
17 
18  GUILayoutGroup layout = new GUILayoutGroup(new RectTransform(new Vector2(0.8f, 0.8f), overlayFrame.RectTransform, Anchor.CenterLeft), false, Anchor.Center)
19  {
20 
21  };
22 
23  textBlock = new GUITextBlock(new RectTransform(new Vector2(1f, 0f), layout.RectTransform), message);
24  overlayFrame.RectTransform.MinSize = new Point((int)(textBlock.TextSize.X * 1.2), 0);
25 
26  layout.Recalculate();
27  }
28 
29  public static void AddToGUIUpdateList()
30  {
31  if (overlayFrame != null && Timing.TotalTime <= showTimer)
32  {
33  overlayFrame.AddToGUIUpdateList();
34  }
35  }
36 
37  public static void ShowErrorOverlay(string message, float time = 5f, float duration = 1.5f)
38  {
39  if (Timing.TotalTime <= showTimer)
40  {
41  return;
42  }
43 
44  CreateOverlay(message);
45 
46  overlayFrame.Flash(Color.Red, duration, true);
47  showTimer = Timing.TotalTime + time;
48  }
49  }
50 }
static void ShowErrorOverlay(string message, float time=5f, float duration=1.5f)