1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 15:07:44 +08:00

Merge branch 'master' into editor-new-beatmap

This commit is contained in:
Bartłomiej Dach 2020-09-06 18:24:02 +02:00 committed by GitHub
commit f138b92078
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 132 additions and 33 deletions

View File

@ -51,7 +51,7 @@
<Reference Include="Java.Interop" /> <Reference Include="Java.Interop" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.903.0" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2020.904.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2020.903.0" /> <PackageReference Include="ppy.osu.Framework.Android" Version="2020.904.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -3,7 +3,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Framework.Graphics.Sprites;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets.Catch.Objects; using osu.Game.Rulesets.Catch.Objects;
@ -23,19 +22,19 @@ namespace osu.Game.Rulesets.Catch.Beatmaps
{ {
Name = @"Fruit Count", Name = @"Fruit Count",
Content = fruits.ToString(), Content = fruits.ToString(),
Icon = FontAwesome.Regular.Circle CreateIcon = () => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Circles),
}, },
new BeatmapStatistic new BeatmapStatistic
{ {
Name = @"Juice Stream Count", Name = @"Juice Stream Count",
Content = juiceStreams.ToString(), Content = juiceStreams.ToString(),
Icon = FontAwesome.Regular.Circle CreateIcon = () => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Sliders),
}, },
new BeatmapStatistic new BeatmapStatistic
{ {
Name = @"Banana Shower Count", Name = @"Banana Shower Count",
Content = bananaShowers.ToString(), Content = bananaShowers.ToString(),
Icon = FontAwesome.Regular.Circle CreateIcon = () => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Spinners),
} }
}; };
} }

View File

@ -3,7 +3,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Framework.Graphics.Sprites;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.Mania.UI; using osu.Game.Rulesets.Mania.UI;
@ -41,14 +40,14 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
new BeatmapStatistic new BeatmapStatistic
{ {
Name = @"Note Count", Name = @"Note Count",
CreateIcon = () => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Circles),
Content = notes.ToString(), Content = notes.ToString(),
Icon = FontAwesome.Regular.Circle
}, },
new BeatmapStatistic new BeatmapStatistic
{ {
Name = @"Hold Note Count", Name = @"Hold Note Count",
CreateIcon = () => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Sliders),
Content = holdnotes.ToString(), Content = holdnotes.ToString(),
Icon = FontAwesome.Regular.Circle
}, },
}; };
} }

View File

@ -3,7 +3,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Framework.Graphics.Sprites;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
@ -23,19 +22,19 @@ namespace osu.Game.Rulesets.Osu.Beatmaps
{ {
Name = @"Circle Count", Name = @"Circle Count",
Content = circles.ToString(), Content = circles.ToString(),
Icon = FontAwesome.Regular.Circle CreateIcon = () => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Circles),
}, },
new BeatmapStatistic new BeatmapStatistic
{ {
Name = @"Slider Count", Name = @"Slider Count",
Content = sliders.ToString(), Content = sliders.ToString(),
Icon = FontAwesome.Regular.Circle CreateIcon = () => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Sliders),
}, },
new BeatmapStatistic new BeatmapStatistic
{ {
Name = @"Spinner Count", Name = @"Spinner Count",
Content = spinners.ToString(), Content = spinners.ToString(),
Icon = FontAwesome.Regular.Circle CreateIcon = () => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Spinners),
} }
}; };
} }

View File

@ -3,7 +3,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Framework.Graphics.Sprites;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets.Taiko.Objects; using osu.Game.Rulesets.Taiko.Objects;
@ -22,20 +21,20 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps
new BeatmapStatistic new BeatmapStatistic
{ {
Name = @"Hit Count", Name = @"Hit Count",
CreateIcon = () => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Circles),
Content = hits.ToString(), Content = hits.ToString(),
Icon = FontAwesome.Regular.Circle
}, },
new BeatmapStatistic new BeatmapStatistic
{ {
Name = @"Drumroll Count", Name = @"Drumroll Count",
CreateIcon = () => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Sliders),
Content = drumrolls.ToString(), Content = drumrolls.ToString(),
Icon = FontAwesome.Regular.Circle
}, },
new BeatmapStatistic new BeatmapStatistic
{ {
Name = @"Swell Count", Name = @"Swell Count",
CreateIcon = () => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Spinners),
Content = swells.ToString(), Content = swells.ToString(),
Icon = FontAwesome.Regular.Circle
} }
}; };
} }

View File

@ -162,6 +162,28 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddAssert("item 2 has rate 2", () => Precision.AlmostEquals(2, ((OsuModDoubleTime)Room.Playlist.Last().RequiredMods[0]).SpeedChange.Value)); AddAssert("item 2 has rate 2", () => Precision.AlmostEquals(2, ((OsuModDoubleTime)Room.Playlist.Last().RequiredMods[0]).SpeedChange.Value));
} }
/// <summary>
/// Tests that the global mod instances are not retained by the rooms, as global mod instances are retained and re-used by the mod select overlay.
/// </summary>
[Test]
public void TestGlobalModInstancesNotRetained()
{
OsuModDoubleTime mod = null;
AddStep("set dt mod and store", () =>
{
SelectedMods.Value = new[] { new OsuModDoubleTime() };
// Mod select overlay replaces our mod.
mod = (OsuModDoubleTime)SelectedMods.Value[0];
});
AddStep("create item", () => songSelect.BeatmapDetails.CreateNewItem());
AddStep("change stored mod rate", () => mod.SpeedChange.Value = 2);
AddAssert("item has rate 1.5", () => Precision.AlmostEquals(1.5, ((OsuModDoubleTime)Room.Playlist.First().RequiredMods[0]).SpeedChange.Value));
}
private class TestMatchSongSelect : MatchSongSelect private class TestMatchSongSelect : MatchSongSelect
{ {
public new MatchBeatmapDetailArea BeatmapDetails => (MatchBeatmapDetailArea)base.BeatmapDetails; public new MatchBeatmapDetailArea BeatmapDetails => (MatchBeatmapDetailArea)base.BeatmapDetails;

View File

@ -1,14 +1,31 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osuTK;
namespace osu.Game.Beatmaps namespace osu.Game.Beatmaps
{ {
public class BeatmapStatistic public class BeatmapStatistic
{ {
public IconUsage Icon; [Obsolete("Use CreateIcon instead")] // can be removed 20210203
public IconUsage Icon = FontAwesome.Regular.QuestionCircle;
/// <summary>
/// A function to create the icon for display purposes. Use default icons available via <see cref="BeatmapStatisticIcon"/> whenever possible for conformity.
/// </summary>
public Func<Drawable> CreateIcon;
public string Content; public string Content;
public string Name; public string Name;
public BeatmapStatistic()
{
#pragma warning disable 618
CreateIcon = () => new SpriteIcon { Icon = Icon, Scale = new Vector2(0.7f) };
#pragma warning restore 618
}
} }
} }

View File

@ -0,0 +1,43 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using Humanizer;
using osu.Framework.Allocation;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
namespace osu.Game.Beatmaps
{
/// <summary>
/// A default implementation of an icon used to represent beatmap statistics.
/// </summary>
public class BeatmapStatisticIcon : Sprite
{
private readonly BeatmapStatisticsIconType iconType;
public BeatmapStatisticIcon(BeatmapStatisticsIconType iconType)
{
this.iconType = iconType;
}
[BackgroundDependencyLoader]
private void load(TextureStore textures)
{
Texture = textures.Get($"Icons/BeatmapDetails/{iconType.ToString().Kebaberize()}");
}
}
public enum BeatmapStatisticsIconType
{
Accuracy,
ApproachRate,
Bpm,
Circles,
HpDrain,
Length,
OverallDifficulty,
Size,
Sliders,
Spinners,
}
}

View File

@ -279,6 +279,11 @@ namespace osu.Game.Overlays
private void changeBeatmap(WorkingBeatmap newWorking) private void changeBeatmap(WorkingBeatmap newWorking)
{ {
// This method can potentially be triggered multiple times as it is eagerly fired in next() / prev() to ensure correct execution order
// (changeBeatmap must be called before consumers receive the bindable changed event, which is not the case when the local beatmap bindable is updated directly).
if (newWorking == current)
return;
var lastWorking = current; var lastWorking = current;
TrackChangeDirection direction = TrackChangeDirection.None; TrackChangeDirection direction = TrackChangeDirection.None;

View File

@ -1,12 +1,14 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Overlays.Settings.Sections.Gameplay; using osu.Game.Overlays.Settings.Sections.Gameplay;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using System.Linq; using System.Linq;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Logging;
namespace osu.Game.Overlays.Settings.Sections namespace osu.Game.Overlays.Settings.Sections
{ {
@ -34,9 +36,17 @@ namespace osu.Game.Overlays.Settings.Sections
{ {
foreach (Ruleset ruleset in rulesets.AvailableRulesets.Select(info => info.CreateInstance())) foreach (Ruleset ruleset in rulesets.AvailableRulesets.Select(info => info.CreateInstance()))
{ {
SettingsSubsection section = ruleset.CreateSettings(); try
if (section != null) {
Add(section); SettingsSubsection section = ruleset.CreateSettings();
if (section != null)
Add(section);
}
catch (Exception e)
{
Logger.Error(e, "Failed to load ruleset settings");
}
} }
} }
} }

View File

@ -318,14 +318,14 @@ namespace osu.Game.Screens.Select
labels.Add(new InfoLabel(new BeatmapStatistic labels.Add(new InfoLabel(new BeatmapStatistic
{ {
Name = "Length", Name = "Length",
Icon = FontAwesome.Regular.Clock, CreateIcon = () => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Length),
Content = TimeSpan.FromMilliseconds(b.BeatmapInfo.Length).ToString(@"m\:ss"), Content = TimeSpan.FromMilliseconds(b.BeatmapInfo.Length).ToString(@"m\:ss"),
})); }));
labels.Add(new InfoLabel(new BeatmapStatistic labels.Add(new InfoLabel(new BeatmapStatistic
{ {
Name = "BPM", Name = "BPM",
Icon = FontAwesome.Regular.Circle, CreateIcon = () => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Bpm),
Content = getBPMRange(b), Content = getBPMRange(b),
})); }));
@ -418,10 +418,18 @@ namespace osu.Game.Screens.Select
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Scale = new Vector2(0.8f),
Colour = Color4Extensions.FromHex(@"f7dd55"), Colour = Color4Extensions.FromHex(@"f7dd55"),
Icon = statistic.Icon, Icon = FontAwesome.Regular.Circle,
Size = new Vector2(0.8f)
}, },
statistic.CreateIcon().With(i =>
{
i.Anchor = Anchor.Centre;
i.Origin = Anchor.Centre;
i.RelativeSizeAxes = Axes.Both;
i.Colour = Color4Extensions.FromHex(@"f7dd55");
i.Size = new Vector2(0.64f);
}),
} }
}, },
new OsuSpriteText new OsuSpriteText

View File

@ -76,9 +76,7 @@ namespace osu.Game.Screens.Select
item.Ruleset.Value = Ruleset.Value; item.Ruleset.Value = Ruleset.Value;
item.RequiredMods.Clear(); item.RequiredMods.Clear();
item.RequiredMods.AddRange(Mods.Value); item.RequiredMods.AddRange(Mods.Value.Select(m => m.CreateCopy()));
Mods.Value = Mods.Value.Select(m => m.CreateCopy()).ToArray();
} }
} }
} }

View File

@ -24,8 +24,8 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="ppy.osu.Framework" Version="2020.903.0" /> <PackageReference Include="ppy.osu.Framework" Version="2020.904.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.903.0" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2020.904.0" />
<PackageReference Include="Sentry" Version="2.1.6" /> <PackageReference Include="Sentry" Version="2.1.6" />
<PackageReference Include="SharpCompress" Version="0.26.0" /> <PackageReference Include="SharpCompress" Version="0.26.0" />
<PackageReference Include="NUnit" Version="3.12.0" /> <PackageReference Include="NUnit" Version="3.12.0" />

View File

@ -70,8 +70,8 @@
<Reference Include="System.Net.Http" /> <Reference Include="System.Net.Http" />
</ItemGroup> </ItemGroup>
<ItemGroup Label="Package References"> <ItemGroup Label="Package References">
<PackageReference Include="ppy.osu.Framework.iOS" Version="2020.903.0" /> <PackageReference Include="ppy.osu.Framework.iOS" Version="2020.904.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.903.0" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2020.904.0" />
</ItemGroup> </ItemGroup>
<!-- Xamarin.iOS does not automatically handle transitive dependencies from NuGet packages. --> <!-- Xamarin.iOS does not automatically handle transitive dependencies from NuGet packages. -->
<ItemGroup Label="Transitive Dependencies"> <ItemGroup Label="Transitive Dependencies">
@ -80,7 +80,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="ppy.osu.Framework" Version="2020.903.0" /> <PackageReference Include="ppy.osu.Framework" Version="2020.904.0" />
<PackageReference Include="SharpCompress" Version="0.26.0" /> <PackageReference Include="SharpCompress" Version="0.26.0" />
<PackageReference Include="NUnit" Version="3.12.0" /> <PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="SharpRaven" Version="2.4.0" /> <PackageReference Include="SharpRaven" Version="2.4.0" />