コード例 #1
0
        public override void Draw()
        {
            ImGui.BeginChild("ConsoleInner", new Vector2(-1, -64));
            ImGui.PushFont(ImGuiManager.Instance.MonospacedFont);

            foreach (var logEntry in Logging.LogEntries.TakeLast(logLimit))
            {
                if (!string.IsNullOrWhiteSpace(currentConsoleFilter) && !GetFilterMatch(logEntry, currentConsoleFilter))
                {
                    continue;
                }

                ImGui.TextWrapped(logEntry.timestamp.TimeOfDay.ToString());
                ImGui.SameLine();
                ImGui.PushStyleColor(ImGuiCol.Text, SeverityToColor(logEntry.severity));
                ImGui.TextWrapped(logEntry.str);
                ImGui.PopStyleColor();

                if (ImGui.IsItemHovered())
                {
                    ImGui.SetNextWindowSize(new Vector2(GameSettings.GameResolutionX / 2f, -1));

                    ImGui.BeginTooltip();

                    ImGui.Text("Stack Trace:");
                    ImGui.TextWrapped(logEntry.stackTrace.ToString());

                    ImGui.EndTooltip();
                }

                ImGui.Separator();
            }

            if (scrollQueued)
            {
                ImGui.SetScrollHereY(1.0f);
                scrollQueued = false;
            }

            ImGui.PopFont();
            ImGui.EndChild();

            ImGui.InputText("Filter", ref currentConsoleFilter, 256);

            ImGui.InputText("Input", ref currentConsoleInput, 256);
            ImGui.SameLine();
            if (ImGui.Button("Submit"))
            {
                CommandRegistry.ParseAndExecute(currentConsoleInput);
                currentConsoleInput = "";
            }
        }