using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AnsiConsolePlugin.Util;
using BepInEx;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization")]
[assembly: AssemblyCompany("AnsiConsolePlugin")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A mod that enables ANSI for Windows 10+ in BepInEx.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AnsiConsolePlugin")]
[assembly: AssemblyTitle("AnsiConsolePlugin")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace AnsiConsolePlugin
{
[BepInPlugin("creator.BepInEx.ANSI", "ANSI Mod", "1.0.0")]
public class DraftingMod : BaseUnityPlugin
{
public const string PluginGuid = "creator.BepInEx.ANSI";
public const string PluginName = "ANSI Mod";
public const string PluginVersion = "1.0.0";
public static ManualLogSource Log = new ManualLogSource("ANSI Mod");
public void Awake()
{
try
{
EnableNativeAnsiUtil.EnableNativeAnsi();
}
catch
{
Log.LogError((object)"Unable to enable ANSI Code Handling.");
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "AnsiConsolePlugin";
public const string PLUGIN_NAME = "AnsiConsolePlugin";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace AnsiConsolePlugin.Util
{
public class ANSICodeLists
{
public static readonly string[] ColorList = new string[8] { "\u001b[0;30m", "\u001b[0;31m", "\u001b[0;32m", "\u001b[0;33m", "\u001b[0;34m", "\u001b[0;35m", "\u001b[0;36m", "\u001b[0;37m" };
public static readonly string[] BoldColorList = new string[8] { "\u001b[1;30m", "\u001b[1;31m", "\u001b[1;32m", "\u001b[1;33m", "\u001b[1;34m", "\u001b[1;35m", "\u001b[1;36m", "\u001b[1;37m" };
public static readonly string[] DarkenedColorList = new string[8] { "\u001b[2;30m", "\u001b[2;31m", "\u001b[2;32m", "\u001b[2;33m", "\u001b[2;34m", "\u001b[2;35m", "\u001b[2;36m", "\u001b[2;37m" };
public static readonly string[] ItalicColorList = new string[8] { "\u001b[3;30m", "\u001b[3;31m", "\u001b[3;32m", "\u001b[3;33m", "\u001b[3;34m", "\u001b[3;35m", "\u001b[3;36m", "\u001b[3;37m" };
public static readonly string[] UnderlineColorList = new string[8] { "\u001b[4;30m", "\u001b[4;31m", "\u001b[4;32m", "\u001b[4;33m", "\u001b[4;34m", "\u001b[4;35m", "\u001b[4;36m", "\u001b[4;37m" };
public static readonly string[] FlashyColorList = new string[8] { "\u001b[5;30m", "\u001b[5;31m", "\u001b[5;32m", "\u001b[5;33m", "\u001b[5;34m", "\u001b[5;35m", "\u001b[5;36m", "\u001b[5;37m" };
public static readonly string[] HighlighterColorList = new string[8] { "\u001b[7;30m", "\u001b[7;31m", "\u001b[7;32m", "\u001b[7;33m", "\u001b[7;34m", "\u001b[7;35m", "\u001b[7;36m", "\u001b[7;37m" };
public static readonly string[] InvisibleColorList = new string[8] { "\u001b[8;30m", "\u001b[8;31m", "\u001b[8;32m", "\u001b[8;33m", "\u001b[8;34m", "\u001b[8;35m", "\u001b[8;36m", "\u001b[8;37m" };
public static readonly string[] StrikethroughColorList = new string[8] { "\u001b[9;30m", "\u001b[9;31m", "\u001b[9;32m", "\u001b[9;33m", "\u001b[9;34m", "\u001b[9;35m", "\u001b[9;36m", "\u001b[9;37m" };
public static readonly string[] BackgroundColorList = new string[8] { "\u001b[40m", "\u001b[41m", "\u001b[42m", "\u001b[43m", "\u001b[44m", "\u001b[45m", "\u001b[46m", "\u001b[47m" };
public static readonly string[] HighIntensityBackgroundColorList = new string[8] { "\u001b[0;100m", "\u001b[0;101m", "\u001b[0;102m", "\u001b[0;103m", "\u001b[0;104m", "\u001b[0;105m", "\u001b[0;106m", "\u001b[0;107m" };
public static readonly string[] HighIntensityColorList = new string[8] { "\u001b[0;90m", "\u001b[0;91m", "\u001b[0;92m", "\u001b[0;93m", "\u001b[0;94m", "\u001b[0;95m", "\u001b[0;96m", "\u001b[0;97m" };
public static readonly string[] HighIntensityBoldColorList = new string[8] { "\u001b[1;90m", "\u001b[1;91m", "\u001b[1;92m", "\u001b[1;93m", "\u001b[1;94m", "\u001b[1;95m", "\u001b[1;96m", "\u001b[1;97m" };
public static readonly string[] HighIntensityDarkenedColorList = new string[8] { "\u001b[2;90m", "\u001b[2;91m", "\u001b[2;92m", "\u001b[2;93m", "\u001b[2;94m", "\u001b[2;95m", "\u001b[2;96m", "\u001b[2;97m" };
public static readonly string[] HighIntensityItalicColorList = new string[8] { "\u001b[9;90m", "\u001b[9;91m", "\u001b[9;92m", "\u001b[9;93m", "\u001b[9;94m", "\u001b[9;95m", "\u001b[9;96m", "\u001b[9;97m" };
public static readonly string[] HighIntensityUnderlineColorList = new string[8] { "\u001b[4;90m", "\u001b[4;91m", "\u001b[4;92m", "\u001b[4;93m", "\u001b[4;94m", "\u001b[4;95m", "\u001b[4;96m", "\u001b[4;97m" };
public static readonly string[] HighIntensityFlashyColorList = new string[8] { "\u001b[5;90m", "\u001b[5;91m", "\u001b[5;92m", "\u001b[5;93m", "\u001b[5;94m", "\u001b[5;95m", "\u001b[5;96m", "\u001b[5;97m" };
public static readonly string[] HighIntensityHighlighterColorList = new string[8] { "\u001b[7;90m", "\u001b[7;91m", "\u001b[7;92m", "\u001b[7;93m", "\u001b[7;94m", "\u001b[7;95m", "\u001b[7;96m", "\u001b[7;97m" };
public static readonly string[] HighIntensityInvisibleColorList = new string[8] { "\u001b[8;90m", "\u001b[8;91m", "\u001b[8;92m", "\u001b[8;93m", "\u001b[8;94m", "\u001b[8;95m", "\u001b[8;96m", "\u001b[8;97m" };
public static readonly string[] HighIntensityStrikethroughColorList = new string[8] { "\u001b[9;90m", "\u001b[9;91m", "\u001b[9;92m", "\u001b[9;93m", "\u001b[9;94m", "\u001b[9;95m", "\u001b[9;96m", "\u001b[9;97m" };
public const string ResetColor = "\u001b[0m";
}
public class EnableNativeAnsiUtil
{
public static void EnableNativeAnsi()
{
IntPtr stdHandle = GetStdHandle(-11);
GetConsoleMode(stdHandle, out var lpMode);
lpMode |= 4u;
SetConsoleMode(stdHandle, lpMode);
}
[DllImport("kernel32.dll", SetLastError = true)]
public static extern IntPtr GetStdHandle(int nStdHandle);
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool GetConsoleMode(IntPtr hConsoleHandle, out uint lpMode);
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool SetConsoleMode(IntPtr hConsoleHandle, uint dwMode);
}
public class GetColorFromTypeFunctions
{
public static string GetColorFromInt(int X, string Type)
{
return (string)((object[])(Type switch
{
"Regular" => ANSICodeLists.ColorList,
"Bold" => ANSICodeLists.BoldColorList,
"Darkened" => ANSICodeLists.DarkenedColorList,
"Italic" => ANSICodeLists.ItalicColorList,
"Underlined" => ANSICodeLists.UnderlineColorList,
"Flashy" => ANSICodeLists.FlashyColorList,
"Highlighter" => ANSICodeLists.HighlighterColorList,
"Invisible" => ANSICodeLists.InvisibleColorList,
"Strikethrough" => ANSICodeLists.StrikethroughColorList,
"Background" => ANSICodeLists.BackgroundColorList,
"HighIntensityRegular" => ANSICodeLists.HighIntensityColorList,
"HighIntensityBold" => ANSICodeLists.HighIntensityBoldColorList,
"HighIntensityDarkened" => ANSICodeLists.HighIntensityDarkenedColorList,
"HighIntensityItalic" => ANSICodeLists.HighIntensityItalicColorList,
"HighIntensityUnderlined" => ANSICodeLists.HighIntensityUnderlineColorList,
"HighIntensityFlashy" => ANSICodeLists.HighIntensityFlashyColorList,
"HighIntensityHighlighter" => ANSICodeLists.HighIntensityHighlighterColorList,
"HighIntensityInvisible" => ANSICodeLists.HighIntensityInvisibleColorList,
"HighIntensityStrikethrough" => ANSICodeLists.HighIntensityStrikethroughColorList,
"HighIntensityBackground" => ANSICodeLists.HighIntensityBackgroundColorList,
_ => ANSICodeLists.ColorList,
}))[X];
}
public static string GetColorFromString(string Color, string Type)
{
int num = Color switch
{
"Black" => 0,
"Red" => 1,
"Green" => 2,
"Yellow" => 3,
"Blue" => 4,
"Magenta" => 5,
"Cyan" => 6,
"White" => 7,
_ => 7,
};
return (string)((object[])(Type switch
{
"Regular" => ANSICodeLists.ColorList,
"Bold" => ANSICodeLists.BoldColorList,
"Darkened" => ANSICodeLists.DarkenedColorList,
"Italic" => ANSICodeLists.ItalicColorList,
"Underlined" => ANSICodeLists.UnderlineColorList,
"Flashy" => ANSICodeLists.FlashyColorList,
"Highlighter" => ANSICodeLists.HighlighterColorList,
"Invisible" => ANSICodeLists.InvisibleColorList,
"Strikethrough" => ANSICodeLists.StrikethroughColorList,
"Background" => ANSICodeLists.BackgroundColorList,
"HighIntensityRegular" => ANSICodeLists.HighIntensityColorList,
"HighIntensityBold" => ANSICodeLists.HighIntensityBoldColorList,
"HighIntensityDarkened" => ANSICodeLists.HighIntensityDarkenedColorList,
"HighIntensityItalic" => ANSICodeLists.HighIntensityItalicColorList,
"HighIntensityUnderlined" => ANSICodeLists.HighIntensityUnderlineColorList,
"HighIntensityFlashy" => ANSICodeLists.HighIntensityFlashyColorList,
"HighIntensityHighlighter" => ANSICodeLists.HighIntensityHighlighterColorList,
"HighIntensityInvisible" => ANSICodeLists.HighIntensityInvisibleColorList,
"HighIntensityStrikethrough" => ANSICodeLists.HighIntensityStrikethroughColorList,
"HighIntensityBackground" => ANSICodeLists.HighIntensityBackgroundColorList,
_ => ANSICodeLists.ColorList,
}))[num];
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}