Compare commits
3 Commits
9b2da5901a
...
Canary-1.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
253cbb2810 | ||
|
|
9c226dcc7a | ||
|
|
30a534edcd |
@@ -1,5 +1,3 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace Ryujinx.Common.Configuration.Hid
|
namespace Ryujinx.Common.Configuration.Hid
|
||||||
{
|
{
|
||||||
public class KeyboardHotkeys
|
public class KeyboardHotkeys
|
||||||
@@ -15,6 +13,5 @@ namespace Ryujinx.Common.Configuration.Hid
|
|||||||
public Key VolumeDown { get; set; }
|
public Key VolumeDown { get; set; }
|
||||||
public Key CustomVSyncIntervalIncrement { get; set; }
|
public Key CustomVSyncIntervalIncrement { get; set; }
|
||||||
public Key CustomVSyncIntervalDecrement { get; set; }
|
public Key CustomVSyncIntervalDecrement { get; set; }
|
||||||
public List<Key> CycleControllers { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ using Ryujinx.HLE;
|
|||||||
using Ryujinx.HLE.FileSystem;
|
using Ryujinx.HLE.FileSystem;
|
||||||
using Ryujinx.HLE.HOS;
|
using Ryujinx.HLE.HOS;
|
||||||
using Ryujinx.HLE.HOS.Services.Account.Acc;
|
using Ryujinx.HLE.HOS.Services.Account.Acc;
|
||||||
using Ryujinx.HLE.HOS.Services.Hid;
|
|
||||||
using Ryujinx.HLE.HOS.SystemState;
|
using Ryujinx.HLE.HOS.SystemState;
|
||||||
using Ryujinx.Input;
|
using Ryujinx.Input;
|
||||||
using Ryujinx.Input.HLE;
|
using Ryujinx.Input.HLE;
|
||||||
@@ -50,7 +49,6 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -1310,18 +1308,6 @@ namespace Ryujinx.Ava
|
|||||||
|
|
||||||
_viewModel.Volume = Device.GetVolume();
|
_viewModel.Volume = Device.GetVolume();
|
||||||
break;
|
break;
|
||||||
case KeyboardHotkeyState.CycleControllersPlayer1:
|
|
||||||
case KeyboardHotkeyState.CycleControllersPlayer2:
|
|
||||||
case KeyboardHotkeyState.CycleControllersPlayer3:
|
|
||||||
case KeyboardHotkeyState.CycleControllersPlayer4:
|
|
||||||
case KeyboardHotkeyState.CycleControllersPlayer5:
|
|
||||||
case KeyboardHotkeyState.CycleControllersPlayer6:
|
|
||||||
case KeyboardHotkeyState.CycleControllersPlayer7:
|
|
||||||
case KeyboardHotkeyState.CycleControllersPlayer8:
|
|
||||||
var player = currentHotkeyState - KeyboardHotkeyState.CycleControllersPlayer1;
|
|
||||||
var ivm = new UI.ViewModels.Input.InputViewModel();
|
|
||||||
Dispatcher.UIThread.Invoke(() => ivm.CyclePlayerDevice(player));
|
|
||||||
break;
|
|
||||||
case KeyboardHotkeyState.None:
|
case KeyboardHotkeyState.None:
|
||||||
(_keyboardInterface as AvaloniaKeyboard).Clear();
|
(_keyboardInterface as AvaloniaKeyboard).Clear();
|
||||||
break;
|
break;
|
||||||
@@ -1404,15 +1390,6 @@ namespace Ryujinx.Ava
|
|||||||
state = KeyboardHotkeyState.CustomVSyncIntervalDecrement;
|
state = KeyboardHotkeyState.CustomVSyncIntervalDecrement;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var cycle in ConfigurationState.Instance.Hid.Hotkeys.Value.CycleControllers?.Select((value, index) => (value, index)) ?? [])
|
|
||||||
{
|
|
||||||
if (_keyboardInterface.IsPressed((Key)cycle.value))
|
|
||||||
{
|
|
||||||
state = KeyboardHotkeyState.CycleControllersPlayer1 + cycle.index;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5672,31 +5672,6 @@
|
|||||||
"zh_TW": "啟用警告日誌"
|
"zh_TW": "啟用警告日誌"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"ID": "SettingsTabHotkeysCycleControllers",
|
|
||||||
"Translations": {
|
|
||||||
"ar_SA": "",
|
|
||||||
"de_DE": "",
|
|
||||||
"el_GR": "",
|
|
||||||
"en_US": "Cycle Controllers",
|
|
||||||
"es_ES": "",
|
|
||||||
"fr_FR": "",
|
|
||||||
"he_IL": "",
|
|
||||||
"it_IT": "",
|
|
||||||
"ja_JP": "",
|
|
||||||
"ko_KR": "",
|
|
||||||
"no_NO": "",
|
|
||||||
"pl_PL": "",
|
|
||||||
"pt_BR": "",
|
|
||||||
"ru_RU": "",
|
|
||||||
"sv_SE": "",
|
|
||||||
"th_TH": "",
|
|
||||||
"tr_TR": "",
|
|
||||||
"uk_UA": "",
|
|
||||||
"zh_CN": "",
|
|
||||||
"zh_TW": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"ID": "SettingsTabLoggingEnableErrorLogs",
|
"ID": "SettingsTabLoggingEnableErrorLogs",
|
||||||
"Translations": {
|
"Translations": {
|
||||||
|
|||||||
@@ -14,13 +14,5 @@ namespace Ryujinx.Ava.Common
|
|||||||
VolumeDown,
|
VolumeDown,
|
||||||
CustomVSyncIntervalIncrement,
|
CustomVSyncIntervalIncrement,
|
||||||
CustomVSyncIntervalDecrement,
|
CustomVSyncIntervalDecrement,
|
||||||
CycleControllersPlayer1,
|
|
||||||
CycleControllersPlayer2,
|
|
||||||
CycleControllersPlayer3,
|
|
||||||
CycleControllersPlayer4,
|
|
||||||
CycleControllersPlayer5,
|
|
||||||
CycleControllersPlayer6,
|
|
||||||
CycleControllersPlayer7,
|
|
||||||
CycleControllersPlayer8
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,6 @@
|
|||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using DynamicData;
|
|
||||||
using Ryujinx.Ava.UI.Helpers;
|
|
||||||
using Ryujinx.Ava.UI.ViewModels;
|
using Ryujinx.Ava.UI.ViewModels;
|
||||||
using Ryujinx.Common.Configuration.Hid;
|
using Ryujinx.Common.Configuration.Hid;
|
||||||
using System.Collections.ObjectModel;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Windows.Input;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.UI.Models.Input
|
namespace Ryujinx.Ava.UI.Models.Input
|
||||||
{
|
{
|
||||||
@@ -33,15 +28,8 @@ namespace Ryujinx.Ava.UI.Models.Input
|
|||||||
|
|
||||||
[ObservableProperty] private Key _customVSyncIntervalDecrement;
|
[ObservableProperty] private Key _customVSyncIntervalDecrement;
|
||||||
|
|
||||||
public ObservableCollection<CycleController> CycleControllers { get; set; } = new ObservableCollection<CycleController>();
|
|
||||||
public ICommand AddCycleController { get; set; }
|
|
||||||
public ICommand RemoveCycleController { get; set; }
|
|
||||||
public bool CanRemoveCycleController => CycleControllers.Count > 0 && CycleControllers.Count < 8;
|
|
||||||
|
|
||||||
public HotkeyConfig(KeyboardHotkeys config)
|
public HotkeyConfig(KeyboardHotkeys config)
|
||||||
{
|
{
|
||||||
AddCycleController = MiniCommand.Create(() => CycleControllers.Add(new CycleController(CycleControllers.Count + 1, Key.Unbound)));
|
|
||||||
RemoveCycleController = MiniCommand.Create(() => CycleControllers.Remove(CycleControllers.Last()));
|
|
||||||
if (config == null)
|
if (config == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -56,7 +44,6 @@ namespace Ryujinx.Ava.UI.Models.Input
|
|||||||
VolumeDown = config.VolumeDown;
|
VolumeDown = config.VolumeDown;
|
||||||
CustomVSyncIntervalIncrement = config.CustomVSyncIntervalIncrement;
|
CustomVSyncIntervalIncrement = config.CustomVSyncIntervalIncrement;
|
||||||
CustomVSyncIntervalDecrement = config.CustomVSyncIntervalDecrement;
|
CustomVSyncIntervalDecrement = config.CustomVSyncIntervalDecrement;
|
||||||
CycleControllers.AddRange((config.CycleControllers ?? []).Select((x, i) => new CycleController(i + 1, x)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public KeyboardHotkeys GetConfig() =>
|
public KeyboardHotkeys GetConfig() =>
|
||||||
@@ -73,7 +60,6 @@ namespace Ryujinx.Ava.UI.Models.Input
|
|||||||
VolumeDown = VolumeDown,
|
VolumeDown = VolumeDown,
|
||||||
CustomVSyncIntervalIncrement = CustomVSyncIntervalIncrement,
|
CustomVSyncIntervalIncrement = CustomVSyncIntervalIncrement,
|
||||||
CustomVSyncIntervalDecrement = CustomVSyncIntervalDecrement,
|
CustomVSyncIntervalDecrement = CustomVSyncIntervalDecrement,
|
||||||
CycleControllers = CycleControllers.Select(x => x.Hotkey).ToList()
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,48 +0,0 @@
|
|||||||
using Ryujinx.Ava.Common.Locale;
|
|
||||||
using Ryujinx.Common.Configuration.Hid;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.UI.ViewModels
|
|
||||||
{
|
|
||||||
public class CycleController : BaseModel
|
|
||||||
{
|
|
||||||
private string _player;
|
|
||||||
private Key _hotkey;
|
|
||||||
|
|
||||||
public string Player
|
|
||||||
{
|
|
||||||
get => _player;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_player = value;
|
|
||||||
OnPropertyChanged(nameof(Player));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Key Hotkey
|
|
||||||
{
|
|
||||||
get => _hotkey;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_hotkey = value;
|
|
||||||
OnPropertyChanged(nameof(Hotkey));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public CycleController(int v, Key x)
|
|
||||||
{
|
|
||||||
Player = v switch
|
|
||||||
{
|
|
||||||
1 => LocaleManager.Instance[LocaleKeys.ControllerSettingsPlayer1],
|
|
||||||
2 => LocaleManager.Instance[LocaleKeys.ControllerSettingsPlayer2],
|
|
||||||
3 => LocaleManager.Instance[LocaleKeys.ControllerSettingsPlayer3],
|
|
||||||
4 => LocaleManager.Instance[LocaleKeys.ControllerSettingsPlayer4],
|
|
||||||
5 => LocaleManager.Instance[LocaleKeys.ControllerSettingsPlayer5],
|
|
||||||
6 => LocaleManager.Instance[LocaleKeys.ControllerSettingsPlayer6],
|
|
||||||
7 => LocaleManager.Instance[LocaleKeys.ControllerSettingsPlayer7],
|
|
||||||
8 => LocaleManager.Instance[LocaleKeys.ControllerSettingsPlayer8],
|
|
||||||
_ => LocaleManager.Instance[LocaleKeys.ControllerSettingsPlayer] + " " + v
|
|
||||||
};
|
|
||||||
Hotkey = x;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -897,13 +897,5 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
|||||||
|
|
||||||
AvaloniaKeyboardDriver.Dispose();
|
AvaloniaKeyboardDriver.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CyclePlayerDevice(int player)
|
|
||||||
{
|
|
||||||
LoadDevices();
|
|
||||||
PlayerId = (PlayerIndex)player;
|
|
||||||
Device = (Device + 1) % Devices.Count;
|
|
||||||
Save();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<UserControl
|
<UserControl
|
||||||
x:Class="Ryujinx.Ava.UI.Views.Settings.SettingsHotkeysView"
|
x:Class="Ryujinx.Ava.UI.Views.Settings.SettingsHotkeysView"
|
||||||
xmlns="https://github.com/avaloniaui"
|
xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
@@ -15,18 +15,17 @@
|
|||||||
<viewModels:SettingsViewModel />
|
<viewModels:SettingsViewModel />
|
||||||
</Design.DataContext>
|
</Design.DataContext>
|
||||||
<UserControl.Styles>
|
<UserControl.Styles>
|
||||||
<Style Selector="StackPanel StackPanel">
|
<Style Selector="StackPanel > StackPanel">
|
||||||
<Setter Property="Margin" Value="10, 0, 0, 0" />
|
<Setter Property="Margin" Value="10, 0, 0, 0" />
|
||||||
<Setter Property="Orientation" Value="Horizontal" />
|
<Setter Property="Orientation" Value="Horizontal" />
|
||||||
</Style>
|
</Style>
|
||||||
<Style Selector="StackPanel StackPanel > TextBlock">
|
<Style Selector="StackPanel > StackPanel > TextBlock">
|
||||||
<Setter Property="VerticalAlignment" Value="Center" />
|
<Setter Property="VerticalAlignment" Value="Center" />
|
||||||
<Setter Property="Width" Value="230" />
|
<Setter Property="Width" Value="230" />
|
||||||
</Style>
|
</Style>
|
||||||
<Style Selector="ToggleButton, Button">
|
<Style Selector="ToggleButton">
|
||||||
<Setter Property="Width" Value="90" />
|
<Setter Property="Width" Value="90" />
|
||||||
<Setter Property="Height" Value="27" />
|
<Setter Property="Height" Value="27" />
|
||||||
<Setter Property="Padding" Value="0,5,0,5" /> <!-- Added vertical padding -->
|
|
||||||
</Style>
|
</Style>
|
||||||
<Style Selector="ToggleButton > TextBlock">
|
<Style Selector="ToggleButton > TextBlock">
|
||||||
<Setter Property="TextAlignment" Value="Center" />
|
<Setter Property="TextAlignment" Value="Center" />
|
||||||
@@ -40,123 +39,79 @@
|
|||||||
VerticalScrollBarVisibility="Auto">
|
VerticalScrollBarVisibility="Auto">
|
||||||
<Border Classes="settings">
|
<Border Classes="settings">
|
||||||
<StackPanel
|
<StackPanel
|
||||||
|
Name="SettingButtons"
|
||||||
Margin="10"
|
Margin="10"
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
Orientation="Vertical"
|
Orientation="Vertical"
|
||||||
Spacing="10"
|
Spacing="10">
|
||||||
Name="SettingButtons">
|
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Classes="h1"
|
Classes="h1"
|
||||||
Text="{ext:Locale SettingsTabHotkeysHotkeys}" />
|
Text="{ext:Locale SettingsTabHotkeysHotkeys}" />
|
||||||
<StackPanel
|
<StackPanel>
|
||||||
Margin="10,0,0,0"
|
<TextBlock Text="{ext:Locale SettingsTabHotkeysToggleVSyncModeHotkey}" />
|
||||||
Spacing="10"
|
<ToggleButton Name="ToggleVSyncMode">
|
||||||
Orientation="Vertical">
|
<TextBlock Text="{Binding KeyboardHotkey.ToggleVSyncMode, Converter={x:Static helpers:KeyValueConverter.Instance}}" />
|
||||||
<StackPanel>
|
</ToggleButton>
|
||||||
<TextBlock Text="{ext:Locale SettingsTabHotkeysToggleVSyncModeHotkey}" />
|
|
||||||
<ToggleButton Name="ToggleVSyncMode">
|
|
||||||
<TextBlock Text="{Binding KeyboardHotkey.ToggleVSyncMode, Converter={x:Static helpers:KeyValueConverter.Instance}}" />
|
|
||||||
</ToggleButton>
|
|
||||||
</StackPanel>
|
|
||||||
<StackPanel>
|
|
||||||
<TextBlock Text="{ext:Locale SettingsTabHotkeysScreenshotHotkey}" />
|
|
||||||
<ToggleButton Name="Screenshot">
|
|
||||||
<TextBlock Text="{Binding KeyboardHotkey.Screenshot, Converter={x:Static helpers:KeyValueConverter.Instance}}" />
|
|
||||||
</ToggleButton>
|
|
||||||
</StackPanel>
|
|
||||||
<StackPanel>
|
|
||||||
<TextBlock Text="{ext:Locale SettingsTabHotkeysShowUiHotkey}" />
|
|
||||||
<ToggleButton Name="ShowUI">
|
|
||||||
<TextBlock Text="{Binding KeyboardHotkey.ShowUI, Converter={x:Static helpers:KeyValueConverter.Instance}}" />
|
|
||||||
</ToggleButton>
|
|
||||||
</StackPanel>
|
|
||||||
<StackPanel>
|
|
||||||
<TextBlock Text="{ext:Locale SettingsTabHotkeysPauseHotkey}" />
|
|
||||||
<ToggleButton Name="Pause">
|
|
||||||
<TextBlock Text="{Binding KeyboardHotkey.Pause, Converter={x:Static helpers:KeyValueConverter.Instance}}" />
|
|
||||||
</ToggleButton>
|
|
||||||
</StackPanel>
|
|
||||||
<StackPanel>
|
|
||||||
<TextBlock Text="{ext:Locale SettingsTabHotkeysToggleMuteHotkey}" />
|
|
||||||
<ToggleButton Name="ToggleMute">
|
|
||||||
<TextBlock Text="{Binding KeyboardHotkey.ToggleMute, Converter={x:Static helpers:KeyValueConverter.Instance}}" />
|
|
||||||
</ToggleButton>
|
|
||||||
</StackPanel>
|
|
||||||
<StackPanel>
|
|
||||||
<TextBlock Text="{ext:Locale SettingsTabHotkeysResScaleUpHotkey}" />
|
|
||||||
<ToggleButton Name="ResScaleUp">
|
|
||||||
<TextBlock Text="{Binding KeyboardHotkey.ResScaleUp, Converter={x:Static helpers:KeyValueConverter.Instance}}" />
|
|
||||||
</ToggleButton>
|
|
||||||
</StackPanel>
|
|
||||||
<StackPanel>
|
|
||||||
<TextBlock Text="{ext:Locale SettingsTabHotkeysResScaleDownHotkey}" />
|
|
||||||
<ToggleButton Name="ResScaleDown">
|
|
||||||
<TextBlock Text="{Binding KeyboardHotkey.ResScaleDown, Converter={x:Static helpers:KeyValueConverter.Instance}}" />
|
|
||||||
</ToggleButton>
|
|
||||||
</StackPanel>
|
|
||||||
<StackPanel>
|
|
||||||
<TextBlock Text="{ext:Locale SettingsTabHotkeysVolumeUpHotkey}" />
|
|
||||||
<ToggleButton Name="VolumeUp">
|
|
||||||
<TextBlock Text="{Binding KeyboardHotkey.VolumeUp, Converter={x:Static helpers:KeyValueConverter.Instance}}" />
|
|
||||||
</ToggleButton>
|
|
||||||
</StackPanel>
|
|
||||||
<StackPanel>
|
|
||||||
<TextBlock Text="{ext:Locale SettingsTabHotkeysVolumeDownHotkey}" />
|
|
||||||
<ToggleButton Name="VolumeDown">
|
|
||||||
<TextBlock Text="{Binding KeyboardHotkey.VolumeDown, Converter={x:Static helpers:KeyValueConverter.Instance}}" />
|
|
||||||
</ToggleButton>
|
|
||||||
</StackPanel>
|
|
||||||
<StackPanel Margin="10,0,0,0" Orientation="Horizontal">
|
|
||||||
<TextBlock Text="{ext:Locale SettingsTabHotkeysIncrementCustomVSyncIntervalHotkey}" />
|
|
||||||
<ToggleButton Name="CustomVSyncIntervalIncrement">
|
|
||||||
<TextBlock Text="{Binding KeyboardHotkey.CustomVSyncIntervalIncrement, Converter={x:Static helpers:KeyValueConverter.Instance}}" />
|
|
||||||
</ToggleButton>
|
|
||||||
</StackPanel>
|
|
||||||
<StackPanel Margin="10,0,0,0" Orientation="Horizontal">
|
|
||||||
<TextBlock Text="{ext:Locale SettingsTabHotkeysDecrementCustomVSyncIntervalHotkey}" />
|
|
||||||
<ToggleButton Name="CustomVSyncIntervalDecrement">
|
|
||||||
<TextBlock Text="{Binding KeyboardHotkey.CustomVSyncIntervalDecrement, Converter={x:Static helpers:KeyValueConverter.Instance}}" />
|
|
||||||
</ToggleButton>
|
|
||||||
</StackPanel>
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<Separator Height="1" />
|
<StackPanel>
|
||||||
<StackPanel Margin="0">
|
<TextBlock Text="{ext:Locale SettingsTabHotkeysScreenshotHotkey}" />
|
||||||
<TextBlock
|
<ToggleButton Name="Screenshot">
|
||||||
Classes="h1"
|
<TextBlock Text="{Binding KeyboardHotkey.Screenshot, Converter={x:Static helpers:KeyValueConverter.Instance}}" />
|
||||||
Text="{ext:Locale SettingsTabHotkeysCycleControllers}" />
|
</ToggleButton>
|
||||||
<StackPanel Orientation="Horizontal" Spacing="10">
|
</StackPanel>
|
||||||
<Button
|
<StackPanel>
|
||||||
Content="{ext:Locale SettingsTabGeneralAdd}"
|
<TextBlock Text="{ext:Locale SettingsTabHotkeysShowUiHotkey}" />
|
||||||
Margin="10,0,0,0"
|
<ToggleButton Name="ShowUI">
|
||||||
Command="{Binding KeyboardHotkey.AddCycleController}" />
|
<TextBlock Text="{Binding KeyboardHotkey.ShowUI, Converter={x:Static helpers:KeyValueConverter.Instance}}" />
|
||||||
<Button
|
</ToggleButton>
|
||||||
Content="{ext:Locale SettingsTabGeneralRemove}"
|
</StackPanel>
|
||||||
IsEnabled="{Binding KeyboardHotkey.CanRemoveCycleController}"
|
<StackPanel>
|
||||||
Command="{Binding KeyboardHotkey.RemoveCycleController}" />
|
<TextBlock Text="{ext:Locale SettingsTabHotkeysPauseHotkey}" />
|
||||||
</StackPanel>
|
<ToggleButton Name="Pause">
|
||||||
|
<TextBlock Text="{Binding KeyboardHotkey.Pause, Converter={x:Static helpers:KeyValueConverter.Instance}}" />
|
||||||
|
</ToggleButton>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel>
|
||||||
|
<TextBlock Text="{ext:Locale SettingsTabHotkeysToggleMuteHotkey}" />
|
||||||
|
<ToggleButton Name="ToggleMute">
|
||||||
|
<TextBlock Text="{Binding KeyboardHotkey.ToggleMute, Converter={x:Static helpers:KeyValueConverter.Instance}}" />
|
||||||
|
</ToggleButton>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel>
|
||||||
|
<TextBlock Text="{ext:Locale SettingsTabHotkeysResScaleUpHotkey}" />
|
||||||
|
<ToggleButton Name="ResScaleUp">
|
||||||
|
<TextBlock Text="{Binding KeyboardHotkey.ResScaleUp, Converter={x:Static helpers:KeyValueConverter.Instance}}" />
|
||||||
|
</ToggleButton>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel>
|
||||||
|
<TextBlock Text="{ext:Locale SettingsTabHotkeysResScaleDownHotkey}" />
|
||||||
|
<ToggleButton Name="ResScaleDown">
|
||||||
|
<TextBlock Text="{Binding KeyboardHotkey.ResScaleDown, Converter={x:Static helpers:KeyValueConverter.Instance}}" />
|
||||||
|
</ToggleButton>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel>
|
||||||
|
<TextBlock Text="{ext:Locale SettingsTabHotkeysVolumeUpHotkey}" />
|
||||||
|
<ToggleButton Name="VolumeUp">
|
||||||
|
<TextBlock Text="{Binding KeyboardHotkey.VolumeUp, Converter={x:Static helpers:KeyValueConverter.Instance}}" />
|
||||||
|
</ToggleButton>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel>
|
||||||
|
<TextBlock Text="{ext:Locale SettingsTabHotkeysVolumeDownHotkey}" />
|
||||||
|
<ToggleButton Name="VolumeDown">
|
||||||
|
<TextBlock Text="{Binding KeyboardHotkey.VolumeDown, Converter={x:Static helpers:KeyValueConverter.Instance}}" />
|
||||||
|
</ToggleButton>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Margin="10,0,0,0" Orientation="Horizontal">
|
||||||
|
<TextBlock Text="{ext:Locale SettingsTabHotkeysIncrementCustomVSyncIntervalHotkey}" />
|
||||||
|
<ToggleButton Name="CustomVSyncIntervalIncrement">
|
||||||
|
<TextBlock Text="{Binding KeyboardHotkey.CustomVSyncIntervalIncrement, Converter={x:Static helpers:KeyValueConverter.Instance}}" />
|
||||||
|
</ToggleButton>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Margin="10,0,0,0" Orientation="Horizontal">
|
||||||
|
<TextBlock Text="{ext:Locale SettingsTabHotkeysDecrementCustomVSyncIntervalHotkey}" />
|
||||||
|
<ToggleButton Name="CustomVSyncIntervalDecrement">
|
||||||
|
<TextBlock Text="{Binding KeyboardHotkey.CustomVSyncIntervalDecrement, Converter={x:Static helpers:KeyValueConverter.Instance}}" />
|
||||||
|
</ToggleButton>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<ItemsControl ItemsSource="{Binding KeyboardHotkey.CycleControllers}"
|
|
||||||
Name="CycleControllers">
|
|
||||||
<ItemsControl.ItemsPanel>
|
|
||||||
<ItemsPanelTemplate>
|
|
||||||
<StackPanel
|
|
||||||
Margin="10,0,0,0"
|
|
||||||
Orientation="Vertical"
|
|
||||||
Spacing="10" />
|
|
||||||
</ItemsPanelTemplate>
|
|
||||||
</ItemsControl.ItemsPanel>
|
|
||||||
<ItemsControl.ItemTemplate>
|
|
||||||
<DataTemplate>
|
|
||||||
<StackPanel>
|
|
||||||
<TextBlock Text="{Binding Player}" />
|
|
||||||
<ToggleButton>
|
|
||||||
<TextBlock
|
|
||||||
Text="{Binding Hotkey, Converter={x:Static helpers:KeyValueConverter.Instance}}" />
|
|
||||||
</ToggleButton>
|
|
||||||
</StackPanel>
|
|
||||||
</DataTemplate>
|
|
||||||
</ItemsControl.ItemTemplate>
|
|
||||||
</ItemsControl>
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Border>
|
</Border>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
|
|||||||
@@ -3,14 +3,11 @@ using Avalonia.Controls.Primitives;
|
|||||||
using Avalonia.Input;
|
using Avalonia.Input;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
using Avalonia.LogicalTree;
|
using Avalonia.LogicalTree;
|
||||||
using Avalonia.VisualTree;
|
|
||||||
using DynamicData;
|
|
||||||
using Ryujinx.Ava.Input;
|
using Ryujinx.Ava.Input;
|
||||||
using Ryujinx.Ava.UI.Helpers;
|
using Ryujinx.Ava.UI.Helpers;
|
||||||
using Ryujinx.Ava.UI.ViewModels;
|
using Ryujinx.Ava.UI.ViewModels;
|
||||||
using Ryujinx.Input;
|
using Ryujinx.Input;
|
||||||
using Ryujinx.Input.Assigner;
|
using Ryujinx.Input.Assigner;
|
||||||
using System.Linq;
|
|
||||||
using Button = Ryujinx.Input.Button;
|
using Button = Ryujinx.Input.Button;
|
||||||
using Key = Ryujinx.Common.Configuration.Hid.Key;
|
using Key = Ryujinx.Common.Configuration.Hid.Key;
|
||||||
|
|
||||||
@@ -24,21 +21,16 @@ namespace Ryujinx.Ava.UI.Views.Settings
|
|||||||
public SettingsHotkeysView()
|
public SettingsHotkeysView()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
RegisterEvents();
|
|
||||||
_avaloniaKeyboardDriver = new AvaloniaKeyboardDriver(this);
|
|
||||||
CycleControllers.LayoutUpdated += (_, _1) => RegisterEvents();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void RegisterEvents()
|
|
||||||
{
|
|
||||||
foreach (ILogical visual in SettingButtons.GetLogicalDescendants())
|
foreach (ILogical visual in SettingButtons.GetLogicalDescendants())
|
||||||
{
|
{
|
||||||
if (visual is ToggleButton button and not CheckBox)
|
if (visual is ToggleButton button and not CheckBox)
|
||||||
{
|
{
|
||||||
button.IsCheckedChanged -= Button_IsCheckedChanged;
|
|
||||||
button.IsCheckedChanged += Button_IsCheckedChanged;
|
button.IsCheckedChanged += Button_IsCheckedChanged;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_avaloniaKeyboardDriver = new AvaloniaKeyboardDriver(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnPointerReleased(PointerReleasedEventArgs e)
|
protected override void OnPointerReleased(PointerReleasedEventArgs e)
|
||||||
@@ -124,13 +116,6 @@ namespace Ryujinx.Ava.UI.Views.Settings
|
|||||||
case "CustomVSyncIntervalDecrement":
|
case "CustomVSyncIntervalDecrement":
|
||||||
viewModel.KeyboardHotkey.CustomVSyncIntervalDecrement = buttonValue.AsHidType<Key>();
|
viewModel.KeyboardHotkey.CustomVSyncIntervalDecrement = buttonValue.AsHidType<Key>();
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
var index = button.FindAncestorOfType<ItemsControl>().GetLogicalDescendants().OfType<ToggleButton>().IndexOf(button);
|
|
||||||
if (index >= 0 && viewModel.KeyboardHotkey.CycleControllers != null)
|
|
||||||
{
|
|
||||||
viewModel.KeyboardHotkey.CycleControllers[index].Hotkey = buttonValue.AsHidType<Key>();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -103,56 +103,12 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
if (!_specs.TryGetFirst(s => runningGameId.EqualsAnyIgnoreCase(s.TitleIds), out GameSpec spec))
|
if (!_specs.TryGetFirst(s => runningGameId.EqualsAnyIgnoreCase(s.TitleIds), out GameSpec spec))
|
||||||
return FormattedValue.Unhandled;
|
return FormattedValue.Unhandled;
|
||||||
|
|
||||||
foreach (FormatterSpec formatSpec in spec.SimpleValueFormatters.OrderBy(x => x.Priority))
|
foreach (FormatterSpecBase formatSpec in spec.ValueFormatters.OrderBy(x => x.Priority))
|
||||||
{
|
{
|
||||||
if (!playReport.ReportData.AsDictionary().TryGetValue(formatSpec.ReportKey, out MessagePackObject valuePackObject))
|
if (!formatSpec.Format(appMeta, playReport, out FormattedValue value))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
return formatSpec.Formatter(new SingleValue(valuePackObject)
|
return value;
|
||||||
{
|
|
||||||
Application = appMeta,
|
|
||||||
PlayReport = playReport
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (MultiFormatterSpec formatSpec in spec.MultiValueFormatters.OrderBy(x => x.Priority))
|
|
||||||
{
|
|
||||||
List<MessagePackObject> packedObjects = [];
|
|
||||||
foreach (var reportKey in formatSpec.ReportKeys)
|
|
||||||
{
|
|
||||||
if (!playReport.ReportData.AsDictionary().TryGetValue(reportKey, out MessagePackObject valuePackObject))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
packedObjects.Add(valuePackObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (packedObjects.Count != formatSpec.ReportKeys.Length)
|
|
||||||
return FormattedValue.Unhandled;
|
|
||||||
|
|
||||||
return formatSpec.Formatter(new MultiValue(packedObjects)
|
|
||||||
{
|
|
||||||
Application = appMeta,
|
|
||||||
PlayReport = playReport
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (SparseMultiFormatterSpec formatSpec in spec.SparseMultiValueFormatters.OrderBy(x => x.Priority))
|
|
||||||
{
|
|
||||||
Dictionary<string, MessagePackObject> packedObjects = [];
|
|
||||||
foreach (var reportKey in formatSpec.ReportKeys)
|
|
||||||
{
|
|
||||||
if (!playReport.ReportData.AsDictionary().TryGetValue(reportKey, out MessagePackObject valuePackObject))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
packedObjects.Add(reportKey, valuePackObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
return formatSpec.Formatter(
|
|
||||||
new SparseMultiValue(packedObjects)
|
|
||||||
{
|
|
||||||
Application = appMeta,
|
|
||||||
PlayReport = playReport
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return FormattedValue.Unhandled;
|
return FormattedValue.Unhandled;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
/// <br/>
|
/// <br/>
|
||||||
/// OR a signal to reset the value that the caller is using the <see cref="Analyzer"/> for.
|
/// OR a signal to reset the value that the caller is using the <see cref="Analyzer"/> for.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public delegate FormattedValue ValueFormatter(SingleValue value);
|
public delegate FormattedValue SingleValueFormatter(SingleValue value);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The delegate type that powers multiple value formatters.<br/>
|
/// The delegate type that powers multiple value formatters.<br/>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
{
|
{
|
||||||
public abstract class MatchedValue<T>
|
public abstract class MatchedValue<T>
|
||||||
{
|
{
|
||||||
public MatchedValue(T matched)
|
protected MatchedValue(T matched)
|
||||||
{
|
{
|
||||||
Matched = matched;
|
Matched = matched;
|
||||||
}
|
}
|
||||||
@@ -29,7 +29,7 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The input data to a <see cref="ValueFormatter"/>,
|
/// The input data to a <see cref="SingleValueFormatter"/>,
|
||||||
/// containing the currently running application's <see cref="ApplicationMetadata"/>,
|
/// containing the currently running application's <see cref="ApplicationMetadata"/>,
|
||||||
/// and the matched <see cref="MessagePackObject"/> from the Play Report.
|
/// and the matched <see cref="MessagePackObject"/> from the Play Report.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -38,8 +38,6 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
public SingleValue(Value matched) : base(matched)
|
public SingleValue(Value matched) : base(matched)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static implicit operator SingleValue(MessagePackObject mpo) => new(mpo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -56,9 +54,6 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
public MultiValue(IEnumerable<MessagePackObject> matched) : base(Value.ConvertPackedObjects(matched))
|
public MultiValue(IEnumerable<MessagePackObject> matched) : base(Value.ConvertPackedObjects(matched))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static implicit operator MultiValue(List<MessagePackObject> matched)
|
|
||||||
=> new(matched.Select(x => new Value(x)).ToArray());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -75,13 +70,5 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
public SparseMultiValue(Dictionary<string, MessagePackObject> matched) : base(Value.ConvertPackedObjectMap(matched))
|
public SparseMultiValue(Dictionary<string, MessagePackObject> matched) : base(Value.ConvertPackedObjectMap(matched))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static implicit operator SparseMultiValue(Dictionary<string, MessagePackObject> matched)
|
|
||||||
=> new(matched
|
|
||||||
.ToDictionary(
|
|
||||||
x => x.Key,
|
|
||||||
x => new Value(x.Value)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
296
src/Ryujinx/Utilities/PlayReport/PlayReports.Formatters.cs
Normal file
296
src/Ryujinx/Utilities/PlayReport/PlayReports.Formatters.cs
Normal file
@@ -0,0 +1,296 @@
|
|||||||
|
using System;
|
||||||
|
using System.Buffers.Binary;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace Ryujinx.Ava.Utilities.PlayReport
|
||||||
|
{
|
||||||
|
public partial class PlayReports
|
||||||
|
{
|
||||||
|
private static FormattedValue BreathOfTheWild_MasterMode(SingleValue value)
|
||||||
|
=> value.Matched.BoxedValue is 1 ? "Playing Master Mode" : FormattedValue.ForceReset;
|
||||||
|
|
||||||
|
private static FormattedValue TearsOfTheKingdom_CurrentField(SingleValue value) =>
|
||||||
|
value.Matched.DoubleValue switch
|
||||||
|
{
|
||||||
|
> 800d => "Exploring the Sky Islands",
|
||||||
|
< -201d => "Exploring the Depths",
|
||||||
|
_ => "Roaming Hyrule"
|
||||||
|
};
|
||||||
|
|
||||||
|
private static FormattedValue SuperMarioOdyssey_AssistMode(SingleValue value)
|
||||||
|
=> value.Matched.BoxedValue is 1 ? "Playing in Assist Mode" : "Playing in Regular Mode";
|
||||||
|
|
||||||
|
private static FormattedValue SuperMarioOdysseyChina_AssistMode(SingleValue value)
|
||||||
|
=> value.Matched.BoxedValue is 1 ? "Playing in 帮助模式" : "Playing in 普通模式";
|
||||||
|
|
||||||
|
private static FormattedValue SuperMario3DWorldOrBowsersFury(SingleValue value)
|
||||||
|
=> value.Matched.BoxedValue is 0 ? "Playing Super Mario 3D World" : "Playing Bowser's Fury";
|
||||||
|
|
||||||
|
private static FormattedValue MarioKart8Deluxe_Mode(SingleValue value)
|
||||||
|
=> value.Matched.StringValue switch
|
||||||
|
{
|
||||||
|
// Single Player
|
||||||
|
"Single" => "Single Player",
|
||||||
|
// Multiplayer
|
||||||
|
"Multi-2players" => "Multiplayer 2 Players",
|
||||||
|
"Multi-3players" => "Multiplayer 3 Players",
|
||||||
|
"Multi-4players" => "Multiplayer 4 Players",
|
||||||
|
// Wireless/LAN Play
|
||||||
|
"Local-Single" => "Wireless/LAN Play",
|
||||||
|
"Local-2players" => "Wireless/LAN Play 2 Players",
|
||||||
|
// CC Classes
|
||||||
|
"50cc" => "50cc",
|
||||||
|
"100cc" => "100cc",
|
||||||
|
"150cc" => "150cc",
|
||||||
|
"Mirror" => "Mirror (150cc)",
|
||||||
|
"200cc" => "200cc",
|
||||||
|
// Modes
|
||||||
|
"GrandPrix" => "Grand Prix",
|
||||||
|
"TimeAttack" => "Time Trials",
|
||||||
|
"VS" => "VS Races",
|
||||||
|
"Battle" => "Battle Mode",
|
||||||
|
"RaceStart" => "Selecting a Course",
|
||||||
|
"Race" => "Racing",
|
||||||
|
_ => FormattedValue.ForceReset
|
||||||
|
};
|
||||||
|
|
||||||
|
private static FormattedValue PokemonSVUnionCircle(SingleValue value)
|
||||||
|
=> value.Matched.BoxedValue is 0 ? "Playing Alone" : "Playing in a group";
|
||||||
|
|
||||||
|
private static FormattedValue PokemonSVArea(SingleValue value)
|
||||||
|
=> value.Matched.StringValue switch
|
||||||
|
{
|
||||||
|
// Base Game Locations
|
||||||
|
"a_w01" => "South Area One",
|
||||||
|
"a_w02" => "Mesagoza",
|
||||||
|
"a_w03" => "The Pokemon League",
|
||||||
|
"a_w04" => "South Area Two",
|
||||||
|
"a_w05" => "South Area Four",
|
||||||
|
"a_w06" => "South Area Six",
|
||||||
|
"a_w07" => "South Area Five",
|
||||||
|
"a_w08" => "South Area Three",
|
||||||
|
"a_w09" => "West Area One",
|
||||||
|
"a_w10" => "Asado Desert",
|
||||||
|
"a_w11" => "West Area Two",
|
||||||
|
"a_w12" => "Medali",
|
||||||
|
"a_w13" => "Tagtree Thicket",
|
||||||
|
"a_w14" => "East Area Three",
|
||||||
|
"a_w15" => "Artazon",
|
||||||
|
"a_w16" => "East Area Two",
|
||||||
|
"a_w18" => "Casseroya Lake",
|
||||||
|
"a_w19" => "Glaseado Mountain",
|
||||||
|
"a_w20" => "North Area Three",
|
||||||
|
"a_w21" => "North Area One",
|
||||||
|
"a_w22" => "North Area Two",
|
||||||
|
"a_w23" => "The Great Crater of Paldea",
|
||||||
|
"a_w24" => "South Paldean Sea",
|
||||||
|
"a_w25" => "West Paldean Sea",
|
||||||
|
"a_w26" => "East Paldean Sea",
|
||||||
|
"a_w27" => "Nouth Paldean Sea",
|
||||||
|
//TODO DLC Locations
|
||||||
|
_ => FormattedValue.ForceReset
|
||||||
|
};
|
||||||
|
|
||||||
|
private static FormattedValue SuperSmashBrosUltimate_Mode(SparseMultiValue values)
|
||||||
|
{
|
||||||
|
// Check if the PlayReport is for a challenger approach or an achievement.
|
||||||
|
if (values.Matched.TryGetValue("fighter", out Value fighter) && values.Matched.ContainsKey("reason"))
|
||||||
|
{
|
||||||
|
return $"Challenger Approaches - {SuperSmashBrosUltimate_Character(fighter)}";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (values.Matched.TryGetValue("fighter", out fighter) && values.Matched.ContainsKey("challenge_count"))
|
||||||
|
{
|
||||||
|
return $"Fighter Unlocked - {SuperSmashBrosUltimate_Character(fighter)}";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (values.Matched.TryGetValue("anniversary", out Value anniversary))
|
||||||
|
{
|
||||||
|
return $"Achievement Unlocked - ID: {anniversary}";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (values.Matched.ContainsKey("adv_slot"))
|
||||||
|
{
|
||||||
|
return "Playing Adventure Mode"; // Doing this as it can be a placeholder until we can grab the character.
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if we have a match_mode at this point, if not, go to default.
|
||||||
|
if (!values.Matched.TryGetValue("match_mode", out Value matchMode))
|
||||||
|
{
|
||||||
|
return "Smashing";
|
||||||
|
}
|
||||||
|
|
||||||
|
return matchMode.BoxedValue switch
|
||||||
|
{
|
||||||
|
0 when values.Matched.TryGetValue("player_1_fighter", out Value player) &&
|
||||||
|
values.Matched.TryGetValue("player_2_fighter", out Value challenger)
|
||||||
|
=> $"Last Smashed: {SuperSmashBrosUltimate_Character(challenger)}'s Fighter Challenge - {SuperSmashBrosUltimate_Character(player)}",
|
||||||
|
1 => $"Last Smashed: Normal Battle - {SuperSmashBrosUltimate_PlayerListing(values)}",
|
||||||
|
2 when values.Matched.TryGetValue("player_1_rank", out Value team)
|
||||||
|
=> team.BoxedValue is 0
|
||||||
|
? "Last Smashed: Squad Strike - Red Team Wins"
|
||||||
|
: "Last Smashed: Squad Strike - Blue Team Wins",
|
||||||
|
3 => $"Last Smashed: Custom Smash - {SuperSmashBrosUltimate_PlayerListing(values)}",
|
||||||
|
4 => $"Last Smashed: Super Sudden Death - {SuperSmashBrosUltimate_PlayerListing(values)}",
|
||||||
|
5 => $"Last Smashed: Smashdown - {SuperSmashBrosUltimate_PlayerListing(values)}",
|
||||||
|
6 => $"Last Smashed: Tourney Battle - {SuperSmashBrosUltimate_PlayerListing(values)}",
|
||||||
|
7 when values.Matched.TryGetValue("player_1_fighter", out Value player)
|
||||||
|
=> $"Last Smashed: Spirit Board Battle as {SuperSmashBrosUltimate_Character(player)}",
|
||||||
|
8 when values.Matched.TryGetValue("player_1_fighter", out Value player)
|
||||||
|
=> $"Playing Adventure Mode as {SuperSmashBrosUltimate_Character(player)}",
|
||||||
|
10 when values.Matched.TryGetValue("match_submode", out Value battle) &&
|
||||||
|
values.Matched.TryGetValue("player_1_fighter", out Value player)
|
||||||
|
=> $"Last Smashed: Classic Mode, Battle {(int)battle.BoxedValue + 1}/8 as {SuperSmashBrosUltimate_Character(player)}",
|
||||||
|
12 => $"Last Smashed: Century Smash - {SuperSmashBrosUltimate_PlayerListing(values)}",
|
||||||
|
13 => $"Last Smashed: All-Star Smash - {SuperSmashBrosUltimate_PlayerListing(values)}",
|
||||||
|
14 => $"Last Smashed: Cruel Smash - {SuperSmashBrosUltimate_PlayerListing(values)}",
|
||||||
|
15 when values.Matched.TryGetValue("player_1_fighter", out Value player)
|
||||||
|
=> $"Last Smashed: Home-Run Contest - {SuperSmashBrosUltimate_Character(player)}",
|
||||||
|
16 when values.Matched.TryGetValue("player_1_fighter", out Value player1) &&
|
||||||
|
values.Matched.TryGetValue("player_2_fighter", out Value player2)
|
||||||
|
=> $"Last Smashed: Home-Run Content (Co-op) - {SuperSmashBrosUltimate_Character(player1)} and {SuperSmashBrosUltimate_Character(player2)}",
|
||||||
|
17 => $"Last Smashed: Home-Run Contest (Versus) - {SuperSmashBrosUltimate_PlayerListing(values)}",
|
||||||
|
18 when values.Matched.TryGetValue("player_1_fighter", out Value player1) &&
|
||||||
|
values.Matched.TryGetValue("player_2_fighter", out Value player2)
|
||||||
|
=> $"Fresh out of Training mode - {SuperSmashBrosUltimate_Character(player1)} with {SuperSmashBrosUltimate_Character(player2)}",
|
||||||
|
58 => $"Last Smashed: LDN Battle - {SuperSmashBrosUltimate_PlayerListing(values)}",
|
||||||
|
63 when values.Matched.TryGetValue("player_1_fighter", out Value player)
|
||||||
|
=> $"Last Smashed: DLC Spirit Board Battle as {SuperSmashBrosUltimate_Character(player)}",
|
||||||
|
_ => "Smashing"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string SuperSmashBrosUltimate_Character(Value value) =>
|
||||||
|
BinaryPrimitives.ReverseEndianness(
|
||||||
|
BitConverter.ToInt64(((MsgPack.MessagePackExtendedTypeObject)value.BoxedValue).GetBody(), 0)) switch
|
||||||
|
{
|
||||||
|
0x0 => "Mario",
|
||||||
|
0x1 => "Donkey Kong",
|
||||||
|
0x2 => "Link",
|
||||||
|
0x3 => "Samus",
|
||||||
|
0x4 => "Dark Samus",
|
||||||
|
0x5 => "Yoshi",
|
||||||
|
0x6 => "Kirby",
|
||||||
|
0x7 => "Fox",
|
||||||
|
0x8 => "Pikachu",
|
||||||
|
0x9 => "Luigi",
|
||||||
|
0xA => "Ness",
|
||||||
|
0xB => "Captain Falcon",
|
||||||
|
0xC => "Jigglypuff",
|
||||||
|
0xD => "Peach",
|
||||||
|
0xE => "Daisy",
|
||||||
|
0xF => "Bowser",
|
||||||
|
0x10 => "Ice Climbers",
|
||||||
|
0x11 => "Sheik",
|
||||||
|
0x12 => "Zelda",
|
||||||
|
0x13 => "Dr. Mario",
|
||||||
|
0x14 => "Pichu",
|
||||||
|
0x15 => "Falco",
|
||||||
|
0x16 => "Marth",
|
||||||
|
0x17 => "Lucina",
|
||||||
|
0x18 => "Young Link",
|
||||||
|
0x19 => "Ganondorf",
|
||||||
|
0x1A => "Mewtwo",
|
||||||
|
0x1B => "Roy",
|
||||||
|
0x1C => "Chrom",
|
||||||
|
0x1D => "Mr Game & Watch",
|
||||||
|
0x1E => "Meta Knight",
|
||||||
|
0x1F => "Pit",
|
||||||
|
0x20 => "Dark Pit",
|
||||||
|
0x21 => "Zero Suit Samus",
|
||||||
|
0x22 => "Wario",
|
||||||
|
0x23 => "Snake",
|
||||||
|
0x24 => "Ike",
|
||||||
|
0x25 => "Pokémon Trainer",
|
||||||
|
0x26 => "Diddy Kong",
|
||||||
|
0x27 => "Lucas",
|
||||||
|
0x28 => "Sonic",
|
||||||
|
0x29 => "King Dedede",
|
||||||
|
0x2A => "Olimar",
|
||||||
|
0x2B => "Lucario",
|
||||||
|
0x2C => "R.O.B.",
|
||||||
|
0x2D => "Toon Link",
|
||||||
|
0x2E => "Wolf",
|
||||||
|
0x2F => "Villager",
|
||||||
|
0x30 => "Mega Man",
|
||||||
|
0x31 => "Wii Fit Trainer",
|
||||||
|
0x32 => "Rosalina & Luma",
|
||||||
|
0x33 => "Little Mac",
|
||||||
|
0x34 => "Greninja",
|
||||||
|
0x35 => "Palutena",
|
||||||
|
0x36 => "Pac-Man",
|
||||||
|
0x37 => "Robin",
|
||||||
|
0x38 => "Shulk",
|
||||||
|
0x39 => "Bowser Jr.",
|
||||||
|
0x3A => "Duck Hunt",
|
||||||
|
0x3B => "Ryu",
|
||||||
|
0x3C => "Ken",
|
||||||
|
0x3D => "Cloud",
|
||||||
|
0x3E => "Corrin",
|
||||||
|
0x3F => "Bayonetta",
|
||||||
|
0x40 => "Richter",
|
||||||
|
0x41 => "Inkling",
|
||||||
|
0x42 => "Ridley",
|
||||||
|
0x43 => "King K. Rool",
|
||||||
|
0x44 => "Simon",
|
||||||
|
0x45 => "Isabelle",
|
||||||
|
0x46 => "Incineroar",
|
||||||
|
0x47 => "Mii Brawler",
|
||||||
|
0x48 => "Mii Swordfighter",
|
||||||
|
0x49 => "Mii Gunner",
|
||||||
|
0x4A => "Piranha Plant",
|
||||||
|
0x4B => "Joker",
|
||||||
|
0x4C => "Hero",
|
||||||
|
0x4D => "Banjo",
|
||||||
|
0x4E => "Terry",
|
||||||
|
0x4F => "Byleth",
|
||||||
|
0x50 => "Min Min",
|
||||||
|
0x51 => "Steve",
|
||||||
|
0x52 => "Sephiroth",
|
||||||
|
0x53 => "Pyra/Mythra",
|
||||||
|
0x54 => "Kazuya",
|
||||||
|
0x55 => "Sora",
|
||||||
|
0xFE => "Random",
|
||||||
|
0xFF => "Scripted Entity",
|
||||||
|
_ => "Unknown"
|
||||||
|
};
|
||||||
|
|
||||||
|
private static string SuperSmashBrosUltimate_PlayerListing(SparseMultiValue values)
|
||||||
|
{
|
||||||
|
List<(string Character, int PlayerNumber, int? Rank)> players = [];
|
||||||
|
|
||||||
|
foreach (KeyValuePair<string, Value> player in values.Matched)
|
||||||
|
{
|
||||||
|
if (player.Key.StartsWith("player_") && player.Key.EndsWith("_fighter") &&
|
||||||
|
player.Value.BoxedValue is not null)
|
||||||
|
{
|
||||||
|
if (!int.TryParse(player.Key.Split('_')[1], out int playerNumber))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
string character = SuperSmashBrosUltimate_Character(player.Value);
|
||||||
|
int? rank = values.Matched.TryGetValue($"player_{playerNumber}_rank", out Value rankValue)
|
||||||
|
? rankValue.IntValue
|
||||||
|
: null;
|
||||||
|
|
||||||
|
players.Add((character, playerNumber, rank));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
players = players.OrderBy(p => p.Rank ?? int.MaxValue).ToList();
|
||||||
|
|
||||||
|
return players.Count > 4
|
||||||
|
? $"{players.Count} Players - " + string.Join(", ",
|
||||||
|
players.Take(3).Select(p => $"{p.Character}({p.PlayerNumber}){RankMedal(p.Rank)}"))
|
||||||
|
: string.Join(", ", players.Select(p => $"{p.Character}({p.PlayerNumber}){RankMedal(p.Rank)}"));
|
||||||
|
|
||||||
|
string RankMedal(int? rank) => rank switch
|
||||||
|
{
|
||||||
|
0 => "🥇",
|
||||||
|
1 => "🥈",
|
||||||
|
2 => "🥉",
|
||||||
|
_ => ""
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,11 @@
|
|||||||
namespace Ryujinx.Ava.Utilities.PlayReport
|
using System;
|
||||||
|
using System.Buffers.Binary;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace Ryujinx.Ava.Utilities.PlayReport
|
||||||
{
|
{
|
||||||
public static class PlayReports
|
public static partial class PlayReports
|
||||||
{
|
{
|
||||||
public static Analyzer Analyzer { get; } = new Analyzer()
|
public static Analyzer Analyzer { get; } = new Analyzer()
|
||||||
.AddSpec(
|
.AddSpec(
|
||||||
@@ -37,91 +42,23 @@
|
|||||||
spec => spec
|
spec => spec
|
||||||
.AddValueFormatter("area_no", PokemonSVArea)
|
.AddValueFormatter("area_no", PokemonSVArea)
|
||||||
.AddValueFormatter("team_circle", PokemonSVUnionCircle)
|
.AddValueFormatter("team_circle", PokemonSVUnionCircle)
|
||||||
|
).AddSpec(
|
||||||
|
"01006a800016e000",
|
||||||
|
spec => spec
|
||||||
|
.AddSparseMultiValueFormatter(
|
||||||
|
[
|
||||||
|
// Metadata to figure out what PlayReport we have.
|
||||||
|
"match_mode", "match_submode", "anniversary", "fighter", "reason", "challenge_count",
|
||||||
|
"adv_slot",
|
||||||
|
// List of Fighters
|
||||||
|
"player_1_fighter", "player_2_fighter", "player_3_fighter", "player_4_fighter",
|
||||||
|
"player_5_fighter", "player_6_fighter", "player_7_fighter", "player_8_fighter",
|
||||||
|
// List of rankings/placements
|
||||||
|
"player_1_rank", "player_2_rank", "player_3_rank", "player_4_rank", "player_5_rank",
|
||||||
|
"player_6_rank", "player_7_rank", "player_8_rank"
|
||||||
|
],
|
||||||
|
SuperSmashBrosUltimate_Mode
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
private static FormattedValue BreathOfTheWild_MasterMode(SingleValue value)
|
|
||||||
=> value.Matched.BoxedValue is 1 ? "Playing Master Mode" : FormattedValue.ForceReset;
|
|
||||||
|
|
||||||
private static FormattedValue TearsOfTheKingdom_CurrentField(SingleValue value) =>
|
|
||||||
value.Matched.DoubleValue switch
|
|
||||||
{
|
|
||||||
> 800d => "Exploring the Sky Islands",
|
|
||||||
< -201d => "Exploring the Depths",
|
|
||||||
_ => "Roaming Hyrule"
|
|
||||||
};
|
|
||||||
|
|
||||||
private static FormattedValue SuperMarioOdyssey_AssistMode(SingleValue value)
|
|
||||||
=> value.Matched.BoxedValue is 1 ? "Playing in Assist Mode" : "Playing in Regular Mode";
|
|
||||||
|
|
||||||
private static FormattedValue SuperMarioOdysseyChina_AssistMode(SingleValue value)
|
|
||||||
=> value.Matched.BoxedValue is 1 ? "Playing in 帮助模式" : "Playing in 普通模式";
|
|
||||||
|
|
||||||
private static FormattedValue SuperMario3DWorldOrBowsersFury(SingleValue value)
|
|
||||||
=> value.Matched.BoxedValue is 0 ? "Playing Super Mario 3D World" : "Playing Bowser's Fury";
|
|
||||||
|
|
||||||
private static FormattedValue MarioKart8Deluxe_Mode(SingleValue value)
|
|
||||||
=> value.Matched.StringValue switch
|
|
||||||
{
|
|
||||||
// Single Player
|
|
||||||
"Single" => "Single Player",
|
|
||||||
// Multiplayer
|
|
||||||
"Multi-2players" => "Multiplayer 2 Players",
|
|
||||||
"Multi-3players" => "Multiplayer 3 Players",
|
|
||||||
"Multi-4players" => "Multiplayer 4 Players",
|
|
||||||
// Wireless/LAN Play
|
|
||||||
"Local-Single" => "Wireless/LAN Play",
|
|
||||||
"Local-2players" => "Wireless/LAN Play 2 Players",
|
|
||||||
// CC Classes
|
|
||||||
"50cc" => "50cc",
|
|
||||||
"100cc" => "100cc",
|
|
||||||
"150cc" => "150cc",
|
|
||||||
"Mirror" => "Mirror (150cc)",
|
|
||||||
"200cc" => "200cc",
|
|
||||||
// Modes
|
|
||||||
"GrandPrix" => "Grand Prix",
|
|
||||||
"TimeAttack" => "Time Trials",
|
|
||||||
"VS" => "VS Races",
|
|
||||||
"Battle" => "Battle Mode",
|
|
||||||
"RaceStart" => "Selecting a Course",
|
|
||||||
"Race" => "Racing",
|
|
||||||
_ => FormattedValue.ForceReset
|
|
||||||
};
|
|
||||||
|
|
||||||
private static FormattedValue PokemonSVUnionCircle(SingleValue value)
|
|
||||||
=> value.Matched.BoxedValue is 0 ? "Playing Alone" : "Playing in a group";
|
|
||||||
|
|
||||||
private static FormattedValue PokemonSVArea(SingleValue value)
|
|
||||||
=> value.Matched.StringValue switch
|
|
||||||
{
|
|
||||||
// Base Game Locations
|
|
||||||
"a_w01" => "South Area One",
|
|
||||||
"a_w02" => "Mesagoza",
|
|
||||||
"a_w03" => "The Pokemon League",
|
|
||||||
"a_w04" => "South Area Two",
|
|
||||||
"a_w05" => "South Area Four",
|
|
||||||
"a_w06" => "South Area Six",
|
|
||||||
"a_w07" => "South Area Five",
|
|
||||||
"a_w08" => "South Area Three",
|
|
||||||
"a_w09" => "West Area One",
|
|
||||||
"a_w10" => "Asado Desert",
|
|
||||||
"a_w11" => "West Area Two",
|
|
||||||
"a_w12" => "Medali",
|
|
||||||
"a_w13" => "Tagtree Thicket",
|
|
||||||
"a_w14" => "East Area Three",
|
|
||||||
"a_w15" => "Artazon",
|
|
||||||
"a_w16" => "East Area Two",
|
|
||||||
"a_w18" => "Casseroya Lake",
|
|
||||||
"a_w19" => "Glaseado Mountain",
|
|
||||||
"a_w20" => "North Area Three",
|
|
||||||
"a_w21" => "North Area One",
|
|
||||||
"a_w22" => "North Area Two",
|
|
||||||
"a_w23" => "The Great Crater of Paldea",
|
|
||||||
"a_w24" => "South Paldean Sea",
|
|
||||||
"a_w25" => "West Paldean Sea",
|
|
||||||
"a_w26" => "East Paldean Sea",
|
|
||||||
"a_w27" => "Nouth Paldean Sea",
|
|
||||||
//TODO DLC Locations
|
|
||||||
_ => FormattedValue.ForceReset
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
using FluentAvalonia.Core;
|
using FluentAvalonia.Core;
|
||||||
|
using MsgPack;
|
||||||
|
using Ryujinx.Ava.Utilities.AppLibrary;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
@@ -11,10 +14,11 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class GameSpec
|
public class GameSpec
|
||||||
{
|
{
|
||||||
|
private int _lastPriority;
|
||||||
|
|
||||||
public required string[] TitleIds { get; init; }
|
public required string[] TitleIds { get; init; }
|
||||||
public List<FormatterSpec> SimpleValueFormatters { get; } = [];
|
|
||||||
public List<MultiFormatterSpec> MultiValueFormatters { get; } = [];
|
public List<FormatterSpecBase> ValueFormatters { get; } = [];
|
||||||
public List<SparseMultiFormatterSpec> SparseMultiValueFormatters { get; } = [];
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -24,8 +28,8 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
/// <param name="reportKey">The key name to match.</param>
|
/// <param name="reportKey">The key name to match.</param>
|
||||||
/// <param name="valueFormatter">The function which can return a potential formatted value.</param>
|
/// <param name="valueFormatter">The function which can return a potential formatted value.</param>
|
||||||
/// <returns>The current <see cref="GameSpec"/>, for chaining convenience.</returns>
|
/// <returns>The current <see cref="GameSpec"/>, for chaining convenience.</returns>
|
||||||
public GameSpec AddValueFormatter(string reportKey, ValueFormatter valueFormatter)
|
public GameSpec AddValueFormatter(string reportKey, SingleValueFormatter valueFormatter)
|
||||||
=> AddValueFormatter(SimpleValueFormatters.Count, reportKey, valueFormatter);
|
=> AddValueFormatter(_lastPriority++, reportKey, valueFormatter);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add a value formatter at a specific priority to the current <see cref="GameSpec"/>
|
/// Add a value formatter at a specific priority to the current <see cref="GameSpec"/>
|
||||||
@@ -36,11 +40,11 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
/// <param name="valueFormatter">The function which can return a potential formatted value.</param>
|
/// <param name="valueFormatter">The function which can return a potential formatted value.</param>
|
||||||
/// <returns>The current <see cref="GameSpec"/>, for chaining convenience.</returns>
|
/// <returns>The current <see cref="GameSpec"/>, for chaining convenience.</returns>
|
||||||
public GameSpec AddValueFormatter(int priority, string reportKey,
|
public GameSpec AddValueFormatter(int priority, string reportKey,
|
||||||
ValueFormatter valueFormatter)
|
SingleValueFormatter valueFormatter)
|
||||||
{
|
{
|
||||||
SimpleValueFormatters.Add(new FormatterSpec
|
ValueFormatters.Add(new FormatterSpec
|
||||||
{
|
{
|
||||||
Priority = priority, ReportKey = reportKey, Formatter = valueFormatter
|
Priority = priority, ReportKeys = [reportKey], Formatter = valueFormatter
|
||||||
});
|
});
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -53,7 +57,7 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
/// <param name="valueFormatter">The function which can format the values.</param>
|
/// <param name="valueFormatter">The function which can format the values.</param>
|
||||||
/// <returns>The current <see cref="GameSpec"/>, for chaining convenience.</returns>
|
/// <returns>The current <see cref="GameSpec"/>, for chaining convenience.</returns>
|
||||||
public GameSpec AddMultiValueFormatter(string[] reportKeys, MultiValueFormatter valueFormatter)
|
public GameSpec AddMultiValueFormatter(string[] reportKeys, MultiValueFormatter valueFormatter)
|
||||||
=> AddMultiValueFormatter(MultiValueFormatters.Count, reportKeys, valueFormatter);
|
=> AddMultiValueFormatter(_lastPriority++, reportKeys, valueFormatter);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add a multi-value formatter at a specific priority to the current <see cref="GameSpec"/>
|
/// Add a multi-value formatter at a specific priority to the current <see cref="GameSpec"/>
|
||||||
@@ -66,7 +70,7 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
public GameSpec AddMultiValueFormatter(int priority, string[] reportKeys,
|
public GameSpec AddMultiValueFormatter(int priority, string[] reportKeys,
|
||||||
MultiValueFormatter valueFormatter)
|
MultiValueFormatter valueFormatter)
|
||||||
{
|
{
|
||||||
MultiValueFormatters.Add(new MultiFormatterSpec
|
ValueFormatters.Add(new MultiFormatterSpec
|
||||||
{
|
{
|
||||||
Priority = priority, ReportKeys = reportKeys, Formatter = valueFormatter
|
Priority = priority, ReportKeys = reportKeys, Formatter = valueFormatter
|
||||||
});
|
});
|
||||||
@@ -84,7 +88,7 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
/// <param name="valueFormatter">The function which can format the values.</param>
|
/// <param name="valueFormatter">The function which can format the values.</param>
|
||||||
/// <returns>The current <see cref="GameSpec"/>, for chaining convenience.</returns>
|
/// <returns>The current <see cref="GameSpec"/>, for chaining convenience.</returns>
|
||||||
public GameSpec AddSparseMultiValueFormatter(string[] reportKeys, SparseMultiValueFormatter valueFormatter)
|
public GameSpec AddSparseMultiValueFormatter(string[] reportKeys, SparseMultiValueFormatter valueFormatter)
|
||||||
=> AddSparseMultiValueFormatter(SparseMultiValueFormatters.Count, reportKeys, valueFormatter);
|
=> AddSparseMultiValueFormatter(_lastPriority++, reportKeys, valueFormatter);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add a multi-value formatter at a specific priority to the current <see cref="GameSpec"/>
|
/// Add a multi-value formatter at a specific priority to the current <see cref="GameSpec"/>
|
||||||
@@ -100,7 +104,7 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
public GameSpec AddSparseMultiValueFormatter(int priority, string[] reportKeys,
|
public GameSpec AddSparseMultiValueFormatter(int priority, string[] reportKeys,
|
||||||
SparseMultiValueFormatter valueFormatter)
|
SparseMultiValueFormatter valueFormatter)
|
||||||
{
|
{
|
||||||
SparseMultiValueFormatters.Add(new SparseMultiFormatterSpec
|
ValueFormatters.Add(new SparseMultiFormatterSpec
|
||||||
{
|
{
|
||||||
Priority = priority, ReportKeys = reportKeys, Formatter = valueFormatter
|
Priority = priority, ReportKeys = reportKeys, Formatter = valueFormatter
|
||||||
});
|
});
|
||||||
@@ -111,30 +115,101 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// A struct containing the data for a mapping of a key in a Play Report to a formatter for its potential value.
|
/// A struct containing the data for a mapping of a key in a Play Report to a formatter for its potential value.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public struct FormatterSpec
|
public class FormatterSpec : FormatterSpecBase
|
||||||
{
|
{
|
||||||
public required int Priority { get; init; }
|
public override bool GetData(Horizon.Prepo.Types.PlayReport playReport, out object result)
|
||||||
public required string ReportKey { get; init; }
|
{
|
||||||
public ValueFormatter Formatter { get; init; }
|
if (!playReport.ReportData.AsDictionary().TryGetValue(ReportKeys[0], out MessagePackObject valuePackObject))
|
||||||
|
{
|
||||||
|
result = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = valuePackObject;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A struct containing the data for a mapping of an arbitrary key set in a Play Report to a formatter for their potential values.
|
/// A struct containing the data for a mapping of an arbitrary key set in a Play Report to a formatter for their potential values.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public struct MultiFormatterSpec
|
public class MultiFormatterSpec : FormatterSpecBase
|
||||||
{
|
{
|
||||||
public required int Priority { get; init; }
|
public override bool GetData(Horizon.Prepo.Types.PlayReport playReport, out object result)
|
||||||
public required string[] ReportKeys { get; init; }
|
{
|
||||||
public MultiValueFormatter Formatter { get; init; }
|
List<MessagePackObject> packedObjects = [];
|
||||||
|
foreach (var reportKey in ReportKeys)
|
||||||
|
{
|
||||||
|
if (!playReport.ReportData.AsDictionary().TryGetValue(reportKey, out MessagePackObject valuePackObject))
|
||||||
|
{
|
||||||
|
result = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
packedObjects.Add(valuePackObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
result = packedObjects;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A struct containing the data for a mapping of an arbitrary key set in a Play Report to a formatter for their sparsely populated potential values.
|
/// A struct containing the data for a mapping of an arbitrary key set in a Play Report to a formatter for their sparsely populated potential values.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public struct SparseMultiFormatterSpec
|
public class SparseMultiFormatterSpec : FormatterSpecBase
|
||||||
{
|
{
|
||||||
public required int Priority { get; init; }
|
public override bool GetData(Horizon.Prepo.Types.PlayReport playReport, out object result)
|
||||||
public required string[] ReportKeys { get; init; }
|
{
|
||||||
public SparseMultiValueFormatter Formatter { get; init; }
|
Dictionary<string, MessagePackObject> packedObjects = [];
|
||||||
|
foreach (var reportKey in ReportKeys)
|
||||||
|
{
|
||||||
|
if (!playReport.ReportData.AsDictionary().TryGetValue(reportKey, out MessagePackObject valuePackObject))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
packedObjects.Add(reportKey, valuePackObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
result = packedObjects;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract class FormatterSpecBase
|
||||||
|
{
|
||||||
|
public abstract bool GetData(Horizon.Prepo.Types.PlayReport playReport, out object data);
|
||||||
|
|
||||||
|
public int Priority { get; init; }
|
||||||
|
public string[] ReportKeys { get; init; }
|
||||||
|
public Delegate Formatter { get; init; }
|
||||||
|
|
||||||
|
public bool Format(ApplicationMetadata appMeta, Horizon.Prepo.Types.PlayReport playReport, out FormattedValue formattedValue)
|
||||||
|
{
|
||||||
|
formattedValue = default;
|
||||||
|
if (!GetData(playReport, out object data))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (data is FormattedValue fv)
|
||||||
|
{
|
||||||
|
formattedValue = fv;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (Formatter)
|
||||||
|
{
|
||||||
|
case SingleValueFormatter svf when data is MessagePackObject mpo:
|
||||||
|
formattedValue = svf(new SingleValue(mpo) { Application = appMeta, PlayReport = playReport });
|
||||||
|
return true;
|
||||||
|
case MultiValueFormatter mvf when data is List<MessagePackObject> messagePackObjects:
|
||||||
|
formattedValue = mvf(new MultiValue(messagePackObjects) { Application = appMeta, PlayReport = playReport });
|
||||||
|
return true;
|
||||||
|
case SparseMultiValueFormatter smvf when
|
||||||
|
data is Dictionary<string, MessagePackObject> sparseMessagePackObjects:
|
||||||
|
formattedValue = smvf(new SparseMultiValue(sparseMessagePackObjects) { Application = appMeta, PlayReport = playReport });
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
throw new InvalidOperationException("Formatter delegate is not of a known type!");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using MsgPack;
|
using MsgPack;
|
||||||
using Ryujinx.Ava.Utilities.AppLibrary;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -7,8 +6,7 @@ using System.Linq;
|
|||||||
namespace Ryujinx.Ava.Utilities.PlayReport
|
namespace Ryujinx.Ava.Utilities.PlayReport
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The input data to a <see cref="ValueFormatter"/>,
|
/// The base input data to a ValueFormatter delegate,
|
||||||
/// containing the currently running application's <see cref="ApplicationMetadata"/>,
|
|
||||||
/// and the matched <see cref="MessagePackObject"/> from the Play Report.
|
/// and the matched <see cref="MessagePackObject"/> from the Play Report.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly struct Value
|
public readonly struct Value
|
||||||
@@ -70,7 +68,7 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A potential formatted value returned by a <see cref="ValueFormatter"/>.
|
/// A potential formatted value returned by a ValueFormatter delegate.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly struct FormattedValue
|
public readonly struct FormattedValue
|
||||||
{
|
{
|
||||||
@@ -116,28 +114,47 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Return this to tell the caller there is no value to return.
|
/// Return this to tell the caller there is no value to return.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static FormattedValue Unhandled => default;
|
public static readonly FormattedValue Unhandled = default;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Return this to suggest the caller reset the value it's using the <see cref="Analyzer"/> for.
|
/// Return this to suggest the caller reset the value it's using the <see cref="Analyzer"/> for.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static FormattedValue ForceReset => new() { Handled = true, Reset = true };
|
public static readonly FormattedValue ForceReset = new() { Handled = true, Reset = true };
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A delegate singleton you can use to always return <see cref="ForceReset"/> in a <see cref="ValueFormatter"/>.
|
/// A delegate singleton you can use to always return <see cref="ForceReset"/> in a <see cref="SingleValueFormatter"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly ValueFormatter SingleAlwaysResets = _ => ForceReset;
|
public static readonly SingleValueFormatter SingleAlwaysResets = _ => ForceReset;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A delegate singleton you can use to always return <see cref="ForceReset"/> in a <see cref="MultiValueFormatter"/>.
|
/// A delegate singleton you can use to always return <see cref="ForceReset"/> in a <see cref="MultiValueFormatter"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly MultiValueFormatter MultiAlwaysResets = _ => ForceReset;
|
public static readonly MultiValueFormatter MultiAlwaysResets = _ => ForceReset;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A delegate singleton you can use to always return <see cref="ForceReset"/> in a <see cref="SparseMultiValueFormatter"/>.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly SparseMultiValueFormatter SparseMultiAlwaysResets = _ => ForceReset;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A delegate factory you can use to always return the specified
|
/// A delegate factory you can use to always return the specified
|
||||||
/// <paramref name="formattedValue"/> in a <see cref="ValueFormatter"/>.
|
/// <paramref name="formattedValue"/> in a <see cref="SingleValueFormatter"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="formattedValue">The string to always return for this delegate instance.</param>
|
/// <param name="formattedValue">The string to always return for this delegate instance.</param>
|
||||||
public static ValueFormatter AlwaysReturns(string formattedValue) => _ => formattedValue;
|
public static SingleValueFormatter SingleAlwaysReturns(string formattedValue) => _ => formattedValue;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A delegate factory you can use to always return the specified
|
||||||
|
/// <paramref name="formattedValue"/> in a <see cref="MultiValueFormatter"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="formattedValue">The string to always return for this delegate instance.</param>
|
||||||
|
public static MultiValueFormatter MultiAlwaysReturns(string formattedValue) => _ => formattedValue;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A delegate factory you can use to always return the specified
|
||||||
|
/// <paramref name="formattedValue"/> in a <see cref="SparseMultiValueFormatter"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="formattedValue">The string to always return for this delegate instance.</param>
|
||||||
|
public static SparseMultiValueFormatter SparseMultiAlwaysReturns(string formattedValue) => _ => formattedValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user