0
0
Fork 0
mirror of https://github.com/ryujinx-mirror/ryujinx.git synced 2024-12-23 04:45:44 +00:00

Add title of game to screenshot text (#6266)

* Add sanitize method

* Add app name to screenshot text output

* Add app name to screenshot text
This commit is contained in:
Kyle 2024-03-07 14:49:57 -08:00 committed by GitHub
parent 2505a1abcd
commit 4e1a60328e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 20 additions and 3 deletions

View file

@ -1,4 +1,6 @@
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
namespace Ryujinx.Common.Utilities namespace Ryujinx.Common.Utilities
{ {
@ -44,5 +46,11 @@ namespace Ryujinx.Common.Utilities
CopyDirectory(sourceDir, destinationDir, true); CopyDirectory(sourceDir, destinationDir, true);
Directory.Delete(sourceDir, true); Directory.Delete(sourceDir, true);
} }
public static string SanitizeFileName(string fileName)
{
var reservedChars = new HashSet<char>(Path.GetInvalidFileNameChars());
return string.Concat(fileName.Select(c => reservedChars.Contains(c) ? '_' : c));
}
} }
} }

View file

@ -3,6 +3,7 @@ using Gtk;
using Ryujinx.Common; using Ryujinx.Common;
using Ryujinx.Common.Configuration; using Ryujinx.Common.Configuration;
using Ryujinx.Common.Logging; using Ryujinx.Common.Logging;
using Ryujinx.Common.Utilities;
using Ryujinx.Graphics.GAL; using Ryujinx.Graphics.GAL;
using Ryujinx.Graphics.GAL.Multithreading; using Ryujinx.Graphics.GAL.Multithreading;
using Ryujinx.Graphics.Gpu; using Ryujinx.Graphics.Gpu;
@ -378,8 +379,12 @@ namespace Ryujinx.UI
{ {
lock (this) lock (this)
{ {
var currentTime = DateTime.Now; string applicationName = Device.Processes.ActiveApplication.Name;
string filename = $"ryujinx_capture_{currentTime.Year}-{currentTime.Month:D2}-{currentTime.Day:D2}_{currentTime.Hour:D2}-{currentTime.Minute:D2}-{currentTime.Second:D2}.png"; string sanitizedApplicationName = FileSystemUtils.SanitizeFileName(applicationName);
DateTime currentTime = DateTime.Now;
string filename = $"{sanitizedApplicationName}_{currentTime.Year}-{currentTime.Month:D2}-{currentTime.Day:D2}_{currentTime.Hour:D2}-{currentTime.Minute:D2}-{currentTime.Second:D2}.png";
string directory = AppDataManager.Mode switch string directory = AppDataManager.Mode switch
{ {
AppDataManager.LaunchMode.Portable or AppDataManager.LaunchMode.Custom => System.IO.Path.Combine(AppDataManager.BaseDirPath, "screenshots"), AppDataManager.LaunchMode.Portable or AppDataManager.LaunchMode.Custom => System.IO.Path.Combine(AppDataManager.BaseDirPath, "screenshots"),

View file

@ -22,6 +22,7 @@ using Ryujinx.Common.Configuration;
using Ryujinx.Common.Configuration.Multiplayer; using Ryujinx.Common.Configuration.Multiplayer;
using Ryujinx.Common.Logging; using Ryujinx.Common.Logging;
using Ryujinx.Common.SystemInterop; using Ryujinx.Common.SystemInterop;
using Ryujinx.Common.Utilities;
using Ryujinx.Graphics.GAL; using Ryujinx.Graphics.GAL;
using Ryujinx.Graphics.GAL.Multithreading; using Ryujinx.Graphics.GAL.Multithreading;
using Ryujinx.Graphics.Gpu; using Ryujinx.Graphics.Gpu;
@ -279,8 +280,11 @@ namespace Ryujinx.Ava
{ {
lock (_lockObject) lock (_lockObject)
{ {
string applicationName = Device.Processes.ActiveApplication.Name;
string sanitizedApplicationName = FileSystemUtils.SanitizeFileName(applicationName);
DateTime currentTime = DateTime.Now; DateTime currentTime = DateTime.Now;
string filename = $"ryujinx_capture_{currentTime.Year}-{currentTime.Month:D2}-{currentTime.Day:D2}_{currentTime.Hour:D2}-{currentTime.Minute:D2}-{currentTime.Second:D2}.png";
string filename = $"{sanitizedApplicationName}_{currentTime.Year}-{currentTime.Month:D2}-{currentTime.Day:D2}_{currentTime.Hour:D2}-{currentTime.Minute:D2}-{currentTime.Second:D2}.png";
string directory = AppDataManager.Mode switch string directory = AppDataManager.Mode switch
{ {