2020-08-20 21:07:40 +02:00
|
|
|
|
using System;
|
2020-08-18 19:35:08 +01:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2020-08-20 21:07:40 +02:00
|
|
|
|
using OWML.Common;
|
2020-02-14 22:14:24 +01:00
|
|
|
|
|
2020-07-30 22:27:14 +02:00
|
|
|
|
namespace QSB.Utility
|
2020-02-15 20:48:02 +01:00
|
|
|
|
{
|
2020-08-20 14:10:37 +01:00
|
|
|
|
public static class DebugLog
|
2020-02-15 20:48:02 +01:00
|
|
|
|
{
|
2020-08-18 19:35:08 +01:00
|
|
|
|
public static void ToConsole(string message, MessageType type = MessageType.Message)
|
2020-07-28 00:13:43 +01:00
|
|
|
|
{
|
|
|
|
|
QSB.Helper.Console.WriteLine(message, type);
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-18 19:35:08 +01:00
|
|
|
|
public static void ToHud(string message)
|
2020-02-15 20:48:02 +01:00
|
|
|
|
{
|
|
|
|
|
if (Locator.GetPlayerBody() == null)
|
|
|
|
|
{
|
2020-02-14 22:14:24 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
2020-08-18 19:35:08 +01:00
|
|
|
|
var data = new NotificationData(NotificationTarget.Player, message);
|
2020-07-28 15:59:24 +02:00
|
|
|
|
NotificationManager.SharedInstance.PostNotification(data);
|
2020-02-14 22:14:24 +01:00
|
|
|
|
}
|
2020-02-15 20:48:02 +01:00
|
|
|
|
|
2020-08-18 19:35:08 +01:00
|
|
|
|
public static void ToAll(string message, MessageType type = MessageType.Message)
|
2020-03-04 21:46:16 +01:00
|
|
|
|
{
|
2020-08-18 19:35:08 +01:00
|
|
|
|
ToConsole(message, type);
|
|
|
|
|
ToHud(message);
|
2020-03-04 21:46:16 +01:00
|
|
|
|
}
|
2020-08-10 18:17:54 +02:00
|
|
|
|
|
2020-08-19 22:29:53 +02:00
|
|
|
|
public static string GenerateTable(List<string> columnsData, List<string> rowData)
|
2020-08-10 18:17:54 +02:00
|
|
|
|
{
|
2020-08-19 22:29:53 +02:00
|
|
|
|
var longestKey = columnsData.OrderByDescending(s => s.Length).First();
|
2020-08-18 19:35:08 +01:00
|
|
|
|
var longestValue = rowData.OrderByDescending(s => s.Length).First();
|
|
|
|
|
var longestObject = (longestKey.Length > longestValue.Length) ? longestKey : longestValue;
|
2020-08-19 22:29:53 +02:00
|
|
|
|
var columns = "|";
|
|
|
|
|
var data = "|";
|
|
|
|
|
foreach (var item in columnsData)
|
2020-08-18 19:35:08 +01:00
|
|
|
|
{
|
2020-08-20 21:07:40 +02:00
|
|
|
|
columns += $" {item.PadRight(longestObject.Length)} |";
|
2020-08-18 19:35:08 +01:00
|
|
|
|
}
|
|
|
|
|
foreach (var item in rowData)
|
|
|
|
|
{
|
2020-08-20 21:07:40 +02:00
|
|
|
|
data += $" {item.PadRight(longestObject.Length)} |";
|
2020-08-18 19:35:08 +01:00
|
|
|
|
}
|
2020-08-19 22:29:53 +02:00
|
|
|
|
return columns + Environment.NewLine + data;
|
2020-08-10 18:17:54 +02:00
|
|
|
|
}
|
2020-08-20 14:47:44 +01:00
|
|
|
|
|
2020-08-20 21:07:40 +02:00
|
|
|
|
public static void LogState(string name, bool state)
|
2020-08-20 14:47:44 +01:00
|
|
|
|
{
|
2020-08-20 21:07:40 +02:00
|
|
|
|
var status = state ? "OK" : "FAIL";
|
|
|
|
|
var messageType = state ? MessageType.Success : MessageType.Error;
|
|
|
|
|
ToConsole($"* {name} {status}", messageType);
|
2020-08-20 14:47:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-14 22:14:24 +01:00
|
|
|
|
}
|
|
|
|
|
}
|