mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-06-28 04:36:23 +02:00
ControllerOverlay: forgot to remove unused axaml one
This commit is contained in:
parent
069a703f22
commit
525bd1019c
2 changed files with 0 additions and 195 deletions
|
@ -1,46 +0,0 @@
|
||||||
<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"
|
|
||||||
mc:Ignorable="d"
|
|
||||||
d:DesignWidth="400"
|
|
||||||
d:DesignHeight="300"
|
|
||||||
x:Class="Ryujinx.Ava.UI.Controls.ControllerOverlay"
|
|
||||||
Focusable="False"
|
|
||||||
IsVisible="False"
|
|
||||||
Name="ControllerOverlayControl">
|
|
||||||
|
|
||||||
<Border Background="#E0000000"
|
|
||||||
CornerRadius="12"
|
|
||||||
Padding="24"
|
|
||||||
BorderBrush="#40FFFFFF"
|
|
||||||
BorderThickness="1">
|
|
||||||
<StackPanel Spacing="16">
|
|
||||||
<StackPanel Orientation="Horizontal"
|
|
||||||
HorizontalAlignment="Center"
|
|
||||||
Spacing="8">
|
|
||||||
<TextBlock Text="🎮"
|
|
||||||
FontSize="18"
|
|
||||||
VerticalAlignment="Center"/>
|
|
||||||
<TextBlock Text="Controller Bindings"
|
|
||||||
FontSize="18"
|
|
||||||
FontWeight="Bold"
|
|
||||||
Foreground="White"
|
|
||||||
VerticalAlignment="Center"/>
|
|
||||||
</StackPanel>
|
|
||||||
|
|
||||||
<StackPanel Name="PlayerBindings" Spacing="10">
|
|
||||||
<!-- Player bindings will be added programmatically -->
|
|
||||||
</StackPanel>
|
|
||||||
|
|
||||||
<TextBlock Name="DurationText"
|
|
||||||
Text="This overlay will disappear in a few seconds"
|
|
||||||
FontSize="11"
|
|
||||||
Foreground="#AAAAAA"
|
|
||||||
HorizontalAlignment="Center"
|
|
||||||
Margin="0,8,0,0"
|
|
||||||
FontStyle="Italic"/>
|
|
||||||
</StackPanel>
|
|
||||||
</Border>
|
|
||||||
</UserControl>
|
|
|
@ -1,149 +0,0 @@
|
||||||
using Avalonia.Controls;
|
|
||||||
using Avalonia.Media;
|
|
||||||
using Avalonia.Threading;
|
|
||||||
using Ryujinx.Common.Configuration.Hid;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.UI.Controls
|
|
||||||
{
|
|
||||||
public partial class ControllerOverlay : UserControl
|
|
||||||
{
|
|
||||||
|
|
||||||
public ControllerOverlay()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
Background = Brushes.Transparent;
|
|
||||||
HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Right;
|
|
||||||
VerticalAlignment = Avalonia.Layout.VerticalAlignment.Top;
|
|
||||||
Margin = new Avalonia.Thickness(0, 50, 20, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ShowControllerBindings(List<InputConfig> inputConfigs, int durationSeconds = 3)
|
|
||||||
{
|
|
||||||
// Clear existing bindings
|
|
||||||
PlayerBindings.Children.Clear();
|
|
||||||
|
|
||||||
// Group controllers by player index
|
|
||||||
var playerBindings = new Dictionary<PlayerIndex, List<InputConfig>>();
|
|
||||||
|
|
||||||
foreach (var config in inputConfigs.Where(c => c.PlayerIndex <= PlayerIndex.Player4))
|
|
||||||
{
|
|
||||||
if (!playerBindings.ContainsKey(config.PlayerIndex))
|
|
||||||
{
|
|
||||||
playerBindings[config.PlayerIndex] = new List<InputConfig>();
|
|
||||||
}
|
|
||||||
playerBindings[config.PlayerIndex].Add(config);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add player bindings to UI
|
|
||||||
for (int i = 0; i < 4; i++)
|
|
||||||
{
|
|
||||||
var playerIndex = (PlayerIndex)i;
|
|
||||||
var playerPanel = new StackPanel { Orientation = Avalonia.Layout.Orientation.Horizontal, Spacing = 12 };
|
|
||||||
|
|
||||||
// Player number with colored background
|
|
||||||
var playerNumberBorder = new Border
|
|
||||||
{
|
|
||||||
Background = GetPlayerColor(i),
|
|
||||||
CornerRadius = new Avalonia.CornerRadius(12),
|
|
||||||
Padding = new Avalonia.Thickness(8, 4),
|
|
||||||
VerticalAlignment = Avalonia.Layout.VerticalAlignment.Center
|
|
||||||
};
|
|
||||||
|
|
||||||
var playerLabel = new TextBlock
|
|
||||||
{
|
|
||||||
Text = $"P{i + 1}",
|
|
||||||
FontWeight = FontWeight.Bold,
|
|
||||||
Foreground = Brushes.White,
|
|
||||||
FontSize = 12,
|
|
||||||
HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Center
|
|
||||||
};
|
|
||||||
playerNumberBorder.Child = playerLabel;
|
|
||||||
playerPanel.Children.Add(playerNumberBorder);
|
|
||||||
|
|
||||||
if (playerBindings.ContainsKey(playerIndex))
|
|
||||||
{
|
|
||||||
var controllers = playerBindings[playerIndex];
|
|
||||||
var controllerNames = controllers.Select(c => GetControllerDisplayName(c)).ToList();
|
|
||||||
|
|
||||||
var controllerText = new TextBlock
|
|
||||||
{
|
|
||||||
Text = string.Join(", ", controllerNames),
|
|
||||||
Foreground = Brushes.LightGreen,
|
|
||||||
VerticalAlignment = Avalonia.Layout.VerticalAlignment.Center,
|
|
||||||
FontWeight = FontWeight.SemiBold
|
|
||||||
};
|
|
||||||
playerPanel.Children.Add(controllerText);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var noControllerText = new TextBlock
|
|
||||||
{
|
|
||||||
Text = "No controller assigned",
|
|
||||||
Foreground = Brushes.Gray,
|
|
||||||
VerticalAlignment = Avalonia.Layout.VerticalAlignment.Center,
|
|
||||||
FontStyle = FontStyle.Italic
|
|
||||||
};
|
|
||||||
playerPanel.Children.Add(noControllerText);
|
|
||||||
}
|
|
||||||
|
|
||||||
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(durationSeconds * 1000);
|
|
||||||
await Dispatcher.UIThread.InvokeAsync(() =>
|
|
||||||
{
|
|
||||||
IsVisible = false;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private static IBrush GetPlayerColor(int playerIndex)
|
|
||||||
{
|
|
||||||
return playerIndex switch
|
|
||||||
{
|
|
||||||
0 => new SolidColorBrush(Color.FromRgb(255, 92, 92)), // Red for Player 1
|
|
||||||
1 => new SolidColorBrush(Color.FromRgb(54, 162, 235)), // Blue for Player 2
|
|
||||||
2 => new SolidColorBrush(Color.FromRgb(255, 206, 84)), // Yellow for Player 3
|
|
||||||
3 => new SolidColorBrush(Color.FromRgb(75, 192, 192)), // Green for Player 4
|
|
||||||
_ => new SolidColorBrush(Color.FromRgb(128, 128, 128)) // Gray fallback
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private static string GetControllerDisplayName(InputConfig config)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(config.Name))
|
|
||||||
{
|
|
||||||
return config.Backend switch
|
|
||||||
{
|
|
||||||
InputBackendType.WindowKeyboard => "Keyboard",
|
|
||||||
InputBackendType.GamepadSDL2 => "Controller",
|
|
||||||
_ => "Unknown"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Truncate long controller names
|
|
||||||
string name = config.Name;
|
|
||||||
if (name.Length > 25)
|
|
||||||
{
|
|
||||||
name = name.Substring(0, 22) + "...";
|
|
||||||
}
|
|
||||||
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue