-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Screencap] Rudimentary Profiles #208
Open
Njaecha
wants to merge
2
commits into
IllusionMods:master
Choose a base branch
from
Njaecha:Screencap_Profiles
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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<CameraGuideLinesMode> GuideLinesModes { get; private set; } | ||
public static ConfigEntry<int> UIShotUpscale { get; private set; } | ||
|
||
// screenshot setting presets | ||
|
||
public static ConfigEntry<int> presetCount { get; private set; } | ||
public static List<ConfigEntry<KeyboardShortcut>> presetKeys { get; private set; } = new List<ConfigEntry<KeyboardShortcut>>(); | ||
public static List<ConfigEntry<int>> presetResX { get; private set; } = new List<ConfigEntry<int>>(); | ||
public static List<ConfigEntry<int>> presetResY { get; private set; } = new List<ConfigEntry<int>>(); | ||
public static List<ConfigEntry<int>> presetDownscaling { get; private set; } = new List<ConfigEntry<int>>(); | ||
|
||
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<int>(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<int>(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<int>(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<int>(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<int>(1, 4), "Advanced"))); | ||
Comment on lines
+216
to
+219
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't it make more sense to include number of the preset in the category name? e.g. Here's how I implemented something similar, a bit less user friendly though. |
||
} | ||
} | ||
|
||
#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)); | ||
} | ||
} | ||
} | ||
|
||
/// <summary> | ||
|
@@ -326,14 +357,18 @@ 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) | ||
{ | ||
Logger.Log(LogLevel.Message, "Can't render a screenshot here, try UI screenshot instead"); | ||
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; | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather make a struct to hold all these config entries in a single list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understandable, I can fix that 😄