mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-05-20 07:27:28 +01:00
Compare commits
9 commits
ef7274e6bb
...
68faff3a5e
Author | SHA1 | Date | |
---|---|---|---|
68faff3a5e | |||
a23d8cb92f | |||
0350d45557 | |||
b58ce13567 | |||
a74e8f8288 | |||
a1646ff551 | |||
c381567328 | |||
36e7f56f2b | |||
55b8cf6e3c |
|
@ -857,8 +857,14 @@ namespace ARMeilleure.Translation.PTC
|
|||
|
||||
Stopwatch sw = Stopwatch.StartNew();
|
||||
|
||||
threads.ForEach((thread) => thread.Start());
|
||||
threads.ForEach((thread) => thread.Join());
|
||||
foreach (var thread in threads)
|
||||
{
|
||||
thread.Start();
|
||||
}
|
||||
foreach (var thread in threads)
|
||||
{
|
||||
thread.Join();
|
||||
}
|
||||
|
||||
threads.Clear();
|
||||
|
||||
|
|
|
@ -395,8 +395,14 @@ namespace Ryujinx.Graphics.Gpu
|
|||
{
|
||||
Renderer.CreateSync(SyncNumber, strict);
|
||||
|
||||
SyncActions.ForEach(action => action.SyncPreAction(syncpoint));
|
||||
SyncpointActions.ForEach(action => action.SyncPreAction(syncpoint));
|
||||
foreach (var action in SyncActions)
|
||||
{
|
||||
action.SyncPreAction(syncpoint);
|
||||
}
|
||||
foreach (var action in SyncpointActions)
|
||||
{
|
||||
action.SyncPreAction(syncpoint);
|
||||
}
|
||||
|
||||
SyncNumber++;
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using DiscordRPC;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.UI.Common.Configuration;
|
||||
using System.Text;
|
||||
|
||||
namespace Ryujinx.UI.Common
|
||||
{
|
||||
|
@ -9,6 +10,9 @@ namespace Ryujinx.UI.Common
|
|||
private const string Description = "A simple, experimental Nintendo Switch emulator.";
|
||||
private const string ApplicationId = "1216775165866807456";
|
||||
|
||||
private const int ApplicationByteLimit = 128;
|
||||
private const string Ellipsis = "…";
|
||||
|
||||
private static DiscordRpcClient _discordClient;
|
||||
private static RichPresence _discordPresenceMain;
|
||||
|
||||
|
@ -60,18 +64,18 @@ namespace Ryujinx.UI.Common
|
|||
}
|
||||
}
|
||||
|
||||
public static void SwitchToPlayingState(string titleId, string titleName)
|
||||
public static void SwitchToPlayingState(string titleId, string applicationName)
|
||||
{
|
||||
_discordClient?.SetPresence(new RichPresence
|
||||
{
|
||||
Assets = new Assets
|
||||
{
|
||||
LargeImageKey = "game",
|
||||
LargeImageText = titleName,
|
||||
LargeImageText = TruncateToByteLength(applicationName, ApplicationByteLimit),
|
||||
SmallImageKey = "ryujinx",
|
||||
SmallImageText = Description,
|
||||
},
|
||||
Details = $"Playing {titleName}",
|
||||
Details = TruncateToByteLength($"Playing {applicationName}", ApplicationByteLimit),
|
||||
State = (titleId == "0000000000000000") ? "Homebrew" : titleId.ToUpper(),
|
||||
Timestamps = Timestamps.Now,
|
||||
Buttons =
|
||||
|
@ -90,6 +94,28 @@ namespace Ryujinx.UI.Common
|
|||
_discordClient?.SetPresence(_discordPresenceMain);
|
||||
}
|
||||
|
||||
private static string TruncateToByteLength(string input, int byteLimit)
|
||||
{
|
||||
if (Encoding.UTF8.GetByteCount(input) <= byteLimit)
|
||||
{
|
||||
return input;
|
||||
}
|
||||
|
||||
// Find the length to trim the string to guarantee we have space for the trailing ellipsis.
|
||||
int trimLimit = byteLimit - Encoding.UTF8.GetByteCount(Ellipsis);
|
||||
|
||||
// Basic trim to best case scenario of 1 byte characters.
|
||||
input = input[..trimLimit];
|
||||
|
||||
while (Encoding.UTF8.GetByteCount(input) > trimLimit)
|
||||
{
|
||||
// Remove one character from the end of the string at a time.
|
||||
input = input[..^1];
|
||||
}
|
||||
|
||||
return input.TrimEnd() + Ellipsis;
|
||||
}
|
||||
|
||||
public static void Exit()
|
||||
{
|
||||
_discordClient?.Dispose();
|
||||
|
|
Loading…
Reference in a new issue