diff --git a/src/Core_Screencap/Core.ScreenshotManager.cs b/src/Core_Screencap/Core.ScreenshotManager.cs index 542a765..8c931c6 100644 --- a/src/Core_Screencap/Core.ScreenshotManager.cs +++ b/src/Core_Screencap/Core.ScreenshotManager.cs @@ -6,6 +6,7 @@ using Illusion.Game; using System; using System.Collections; +using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.IO; @@ -72,6 +73,14 @@ public partial class ScreenshotManager public static ConfigEntry GuideLinesModes { get; private set; } public static ConfigEntry UIShotUpscale { get; private set; } + // screenshot setting presets + + public static ConfigEntry presetCount { get; private set; } + public static List> presetKeys { get; private set; } = new List>(); + public static List> presetResX { get; private set; } = new List>(); + public static List> presetResY { get; private set; } = new List>(); + public static List> presetDownscaling { get; private set; } = new List>(); + private void InitializeSettings() { KeyCapture = Config.Bind( @@ -194,6 +203,21 @@ private void InitializeSettings() "UI Screenshots", "Screenshot resolution multiplier", 1, new ConfigDescription("Multiplies the UI screenshot resolution from the current game resolution by this amount.\nWarning: Some elements will still be rendered at the original resolution (most notably the interface).", new AcceptableValueRange(1, 8), "Advanced")); + + // config presets + presetCount = Config.Bind( + "Presets", "Preset Count", + 1, + new ConfigDescription("Amount of additional screenshot presets. Requires Restart to apply.", new AcceptableValueRange(0, 10), "Advanced")); + + + for(int i = 0; i < presetCount.Value; i++) + { + presetKeys.Add(Config.Bind("Presets", $"~{i + 1} - Shortcut", KeyboardShortcut.Empty, new ConfigDescription($"Keyboard Shortcut for Preset #{i + 1}.", null, "Advanced"))); + presetResX.Add(Config.Bind("Presets", $"~{i + 1} - Res Horizontal", Screen.width, new ConfigDescription($"Horizontal size (width) of rendered screenshots in pixels of Preset #{i + 1}.", new AcceptableValueRange(ScreenshotSizeMin, ScreenshotSizeMax), "Advanced"))); + presetResY.Add(Config.Bind("Presets", $"~{i + 1} - Res Vertical", Screen.height, new ConfigDescription($"Vertical size (height) of rendered screenshots in pixels of Preset #{i + 1}.", new AcceptableValueRange(ScreenshotSizeMin, ScreenshotSizeMax), "Advanced"))); + presetDownscaling.Add(Config.Bind("Presets", $"~{i + 1} - Upsampling Ratio", 2, new ConfigDescription($"Capture screenshots in a higher resolution and then downscale them to desired size for Preset #{i + 1}. Prevents aliasing, perserves small details and gives a smoother result, but takes longer to create.", new AcceptableValueRange(1, 4), "Advanced"))); + } } #endregion @@ -280,6 +304,13 @@ protected void Update() else if (KeyCapture360.Value.IsDown()) StartCoroutine(Take360Screenshot(false)); else if (KeyCaptureAlphaIn3D.Value.IsDown()) StartCoroutine(TakeCharScreenshot(true)); else if (KeyCapture360in3D.Value.IsDown()) StartCoroutine(Take360Screenshot(true)); + else + { + for (int i = 0; i < presetCount.Value && i < presetKeys.Count; i++) + { + if (presetKeys[i].Value.IsDown()) StartCoroutine(TakeCharScreenshot(false, presetResX[i].Value, presetResY[i].Value, presetDownscaling[i].Value)); + } + } } /// @@ -326,7 +357,7 @@ private IEnumerator TakeScreenshotLog(string filename) Logger.Log(ScreenshotMessage.Value ? LogLevel.Message : LogLevel.Info, $"UI screenshot saved to {filename}"); } - private IEnumerator TakeCharScreenshot(bool in3D) + private IEnumerator TakeCharScreenshot(bool in3D, int resX = -1, int resY = -1, int downscaling = -1) { if (currentAlphaShot == null) { @@ -334,6 +365,10 @@ private IEnumerator TakeCharScreenshot(bool in3D) yield break; } + if (resX <= 0) resX = ResolutionX.Value; + if (resY <= 0) resY = ResolutionY.Value; + if (downscaling <= 0) downscaling = DownscalingRate.Value; + try { OnPreCapture?.Invoke(); } catch (Exception ex) { Logger.LogError(ex); } @@ -350,7 +385,7 @@ private IEnumerator TakeCharScreenshot(bool in3D) if (!in3D) { yield return new WaitForEndOfFrame(); - var capture = currentAlphaShot.CaptureTex(ResolutionX.Value, ResolutionY.Value, DownscalingRate.Value, CaptureAlphaMode.Value); + var capture = currentAlphaShot.CaptureTex(resX, resY, downscaling, CaptureAlphaMode.Value); var filename = GetUniqueFilename("Render"); File.WriteAllBytes(filename, EncodeToFile(capture)); @@ -369,11 +404,11 @@ private IEnumerator TakeCharScreenshot(bool in3D) targetTr.position += targetTr.right * EyeSeparation.Value / 2; // Let the game render at the new position yield return new WaitForEndOfFrame(); - var capture = currentAlphaShot.CaptureTex(ResolutionX.Value, ResolutionY.Value, DownscalingRate.Value, CaptureAlphaMode.Value); + var capture = currentAlphaShot.CaptureTex(resX, resY, downscaling, CaptureAlphaMode.Value); targetTr.position -= targetTr.right * EyeSeparation.Value; yield return new WaitForEndOfFrame(); - var capture2 = currentAlphaShot.CaptureTex(ResolutionX.Value, ResolutionY.Value, DownscalingRate.Value, CaptureAlphaMode.Value); + var capture2 = currentAlphaShot.CaptureTex(resX, resY, downscaling, CaptureAlphaMode.Value); targetTr.position += targetTr.right * EyeSeparation.Value / 2;