forked from MapStudioProject/MapStudio.UI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConsoleWindow.cs
More file actions
76 lines (63 loc) · 2.46 KB
/
Copy pathConsoleWindow.cs
File metadata and controls
76 lines (63 loc) · 2.46 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
using ImGuiNET;
using MapStudio.UI;
using Toolbox.Core;
namespace MapStudio.UI
{
public class ConsoleWindow : DockWindow
{
public override string Name => "CONSOLE";
bool displayErrors = true;
bool displayWarnings = true;
bool displayInfo = true;
public override void Render()
{
ImGui.Checkbox(TranslationSource.GetText("ERRORS"), ref displayErrors); ImGui.SameLine();
ImGui.Checkbox(TranslationSource.GetText("WARNINGS"), ref displayWarnings); ImGui.SameLine();
ImGui.Checkbox(TranslationSource.GetText("MESSAGES"), ref displayInfo); ImGui.SameLine();
if (ImGui.Button(TranslationSource.GetText("COPY")))
{
string text = "";
if (displayErrors) text += StudioLogger.GetErrorLog();
if (displayWarnings) text += StudioLogger.GetWarningLog();
if (displayInfo) text += StudioLogger.GetLog();
ImGui.SetClipboardText(text);
}
ImGui.SameLine();
if (ImGui.Button("Check Errors"))
{
StudioLogger.ResetErrors();
Workspace.ActiveWorkspace.PrintErrors();
}
var color = ImGui.GetStyle().Colors[(int)ImGuiCol.FrameBg];
ImGui.PushStyleColor(ImGuiCol.ChildBg, color);
ImGui.BeginChild("consoleWindow");
//Add in transform info wne
//Todo find a better place for this
var info = GLFrameworkEngine.GLContext.ActiveContext.TransformTools.GetTextInput();
if (!string.IsNullOrEmpty(info))
WriteText(info);
if (displayErrors) WriteText(StudioLogger.GetErrorLog(), ThemeHandler.Theme.Error);
if (displayWarnings) WriteText(StudioLogger.GetWarningLog(), ThemeHandler.Theme.Warning);
if (displayInfo) WriteText(StudioLogger.GetLog());
ImGui.EndChild();
ImGui.PopStyleColor();
}
private void WriteText(string text)
{
ImGui.TextWrapped(text);
}
private void WriteText(string text, Vector4 color)
{
if (string.IsNullOrEmpty(text))
return;
ImGui.PushStyleColor(ImGuiCol.Text, color);
ImGui.TextWrapped(text);
ImGui.PopStyleColor();
}
}
}