aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAc_K <Acoustik666@gmail.com>2023-01-22 01:42:55 +0100
committerGitHub <noreply@github.com>2023-01-22 01:42:55 +0100
commitc14844d12c199894ba3ad75ff48802ad09f2b498 (patch)
tree6f20b11104b97fb8bbeaa156331c2171e78266a2
parent7fea26e97e74e7ec0a5fa27921aa40c31b2c1dd9 (diff)
Ava UI: Various Fixes (#4326)1.1.587
* Ava UI: Various Fixes * use WriteAllBytes
-rw-r--r--Ryujinx.Ava/AppHost.cs4
-rw-r--r--Ryujinx.Ava/UI/Renderer/EmbeddedWindow.cs129
-rw-r--r--Ryujinx.Ava/UI/ViewModels/TitleUpdateViewModel.cs26
-rw-r--r--Ryujinx.Ava/UI/Windows/TitleUpdateWindow.axaml.cs19
4 files changed, 96 insertions, 82 deletions
diff --git a/Ryujinx.Ava/AppHost.cs b/Ryujinx.Ava/AppHost.cs
index fdeee2cc..ad33d08c 100644
--- a/Ryujinx.Ava/AppHost.cs
+++ b/Ryujinx.Ava/AppHost.cs
@@ -231,7 +231,7 @@ namespace Ryujinx.Ava
}
}
- private unsafe void Renderer_ScreenCaptured(object sender, ScreenCaptureImageInfo e)
+ private void Renderer_ScreenCaptured(object sender, ScreenCaptureImageInfo e)
{
if (e.Data.Length > 0 && e.Height > 0 && e.Width > 0)
{
@@ -240,7 +240,7 @@ namespace Ryujinx.Ava
lock (_lockObject)
{
DateTime currentTime = DateTime.Now;
- string filename = $"ryujinx_capture_{currentTime}-{currentTime:D2}-{currentTime:D2}_{currentTime:D2}-{currentTime:D2}-{currentTime:D2}.png";
+ string filename = $"ryujinx_capture_{currentTime.Year}-{currentTime.Month:D2}-{currentTime.Day:D2}_{currentTime.Hour:D2}-{currentTime.Minute:D2}-{currentTime.Second:D2}.png";
string directory = AppDataManager.Mode switch
{
diff --git a/Ryujinx.Ava/UI/Renderer/EmbeddedWindow.cs b/Ryujinx.Ava/UI/Renderer/EmbeddedWindow.cs
index 6cacfef4..532f4dc2 100644
--- a/Ryujinx.Ava/UI/Renderer/EmbeddedWindow.cs
+++ b/Ryujinx.Ava/UI/Renderer/EmbeddedWindow.cs
@@ -140,68 +140,75 @@ namespace Ryujinx.Ava.UI.Renderer
{
if (VisualRoot != null)
{
- Point rootVisualPosition = this.TranslatePoint(new Point((long)lParam & 0xFFFF, (long)lParam >> 16 & 0xFFFF), VisualRoot).Value;
- Pointer pointer = new(0, PointerType.Mouse, true);
-
- switch (msg)
+ if (msg == WindowsMessages.LBUTTONDOWN ||
+ msg == WindowsMessages.RBUTTONDOWN ||
+ msg == WindowsMessages.LBUTTONUP ||
+ msg == WindowsMessages.RBUTTONUP ||
+ msg == WindowsMessages.MOUSEMOVE)
{
- case WindowsMessages.LBUTTONDOWN:
- case WindowsMessages.RBUTTONDOWN:
- {
- bool isLeft = msg == WindowsMessages.LBUTTONDOWN;
- RawInputModifiers pointerPointModifier = isLeft ? RawInputModifiers.LeftMouseButton : RawInputModifiers.RightMouseButton;
- PointerPointProperties properties = new(pointerPointModifier, isLeft ? PointerUpdateKind.LeftButtonPressed : PointerUpdateKind.RightButtonPressed);
-
- var evnt = new PointerPressedEventArgs(
- this,
- pointer,
- VisualRoot,
- rootVisualPosition,
- (ulong)Environment.TickCount64,
- properties,
- KeyModifiers.None);
-
- RaiseEvent(evnt);
-
- break;
- }
- case WindowsMessages.LBUTTONUP:
- case WindowsMessages.RBUTTONUP:
- {
- bool isLeft = msg == WindowsMessages.LBUTTONUP;
- RawInputModifiers pointerPointModifier = isLeft ? RawInputModifiers.LeftMouseButton : RawInputModifiers.RightMouseButton;
- PointerPointProperties properties = new(pointerPointModifier, isLeft ? PointerUpdateKind.LeftButtonReleased : PointerUpdateKind.RightButtonReleased);
-
- var evnt = new PointerReleasedEventArgs(
- this,
- pointer,
- VisualRoot,
- rootVisualPosition,
- (ulong)Environment.TickCount64,
- properties,
- KeyModifiers.None,
- isLeft ? MouseButton.Left : MouseButton.Right);
-
- RaiseEvent(evnt);
-
- break;
- }
- case WindowsMessages.MOUSEMOVE:
- {
- var evnt = new PointerEventArgs(
- PointerMovedEvent,
- this,
- pointer,
- VisualRoot,
- rootVisualPosition,
- (ulong)Environment.TickCount64,
- new PointerPointProperties(RawInputModifiers.None, PointerUpdateKind.Other),
- KeyModifiers.None);
-
- RaiseEvent(evnt);
-
- break;
- }
+ Point rootVisualPosition = this.TranslatePoint(new Point((long)lParam & 0xFFFF, (long)lParam >> 16 & 0xFFFF), VisualRoot).Value;
+ Pointer pointer = new(0, PointerType.Mouse, true);
+
+ switch (msg)
+ {
+ case WindowsMessages.LBUTTONDOWN:
+ case WindowsMessages.RBUTTONDOWN:
+ {
+ bool isLeft = msg == WindowsMessages.LBUTTONDOWN;
+ RawInputModifiers pointerPointModifier = isLeft ? RawInputModifiers.LeftMouseButton : RawInputModifiers.RightMouseButton;
+ PointerPointProperties properties = new(pointerPointModifier, isLeft ? PointerUpdateKind.LeftButtonPressed : PointerUpdateKind.RightButtonPressed);
+
+ var evnt = new PointerPressedEventArgs(
+ this,
+ pointer,
+ VisualRoot,
+ rootVisualPosition,
+ (ulong)Environment.TickCount64,
+ properties,
+ KeyModifiers.None);
+
+ RaiseEvent(evnt);
+
+ break;
+ }
+ case WindowsMessages.LBUTTONUP:
+ case WindowsMessages.RBUTTONUP:
+ {
+ bool isLeft = msg == WindowsMessages.LBUTTONUP;
+ RawInputModifiers pointerPointModifier = isLeft ? RawInputModifiers.LeftMouseButton : RawInputModifiers.RightMouseButton;
+ PointerPointProperties properties = new(pointerPointModifier, isLeft ? PointerUpdateKind.LeftButtonReleased : PointerUpdateKind.RightButtonReleased);
+
+ var evnt = new PointerReleasedEventArgs(
+ this,
+ pointer,
+ VisualRoot,
+ rootVisualPosition,
+ (ulong)Environment.TickCount64,
+ properties,
+ KeyModifiers.None,
+ isLeft ? MouseButton.Left : MouseButton.Right);
+
+ RaiseEvent(evnt);
+
+ break;
+ }
+ case WindowsMessages.MOUSEMOVE:
+ {
+ var evnt = new PointerEventArgs(
+ PointerMovedEvent,
+ this,
+ pointer,
+ VisualRoot,
+ rootVisualPosition,
+ (ulong)Environment.TickCount64,
+ new PointerPointProperties(RawInputModifiers.None, PointerUpdateKind.Other),
+ KeyModifiers.None);
+
+ RaiseEvent(evnt);
+
+ break;
+ }
+ }
}
}
diff --git a/Ryujinx.Ava/UI/ViewModels/TitleUpdateViewModel.cs b/Ryujinx.Ava/UI/ViewModels/TitleUpdateViewModel.cs
index 1bac9424..3d0b20f7 100644
--- a/Ryujinx.Ava/UI/ViewModels/TitleUpdateViewModel.cs
+++ b/Ryujinx.Ava/UI/ViewModels/TitleUpdateViewModel.cs
@@ -21,8 +21,9 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
-using SpanHelpers = LibHac.Common.SpanHelpers;
+using System.Text;
using Path = System.IO.Path;
+using SpanHelpers = LibHac.Common.SpanHelpers;
namespace Ryujinx.Ava.UI.ViewModels;
@@ -90,6 +91,8 @@ public class TitleUpdateViewModel : BaseModel
Selected = "",
Paths = new List<string>()
};
+
+ Save();
}
LoadUpdates();
@@ -102,6 +105,9 @@ public class TitleUpdateViewModel : BaseModel
AddUpdate(path);
}
+ // NOTE: Save the list again to remove leftovers.
+ Save();
+
TitleUpdateModel selected = TitleUpdates.FirstOrDefault(x => x.Path == _titleUpdateWindowData.Selected, null);
SelectedUpdate = selected;
@@ -223,4 +229,22 @@ public class TitleUpdateViewModel : BaseModel
SortUpdates();
}
+
+ public void Save()
+ {
+ _titleUpdateWindowData.Paths.Clear();
+ _titleUpdateWindowData.Selected = "";
+
+ foreach (TitleUpdateModel update in TitleUpdates)
+ {
+ _titleUpdateWindowData.Paths.Add(update.Path);
+
+ if (update == SelectedUpdate)
+ {
+ _titleUpdateWindowData.Selected = update.Path;
+ }
+ }
+
+ File.WriteAllBytes(_titleUpdateJsonPath, Encoding.UTF8.GetBytes(JsonHelper.Serialize(_titleUpdateWindowData, true)));
+ }
} \ No newline at end of file
diff --git a/Ryujinx.Ava/UI/Windows/TitleUpdateWindow.axaml.cs b/Ryujinx.Ava/UI/Windows/TitleUpdateWindow.axaml.cs
index 41370e66..1b50c46f 100644
--- a/Ryujinx.Ava/UI/Windows/TitleUpdateWindow.axaml.cs
+++ b/Ryujinx.Ava/UI/Windows/TitleUpdateWindow.axaml.cs
@@ -60,24 +60,7 @@ namespace Ryujinx.Ava.UI.Windows
public void Save(object sender, RoutedEventArgs e)
{
- ViewModel._titleUpdateWindowData.Paths.Clear();
-
- ViewModel._titleUpdateWindowData.Selected = "";
-
- foreach (TitleUpdateModel update in ViewModel.TitleUpdates)
- {
- ViewModel._titleUpdateWindowData.Paths.Add(update.Path);
-
- if (update == ViewModel.SelectedUpdate)
- {
- ViewModel._titleUpdateWindowData.Selected = update.Path;
- }
- }
-
- using (FileStream titleUpdateJsonStream = File.Create(ViewModel._titleUpdateJsonPath, 4096, FileOptions.WriteThrough))
- {
- titleUpdateJsonStream.Write(Encoding.UTF8.GetBytes(JsonHelper.Serialize(ViewModel._titleUpdateWindowData, true)));
- }
+ ViewModel.Save();
if (VisualRoot is MainWindow window)
{