diff --git a/OsuHelper/Services/BeatmapProcessorService.cs b/OsuHelper/Services/BeatmapProcessorService.cs index b8da3c4..7f007d6 100644 --- a/OsuHelper/Services/BeatmapProcessorService.cs +++ b/OsuHelper/Services/BeatmapProcessorService.cs @@ -32,7 +32,7 @@ private double TimeToOverallDifficulty(TimeSpan time) return (78 - ms) / 6; } - public BeatmapTraits CalculateTraitsWithMods(Beatmap beatmap, Mods mods) + public BeatmapTraits CalculateBeatmapTraitsWithMods(Beatmap beatmap, Mods mods) { // No mods - just return base traits if (mods == Mods.None) @@ -44,19 +44,19 @@ public BeatmapTraits CalculateTraitsWithMods(Beatmap beatmap, Mods mods) // Carry over unchanged traits var maxCombo = beatmap.Traits.MaxCombo; - var duration = beatmap.Traits.Duration; - var tempo = beatmap.Traits.Tempo; var sr = beatmap.Traits.StarRating; // can't calculate this // Calculate duration and tempo + var duration = beatmap.Traits.Duration; + var tempo = beatmap.Traits.Tempo; if (mods.HasFlag(Mods.DoubleTime)) { - duration = beatmap.Traits.Duration.Multiply(1 / 1.5); + duration = beatmap.Traits.Duration.Divide(1.5); tempo = beatmap.Traits.Tempo * 1.5; } else if (mods.HasFlag(Mods.HalfTime)) { - duration = beatmap.Traits.Duration.Multiply(1 / 0.75); + duration = beatmap.Traits.Duration.Divide(0.75); tempo = beatmap.Traits.Tempo * 0.75; } @@ -75,13 +75,13 @@ public BeatmapTraits CalculateTraitsWithMods(Beatmap beatmap, Mods mods) } if (mods.HasFlag(Mods.DoubleTime)) { - ar = TimeToApproachRate(ApproachRateToTime(ar).Multiply(1 / 1.5)); - od = TimeToOverallDifficulty(OverallDifficultyToTime(od).Multiply(1 / 1.5)); + ar = TimeToApproachRate(ApproachRateToTime(ar).Divide(1.5)); + od = TimeToOverallDifficulty(OverallDifficultyToTime(od).Divide(1.5)); } else if (mods.HasFlag(Mods.HalfTime)) { - ar = TimeToApproachRate(ApproachRateToTime(ar).Multiply(1 / 0.75)); - od = TimeToOverallDifficulty(OverallDifficultyToTime(od).Multiply(1 / 0.75)); + ar = TimeToApproachRate(ApproachRateToTime(ar).Divide(0.75)); + od = TimeToOverallDifficulty(OverallDifficultyToTime(od).Divide(0.75)); } // Calculate CS and HP diff --git a/OsuHelper/Services/DataService.cs b/OsuHelper/Services/DataService.cs index 8e26025..467d35f 100644 --- a/OsuHelper/Services/DataService.cs +++ b/OsuHelper/Services/DataService.cs @@ -159,7 +159,7 @@ public async Task GetBeatmapRawAsync(string beatmapId) return response; } - public async Task GetMapSetPreviewAsync(string mapSetId) + public async Task GetBeatmapSetPreviewAsync(string mapSetId) { // Try get from cache first var cached = _cacheService.RetrieveOrDefault($"BeatmapPreview-{mapSetId}"); diff --git a/OsuHelper/Services/IBeatmapProcessorService.cs b/OsuHelper/Services/IBeatmapProcessorService.cs index e68e0d9..b631de6 100644 --- a/OsuHelper/Services/IBeatmapProcessorService.cs +++ b/OsuHelper/Services/IBeatmapProcessorService.cs @@ -4,6 +4,6 @@ namespace OsuHelper.Services { public interface IBeatmapProcessorService { - BeatmapTraits CalculateTraitsWithMods(Beatmap beatmap, Mods mods); + BeatmapTraits CalculateBeatmapTraitsWithMods(Beatmap beatmap, Mods mods); } } \ No newline at end of file diff --git a/OsuHelper/Services/IDataService.cs b/OsuHelper/Services/IDataService.cs index e80c392..18d26f7 100644 --- a/OsuHelper/Services/IDataService.cs +++ b/OsuHelper/Services/IDataService.cs @@ -11,7 +11,7 @@ public interface IDataService Task GetBeatmapRawAsync(string beatmapId); - Task GetMapSetPreviewAsync(string mapSetId); + Task GetBeatmapSetPreviewAsync(string mapSetId); Task> GetUserTopPlaysAsync(string userId, GameMode gameMode); diff --git a/OsuHelper/Services/IRecommendationService.cs b/OsuHelper/Services/IRecommendationService.cs index 1f42a83..d2c2821 100644 --- a/OsuHelper/Services/IRecommendationService.cs +++ b/OsuHelper/Services/IRecommendationService.cs @@ -7,6 +7,6 @@ namespace OsuHelper.Services { public interface IRecommendationService { - Task> GetRecommendationsAsync(IProgress progress); + Task> GetRecommendationsAsync(IProgress progressHandler); } } \ No newline at end of file diff --git a/OsuHelper/Services/RecommendationService.cs b/OsuHelper/Services/RecommendationService.cs index f8b0f4e..ef306b7 100644 --- a/OsuHelper/Services/RecommendationService.cs +++ b/OsuHelper/Services/RecommendationService.cs @@ -107,7 +107,7 @@ await candidatePlaysGroups.ParallelForEachAsync(async group => var beatmap = await _dataService.GetBeatmapAsync(play.BeatmapId, GameMode); // Calculate traits with mods - var traitsWithMods = _beatmapProcessorService.CalculateTraitsWithMods(beatmap, play.Mods); + var traitsWithMods = _beatmapProcessorService.CalculateBeatmapTraitsWithMods(beatmap, play.Mods); // Add recommendation to the list var recommendation = new Recommendation(beatmap, count, play.Mods, traitsWithMods, play.Accuracy, diff --git a/OsuHelper/ViewModels/BeatmapDetailsViewModel.cs b/OsuHelper/ViewModels/BeatmapDetailsViewModel.cs index b51374e..b45fd77 100644 --- a/OsuHelper/ViewModels/BeatmapDetailsViewModel.cs +++ b/OsuHelper/ViewModels/BeatmapDetailsViewModel.cs @@ -1,5 +1,4 @@ -using System; -using System.Diagnostics; +using System.Diagnostics; using System.Net; using GalaSoft.MvvmLight; using GalaSoft.MvvmLight.CommandWpf; @@ -50,6 +49,7 @@ public BeatmapDetailsViewModel(ISettingsService settingsService, IDataService da _dataService = dataService; _audioService = audioService; + // Commands OpenPageCommand = new RelayCommand(OpenPage); DownloadCommand = new RelayCommand(Download); DownloadDirectCommand = new RelayCommand(DownloadDirect); @@ -58,6 +58,7 @@ public BeatmapDetailsViewModel(ISettingsService settingsService, IDataService da StopPreviewCommand = new RelayCommand(StopPreview, () => IsPreviewPlaying); TogglePreviewCommand = new RelayCommand(TogglePreview); + // Messages MessengerInstance.Register(this, m => { Beatmap = m.Beatmap; @@ -92,7 +93,7 @@ private async void PlayPreview() try { - using (var stream = await _dataService.GetMapSetPreviewAsync(Beatmap.MapSetId)) + using (var stream = await _dataService.GetBeatmapSetPreviewAsync(Beatmap.MapSetId)) await _audioService.PlayAsync(stream); } catch (HttpErrorStatusCodeException ex) when (ex.StatusCode == HttpStatusCode.Forbidden) diff --git a/OsuHelper/ViewModels/NotificationViewModel.cs b/OsuHelper/ViewModels/NotificationViewModel.cs index 5b5a3ec..1fd69a3 100644 --- a/OsuHelper/ViewModels/NotificationViewModel.cs +++ b/OsuHelper/ViewModels/NotificationViewModel.cs @@ -22,6 +22,7 @@ public string Content public NotificationViewModel() { + // Messages MessengerInstance.Register(this, m => { Title = m.Title;