using System; using System.Reflection; using System.Runtime.CompilerServices; using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; using Barotrauma; using HarmonyLib; using Microsoft.Xna.Framework; using System.IO; namespace QICrabUI { public partial class CUI { /// /// $"‖color:{color}‖{msg}‖end‖" /// /// /// /// public static string WrapInColor(object msg, string color) { return $"‖color:{color}‖{msg}‖end‖"; } //HACK too lazy to make good name /// /// Serializes the array /// /// /// public static string ArrayToString(IEnumerable array) { return $"[{String.Join(", ", array.Select(o => o.ToString()))}]"; } /// /// Prints a message to console /// /// /// public static void Log(object msg, Color? color = null, [CallerFilePath] string source = "", [CallerLineNumber] int lineNumber = 0) { color ??= Color.Cyan; // var fi = new FileInfo(source); // LuaCsLogger.LogMessage($"{fi.Directory.Name}/{fi.Name}:{lineNumber}", color * 0.6f, color * 0.6f); LuaCsLogger.LogMessage($"{msg ?? "null"}", color * 0.8f, color); } public static void Warning(object msg, Color? color = null, [CallerFilePath] string source = "", [CallerLineNumber] int lineNumber = 0) { color ??= Color.Yellow; // var fi = new FileInfo(source); // LuaCsLogger.LogMessage($"{fi.Directory.Name}/{fi.Name}:{lineNumber}", color * 0.6f, color * 0.6f); LuaCsLogger.LogMessage($"{msg ?? "null"}", color * 0.8f, color); } /// /// xd /// /// This should be injected by compiler, don't set /// public static string GetCallerFolderPath([CallerFilePath] string source = "") => Path.GetDirectoryName(source); /// /// Prints debug message with source path /// Works only if debug is true /// /// public static void Info(object msg, [CallerFilePath] string source = "", [CallerLineNumber] int lineNumber = 0) { if (Debug == true) { var fi = new FileInfo(source); Log($"{fi.Directory.Name}/{fi.Name}:{lineNumber}", Color.Yellow * 0.5f); Log(msg, Color.Yellow); } } } }