diff --git a/Core/RenderManager.cs b/Core/RenderManager.cs index 93a7494..e1112c9 100644 --- a/Core/RenderManager.cs +++ b/Core/RenderManager.cs @@ -792,7 +792,7 @@ internal class RenderManager : MonoBehaviour // removes frames, and it signals FrameDequeuedEvent for each one. The wait has a timeout so that the loop // re-checks the render thread state and pumps pending readback completions (see ThrottleWaitMilliseconds). isThrottling = false; - var frameLimit = QueueFrameLimit = ComputeQueueFrameLimit(texture!); + var frameLimit = QueueFrameLimit = ComputeQueueFrameLimit(texture); while (Instance.stage >= RenderStage.Render) { diff --git a/Data/Codec.cs b/Data/Codec.cs index 346785d..f1c970b 100644 --- a/Data/Codec.cs +++ b/Data/Codec.cs @@ -35,7 +35,7 @@ internal static class CodecUtil /// public static readonly Dictionary> AvailableSampleRate = new() { - [AVCodecID.AV_CODEC_ID_AAC] = new List { 44100, 48000, 96000 }, - [AVCodecID.AV_CODEC_ID_OPUS] = new List { 48000 } + [AVCodecID.AV_CODEC_ID_AAC] = [44100, 48000, 96000], + [AVCodecID.AV_CODEC_ID_OPUS] = [48000] }; } \ No newline at end of file diff --git a/Data/ColorJsonConverter.cs b/Data/ColorJsonConverter.cs index 28c501d..9e281c1 100644 --- a/Data/ColorJsonConverter.cs +++ b/Data/ColorJsonConverter.cs @@ -43,7 +43,7 @@ public class ColorJsonConverter : JsonConverter if (reader.TokenType == JsonToken.Null) { - return isNullable ? null : (object)default(Color); + return isNullable ? null : default(Color); } if (reader.TokenType == JsonToken.String) @@ -54,7 +54,7 @@ public class ColorJsonConverter : JsonConverter return parsedColor; } - return isNullable ? null : (object)default(Color); + return isNullable ? null : default(Color); } if (reader.TokenType == JsonToken.StartObject) @@ -67,7 +67,7 @@ public class ColorJsonConverter : JsonConverter return new Color(r, g, b, a); } - return isNullable ? null : (object)default(Color); + return isNullable ? null : default(Color); } /// diff --git a/Patch/Engine/AudioPatches.cs b/Patch/Engine/AudioPatches.cs index 5f33e9a..25df921 100644 --- a/Patch/Engine/AudioPatches.cs +++ b/Patch/Engine/AudioPatches.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using ADOFAIRenderer.Core; using ADOFAIRenderer.Util.Audio; using ADOFAIRenderer.Util.Audio.Clip; @@ -206,7 +207,7 @@ public static class AudioSourceIsPlayingPatch { /// When finds a mapped state, uses it and returns false (Unity is skipped); otherwise returns true. [HarmonyPrefix] - // ReSharper disable once InconsistentNaming + [SuppressMessage("ReSharper", "InconsistentNaming")] public static bool Prefix(AudioSource __instance, ref bool __result) { if (!EffectSource.TryGet(__instance, out var state, out var now)) return true; @@ -221,7 +222,7 @@ public static class AudioSourceTimeGetterPatch { /// When finds a mapped state, uses it and returns false (Unity is skipped); otherwise returns true. [HarmonyPrefix] - // ReSharper disable once InconsistentNaming + [SuppressMessage("ReSharper", "InconsistentNaming")] public static bool Prefix(AudioSource __instance, ref float __result) { if (!EffectSource.TryGet(__instance, out var state, out var now)) return true; @@ -257,7 +258,7 @@ public static class AudioSourceTimeSamplesGetterPatch { /// When finds a mapped state, uses it and returns false (Unity is skipped); otherwise returns true. [HarmonyPrefix] - // ReSharper disable once InconsistentNaming + [SuppressMessage("ReSharper", "InconsistentNaming")] public static bool Prefix(AudioSource __instance, ref int __result) { if (!EffectSource.TryGet(__instance, out var state, out var now)) return true; @@ -287,7 +288,7 @@ public static class AudioSourcePitchGetterPatch { /// When finds a mapped state, uses it and returns false (Unity is skipped); otherwise returns true. [HarmonyPrefix] - // ReSharper disable once InconsistentNaming + [SuppressMessage("ReSharper", "InconsistentNaming")] public static bool Prefix(AudioSource __instance, ref float __result) { if (!EffectSource.TryGet(__instance, out var state, out _)) return true; diff --git a/Patch/Game/CustomFrameRateDeferPatch.cs b/Patch/Game/CustomFrameRateDeferPatch.cs index 7880867..1d765fa 100644 --- a/Patch/Game/CustomFrameRateDeferPatch.cs +++ b/Patch/Game/CustomFrameRateDeferPatch.cs @@ -28,20 +28,9 @@ public static class CustomFrameRateDeferPatch /// /// Checks whether the SetFramerate render timing fix is enabled. - /// Active if rendering session has the option enabled, or enabled by default during normal in-game play. + /// Active if rendering session has the option enabled. /// - public static bool IsEnabled - { - get - { - if (RenderManager.IsActive && RenderManager.Instance?.Configuration?.AdvancedConfig != null) - { - return RenderManager.Instance.Configuration.AdvancedConfig.FixCustomFrameRate; - } - - return true; - } - } + public static bool IsEnabled => RenderManager.IsActive && RenderManager.Instance.Configuration.AdvancedConfig.FixCustomFrameRate; /// /// Intercepts manual camera render calls from SetCustomFrameRate (Update phase) or CheckUpdateFrameRateScreen diff --git a/Patch/Game/DecorationPatch.cs b/Patch/Game/DecorationPatch.cs index 8ebce33..9ece435 100644 --- a/Patch/Game/DecorationPatch.cs +++ b/Patch/Game/DecorationPatch.cs @@ -16,7 +16,7 @@ public static class DecorationPatch public static bool IsEnabled => RenderManager.Instance && RenderManager.Instance.stage >= RenderStage.Load && - RenderManager.Instance.Configuration?.AdvancedConfig?.HideFailedDecorations == true; + RenderManager.Instance.Configuration.AdvancedConfig.HideFailedDecorations; /// /// Checks whether the given sprite is the default placeholder or not-found sprite of the decoration manager. @@ -46,7 +46,7 @@ public static class DecorationPatch { if (IsPlaceholderSprite(visualDec.spriteRenderer.sprite, manager)) { - visualDec.SetSprite((Sprite)null!); + visualDec.SetSprite(null!); } } } @@ -61,6 +61,7 @@ public static class DecorationPatch public static class VisualDecorationSetSpritePatch { [HarmonyPrefix] + // ReSharper disable once InconsistentNaming public static void Prefix(scrVisualDecoration __instance, ref Sprite? sprite) { if (!IsEnabled || !sprite) return; diff --git a/Patch/Game/scnGamePatch.cs b/Patch/Game/scnGamePatch.cs index 1cdcf21..e7067fd 100644 --- a/Patch/Game/scnGamePatch.cs +++ b/Patch/Game/scnGamePatch.cs @@ -44,7 +44,7 @@ public static class scnGamePatch var nonTile = RenderManager.Instance && RenderManager.Instance.stage >= RenderStage.Load && - RenderManager.Instance.Configuration?.AdvancedConfig?.NonTile == true; + RenderManager.Instance.Configuration.AdvancedConfig.NonTile; if (!nonTile) return; foreach (var floor in scrLevelMaker.instance.listFloors) diff --git a/Patch/Game/scrControllerPatch.cs b/Patch/Game/scrControllerPatch.cs index 74ed665..2a6880e 100644 --- a/Patch/Game/scrControllerPatch.cs +++ b/Patch/Game/scrControllerPatch.cs @@ -91,6 +91,7 @@ public static class scrControllerPatch /// The game controller. [HarmonyPostfix] [HarmonyPatch("OnLandOnPortal")] + // ReSharper disable once InconsistentNaming public static void PreventWinTextsPostfix(scrController __instance) { if (!RenderManager.IsActive || __instance == null) return; diff --git a/Patch/Game/scrFloorPatch.cs b/Patch/Game/scrFloorPatch.cs index 69e7d9d..36522c7 100644 --- a/Patch/Game/scrFloorPatch.cs +++ b/Patch/Game/scrFloorPatch.cs @@ -41,6 +41,7 @@ public class scrFloorPatch /// [HarmonyPostfix] [HarmonyPatch("Start")] + // ReSharper disable once InconsistentNaming public static void ForceEnableOnStart(scrFloor __instance) { if (RenderManager.Instance && diff --git a/UI/CommonWarningDialogUI.cs b/UI/CommonWarningDialogUI.cs index 7c30c77..e0e5b80 100644 --- a/UI/CommonWarningDialogUI.cs +++ b/UI/CommonWarningDialogUI.cs @@ -222,6 +222,7 @@ internal class CommonWarningDialogUI : MonoBehaviour var btnRowObj = new GameObject("ButtonRow"); btnRowObj.transform.SetParent(content, false); var btnRowRect = btnRowObj.AddComponent(); + // ReSharper disable once InconsistentNaming var btnRowLE = btnRowObj.AddComponent(); btnRowLE.preferredHeight = 40f; btnRowLE.flexibleWidth = 1f; diff --git a/UI/FFmpegDownloadUI.cs b/UI/FFmpegDownloadUI.cs index 6760d47..dd9f910 100644 --- a/UI/FFmpegDownloadUI.cs +++ b/UI/FFmpegDownloadUI.cs @@ -228,6 +228,7 @@ internal class FFmpegDownloadUI : MonoBehaviour descText.lineSpacing = 5; descText.color = new Color(0.85f, 0.85f, 0.85f, 1f); + // ReSharper disable once InconsistentNaming var descLE = descText.gameObject.AddComponent(); descLE.flexibleWidth = 1f; descLE.flexibleHeight = 1f; @@ -237,6 +238,7 @@ internal class FFmpegDownloadUI : MonoBehaviour _buttonContainerObj.transform.SetParent(content, false); _buttonContainerObj.layer = 5; + // ReSharper disable once InconsistentNaming var btnContainerLE = _buttonContainerObj.AddComponent(); btnContainerLE.preferredHeight = 40f; btnContainerLE.flexibleWidth = 1f; @@ -265,6 +267,7 @@ internal class FFmpegDownloadUI : MonoBehaviour downloadBtn.NormalColor = ctx.Theme.ObjectActiveBright; downloadBtn.UpdateVisual(); + // ReSharper disable once InconsistentNaming var downloadBtnLE = downloadBtn.Rect.gameObject.AddComponent(); downloadBtnLE.flexibleWidth = 1f; downloadBtnLE.preferredHeight = 40f; @@ -277,6 +280,7 @@ internal class FFmpegDownloadUI : MonoBehaviour id: "btn_ffmpeg_cancel", height: 40f ); + // ReSharper disable once InconsistentNaming var cancelBtnLE = cancelBtn.Rect.gameObject.AddComponent(); cancelBtnLE.flexibleWidth = 1f; cancelBtnLE.preferredHeight = 40f; @@ -288,6 +292,7 @@ internal class FFmpegDownloadUI : MonoBehaviour _progressBarObj.layer = 5; _progressBarObj.SetActive(false); + // ReSharper disable once InconsistentNaming var pbLE = _progressBarObj.AddComponent(); pbLE.preferredHeight = 24f; pbLE.flexibleWidth = 1f; @@ -355,6 +360,7 @@ internal class FFmpegDownloadUI : MonoBehaviour _statusTextObj.layer = 5; _statusTextObj.SetActive(false); + // ReSharper disable once InconsistentNaming var statusLE = _statusTextObj.AddComponent(); statusLE.preferredHeight = 22f; statusLE.flexibleWidth = 1f; diff --git a/UI/SegmentedControl.cs b/UI/SegmentedControl.cs index 39e31a6..edb146b 100644 --- a/UI/SegmentedControl.cs +++ b/UI/SegmentedControl.cs @@ -183,6 +183,7 @@ internal class SegmentedControl : O5Object segmentObj.transform.SetParent(maskRect, false); var segRect = segmentObj.AddComponent(); + // ReSharper disable once InconsistentNaming var segLE = segmentObj.AddComponent(); segLE.minWidth = 0f; segLE.preferredWidth = 0f; @@ -323,7 +324,7 @@ internal class SegmentedControl : O5Object if (EqualityComparer.Default.Equals(_value, newValue)) return; _value = newValue; - UpdateVisual(false); + UpdateVisual(); if (notify) { @@ -337,7 +338,7 @@ internal class SegmentedControl : O5Object if (EqualityComparer.Default.Equals(_value, value)) return; _value = value; - UpdateVisual(false); + UpdateVisual(); if (notify) { diff --git a/Util/Audio/AudioSpectrumGenerator.cs b/Util/Audio/AudioSpectrumGenerator.cs index 669761c..d248618 100644 --- a/Util/Audio/AudioSpectrumGenerator.cs +++ b/Util/Audio/AudioSpectrumGenerator.cs @@ -75,7 +75,7 @@ internal static class AudioSpectrumGenerator _store = _ownStore; } - _source = AudioClipResolver.GetOrAdd(_store, clip!.name, clip); + _source = AudioClipResolver.GetOrAdd(_store, clip.name, clip); if (_source == null) { Melon.Logger.Error($"[AudioSpectrumGenerator] Song clip '{clip.name}' could not be loaded, the spectrum will be empty."); @@ -125,7 +125,7 @@ internal static class AudioSpectrumGenerator { var n = samples.Length; var conductor = scrConductor.instance; - if (_source == null || _store == null || !conductor || !conductor!.hasSongStarted || !conductor.song + if (_source == null || _store == null || !conductor || !conductor.hasSongStarted || !conductor.song || n == 0 || (n & (n - 1)) != 0) { Array.Clear(samples, 0, n); diff --git a/Util/Audio/AudioSyncCalculator.cs b/Util/Audio/AudioSyncCalculator.cs index f6a7c31..ed9e5c7 100644 --- a/Util/Audio/AudioSyncCalculator.cs +++ b/Util/Audio/AudioSyncCalculator.cs @@ -1,5 +1,3 @@ -using System; - namespace ADOFAIRenderer.Util.Audio; /// diff --git a/Util/Audio/Clip/AudioClipResolver.cs b/Util/Audio/Clip/AudioClipResolver.cs index bcc7010..11ef42f 100644 --- a/Util/Audio/Clip/AudioClipResolver.cs +++ b/Util/Audio/Clip/AudioClipResolver.cs @@ -54,7 +54,7 @@ internal static class AudioClipResolver } if (!clip) return store.GetOrAdd(key, () => null); - return store.GetOrAdd(key, () => UnityClipLoader.Load(clip!, store)); + return store.GetOrAdd(key, () => UnityClipLoader.Load(clip, store)); } /// Opens with FFmpeg; mono MP3 files are wrapped in (game layout). diff --git a/Util/Audio/Clip/AudioClipStore.cs b/Util/Audio/Clip/AudioClipStore.cs index 35152ea..dc2e37a 100644 --- a/Util/Audio/Clip/AudioClipStore.cs +++ b/Util/Audio/Clip/AudioClipStore.cs @@ -198,7 +198,7 @@ internal sealed class AudioClipStore : IDisposable // same key meanwhile, its entry wins and this source is discarded. lock (_sources) { - if (_disposed || _sources.TryGetValue(key, out var raced)) + if (_disposed || _sources.TryGetValue(key, out _)) { source?.DisposeInternal(); return _disposed ? null : _sources[key]; diff --git a/Util/Audio/Clip/DecodeStream.cs b/Util/Audio/Clip/DecodeStream.cs index a962fc1..7c8277c 100644 --- a/Util/Audio/Clip/DecodeStream.cs +++ b/Util/Audio/Clip/DecodeStream.cs @@ -196,6 +196,7 @@ internal sealed class DecodeStream : IDisposable } /// Greatest common divisor of two positive integers (Euclid). + // ReSharper disable once InconsistentNaming private static int GCD(int a, int b) { while (b != 0) (a, b) = (b, a % b); diff --git a/Util/Audio/Clip/FFmpegPCMReader.cs b/Util/Audio/Clip/FFmpegPCMReader.cs index 504b7de..a0a6ee1 100644 --- a/Util/Audio/Clip/FFmpegPCMReader.cs +++ b/Util/Audio/Clip/FFmpegPCMReader.cs @@ -81,6 +81,7 @@ internal sealed unsafe class FFmpegPCMReader : IPCMReader public long Position { get; private set; } /// True when the stream is MP3 and is decoded with the game's MP3 timing (see class summary). + // ReSharper disable once InconsistentNaming public bool IsMP3 { get; } /// Number of demuxer seeks performed (for diagnostics). diff --git a/Util/Audio/Clip/MP3HeaderFrame.cs b/Util/Audio/Clip/MP3HeaderFrame.cs index deae053..5696e92 100644 --- a/Util/Audio/Clip/MP3HeaderFrame.cs +++ b/Util/Audio/Clip/MP3HeaderFrame.cs @@ -1,4 +1,3 @@ -using System; using System.IO; namespace ADOFAIRenderer.Util.Audio.Clip; @@ -20,6 +19,7 @@ namespace ADOFAIRenderer.Util.Audio.Clip; /// - Samples per frame: Layer I 384, Layer II 1152, Layer III 1152 (MPEG-1) or 576 (MPEG-2/2.5). /// - ID3v2 tags before the first frame: "ID3", version (2 bytes), flags (bit 0x10 = 10-byte footer), size (4 bytes, 7 bits each). /// +// ReSharper disable once InconsistentNaming internal static class MP3HeaderFrame { /// Bytes searched for the first frame sync after the ID3v2 tags. diff --git a/Util/Audio/Clip/MP3MonoLayoutReader.cs b/Util/Audio/Clip/MP3MonoLayoutReader.cs index c1c0c8e..48a5df4 100644 --- a/Util/Audio/Clip/MP3MonoLayoutReader.cs +++ b/Util/Audio/Clip/MP3MonoLayoutReader.cs @@ -13,6 +13,7 @@ namespace ADOFAIRenderer.Util.Audio.Clip; /// Output: 1 channel at the inner reader's sample rate. Frame 2k is inner frame k, frame 2k + 1 is 0. /// = 2 * inner TotalFrames. /// +// ReSharper disable once InconsistentNaming internal sealed class MP3MonoLayoutReader : IPCMReader { private readonly IPCMReader _inner; diff --git a/Util/Audio/OfflineAudioMixer.cs b/Util/Audio/OfflineAudioMixer.cs index d8af3b2..d371494 100644 --- a/Util/Audio/OfflineAudioMixer.cs +++ b/Util/Audio/OfflineAudioMixer.cs @@ -164,7 +164,7 @@ internal sealed class OfflineAudioMixer : IDisposable return; } - _bgmKey = clip!.name; + _bgmKey = clip.name; _bgmSource = AudioClipResolver.GetOrAdd(_store, _bgmKey, clip); if (_bgmSource == null) { @@ -268,7 +268,7 @@ internal sealed class OfflineAudioMixer : IDisposable var state = new SourceState(voice, Math.Max(startTime, now), pitch, loop, loop ? endTime : double.PositiveInfinity, clipSource?.Duration ?? 0.0, _sampleRate); - if (source) MapSource(source!, state); + if (source) MapSource(source, state); return state; } diff --git a/Util/Audio/SourceState.cs b/Util/Audio/SourceState.cs index a52e67e..8a719f9 100644 --- a/Util/Audio/SourceState.cs +++ b/Util/Audio/SourceState.cs @@ -76,7 +76,7 @@ internal sealed class SourceState public void BindClip(AudioClip? clip) { if (!clip) return; - _length = clip!.length; + _length = clip.length; _frequency = Math.Max(1, clip.frequency); } diff --git a/Util/FFmpeg/VideoEncoder.cs b/Util/FFmpeg/VideoEncoder.cs index dc709c6..6e1d9eb 100644 --- a/Util/FFmpeg/VideoEncoder.cs +++ b/Util/FFmpeg/VideoEncoder.cs @@ -107,14 +107,13 @@ internal sealed class VideoEncoder : IEquatable /// (for the families the codec has); GPUUtil.GetPrioritizedEncoders keeps this order for the encoders that do not /// belong to the active GPU vendor. /// - public static readonly IReadOnlyList All = new[] - { + public static readonly IReadOnlyList All = [ H264_NVENC, H264_QSV, H264_AMF, H264_VideoToolbox, Libx264, HEVC_NVENC, HEVC_QSV, HEVC_AMF, HEVC_VideoToolbox, Libx265, VP9_NVENC, VP9_QSV, LibvpxVP9, AV1_NVENC, AV1_QSV, AV1_AMF, LibSvtAv1, LibAomAv1, LibVvenc - }; + ]; /// Lookup table of by (case-insensitive), used by . private static readonly Dictionary ByName = diff --git a/Util/UI/UIComponentWrapper.cs b/Util/UI/UIComponentWrapper.cs index 4ca94c4..d40418b 100644 --- a/Util/UI/UIComponentWrapper.cs +++ b/Util/UI/UIComponentWrapper.cs @@ -2,7 +2,6 @@ using O5Kit.Control; using O5Kit.Core; using TMPro; -using UnityEngine; namespace ADOFAIRenderer.Util.UI;