From 22987ba7f10f933fbb8584b1db1aa7a5cc2ca108 Mon Sep 17 00:00:00 2001 From: Milkitic Date: Sun, 24 Dec 2023 17:42:18 +0800 Subject: [PATCH] Clean code --- KeyAsio.MemoryReading/Mods.cs | 1 + KeyAsio.Shared/AssemblyInfo.cs | 3 +++ KeyAsio.Shared/Realtime/RealtimeModeManager.cs | 8 +++----- KeyAsio.Shared/Realtime/SkinManager.cs | 6 ++---- .../Charts/PlayTimeChart.xaml.cs | 15 +-------------- 5 files changed, 10 insertions(+), 23 deletions(-) create mode 100644 KeyAsio.Shared/AssemblyInfo.cs diff --git a/KeyAsio.MemoryReading/Mods.cs b/KeyAsio.MemoryReading/Mods.cs index cc0d289..84e9409 100644 --- a/KeyAsio.MemoryReading/Mods.cs +++ b/KeyAsio.MemoryReading/Mods.cs @@ -1,4 +1,5 @@ namespace KeyAsio.MemoryReading; + [Flags] public enum Mods : uint { diff --git a/KeyAsio.Shared/AssemblyInfo.cs b/KeyAsio.Shared/AssemblyInfo.cs new file mode 100644 index 0000000..abc526f --- /dev/null +++ b/KeyAsio.Shared/AssemblyInfo.cs @@ -0,0 +1,3 @@ +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("ColumnTest")] \ No newline at end of file diff --git a/KeyAsio.Shared/Realtime/RealtimeModeManager.cs b/KeyAsio.Shared/Realtime/RealtimeModeManager.cs index 9cd4926..a9998bc 100644 --- a/KeyAsio.Shared/Realtime/RealtimeModeManager.cs +++ b/KeyAsio.Shared/Realtime/RealtimeModeManager.cs @@ -25,7 +25,7 @@ namespace KeyAsio.Shared.Realtime; public class RealtimeModeManager : ViewModelBase { - private static readonly string[] SkinAudioFiles = { "combobreak" }; + private static readonly string[] SkinAudioFiles = ["combobreak"]; public static RealtimeModeManager Instance { get; } = new(); private static readonly ILogger Logger = LogUtils.GetLogger(nameof(RealtimeModeManager)); @@ -183,7 +183,7 @@ public OsuMemoryStatus OsuStatus } } - public OsuFile? OsuFile { get; /*private*/ set; } + public OsuFile? OsuFile { get; internal set; } public string? AudioFilename { get; set; } @@ -205,8 +205,6 @@ public bool IsStarted set { lock (_isStartedLock) { SetField(ref _isStarted, value); } } } - //public OsuListenerManager? OsuListenerManager { get; set; } - public AppSettings AppSettings => ConfigurationFactory.GetConfiguration(); public IReadOnlyList PlaybackList => _playbackList; @@ -667,7 +665,7 @@ private void OnBeatmapChanged(BeatmapIdentifier beatmap) if (OsuStatus is OsuMemoryStatus.SongSelect or OsuMemoryStatus.SongSelectEdit or OsuMemoryStatus.MainMenu && beatmap != default) { - var coosu = OsuFile.ReadFromFile(Beatmap.FilenameFull, k => + var coosu = OsuFile.ReadFromFile(beatmap.FilenameFull, k => { k.IncludeSection("General"); k.IncludeSection("Metadata"); diff --git a/KeyAsio.Shared/Realtime/SkinManager.cs b/KeyAsio.Shared/Realtime/SkinManager.cs index 28dd6d6..26e0858 100644 --- a/KeyAsio.Shared/Realtime/SkinManager.cs +++ b/KeyAsio.Shared/Realtime/SkinManager.cs @@ -24,7 +24,6 @@ private SkinManager() public SharedViewModel SharedViewModel => SharedViewModel.Instance; public AppSettings AppSettings => ConfigurationFactory.GetConfiguration(); - //public OsuListenerManager? OsuListenerManager => RealtimeModeManager.Instance.OsuListenerManager; public void ListenPropertyChanging() { @@ -48,9 +47,8 @@ public void ListenPropertyChanging() public void ListenToProcess() { - var manager = MemoryScan.MemoryReadObject; - if (manager == null) return; - manager.OsuStatusChanged += (pre, current) => + var memoryReadObject = MemoryScan.MemoryReadObject; + memoryReadObject.OsuStatusChanged += (pre, current) => { if (current is OsuMemoryStatus.NotRunning or OsuMemoryStatus.Unknown) { diff --git a/Tests/MemoryReadingTest/Charts/PlayTimeChart.xaml.cs b/Tests/MemoryReadingTest/Charts/PlayTimeChart.xaml.cs index d2702b9..39f765c 100644 --- a/Tests/MemoryReadingTest/Charts/PlayTimeChart.xaml.cs +++ b/Tests/MemoryReadingTest/Charts/PlayTimeChart.xaml.cs @@ -1,18 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; +using System.Collections.ObjectModel; using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; using KeyAsio.MemoryReading; using KeyAsio.Shared.Models; using LiveChartsCore;