Files
sbox-public/engine/Sandbox.Engine/Systems/Render/Multimedia/ScreenCaptureUtility.cs
s&box team 71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00

49 lines
1.2 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 )
{
// Extract path component
var 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;
}
}