mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-04-20 22:38:16 -04:00
* 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
45 lines
1.1 KiB
C#
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;
|
|
}
|
|
}
|