-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLog.cs
47 lines (40 loc) · 1.24 KB
/
Log.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System;
using Sandbox.Game.Gui;
using VRage.Game;
using VRage.Utils;
using VRageMath;
namespace Digi.ParticleEditor
{
public static class Log
{
public static string Name = "(UnknownPlugin)";
public static MyHudNotification ErrorNotify;
public static void Error(Exception e)
{
MyLog.Default.WriteLine($"{Name} ERROR: {e}");
Notify($"{Name} ERROR: {e.Message}");
}
public static void Error(string error)
{
MyLog.Default.WriteLine($"{Name} ERROR: {error}");
Notify($"{Name} ERROR: {error}");
}
static void Notify(string msg)
{
if(EditorUI.Instance?.Editor?.ShowEditor ?? false)
{
Notifications.Show(msg, 5, Color.Red);
}
else
{
if(MyHud.Notifications == null)
return;
if(ErrorNotify == null)
ErrorNotify = new MyHudNotification(MyCommonTexts.CustomText, 5000, MyFontEnum.Red);
MyHud.Notifications.Remove(ErrorNotify);
ErrorNotify.SetTextFormatArguments(msg);
MyHud.Notifications.Add(ErrorNotify);
}
}
}
}