Merge GreemDev/master

This commit is contained in:
Vudjun 2024-11-10 18:26:16 +00:00
commit f1ca4e98bd
14 changed files with 268 additions and 98 deletions

View File

@ -74,36 +74,36 @@ jobs:
chmod +x ./publish_sdl2_headless/Ryujinx.Headless.SDL2 ./publish_sdl2_headless/Ryujinx.sh chmod +x ./publish_sdl2_headless/Ryujinx.Headless.SDL2 ./publish_sdl2_headless/Ryujinx.sh
if: github.event_name == 'pull_request' && matrix.platform.os == 'ubuntu-latest' if: github.event_name == 'pull_request' && matrix.platform.os == 'ubuntu-latest'
#- name: Build AppImage - name: Build AppImage
# if: github.event_name == 'pull_request' && matrix.platform.os == 'ubuntu-latest' if: github.event_name == 'pull_request' && matrix.platform.os == 'ubuntu-latest'
# run: | run: |
# PLATFORM_NAME="${{ matrix.platform.name }}" PLATFORM_NAME="${{ matrix.platform.name }}"
# sudo apt install -y zsync desktop-file-utils appstream sudo apt install -y zsync desktop-file-utils appstream
# mkdir -p tools mkdir -p tools
# export PATH="$PATH:$(readlink -f tools)" export PATH="$PATH:$(readlink -f tools)"
# # Setup appimagetool # Setup appimagetool
# wget -q -O tools/appimagetool "https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage" wget -q -O tools/appimagetool "https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage"
# chmod +x tools/appimagetool chmod +x tools/appimagetool
# chmod +x distribution/linux/appimage/build-appimage.sh chmod +x distribution/linux/appimage/build-appimage.sh
# Explicitly set $ARCH for appimagetool ($ARCH_NAME is for the file name) # Explicitly set $ARCH for appimagetool ($ARCH_NAME is for the file name)
# if [ "$PLATFORM_NAME" = "linux-x64" ]; then if [ "$PLATFORM_NAME" = "linux-x64" ]; then
# ARCH_NAME=x64 ARCH_NAME=x64
# export ARCH=x86_64 export ARCH=x86_64
# elif [ "$PLATFORM_NAME" = "linux-arm64" ]; then elif [ "$PLATFORM_NAME" = "linux-arm64" ]; then
# ARCH_NAME=arm64 ARCH_NAME=arm64
# export ARCH=aarch64 export ARCH=aarch64
# else else
# echo "Unexpected PLATFORM_NAME "$PLATFORM_NAME"" echo "Unexpected PLATFORM_NAME "$PLATFORM_NAME""
# exit 1 exit 1
# fi fi
# export UFLAG="gh-releases-zsync|${{ github.repository_owner }}|${{ github.event.repository.name }}|latest|*-$ARCH_NAME.AppImage.zsync" export UFLAG="gh-releases-zsync|${{ github.repository_owner }}|${{ github.event.repository.name }}|latest|*-$ARCH_NAME.AppImage.zsync"
# BUILDDIR=publish OUTDIR=publish_appimage distribution/linux/appimage/build-appimage.sh BUILDDIR=publish OUTDIR=publish_appimage distribution/linux/appimage/build-appimage.sh
# shell: bash shell: bash
- name: Upload Ryujinx artifact - name: Upload Ryujinx artifact
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
@ -112,12 +112,12 @@ jobs:
path: publish path: publish
if: github.event_name == 'pull_request' && matrix.platform.os != 'macos-13' if: github.event_name == 'pull_request' && matrix.platform.os != 'macos-13'
#- name: Upload Ryujinx (AppImage) artifact - name: Upload Ryujinx (AppImage) artifact
# uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
# if: github.event_name == 'pull_request' && matrix.platform.os == 'ubuntu-latest' if: github.event_name == 'pull_request' && matrix.platform.os == 'ubuntu-latest'
# with: with:
# name: ryujinx-${{ matrix.configuration }}-${{ env.RYUJINX_BASE_VERSION }}+${{ steps.git_short_hash.outputs.result }}-${{ matrix.platform.zip_os_name }}-AppImage name: ryujinx-${{ matrix.configuration }}-${{ env.RYUJINX_BASE_VERSION }}+${{ steps.git_short_hash.outputs.result }}-${{ matrix.platform.zip_os_name }}-AppImage
# path: publish_appimage path: publish_appimage
- name: Upload Ryujinx.Headless.SDL2 artifact - name: Upload Ryujinx.Headless.SDL2 artifact
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4

View File

@ -101,83 +101,79 @@ jobs:
- name: Publish - name: Publish
run: | run: |
dotnet publish -c Release -r "${{ matrix.platform.name }}" -o ./publish_ava/publish -p:Version="${{ steps.version_info.outputs.build_version }}" -p:SourceRevisionId="${{ steps.version_info.outputs.git_short_hash }}" -p:DebugType=embedded src/Ryujinx --self-contained -p:IncludeNativeLibrariesForSelfExtract=true dotnet publish -c Release -r "${{ matrix.platform.name }}" -o ./publish -p:Version="${{ steps.version_info.outputs.build_version }}" -p:SourceRevisionId="${{ steps.version_info.outputs.git_short_hash }}" -p:DebugType=embedded src/Ryujinx --self-contained -p:IncludeNativeLibrariesForSelfExtract=true
dotnet publish -c Release -r "${{ matrix.platform.name }}" -o ./publish_sdl2_headless/publish -p:Version="${{ steps.version_info.outputs.build_version }}" -p:SourceRevisionId="${{ steps.version_info.outputs.git_short_hash }}" -p:DebugType=embedded src/Ryujinx.Headless.SDL2 --self-contained -p:IncludeNativeLibrariesForSelfExtract=true dotnet publish -c Release -r "${{ matrix.platform.name }}" -o ./publish_sdl2_headless -p:Version="${{ steps.version_info.outputs.build_version }}" -p:SourceRevisionId="${{ steps.version_info.outputs.git_short_hash }}" -p:DebugType=embedded src/Ryujinx.Headless.SDL2 --self-contained -p:IncludeNativeLibrariesForSelfExtract=true
- name: Packing Windows builds - name: Packing Windows builds
if: matrix.platform.os == 'windows-latest' if: matrix.platform.os == 'windows-latest'
run: | run: |
pushd publish_ava pushd publish
rm publish/libarmeilleure-jitsupport.dylib rm libarmeilleure-jitsupport.dylib
7z a ../release_output/ryujinx-${{ steps.version_info.outputs.build_version }}-${{ matrix.platform.zip_os_name }}.zip publish 7z a ../release_output/ryujinx-${{ steps.version_info.outputs.build_version }}-${{ matrix.platform.zip_os_name }}.zip ../publish
popd popd
pushd publish_sdl2_headless pushd publish_sdl2_headless
rm publish/libarmeilleure-jitsupport.dylib rm libarmeilleure-jitsupport.dylib
7z a ../release_output/sdl2-ryujinx-headless-${{ steps.version_info.outputs.build_version }}-${{ matrix.platform.zip_os_name }}.zip publish 7z a ../release_output/sdl2-ryujinx-headless-${{ steps.version_info.outputs.build_version }}-${{ matrix.platform.zip_os_name }}.zip ../publish
popd
shell: bash
- name: Build AppImage (Linux)
if: matrix.platform.os == 'ubuntu-latest'
run: |
BUILD_VERSION="${{ steps.version_info.outputs.build_version }}"
PLATFORM_NAME="${{ matrix.platform.name }}"
sudo apt install -y zsync desktop-file-utils appstream
mkdir -p tools
export PATH="$PATH:$(readlink -f tools)"
# Setup appimagetool
wget -q -O tools/appimagetool "https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage"
chmod +x tools/appimagetool
chmod +x distribution/linux/appimage/build-appimage.sh
# Explicitly set $ARCH for appimagetool ($ARCH_NAME is for the file name)
if [ "$PLATFORM_NAME" = "linux-x64" ]; then
ARCH_NAME=x64
export ARCH=x86_64
elif [ "$PLATFORM_NAME" = "linux-arm64" ]; then
ARCH_NAME=arm64
export ARCH=aarch64
else
echo "Unexpected PLATFORM_NAME "$PLATFORM_NAME""
exit 1
fi
export UFLAG="gh-releases-zsync|${{ github.repository_owner }}|${{ github.event.repository.name }}|latest|*-$ARCH_NAME.AppImage.zsync"
BUILDDIR=publish OUTDIR=publish_appimage distribution/linux/appimage/build-appimage.sh
pushd publish_appimage
mv Ryujinx.AppImage ../release_output/ryujinx-$BUILD_VERSION-$ARCH_NAME.AppImage
mv Ryujinx.AppImage.zsync ../release_output/ryujinx-$BUILD_VERSION-$ARCH_NAME.AppImage.zsync
popd popd
shell: bash shell: bash
- name: Packing Linux builds - name: Packing Linux builds
if: matrix.platform.os == 'ubuntu-latest' if: matrix.platform.os == 'ubuntu-latest'
run: | run: |
pushd publish_ava pushd publish
rm publish/libarmeilleure-jitsupport.dylib chmod +x Ryujinx.sh Ryujinx
chmod +x publish/Ryujinx.sh publish/Ryujinx tar -czvf ../release_output/ryujinx-${{ steps.version_info.outputs.build_version }}-${{ matrix.platform.zip_os_name }}.tar.gz ../publish
tar -czvf ../release_output/ryujinx-${{ steps.version_info.outputs.build_version }}-${{ matrix.platform.zip_os_name }}.tar.gz publish
popd popd
pushd publish_sdl2_headless pushd publish_sdl2_headless
rm publish/libarmeilleure-jitsupport.dylib chmod +x Ryujinx.sh Ryujinx.Headless.SDL2
chmod +x publish/Ryujinx.sh publish/Ryujinx.Headless.SDL2 tar -czvf ../release_output/sdl2-ryujinx-headless-${{ steps.version_info.outputs.build_version }}-${{ matrix.platform.zip_os_name }}.tar.gz ../publish
tar -czvf ../release_output/sdl2-ryujinx-headless-${{ steps.version_info.outputs.build_version }}-${{ matrix.platform.zip_os_name }}.tar.gz publish
popd popd
shell: bash shell: bash
#- name: Build AppImage (Linux)
# if: matrix.platform.os == 'ubuntu-latest'
# run: |
# BUILD_VERSION="${{ steps.version_info.outputs.build_version }}"
# PLATFORM_NAME="${{ matrix.platform.name }}"
# sudo apt install -y zsync desktop-file-utils appstream
# mkdir -p tools
# export PATH="$PATH:$(readlink -f tools)"
# Setup appimagetool
# wget -q -O tools/appimagetool "https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage"
# chmod +x tools/appimagetool
# chmod +x distribution/linux/appimage/build-appimage.sh
# Explicitly set $ARCH for appimagetool ($ARCH_NAME is for the file name)
# if [ "$PLATFORM_NAME" = "linux-x64" ]; then
# ARCH_NAME=x64
# export ARCH=x86_64
# elif [ "$PLATFORM_NAME" = "linux-arm64" ]; then
# ARCH_NAME=arm64
# export ARCH=aarch64
# else
# echo "Unexpected PLATFORM_NAME "$PLATFORM_NAME""
# exit 1
# fi
# export UFLAG="gh-releases-zsync|${{ github.repository_owner }}|${{ github.event.repository.name }}|latest|*-$ARCH_NAME.AppImage.zsync"
# BUILDDIR=publish_ava OUTDIR=publish_ava_appimage distribution/linux/appimage/build-appimage.sh
# Add to release output
# pushd publish_ava_appimage
# mv Ryujinx.AppImage ../release_output/ryujinx-$BUILD_VERSION-$ARCH_NAME.AppImage
# mv Ryujinx.AppImage.zsync ../release_output/ryujinx-$BUILD_VERSION-$ARCH_NAME.AppImage.zsync
# popd
# shell: bash
- name: Pushing new release - name: Pushing new release
uses: ncipollo/release-action@v1 uses: ncipollo/release-action@v1
with: with:
name: ${{ steps.version_info.outputs.build_version }} name: ${{ steps.version_info.outputs.build_version }}
artifacts: "release_output/*.tar.gz,release_output/*.zip" artifacts: "release_output/*.tar.gz,release_output/*.zip/*AppImage*"
#artifacts: "release_output/*.tar.gz,release_output/*.zip/*AppImage*"
tag: ${{ steps.version_info.outputs.build_version }} tag: ${{ steps.version_info.outputs.build_version }}
body: "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ steps.version_info.outputs.prev_build_version }}...${{ steps.version_info.outputs.build_version }}" body: "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ steps.version_info.outputs.prev_build_version }}...${{ steps.version_info.outputs.build_version }}"
omitBodyDuringUpdate: true omitBodyDuringUpdate: true
@ -233,7 +229,7 @@ jobs:
- name: Publish macOS Ryujinx - name: Publish macOS Ryujinx
run: | run: |
./distribution/macos/create_macos_build_ava.sh . publish_tmp_ava publish_ava ./distribution/macos/entitlements.xml "${{ steps.version_info.outputs.build_version }}" "${{ steps.version_info.outputs.git_short_hash }}" Release ./distribution/macos/create_macos_build_ava.sh . publish_tmp_ava publish ./distribution/macos/entitlements.xml "${{ steps.version_info.outputs.build_version }}" "${{ steps.version_info.outputs.git_short_hash }}" Release
- name: Publish macOS Ryujinx.Headless.SDL2 - name: Publish macOS Ryujinx.Headless.SDL2
run: | run: |
@ -243,7 +239,7 @@ jobs:
uses: ncipollo/release-action@v1 uses: ncipollo/release-action@v1
with: with:
name: ${{ steps.version_info.outputs.build_version }} name: ${{ steps.version_info.outputs.build_version }}
artifacts: "publish_ava/*.tar.gz, publish_headless/*.tar.gz" artifacts: "publish/*.tar.gz, publish_headless/*.tar.gz"
tag: ${{ steps.version_info.outputs.build_version }} tag: ${{ steps.version_info.outputs.build_version }}
body: "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ steps.version_info.outputs.prev_build_version }}...${{ steps.version_info.outputs.build_version }}" body: "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ steps.version_info.outputs.prev_build_version }}...${{ steps.version_info.outputs.build_version }}"
omitBodyDuringUpdate: true omitBodyDuringUpdate: true

View File

@ -14,6 +14,15 @@
<img src="https://img.shields.io/github/v/release/GreemDev/Ryujinx" <img src="https://img.shields.io/github/v/release/GreemDev/Ryujinx"
alt="Latest Release"> alt="Latest Release">
</a> </a>
<br>
<a href="https://github.com/GreemDev/Ryujinx/actions/workflows/canary.yml">
<img src="https://github.com/GreemDev/Ryujinx/actions/workflows/canary.yml/badge.svg"
alt="">
</a>
<a href="https://github.com/GreemDev/Ryujinx-Canary/releases/latest">
<img src="https://img.shields.io/github/v/release/GreemDev/Ryujinx-Canary?label=canary"
alt="Latest Canary Release">
</a>
</h1> </h1>
<p align="center"> <p align="center">

View File

@ -1,4 +1,6 @@
using Ryujinx.Common.Logging;
using Ryujinx.HLE.HOS.Applets.Browser; using Ryujinx.HLE.HOS.Applets.Browser;
using Ryujinx.HLE.HOS.Applets.Dummy;
using Ryujinx.HLE.HOS.Applets.Error; using Ryujinx.HLE.HOS.Applets.Error;
using Ryujinx.HLE.HOS.Services.Am.AppletAE; using Ryujinx.HLE.HOS.Services.Am.AppletAE;
using System; using System;
@ -26,9 +28,13 @@ namespace Ryujinx.HLE.HOS.Applets
return new BrowserApplet(system); return new BrowserApplet(system);
case AppletId.LibAppletOff: case AppletId.LibAppletOff:
return new BrowserApplet(system); return new BrowserApplet(system);
case AppletId.MiiEdit:
Logger.Warning?.Print(LogClass.Application, $"Please use the MiiEdit inside File/Open Applet");
return new DummyApplet(system);
} }
throw new NotImplementedException($"{applet} applet is not implemented."); Logger.Warning?.Print(LogClass.Application, $"Applet {applet} not implemented!");
return new DummyApplet(system);
} }
} }
} }

View File

@ -0,0 +1,43 @@
using Ryujinx.Common.Logging;
using Ryujinx.Common.Memory;
using Ryujinx.HLE.HOS.Applets;
using Ryujinx.HLE.HOS.Services.Am.AppletAE;
using System;
using System.IO;
using System.Runtime.InteropServices;
namespace Ryujinx.HLE.HOS.Applets.Dummy
{
internal class DummyApplet : IApplet
{
private readonly Horizon _system;
private AppletSession _normalSession;
public event EventHandler AppletStateChanged;
public DummyApplet(Horizon system)
{
_system = system;
}
public ResultCode Start(AppletSession normalSession, AppletSession interactiveSession)
{
_normalSession = normalSession;
_normalSession.Push(BuildResponse());
AppletStateChanged?.Invoke(this, null);
_system.ReturnFocus();
return ResultCode.Success;
}
private static T ReadStruct<T>(byte[] data) where T : struct
{
return MemoryMarshal.Read<T>(data.AsSpan());
}
private static byte[] BuildResponse()
{
using MemoryStream stream = MemoryStreamManager.Shared.GetStream();
using BinaryWriter writer = new(stream);
writer.Write((ulong)ResultCode.Success);
return stream.ToArray();
}
public ResultCode GetResult()
{
return ResultCode.Success;
}
}
}

View File

@ -8,6 +8,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp.NfpManager
public uint FileVersion { get; set; } public uint FileVersion { get; set; }
public byte[] TagUuid { get; set; } public byte[] TagUuid { get; set; }
public string AmiiboId { get; set; } public string AmiiboId { get; set; }
public string NickName { get; set; }
public DateTime FirstWriteDate { get; set; } public DateTime FirstWriteDate { get; set; }
public DateTime LastWriteDate { get; set; } public DateTime LastWriteDate { get; set; }
public ushort WriteCounter { get; set; } public ushort WriteCounter { get; set; }

View File

@ -64,16 +64,17 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
}; };
} }
public static RegisterInfo GetRegisterInfo(ITickSource tickSource, string amiiboId, string nickname) public static RegisterInfo GetRegisterInfo(ITickSource tickSource, string amiiboId, string userName)
{ {
VirtualAmiiboFile amiiboFile = LoadAmiiboFile(amiiboId); VirtualAmiiboFile amiiboFile = LoadAmiiboFile(amiiboId);
string nickname = amiiboFile.NickName ?? "Ryujinx";
UtilityImpl utilityImpl = new(tickSource); UtilityImpl utilityImpl = new(tickSource);
CharInfo charInfo = new(); CharInfo charInfo = new();
charInfo.SetFromStoreData(StoreData.BuildDefault(utilityImpl, 0)); charInfo.SetFromStoreData(StoreData.BuildDefault(utilityImpl, 0));
charInfo.Nickname = Nickname.FromString(nickname); // This is the player's name
charInfo.Nickname = Nickname.FromString(userName);
RegisterInfo registerInfo = new() RegisterInfo registerInfo = new()
{ {
@ -85,7 +86,9 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
Reserved1 = new Array64<byte>(), Reserved1 = new Array64<byte>(),
Reserved2 = new Array58<byte>(), Reserved2 = new Array58<byte>(),
}; };
"Ryujinx"u8.CopyTo(registerInfo.Nickname.AsSpan()); // This is the amiibo's name
byte[] nicknameBytes = System.Text.Encoding.UTF8.GetBytes(nickname);
nicknameBytes.CopyTo(registerInfo.Nickname.AsSpan());
return registerInfo; return registerInfo;
} }

View File

@ -413,6 +413,7 @@
"AvatarSetBackgroundColor": "Set Background Color", "AvatarSetBackgroundColor": "Set Background Color",
"AvatarClose": "Close", "AvatarClose": "Close",
"ControllerSettingsLoadProfileToolTip": "Load Profile", "ControllerSettingsLoadProfileToolTip": "Load Profile",
"ControllerSettingsViewProfileToolTip": "View Profile",
"ControllerSettingsAddProfileToolTip": "Add Profile", "ControllerSettingsAddProfileToolTip": "Add Profile",
"ControllerSettingsRemoveProfileToolTip": "Remove Profile", "ControllerSettingsRemoveProfileToolTip": "Remove Profile",
"ControllerSettingsSaveProfileToolTip": "Save Profile", "ControllerSettingsSaveProfileToolTip": "Save Profile",

View File

@ -30,6 +30,7 @@ namespace Ryujinx.Ava
{ {
internal partial class Program internal partial class Program
{ {
//
public static double WindowScaleFactor { get; set; } public static double WindowScaleFactor { get; set; }
public static double DesktopScaleFactor { get; set; } = 1.0; public static double DesktopScaleFactor { get; set; } = 1.0;
public static string Version { get; private set; } public static string Version { get; private set; }

View File

@ -226,6 +226,24 @@ namespace Ryujinx.Ava.UI.Helpers
(int)Symbol.Help, (int)Symbol.Help,
primaryButtonResult); primaryButtonResult);
internal static async Task<UserResult> CreateConfirmationDialogExtended(
string primaryText,
string secondaryText,
string acceptButtonText,
string noacceptButtonText,
string cancelButtonText,
string title,
UserResult primaryButtonResult = UserResult.Yes)
=> await ShowTextDialog(
string.IsNullOrWhiteSpace(title) ? LocaleManager.Instance[LocaleKeys.DialogConfirmationTitle] : title,
primaryText,
secondaryText,
acceptButtonText,
noacceptButtonText,
cancelButtonText,
(int)Symbol.Help,
primaryButtonResult);
internal static async Task<UserResult> CreateLocalizedConfirmationDialog(string primaryText, string secondaryText) internal static async Task<UserResult> CreateLocalizedConfirmationDialog(string primaryText, string secondaryText)
=> await CreateConfirmationDialog( => await CreateConfirmationDialog(
primaryText, primaryText,

View File

@ -44,6 +44,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
private readonly MainWindow _mainWindow; private readonly MainWindow _mainWindow;
private PlayerIndex _playerId; private PlayerIndex _playerId;
private PlayerIndex _playerIdChoose;
private int _controller; private int _controller;
private string _controllerImage; private string _controllerImage;
private int _device; private int _device;
@ -83,6 +84,12 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
} }
} }
public PlayerIndex PlayerIdChoose
{
get => _playerIdChoose;
set { }
}
public PlayerIndex PlayerId public PlayerIndex PlayerId
{ {
get => _playerId; get => _playerId;
@ -90,6 +97,8 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
{ {
if (IsModified) if (IsModified)
{ {
_playerIdChoose = value;
return; return;
} }
@ -99,7 +108,9 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
if (!Enum.IsDefined(typeof(PlayerIndex), _playerId)) if (!Enum.IsDefined(typeof(PlayerIndex), _playerId))
{ {
_playerId = PlayerIndex.Player1; _playerId = PlayerIndex.Player1;
} }
_isLoaded = false;
LoadConfiguration(); LoadConfiguration();
LoadDevice(); LoadDevice();

View File

@ -4,11 +4,14 @@ using Avalonia.Controls.Primitives;
using Avalonia.Input; using Avalonia.Input;
using Avalonia.Interactivity; using Avalonia.Interactivity;
using Avalonia.LogicalTree; using Avalonia.LogicalTree;
using DiscordRPC;
using Ryujinx.Ava.UI.Helpers; using Ryujinx.Ava.UI.Helpers;
using Ryujinx.Ava.UI.ViewModels.Input; using Ryujinx.Ava.UI.ViewModels.Input;
using Ryujinx.Common.Configuration.Hid.Controller; using Ryujinx.Common.Configuration.Hid.Controller;
using Ryujinx.Common.Logging;
using Ryujinx.Input; using Ryujinx.Input;
using Ryujinx.Input.Assigner; using Ryujinx.Input.Assigner;
using System;
using StickInputId = Ryujinx.Common.Configuration.Hid.Controller.StickInputId; using StickInputId = Ryujinx.Common.Configuration.Hid.Controller.StickInputId;
namespace Ryujinx.Ava.UI.Views.Input namespace Ryujinx.Ava.UI.Views.Input
@ -27,6 +30,16 @@ namespace Ryujinx.Ava.UI.Views.Input
{ {
button.IsCheckedChanged += Button_IsCheckedChanged; button.IsCheckedChanged += Button_IsCheckedChanged;
} }
if (visual is CheckBox check)
{
check.IsCheckedChanged += CheckBox_IsCheckedChanged;
}
if (visual is Slider slider)
{
slider.PropertyChanged += Slider_IsCheckedChanged;
}
} }
} }
@ -40,6 +53,48 @@ namespace Ryujinx.Ava.UI.Views.Input
} }
} }
private float _changeSlider = -1.0f;
private void Slider_IsCheckedChanged(object sender, AvaloniaPropertyChangedEventArgs e)
{
if (sender is Slider check)
{
if ((bool)check.IsPointerOver && _changeSlider == -1.0f)
{
_changeSlider = (float)check.Value;
}
else if (!(bool)check.IsPointerOver)
{
_changeSlider = -1.0f;
}
if (_changeSlider != -1.0f && _changeSlider != (float)check.Value)
{
var viewModel = (DataContext as ControllerInputViewModel);
viewModel.ParentModel.IsModified = true;
_changeSlider = (float)check.Value;
}
}
}
private void CheckBox_IsCheckedChanged(object sender, RoutedEventArgs e)
{
if (sender is CheckBox check)
{
if ((bool)check.IsPointerOver)
{
var viewModel = (DataContext as ControllerInputViewModel);
viewModel.ParentModel.IsModified = true;
_currentAssigner?.Cancel();
_currentAssigner = null;
}
}
}
private void Button_IsCheckedChanged(object sender, RoutedEventArgs e) private void Button_IsCheckedChanged(object sender, RoutedEventArgs e)
{ {
if (sender is ToggleButton button ) if (sender is ToggleButton button )

View File

@ -108,7 +108,7 @@
ToolTip.Tip="{ext:Locale ControllerSettingsLoadProfileToolTip}" ToolTip.Tip="{ext:Locale ControllerSettingsLoadProfileToolTip}"
Command="{Binding LoadProfile}"> Command="{Binding LoadProfile}">
<ui:SymbolIcon <ui:SymbolIcon
Symbol="Upload" Symbol="View"
FontSize="15" FontSize="15"
Height="20" /> Height="20" />
</Button> </Button>

View File

@ -25,17 +25,27 @@ namespace Ryujinx.Ava.UI.Views.Input
private async void PlayerIndexBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) private async void PlayerIndexBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{ {
if (PlayerIndexBox != null)
{
if (PlayerIndexBox.SelectedIndex != (int)ViewModel.PlayerId)
{
PlayerIndexBox.SelectedIndex = (int)ViewModel.PlayerId;
}
}
if (ViewModel.IsModified && !_dialogOpen) if (ViewModel.IsModified && !_dialogOpen)
{ {
_dialogOpen = true; _dialogOpen = true;
var result = await ContentDialogHelper.CreateConfirmationDialog( var result = await ContentDialogHelper.CreateConfirmationDialogExtended(
LocaleManager.Instance[LocaleKeys.DialogControllerSettingsModifiedConfirmMessage], LocaleManager.Instance[LocaleKeys.DialogControllerSettingsModifiedConfirmMessage],
LocaleManager.Instance[LocaleKeys.DialogControllerSettingsModifiedConfirmSubMessage], LocaleManager.Instance[LocaleKeys.DialogControllerSettingsModifiedConfirmSubMessage],
LocaleManager.Instance[LocaleKeys.InputDialogYes], LocaleManager.Instance[LocaleKeys.InputDialogYes],
LocaleManager.Instance[LocaleKeys.InputDialogNo], LocaleManager.Instance[LocaleKeys.InputDialogNo],
LocaleManager.Instance[LocaleKeys.Cancel],
LocaleManager.Instance[LocaleKeys.RyujinxConfirm]); LocaleManager.Instance[LocaleKeys.RyujinxConfirm]);
if (result == UserResult.Yes) if (result == UserResult.Yes)
{ {
ViewModel.Save(); ViewModel.Save();
@ -43,16 +53,32 @@ namespace Ryujinx.Ava.UI.Views.Input
_dialogOpen = false; _dialogOpen = false;
if (result == UserResult.Cancel)
{
return;
}
ViewModel.IsModified = false; ViewModel.IsModified = false;
if (result != UserResult.Cancel)
{
ViewModel.PlayerId = ViewModel.PlayerIdChoose;
}
if (result == UserResult.Cancel)
{
if (e.AddedItems.Count > 0) if (e.AddedItems.Count > 0)
{ {
ViewModel.IsModified = true;
var player = (PlayerModel)e.AddedItems[0]; var player = (PlayerModel)e.AddedItems[0];
ViewModel.PlayerId = player.Id; ViewModel.PlayerId = player.Id;
} }
} }
} }
}
public void Dispose() public void Dispose()
{ {
ViewModel.Dispose(); ViewModel.Dispose();