mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-06-27 22:06:24 +02:00
Controller overlay changed from Window to UserControl
This commit is contained in:
parent
1e86aa9764
commit
d7929a7f0e
5 changed files with 45 additions and 58 deletions
|
@ -1484,9 +1484,12 @@ namespace Ryujinx.Ava.Systems
|
|||
{
|
||||
try
|
||||
{
|
||||
var overlayWindow = new UI.Windows.ControllerOverlayWindow(_topLevel as Avalonia.Controls.Window);
|
||||
overlayWindow.ShowControllerBindings(inputConfigs);
|
||||
overlayWindow.Show();
|
||||
// Access the overlay through the MainWindow via the ViewModel
|
||||
if (_viewModel?.Window?.ControllerOverlay != null)
|
||||
{
|
||||
int duration = ConfigurationState.Instance.ControllerOverlayInputCycleDuration.Value;
|
||||
_viewModel.Window.ControllerOverlay.ShowControllerBindings(inputConfigs, duration);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
@ -1,20 +1,15 @@
|
|||
<window:StyleableAppWindow
|
||||
<UserControl
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:window="clr-namespace:Ryujinx.Ava.UI.Windows"
|
||||
mc:Ignorable="d"
|
||||
d:DesignWidth="400"
|
||||
d:DesignHeight="300"
|
||||
x:Class="Ryujinx.Ava.UI.Windows.ControllerOverlayWindow"
|
||||
Title="Controller Overlay"
|
||||
x:Class="Ryujinx.Ava.UI.Controls.ControllerOverlay"
|
||||
Focusable="False"
|
||||
Topmost="True"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
Width="400"
|
||||
Height="250"
|
||||
SizeToContent="Height">
|
||||
IsVisible="False"
|
||||
Name="ControllerOverlayControl">
|
||||
|
||||
<Border Background="#E0000000"
|
||||
CornerRadius="12"
|
||||
|
@ -39,7 +34,8 @@
|
|||
<!-- Player bindings will be added programmatically -->
|
||||
</StackPanel>
|
||||
|
||||
<TextBlock Text="This overlay will disappear in a few seconds"
|
||||
<TextBlock Name="DurationText"
|
||||
Text="This overlay will disappear in a few seconds"
|
||||
FontSize="11"
|
||||
Foreground="#AAAAAA"
|
||||
HorizontalAlignment="Center"
|
||||
|
@ -47,4 +43,4 @@
|
|||
FontStyle="Italic"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</window:StyleableAppWindow>
|
||||
</UserControl>
|
|
@ -7,46 +7,21 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Ryujinx.Ava.UI.Windows
|
||||
namespace Ryujinx.Ava.UI.Controls
|
||||
{
|
||||
public partial class ControllerOverlayWindow : StyleableWindow
|
||||
public partial class ControllerOverlay : UserControl
|
||||
{
|
||||
private const int AutoHideDelayMs = 4000; // 4 seconds
|
||||
|
||||
public ControllerOverlayWindow()
|
||||
public ControllerOverlay()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
TransparencyLevelHint = [WindowTransparencyLevel.Transparent];
|
||||
SystemDecorations = SystemDecorations.None;
|
||||
ExtendClientAreaTitleBarHeightHint = 0;
|
||||
Background = Brushes.Transparent;
|
||||
CanResize = false;
|
||||
ShowInTaskbar = false;
|
||||
HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Right;
|
||||
VerticalAlignment = Avalonia.Layout.VerticalAlignment.Top;
|
||||
Margin = new Avalonia.Thickness(0, 50, 20, 0);
|
||||
}
|
||||
|
||||
public ControllerOverlayWindow(Window owner) : this()
|
||||
{
|
||||
if (owner != null)
|
||||
{
|
||||
// Position the overlay in the top-right corner of the owner window
|
||||
WindowStartupLocation = WindowStartupLocation.Manual;
|
||||
|
||||
// Set position after the window is loaded
|
||||
Loaded += (s, e) =>
|
||||
{
|
||||
if (owner.WindowState != WindowState.Minimized)
|
||||
{
|
||||
Position = new Avalonia.PixelPoint(
|
||||
(int)(owner.Position.X + owner.Width - Width - 20),
|
||||
(int)(owner.Position.Y + 50)
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowControllerBindings(List<InputConfig> inputConfigs)
|
||||
public void ShowControllerBindings(List<InputConfig> inputConfigs, int durationSeconds = 3)
|
||||
{
|
||||
// Clear existing bindings
|
||||
PlayerBindings.Children.Clear();
|
||||
|
@ -118,13 +93,21 @@ namespace Ryujinx.Ava.UI.Windows
|
|||
PlayerBindings.Children.Add(playerPanel);
|
||||
}
|
||||
|
||||
// Update duration text
|
||||
DurationText.Text = durationSeconds == 1
|
||||
? "This overlay will disappear in 1 second"
|
||||
: $"This overlay will disappear in {durationSeconds} seconds";
|
||||
|
||||
// Show the overlay
|
||||
IsVisible = true;
|
||||
|
||||
// Auto-hide after delay
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
await Task.Delay(AutoHideDelayMs);
|
||||
await Task.Delay(durationSeconds * 1000);
|
||||
await Dispatcher.UIThread.InvokeAsync(() =>
|
||||
{
|
||||
Close();
|
||||
IsVisible = false;
|
||||
});
|
||||
});
|
||||
}
|
|
@ -1710,9 +1710,8 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
// Only show overlay if there are actual controller configurations for players 1-4
|
||||
if (inputConfigs?.Any(c => c.PlayerIndex <= PlayerIndex.Player4) == true)
|
||||
{
|
||||
var overlay = new Windows.ControllerOverlayWindow(Window);
|
||||
overlay.ShowControllerBindings(inputConfigs);
|
||||
overlay.Show();
|
||||
int duration = ConfigurationState.Instance.ControllerOverlayGameStartDuration.Value;
|
||||
Window.ControllerOverlay.ShowControllerBindings(inputConfigs, duration);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
xmlns:controls="clr-namespace:Ryujinx.Ava.UI.Controls"
|
||||
xmlns:main="clr-namespace:Ryujinx.Ava.UI.Views.Main"
|
||||
xmlns:viewsMisc="clr-namespace:Ryujinx.Ava.UI.Views.Misc"
|
||||
xmlns:overlayControls="clr-namespace:Ryujinx.Ava.UI.Controls"
|
||||
Cursor="{Binding Cursor}"
|
||||
Title="{Binding Title}"
|
||||
WindowState="{Binding WindowState}"
|
||||
|
@ -178,5 +179,10 @@
|
|||
Name="StatusBarView"
|
||||
Grid.Row="2" />
|
||||
</Grid>
|
||||
|
||||
<!-- Controller Overlay -->
|
||||
<overlayControls:ControllerOverlay
|
||||
Name="ControllerOverlay"
|
||||
ZIndex="2000" />
|
||||
</Grid>
|
||||
</window:StyleableAppWindow>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue