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

Merge branch 'master' into fix-retry-sound

This commit is contained in:
Dan Balasescu 2019-05-07 12:37:22 +09:00 committed by GitHub
commit 8b9cfadd64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 178 additions and 45 deletions

View File

@ -12,6 +12,7 @@ using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI;
using osu.Game.Scoring;
using osuTK;
using osuTK.Graphics;
@ -41,6 +42,8 @@ namespace osu.Game.Rulesets.Osu.Mods
scoreProcessor.Health.ValueChanged += health => { blinds.AnimateClosedness((float)health.NewValue); };
}
public ScoreRank AdjustRank(ScoreRank rank, double accuracy) => rank;
/// <summary>
/// Element for the Blinds mod drawing 2 black boxes covering the whole screen which resize inside a restricted area with some leniency.
/// </summary>

View File

@ -3,12 +3,13 @@
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio.Track;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Audio;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Beatmaps;
using osu.Game.Graphics.Sprites;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Tests.Visual.Editor
@ -16,35 +17,38 @@ namespace osu.Game.Tests.Visual.Editor
[TestFixture]
public class TestCaseWaveform : OsuTestCase
{
private WorkingBeatmap waveformBeatmap;
[BackgroundDependencyLoader]
private void load()
{
Beatmap.Value = new WaveformTestBeatmap();
waveformBeatmap = new WaveformTestBeatmap();
}
FillFlowContainer flow;
Child = flow = new FillFlowContainer
[TestCase(1f)]
[TestCase(1f / 2)]
[TestCase(1f / 4)]
[TestCase(1f / 8)]
[TestCase(1f / 16)]
[TestCase(0f)]
public void TestResolution(float resolution)
{
TestWaveformGraph graph = null;
AddStep("add graph", () =>
{
RelativeSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 10),
};
for (int i = 1; i <= 16; i *= 2)
{
var newDisplay = new WaveformGraph
{
RelativeSizeAxes = Axes.Both,
Resolution = 1f / i,
Waveform = Beatmap.Value.Waveform,
};
flow.Add(new Container
Child = new Container
{
RelativeSizeAxes = Axes.X,
Height = 100,
Children = new Drawable[]
{
newDisplay,
graph = new TestWaveformGraph
{
RelativeSizeAxes = Axes.Both,
Resolution = resolution,
Waveform = waveformBeatmap.Waveform,
},
new Container
{
Anchor = Anchor.Centre,
@ -62,13 +66,42 @@ namespace osu.Game.Tests.Visual.Editor
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Text = $"Resolution: {1f / i:0.00}"
Text = $"Resolution: {resolution:0.00}"
}
}
}
}
});
}
};
});
AddUntilStep("wait for load", () => graph.ResampledWaveform != null);
}
[Test]
public void TestDefaultBeatmap()
{
TestWaveformGraph graph = null;
AddStep("add graph", () =>
{
Child = new Container
{
RelativeSizeAxes = Axes.X,
Height = 100,
Child = graph = new TestWaveformGraph
{
RelativeSizeAxes = Axes.Both,
Waveform = new DummyWorkingBeatmap().Waveform,
},
};
});
AddUntilStep("wait for load", () => graph.ResampledWaveform != null);
}
public class TestWaveformGraph : WaveformGraph
{
public new Waveform ResampledWaveform => base.ResampledWaveform;
}
}
}

View File

@ -12,6 +12,7 @@ using osu.Framework.Screens;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;
using osu.Game.Screens;
using osu.Game.Screens.Play;
using osu.Game.Tests.Beatmaps;
@ -96,6 +97,8 @@ namespace osu.Game.Tests.Visual.Gameplay
{
Applied = true;
}
public ScoreRank AdjustRank(ScoreRank rank, double accuracy) => rank;
}
private class TestPlayer : Player

View File

@ -8,5 +8,7 @@ namespace osu.Game.Online.API.Requests.Responses
public class APIMod : IMod
{
public string Acronym { get; set; }
public bool Equals(IMod other) => Acronym == other?.Acronym;
}
}

View File

@ -134,17 +134,17 @@ namespace osu.Game.Overlays.Profile.Header
DetailsVisible.BindValueChanged(visible =>
{
hiddenDetailContainer.Alpha = visible.NewValue ? 1 : 0;
expandedDetailContainer.Alpha = visible.NewValue ? 0 : 1;
}, true);
hiddenDetailContainer.FadeTo(visible.NewValue ? 0 : 1, 200, Easing.OutQuint);
expandedDetailContainer.FadeTo(visible.NewValue ? 1 : 0, 200, Easing.OutQuint);
});
User.BindValueChanged(user => updateDisplay(user.NewValue));
}
private void updateDisplay(User user)
{
hiddenDetailGlobal.Content = user?.Statistics?.Ranks.Global?.ToString("#,##0") ?? "-";
hiddenDetailCountry.Content = user?.Statistics?.Ranks.Country?.ToString("#,##0") ?? "-";
hiddenDetailGlobal.Content = user?.Statistics?.Ranks.Global?.ToString("\\##,##0") ?? "-";
hiddenDetailCountry.Content = user?.Statistics?.Ranks.Country?.ToString("\\##,##0") ?? "-";
}
}
}

View File

@ -188,7 +188,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
}
}
public string TooltipText => User.Value?.Statistics?.Ranks.Global == null ? "" : $"{ranks[dayIndex].Value:#,##0}|{ranked_days - ranks[dayIndex].Key + 1}";
public string TooltipText => User.Value?.Statistics?.Ranks.Global == null ? "" : $"#{ranks[dayIndex].Value:#,##0}|{ranked_days - ranks[dayIndex].Key + 1}";
public ITooltip GetCustomTooltip() => new RankGraphTooltip();

View File

@ -26,14 +26,40 @@ namespace osu.Game.Overlays.Profile.Header
private OverlinedInfoContainer ppInfo;
private OverlinedInfoContainer detailGlobalRank;
private OverlinedInfoContainer detailCountryRank;
private FillFlowContainer fillFlow;
private RankGraph rankGraph;
public readonly Bindable<User> User = new Bindable<User>();
private bool expanded = true;
public bool Expanded
{
set
{
if (expanded == value) return;
expanded = value;
if (fillFlow == null) return;
fillFlow.ClearTransforms();
if (expanded)
fillFlow.AutoSizeAxes = Axes.Y;
else
{
fillFlow.AutoSizeAxes = Axes.None;
fillFlow.ResizeHeightTo(0, 200, Easing.OutQuint);
}
}
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
AutoSizeAxes = Axes.Y;
User.ValueChanged += e => updateDisplay(e.NewValue);
InternalChildren = new Drawable[]
@ -43,10 +69,13 @@ namespace osu.Game.Overlays.Profile.Header
RelativeSizeAxes = Axes.Both,
Colour = colours.CommunityUserGrayGreenDarkest,
},
new FillFlowContainer
fillFlow = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
AutoSizeAxes = expanded ? Axes.Y : Axes.None,
AutoSizeDuration = 200,
AutoSizeEasing = Easing.OutQuint,
Masking = true,
Padding = new MarginPadding { Horizontal = UserProfileOverlay.CONTENT_X_MARGIN, Vertical = 10 },
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 20),
@ -148,8 +177,8 @@ namespace osu.Game.Overlays.Profile.Header
foreach (var scoreRankInfo in scoreRankInfos)
scoreRankInfo.Value.RankCount = user?.Statistics?.GradesCount[scoreRankInfo.Key] ?? 0;
detailGlobalRank.Content = user?.Statistics?.Ranks.Global?.ToString("#,##0") ?? "-";
detailCountryRank.Content = user?.Statistics?.Ranks.Country?.ToString("#,##0") ?? "-";
detailGlobalRank.Content = user?.Statistics?.Ranks.Global?.ToString("\\##,##0") ?? "-";
detailCountryRank.Content = user?.Statistics?.Ranks.Country?.ToString("\\##,##0") ?? "-";
rankGraph.User.Value = user;
}

View File

@ -117,7 +117,7 @@ namespace osu.Game.Overlays.Profile
infoTabControl.AddItem("Info");
infoTabControl.AddItem("Modding");
centreHeaderContainer.DetailsVisible.BindValueChanged(visible => detailHeaderContainer.Alpha = visible.NewValue ? 1 : 0, true);
centreHeaderContainer.DetailsVisible.BindValueChanged(visible => detailHeaderContainer.Expanded = visible.NewValue, true);
User.ValueChanged += e => updateDisplay(e.NewValue);
}

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;
namespace osu.Game.Rulesets.Mods
{
@ -10,6 +11,14 @@ namespace osu.Game.Rulesets.Mods
/// </summary>
public interface IApplicableToScoreProcessor : IApplicableMod
{
/// <summary>
/// Provide a <see cref="ScoreProcessor"/> to a mod. Called once on initialisation of a play instance.
/// </summary>
void ApplyToScoreProcessor(ScoreProcessor scoreProcessor);
/// <summary>
/// Called every time a rank calculation is requested. Allows mods to adjust the final rank.
/// </summary>
ScoreRank AdjustRank(ScoreRank rank, double accuracy);
}
}

View File

@ -1,11 +1,12 @@
// 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 System;
using Newtonsoft.Json;
namespace osu.Game.Rulesets.Mods
{
public interface IMod
public interface IMod : IEquatable<IMod>
{
/// <summary>
/// The shortened name of this mod.

View File

@ -70,5 +70,7 @@ namespace osu.Game.Rulesets.Mods
/// Creates a copy of this <see cref="Mod"/> initialised to a default state.
/// </summary>
public virtual Mod CreateCopy() => (Mod)Activator.CreateInstance(GetType());
public bool Equals(IMod other) => GetType() == other?.GetType();
}
}

View File

@ -16,6 +16,7 @@ using osu.Game.Graphics;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI;
using osu.Game.Scoring;
using osuTK;
using osuTK.Graphics;
@ -46,6 +47,8 @@ namespace osu.Game.Rulesets.Mods
Combo.BindTo(scoreProcessor.Combo);
}
public ScoreRank AdjustRank(ScoreRank rank, double accuracy) => rank;
public virtual void ApplyToDrawableRuleset(DrawableRuleset<T> drawableRuleset)
{
var flashlight = CreateFlashlight();

View File

@ -8,10 +8,12 @@ using System.Collections.Generic;
using System.Linq;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Sprites;
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;
namespace osu.Game.Rulesets.Mods
{
public abstract class ModHidden : Mod, IReadFromConfig, IApplicableToDrawableHitObjects
public abstract class ModHidden : Mod, IReadFromConfig, IApplicableToDrawableHitObjects, IApplicableToScoreProcessor
{
public override string Name => "Hidden";
public override string Acronym => "HD";
@ -32,6 +34,25 @@ namespace osu.Game.Rulesets.Mods
d.ApplyCustomUpdateState += ApplyHiddenState;
}
public void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)
{
// Default value of ScoreProcessor's Rank in Hidden Mod should be SS+
scoreProcessor.Rank.Value = ScoreRank.XH;
}
public ScoreRank AdjustRank(ScoreRank rank, double accuracy)
{
switch (rank)
{
case ScoreRank.X:
return ScoreRank.XH;
case ScoreRank.S:
return ScoreRank.SH;
default:
return rank;
}
}
protected virtual void ApplyHiddenState(DrawableHitObject hitObject, ArmedState state)
{
}

View File

@ -5,6 +5,7 @@ using System;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;
namespace osu.Game.Rulesets.Mods
{
@ -24,6 +25,8 @@ namespace osu.Game.Rulesets.Mods
scoreProcessor.FailConditions += FailCondition;
}
public ScoreRank AdjustRank(ScoreRank rank, double accuracy) => rank;
protected virtual bool FailCondition(ScoreProcessor scoreProcessor) => scoreProcessor.Combo.Value == 0;
}
}

View File

@ -10,6 +10,7 @@ using osu.Framework.Extensions;
using osu.Framework.Extensions.TypeExtensions;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.UI;
using osu.Game.Scoring;
@ -60,6 +61,11 @@ namespace osu.Game.Rulesets.Scoring
/// </summary>
public readonly BindableInt Combo = new BindableInt();
/// <summary>
/// The current selected mods
/// </summary>
public readonly Bindable<IReadOnlyList<Mod>> Mods = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());
/// <summary>
/// Create a <see cref="HitWindows"/> for this processor.
/// </summary>
@ -98,7 +104,12 @@ namespace osu.Game.Rulesets.Scoring
protected ScoreProcessor()
{
Combo.ValueChanged += delegate { HighestCombo.Value = Math.Max(HighestCombo.Value, Combo.Value); };
Accuracy.ValueChanged += delegate { Rank.Value = rankFrom(Accuracy.Value); };
Accuracy.ValueChanged += delegate
{
Rank.Value = rankFrom(Accuracy.Value);
foreach (var mod in Mods.Value.OfType<IApplicableToScoreProcessor>())
Rank.Value = mod.AdjustRank(Rank.Value, Accuracy.Value);
};
}
private ScoreRank rankFrom(double acc)

View File

@ -177,6 +177,8 @@ namespace osu.Game.Scoring
protected class DeserializedMod : IMod
{
public string Acronym { get; set; }
public bool Equals(IMod other) => Acronym == other?.Acronym;
}
public override string ToString() => $"{User} playing {Beatmap}";

View File

@ -56,7 +56,7 @@ namespace osu.Game.Screens.Multi.Play
if (ruleset.Value.ID != playlistItem.Ruleset.ID)
throw new InvalidOperationException("Current Ruleset does not match PlaylistItem's Ruleset");
if (!playlistItem.RequiredMods.All(m => Mods.Value.Contains(m)))
if (!playlistItem.RequiredMods.All(m => Mods.Value.Any(m.Equals)))
throw new InvalidOperationException("Current Mods do not match PlaylistItem's RequiredMods");
var req = new CreateRoomScoreRequest(roomId.Value ?? 0, playlistItem.ID);

View File

@ -106,6 +106,8 @@ namespace osu.Game.Screens.Play
showStoryboard = config.GetBindable<bool>(OsuSetting.ShowStoryboard);
ScoreProcessor = DrawableRuleset.CreateScoreProcessor();
ScoreProcessor.Mods.BindTo(Mods);
if (!ScoreProcessor.Mode.Disabled)
config.BindWith(OsuSetting.ScoreDisplayMode, ScoreProcessor.Mode);

View File

@ -38,6 +38,10 @@ namespace osu.Game.Screens.Play
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
protected override bool BlockPositionalInput => false;
/// <summary>
/// Displays a skip overlay, giving the user the ability to skip forward.
/// </summary>
/// <param name="startTime">The time at which gameplay begins to appear.</param>
public SkipOverlay(double startTime)
{
this.startTime = startTime;
@ -87,16 +91,21 @@ namespace osu.Game.Screens.Play
};
}
private const double skip_required_cutoff = 3000;
/// <summary>
/// Duration before gameplay start time required before skip button displays.
/// </summary>
private const double skip_buffer = 1000;
private const double fade_time = 300;
private double beginFadeTime => startTime - skip_required_cutoff - fade_time;
private double beginFadeTime => startTime - fade_time;
protected override void LoadComplete()
{
base.LoadComplete();
if (startTime < skip_required_cutoff)
// skip is not required if there is no extra "empty" time to skip.
if (Clock.CurrentTime > beginFadeTime - skip_buffer)
{
Alpha = 0;
Expire();
@ -107,7 +116,7 @@ namespace osu.Game.Screens.Play
using (BeginAbsoluteSequence(beginFadeTime))
this.FadeOut(fade_time);
button.Action = () => RequestSeek?.Invoke(startTime - skip_required_cutoff - fade_time);
button.Action = () => RequestSeek?.Invoke(beginFadeTime);
displayTime = Time.Current;

View File

@ -15,7 +15,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.3" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.128.0" />
<PackageReference Include="ppy.osu.Framework" Version="2019.427.0" />
<PackageReference Include="ppy.osu.Framework" Version="2019.502.0" />
<PackageReference Include="SharpCompress" Version="0.23.0" />
<PackageReference Include="NUnit" Version="3.11.0" />
<PackageReference Include="SharpRaven" Version="2.4.0" />

View File

@ -105,8 +105,8 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.128.0" />
<PackageReference Include="ppy.osu.Framework" Version="2019.427.0" />
<PackageReference Include="ppy.osu.Framework.iOS" Version="2019.427.0" />
<PackageReference Include="ppy.osu.Framework" Version="2019.502.0" />
<PackageReference Include="ppy.osu.Framework.iOS" Version="2019.502.0" />
<PackageReference Include="SharpCompress" Version="0.22.0" />
<PackageReference Include="NUnit" Version="3.11.0" />
<PackageReference Include="SharpRaven" Version="2.4.0" />