Merge branch 'master' into placement-display-in-timeline

This commit is contained in:
Dan Balasescu 2020-02-10 14:29:01 +09:00 committed by GitHub
commit bb15153f30
15 changed files with 136 additions and 45 deletions

View File

@ -38,8 +38,8 @@ namespace osu.Game.Tests.Visual.UserInterface
public void TestButtonShowsOnCustomisableMod()
{
createModSelect();
openModSelect();
AddStep("open", () => modSelect.Show());
AddAssert("button disabled", () => !modSelect.CustomiseButton.Enabled.Value);
AddUntilStep("wait for button load", () => modSelect.ButtonsLoaded);
AddStep("select mod", () => modSelect.SelectMod(testCustomisableMod));
@ -58,19 +58,21 @@ namespace osu.Game.Tests.Visual.UserInterface
AddAssert("mods still active", () => SelectedMods.Value.Count == 1);
AddStep("open", () => modSelect.Show());
openModSelect();
AddAssert("button enabled", () => modSelect.CustomiseButton.Enabled.Value);
}
[Test]
public void TestCustomisationOpensOnModSelect()
public void TestCustomisationMenuVisibility()
{
createModSelect();
openModSelect();
AddStep("open", () => modSelect.Show());
AddAssert("Customisation closed", () => modSelect.ModSettingsContainer.Alpha == 0);
AddStep("select mod", () => modSelect.SelectMod(testCustomisableAutoOpenMod));
AddAssert("Customisation opened", () => modSelect.ModSettingsContainer.Alpha == 1);
AddStep("deselect mod", () => modSelect.SelectMod(testCustomisableAutoOpenMod));
AddAssert("Customisation closed", () => modSelect.ModSettingsContainer.Alpha == 0);
}
private void createModSelect()
@ -86,6 +88,12 @@ namespace osu.Game.Tests.Visual.UserInterface
});
}
private void openModSelect()
{
AddStep("open", () => modSelect.Show());
AddUntilStep("wait for ready", () => modSelect.State.Value == Visibility.Visible && modSelect.ButtonsLoaded);
}
private class TestModSelectOverlay : ModSelectOverlay
{
public new Container ModSettingsContainer => base.ModSettingsContainer;

View File

@ -64,7 +64,7 @@ namespace osu.Game.Beatmaps.Formats
hitObject.ApplyDefaults(this.beatmap.ControlPointInfo, this.beatmap.BeatmapInfo.BaseDifficulty);
}
protected override bool ShouldSkipLine(string line) => base.ShouldSkipLine(line) || line.StartsWith(" ", StringComparison.Ordinal) || line.StartsWith("_", StringComparison.Ordinal);
protected override bool ShouldSkipLine(string line) => base.ShouldSkipLine(line) || line.StartsWith(' ') || line.StartsWith('_');
protected override void ParseLine(Beatmap beatmap, Section section, string line)
{

View File

@ -33,7 +33,7 @@ namespace osu.Game.Beatmaps.Formats
if (ShouldSkipLine(line))
continue;
if (line.StartsWith(@"[", StringComparison.Ordinal) && line.EndsWith(@"]", StringComparison.Ordinal))
if (line.StartsWith('[') && line.EndsWith(']'))
{
if (!Enum.TryParse(line[1..^1], out section))
{

View File

@ -64,15 +64,16 @@ namespace osu.Game.Beatmaps.Formats
private void handleEvents(string line)
{
var depth = 0;
var lineSpan = line.AsSpan();
while (lineSpan.StartsWith(" ", StringComparison.Ordinal) || lineSpan.StartsWith("_", StringComparison.Ordinal))
foreach (char c in line)
{
lineSpan = lineSpan.Slice(1);
++depth;
if (c == ' ' || c == '_')
depth++;
else
break;
}
line = lineSpan.ToString();
line = line.Substring(depth);
decodeVariables(ref line);

View File

@ -39,7 +39,7 @@ namespace osu.Game.Beatmaps
BeatmapSetInfo = beatmapInfo.BeatmapSet;
Metadata = beatmapInfo.Metadata ?? BeatmapSetInfo?.Metadata ?? new BeatmapMetadata();
track = new RecyclableLazy<Track>(() => GetTrack() ?? GetVirtualTrack());
track = new RecyclableLazy<Track>(() => GetTrack() ?? GetVirtualTrack(1000));
background = new RecyclableLazy<Texture>(GetBackground, BackgroundStillValid);
waveform = new RecyclableLazy<Waveform>(GetWaveform);
storyboard = new RecyclableLazy<Storyboard>(GetStoryboard);
@ -48,7 +48,7 @@ namespace osu.Game.Beatmaps
total_count.Value++;
}
protected virtual Track GetVirtualTrack()
protected virtual Track GetVirtualTrack(double emptyLength = 0)
{
const double excess_length = 1000;
@ -59,7 +59,7 @@ namespace osu.Game.Beatmaps
switch (lastObject)
{
case null:
length = excess_length;
length = emptyLength;
break;
case IHasEndTime endTime:

View File

@ -78,7 +78,7 @@ namespace osu.Game.Configuration
Set(OsuSetting.MenuParallax, true);
// Gameplay
Set(OsuSetting.DimLevel, 0.3, 0, 1, 0.01);
Set(OsuSetting.DimLevel, 0.8, 0, 1, 0.01);
Set(OsuSetting.BlurLevel, 0, 0, 1, 0.01);
Set(OsuSetting.LightenDuringBreaks, true);

View File

@ -59,9 +59,9 @@ namespace osu.Game.Graphics.Containers
Track track = null;
IBeatmap beatmap = null;
double currentTrackTime;
TimingControlPoint timingPoint;
EffectControlPoint effectPoint;
double currentTrackTime = 0;
TimingControlPoint timingPoint = null;
EffectControlPoint effectPoint = null;
if (Beatmap.Value.TrackLoaded && Beatmap.Value.BeatmapLoaded)
{
@ -69,24 +69,18 @@ namespace osu.Game.Graphics.Containers
beatmap = Beatmap.Value.Beatmap;
}
if (track != null && beatmap != null && track.IsRunning)
if (track != null && beatmap != null && track.IsRunning && track.Length > 0)
{
currentTrackTime = track.Length > 0 ? track.CurrentTime + EarlyActivationMilliseconds : Clock.CurrentTime;
currentTrackTime = track.CurrentTime + EarlyActivationMilliseconds;
timingPoint = beatmap.ControlPointInfo.TimingPointAt(currentTrackTime);
effectPoint = beatmap.ControlPointInfo.EffectPointAt(currentTrackTime);
if (timingPoint.BeatLength == 0)
{
IsBeatSyncedWithTrack = false;
return;
}
IsBeatSyncedWithTrack = true;
}
else
IsBeatSyncedWithTrack = timingPoint?.BeatLength > 0;
if (timingPoint == null || !IsBeatSyncedWithTrack)
{
IsBeatSyncedWithTrack = false;
currentTrackTime = Clock.CurrentTime;
timingPoint = defaultTiming;
effectPoint = defaultEffect;

View File

@ -2,13 +2,18 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Audio.Track;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics.Sprites;
using osuTK.Graphics;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Graphics.Containers;
using osuTK;
namespace osu.Game.Graphics.UserInterface
{
@ -59,5 +64,91 @@ namespace osu.Game.Graphics.UserInterface
}
protected override Drawable GetDrawableCharacter(char c) => new OsuSpriteText { Text = c.ToString(), Font = OsuFont.GetFont(size: CalculatedTextSize) };
protected override Caret CreateCaret() => new OsuCaret
{
CaretWidth = CaretWidth,
SelectionColour = SelectionColour,
};
private class OsuCaret : Caret
{
private const float caret_move_time = 60;
private readonly CaretBeatSyncedContainer beatSync;
public OsuCaret()
{
RelativeSizeAxes = Axes.Y;
Size = new Vector2(1, 0.9f);
Colour = Color4.Transparent;
Anchor = Anchor.CentreLeft;
Origin = Anchor.CentreLeft;
Masking = true;
CornerRadius = 1;
InternalChild = beatSync = new CaretBeatSyncedContainer
{
RelativeSizeAxes = Axes.Both,
};
}
public override void Hide() => this.FadeOut(200);
public float CaretWidth { get; set; }
public Color4 SelectionColour { get; set; }
public override void DisplayAt(Vector2 position, float? selectionWidth)
{
beatSync.HasSelection = selectionWidth != null;
if (selectionWidth != null)
{
this.MoveTo(new Vector2(position.X, position.Y), 60, Easing.Out);
this.ResizeWidthTo(selectionWidth.Value + CaretWidth / 2, caret_move_time, Easing.Out);
this.FadeColour(SelectionColour, 200, Easing.Out);
}
else
{
this.MoveTo(new Vector2(position.X - CaretWidth / 2, position.Y), 60, Easing.Out);
this.ResizeWidthTo(CaretWidth, caret_move_time, Easing.Out);
this.FadeColour(Color4.White, 200, Easing.Out);
}
}
private class CaretBeatSyncedContainer : BeatSyncedContainer
{
private bool hasSelection;
public bool HasSelection
{
set
{
hasSelection = value;
if (value)
this.FadeTo(0.5f, 200, Easing.Out);
}
}
public CaretBeatSyncedContainer()
{
MinimumBeatLength = 300;
InternalChild = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.White,
};
}
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes)
{
if (!hasSelection)
this.FadeTo(0.7f).FadeTo(0.4f, timingPoint.BeatLength, Easing.InOutSine);
}
}
}
}
}

View File

@ -3,6 +3,7 @@
using System;
using osu.Framework.Allocation;
using osu.Game.Utils;
namespace osu.Game.Graphics.UserInterface
{
@ -29,10 +30,7 @@ namespace osu.Game.Graphics.UserInterface
[BackgroundDependencyLoader]
private void load(OsuColour colours) => AccentColour = colours.BlueLighter;
protected override string FormatCount(double count)
{
return $@"{count:P2}";
}
protected override string FormatCount(double count) => count.FormatAccuracy();
protected override double GetProportionalDuration(double currentValue, double newValue)
{

View File

@ -82,7 +82,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
new TableColumn("max combo", Anchor.CentreLeft, new Dimension(GridSizeMode.Distributed, minSize: 70, maxSize: 90))
};
foreach (var statistic in score.Statistics)
foreach (var statistic in score.SortedStatistics)
columns.Add(new TableColumn(statistic.Key.GetDescription(), Anchor.CentreLeft, new Dimension(GridSizeMode.Distributed, minSize: 50, maxSize: 70)));
columns.AddRange(new[]
@ -150,7 +150,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
}
});
foreach (var kvp in score.Statistics)
foreach (var kvp in score.SortedStatistics)
{
content.Add(new OsuSpriteText
{

View File

@ -99,9 +99,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
maxComboColumn.Text = $@"{value.MaxCombo:N0}x";
ppColumn.Text = $@"{value.PP:N0}";
statisticsColumns.ChildrenEnumerable = value.Statistics
.OrderByDescending(pair => pair.Key)
.Select(kvp => createStatisticsColumn(kvp.Key, kvp.Value));
statisticsColumns.ChildrenEnumerable = value.SortedStatistics.Select(kvp => createStatisticsColumn(kvp.Key, kvp.Value));
modsColumn.Mods = value.Mods;
}
}

View File

@ -151,6 +151,8 @@ namespace osu.Game.Scoring
[JsonProperty("statistics")]
public Dictionary<HitResult, int> Statistics = new Dictionary<HitResult, int>();
public IOrderedEnumerable<KeyValuePair<HitResult, int>> SortedStatistics => Statistics.OrderByDescending(pair => pair.Key);
[JsonIgnore]
[Column("Statistics")]
public string StatisticsJson

View File

@ -9,6 +9,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Utils;
namespace osu.Game.Screens.Play.Break
{
@ -85,6 +86,6 @@ namespace osu.Game.Screens.Play.Break
{
}
protected override string Format(double count) => $@"{count:P2}";
protected override string Format(double count) => count.FormatAccuracy();
}
}

View File

@ -188,7 +188,7 @@ namespace osu.Game.Screens.Ranking.Pages
},
};
statisticsContainer.ChildrenEnumerable = Score.Statistics.OrderByDescending(p => p.Key).Select(s => new DrawableScoreStatistic(s));
statisticsContainer.ChildrenEnumerable = Score.SortedStatistics.Select(s => new DrawableScoreStatistic(s));
}
protected override void LoadComplete()

View File

@ -7,18 +7,16 @@ namespace osu.Game.Utils
{
/// <summary>
/// Turns the provided accuracy into a percentage with 2 decimal places.
/// Omits all decimal places when <paramref name="accuracy"/> equals 1d.
/// </summary>
/// <param name="accuracy">The accuracy to be formatted</param>
/// <returns>formatted accuracy in percentage</returns>
public static string FormatAccuracy(this double accuracy) => accuracy == 1 ? "100%" : $"{accuracy:0.00%}";
public static string FormatAccuracy(this double accuracy) => $"{accuracy:0.00%}";
/// <summary>
/// Turns the provided accuracy into a percentage with 2 decimal places.
/// Omits all decimal places when <paramref name="accuracy"/> equals 100m.
/// </summary>
/// <param name="accuracy">The accuracy to be formatted</param>
/// <returns>formatted accuracy in percentage</returns>
public static string FormatAccuracy(this decimal accuracy) => accuracy == 100 ? "100%" : $"{accuracy:0.00}%";
public static string FormatAccuracy(this decimal accuracy) => $"{accuracy:0.00}%";
}
}