Compare commits
3 Commits
Canary-1.2
...
Canary-1.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3f12727ef8 | ||
|
|
8bfcebebf1 | ||
|
|
e3f20abd23 |
@@ -1,6 +1,7 @@
|
||||
using Gommon;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Ryujinx.Common.Utilities
|
||||
@@ -18,7 +19,7 @@ namespace Ryujinx.Common.Utilities
|
||||
{
|
||||
while (CyclingEnabled)
|
||||
{
|
||||
await Task.Delay(15);
|
||||
await Task.Delay(20);
|
||||
Tick();
|
||||
}
|
||||
});
|
||||
@@ -33,28 +34,46 @@ namespace Ryujinx.Common.Utilities
|
||||
|
||||
public static float Speed { get; set; } = 1;
|
||||
|
||||
public static Color Color { get; private set; } = Color.Blue;
|
||||
private static readonly Lock _lock = new();
|
||||
|
||||
private static Color _color = Color.Blue;
|
||||
|
||||
public static ref Color Color
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
return ref _color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Tick()
|
||||
{
|
||||
Color = HsbToRgb((Color.GetHue() + Speed) / 360);
|
||||
lock (_lock)
|
||||
{
|
||||
_color = HsbToRgb((_color.GetHue() + Speed) / 360);
|
||||
|
||||
UpdatedHandler.Call(Color.ToArgb());
|
||||
_updatedHandler.Call(_color.ToArgb());
|
||||
}
|
||||
}
|
||||
|
||||
public static void Reset()
|
||||
{
|
||||
Color = Color.Blue;
|
||||
UpdatedHandler.Clear();
|
||||
_updatedHandler.Clear();
|
||||
|
||||
lock (_lock)
|
||||
_color = Color.Blue;
|
||||
}
|
||||
|
||||
public static event Action<int> Updated
|
||||
{
|
||||
add => UpdatedHandler.Add(value);
|
||||
remove => UpdatedHandler.Remove(value);
|
||||
add => _updatedHandler.Add(value);
|
||||
remove => _updatedHandler.Remove(value);
|
||||
}
|
||||
|
||||
internal static Event<int> UpdatedHandler = new();
|
||||
private static readonly Event<int> _updatedHandler = new();
|
||||
|
||||
private static Color HsbToRgb(float hue, float saturation = 1, float brightness = 1)
|
||||
{
|
||||
|
||||
@@ -148,8 +148,6 @@ namespace Ryujinx.Input.SDL2
|
||||
{
|
||||
if (disposing && _gamepadHandle != nint.Zero)
|
||||
{
|
||||
Rainbow.Updated -= RainbowColorChanged;
|
||||
|
||||
SDL_GameControllerClose(_gamepadHandle);
|
||||
|
||||
_gamepadHandle = nint.Zero;
|
||||
@@ -228,15 +226,6 @@ namespace Ryujinx.Input.SDL2
|
||||
|
||||
private static Vector3 GsToMs2(Vector3 gs) => gs / SDL_STANDARD_GRAVITY;
|
||||
|
||||
private void RainbowColorChanged(int packedRgb)
|
||||
{
|
||||
if (!_configuration.Led.UseRainbow) return;
|
||||
|
||||
SetLed((uint)packedRgb);
|
||||
}
|
||||
|
||||
private bool _rainbowColorEnabled;
|
||||
|
||||
public void SetConfiguration(InputConfig configuration)
|
||||
{
|
||||
lock (_userMappingLock)
|
||||
@@ -247,19 +236,10 @@ namespace Ryujinx.Input.SDL2
|
||||
{
|
||||
if (_configuration.Led.TurnOffLed)
|
||||
(this as IGamepad).ClearLed();
|
||||
else switch (_configuration.Led.UseRainbow)
|
||||
{
|
||||
case true when !_rainbowColorEnabled:
|
||||
Rainbow.Updated += RainbowColorChanged;
|
||||
_rainbowColorEnabled = true;
|
||||
break;
|
||||
case false when _rainbowColorEnabled:
|
||||
Rainbow.Updated -= RainbowColorChanged;
|
||||
_rainbowColorEnabled = false;
|
||||
break;
|
||||
}
|
||||
else if (_configuration.Led.UseRainbow)
|
||||
SetLed((uint)Rainbow.Color.ToArgb());
|
||||
|
||||
if (!_configuration.Led.TurnOffLed && !_rainbowColorEnabled)
|
||||
if (!_configuration.Led.TurnOffLed && !_configuration.Led.UseRainbow)
|
||||
SetLed(_configuration.Led.LedColor);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using Avalonia.Controls;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Threading;
|
||||
using DiscordRPC;
|
||||
using LibHac.Common;
|
||||
using LibHac.Ns;
|
||||
using LibHac.Tools.FsSystem;
|
||||
@@ -595,6 +596,8 @@ namespace Ryujinx.Ava
|
||||
gamepad?.Dispose();
|
||||
}
|
||||
|
||||
DiscordIntegrationModule.GuestAppStartedAt = null;
|
||||
|
||||
Rainbow.Disable();
|
||||
Rainbow.Reset();
|
||||
|
||||
@@ -685,6 +688,8 @@ namespace Ryujinx.Ava
|
||||
|
||||
public async Task<bool> LoadGuestApplication(BlitStruct<ApplicationControlProperty>? customNacpData = null)
|
||||
{
|
||||
DiscordIntegrationModule.GuestAppStartedAt = Timestamps.Now;
|
||||
|
||||
InitEmulatedSwitch();
|
||||
MainWindow.UpdateGraphicsConfig();
|
||||
|
||||
|
||||
@@ -14,7 +14,8 @@ namespace Ryujinx.Ava
|
||||
{
|
||||
public static class DiscordIntegrationModule
|
||||
{
|
||||
public static Timestamps StartedAt { get; set; }
|
||||
public static Timestamps EmulatorStartedAt { get; set; }
|
||||
public static Timestamps GuestAppStartedAt { get; set; }
|
||||
|
||||
private static string VersionString
|
||||
=> (ReleaseInformation.IsCanaryBuild ? "Canary " : string.Empty) + $"v{ReleaseInformation.Version}";
|
||||
@@ -43,7 +44,7 @@ namespace Ryujinx.Ava
|
||||
},
|
||||
Details = "Main Menu",
|
||||
State = "Idling",
|
||||
Timestamps = StartedAt
|
||||
Timestamps = EmulatorStartedAt
|
||||
};
|
||||
|
||||
ConfigurationState.Instance.EnableDiscordIntegration.Event += Update;
|
||||
@@ -100,7 +101,7 @@ namespace Ryujinx.Ava
|
||||
State = appMeta.LastPlayed.HasValue && appMeta.TimePlayed.TotalSeconds > 5
|
||||
? $"Total play time: {ValueFormatUtils.FormatTimeSpan(appMeta.TimePlayed)}"
|
||||
: "Never played",
|
||||
Timestamps = Timestamps.Now
|
||||
Timestamps = GuestAppStartedAt ??= Timestamps.Now
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace Ryujinx.Headless
|
||||
public static void Initialize()
|
||||
{
|
||||
// Ensure Discord presence timestamp begins at the absolute start of when Ryujinx is launched
|
||||
DiscordIntegrationModule.StartedAt = Timestamps.Now;
|
||||
DiscordIntegrationModule.EmulatorStartedAt = Timestamps.Now;
|
||||
|
||||
// Delete backup files after updating.
|
||||
Task.Run(Updater.CleanupUpdate);
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace Ryujinx.Ava
|
||||
private static void Initialize(string[] args)
|
||||
{
|
||||
// Ensure Discord presence timestamp begins at the absolute start of when Ryujinx is launched
|
||||
DiscordIntegrationModule.StartedAt = Timestamps.Now;
|
||||
DiscordIntegrationModule.EmulatorStartedAt = Timestamps.Now;
|
||||
|
||||
// Parse arguments
|
||||
CommandLineState.ParseArguments(args);
|
||||
|
||||
Reference in New Issue
Block a user