Skip to content
This repository has been archived by the owner on May 15, 2023. It is now read-only.

Commit

Permalink
LFS: update string setting to a enum setting, add an option for custo…
Browse files Browse the repository at this point in the history
…m resolution
  • Loading branch information
knah committed Feb 22, 2022
1 parent f9a6582 commit a7b191b
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 16 deletions.
2 changes: 1 addition & 1 deletion LagFreeScreenshots/LagFreeScreenshots.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<VrcReferences>true</VrcReferences>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
<Version>1.3.1.0</Version>
<Version>1.4.0.0</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
43 changes: 28 additions & 15 deletions LagFreeScreenshots/LagFreeScreenshotsMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<bool> ourEnabled;
private static MelonPreferences_Entry<string> ourResolution;
private static MelonPreferences_Entry<PresetScreenshotSizes> ourResolution;
private static MelonPreferences_Entry<string> ourFormat;
private static MelonPreferences_Entry<int> ourJpegPercent;
private static MelonPreferences_Entry<int> ourCustomResolutionX;
private static MelonPreferences_Entry<int> ourCustomResolutionY;
private static MelonPreferences_Entry<bool> ourAutorotation;
private static MelonPreferences_Entry<bool> ourMetadata;
private static MelonPreferences_Entry<int> ourRecommendedMaxFb;
Expand All @@ -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)))
{
Expand All @@ -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)
Expand Down Expand Up @@ -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)
};
}

Expand Down
34 changes: 34 additions & 0 deletions LagFreeScreenshots/PresetScreenshotSizes.cs
Original file line number Diff line number Diff line change
@@ -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,
}
}
2 changes: 2 additions & 0 deletions ReleaseChangelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a7b191b

Please sign in to comment.