using System.Drawing.Imaging; using Dalamud.Configuration; using Dalamud.Game.ClientState.GamePad; using FFXIVClientStructs.FFXIV.Client.UI; using Scriban; using Scriban.Parsing; namespace Screenie; [Serializable] public class Configuration : IPluginConfiguration { public int Version { get; set; } = 1; public string SaveDirectory = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "Screenie"); public Format SaveFormat = Format.Png; public int SaveFormatData = 90; public string SaveFileNameFormat = """ {{ captured_at_local | date.to_string '%Y/%m %b/[%H.%M.%S]' }} {{ if active_character -}} {{ active_character.name }} - {{ location }} {{- else -}} Main Menu or Loading Screen {{- end -}} {{- if area }} ({{ area }}) {{- end -}} {{- if ward }} W{{ ward }} {{- end -}} {{- if plot -}} P{{ plot }} {{- end -}} """; public GamepadButtons GamepadKeybind = GamepadButtons.L1 | GamepadButtons.Start; public List KeyboardKeybind = []; public bool DisableNativeScreenshots = true; private int _templateHashCode; private Template? _template; internal Template SaveFileNameTemplate { get { var currentHash = this.SaveFileNameFormat.GetHashCode(); if (currentHash == this._templateHashCode && this._template != null) { return this._template; } this._templateHashCode = currentHash; this._template = Template.Parse( this.SaveFileNameFormat, parserOptions: new ParserOptions { LiquidFunctionsToScriban = true, } ); return this._template; } } } public enum Format { Png, WebpLossless, WebpLossy, Jpg, // AvifLossless, // AvifLossy, // HeicLossless, // HeicLossy, } public static class FormatExt { public static string Name(this Format format) { return format switch { Format.Png => "PNG", Format.WebpLossless => "WEBP (lossless)", Format.WebpLossy => "WEBP (lossy)", Format.Jpg => "JPG", // Format.AvifLossless => "AVIF (lossless)", // Format.AvifLossy => "AVIF (lossy)", // Format.HeicLossless => "HEIC (lossless)", // Format.HeicLossy => "HEIC (lossy)", _ => throw new ArgumentOutOfRangeException(nameof(format), format, null), }; } public static ImageFormat? ToImageFormat(this Format format) { return format switch { Format.Png => ImageFormat.Png, Format.WebpLossless => null, Format.WebpLossy => null, Format.Jpg => ImageFormat.Jpeg, // Format.AvifLossless => null, // Format.AvifLossy => null, // Format.HeicLossless => null, // Format.HeicLossy => null, _ => throw new ArgumentOutOfRangeException(nameof(format), format, null), }; } }