mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 03:13:21 +08:00
Change screenshot file name
This commit is contained in:
parent
604e725f3f
commit
8429408974
@ -45,7 +45,7 @@ namespace osu.Game.Graphics
|
||||
{
|
||||
host.TakeScreenshot(screenshotBitmap =>
|
||||
{
|
||||
var stream = storage.GetStream($"{DateTime.Now:yyyyMMddTHHmmss}.{screenshotFormat.ToString().ToLower()}", FileAccess.Write);
|
||||
var stream = getFileStream();
|
||||
|
||||
switch (screenshotFormat.Value)
|
||||
{
|
||||
@ -60,5 +60,23 @@ namespace osu.Game.Graphics
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private Stream getFileStream()
|
||||
{
|
||||
var fileExt = screenshotFormat.ToString().ToLower();
|
||||
|
||||
var withoutIndex = $"Screenshot.{fileExt}";
|
||||
if (!storage.Exists(withoutIndex))
|
||||
return storage.GetStream(withoutIndex, FileAccess.Write);
|
||||
|
||||
for (ulong i = 1; i < ulong.MaxValue; i++)
|
||||
{
|
||||
var indexedName = $"Screenshot-{i}.{fileExt}";
|
||||
if (!storage.Exists(indexedName))
|
||||
return storage.GetStream(indexedName, FileAccess.Write);
|
||||
}
|
||||
|
||||
throw new Exception($"Failed to get stream for saving {fileExt} file");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user