aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremmauss <emmausssss@gmail.com>2021-07-06 19:07:23 +0000
committerGitHub <noreply@github.com>2021-07-06 21:07:23 +0200
commitb0ac1ade7fcde04f15384a329a0eca5ae9ed5065 (patch)
treecb5424db478d7af876e15c32b7fcb1fd974503f6
parenta6c2b5d6ec6d205a421e23b767ed9157c8296656 (diff)
Add portable screenshot folder (#2447)
* add portable screenshot folder * fix style Co-authored-by: Ac_K <Acoustik666@gmail.com> Co-authored-by: Ac_K <Acoustik666@gmail.com>
-rw-r--r--Ryujinx/Ui/RendererWidgetBase.cs26
1 files changed, 22 insertions, 4 deletions
diff --git a/Ryujinx/Ui/RendererWidgetBase.cs b/Ryujinx/Ui/RendererWidgetBase.cs
index dee5cbb6..d74cfec1 100644
--- a/Ryujinx/Ui/RendererWidgetBase.cs
+++ b/Ryujinx/Ui/RendererWidgetBase.cs
@@ -310,7 +310,7 @@ namespace Ryujinx.Ui
private unsafe void Renderer_ScreenCaptured(object sender, ScreenCaptureImageInfo e)
{
- if (e.Data.Length > 0)
+ if (e.Data.Length > 0 && e.Height > 0 && e.Width > 0)
{
Task.Run(() =>
{
@@ -318,10 +318,24 @@ namespace Ryujinx.Ui
{
var 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 directory = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyPictures), "Ryujinx");
- string path = System.IO.Path.Combine(directory, filename);
+ string directory = AppDataManager.Mode switch
+ {
+ AppDataManager.LaunchMode.Portable => System.IO.Path.Combine(AppDataManager.BaseDirPath, "screenshots"),
+ _ => System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyPictures), "Ryujinx")
+ };
+
+ string path = System.IO.Path.Combine(directory, filename);
+
+ try
+ {
+ Directory.CreateDirectory(directory);
+ }
+ catch (Exception ex)
+ {
+ Logger.Error?.Print(LogClass.Application, $"Failed to create directory at path {directory}. Error : {ex.GetType().Name}", "Screenshot");
- Directory.CreateDirectory(directory);
+ return;
+ }
Image image = e.IsBgra ? Image.LoadPixelData<Bgra32>(e.Data, e.Width, e.Height)
: Image.LoadPixelData<Rgba32>(e.Data, e.Width, e.Height);
@@ -347,6 +361,10 @@ namespace Ryujinx.Ui
}
});
}
+ else
+ {
+ Logger.Error?.Print(LogClass.Application, $"Screenshot is empty. Size : {e.Data.Length} bytes. Resolution : {e.Width}x{e.Height}", "Screenshot");
+ }
}
public void Render()