mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-06-28 06:46:24 +02:00
Compare commits
No commits in common. "154f0564224d8ad87596c40ab5da6f514bb21b99" and "d6232008d5439dc2983a8a4a398d136e8a835198" have entirely different histories.
154f056422
...
d6232008d5
2 changed files with 9 additions and 44 deletions
|
@ -213,7 +213,7 @@ namespace Ryujinx.Graphics.Gpu
|
||||||
texture.SynchronizeMemory();
|
texture.SynchronizeMemory();
|
||||||
|
|
||||||
// Add overlays by modifying texture data directly
|
// Add overlays by modifying texture data directly
|
||||||
AddOverlaysToTexture(texture, pt.Crop);
|
AddOverlaysToTexture(texture);
|
||||||
|
|
||||||
ImageCrop crop = new(
|
ImageCrop crop = new(
|
||||||
(int)(pt.Crop.Left * texture.ScaleFactor),
|
(int)(pt.Crop.Left * texture.ScaleFactor),
|
||||||
|
@ -264,8 +264,7 @@ namespace Ryujinx.Graphics.Gpu
|
||||||
/// Add overlays to the texture using SkiaSharp
|
/// Add overlays to the texture using SkiaSharp
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="texture">The texture to modify</param>
|
/// <param name="texture">The texture to modify</param>
|
||||||
/// <param name="crop">The crop information containing flip flags</param>
|
private void AddOverlaysToTexture(Image.Texture texture)
|
||||||
private void AddOverlaysToTexture(Image.Texture texture, ImageCrop crop)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -315,9 +314,9 @@ namespace Ryujinx.Graphics.Gpu
|
||||||
// Create canvas for drawing overlays
|
// Create canvas for drawing overlays
|
||||||
using var canvas = new SKCanvas(bitmap);
|
using var canvas = new SKCanvas(bitmap);
|
||||||
|
|
||||||
// Flip Y-axis if the game/texture requires it
|
// On Linux with OpenGL, we need to flip the Y-axis because OpenGL uses bottom-left origin
|
||||||
// Some games have textures that are already flipped, while others need flipping
|
// while SkiaSharp uses top-left origin
|
||||||
if (crop.FlipY)
|
if (OperatingSystem.IsLinux())
|
||||||
{
|
{
|
||||||
canvas.Scale(1, -1);
|
canvas.Scale(1, -1);
|
||||||
canvas.Translate(0, -height);
|
canvas.Translate(0, -height);
|
||||||
|
|
|
@ -16,6 +16,7 @@ namespace Ryujinx.UI.Overlay
|
||||||
{
|
{
|
||||||
private const float OverlayWidth = 400;
|
private const float OverlayWidth = 400;
|
||||||
private const float Padding = 24;
|
private const float Padding = 24;
|
||||||
|
private const float Spacing = 16;
|
||||||
private const float PlayerSpacing = 12;
|
private const float PlayerSpacing = 12;
|
||||||
private const float PlayerRowHeight = 32;
|
private const float PlayerRowHeight = 32;
|
||||||
|
|
||||||
|
@ -119,7 +120,7 @@ namespace Ryujinx.UI.Overlay
|
||||||
if (playerBindings.ContainsKey(playerIndex))
|
if (playerBindings.ContainsKey(playerIndex))
|
||||||
{
|
{
|
||||||
var controllers = playerBindings[playerIndex];
|
var controllers = playerBindings[playerIndex];
|
||||||
var controllerNames = GetUniqueControllerDisplayNames(controllers);
|
var controllerNames = controllers.Select(c => GetControllerDisplayName(c)).ToList();
|
||||||
|
|
||||||
var controllerTextElement = new TextElement(Padding + 56, rowY + 2, string.Join(", ", controllerNames), PlayerTextSize, new SKColor(144, 238, 144)) // LightGreen
|
var controllerTextElement = new TextElement(Padding + 56, rowY + 2, string.Join(", ", controllerNames), PlayerTextSize, new SKColor(144, 238, 144)) // LightGreen
|
||||||
{
|
{
|
||||||
|
@ -168,37 +169,6 @@ namespace Ryujinx.UI.Overlay
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<string> GetUniqueControllerDisplayNames(List<OriginalInputConfig> controllers)
|
|
||||||
{
|
|
||||||
var nameGroups = new Dictionary<string, List<int>>();
|
|
||||||
var displayNames = new List<string>();
|
|
||||||
|
|
||||||
// First pass: get base names and group them
|
|
||||||
for (int i = 0; i < controllers.Count; i++)
|
|
||||||
{
|
|
||||||
string baseName = GetControllerDisplayName(controllers[i]);
|
|
||||||
|
|
||||||
if (!nameGroups.ContainsKey(baseName))
|
|
||||||
{
|
|
||||||
nameGroups[baseName] = new List<int>();
|
|
||||||
}
|
|
||||||
nameGroups[baseName].Add(i);
|
|
||||||
displayNames.Add(baseName);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Second pass: add numbering for duplicates
|
|
||||||
foreach (var group in nameGroups.Where(g => g.Value.Count > 1))
|
|
||||||
{
|
|
||||||
for (int i = 0; i < group.Value.Count; i++)
|
|
||||||
{
|
|
||||||
int index = group.Value[i];
|
|
||||||
displayNames[index] = $"{group.Key} #{i + 1}";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return displayNames;
|
|
||||||
}
|
|
||||||
|
|
||||||
private string GetControllerDisplayName(OriginalInputConfig config)
|
private string GetControllerDisplayName(OriginalInputConfig config)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(config.Name))
|
if (string.IsNullOrEmpty(config.Name))
|
||||||
|
@ -211,15 +181,11 @@ namespace Ryujinx.UI.Overlay
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Truncate long controller names from the middle
|
// Truncate long controller names
|
||||||
string name = config.Name;
|
string name = config.Name;
|
||||||
if (name.Length > 25)
|
if (name.Length > 25)
|
||||||
{
|
{
|
||||||
int keepLength = 22; // Total characters to keep (excluding "...")
|
name = name.Substring(0, 22) + "...";
|
||||||
int leftLength = (keepLength + 1) / 2; // Round up for left side
|
|
||||||
int rightLength = keepLength / 2; // Round down for right side
|
|
||||||
|
|
||||||
name = name.Substring(0, leftLength) + "..." + name.Substring(name.Length - rightLength);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue