Migrate to C#12

This commit is contained in:
copecone committed 2026-10-22 11:54:26 +09:00
1 parent 7eaf4f48e6
commit 98d31404cc
24 files changed
+42 -42

No files matched your search

+1 -1
View File
@@ -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)
{
+2 -2
View File
@@ -35,7 +35,7 @@ internal static class CodecUtil
/// </summary>
public static readonly Dictionary<AVCodecID, List<int>> AvailableSampleRate = new()
{
[AVCodecID.AV_CODEC_ID_AAC] = new List<int> { 44100, 48000, 96000 },
[AVCodecID.AV_CODEC_ID_OPUS] = new List<int> { 48000 }
[AVCodecID.AV_CODEC_ID_AAC] = [44100, 48000, 96000],
[AVCodecID.AV_CODEC_ID_OPUS] = [48000]
};
}
+3 -3
View File
@@ -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);
}
/// <summary>
+5 -4
View File
@@ -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
{
/// <summary>When <see cref="EffectSource.TryGet"/> finds a mapped state, uses it and returns false (Unity is skipped); otherwise returns true.</summary>
[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
{
/// <summary>When <see cref="EffectSource.TryGet"/> finds a mapped state, uses it and returns false (Unity is skipped); otherwise returns true.</summary>
[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
{
/// <summary>When <see cref="EffectSource.TryGet"/> finds a mapped state, uses it and returns false (Unity is skipped); otherwise returns true.</summary>
[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
{
/// <summary>When <see cref="EffectSource.TryGet"/> finds a mapped state, uses it and returns false (Unity is skipped); otherwise returns true.</summary>
[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;
+2 -13
View File
@@ -28,20 +28,9 @@ public static class CustomFrameRateDeferPatch
/// <summary>
/// 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.
/// </summary>
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;
/// <summary>
/// Intercepts manual camera render calls from SetCustomFrameRate (Update phase) or CheckUpdateFrameRateScreen
+3 -2
View File
@@ -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;
/// <summary>
/// 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;
+1 -1
View File
@@ -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)
+1
View File
@@ -91,6 +91,7 @@ public static class scrControllerPatch
/// <param name="__instance">The game controller.</param>
[HarmonyPostfix]
[HarmonyPatch("OnLandOnPortal")]
// ReSharper disable once InconsistentNaming
public static void PreventWinTextsPostfix(scrController __instance)
{
if (!RenderManager.IsActive || __instance == null) return;
+1
View File
@@ -41,6 +41,7 @@ public class scrFloorPatch
/// </summary>
[HarmonyPostfix]
[HarmonyPatch("Start")]
// ReSharper disable once InconsistentNaming
public static void ForceEnableOnStart(scrFloor __instance)
{
if (RenderManager.Instance &&
+1
View File
@@ -222,6 +222,7 @@ internal class CommonWarningDialogUI : MonoBehaviour
var btnRowObj = new GameObject("ButtonRow");
btnRowObj.transform.SetParent(content, false);
var btnRowRect = btnRowObj.AddComponent<RectTransform>();
// ReSharper disable once InconsistentNaming
var btnRowLE = btnRowObj.AddComponent<LayoutElement>();
btnRowLE.preferredHeight = 40f;
btnRowLE.flexibleWidth = 1f;
+6
View File
@@ -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<LayoutElement>();
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<LayoutElement>();
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<LayoutElement>();
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<LayoutElement>();
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<LayoutElement>();
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<LayoutElement>();
statusLE.preferredHeight = 22f;
statusLE.flexibleWidth = 1f;
+3 -2
View File
@@ -183,6 +183,7 @@ internal class SegmentedControl<T> : O5Object
segmentObj.transform.SetParent(maskRect, false);
var segRect = segmentObj.AddComponent<RectTransform>();
// ReSharper disable once InconsistentNaming
var segLE = segmentObj.AddComponent<LayoutElement>();
segLE.minWidth = 0f;
segLE.preferredWidth = 0f;
@@ -323,7 +324,7 @@ internal class SegmentedControl<T> : O5Object
if (EqualityComparer<T>.Default.Equals(_value, newValue)) return;
_value = newValue;
UpdateVisual(false);
UpdateVisual();
if (notify)
{
@@ -337,7 +338,7 @@ internal class SegmentedControl<T> : O5Object
if (EqualityComparer<T>.Default.Equals(_value, value)) return;
_value = value;
UpdateVisual(false);
UpdateVisual();
if (notify)
{
+2 -2
View File
@@ -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<RenderMod>.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);
-2
View File
@@ -1,5 +1,3 @@
using System;
namespace ADOFAIRenderer.Util.Audio;
/// <summary>
+1 -1
View File
@@ -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));
}
/// <summary>Opens <paramref name="path"/> with FFmpeg; mono MP3 files are wrapped in <see cref="MP3MonoLayoutReader"/> (game layout).</summary>
+1 -1
View File
@@ -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];
+1
View File
@@ -196,6 +196,7 @@ internal sealed class DecodeStream : IDisposable
}
/// <summary>Greatest common divisor of two positive integers (Euclid).</summary>
// ReSharper disable once InconsistentNaming
private static int GCD(int a, int b)
{
while (b != 0) (a, b) = (b, a % b);
+1
View File
@@ -81,6 +81,7 @@ internal sealed unsafe class FFmpegPCMReader : IPCMReader
public long Position { get; private set; }
/// <summary>True when the stream is MP3 and is decoded with the game's MP3 timing (see class summary).</summary>
// ReSharper disable once InconsistentNaming
public bool IsMP3 { get; }
/// <summary>Number of demuxer seeks performed (for diagnostics).</summary>
+1 -1
View File
@@ -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).
/// </summary>
// ReSharper disable once InconsistentNaming
internal static class MP3HeaderFrame
{
/// <summary>Bytes searched for the first frame sync after the ID3v2 tags.</summary>
+1
View File
@@ -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.
/// <see cref="TotalFrames"/> = 2 * inner TotalFrames.
/// </summary>
// ReSharper disable once InconsistentNaming
internal sealed class MP3MonoLayoutReader : IPCMReader
{
private readonly IPCMReader _inner;
+2 -2
View File
@@ -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;
}
+1 -1
View File
@@ -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);
}
+2 -3
View File
@@ -107,14 +107,13 @@ internal sealed class VideoEncoder : IEquatable<VideoEncoder>
/// (for the families the codec has); GPUUtil.GetPrioritizedEncoders keeps this order for the encoders that do not
/// belong to the active GPU vendor.
/// </summary>
public static readonly IReadOnlyList<VideoEncoder> All = new[]
{
public static readonly IReadOnlyList<VideoEncoder> 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
};
];
/// <summary>Lookup table of <see cref="All"/> by <see cref="Name"/> (case-insensitive), used by <see cref="FromName"/>.</summary>
private static readonly Dictionary<string, VideoEncoder> ByName =
-1
View File
@@ -2,7 +2,6 @@
using O5Kit.Control;
using O5Kit.Core;
using TMPro;
using UnityEngine;
namespace ADOFAIRenderer.Util.UI;