using System; using System.Collections.Generic; using System.IO; using Artemis.Core.JsonConverters; using Artemis.Core.Services; using Artemis.Core.Services.Core; using Artemis.Core.SkiaSharp; using Newtonsoft.Json; namespace Artemis.Core { /// /// A few useful constant values /// public static class Constants { /// /// The full path to the Artemis application folder /// public static readonly string ApplicationFolder = Path.GetDirectoryName(typeof(Constants).Assembly.Location)!; /// /// The full path to the Artemis executable /// public static readonly string ExecutablePath = Utilities.GetCurrentLocation(); /// /// The full path to the Artemis data folder /// public static readonly string DataFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Artemis"); /// /// The plugin info used by core components of Artemis /// public static readonly PluginInfo CorePluginInfo = new() { Guid = Guid.Parse("ffffffff-ffff-ffff-ffff-ffffffffffff"), Name = "Artemis Core", Version = new Version(2, 0) }; /// /// The build information related to the currently running Artemis build /// Information is retrieved from buildinfo.json /// public static readonly BuildInfo BuildInfo = File.Exists(Path.Combine(ApplicationFolder, "buildinfo.json")) ? JsonConvert.DeserializeObject(File.ReadAllText(Path.Combine(ApplicationFolder, "buildinfo.json")))! : new BuildInfo { IsLocalBuild = true, BuildId = 1337, BuildNumber = 1337, SourceBranch = "local", SourceVersion = "local" }; /// /// The plugin used by core components of Artemis /// public static readonly Plugin CorePlugin = new(CorePluginInfo, new DirectoryInfo(ApplicationFolder), null); internal static readonly CorePluginFeature CorePluginFeature = new() {Plugin = CorePlugin, Profiler = CorePlugin.GetProfiler("Feature - Core")}; internal static readonly EffectPlaceholderPlugin EffectPlaceholderPlugin = new() {Plugin = CorePlugin, Profiler = CorePlugin.GetProfiler("Feature - Effect Placeholder")}; internal static JsonSerializerSettings JsonConvertSettings = new() { Converters = new List {new SKColorConverter(), new ForgivingIntConverter()} }; internal static JsonSerializerSettings JsonConvertTypedSettings = new() { TypeNameHandling = TypeNameHandling.All, Converters = new List {new SKColorConverter(), new ForgivingIntConverter()} }; /// /// A read-only collection containing all primitive numeric types /// public static IReadOnlyCollection NumberTypes = new List { typeof(sbyte), typeof(byte), typeof(short), typeof(ushort), typeof(int), typeof(uint), typeof(long), typeof(ulong), typeof(float), typeof(double), typeof(decimal) }; /// /// A read-only collection containing all primitive integral numeric types /// public static IReadOnlyCollection IntegralNumberTypes = new List { typeof(sbyte), typeof(byte), typeof(short), typeof(ushort), typeof(int), typeof(uint), typeof(long), typeof(ulong) }; /// /// A read-only collection containing all primitive floating-point numeric types /// public static IReadOnlyCollection FloatNumberTypes = new List { typeof(float), typeof(double), typeof(decimal) }; /// /// Gets the graphics context to be used for rendering by SkiaSharp. Can be set via /// . /// public static IManagedGraphicsContext? ManagedGraphicsContext { get; internal set; } } }