diff --git a/osu.Game/Beatmaps/BeatmapInfo.cs b/osu.Game/Beatmaps/BeatmapInfo.cs index 0534fd9253..6ad5b2070e 100644 --- a/osu.Game/Beatmaps/BeatmapInfo.cs +++ b/osu.Game/Beatmaps/BeatmapInfo.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Linq; @@ -9,6 +10,7 @@ using Newtonsoft.Json; using osu.Game.Database; using osu.Game.IO.Serialization; using osu.Game.Rulesets; +using osu.Game.Scoring; namespace osu.Game.Beatmaps { @@ -112,6 +114,11 @@ namespace osu.Game.Beatmaps [JsonProperty("difficulty_rating")] public double StarDifficulty { get; set; } + /// + /// Currently only populated for beatmap deletion. Use to query scores. + /// + public List Scores { get; set; } + public override string ToString() => $"{Metadata} [{Version}]"; public bool Equals(BeatmapInfo other) diff --git a/osu.Game/Beatmaps/BeatmapStore.cs b/osu.Game/Beatmaps/BeatmapStore.cs index 5bdc42cdf3..6817c0653d 100644 --- a/osu.Game/Beatmaps/BeatmapStore.cs +++ b/osu.Game/Beatmaps/BeatmapStore.cs @@ -64,7 +64,8 @@ namespace osu.Game.Beatmaps base.AddIncludesForDeletion(query) .Include(s => s.Beatmaps).ThenInclude(b => b.Metadata) .Include(s => s.Beatmaps).ThenInclude(b => b.BaseDifficulty) - .Include(s => s.Metadata); + .Include(s => s.Metadata) + .Include(s => s.Beatmaps).ThenInclude(b => b.Scores); protected override IQueryable AddIncludesForConsumption(IQueryable query) => base.AddIncludesForConsumption(query) diff --git a/osu.Game/Graphics/UserInterface/OsuSliderBar.cs b/osu.Game/Graphics/UserInterface/OsuSliderBar.cs index 10b83c2610..2bd84ab2b4 100644 --- a/osu.Game/Graphics/UserInterface/OsuSliderBar.cs +++ b/osu.Game/Graphics/UserInterface/OsuSliderBar.cs @@ -8,7 +8,6 @@ using osuTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; -using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.Cursor; @@ -33,38 +32,7 @@ namespace osu.Game.Graphics.UserInterface private readonly Box leftBox; private readonly Box rightBox; - public virtual string TooltipText - { - get - { - var bindableDouble = CurrentNumber as BindableNumber; - var bindableFloat = CurrentNumber as BindableNumber; - var floatValue = bindableDouble?.Value ?? bindableFloat?.Value; - var floatPrecision = bindableDouble?.Precision ?? bindableFloat?.Precision; - - if (floatValue != null) - { - var floatMinValue = bindableDouble?.MinValue ?? bindableFloat.MinValue; - var floatMaxValue = bindableDouble?.MaxValue ?? bindableFloat.MaxValue; - - if (floatMaxValue == 1 && floatMinValue >= -1) - return floatValue.Value.ToString("P0"); - - var decimalPrecision = normalise((decimal)floatPrecision, max_decimal_digits); - - // Find the number of significant digits (we could have less than 5 after normalize()) - var significantDigits = findPrecision(decimalPrecision); - - return floatValue.Value.ToString($"N{significantDigits}"); - } - - var bindableInt = CurrentNumber as BindableNumber; - if (bindableInt != null) - return bindableInt.Value.ToString("N0"); - - return Current.Value.ToString(CultureInfo.InvariantCulture); - } - } + public virtual string TooltipText { get; private set; } private Color4 accentColour; public Color4 AccentColour @@ -136,21 +104,34 @@ namespace osu.Game.Graphics.UserInterface base.OnHoverLost(e); } - protected override void OnUserChange() + protected override bool OnMouseDown(MouseDownEvent e) { - base.OnUserChange(); - playSample(); + Nub.Current.Value = true; + return base.OnMouseDown(e); } - private void playSample() + protected override bool OnMouseUp(MouseUpEvent e) + { + Nub.Current.Value = false; + return base.OnMouseUp(e); + } + + protected override void OnUserChange(T value) + { + base.OnUserChange(value); + playSample(value); + updateTooltipText(value); + } + + private void playSample(T value) { if (Clock == null || Clock.CurrentTime - lastSampleTime <= 50) return; - if (Current.Value.Equals(lastSampleValue)) + if (value.Equals(lastSampleValue)) return; - lastSampleValue = Current.Value; + lastSampleValue = value; lastSampleTime = Clock.CurrentTime; sample.Frequency.Value = 1 + NormalizedValue * 0.2f; @@ -163,16 +144,28 @@ namespace osu.Game.Graphics.UserInterface sample.Play(); } - protected override bool OnMouseDown(MouseDownEvent e) + private void updateTooltipText(T value) { - Nub.Current.Value = true; - return base.OnMouseDown(e); - } + if (CurrentNumber.IsInteger) + TooltipText = ((int)Convert.ChangeType(value, typeof(int))).ToString("N0"); + else + { + double floatValue = (double)Convert.ChangeType(value, typeof(double)); + double floatMinValue = (double)Convert.ChangeType(CurrentNumber.MinValue, typeof(double)); + double floatMaxValue = (double)Convert.ChangeType(CurrentNumber.MaxValue, typeof(double)); - protected override bool OnMouseUp(MouseUpEvent e) - { - Nub.Current.Value = false; - return base.OnMouseUp(e); + if (floatMaxValue == 1 && floatMinValue >= -1) + TooltipText = floatValue.ToString("P0"); + else + { + var decimalPrecision = normalise((decimal)Convert.ChangeType(CurrentNumber.Precision, typeof(decimal)), max_decimal_digits); + + // Find the number of significant digits (we could have less than 5 after normalize()) + var significantDigits = findPrecision(decimalPrecision); + + TooltipText = floatValue.ToString($"N{significantDigits}"); + } + } } protected override void UpdateAfterChildren() diff --git a/osu.Game/Graphics/UserInterface/ProgressBar.cs b/osu.Game/Graphics/UserInterface/ProgressBar.cs index ee64c7c25c..6dca58f70d 100644 --- a/osu.Game/Graphics/UserInterface/ProgressBar.cs +++ b/osu.Game/Graphics/UserInterface/ProgressBar.cs @@ -62,6 +62,6 @@ namespace osu.Game.Graphics.UserInterface fill.Width = value * UsableWidth; } - protected override void OnUserChange() => OnSeek?.Invoke(Current); + protected override void OnUserChange(double value) => OnSeek?.Invoke(value); } } diff --git a/osu.Game/Migrations/OsuDbContextModelSnapshot.cs b/osu.Game/Migrations/OsuDbContextModelSnapshot.cs index 8026847e3b..2dafedc3ac 100644 --- a/osu.Game/Migrations/OsuDbContextModelSnapshot.cs +++ b/osu.Game/Migrations/OsuDbContextModelSnapshot.cs @@ -14,7 +14,7 @@ namespace osu.Game.Migrations { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "2.1.4-rtm-31024"); + .HasAnnotation("ProductVersion", "2.2.0-rtm-35687"); modelBuilder.Entity("osu.Game.Beatmaps.BeatmapDifficulty", b => { @@ -215,6 +215,25 @@ namespace osu.Game.Migrations b.ToTable("Settings"); }); + modelBuilder.Entity("osu.Game.IO.FileInfo", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("Hash"); + + b.Property("ReferenceCount"); + + b.HasKey("ID"); + + b.HasIndex("Hash") + .IsUnique(); + + b.HasIndex("ReferenceCount"); + + b.ToTable("FileInfo"); + }); + modelBuilder.Entity("osu.Game.Input.Bindings.DatabasedKeyBinding", b => { b.Property("ID") @@ -239,25 +258,6 @@ namespace osu.Game.Migrations b.ToTable("KeyBinding"); }); - modelBuilder.Entity("osu.Game.IO.FileInfo", b => - { - b.Property("ID") - .ValueGeneratedOnAdd(); - - b.Property("Hash"); - - b.Property("ReferenceCount"); - - b.HasKey("ID"); - - b.HasIndex("Hash") - .IsUnique(); - - b.HasIndex("ReferenceCount"); - - b.ToTable("FileInfo"); - }); - modelBuilder.Entity("osu.Game.Rulesets.RulesetInfo", b => { b.Property("ID") @@ -454,7 +454,7 @@ namespace osu.Game.Migrations modelBuilder.Entity("osu.Game.Scoring.ScoreInfo", b => { b.HasOne("osu.Game.Beatmaps.BeatmapInfo", "Beatmap") - .WithMany() + .WithMany("Scores") .HasForeignKey("BeatmapInfoID") .OnDelete(DeleteBehavior.Cascade); diff --git a/osu.Game/Overlays/Chat/Selection/ChannelSection.cs b/osu.Game/Overlays/Chat/Selection/ChannelSection.cs index 94ee9d4bf6..c02215d690 100644 --- a/osu.Game/Overlays/Chat/Selection/ChannelSection.cs +++ b/osu.Game/Overlays/Chat/Selection/ChannelSection.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using System.Collections.Generic; using System.Linq; using osuTK; @@ -18,7 +19,7 @@ namespace osu.Game.Overlays.Chat.Selection public readonly FillFlowContainer ChannelFlow; public IEnumerable FilterableChildren => ChannelFlow.Children; - public IEnumerable FilterTerms => new[] { Header }; + public IEnumerable FilterTerms => Array.Empty(); public bool MatchingFilter { set diff --git a/osu.Game/Screens/Edit/Compose/Components/BeatDivisorControl.cs b/osu.Game/Screens/Edit/Compose/Components/BeatDivisorControl.cs index aa63b02013..373f4d1682 100644 --- a/osu.Game/Screens/Edit/Compose/Components/BeatDivisorControl.cs +++ b/osu.Game/Screens/Edit/Compose/Components/BeatDivisorControl.cs @@ -238,11 +238,11 @@ namespace osu.Game.Screens.Edit.Compose.Components { case Key.Right: beatDivisor.Next(); - OnUserChange(); + OnUserChange(Current); return true; case Key.Left: beatDivisor.Previous(); - OnUserChange(); + OnUserChange(Current); return true; default: return false; @@ -279,7 +279,7 @@ namespace osu.Game.Screens.Edit.Compose.Components var xPosition = (ToLocalSpace(screenSpaceMousePosition).X - RangePadding) / UsableWidth; CurrentNumber.Value = availableDivisors.OrderBy(d => Math.Abs(getMappedPosition(d) - xPosition)).First(); - OnUserChange(); + OnUserChange(Current); } private float getMappedPosition(float divisor) => (float)Math.Pow((divisor - 1) / (availableDivisors.Last() - 1), 0.90f); diff --git a/osu.Game/Screens/Play/SongProgressBar.cs b/osu.Game/Screens/Play/SongProgressBar.cs index 1f0c4936a5..b06a34e603 100644 --- a/osu.Game/Screens/Play/SongProgressBar.cs +++ b/osu.Game/Screens/Play/SongProgressBar.cs @@ -112,6 +112,6 @@ namespace osu.Game.Screens.Play handleBase.X = xFill; } - protected override void OnUserChange() => OnSeek?.Invoke(Current); + protected override void OnUserChange(double value) => OnSeek?.Invoke(value); } } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index d6dbb6f11c..8f00e81237 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -18,7 +18,7 @@ - +