diff --git a/src/Ryujinx.Common/Extensions/StreamExtensions.cs b/src/Ryujinx.Common/Extensions/StreamExtensions.cs index 431d5534a..4b02781c9 100644 --- a/src/Ryujinx.Common/Extensions/StreamExtensions.cs +++ b/src/Ryujinx.Common/Extensions/StreamExtensions.cs @@ -8,7 +8,7 @@ namespace Ryujinx.Common public static class StreamExtensions { /// - /// Writes a " /> to this stream. + /// Writes a to this stream. /// /// This default implementation converts each buffer value to a stack-allocated /// byte array, then writes it to the Stream using . @@ -66,8 +66,8 @@ namespace Ryujinx.Common } /// - // Writes a four-byte unsigned integer to this stream. The current position - // of the stream is advanced by four. + /// Writes a four-byte unsigned integer to this stream. The current position + /// of the stream is advanced by four. /// /// The stream to be written to /// The value to be written diff --git a/src/Ryujinx.Common/Hash128.cs b/src/Ryujinx.Common/Hash128.cs index be73b6e39..69ab9f76e 100644 --- a/src/Ryujinx.Common/Hash128.cs +++ b/src/Ryujinx.Common/Hash128.cs @@ -107,7 +107,7 @@ namespace Ryujinx.Common [MethodImpl(MethodImplOptions.AggressiveInlining)] private static ulong XorShift64(ulong v64, int shift) { - Debug.Assert(0 <= shift && shift < 64); + Debug.Assert(shift is >= 0 and < 64); return v64 ^ (v64 >> shift); } diff --git a/src/Ryujinx.Common/Utilities/BitUtils.cs b/src/Ryujinx.Common/Utilities/BitUtils.cs index 0bf9c8acd..3277b0f82 100644 --- a/src/Ryujinx.Common/Utilities/BitUtils.cs +++ b/src/Ryujinx.Common/Utilities/BitUtils.cs @@ -4,23 +4,18 @@ namespace Ryujinx.Common { public static class BitUtils { - public static T AlignUp(T value, T size) - where T : IBinaryInteger - { - return (value + (size - T.One)) & -size; - } + public static T AlignUp(T value, T size) where T : IBinaryInteger + => (value + (size - T.One)) & -size; - public static T AlignDown(T value, T size) - where T : IBinaryInteger - { - return value & -size; - } + public static T AlignDown(T value, T size) where T : IBinaryInteger + => value & -size; - public static T DivRoundUp(T value, T dividend) - where T : IBinaryInteger - { - return (value + (dividend - T.One)) / dividend; - } + public static T DivRoundUp(T value, T dividend) where T : IBinaryInteger + => (value + (dividend - T.One)) / dividend; + + public static int Pow2RoundDown(int value) => BitOperations.IsPow2(value) ? value : Pow2RoundUp(value) >> 1; + + public static long ReverseBits64(long value) => (long)ReverseBits64((ulong)value); public static int Pow2RoundUp(int value) { @@ -35,16 +30,6 @@ namespace Ryujinx.Common return ++value; } - public static int Pow2RoundDown(int value) - { - return BitOperations.IsPow2(value) ? value : Pow2RoundUp(value) >> 1; - } - - public static long ReverseBits64(long value) - { - return (long)ReverseBits64((ulong)value); - } - private static ulong ReverseBits64(ulong value) { value = ((value & 0xaaaaaaaaaaaaaaaa) >> 1) | ((value & 0x5555555555555555) << 1); diff --git a/src/Ryujinx.Graphics.OpenGL/OpenGLRenderer.cs b/src/Ryujinx.Graphics.OpenGL/OpenGLRenderer.cs index 9fcdf1ad7..377cad386 100644 --- a/src/Ryujinx.Graphics.OpenGL/OpenGLRenderer.cs +++ b/src/Ryujinx.Graphics.OpenGL/OpenGLRenderer.cs @@ -243,7 +243,7 @@ namespace Ryujinx.Graphics.OpenGL // This is required to disable [0, 1] clamping for SNorm outputs on compatibility profiles. // This call is expected to fail if we're running with a core profile, // as this clamp target was deprecated, but that's fine as a core profile - // should already have the desired behaviour were outputs are not clamped. + // should already have the desired behaviour where outputs are not clamped. GL.ClampColor(ClampColorTarget.ClampFragmentColor, ClampColorMode.False); } diff --git a/src/Ryujinx.Graphics.Texture/BC6Decoder.cs b/src/Ryujinx.Graphics.Texture/BC6Decoder.cs index ae33e9cf9..f4d933643 100644 --- a/src/Ryujinx.Graphics.Texture/BC6Decoder.cs +++ b/src/Ryujinx.Graphics.Texture/BC6Decoder.cs @@ -45,7 +45,7 @@ namespace Ryujinx.Graphics.Texture if (subsetCount == 0) { // Mode is invalid, the spec mandates that hardware fills the block with - // a opaque black color. + // an opaque black color. for (int ty = 0; ty < h; ty++) { int baseOffs = ty * width; diff --git a/src/Ryujinx.Graphics.Texture/OffsetCalculator.cs b/src/Ryujinx.Graphics.Texture/OffsetCalculator.cs index 48d36cdfb..da357f57e 100644 --- a/src/Ryujinx.Graphics.Texture/OffsetCalculator.cs +++ b/src/Ryujinx.Graphics.Texture/OffsetCalculator.cs @@ -15,7 +15,7 @@ namespace Ryujinx.Graphics.Texture private readonly BlockLinearLayout _layoutConverter; - // Variables for built in iteration. + // Variables for built-in iteration. private int _yPart; public OffsetCalculator( @@ -73,69 +73,50 @@ namespace Ryujinx.Graphics.Texture public int GetOffset(int x, int y) { if (_isLinear) - { return x * _bytesPerPixel + y * _stride; - } - else - { - return _layoutConverter.GetOffset(x, y, 0); - } + + return _layoutConverter.GetOffset(x, y, 0); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public int GetOffset(int x) { if (_isLinear) - { return x * _bytesPerPixel + _yPart; - } - else - { - return _layoutConverter.GetOffset(x); - } + + return _layoutConverter.GetOffset(x); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public int GetOffsetWithLineOffset64(int x) { if (_isLinear) - { return x + _yPart; - } - else - { - return _layoutConverter.GetOffsetWithLineOffset64(x); - } + + return _layoutConverter.GetOffsetWithLineOffset64(x); } public (int offset, int size) GetRectangleRange(int x, int y, int width, int height) { - if (_isLinear) - { - int start = y * Math.Abs(_stride) + x * _bytesPerPixel; - int end = (y + height - 1) * Math.Abs(_stride) + (x + width) * _bytesPerPixel; - return (y * _stride + x * _bytesPerPixel, end - start); - } - else - { + if (!_isLinear) return _layoutConverter.GetRectangleRange(x, y, width, height); - } + + int start = y * Math.Abs(_stride) + x * _bytesPerPixel; + int end = (y + height - 1) * Math.Abs(_stride) + (x + width) * _bytesPerPixel; + return (y * _stride + x * _bytesPerPixel, end - start); } public bool LayoutMatches(OffsetCalculator other) { if (_isLinear) - { return other._isLinear && _width == other._width && _height == other._height && _stride == other._stride && _bytesPerPixel == other._bytesPerPixel; - } - else - { - return !other._isLinear && _layoutConverter.LayoutMatches(other._layoutConverter); - } + + + return !other._isLinear && _layoutConverter.LayoutMatches(other._layoutConverter); } } } diff --git a/src/Ryujinx.HLE.Generators/IpcServiceGenerator.cs b/src/Ryujinx.HLE.Generators/IpcServiceGenerator.cs index 19fdbe197..d6b6f23ef 100644 --- a/src/Ryujinx.HLE.Generators/IpcServiceGenerator.cs +++ b/src/Ryujinx.HLE.Generators/IpcServiceGenerator.cs @@ -25,7 +25,7 @@ namespace Ryujinx.HLE.Generators var name = GetFullName(className, context).Replace("global::", ""); if (!name.StartsWith("Ryujinx.HLE.HOS.Services")) continue; - var constructors = className.ChildNodes().Where(x => x.IsKind(SyntaxKind.ConstructorDeclaration)).Select(y => y as ConstructorDeclarationSyntax); + var constructors = className.ChildNodes().Where(x => x.IsKind(SyntaxKind.ConstructorDeclaration)).Select(y => y as ConstructorDeclarationSyntax).ToArray(); if (!constructors.Any(x => x.ParameterList.Parameters.Count >= 1)) continue; diff --git a/src/Ryujinx.UI.Common/DiscordIntegrationModule.cs b/src/Ryujinx.UI.Common/DiscordIntegrationModule.cs index 0901319e4..d5a9c3089 100644 --- a/src/Ryujinx.UI.Common/DiscordIntegrationModule.cs +++ b/src/Ryujinx.UI.Common/DiscordIntegrationModule.cs @@ -15,7 +15,10 @@ namespace Ryujinx.UI.Common { public static Timestamps StartedAt { get; set; } - private static readonly string _description = $"v{ReleaseInformation.Version} {ReleaseInformation.ReleaseChannelOwner}/{ReleaseInformation.ReleaseChannelRepo}@{ReleaseInformation.BuildGitHash}"; + private static readonly string _description = ReleaseInformation.IsValid + ? $"v{ReleaseInformation.Version} {ReleaseInformation.ReleaseChannelOwner}/{ReleaseInformation.ReleaseChannelRepo}@{ReleaseInformation.BuildGitHash}" + : "dev build"; + private const string ApplicationId = "1293250299716173864"; private const int ApplicationByteLimit = 128; @@ -76,7 +79,7 @@ namespace Ryujinx.UI.Common SmallImageText = TruncateToByteLength(_description) }, Details = TruncateToByteLength($"Playing {appMeta.Title}"), - State = appMeta.LastPlayed.HasValue + State = appMeta.LastPlayed.HasValue && appMeta.TimePlayed.TotalSeconds > 5 ? $"Total play time: {appMeta.TimePlayed.Humanize(2, false)}" : "Never played", Timestamps = Timestamps.Now @@ -115,7 +118,8 @@ namespace Ryujinx.UI.Common _discordClient?.Dispose(); } - private static readonly string[] _discordGameAssetKeys = [ + private static readonly string[] _discordGameAssetKeys = + [ "01002da013484000", // The Legend of Zelda: Skyward Sword HD "01007ef00011e000", // The Legend of Zelda: Breath of the Wild "0100f2c0115b6000", // The Legend of Zelda: Tears of the Kingdom @@ -145,9 +149,12 @@ namespace Ryujinx.UI.Common "0100c2500fc20000", // Splatoon 3 "0100ba0018500000", // Splatoon 3: Splatfest World Premiere + "01000a10041ea000", // The Elder Scrolls V: Skyrim "01007820196a6000", // Red Dead Redemption "0100744001588000", // Cars 3: Driven to Win + "01002b00111a2000", // Hyrule Warriors: Age of Calamity "01006f8002326000", // Animal Crossing: New Horizons + "01004d300c5ae000", // Kirby and the Forgotten Land "0100853015e86000", // No Man's Sky "01008d100d43e000", // Saints Row IV "0100de600beee000", // Saints Row: The Third - The Full Package diff --git a/src/Ryujinx/UI/Controls/SliderScroll.axaml.cs b/src/Ryujinx/UI/Controls/SliderScroll.axaml.cs index b57c6f0a2..2f421e331 100644 --- a/src/Ryujinx/UI/Controls/SliderScroll.axaml.cs +++ b/src/Ryujinx/UI/Controls/SliderScroll.axaml.cs @@ -10,20 +10,7 @@ namespace Ryujinx.Ava.UI.Controls protected override void OnPointerWheelChanged(PointerWheelEventArgs e) { - var newValue = Value + e.Delta.Y * TickFrequency; - - if (newValue < Minimum) - { - Value = Minimum; - } - else if (newValue > Maximum) - { - Value = Maximum; - } - else - { - Value = newValue; - } + Value = Math.Clamp(Value + e.Delta.Y * TickFrequency, Minimum, Maximum); e.Handled = true; } diff --git a/src/Ryujinx/UI/Helpers/ContentDialogHelper.cs b/src/Ryujinx/UI/Helpers/ContentDialogHelper.cs index 15b7ddd14..434771eca 100644 --- a/src/Ryujinx/UI/Helpers/ContentDialogHelper.cs +++ b/src/Ryujinx/UI/Helpers/ContentDialogHelper.cs @@ -230,6 +230,16 @@ namespace Ryujinx.Ava.UI.Helpers primaryButtonResult); } + internal static async Task CreateLocalizedConfirmationDialog( + string primaryText, + string secondaryText) => + await CreateConfirmationDialog( + primaryText, + secondaryText, + LocaleManager.Instance[LocaleKeys.InputDialogYes], + LocaleManager.Instance[LocaleKeys.InputDialogNo], + LocaleManager.Instance[LocaleKeys.RyujinxConfirm]); + internal static async Task CreateUpdaterInfoDialog(string primary, string secondaryText) { await ShowTextDialog( diff --git a/src/Ryujinx/UI/Views/Main/MainStatusBarView.axaml b/src/Ryujinx/UI/Views/Main/MainStatusBarView.axaml index f9e192e62..c01f43a01 100644 --- a/src/Ryujinx/UI/Views/Main/MainStatusBarView.axaml +++ b/src/Ryujinx/UI/Views/Main/MainStatusBarView.axaml @@ -1,4 +1,4 @@ - - - - - - - + IsVisible="{Binding ShowMenuAndStatusBar}" + ColumnDefinitions="Auto,Auto,*,Auto"> Math.Max(Math.Max(color.R, color.G), color.B); + + private static int BalanceHitCount(int hitCount, int maxHitCount) => (hitCount << 8) / maxHitCount; + + private static int GetColorApproximateLuminosity(byte r, byte g, byte b) => (r + g + b) / 3; private static int GetQuantizedColorKey(byte r, byte g, byte b) {