mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-01-16 02:09:20 -05:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
49 lines
1.2 KiB
C#
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;
|
|
}
|
|
}
|