Files
sbox-public/engine/Sandbox.Engine/Systems/Render/Multimedia/ScreenCaptureUtility.cs
James King e24c2b592f Movie Maker Fix Mix (#4254)
* Support types like Curve, Gradient, ParticleGradient in movies
* Fix TransformOperation.OnReduce: old implementation was nonsense, could stack overflow
* Add optional filePath parameter to GenerateScreenshotFilename
* Force movie project to save even if we don't think it's changed
* ITemporaryEffect.IsActive pseudo-property for movie recordings
* Add ITrack.GetPathString() extension
* Safety when trying to compress a sample block
* Skip updating playback rate on renderers with a bone merge target
* Move PropertySignal<T>.FromSamples to PropertySignal
* Fix view not always updating when zooming
* Enabled tracks defaults to false when applying
* Movie export: manually call Scene.EditorTick, pause updates elsewhere (fixes Facepunch/sbox-public#10137)
* CanMakeTrackFromProperties: default to only allowing user types
2026-03-10 11:03:42 +00:00

45 lines
1.1 KiB
C#

using System.IO;
namespace Sandbox;
/// <summary>
/// Utility methods for screen recording and screenshot functionality
/// </summary>
internal static class ScreenCaptureUtility
{
/// <summary>
/// Generates a suitable screenshot filename with timestamp
/// </summary>
public static string GenerateScreenshotFilename( string extension, string filePath = "screenshots" )
{
var fileName = ConsoleSystem.GetValue( "screenshot_prefix", "sbox_" );
if ( string.IsNullOrEmpty( fileName ) )
{
fileName = "sbox_";
}
// Format extension with dot if needed
string extensionSeparator = "";
if ( !string.IsNullOrEmpty( extension ) && !extension.StartsWith( "." ) )
{
extensionSeparator = ".";
}
// Get timestamp
string timestamp = DateTime.Now.ToString( "yyyy.MM.dd.HH.mm.ss" );
// Generate final filename
string screenshotFilename;
if ( !string.IsNullOrEmpty( filePath ) )
{
screenshotFilename = Path.Combine( filePath, $"{fileName}.{timestamp}{extensionSeparator}{extension}" );
}
else
{
screenshotFilename = $"{fileName}.{timestamp}{extensionSeparator}{extension}";
}
return screenshotFilename;
}
}