mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-10-01 12:30:00 +02:00
Ava UI: Various Fixes (#4326)
* Ava UI: Various Fixes * use WriteAllBytes
This commit is contained in:
parent
7fea26e97e
commit
c14844d12c
4 changed files with 88 additions and 74 deletions
|
@ -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)
|
if (e.Data.Length > 0 && e.Height > 0 && e.Width > 0)
|
||||||
{
|
{
|
||||||
|
@ -240,7 +240,7 @@ namespace Ryujinx.Ava
|
||||||
lock (_lockObject)
|
lock (_lockObject)
|
||||||
{
|
{
|
||||||
DateTime currentTime = DateTime.Now;
|
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
|
string directory = AppDataManager.Mode switch
|
||||||
{
|
{
|
||||||
|
|
|
@ -140,68 +140,75 @@ namespace Ryujinx.Ava.UI.Renderer
|
||||||
{
|
{
|
||||||
if (VisualRoot != null)
|
if (VisualRoot != null)
|
||||||
{
|
{
|
||||||
Point rootVisualPosition = this.TranslatePoint(new Point((long)lParam & 0xFFFF, (long)lParam >> 16 & 0xFFFF), VisualRoot).Value;
|
if (msg == WindowsMessages.LBUTTONDOWN ||
|
||||||
Pointer pointer = new(0, PointerType.Mouse, true);
|
msg == WindowsMessages.RBUTTONDOWN ||
|
||||||
|
msg == WindowsMessages.LBUTTONUP ||
|
||||||
switch (msg)
|
msg == WindowsMessages.RBUTTONUP ||
|
||||||
|
msg == WindowsMessages.MOUSEMOVE)
|
||||||
{
|
{
|
||||||
case WindowsMessages.LBUTTONDOWN:
|
Point rootVisualPosition = this.TranslatePoint(new Point((long)lParam & 0xFFFF, (long)lParam >> 16 & 0xFFFF), VisualRoot).Value;
|
||||||
case WindowsMessages.RBUTTONDOWN:
|
Pointer pointer = new(0, PointerType.Mouse, true);
|
||||||
{
|
|
||||||
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(
|
switch (msg)
|
||||||
this,
|
{
|
||||||
pointer,
|
case WindowsMessages.LBUTTONDOWN:
|
||||||
VisualRoot,
|
case WindowsMessages.RBUTTONDOWN:
|
||||||
rootVisualPosition,
|
{
|
||||||
(ulong)Environment.TickCount64,
|
bool isLeft = msg == WindowsMessages.LBUTTONDOWN;
|
||||||
properties,
|
RawInputModifiers pointerPointModifier = isLeft ? RawInputModifiers.LeftMouseButton : RawInputModifiers.RightMouseButton;
|
||||||
KeyModifiers.None);
|
PointerPointProperties properties = new(pointerPointModifier, isLeft ? PointerUpdateKind.LeftButtonPressed : PointerUpdateKind.RightButtonPressed);
|
||||||
|
|
||||||
RaiseEvent(evnt);
|
var evnt = new PointerPressedEventArgs(
|
||||||
|
this,
|
||||||
|
pointer,
|
||||||
|
VisualRoot,
|
||||||
|
rootVisualPosition,
|
||||||
|
(ulong)Environment.TickCount64,
|
||||||
|
properties,
|
||||||
|
KeyModifiers.None);
|
||||||
|
|
||||||
break;
|
RaiseEvent(evnt);
|
||||||
}
|
|
||||||
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(
|
break;
|
||||||
this,
|
}
|
||||||
pointer,
|
case WindowsMessages.LBUTTONUP:
|
||||||
VisualRoot,
|
case WindowsMessages.RBUTTONUP:
|
||||||
rootVisualPosition,
|
{
|
||||||
(ulong)Environment.TickCount64,
|
bool isLeft = msg == WindowsMessages.LBUTTONUP;
|
||||||
properties,
|
RawInputModifiers pointerPointModifier = isLeft ? RawInputModifiers.LeftMouseButton : RawInputModifiers.RightMouseButton;
|
||||||
KeyModifiers.None,
|
PointerPointProperties properties = new(pointerPointModifier, isLeft ? PointerUpdateKind.LeftButtonReleased : PointerUpdateKind.RightButtonReleased);
|
||||||
isLeft ? MouseButton.Left : MouseButton.Right);
|
|
||||||
|
|
||||||
RaiseEvent(evnt);
|
var evnt = new PointerReleasedEventArgs(
|
||||||
|
this,
|
||||||
|
pointer,
|
||||||
|
VisualRoot,
|
||||||
|
rootVisualPosition,
|
||||||
|
(ulong)Environment.TickCount64,
|
||||||
|
properties,
|
||||||
|
KeyModifiers.None,
|
||||||
|
isLeft ? MouseButton.Left : MouseButton.Right);
|
||||||
|
|
||||||
break;
|
RaiseEvent(evnt);
|
||||||
}
|
|
||||||
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;
|
||||||
|
}
|
||||||
|
case WindowsMessages.MOUSEMOVE:
|
||||||
|
{
|
||||||
|
var evnt = new PointerEventArgs(
|
||||||
|
PointerMovedEvent,
|
||||||
|
this,
|
||||||
|
pointer,
|
||||||
|
VisualRoot,
|
||||||
|
rootVisualPosition,
|
||||||
|
(ulong)Environment.TickCount64,
|
||||||
|
new PointerPointProperties(RawInputModifiers.None, PointerUpdateKind.Other),
|
||||||
|
KeyModifiers.None);
|
||||||
|
|
||||||
break;
|
RaiseEvent(evnt);
|
||||||
}
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,8 +21,9 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using SpanHelpers = LibHac.Common.SpanHelpers;
|
using System.Text;
|
||||||
using Path = System.IO.Path;
|
using Path = System.IO.Path;
|
||||||
|
using SpanHelpers = LibHac.Common.SpanHelpers;
|
||||||
|
|
||||||
namespace Ryujinx.Ava.UI.ViewModels;
|
namespace Ryujinx.Ava.UI.ViewModels;
|
||||||
|
|
||||||
|
@ -90,6 +91,8 @@ public class TitleUpdateViewModel : BaseModel
|
||||||
Selected = "",
|
Selected = "",
|
||||||
Paths = new List<string>()
|
Paths = new List<string>()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadUpdates();
|
LoadUpdates();
|
||||||
|
@ -102,6 +105,9 @@ public class TitleUpdateViewModel : BaseModel
|
||||||
AddUpdate(path);
|
AddUpdate(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE: Save the list again to remove leftovers.
|
||||||
|
Save();
|
||||||
|
|
||||||
TitleUpdateModel selected = TitleUpdates.FirstOrDefault(x => x.Path == _titleUpdateWindowData.Selected, null);
|
TitleUpdateModel selected = TitleUpdates.FirstOrDefault(x => x.Path == _titleUpdateWindowData.Selected, null);
|
||||||
|
|
||||||
SelectedUpdate = selected;
|
SelectedUpdate = selected;
|
||||||
|
@ -223,4 +229,22 @@ public class TitleUpdateViewModel : BaseModel
|
||||||
|
|
||||||
SortUpdates();
|
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)));
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -60,24 +60,7 @@ namespace Ryujinx.Ava.UI.Windows
|
||||||
|
|
||||||
public void Save(object sender, RoutedEventArgs e)
|
public void Save(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
ViewModel._titleUpdateWindowData.Paths.Clear();
|
ViewModel.Save();
|
||||||
|
|
||||||
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)));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (VisualRoot is MainWindow window)
|
if (VisualRoot is MainWindow window)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue