From 61bb66e2b477c50ca6416b663f29eb7dbf63ee68 Mon Sep 17 00:00:00 2001 From: Piotrekol Date: Sun, 23 Sep 2018 12:16:38 +0200 Subject: [PATCH] Add: 'mods' search modifier works just like selecting mods ingame & searching with them (only star rating is affected in search) --- App/Misc/BeatmapListFilter.cs | 3 + .../Controls/BeatmapListingPresenter.cs | 6 + CollectionManagerDll/DataTypes/Beatmap.cs | 2 +- .../CollectionManagerExtensionsDll.csproj | 1 + .../Modules/BeatmapFilter/BeatmapFilter.cs | 27 +++- .../Modules/DifficultyCalculator.cs | 122 ++++++++++++++++++ .../Controls/IBeatmapListingView.cs | 3 + .../Controls/BeatmapListingView.Designer.cs | 110 ++++++++-------- GuiComponents/Controls/BeatmapListingView.cs | 55 ++++++++ 9 files changed, 271 insertions(+), 58 deletions(-) create mode 100644 CollectionManagerExtensionsDll/Modules/DifficultyCalculator.cs diff --git a/App/Misc/BeatmapListFilter.cs b/App/Misc/BeatmapListFilter.cs index 84e5836..74535bb 100644 --- a/App/Misc/BeatmapListFilter.cs +++ b/App/Misc/BeatmapListFilter.cs @@ -2,6 +2,7 @@ using System.Windows.Forms; using BrightIdeasSoftware; using CollectionManager.DataTypes; +using CollectionManager.Enums; using CollectionManagerExtensionsDll.Modules.BeatmapFilter; namespace App.Misc @@ -9,6 +10,8 @@ namespace App.Misc public class BeatmapListFilter: IModelFilter { private readonly BeatmapFilter _beatmapFilter; + public Mods CurrentMods => _beatmapFilter.CurrentMods; + public PlayMode CurrentPlayMode => _beatmapFilter.CurrentPlayMode; private string _searchString; private readonly object _searchStringLockingObject = new object(); private Timer timer; diff --git a/App/Presenters/Controls/BeatmapListingPresenter.cs b/App/Presenters/Controls/BeatmapListingPresenter.cs index 5a16160..7ea5a78 100644 --- a/App/Presenters/Controls/BeatmapListingPresenter.cs +++ b/App/Presenters/Controls/BeatmapListingPresenter.cs @@ -1,6 +1,7 @@ using System; using CollectionManager.DataTypes; using App.Interfaces; +using App.Misc; using GuiComponents.Interfaces; namespace App.Presenters.Controls @@ -44,6 +45,11 @@ public BeatmapListingPresenter(IBeatmapListingView view, IBeatmapListingModel mo private void _model_FilteringFinished(object sender, EventArgs e) { + if (_model.GetFilter() is BeatmapListFilter filter) + { + _view.SetCurrentPlayMode(filter.CurrentPlayMode); + _view.SetCurrentMods(filter.CurrentMods); + } _view.FilteringFinished(); } diff --git a/CollectionManagerDll/DataTypes/Beatmap.cs b/CollectionManagerDll/DataTypes/Beatmap.cs index d16d5ca..02ccb22 100644 --- a/CollectionManagerDll/DataTypes/Beatmap.cs +++ b/CollectionManagerDll/DataTypes/Beatmap.cs @@ -97,7 +97,7 @@ public double Stars(PlayMode playMode, Mods mods=Mods.Omod) mods = mods & Mods.MapChanging; if (ModPpStars.ContainsKey(_playMode) && ModPpStars[_playMode].ContainsKey((int)mods)) return ModPpStars[_playMode][(int)mods]; - return 0d; + return -1d; } public double MaxBpm { get; set; } diff --git a/CollectionManagerExtensionsDll/CollectionManagerExtensionsDll.csproj b/CollectionManagerExtensionsDll/CollectionManagerExtensionsDll.csproj index e0b00aa..41f63b7 100644 --- a/CollectionManagerExtensionsDll/CollectionManagerExtensionsDll.csproj +++ b/CollectionManagerExtensionsDll/CollectionManagerExtensionsDll.csproj @@ -73,6 +73,7 @@ + Component diff --git a/CollectionManagerExtensionsDll/Modules/BeatmapFilter/BeatmapFilter.cs b/CollectionManagerExtensionsDll/Modules/BeatmapFilter/BeatmapFilter.cs index bd86b92..5b5fe4c 100644 --- a/CollectionManagerExtensionsDll/Modules/BeatmapFilter/BeatmapFilter.cs +++ b/CollectionManagerExtensionsDll/Modules/BeatmapFilter/BeatmapFilter.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Globalization; +using System.Linq; using System.Text.RegularExpressions; using CollectionManager.DataTypes; using CollectionManager.Enums; @@ -58,9 +59,17 @@ public void UpdateSearch(string searchString) { BeatmapHashHidden[beatmap.Md5] = false; } + + if (!words.Any(s => s.Contains("mods"))) + { + CurrentMods = Mods.Omod; + } + foreach (string w in words) { searchFilter filter = GetSearchFilter(w); + if(filter==null) + continue; foreach (var b in _beatmaps) { @@ -72,6 +81,10 @@ public void UpdateSearch(string searchString) } } } + + public Mods CurrentMods { get; private set; } = Mods.Omod; + public PlayMode CurrentPlayMode { get; private set; } = PlayMode.Osu; + private double GetStars(Beatmap b) => b.Stars(CurrentPlayMode, CurrentMods); /// /// Returns beatmapFilter delegate for specified searchWord. /// Unimplemented: key/keys/speed/played/unplayed @@ -96,10 +109,9 @@ private searchFilter GetSearchFilter(string searchWord) num = Double.Parse(matchNum.Groups[0].Value, nfi); switch (key) { - case "star": case "stars": - return delegate (Beatmap b) { return isPatternMatch(Math.Round(b.StarsNomod, 2), op, num); }; + return delegate (Beatmap b) { return isPatternMatch(Math.Round(GetStars(b), 2), op, num); }; case "cs": return delegate (Beatmap b) { return isPatternMatch(Math.Round((double)b.CircleSize, 1), op, num) && b.PlayMode != PlayMode.OsuMania && b.PlayMode != PlayMode.Taiko; }; @@ -131,6 +143,16 @@ private searchFilter GetSearchFilter(string searchWord) switch (key) { + case "mods": + var splitMods = Regex.Split(val, @"([A-Za-z]{2})").Where(s=>!string.IsNullOrEmpty(s)).ToList(); + Mods mods = Mods.Omod; + foreach (var mod in splitMods) + { + if (Enum.TryParse(mod, true, out Mods parsedMod)) + mods |= parsedMod; + } + CurrentMods = mods; + return null; case "artist": var artist = val.Replace(SpaceReplacement, " "); return delegate (Beatmap b) { return isArtistMatch(b, artist); }; @@ -143,6 +165,7 @@ private searchFilter GetSearchFilter(string searchWord) break; case "mode": num = descriptorToNum(val, ModePairs); + CurrentPlayMode = (PlayMode)num; return delegate (Beatmap b) { return isPatternMatch((double)b.PlayMode, op, num); }; case "status": num = descriptorToNum(val, StatusPairs); diff --git a/CollectionManagerExtensionsDll/Modules/DifficultyCalculator.cs b/CollectionManagerExtensionsDll/Modules/DifficultyCalculator.cs new file mode 100644 index 0000000..976288b --- /dev/null +++ b/CollectionManagerExtensionsDll/Modules/DifficultyCalculator.cs @@ -0,0 +1,122 @@ +using System; +using System.Collections.Generic; +using CollectionManager.DataTypes; + +namespace CollectionManagerExtensionsDll.Modules +{ + public class DifficultyCalculator + { + public class DifficultyCalculatorResult + { + public float Od { get; set; } + public float Ar { get; set; } + public float Cs { get; set; } + public float Hp { get; set; } + public double MinBpm { get; set; } + public double MaxBpm { get; set; } + } + readonly float od0_ms = 79.5f, + od10_ms = 19.5f, + ar0_ms = 1800f, + ar5_ms = 1200f, + ar10_ms = 450f; + + readonly float od_ms_step = 6, + ar_ms_step1 = 120, // ar0-5 + ar_ms_step2 = 150; // ar5-10 + + public DifficultyCalculatorResult ApplyMods(Beatmap map, Mods mods, DifficultyCalculatorResult result=null) + { + if(result==null) + result = new DifficultyCalculatorResult(); + + result.Od = map.OverallDifficulty; + result.Ar = map.ApproachRate; + result.Cs = map.CircleSize; + result.Hp = map.HpDrainRate; + result.MinBpm = map.MinBpm; + result.MaxBpm = map.MaxBpm; + + if ((mods & Mods.MapChanging) == 0) + { + return result; + } + + float speed = 1; + if ((mods & Mods.Dt) != 0 || (mods & Mods.Nc) != 0) + speed *= 1.5f; + if ((mods & Mods.Ht) != 0) + speed *= 0.75f; + + float od_multiplier = 1; + if ((mods & Mods.Hr) != 0) + od_multiplier *= 1.4f; + if ((mods & Mods.Ez) != 0) + od_multiplier *= 0.5f; + + result.Od *= od_multiplier; + float odms = od0_ms - (float)Math.Ceiling(od_ms_step * result.Od); + //hp + if ((mods & Mods.Ez) != 0) + result.Hp *= 0.5f; + else if ((mods & Mods.Hr) != 0) + result.Hp *= 1.4f; + + //bpm + double modifier = 1; + if ((mods & Mods.Dt) != 0) + { + modifier *= 1.5; + } + else if ((mods & Mods.Ht) != 0) + { + modifier *= 0.75; + } + + result.MinBpm *= modifier; + result.MaxBpm *= modifier; + + //ar + float ar_multiplier = 1; + + if ((mods & Mods.Hr) != 0) + ar_multiplier *= 1.4f; + if ((mods & Mods.Ez) != 0) + ar_multiplier *= 0.5f; + + result.Ar *= ar_multiplier; + float arms = result.Ar <= 5 + ? (ar0_ms - ar_ms_step1 * result.Ar) + : (ar5_ms - ar_ms_step2 * (result.Ar - 5)); + + //cs + float cs_multiplier = 1; + if ((mods & Mods.Hr) != 0) + cs_multiplier *= 1.3f; + if ((mods & Mods.Ez) != 0) + cs_multiplier *= 0.5f; + + // stats must be capped to 0-10 before HT/DT which bring them to a range + // of -4.42 to 11.08 for OD and -5 to 11 for AR + odms = Math.Min(od0_ms, Math.Max(od10_ms, odms)); + arms = Math.Min(ar0_ms, Math.Max(ar10_ms, arms)); + + // apply speed-changing mods + odms /= speed; + arms /= speed; + + // convert OD and AR back into their stat form + //od = (-(odms - od0_ms)) / od_ms_step; + result.Od = (od0_ms - odms) / od_ms_step; + result.Ar = result.Ar <= 5.0f + ? ((ar0_ms - arms) / ar_ms_step1) + : (5.0f + (ar5_ms - arms) / ar_ms_step2); + + result.Cs *= cs_multiplier; + result.Cs = Math.Max(0.0f, Math.Min(10.0f, result.Cs)); + + return result; + } + + } +} \ No newline at end of file diff --git a/Common/Interfaces/Controls/IBeatmapListingView.cs b/Common/Interfaces/Controls/IBeatmapListingView.cs index 61dab88..58bb16e 100644 --- a/Common/Interfaces/Controls/IBeatmapListingView.cs +++ b/Common/Interfaces/Controls/IBeatmapListingView.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using BrightIdeasSoftware; using CollectionManager.DataTypes; +using CollectionManager.Enums; using Gui.Misc; namespace GuiComponents.Interfaces @@ -20,6 +21,8 @@ public interface IBeatmapListingView event GuiHelpers.BeatmapListingActionArgs BeatmapOperation; event GuiHelpers.BeatmapsEventArgs BeatmapsDropped; + void SetCurrentPlayMode(PlayMode playMode); + void SetCurrentMods(Mods mods); void SetBeatmaps(IEnumerable beatmaps); void SetFilter(IModelFilter filter); void FilteringStarted(); diff --git a/GuiComponents/Controls/BeatmapListingView.Designer.cs b/GuiComponents/Controls/BeatmapListingView.Designer.cs index 6d3b278..fe03bc0 100644 --- a/GuiComponents/Controls/BeatmapListingView.Designer.cs +++ b/GuiComponents/Controls/BeatmapListingView.Designer.cs @@ -50,12 +50,12 @@ private void InitializeComponent() this.ListViewBeatmaps = new BrightIdeasSoftware.FastDataListView(); this.olvColumn2 = ((BrightIdeasSoftware.OLVColumn)(new BrightIdeasSoftware.OLVColumn())); this.olvColumn4 = ((BrightIdeasSoftware.OLVColumn)(new BrightIdeasSoftware.OLVColumn())); - this.olvColumn1 = ((BrightIdeasSoftware.OLVColumn)(new BrightIdeasSoftware.OLVColumn())); - this.olvColumn6 = ((BrightIdeasSoftware.OLVColumn)(new BrightIdeasSoftware.OLVColumn())); - this.olvColumn7 = ((BrightIdeasSoftware.OLVColumn)(new BrightIdeasSoftware.OLVColumn())); + this.column_stars = ((BrightIdeasSoftware.OLVColumn)(new BrightIdeasSoftware.OLVColumn())); + this.column_ar = ((BrightIdeasSoftware.OLVColumn)(new BrightIdeasSoftware.OLVColumn())); + this.column_cs = ((BrightIdeasSoftware.OLVColumn)(new BrightIdeasSoftware.OLVColumn())); this.olvColumn5 = ((BrightIdeasSoftware.OLVColumn)(new BrightIdeasSoftware.OLVColumn())); - this.olvColumn8 = ((BrightIdeasSoftware.OLVColumn)(new BrightIdeasSoftware.OLVColumn())); - this.olvColumn9 = ((BrightIdeasSoftware.OLVColumn)(new BrightIdeasSoftware.OLVColumn())); + this.column_hp = ((BrightIdeasSoftware.OLVColumn)(new BrightIdeasSoftware.OLVColumn())); + this.column_od = ((BrightIdeasSoftware.OLVColumn)(new BrightIdeasSoftware.OLVColumn())); this.olvColumn3 = ((BrightIdeasSoftware.OLVColumn)(new BrightIdeasSoftware.OLVColumn())); this.olvColumn10 = ((BrightIdeasSoftware.OLVColumn)(new BrightIdeasSoftware.OLVColumn())); this.LastPlayed = ((BrightIdeasSoftware.OLVColumn)(new BrightIdeasSoftware.OLVColumn())); @@ -101,7 +101,7 @@ private void InitializeComponent() this.searchToolStripMenuItem, this.copyToolStripMenuItem}); this.BeatmapsContextMenuStrip.Name = "CollectionContextMenuStrip"; - this.BeatmapsContextMenuStrip.Size = new System.Drawing.Size(153, 114); + this.BeatmapsContextMenuStrip.Size = new System.Drawing.Size(132, 92); // // OpenDlMapMenuStrip // @@ -110,7 +110,7 @@ private void InitializeComponent() this.OpenBeatmapDownloadMapMenuStrip, this.OpenBeatmapFolderMenuStrip}); this.OpenDlMapMenuStrip.Name = "OpenDlMapMenuStrip"; - this.OpenDlMapMenuStrip.Size = new System.Drawing.Size(152, 22); + this.OpenDlMapMenuStrip.Size = new System.Drawing.Size(131, 22); this.OpenDlMapMenuStrip.Text = "Open"; // // OpenBeatmapPageMapMenuStrip @@ -155,7 +155,7 @@ private void InitializeComponent() this.DeleteMapMenuStrip.Enabled = false; this.DeleteMapMenuStrip.Name = "DeleteMapMenuStrip"; this.DeleteMapMenuStrip.ShortcutKeys = System.Windows.Forms.Keys.Delete; - this.DeleteMapMenuStrip.Size = new System.Drawing.Size(152, 22); + this.DeleteMapMenuStrip.Size = new System.Drawing.Size(131, 22); this.DeleteMapMenuStrip.Text = "Delete"; this.DeleteMapMenuStrip.Click += new System.EventHandler(this.MenuStripClick); // @@ -167,7 +167,7 @@ private void InitializeComponent() this.SearchTitleMapMenuStrip}); this.searchToolStripMenuItem.Enabled = false; this.searchToolStripMenuItem.Name = "searchToolStripMenuItem"; - this.searchToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.searchToolStripMenuItem.Size = new System.Drawing.Size(131, 22); this.searchToolStripMenuItem.Text = "Search"; // // SearchMapsetMapMenuStrip @@ -194,20 +194,20 @@ private void InitializeComponent() this.copyUrlMenuStrip, this.copyAsTextMenuStrip}); this.copyToolStripMenuItem.Name = "copyToolStripMenuItem"; - this.copyToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.copyToolStripMenuItem.Size = new System.Drawing.Size(131, 22); this.copyToolStripMenuItem.Text = "Copy"; // // copyUrlMenuStrip // this.copyUrlMenuStrip.Name = "copyUrlMenuStrip"; - this.copyUrlMenuStrip.Size = new System.Drawing.Size(152, 22); + this.copyUrlMenuStrip.Size = new System.Drawing.Size(109, 22); this.copyUrlMenuStrip.Text = "url(s)"; this.copyUrlMenuStrip.Click += new System.EventHandler(this.MenuStripClick); // // copyAsTextMenuStrip // this.copyAsTextMenuStrip.Name = "copyAsTextMenuStrip"; - this.copyAsTextMenuStrip.Size = new System.Drawing.Size(152, 22); + this.copyAsTextMenuStrip.Size = new System.Drawing.Size(109, 22); this.copyAsTextMenuStrip.Text = "As text"; this.copyAsTextMenuStrip.Click += new System.EventHandler(this.MenuStripClick); // @@ -215,12 +215,12 @@ private void InitializeComponent() // this.ListViewBeatmaps.AllColumns.Add(this.olvColumn2); this.ListViewBeatmaps.AllColumns.Add(this.olvColumn4); - this.ListViewBeatmaps.AllColumns.Add(this.olvColumn1); - this.ListViewBeatmaps.AllColumns.Add(this.olvColumn6); - this.ListViewBeatmaps.AllColumns.Add(this.olvColumn7); + this.ListViewBeatmaps.AllColumns.Add(this.column_stars); + this.ListViewBeatmaps.AllColumns.Add(this.column_ar); + this.ListViewBeatmaps.AllColumns.Add(this.column_cs); this.ListViewBeatmaps.AllColumns.Add(this.olvColumn5); - this.ListViewBeatmaps.AllColumns.Add(this.olvColumn8); - this.ListViewBeatmaps.AllColumns.Add(this.olvColumn9); + this.ListViewBeatmaps.AllColumns.Add(this.column_hp); + this.ListViewBeatmaps.AllColumns.Add(this.column_od); this.ListViewBeatmaps.AllColumns.Add(this.olvColumn3); this.ListViewBeatmaps.AllColumns.Add(this.olvColumn10); this.ListViewBeatmaps.AllColumns.Add(this.LastPlayed); @@ -233,9 +233,9 @@ private void InitializeComponent() this.ListViewBeatmaps.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.olvColumn2, this.olvColumn4, - this.olvColumn1, - this.olvColumn6, - this.olvColumn7, + this.column_stars, + this.column_ar, + this.column_cs, this.olvColumn5, this.olvColumn3, this.olvColumn10, @@ -273,27 +273,27 @@ private void InitializeComponent() this.olvColumn4.TextCopyFormat = "[{0}]"; this.olvColumn4.Width = 100; // - // olvColumn1 + // column_stars // - this.olvColumn1.AspectName = "StarsNomod"; - this.olvColumn1.IsEditable = false; - this.olvColumn1.Text = "★"; - this.olvColumn1.TextCopyFormat = "{0}★"; - this.olvColumn1.Width = 30; + this.column_stars.AspectName = "StarsNomod"; + this.column_stars.IsEditable = false; + this.column_stars.Text = "★"; + this.column_stars.TextCopyFormat = "{0}★"; + this.column_stars.Width = 30; // - // olvColumn6 + // column_ar // - this.olvColumn6.AspectName = "ApproachRate"; - this.olvColumn6.IsEditable = false; - this.olvColumn6.Text = "AR"; - this.olvColumn6.Width = 30; + this.column_ar.AspectName = "ApproachRate"; + this.column_ar.IsEditable = false; + this.column_ar.Text = "AR"; + this.column_ar.Width = 30; // - // olvColumn7 + // column_cs // - this.olvColumn7.AspectName = "CircleSize"; - this.olvColumn7.IsEditable = false; - this.olvColumn7.Text = "CS"; - this.olvColumn7.Width = 30; + this.column_cs.AspectName = "CircleSize"; + this.column_cs.IsEditable = false; + this.column_cs.Text = "CS"; + this.column_cs.Width = 30; // // olvColumn5 // @@ -301,23 +301,23 @@ private void InitializeComponent() this.olvColumn5.IsEditable = false; this.olvColumn5.Text = "State"; // - // olvColumn8 + // column_hp // - this.olvColumn8.AspectName = "HpDrainRate"; - this.olvColumn8.DisplayIndex = 8; - this.olvColumn8.IsEditable = false; - this.olvColumn8.IsVisible = false; - this.olvColumn8.Text = "HP"; - this.olvColumn8.Width = 30; + this.column_hp.AspectName = "HpDrainRate"; + this.column_hp.DisplayIndex = 8; + this.column_hp.IsEditable = false; + this.column_hp.IsVisible = false; + this.column_hp.Text = "HP"; + this.column_hp.Width = 30; // - // olvColumn9 + // column_od // - this.olvColumn9.AspectName = "OverallDifficulty"; - this.olvColumn9.DisplayIndex = 9; - this.olvColumn9.IsEditable = false; - this.olvColumn9.IsVisible = false; - this.olvColumn9.Text = "OD"; - this.olvColumn9.Width = 30; + this.column_od.AspectName = "OverallDifficulty"; + this.column_od.DisplayIndex = 9; + this.column_od.IsEditable = false; + this.column_od.IsVisible = false; + this.column_od.Text = "OD"; + this.column_od.Width = 30; // // olvColumn3 // @@ -379,12 +379,12 @@ private void InitializeComponent() public BrightIdeasSoftware.FastDataListView ListViewBeatmaps; private BrightIdeasSoftware.OLVColumn olvColumn2; private BrightIdeasSoftware.OLVColumn olvColumn4; - private BrightIdeasSoftware.OLVColumn olvColumn1; + private BrightIdeasSoftware.OLVColumn column_stars; private BrightIdeasSoftware.OLVColumn olvColumn5; - private BrightIdeasSoftware.OLVColumn olvColumn6; - private BrightIdeasSoftware.OLVColumn olvColumn7; - private BrightIdeasSoftware.OLVColumn olvColumn8; - private BrightIdeasSoftware.OLVColumn olvColumn9; + private BrightIdeasSoftware.OLVColumn column_ar; + private BrightIdeasSoftware.OLVColumn column_cs; + private BrightIdeasSoftware.OLVColumn column_hp; + private BrightIdeasSoftware.OLVColumn column_od; public System.Windows.Forms.Label label_resultsCount; private System.Windows.Forms.Label label1; public System.Windows.Forms.TextBox textBox_beatmapSearch; diff --git a/GuiComponents/Controls/BeatmapListingView.cs b/GuiComponents/Controls/BeatmapListingView.cs index ad92728..4a8e444 100644 --- a/GuiComponents/Controls/BeatmapListingView.cs +++ b/GuiComponents/Controls/BeatmapListingView.cs @@ -6,6 +6,8 @@ using System.Windows.Forms; using BrightIdeasSoftware; using CollectionManager.DataTypes; +using CollectionManager.Enums; +using CollectionManagerExtensionsDll.Modules; using Common; using GuiComponents.Interfaces; using Gui.Misc; @@ -37,6 +39,14 @@ public bool AllowForDeletion } } + public void SetCurrentPlayMode(PlayMode playMode) + { + _currentPlayMode = playMode; + } + public void SetCurrentMods(Mods mods) + { + _currentMods = mods; + } public void SetBeatmaps(IEnumerable beatmaps) { @@ -91,6 +101,9 @@ private void UpdateResultsCount() label_resultsCount.Text = string.Format("{0} {1}", count, count == 1 ? "map" : "maps"); } public static DateTime d = new DateTime(2006, 1, 1); + private Mods _currentMods = Mods.Omod; + private PlayMode _currentPlayMode = PlayMode.Osu; + private DifficultyCalculator _difficultyCalculator = new DifficultyCalculator(); private void InitListView() { //listview @@ -103,6 +116,48 @@ private void InitListView() ListViewBeatmaps.UseNotifyPropertyChanged = true; ListViewBeatmaps.ShowItemCountOnGroups = true; ListViewBeatmaps.CellEditActivation = ObjectListView.CellEditActivateMode.DoubleClick; + + column_stars.AspectGetter = rowObject => + { + if (rowObject is Beatmap beatmap) + { + return beatmap.Stars(_currentPlayMode, _currentMods); + } + return null; + }; + + column_ar.AspectGetter = rowObject => + { + if (rowObject is Beatmap beatmap) + { + return _difficultyCalculator.ApplyMods(beatmap, _currentMods).Ar; + } + return null; + }; + column_od.AspectGetter = rowObject => + { + if (rowObject is Beatmap beatmap) + { + return _difficultyCalculator.ApplyMods(beatmap, _currentMods).Od; + } + return null; + }; + column_cs.AspectGetter = rowObject => + { + if (rowObject is Beatmap beatmap) + { + return _difficultyCalculator.ApplyMods(beatmap, _currentMods).Cs; + } + return null; + }; + column_hp.AspectGetter = rowObject => + { + if (rowObject is Beatmap beatmap) + { + return _difficultyCalculator.ApplyMods(beatmap, _currentMods).Hp; + } + return null; + }; LastPlayed.AspectToStringConverter = delegate (object cellValue) { if (cellValue == null) return "Never";