From a7b191b11a9d9b0bce5e104afee69261646f9e3c Mon Sep 17 00:00:00 2001 From: Nikolay Kuznetsov Date: Wed, 23 Feb 2022 00:10:11 +0100 Subject: [PATCH] LFS: update string setting to a enum setting, add an option for custom resolution --- LagFreeScreenshots/LagFreeScreenshots.csproj | 2 +- LagFreeScreenshots/LagFreeScreenshotsMod.cs | 43 +++++++++++++------- LagFreeScreenshots/PresetScreenshotSizes.cs | 34 ++++++++++++++++ ReleaseChangelog.md | 2 + 4 files changed, 65 insertions(+), 16 deletions(-) create mode 100644 LagFreeScreenshots/PresetScreenshotSizes.cs diff --git a/LagFreeScreenshots/LagFreeScreenshots.csproj b/LagFreeScreenshots/LagFreeScreenshots.csproj index a9b0c42..7148cd2 100644 --- a/LagFreeScreenshots/LagFreeScreenshots.csproj +++ b/LagFreeScreenshots/LagFreeScreenshots.csproj @@ -5,7 +5,7 @@ true true latest - 1.3.1.0 + 1.4.0.0 diff --git a/LagFreeScreenshots/LagFreeScreenshotsMod.cs b/LagFreeScreenshots/LagFreeScreenshotsMod.cs index 8d43d74..0bd187c 100644 --- a/LagFreeScreenshots/LagFreeScreenshotsMod.cs +++ b/LagFreeScreenshots/LagFreeScreenshotsMod.cs @@ -29,7 +29,7 @@ // using CameraUtil = ObjectPublicCaSiVeUnique; -[assembly:MelonInfo(typeof(LagFreeScreenshotsMod), "Lag Free Screenshots", "1.3.1", "knah, Protected", "https://github.com/knah/VRCMods")] +[assembly:MelonInfo(typeof(LagFreeScreenshotsMod), "Lag Free Screenshots", "1.4.0", "knah, Protected", "https://github.com/knah/VRCMods")] [assembly:MelonGame("VRChat", "VRChat")] namespace LagFreeScreenshots @@ -43,11 +43,16 @@ internal partial class LagFreeScreenshotsMod : MelonMod private const string SettingJpegPercent = "JpegPercent"; private const string SettingAutorotation = "Auto-rotation"; private const string SettingMetadata = "Metadata"; + private const string SettingRecommendedMaximumFb = "RecommendedMaximumFb"; + private const string SettingCustomResolutionX = "CustomResolutionX"; + private const string SettingCustomResolutionY = "CustomResolutionY"; private static MelonPreferences_Entry ourEnabled; - private static MelonPreferences_Entry ourResolution; + private static MelonPreferences_Entry ourResolution; private static MelonPreferences_Entry ourFormat; private static MelonPreferences_Entry ourJpegPercent; + private static MelonPreferences_Entry ourCustomResolutionX; + private static MelonPreferences_Entry ourCustomResolutionY; private static MelonPreferences_Entry ourAutorotation; private static MelonPreferences_Entry ourMetadata; private static MelonPreferences_Entry ourRecommendedMaxFb; @@ -58,12 +63,14 @@ public override void OnApplicationStart() { var category = MelonPreferences.CreateCategory(SettingsCategory, "Lag Free Screenshots"); ourEnabled = category.CreateEntry(SettingEnableMod, true, "Enabled"); - ourResolution = category.CreateEntry( SettingScreenshotResolution, "default", "Screenshot resolution"); - ourFormat = category.CreateEntry( SettingScreenshotFormat, "auto", "Screenshot format"); + ourResolution = category.CreateEntry( SettingScreenshotResolution, PresetScreenshotSizes.Default, "Screenshot resolution override"); + ourFormat = category.CreateEntry( SettingScreenshotFormat, "png", "Screenshot format"); ourJpegPercent = category.CreateEntry(SettingJpegPercent, 95, "JPEG quality (0-100)"); ourAutorotation = category.CreateEntry(SettingAutorotation, true, "Rotate picture to match camera"); ourMetadata = category.CreateEntry(SettingMetadata, false, "Save metadata in picture"); - ourRecommendedMaxFb = category.CreateEntry("RecommendedMaximumFb", 1024, "Try to keep framebuffer below (MB) by reducing MSAA"); + ourRecommendedMaxFb = category.CreateEntry(SettingRecommendedMaximumFb, 1024, "Try to keep framebuffer below (MB) by reducing MSAA"); + ourCustomResolutionX = category.CreateEntry(SettingCustomResolutionX, 1920, "Custom screenshot resolution (X)"); + ourCustomResolutionY = category.CreateEntry(SettingCustomResolutionY, 1080, "Custom screenshot resolution (Y)"); if (!MelonHandler.Mods.Any(it => it.Info.Name == "UI Expansion Kit" && it.Assembly.GetName().Version >= new Version(0, 2, 6))) { @@ -83,8 +90,10 @@ private static void AddEnumSettings() { ExpansionKitApi.RegisterSettingAsStringEnum(SettingsCategory, SettingScreenshotFormat, new []{("png", "PNG"), ("jpeg", "JPEG"), ("auto", "Auto")}); - ExpansionKitApi.RegisterSettingAsStringEnum(SettingsCategory, SettingScreenshotResolution, - new []{("default", "Default"), ("100x100", "Thumbnail 100x100"), ("1024x1024", "Square 1024x1024"), ("720p", "720p"), ("1080p","1080p"), ("4K","4K"), ("8K", "8K")}); + var updaterX = ExpansionKitApi.RegisterSettingsVisibilityCallback(SettingsCategory, SettingCustomResolutionX, () => ourResolution.Value == PresetScreenshotSizes.Custom); + var updaterY = ExpansionKitApi.RegisterSettingsVisibilityCallback(SettingsCategory, SettingCustomResolutionY, () => ourResolution.Value == PresetScreenshotSizes.Custom); + ourResolution.OnValueChangedUntyped += updaterX; + ourResolution.OnValueChangedUntyped += updaterY; } private static ScreenshotRotation GetPictureAutorotation(Camera camera) @@ -161,17 +170,21 @@ public static bool MoveNextPatchAsyncReadback(ref bool __result, CameraTakePhoto return false; } - public static (int width, int height)? ImageResolution(String d) + public static (int width, int height)? ImageResolution(PresetScreenshotSizes d) { return d switch { - "100x100" => (100, 100), - "1024x1024" => (1024, 1024), - "720p" => (1280, 720), - "1080p" => (1920, 1080), - "4K" => (3840, 2160), - "8K" => (7680, 4320), - _ => null, + PresetScreenshotSizes.Default => null, + PresetScreenshotSizes.Custom => (ourCustomResolutionX.Value, ourCustomResolutionY.Value), + PresetScreenshotSizes.Thumbnail => (100, 100), + PresetScreenshotSizes.Square => (1024, 1024), + PresetScreenshotSizes._720p => (1280, 720), + PresetScreenshotSizes._1080p => (1920, 1080), + PresetScreenshotSizes._4K => (3840, 2160), + PresetScreenshotSizes._8K => (7680, 4320), + PresetScreenshotSizes._12K => (11520, 6480), + PresetScreenshotSizes._16K => (15360, 8640), + _ => throw new ArgumentOutOfRangeException(nameof(d), d, null) }; } diff --git a/LagFreeScreenshots/PresetScreenshotSizes.cs b/LagFreeScreenshots/PresetScreenshotSizes.cs new file mode 100644 index 0000000..647e6c8 --- /dev/null +++ b/LagFreeScreenshots/PresetScreenshotSizes.cs @@ -0,0 +1,34 @@ +using System.ComponentModel; + +namespace LagFreeScreenshots +{ + internal enum PresetScreenshotSizes + { + Default, + Custom, + + [Description("Thumbnail 100x100")] + Thumbnail, + + [Description("Square 1024x1024")] + Square, + + [Description("1280x720")] + _720p, + + [Description("1920x1080 (VRC default)")] + _1080p, + + [Description("4K (3840x2160)")] + _4K, + + [Description("8K (7680x4320)")] + _8K, + + [Description("12K (11520x6480)")] + _12K, + + [Description("16K (15360x8640)")] + _16K, + } +} \ No newline at end of file diff --git a/ReleaseChangelog.md b/ReleaseChangelog.md index 8c17a01..df65bc0 100644 --- a/ReleaseChangelog.md +++ b/ReleaseChangelog.md @@ -9,6 +9,8 @@ Changes: * CameraMinus: added toggles for grabbing the camera and camera UI * IKTweaks: added settings for elbow/knee/chest bend goal offsets (see README) * Advanced Safety: minor tuning to some patches + * Lag Free Screenshots: added auto screenshot type (png for transparent, jpeg for non-transparent, contributed by @dakyneko) + * Lag Free Screenshots: added screenshot resolution override (contributed by @dakyneko) * Updated the following mods to new UIX APIs: * Advanced Safety * CameraMinus