1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 22:33:05 +08:00

Change screenshot file name

This commit is contained in:
TocoToucan 2018-03-16 21:05:25 +03:00
parent 604e725f3f
commit 8429408974

View File

@ -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");
}
}
}