Skip to content

Commit

Permalink
Merge pull request #28 from fsegurai/development
Browse files Browse the repository at this point in the history
Fix input configuration error and improved main layout visualization
  • Loading branch information
fsegurai authored Nov 8, 2024
2 parents 3ce233d + 2db74a1 commit 4d5d476
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 11 deletions.
12 changes: 6 additions & 6 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
<PackageVersion Include="Projektanker.Icons.Avalonia.FontAwesome" Version="9.4.0"/>
<PackageVersion Include="Projektanker.Icons.Avalonia.MaterialDesign" Version="9.4.0"/>
<PackageVersion Include="CommandLineParser" Version="2.9.1" />
<PackageVersion Include="Concentus" Version="2.2.0" />
<PackageVersion Include="Concentus" Version="2.2.2" />
<PackageVersion Include="DiscordRichPresence" Version="1.2.1.24" />
<PackageVersion Include="DynamicData" Version="9.0.4" />
<PackageVersion Include="FluentAvaloniaUI" Version="2.0.5" />
<PackageVersion Include="Humanizer" Version="2.14.1" />
<PackageVersion Include="LibHac" Version="0.19.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.9.2" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.11.0" />
<PackageVersion Include="Microsoft.IdentityModel.JsonWebTokens" Version="8.2.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageVersion Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.1" />
<PackageVersion Include="MsgPack.Cli" Version="1.0.1" />
<PackageVersion Include="NetCoreServer" Version="8.0.7" />
Expand All @@ -35,7 +35,7 @@
<PackageVersion Include="OpenTK.Windowing.GraphicsLibraryFramework" Version="4.8.2" />
<PackageVersion Include="Ryujinx.Audio.OpenAL.Dependencies" Version="1.21.0.1" />
<PackageVersion Include="Ryujinx.Graphics.Nvdec.Dependencies" Version="5.0.3-build14" />
<PackageVersion Include="Ryujinx.Graphics.Vulkan.Dependencies.MoltenVK" Version="1.2.0" />
<PackageVersion Include="Ryujinx.Graphics.Vulkan.Dependencies.MoltenVK" Version="1.2.3" />
<PackageVersion Include="Ryujinx.SDL2-CS" Version="2.30.0-build32" />
<PackageVersion Include="Gommon" Version="2.6.5" />
<PackageVersion Include="securifybv.ShellLink" Version="0.1.0" />
Expand All @@ -44,11 +44,11 @@
<PackageVersion Include="Silk.NET.Vulkan" Version="2.21.0" />
<PackageVersion Include="Silk.NET.Vulkan.Extensions.EXT" Version="2.21.0" />
<PackageVersion Include="Silk.NET.Vulkan.Extensions.KHR" Version="2.21.0" />
<PackageVersion Include="SkiaSharp" Version="2.88.7" />
<PackageVersion Include="SkiaSharp" Version="2.88.8" />
<PackageVersion Include="SkiaSharp.NativeAssets.Linux" Version="2.88.7" />
<PackageVersion Include="SPB" Version="0.0.4-build32" />
<PackageVersion Include="System.IO.Hashing" Version="8.0.0" />
<PackageVersion Include="System.Management" Version="8.0.0" />
<PackageVersion Include="UnicornEngine.Unicorn" Version="2.0.2-rc1-fb78016" />
</ItemGroup>
</Project>
</Project>
18 changes: 18 additions & 0 deletions src/Ryujinx/UI/Helpers/ContentDialogHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,24 @@ internal static async Task<UserResult> CreateConfirmationDialog(
cancelButtonText,
(int)Symbol.Help,
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)
=> await CreateConfirmationDialog(
Expand Down
10 changes: 10 additions & 0 deletions src/Ryujinx/UI/ViewModels/Input/InputViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class InputViewModel : BaseModel, IDisposable
private readonly MainWindow _mainWindow;

private PlayerIndex _playerId;
private PlayerIndex _playerIdChoose;
private int _controller;
private string _controllerImage;
private int _device;
Expand Down Expand Up @@ -82,6 +83,12 @@ public object ConfigViewModel
OnPropertyChanged();
}
}

public PlayerIndex PlayerIdChoose
{
get => _playerIdChoose;
set { }
}

public PlayerIndex PlayerId
{
Expand All @@ -90,6 +97,7 @@ public PlayerIndex PlayerId
{
if (IsModified)
{
_playerIdChoose = value;
return;
}

Expand All @@ -100,6 +108,8 @@ public PlayerIndex PlayerId
{
_playerId = PlayerIndex.Player1;
}

_isLoaded = false;

LoadConfiguration();
LoadDevice();
Expand Down
55 changes: 55 additions & 0 deletions src/Ryujinx/UI/Views/Input/ControllerInputView.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.LogicalTree;
using DiscordRPC;
using Ryujinx.Ava.UI.Helpers;
using Ryujinx.Ava.UI.ViewModels.Input;
using Ryujinx.Common.Configuration.Hid.Controller;
using Ryujinx.Common.Logging;
using Ryujinx.Input;
using Ryujinx.Input.Assigner;
using System;
using StickInputId = Ryujinx.Common.Configuration.Hid.Controller.StickInputId;

namespace Ryujinx.Ava.UI.Views.Input
Expand All @@ -27,6 +30,16 @@ public ControllerInputView()
{
button.IsCheckedChanged += Button_IsCheckedChanged;
}

if (visual is CheckBox check)
{
check.IsCheckedChanged += CheckBox_IsCheckedChanged;
}

if (visual is Slider slider)
{
slider.PropertyChanged += Slider_IsCheckedChanged;
}
}
}

Expand All @@ -39,6 +52,48 @@ protected override void OnPointerReleased(PointerReleasedEventArgs e)
_currentAssigner.Cancel();
}
}

private float _changeSlider = -1.0f;

private void Slider_IsCheckedChanged(object? sender, AvaloniaPropertyChangedEventArgs e)

Check warning on line 58 in src/Ryujinx/UI/Views/Input/ControllerInputView.axaml.cs

View workflow job for this annotation

GitHub Actions / Release MacOS universal

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 58 in src/Ryujinx/UI/Views/Input/ControllerInputView.axaml.cs

View workflow job for this annotation

GitHub Actions / Release MacOS universal

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 58 in src/Ryujinx/UI/Views/Input/ControllerInputView.axaml.cs

View workflow job for this annotation

GitHub Actions / Release MacOS universal

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 58 in src/Ryujinx/UI/Views/Input/ControllerInputView.axaml.cs

View workflow job for this annotation

GitHub Actions / Release MacOS universal

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 58 in src/Ryujinx/UI/Views/Input/ControllerInputView.axaml.cs

View workflow job for this annotation

GitHub Actions / Release for linux-x64

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 58 in src/Ryujinx/UI/Views/Input/ControllerInputView.axaml.cs

View workflow job for this annotation

GitHub Actions / Release for linux-arm64

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
{
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;
//Logger.Notice.Print(LogClass.Application, $"IsEnabled: {temp}\" \"{check.Value} {check.IsPointerOver}");
_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)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Ryujinx/UI/Views/Input/InputView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
ToolTip.Tip="{ext:Locale ControllerSettingsLoadProfileToolTip}"
Command="{Binding LoadProfile}">
<ui:SymbolIcon
Symbol="Upload"
Symbol="View"
FontSize="15"
Height="20" />
</Button>
Expand Down
25 changes: 22 additions & 3 deletions src/Ryujinx/UI/Views/Input/InputView.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,24 @@ public void SaveCurrentProfile()

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)
{
_dialogOpen = true;

var result = await ContentDialogHelper.CreateConfirmationDialog(
var result = await ContentDialogHelper.CreateConfirmationDialogExtended(
LocaleManager.Instance[LocaleKeys.DialogControllerSettingsModifiedConfirmMessage],
LocaleManager.Instance[LocaleKeys.DialogControllerSettingsModifiedConfirmSubMessage],
LocaleManager.Instance[LocaleKeys.InputDialogYes],
LocaleManager.Instance[LocaleKeys.InputDialogNo],
LocaleManager.Instance[LocaleKeys.Cancel],
LocaleManager.Instance[LocaleKeys.RyujinxConfirm]);

if (result == UserResult.Yes)
Expand All @@ -42,13 +51,23 @@ private async void PlayerIndexBox_OnSelectionChanged(object sender, SelectionCha
}

_dialogOpen = false;

if (result == UserResult.Cancel)
{
return;
}

ViewModel.IsModified = false;
ViewModel.PlayerId = ViewModel.PlayerIdChoose;

if (e.AddedItems.Count > 0)
{
var player = (PlayerModel)e.AddedItems[0];
ViewModel.PlayerId = player.Id;
ViewModel.IsModified = true;
var player = e.AddedItems[0] as PlayerModel;
if (player != null)
{
ViewModel.PlayerId = player.Id;
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Ryujinx/UI/Views/Main/MainStatusBarView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@
Orientation="Horizontal">
<TextBlock
Name="FirmwareStatus"
Margin="0"
Margin="0,0,5,0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Text="{ext:Locale StatusBarSystemVersion}" />
Expand Down

0 comments on commit 4d5d476

Please sign in to comment.