mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 06:57:39 +08:00
Merge branch 'master' into hoc-event-queue
This commit is contained in:
commit
55cc533a37
@ -52,6 +52,6 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.422.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2021.510.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2021.513.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
@ -28,10 +28,12 @@ namespace osu.Game.Rulesets.Catch.Mods
|
||||
catchPlayfield.CatcherArea.MovableCatcher.CatchFruitOnPlate = false;
|
||||
}
|
||||
|
||||
protected override void ApplyIncreasedVisibilityState(DrawableHitObject hitObject, ArmedState state)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void ApplyNormalVisibilityState(DrawableHitObject hitObject, ArmedState state)
|
||||
{
|
||||
base.ApplyNormalVisibilityState(hitObject, state);
|
||||
|
||||
if (!(hitObject is DrawableCatchHitObject catchDrawable))
|
||||
return;
|
||||
|
||||
@ -54,7 +56,7 @@ namespace osu.Game.Rulesets.Catch.Mods
|
||||
var offset = hitObject.TimePreempt * fade_out_offset_multiplier;
|
||||
var duration = offset - hitObject.TimePreempt * fade_out_duration_multiplier;
|
||||
|
||||
using (drawable.BeginAbsoluteSequence(hitObject.StartTime - offset, true))
|
||||
using (drawable.BeginAbsoluteSequence(hitObject.StartTime - offset))
|
||||
drawable.FadeOut(duration);
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ namespace osu.Game.Rulesets.Catch.Skinning.Legacy
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
explosion = new LegacyRollingCounter(skin, LegacyFont.Combo)
|
||||
explosion = new LegacyRollingCounter(LegacyFont.Combo)
|
||||
{
|
||||
Alpha = 0.65f,
|
||||
Blending = BlendingParameters.Additive,
|
||||
@ -38,7 +38,7 @@ namespace osu.Game.Rulesets.Catch.Skinning.Legacy
|
||||
Origin = Anchor.Centre,
|
||||
Scale = new Vector2(1.5f),
|
||||
},
|
||||
counter = new LegacyRollingCounter(skin, LegacyFont.Combo)
|
||||
counter = new LegacyRollingCounter(LegacyFont.Combo)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
|
@ -8,6 +8,7 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Rulesets.Mania.Objects;
|
||||
using osu.Game.Rulesets.Mania.UI;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.UI;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Mods
|
||||
@ -39,5 +40,13 @@ namespace osu.Game.Rulesets.Mania.Mods
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
protected override void ApplyIncreasedVisibilityState(DrawableHitObject hitObject, ArmedState state)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void ApplyNormalVisibilityState(DrawableHitObject hitObject, ArmedState state)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using osu.Game.Rulesets.Osu.Edit.Checks;
|
||||
@ -224,12 +225,14 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor.Checks
|
||||
|
||||
private void assertOk(IBeatmap beatmap)
|
||||
{
|
||||
Assert.That(check.Run(beatmap, new TestWorkingBeatmap(beatmap)), Is.Empty);
|
||||
var context = new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap));
|
||||
Assert.That(check.Run(context), Is.Empty);
|
||||
}
|
||||
|
||||
private void assertOffscreenCircle(IBeatmap beatmap)
|
||||
{
|
||||
var issues = check.Run(beatmap, new TestWorkingBeatmap(beatmap)).ToList();
|
||||
var context = new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap));
|
||||
var issues = check.Run(context).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(1));
|
||||
Assert.That(issues.Single().Template is CheckOffscreenObjects.IssueTemplateOffscreenCircle);
|
||||
@ -237,7 +240,8 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor.Checks
|
||||
|
||||
private void assertOffscreenSlider(IBeatmap beatmap)
|
||||
{
|
||||
var issues = check.Run(beatmap, new TestWorkingBeatmap(beatmap)).ToList();
|
||||
var context = new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap));
|
||||
var issues = check.Run(context).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(1));
|
||||
Assert.That(issues.Single().Template is CheckOffscreenObjects.IssueTemplateOffscreenSlider);
|
||||
|
@ -2,7 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Edit.Checks.Components;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osuTK;
|
||||
@ -31,9 +31,9 @@ namespace osu.Game.Rulesets.Osu.Edit.Checks
|
||||
new IssueTemplateOffscreenSlider(this)
|
||||
};
|
||||
|
||||
public IEnumerable<Issue> Run(IBeatmap playableBeatmap, IWorkingBeatmap workingBeatmap)
|
||||
public IEnumerable<Issue> Run(BeatmapVerifierContext context)
|
||||
{
|
||||
foreach (var hitobject in playableBeatmap.HitObjects)
|
||||
foreach (var hitobject in context.Beatmap.HitObjects)
|
||||
{
|
||||
switch (hitobject)
|
||||
{
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Edit.Checks.Components;
|
||||
using osu.Game.Rulesets.Osu.Edit.Checks;
|
||||
@ -17,9 +16,9 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
new CheckOffscreenObjects()
|
||||
};
|
||||
|
||||
public IEnumerable<Issue> Run(IBeatmap playableBeatmap, WorkingBeatmap workingBeatmap)
|
||||
public IEnumerable<Issue> Run(BeatmapVerifierContext context)
|
||||
{
|
||||
return checks.SelectMany(check => check.Run(playableBeatmap, workingBeatmap));
|
||||
return checks.SelectMany(check => check.Run(context));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,13 +43,11 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
|
||||
protected override void ApplyIncreasedVisibilityState(DrawableHitObject hitObject, ArmedState state)
|
||||
{
|
||||
base.ApplyIncreasedVisibilityState(hitObject, state);
|
||||
applyState(hitObject, true);
|
||||
}
|
||||
|
||||
protected override void ApplyNormalVisibilityState(DrawableHitObject hitObject, ArmedState state)
|
||||
{
|
||||
base.ApplyNormalVisibilityState(hitObject, state);
|
||||
applyState(hitObject, false);
|
||||
}
|
||||
|
||||
@ -60,20 +58,20 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
|
||||
OsuHitObject hitObject = drawableOsuObject.HitObject;
|
||||
|
||||
(double startTime, double duration) fadeOut = getFadeOutParameters(drawableOsuObject);
|
||||
(double fadeStartTime, double fadeDuration) = getFadeOutParameters(drawableOsuObject);
|
||||
|
||||
switch (drawableObject)
|
||||
{
|
||||
case DrawableSliderTail _:
|
||||
using (drawableObject.BeginAbsoluteSequence(fadeOut.startTime, true))
|
||||
drawableObject.FadeOut(fadeOut.duration);
|
||||
using (drawableObject.BeginAbsoluteSequence(fadeStartTime))
|
||||
drawableObject.FadeOut(fadeDuration);
|
||||
|
||||
break;
|
||||
|
||||
case DrawableSliderRepeat sliderRepeat:
|
||||
using (drawableObject.BeginAbsoluteSequence(fadeOut.startTime, true))
|
||||
using (drawableObject.BeginAbsoluteSequence(fadeStartTime))
|
||||
// only apply to circle piece – reverse arrow is not affected by hidden.
|
||||
sliderRepeat.CirclePiece.FadeOut(fadeOut.duration);
|
||||
sliderRepeat.CirclePiece.FadeOut(fadeDuration);
|
||||
|
||||
break;
|
||||
|
||||
@ -88,23 +86,23 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
else
|
||||
{
|
||||
// we don't want to see the approach circle
|
||||
using (circle.BeginAbsoluteSequence(hitObject.StartTime - hitObject.TimePreempt, true))
|
||||
using (circle.BeginAbsoluteSequence(hitObject.StartTime - hitObject.TimePreempt))
|
||||
circle.ApproachCircle.Hide();
|
||||
}
|
||||
|
||||
using (drawableObject.BeginAbsoluteSequence(fadeOut.startTime, true))
|
||||
fadeTarget.FadeOut(fadeOut.duration);
|
||||
using (drawableObject.BeginAbsoluteSequence(fadeStartTime))
|
||||
fadeTarget.FadeOut(fadeDuration);
|
||||
break;
|
||||
|
||||
case DrawableSlider slider:
|
||||
using (slider.BeginAbsoluteSequence(fadeOut.startTime, true))
|
||||
slider.Body.FadeOut(fadeOut.duration, Easing.Out);
|
||||
using (slider.BeginAbsoluteSequence(fadeStartTime))
|
||||
slider.Body.FadeOut(fadeDuration, Easing.Out);
|
||||
|
||||
break;
|
||||
|
||||
case DrawableSliderTick sliderTick:
|
||||
using (sliderTick.BeginAbsoluteSequence(fadeOut.startTime, true))
|
||||
sliderTick.FadeOut(fadeOut.duration);
|
||||
using (sliderTick.BeginAbsoluteSequence(fadeStartTime))
|
||||
sliderTick.FadeOut(fadeDuration);
|
||||
|
||||
break;
|
||||
|
||||
@ -112,14 +110,14 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
// hide elements we don't care about.
|
||||
// todo: hide background
|
||||
|
||||
using (spinner.BeginAbsoluteSequence(fadeOut.startTime, true))
|
||||
spinner.FadeOut(fadeOut.duration);
|
||||
using (spinner.BeginAbsoluteSequence(fadeStartTime))
|
||||
spinner.FadeOut(fadeDuration);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private (double startTime, double duration) getFadeOutParameters(DrawableOsuHitObject drawableObject)
|
||||
private (double fadeStartTime, double fadeDuration) getFadeOutParameters(DrawableOsuHitObject drawableObject)
|
||||
{
|
||||
switch (drawableObject)
|
||||
{
|
||||
@ -137,7 +135,7 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
return getParameters(drawableObject.HitObject);
|
||||
}
|
||||
|
||||
static (double startTime, double duration) getParameters(OsuHitObject hitObject)
|
||||
static (double fadeStartTime, double fadeDuration) getParameters(OsuHitObject hitObject)
|
||||
{
|
||||
var fadeOutStartTime = hitObject.StartTime - hitObject.TimePreempt + hitObject.TimeFadeIn;
|
||||
var fadeOutDuration = hitObject.TimePreempt * fade_out_duration_multiplier;
|
||||
|
@ -76,7 +76,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
||||
Scale = new Vector2(SPRITE_SCALE),
|
||||
Y = SPINNER_TOP_OFFSET + 115,
|
||||
},
|
||||
bonusCounter = new LegacySpriteText(source, LegacyFont.Score)
|
||||
bonusCounter = new LegacySpriteText(LegacyFont.Score)
|
||||
{
|
||||
Alpha = 0f,
|
||||
Anchor = Anchor.TopCentre,
|
||||
@ -92,7 +92,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
||||
Scale = new Vector2(SPRITE_SCALE),
|
||||
Position = new Vector2(-87, 445 + spm_hide_offset),
|
||||
},
|
||||
spmCounter = new LegacySpriteText(source, LegacyFont.Score)
|
||||
spmCounter = new LegacySpriteText(LegacyFont.Score)
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopRight,
|
||||
|
@ -100,7 +100,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
||||
if (!this.HasFont(LegacyFont.HitCircle))
|
||||
return null;
|
||||
|
||||
return new LegacySpriteText(Source, LegacyFont.HitCircle)
|
||||
return new LegacySpriteText(LegacyFont.HitCircle)
|
||||
{
|
||||
// stable applies a blanket 0.8x scale to hitcircle fonts
|
||||
Scale = new Vector2(0.8f),
|
||||
|
@ -166,7 +166,7 @@ namespace osu.Game.Rulesets.Osu.Statistics
|
||||
|
||||
var point = new HitPoint(pointType, this)
|
||||
{
|
||||
Colour = pointType == HitPointType.Hit ? new Color4(102, 255, 204, 255) : new Color4(255, 102, 102, 255)
|
||||
BaseColour = pointType == HitPointType.Hit ? new Color4(102, 255, 204, 255) : new Color4(255, 102, 102, 255)
|
||||
};
|
||||
|
||||
points[r][c] = point;
|
||||
@ -234,6 +234,11 @@ namespace osu.Game.Rulesets.Osu.Statistics
|
||||
|
||||
private class HitPoint : Circle
|
||||
{
|
||||
/// <summary>
|
||||
/// The base colour which will be lightened/darkened depending on the value of this <see cref="HitPoint"/>.
|
||||
/// </summary>
|
||||
public Color4 BaseColour;
|
||||
|
||||
private readonly HitPointType pointType;
|
||||
private readonly AccuracyHeatmap heatmap;
|
||||
|
||||
@ -284,7 +289,7 @@ namespace osu.Game.Rulesets.Osu.Statistics
|
||||
|
||||
Alpha = Math.Min(amount / lighten_cutoff, 1);
|
||||
if (pointType == HitPointType.Hit)
|
||||
Colour = ((Color4)Colour).Lighten(Math.Max(0, amount - lighten_cutoff));
|
||||
Colour = BaseColour.Lighten(Math.Max(0, amount - lighten_cutoff));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
|
||||
var hitWindows = new OsuHitWindows();
|
||||
foreach (var result in Enum.GetValues(typeof(HitResult)).OfType<HitResult>().Where(r => r > HitResult.None && hitWindows.IsHitResultAllowed(r)))
|
||||
poolDictionary.Add(result, new DrawableJudgementPool(result, onJudgmentLoaded));
|
||||
poolDictionary.Add(result, new DrawableJudgementPool(result, onJudgementLoaded));
|
||||
|
||||
AddRangeInternal(poolDictionary.Values);
|
||||
|
||||
@ -102,7 +102,7 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
}
|
||||
}
|
||||
|
||||
private void onJudgmentLoaded(DrawableOsuJudgement judgement)
|
||||
private void onJudgementLoaded(DrawableOsuJudgement judgement)
|
||||
{
|
||||
judgementAboveHitObjectLayer.Add(judgement.GetProxyAboveHitObjectsContent());
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.Taiko.Skinning.Legacy;
|
||||
using osu.Game.Skinning;
|
||||
@ -27,7 +28,7 @@ namespace osu.Game.Rulesets.Taiko.Tests.Skinning
|
||||
}));
|
||||
|
||||
AddToggleStep("Toggle passing", passing => this.ChildrenOfType<LegacyTaikoScroller>().ForEach(s => s.LastResult.Value =
|
||||
new JudgementResult(null, new Judgement()) { Type = passing ? HitResult.Great : HitResult.Miss }));
|
||||
new JudgementResult(new HitObject(), new Judgement()) { Type = passing ? HitResult.Great : HitResult.Miss }));
|
||||
|
||||
AddToggleStep("toggle playback direction", reversed => this.reversed = reversed);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Mods
|
||||
{
|
||||
@ -10,5 +11,13 @@ namespace osu.Game.Rulesets.Taiko.Mods
|
||||
public override string Description => @"Beats fade out before you hit them!";
|
||||
public override double ScoreMultiplier => 1.06;
|
||||
public override bool HasImplementation => false;
|
||||
|
||||
protected override void ApplyIncreasedVisibilityState(DrawableHitObject hitObject, ArmedState state)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void ApplyNormalVisibilityState(DrawableHitObject hitObject, ArmedState state)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
// 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 System.Linq;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
@ -12,6 +14,7 @@ namespace osu.Game.Rulesets.Taiko.Mods
|
||||
public class TaikoModRandom : ModRandom, IApplicableToBeatmap
|
||||
{
|
||||
public override string Description => @"Shuffle around the colours!";
|
||||
public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(TaikoModSwap)).ToArray();
|
||||
|
||||
public void ApplyToBeatmap(IBeatmap beatmap)
|
||||
{
|
||||
|
33
osu.Game.Rulesets.Taiko/Mods/TaikoModSwap.cs
Normal file
33
osu.Game.Rulesets.Taiko/Mods/TaikoModSwap.cs
Normal file
@ -0,0 +1,33 @@
|
||||
// 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 System.Linq;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Taiko.Beatmaps;
|
||||
using osu.Game.Rulesets.Taiko.Objects;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Mods
|
||||
{
|
||||
public class TaikoModSwap : Mod, IApplicableToBeatmap
|
||||
{
|
||||
public override string Name => "Swap";
|
||||
public override string Acronym => "SW";
|
||||
public override string Description => @"Dons become kats, kats become dons";
|
||||
public override ModType Type => ModType.Conversion;
|
||||
public override double ScoreMultiplier => 1;
|
||||
public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(ModRandom)).ToArray();
|
||||
|
||||
public void ApplyToBeatmap(IBeatmap beatmap)
|
||||
{
|
||||
var taikoBeatmap = (TaikoBeatmap)beatmap;
|
||||
|
||||
foreach (var obj in taikoBeatmap.HitObjects)
|
||||
{
|
||||
if (obj is Hit hit)
|
||||
hit.Type = hit.Type == HitType.Centre ? HitType.Rim : HitType.Centre;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -57,7 +57,7 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy
|
||||
base.Update();
|
||||
|
||||
// store X before checking wide enough so if we perform layout there is no positional discrepancy.
|
||||
float currentX = (InternalChildren?.FirstOrDefault()?.X ?? 0) - (float)Clock.ElapsedFrameTime * 0.1f;
|
||||
float currentX = (InternalChildren.FirstOrDefault()?.X ?? 0) - (float)Clock.ElapsedFrameTime * 0.1f;
|
||||
|
||||
// ensure we have enough sprites
|
||||
if (!InternalChildren.Any()
|
||||
|
@ -136,6 +136,7 @@ namespace osu.Game.Rulesets.Taiko
|
||||
new TaikoModRandom(),
|
||||
new TaikoModDifficultyAdjust(),
|
||||
new TaikoModClassic(),
|
||||
new TaikoModSwap(),
|
||||
};
|
||||
|
||||
case ModType.Automation:
|
||||
|
@ -12,6 +12,7 @@ using osu.Framework.Platform;
|
||||
using osu.Game.IPC;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Extensions.ObjectExtensions;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Database;
|
||||
@ -264,7 +265,7 @@ namespace osu.Game.Tests.Beatmaps.IO
|
||||
|
||||
// change filename
|
||||
var firstFile = new FileInfo(Directory.GetFiles(extractedFolder).First());
|
||||
firstFile.MoveTo(Path.Combine(firstFile.DirectoryName, $"{firstFile.Name}-changed{firstFile.Extension}"));
|
||||
firstFile.MoveTo(Path.Combine(firstFile.DirectoryName.AsNonNull(), $"{firstFile.Name}-changed{firstFile.Extension}"));
|
||||
|
||||
using (var zip = ZipArchive.Create())
|
||||
{
|
||||
|
@ -6,6 +6,7 @@ using Moq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Edit.Checks;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
|
||||
@ -40,23 +41,23 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
mock.SetupGet(w => w.Beatmap).Returns(beatmap);
|
||||
mock.SetupGet(w => w.Track).Returns((Track)null);
|
||||
|
||||
Assert.That(check.Run(beatmap, mock.Object), Is.Empty);
|
||||
Assert.That(check.Run(new BeatmapVerifierContext(beatmap, mock.Object)), Is.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAcceptable()
|
||||
{
|
||||
var mock = getMockWorkingBeatmap(192);
|
||||
var context = getContext(192);
|
||||
|
||||
Assert.That(check.Run(beatmap, mock.Object), Is.Empty);
|
||||
Assert.That(check.Run(context), Is.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNullBitrate()
|
||||
{
|
||||
var mock = getMockWorkingBeatmap(null);
|
||||
var context = getContext(null);
|
||||
|
||||
var issues = check.Run(beatmap, mock.Object).ToList();
|
||||
var issues = check.Run(context).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(1));
|
||||
Assert.That(issues.Single().Template is CheckAudioQuality.IssueTemplateNoBitrate);
|
||||
@ -65,9 +66,9 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
[Test]
|
||||
public void TestZeroBitrate()
|
||||
{
|
||||
var mock = getMockWorkingBeatmap(0);
|
||||
var context = getContext(0);
|
||||
|
||||
var issues = check.Run(beatmap, mock.Object).ToList();
|
||||
var issues = check.Run(context).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(1));
|
||||
Assert.That(issues.Single().Template is CheckAudioQuality.IssueTemplateNoBitrate);
|
||||
@ -76,9 +77,9 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
[Test]
|
||||
public void TestTooHighBitrate()
|
||||
{
|
||||
var mock = getMockWorkingBeatmap(320);
|
||||
var context = getContext(320);
|
||||
|
||||
var issues = check.Run(beatmap, mock.Object).ToList();
|
||||
var issues = check.Run(context).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(1));
|
||||
Assert.That(issues.Single().Template is CheckAudioQuality.IssueTemplateTooHighBitrate);
|
||||
@ -87,14 +88,19 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
[Test]
|
||||
public void TestTooLowBitrate()
|
||||
{
|
||||
var mock = getMockWorkingBeatmap(64);
|
||||
var context = getContext(64);
|
||||
|
||||
var issues = check.Run(beatmap, mock.Object).ToList();
|
||||
var issues = check.Run(context).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(1));
|
||||
Assert.That(issues.Single().Template is CheckAudioQuality.IssueTemplateTooLowBitrate);
|
||||
}
|
||||
|
||||
private BeatmapVerifierContext getContext(int? audioBitrate)
|
||||
{
|
||||
return new BeatmapVerifierContext(beatmap, getMockWorkingBeatmap(audioBitrate).Object);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the mock of the working beatmap with the given audio properties.
|
||||
/// </summary>
|
||||
|
@ -9,6 +9,7 @@ using Moq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Edit.Checks;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using FileInfo = osu.Game.IO.FileInfo;
|
||||
@ -53,25 +54,25 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
{
|
||||
// While this is a problem, it is out of scope for this check and is caught by a different one.
|
||||
beatmap.Metadata.BackgroundFile = null;
|
||||
var mock = getMockWorkingBeatmap(null, System.Array.Empty<byte>());
|
||||
var context = getContext(null, System.Array.Empty<byte>());
|
||||
|
||||
Assert.That(check.Run(beatmap, mock.Object), Is.Empty);
|
||||
Assert.That(check.Run(context), Is.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAcceptable()
|
||||
{
|
||||
var mock = getMockWorkingBeatmap(new Texture(1920, 1080));
|
||||
var context = getContext(new Texture(1920, 1080));
|
||||
|
||||
Assert.That(check.Run(beatmap, mock.Object), Is.Empty);
|
||||
Assert.That(check.Run(context), Is.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestTooHighResolution()
|
||||
{
|
||||
var mock = getMockWorkingBeatmap(new Texture(3840, 2160));
|
||||
var context = getContext(new Texture(3840, 2160));
|
||||
|
||||
var issues = check.Run(beatmap, mock.Object).ToList();
|
||||
var issues = check.Run(context).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(1));
|
||||
Assert.That(issues.Single().Template is CheckBackgroundQuality.IssueTemplateTooHighResolution);
|
||||
@ -80,9 +81,9 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
[Test]
|
||||
public void TestLowResolution()
|
||||
{
|
||||
var mock = getMockWorkingBeatmap(new Texture(640, 480));
|
||||
var context = getContext(new Texture(640, 480));
|
||||
|
||||
var issues = check.Run(beatmap, mock.Object).ToList();
|
||||
var issues = check.Run(context).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(1));
|
||||
Assert.That(issues.Single().Template is CheckBackgroundQuality.IssueTemplateLowResolution);
|
||||
@ -91,9 +92,9 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
[Test]
|
||||
public void TestTooLowResolution()
|
||||
{
|
||||
var mock = getMockWorkingBeatmap(new Texture(100, 100));
|
||||
var context = getContext(new Texture(100, 100));
|
||||
|
||||
var issues = check.Run(beatmap, mock.Object).ToList();
|
||||
var issues = check.Run(context).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(1));
|
||||
Assert.That(issues.Single().Template is CheckBackgroundQuality.IssueTemplateTooLowResolution);
|
||||
@ -102,14 +103,19 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
[Test]
|
||||
public void TestTooUncompressed()
|
||||
{
|
||||
var mock = getMockWorkingBeatmap(new Texture(1920, 1080), new byte[1024 * 1024 * 3]);
|
||||
var context = getContext(new Texture(1920, 1080), new byte[1024 * 1024 * 3]);
|
||||
|
||||
var issues = check.Run(beatmap, mock.Object).ToList();
|
||||
var issues = check.Run(context).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(1));
|
||||
Assert.That(issues.Single().Template is CheckBackgroundQuality.IssueTemplateTooUncompressed);
|
||||
}
|
||||
|
||||
private BeatmapVerifierContext getContext(Texture background, [CanBeNull] byte[] fileBytes = null)
|
||||
{
|
||||
return new BeatmapVerifierContext(beatmap, getMockWorkingBeatmap(background, fileBytes).Object);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the mock of the working beatmap with the given background and filesize.
|
||||
/// </summary>
|
||||
|
@ -6,11 +6,13 @@ using System.Linq;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Edit.Checks;
|
||||
using osu.Game.Rulesets.Mania.Objects;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
|
||||
namespace osu.Game.Tests.Editing.Checks
|
||||
{
|
||||
@ -105,7 +107,7 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
new HitCircle { StartTime = 300 }
|
||||
};
|
||||
|
||||
var issues = check.Run(getPlayableBeatmap(hitobjects), null).ToList();
|
||||
var issues = check.Run(getContext(hitobjects)).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(3));
|
||||
Assert.That(issues.Where(issue => issue.Template is CheckConcurrentObjects.IssueTemplateConcurrentDifferent).ToList(), Has.Count.EqualTo(2));
|
||||
@ -164,12 +166,12 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
|
||||
private void assertOk(List<HitObject> hitobjects)
|
||||
{
|
||||
Assert.That(check.Run(getPlayableBeatmap(hitobjects), null), Is.Empty);
|
||||
Assert.That(check.Run(getContext(hitobjects)), Is.Empty);
|
||||
}
|
||||
|
||||
private void assertConcurrentSame(List<HitObject> hitobjects, int count = 1)
|
||||
{
|
||||
var issues = check.Run(getPlayableBeatmap(hitobjects), null).ToList();
|
||||
var issues = check.Run(getContext(hitobjects)).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(count));
|
||||
Assert.That(issues.All(issue => issue.Template is CheckConcurrentObjects.IssueTemplateConcurrentSame));
|
||||
@ -177,18 +179,16 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
|
||||
private void assertConcurrentDifferent(List<HitObject> hitobjects, int count = 1)
|
||||
{
|
||||
var issues = check.Run(getPlayableBeatmap(hitobjects), null).ToList();
|
||||
var issues = check.Run(getContext(hitobjects)).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(count));
|
||||
Assert.That(issues.All(issue => issue.Template is CheckConcurrentObjects.IssueTemplateConcurrentDifferent));
|
||||
}
|
||||
|
||||
private IBeatmap getPlayableBeatmap(List<HitObject> hitobjects)
|
||||
private BeatmapVerifierContext getContext(List<HitObject> hitobjects)
|
||||
{
|
||||
return new Beatmap<HitObject>
|
||||
{
|
||||
HitObjects = hitobjects
|
||||
};
|
||||
var beatmap = new Beatmap<HitObject> { HitObjects = hitobjects };
|
||||
return new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.IO;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Edit.Checks;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
@ -45,7 +46,8 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
[Test]
|
||||
public void TestBackgroundSetAndInFiles()
|
||||
{
|
||||
Assert.That(check.Run(beatmap, new TestWorkingBeatmap(beatmap)), Is.Empty);
|
||||
var context = new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap));
|
||||
Assert.That(check.Run(context), Is.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -53,7 +55,8 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
{
|
||||
beatmap.BeatmapInfo.BeatmapSet.Files.Clear();
|
||||
|
||||
var issues = check.Run(beatmap, new TestWorkingBeatmap(beatmap)).ToList();
|
||||
var context = new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap));
|
||||
var issues = check.Run(context).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(1));
|
||||
Assert.That(issues.Single().Template is CheckFilePresence.IssueTemplateDoesNotExist);
|
||||
@ -64,7 +67,8 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
{
|
||||
beatmap.Metadata.BackgroundFile = null;
|
||||
|
||||
var issues = check.Run(beatmap, new TestWorkingBeatmap(beatmap)).ToList();
|
||||
var context = new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap));
|
||||
var issues = check.Run(context).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(1));
|
||||
Assert.That(issues.Single().Template is CheckFilePresence.IssueTemplateNoneSet);
|
||||
|
@ -7,10 +7,12 @@ using Moq;
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Edit.Checks;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
|
||||
namespace osu.Game.Tests.Editing.Checks
|
||||
{
|
||||
@ -100,12 +102,12 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
}, count: 2);
|
||||
|
||||
// Start and end are 2 ms and 1.25 ms off respectively, hence two different issues in one object.
|
||||
var hitobjects = new List<HitObject>
|
||||
var hitObjects = new List<HitObject>
|
||||
{
|
||||
getSliderMock(startTime: 98, endTime: 398.75d).Object
|
||||
};
|
||||
|
||||
var issues = check.Run(getPlayableBeatmap(hitobjects), null).ToList();
|
||||
var issues = check.Run(getContext(hitObjects)).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(2));
|
||||
Assert.That(issues.Any(issue => issue.Template is CheckUnsnappedObjects.IssueTemplateSmallUnsnap));
|
||||
@ -122,34 +124,36 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
return mockSlider;
|
||||
}
|
||||
|
||||
private void assertOk(List<HitObject> hitobjects)
|
||||
private void assertOk(List<HitObject> hitObjects)
|
||||
{
|
||||
Assert.That(check.Run(getPlayableBeatmap(hitobjects), null), Is.Empty);
|
||||
Assert.That(check.Run(getContext(hitObjects)), Is.Empty);
|
||||
}
|
||||
|
||||
private void assert1Ms(List<HitObject> hitobjects, int count = 1)
|
||||
private void assert1Ms(List<HitObject> hitObjects, int count = 1)
|
||||
{
|
||||
var issues = check.Run(getPlayableBeatmap(hitobjects), null).ToList();
|
||||
var issues = check.Run(getContext(hitObjects)).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(count));
|
||||
Assert.That(issues.All(issue => issue.Template is CheckUnsnappedObjects.IssueTemplateSmallUnsnap));
|
||||
}
|
||||
|
||||
private void assert2Ms(List<HitObject> hitobjects, int count = 1)
|
||||
private void assert2Ms(List<HitObject> hitObjects, int count = 1)
|
||||
{
|
||||
var issues = check.Run(getPlayableBeatmap(hitobjects), null).ToList();
|
||||
var issues = check.Run(getContext(hitObjects)).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(count));
|
||||
Assert.That(issues.All(issue => issue.Template is CheckUnsnappedObjects.IssueTemplateLargeUnsnap));
|
||||
}
|
||||
|
||||
private IBeatmap getPlayableBeatmap(List<HitObject> hitobjects)
|
||||
private BeatmapVerifierContext getContext(List<HitObject> hitObjects)
|
||||
{
|
||||
return new Beatmap<HitObject>
|
||||
var beatmap = new Beatmap<HitObject>
|
||||
{
|
||||
ControlPointInfo = cpi,
|
||||
HitObjects = hitobjects
|
||||
HitObjects = hitObjects
|
||||
};
|
||||
|
||||
return new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ namespace osu.Game.Tests.Mods
|
||||
if (isValid)
|
||||
Assert.IsNull(invalid);
|
||||
else
|
||||
Assert.That(invalid?.Select(t => t.GetType()), Is.EquivalentTo(expectedInvalid));
|
||||
Assert.That(invalid.Select(t => t.GetType()), Is.EquivalentTo(expectedInvalid));
|
||||
}
|
||||
|
||||
public abstract class CustomMod1 : Mod
|
||||
|
@ -4,6 +4,7 @@
|
||||
using System.Linq;
|
||||
using Humanizer;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Extensions.ObjectExtensions;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Tests.Visual.Multiplayer;
|
||||
@ -34,7 +35,7 @@ namespace osu.Game.Tests.NonVisual.Multiplayer
|
||||
changeState(6, MultiplayerUserState.WaitingForLoad);
|
||||
checkPlayingUserCount(6);
|
||||
|
||||
AddStep("another user left", () => Client.RemoveUser(Client.Room?.Users.Last().User));
|
||||
AddStep("another user left", () => Client.RemoveUser((Client.Room?.Users.Last().User).AsNonNull()));
|
||||
checkPlayingUserCount(5);
|
||||
|
||||
AddStep("leave room", () => Client.LeaveRoom());
|
||||
|
@ -167,5 +167,21 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
AddStep("move mouse away", () => InputManager.MoveMouseTo(selectionBox, new Vector2(20)));
|
||||
AddUntilStep("rotation handle hidden", () => rotationHandle.Alpha == 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests that hovering over two handles instantaneously from one to another does not crash or cause issues to the visibility state.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestHoverOverTwoHandlesInstantaneously()
|
||||
{
|
||||
AddStep("hover over top-left scale handle", () =>
|
||||
InputManager.MoveMouseTo(this.ChildrenOfType<SelectionBoxScaleHandle>().Single(s => s.Anchor == Anchor.TopLeft)));
|
||||
AddStep("hover over top-right scale handle", () =>
|
||||
InputManager.MoveMouseTo(this.ChildrenOfType<SelectionBoxScaleHandle>().Single(s => s.Anchor == Anchor.TopRight)));
|
||||
AddUntilStep("top-left rotation handle hidden", () =>
|
||||
this.ChildrenOfType<SelectionBoxRotationHandle>().Single(r => r.Anchor == Anchor.TopLeft).Alpha == 0);
|
||||
AddUntilStep("top-right rotation handle shown", () =>
|
||||
this.ChildrenOfType<SelectionBoxRotationHandle>().Single(r => r.Anchor == Anchor.TopRight).Alpha == 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
private void seekToBreak(int breakIndex)
|
||||
{
|
||||
AddStep($"seek to break {breakIndex}", () => Player.GameplayClockContainer.Seek(destBreak().StartTime));
|
||||
AddUntilStep("wait for seek to complete", () => Player.HUDOverlay.Progress.ReferenceClock.CurrentTime >= destBreak().StartTime);
|
||||
AddUntilStep("wait for seek to complete", () => Player.DrawableRuleset.FrameStableClock.CurrentTime >= destBreak().StartTime);
|
||||
|
||||
BreakPeriod destBreak() => Beatmap.Value.Beatmap.Breaks.ElementAt(breakIndex);
|
||||
}
|
||||
|
@ -1,22 +1,18 @@
|
||||
// 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.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Screens.Play.HUD;
|
||||
using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
public class TestSceneComboCounter : SkinnableTestScene
|
||||
{
|
||||
private IEnumerable<SkinnableComboCounter> comboCounters => CreatedDrawables.OfType<SkinnableComboCounter>();
|
||||
|
||||
protected override Ruleset CreateRulesetForSkinProvider() => new OsuRuleset();
|
||||
|
||||
[Cached]
|
||||
@ -25,7 +21,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[SetUpSteps]
|
||||
public void SetUpSteps()
|
||||
{
|
||||
AddStep("Create combo counters", () => SetContents(() => new SkinnableComboCounter()));
|
||||
AddStep("Create combo counters", () => SetContents(() => new SkinnableDrawable(new HUDSkinComponent(HUDSkinComponents.ComboCounter))));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -2,10 +2,12 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Skinning;
|
||||
using osu.Game.Skinning.Editor;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
@ -14,12 +16,17 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
private SkinEditor skinEditor;
|
||||
|
||||
[Resolved]
|
||||
private SkinManager skinManager { get; set; }
|
||||
|
||||
protected override bool Autoplay => true;
|
||||
|
||||
[SetUpSteps]
|
||||
public override void SetUpSteps()
|
||||
{
|
||||
base.SetUpSteps();
|
||||
|
||||
AddStep("add editor overlay", () =>
|
||||
AddStep("reload skin editor", () =>
|
||||
{
|
||||
skinEditor?.Expire();
|
||||
Player.ScaleTo(SkinEditorOverlay.VISIBLE_TARGET_SCALE);
|
||||
|
@ -1,13 +1,11 @@
|
||||
// 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 osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Screens.Play;
|
||||
@ -32,12 +30,13 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
SetContents(() =>
|
||||
{
|
||||
var ruleset = new OsuRuleset();
|
||||
var mods = new[] { ruleset.GetAutoplayMod() };
|
||||
var working = CreateWorkingBeatmap(ruleset.RulesetInfo);
|
||||
var beatmap = working.GetPlayableBeatmap(ruleset.RulesetInfo);
|
||||
var beatmap = working.GetPlayableBeatmap(ruleset.RulesetInfo, mods);
|
||||
|
||||
var drawableRuleset = ruleset.CreateDrawableRulesetWith(beatmap);
|
||||
var drawableRuleset = ruleset.CreateDrawableRulesetWith(beatmap, mods);
|
||||
|
||||
var hudOverlay = new HUDOverlay(drawableRuleset, Array.Empty<Mod>())
|
||||
var hudOverlay = new HUDOverlay(drawableRuleset, mods)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
|
@ -7,7 +7,7 @@ using osu.Framework.Testing;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Screens.Play.HUD;
|
||||
using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
@ -22,7 +22,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
public void SetUpSteps()
|
||||
{
|
||||
AddStep("Set initial accuracy", () => scoreProcessor.Accuracy.Value = 1);
|
||||
AddStep("Create accuracy counters", () => SetContents(() => new SkinnableAccuracyCounter()));
|
||||
AddStep("Create accuracy counters", () => SetContents(() => new SkinnableDrawable(new HUDSkinComponent(HUDSkinComponents.AccuracyCounter))));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -1,8 +1,6 @@
|
||||
// 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.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Testing;
|
||||
@ -12,14 +10,12 @@ using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Osu.Judgements;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Screens.Play.HUD;
|
||||
using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
public class TestSceneSkinnableHealthDisplay : SkinnableTestScene
|
||||
{
|
||||
private IEnumerable<SkinnableHealthDisplay> healthDisplays => CreatedDrawables.OfType<SkinnableHealthDisplay>();
|
||||
|
||||
protected override Ruleset CreateRulesetForSkinProvider() => new OsuRuleset();
|
||||
|
||||
[Cached(typeof(HealthProcessor))]
|
||||
@ -28,10 +24,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[SetUpSteps]
|
||||
public void SetUpSteps()
|
||||
{
|
||||
AddStep("Create health displays", () =>
|
||||
{
|
||||
SetContents(() => new SkinnableHealthDisplay());
|
||||
});
|
||||
AddStep("Create health displays", () => SetContents(() => new SkinnableDrawable(new HUDSkinComponent(HUDSkinComponents.HealthDisplay))));
|
||||
AddStep(@"Reset all", delegate
|
||||
{
|
||||
healthProcessor.Health.Value = 1;
|
||||
|
@ -1,23 +1,18 @@
|
||||
// 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.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Screens.Play.HUD;
|
||||
using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
public class TestSceneSkinnableScoreCounter : SkinnableTestScene
|
||||
{
|
||||
private IEnumerable<SkinnableScoreCounter> scoreCounters => CreatedDrawables.OfType<SkinnableScoreCounter>();
|
||||
|
||||
protected override Ruleset CreateRulesetForSkinProvider() => new OsuRuleset();
|
||||
|
||||
[Cached]
|
||||
@ -26,7 +21,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[SetUpSteps]
|
||||
public void SetUpSteps()
|
||||
{
|
||||
AddStep("Create score counters", () => SetContents(() => new SkinnableScoreCounter()));
|
||||
AddStep("Create score counters", () => SetContents(() => new SkinnableDrawable(new HUDSkinComponent(HUDSkinComponents.ScoreCounter))));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -40,7 +35,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Test]
|
||||
public void TestVeryLargeScore()
|
||||
{
|
||||
AddStep("set large score", () => scoreCounters.ForEach(counter => scoreProcessor.TotalScore.Value = 1_000_000_000));
|
||||
AddStep("set large score", () => scoreProcessor.TotalScore.Value = 1_000_000_000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.ObjectExtensions;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
@ -45,14 +46,14 @@ namespace osu.Game.Tests.Visual.Online
|
||||
switch (args.Action)
|
||||
{
|
||||
case NotifyCollectionChangedAction.Add:
|
||||
args.NewItems.Cast<Mod>().ForEach(mod => selectedMods.Add(new OsuSpriteText
|
||||
args.NewItems.AsNonNull().Cast<Mod>().ForEach(mod => selectedMods.Add(new OsuSpriteText
|
||||
{
|
||||
Text = mod.Acronym,
|
||||
}));
|
||||
break;
|
||||
|
||||
case NotifyCollectionChangedAction.Remove:
|
||||
args.OldItems.Cast<Mod>().ForEach(mod =>
|
||||
args.OldItems.AsNonNull().Cast<Mod>().ForEach(mod =>
|
||||
{
|
||||
foreach (var selected in selectedMods)
|
||||
{
|
||||
|
@ -11,11 +11,13 @@ using osu.Framework.Platform;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Screens.OnlinePlay;
|
||||
using osu.Game.Screens.OnlinePlay.Playlists;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
using osu.Game.Users;
|
||||
using osuTK.Input;
|
||||
@ -24,8 +26,6 @@ namespace osu.Game.Tests.Visual.Playlists
|
||||
{
|
||||
public class TestScenePlaylistsRoomSubScreen : RoomTestScene
|
||||
{
|
||||
protected override bool UseOnlineAPI => true;
|
||||
|
||||
[Cached(typeof(IRoomManager))]
|
||||
private readonly TestRoomManager roomManager = new TestRoomManager();
|
||||
|
||||
@ -41,6 +41,18 @@ namespace osu.Game.Tests.Visual.Playlists
|
||||
Dependencies.Cache(manager = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, host, Beatmap.Default));
|
||||
|
||||
manager.Import(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo.BeatmapSet).Wait();
|
||||
|
||||
((DummyAPIAccess)API).HandleRequest = req =>
|
||||
{
|
||||
switch (req)
|
||||
{
|
||||
case CreateRoomScoreRequest createRoomScoreRequest:
|
||||
createRoomScoreRequest.TriggerSuccess(new APIScoreToken { ID = 1 });
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
[SetUpSteps]
|
||||
@ -59,12 +71,16 @@ namespace osu.Game.Tests.Visual.Playlists
|
||||
Room.Name.Value = "my awesome room";
|
||||
Room.Host.Value = new User { Id = 2, Username = "peppy" };
|
||||
Room.RecentParticipants.Add(Room.Host.Value);
|
||||
Room.EndDate.Value = DateTimeOffset.Now.AddMinutes(5);
|
||||
Room.Playlist.Add(new PlaylistItem
|
||||
{
|
||||
Beatmap = { Value = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo },
|
||||
Ruleset = { Value = new OsuRuleset().RulesetInfo }
|
||||
});
|
||||
});
|
||||
|
||||
AddStep("start match", () => match.ChildrenOfType<PlaylistsReadyButton>().First().Click());
|
||||
AddUntilStep("player loader loaded", () => Stack.CurrentScreen is PlayerLoader);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -1,32 +1,65 @@
|
||||
// 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.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Screens.Ranking.Expanded;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Ranking
|
||||
{
|
||||
public class TestSceneStarRatingDisplay : OsuTestScene
|
||||
{
|
||||
public TestSceneStarRatingDisplay()
|
||||
[Test]
|
||||
public void TestDisplay()
|
||||
{
|
||||
Child = new FillFlowContainer
|
||||
AddStep("load displays", () => Child = new FillFlowContainer
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Children = new Drawable[]
|
||||
ChildrenEnumerable = new[]
|
||||
{
|
||||
new StarRatingDisplay(new StarDifficulty(1.23, 0)),
|
||||
new StarRatingDisplay(new StarDifficulty(2.34, 0)),
|
||||
new StarRatingDisplay(new StarDifficulty(3.45, 0)),
|
||||
new StarRatingDisplay(new StarDifficulty(4.56, 0)),
|
||||
new StarRatingDisplay(new StarDifficulty(5.67, 0)),
|
||||
new StarRatingDisplay(new StarDifficulty(6.78, 0)),
|
||||
new StarRatingDisplay(new StarDifficulty(10.11, 0)),
|
||||
}
|
||||
};
|
||||
1.23,
|
||||
2.34,
|
||||
3.45,
|
||||
4.56,
|
||||
5.67,
|
||||
6.78,
|
||||
10.11,
|
||||
}.Select(starRating => new StarRatingDisplay(new StarDifficulty(starRating, 0))
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestChangingStarRatingDisplay()
|
||||
{
|
||||
StarRatingDisplay starRating = null;
|
||||
|
||||
AddStep("load display", () => Child = starRating = new StarRatingDisplay(new StarDifficulty(5.55, 1))
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Scale = new Vector2(3f),
|
||||
});
|
||||
|
||||
AddRepeatStep("set random value", () =>
|
||||
{
|
||||
starRating.Current.Value = new StarDifficulty(RNG.NextDouble(0.0, 11.0), 1);
|
||||
}, 10);
|
||||
|
||||
AddSliderStep("set exact stars", 0.0, 11.0, 5.55, d =>
|
||||
{
|
||||
if (starRating != null)
|
||||
starRating.Current.Value = new StarDifficulty(d, 1);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,151 @@
|
||||
// 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 System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Screens.Menu;
|
||||
using osu.Game.Screens.Play;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual.SongSelect
|
||||
{
|
||||
public class TestSceneBeatmapMetadataDisplay : OsuTestScene
|
||||
{
|
||||
private BeatmapMetadataDisplay display;
|
||||
|
||||
[Resolved]
|
||||
private BeatmapManager manager { get; set; }
|
||||
|
||||
[Cached(typeof(BeatmapDifficultyCache))]
|
||||
private readonly TestBeatmapDifficultyCache testDifficultyCache = new TestBeatmapDifficultyCache();
|
||||
|
||||
[Test]
|
||||
public void TestLocal([Values("Beatmap", "Some long title and stuff")]
|
||||
string title,
|
||||
[Values("Trial", "Some1's very hardest difficulty")]
|
||||
string version)
|
||||
{
|
||||
showMetadataForBeatmap(() => CreateWorkingBeatmap(new Beatmap
|
||||
{
|
||||
BeatmapInfo =
|
||||
{
|
||||
Metadata = new BeatmapMetadata
|
||||
{
|
||||
Title = title,
|
||||
},
|
||||
Version = version,
|
||||
StarDifficulty = RNG.NextDouble(0, 10),
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDelayedStarRating()
|
||||
{
|
||||
AddStep("block calculation", () => testDifficultyCache.BlockCalculation = true);
|
||||
|
||||
showMetadataForBeatmap(() => CreateWorkingBeatmap(new Beatmap
|
||||
{
|
||||
BeatmapInfo =
|
||||
{
|
||||
Metadata = new BeatmapMetadata
|
||||
{
|
||||
Title = "Heavy beatmap",
|
||||
},
|
||||
Version = "10k objects",
|
||||
StarDifficulty = 99.99f,
|
||||
}
|
||||
}));
|
||||
|
||||
AddStep("allow calculation", () => testDifficultyCache.BlockCalculation = false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRandomFromDatabase()
|
||||
{
|
||||
showMetadataForBeatmap(() =>
|
||||
{
|
||||
var allBeatmapSets = manager.GetAllUsableBeatmapSets(IncludedDetails.Minimal);
|
||||
if (allBeatmapSets.Count == 0)
|
||||
return manager.DefaultBeatmap;
|
||||
|
||||
var randomBeatmapSet = allBeatmapSets[RNG.Next(0, allBeatmapSets.Count - 1)];
|
||||
var randomBeatmap = randomBeatmapSet.Beatmaps[RNG.Next(0, randomBeatmapSet.Beatmaps.Count - 1)];
|
||||
|
||||
return manager.GetWorkingBeatmap(randomBeatmap);
|
||||
});
|
||||
}
|
||||
|
||||
private void showMetadataForBeatmap(Func<WorkingBeatmap> getBeatmap)
|
||||
{
|
||||
AddStep("setup display", () =>
|
||||
{
|
||||
var randomMods = Ruleset.Value.CreateInstance().GetAllMods().OrderBy(_ => RNG.Next()).Take(5).ToList();
|
||||
|
||||
OsuLogo logo = new OsuLogo { Scale = new Vector2(0.15f) };
|
||||
|
||||
Remove(testDifficultyCache);
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
testDifficultyCache,
|
||||
display = new BeatmapMetadataDisplay(getBeatmap(), new Bindable<IReadOnlyList<Mod>>(randomMods), logo)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Alpha = 0f,
|
||||
}
|
||||
};
|
||||
|
||||
display.FadeIn(400, Easing.OutQuint);
|
||||
});
|
||||
|
||||
AddWaitStep("wait a bit", 5);
|
||||
|
||||
AddStep("finish loading", () => display.Loading = false);
|
||||
}
|
||||
|
||||
private class TestBeatmapDifficultyCache : BeatmapDifficultyCache
|
||||
{
|
||||
private TaskCompletionSource<bool> calculationBlocker;
|
||||
|
||||
private bool blockCalculation;
|
||||
|
||||
public bool BlockCalculation
|
||||
{
|
||||
get => blockCalculation;
|
||||
set
|
||||
{
|
||||
if (value == blockCalculation)
|
||||
return;
|
||||
|
||||
blockCalculation = value;
|
||||
|
||||
if (value)
|
||||
calculationBlocker = new TaskCompletionSource<bool>();
|
||||
else
|
||||
calculationBlocker?.SetResult(false);
|
||||
}
|
||||
}
|
||||
|
||||
public override async Task<StarDifficulty> GetDifficultyAsync(BeatmapInfo beatmapInfo, RulesetInfo rulesetInfo = null, IEnumerable<Mod> mods = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (blockCalculation)
|
||||
await calculationBlocker.Task;
|
||||
|
||||
return await base.GetDifficultyAsync(beatmapInfo, rulesetInfo, mods, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -264,7 +264,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
|
||||
private void moveLogoFacade()
|
||||
{
|
||||
if (!(logoFacade?.Transforms).Any() && !(transferContainer?.Transforms).Any())
|
||||
if (!logoFacade.Transforms.Any() && !transferContainer.Transforms.Any())
|
||||
{
|
||||
Random random = new Random();
|
||||
trackingContainer.Delay(500).MoveTo(new Vector2(random.Next(0, (int)logo.Parent.DrawWidth), random.Next(0, (int)logo.Parent.DrawHeight)), 300);
|
||||
|
@ -7,6 +7,7 @@ using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Microsoft.Win32;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.ObjectExtensions;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Threading;
|
||||
@ -77,8 +78,8 @@ namespace osu.Game.Tournament.IPC
|
||||
using (var stream = IPCStorage.GetStream(file_ipc_filename))
|
||||
using (var sr = new StreamReader(stream))
|
||||
{
|
||||
var beatmapId = int.Parse(sr.ReadLine());
|
||||
var mods = int.Parse(sr.ReadLine());
|
||||
var beatmapId = int.Parse(sr.ReadLine().AsNonNull());
|
||||
var mods = int.Parse(sr.ReadLine().AsNonNull());
|
||||
|
||||
if (lastBeatmapId != beatmapId)
|
||||
{
|
||||
@ -124,7 +125,7 @@ namespace osu.Game.Tournament.IPC
|
||||
using (var stream = IPCStorage.GetStream(file_ipc_state_filename))
|
||||
using (var sr = new StreamReader(stream))
|
||||
{
|
||||
State.Value = (TourneyState)Enum.Parse(typeof(TourneyState), sr.ReadLine());
|
||||
State.Value = (TourneyState)Enum.Parse(typeof(TourneyState), sr.ReadLine().AsNonNull());
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
|
@ -103,8 +103,8 @@ namespace osu.Game.Beatmaps
|
||||
/// <param name="mods">The <see cref="Mod"/>s to get the difficulty with.</param>
|
||||
/// <param name="cancellationToken">An optional <see cref="CancellationToken"/> which stops computing the star difficulty.</param>
|
||||
/// <returns>The <see cref="StarDifficulty"/>.</returns>
|
||||
public Task<StarDifficulty> GetDifficultyAsync([NotNull] BeatmapInfo beatmapInfo, [CanBeNull] RulesetInfo rulesetInfo = null, [CanBeNull] IEnumerable<Mod> mods = null,
|
||||
CancellationToken cancellationToken = default)
|
||||
public virtual Task<StarDifficulty> GetDifficultyAsync([NotNull] BeatmapInfo beatmapInfo, [CanBeNull] RulesetInfo rulesetInfo = null,
|
||||
[CanBeNull] IEnumerable<Mod> mods = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
// In the case that the user hasn't given us a ruleset, use the beatmap's default ruleset.
|
||||
rulesetInfo ??= beatmapInfo.Ruleset;
|
||||
|
@ -7,6 +7,7 @@ using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.IO.Serialization;
|
||||
@ -127,6 +128,8 @@ namespace osu.Game.Beatmaps
|
||||
// Metadata
|
||||
public string Version { get; set; }
|
||||
|
||||
private string versionString => string.IsNullOrEmpty(Version) ? string.Empty : $"[{Version}]";
|
||||
|
||||
[JsonProperty("difficulty_rating")]
|
||||
public double StarDifficulty { get; set; }
|
||||
|
||||
@ -143,11 +146,12 @@ namespace osu.Game.Beatmaps
|
||||
Version
|
||||
}.Concat(Metadata?.SearchableTerms ?? Enumerable.Empty<string>()).Where(s => !string.IsNullOrEmpty(s)).ToArray();
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string version = string.IsNullOrEmpty(Version) ? string.Empty : $"[{Version}]";
|
||||
public override string ToString() => $"{Metadata ?? BeatmapSet?.Metadata} {versionString}".Trim();
|
||||
|
||||
return $"{Metadata ?? BeatmapSet?.Metadata} {version}".Trim();
|
||||
public RomanisableString ToRomanisableString()
|
||||
{
|
||||
var metadata = (Metadata ?? BeatmapSet?.Metadata)?.ToRomanisableString() ?? new RomanisableString(null, null);
|
||||
return new RomanisableString($"{metadata.GetPreferred(true)} {versionString}".Trim(), $"{metadata.GetPreferred(false)} {versionString}".Trim());
|
||||
}
|
||||
|
||||
public bool Equals(BeatmapInfo other)
|
||||
|
@ -2,7 +2,6 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
@ -83,6 +82,12 @@ namespace osu.Game.Beatmaps
|
||||
beatmap.BeatmapSet.OnlineBeatmapSetID = res.OnlineBeatmapSetID;
|
||||
beatmap.OnlineBeatmapID = res.OnlineBeatmapID;
|
||||
|
||||
if (beatmap.Metadata != null)
|
||||
beatmap.Metadata.AuthorID = res.AuthorID;
|
||||
|
||||
if (beatmap.BeatmapSet.Metadata != null)
|
||||
beatmap.BeatmapSet.Metadata.AuthorID = res.AuthorID;
|
||||
|
||||
LogForModel(set, $"Online retrieval mapped {beatmap} to {res.OnlineBeatmapSetID} / {res.OnlineBeatmapID}.");
|
||||
}
|
||||
}
|
||||
@ -157,7 +162,7 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
using (var cmd = db.CreateCommand())
|
||||
{
|
||||
cmd.CommandText = "SELECT beatmapset_id, beatmap_id, approved FROM osu_beatmaps WHERE checksum = @MD5Hash OR beatmap_id = @OnlineBeatmapID OR filename = @Path";
|
||||
cmd.CommandText = "SELECT beatmapset_id, beatmap_id, approved, user_id FROM osu_beatmaps WHERE checksum = @MD5Hash OR beatmap_id = @OnlineBeatmapID OR filename = @Path";
|
||||
|
||||
cmd.Parameters.Add(new SqliteParameter("@MD5Hash", beatmap.MD5Hash));
|
||||
cmd.Parameters.Add(new SqliteParameter("@OnlineBeatmapID", beatmap.OnlineBeatmapID ?? (object)DBNull.Value));
|
||||
@ -174,6 +179,12 @@ namespace osu.Game.Beatmaps
|
||||
beatmap.BeatmapSet.OnlineBeatmapSetID = reader.GetInt32(0);
|
||||
beatmap.OnlineBeatmapID = reader.GetInt32(1);
|
||||
|
||||
if (beatmap.Metadata != null)
|
||||
beatmap.Metadata.AuthorID = reader.GetInt32(3);
|
||||
|
||||
if (beatmap.BeatmapSet.Metadata != null)
|
||||
beatmap.BeatmapSet.Metadata.AuthorID = reader.GetInt32(3);
|
||||
|
||||
LogForModel(set, $"Cached local retrieval for {beatmap}.");
|
||||
return true;
|
||||
}
|
||||
@ -194,17 +205,6 @@ namespace osu.Game.Beatmaps
|
||||
cacheDownloadRequest?.Dispose();
|
||||
updateScheduler?.Dispose();
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
private class CachedOnlineBeatmapLookup
|
||||
{
|
||||
public int approved { get; set; }
|
||||
|
||||
public int? beatmapset_id { get; set; }
|
||||
|
||||
public int? beatmap_id { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Users;
|
||||
@ -34,6 +35,21 @@ namespace osu.Game.Beatmaps
|
||||
[JsonIgnore]
|
||||
public List<BeatmapSetInfo> BeatmapSets { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Helper property to deserialize a username to <see cref="User"/>.
|
||||
/// </summary>
|
||||
[JsonProperty(@"user_id")]
|
||||
[Column("AuthorID")]
|
||||
public int AuthorID
|
||||
{
|
||||
get => Author?.Id ?? 1;
|
||||
set
|
||||
{
|
||||
Author ??= new User();
|
||||
Author.Id = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper property to deserialize a username to <see cref="User"/>.
|
||||
/// </summary>
|
||||
@ -42,7 +58,11 @@ namespace osu.Game.Beatmaps
|
||||
public string AuthorString
|
||||
{
|
||||
get => Author?.Username;
|
||||
set => Author = new User { Username = value };
|
||||
set
|
||||
{
|
||||
Author ??= new User();
|
||||
Author.Username = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -71,6 +91,12 @@ namespace osu.Game.Beatmaps
|
||||
return $"{Artist} - {Title} {author}".Trim();
|
||||
}
|
||||
|
||||
public RomanisableString ToRomanisableString()
|
||||
{
|
||||
string author = Author == null ? string.Empty : $"({Author})";
|
||||
return new RomanisableString($"{ArtistUnicode} - {TitleUnicode} {author}".Trim(), $"{Artist} - {Title} {author}".Trim());
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public string[] SearchableTerms => new[]
|
||||
{
|
||||
|
@ -472,7 +472,7 @@ namespace osu.Game.Database
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete new file.
|
||||
/// Delete an existing file.
|
||||
/// </summary>
|
||||
/// <param name="model">The item to operate on.</param>
|
||||
/// <param name="file">The existing file to be deleted.</param>
|
||||
|
@ -3,8 +3,10 @@
|
||||
|
||||
using System;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Game.Screens.Play.HUD;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Extensions
|
||||
@ -43,5 +45,23 @@ namespace osu.Game.Extensions
|
||||
/// <returns>The delta vector in Parent's coordinates.</returns>
|
||||
public static Vector2 ScreenSpaceDeltaToParentSpace(this Drawable drawable, Vector2 delta) =>
|
||||
drawable.Parent.ToLocalSpace(drawable.Parent.ToScreenSpace(Vector2.Zero) + delta);
|
||||
|
||||
public static SkinnableInfo CreateSkinnableInfo(this Drawable component) => new SkinnableInfo(component);
|
||||
|
||||
public static void ApplySkinnableInfo(this Drawable component, SkinnableInfo info)
|
||||
{
|
||||
// todo: can probably make this better via deserialisation directly using a common interface.
|
||||
component.Position = info.Position;
|
||||
component.Rotation = info.Rotation;
|
||||
component.Scale = info.Scale;
|
||||
component.Anchor = info.Anchor;
|
||||
component.Origin = info.Origin;
|
||||
|
||||
if (component is Container container)
|
||||
{
|
||||
foreach (var child in info.Children)
|
||||
container.Add(child.CreateInstance());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Extensions.ObjectExtensions;
|
||||
|
||||
namespace osu.Game.Extensions
|
||||
{
|
||||
@ -50,7 +51,7 @@ namespace osu.Game.Extensions
|
||||
}
|
||||
else if (continuationTask.IsFaulted)
|
||||
{
|
||||
tcs.TrySetException(continuationTask.Exception);
|
||||
tcs.TrySetException(continuationTask.Exception.AsNonNull());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -7,7 +7,10 @@ using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Graphics.Containers
|
||||
@ -59,6 +62,14 @@ namespace osu.Game.Graphics.Containers
|
||||
public void AddLink(string text, LinkAction action, string argument, string tooltipText = null, Action<SpriteText> creationParameters = null)
|
||||
=> createLink(AddText(text, creationParameters), new LinkDetails(action, argument), tooltipText);
|
||||
|
||||
public void AddLink(LocalisableString text, LinkAction action, string argument, string tooltipText = null, Action<SpriteText> creationParameters = null)
|
||||
{
|
||||
var spriteText = new OsuSpriteText { Text = text };
|
||||
|
||||
AddText(spriteText, creationParameters);
|
||||
createLink(spriteText.Yield(), new LinkDetails(action, argument), tooltipText);
|
||||
}
|
||||
|
||||
public void AddLink(IEnumerable<SpriteText> text, LinkAction action = LinkAction.External, string linkArgument = null, string tooltipText = null)
|
||||
{
|
||||
foreach (var t in text)
|
||||
|
18
osu.Game/Graphics/UserInterface/DangerousTriangleButton.cs
Normal file
18
osu.Game/Graphics/UserInterface/DangerousTriangleButton.cs
Normal file
@ -0,0 +1,18 @@
|
||||
// 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 osu.Framework.Allocation;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public class DangerousTriangleButton : TriangleButton
|
||||
{
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
BackgroundColour = colours.PinkDark;
|
||||
Triangles.ColourDark = colours.PinkDarker;
|
||||
Triangles.ColourLight = colours.Pink;
|
||||
}
|
||||
}
|
||||
}
|
@ -38,6 +38,7 @@ namespace osu.Game.IO.Legacy
|
||||
/// <summary> Reads a string from the buffer. Overrides the base implementation so it can cope with nulls. </summary>
|
||||
public override string ReadString()
|
||||
{
|
||||
// ReSharper disable once AssignNullToNotNullAttribute
|
||||
if (ReadByte() == 0) return null;
|
||||
|
||||
return base.ReadString();
|
||||
|
@ -5,6 +5,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using osu.Framework.Extensions.ObjectExtensions;
|
||||
|
||||
namespace osu.Game.IO.Serialization.Converters
|
||||
{
|
||||
@ -60,7 +61,7 @@ namespace osu.Game.IO.Serialization.Converters
|
||||
throw new JsonException("Expected $type token.");
|
||||
|
||||
var typeName = lookupTable[(int)tok["$type"]];
|
||||
var instance = (T)Activator.CreateInstance(Type.GetType(typeName));
|
||||
var instance = (T)Activator.CreateInstance(Type.GetType(typeName).AsNonNull());
|
||||
serializer.Populate(itemReader, instance);
|
||||
|
||||
list.Add(instance);
|
||||
|
@ -48,7 +48,7 @@ namespace osu.Game.Input.Bindings
|
||||
new KeyBinding(new[] { InputKey.Control, InputKey.O }, GlobalAction.ToggleSettings),
|
||||
new KeyBinding(new[] { InputKey.Control, InputKey.D }, GlobalAction.ToggleBeatmapListing),
|
||||
new KeyBinding(new[] { InputKey.Control, InputKey.N }, GlobalAction.ToggleNotifications),
|
||||
new KeyBinding(new[] { InputKey.Shift, InputKey.F2 }, GlobalAction.ToggleSkinEditor),
|
||||
new KeyBinding(new[] { InputKey.Control, InputKey.Shift, InputKey.S }, GlobalAction.ToggleSkinEditor),
|
||||
|
||||
new KeyBinding(InputKey.Escape, GlobalAction.Back),
|
||||
new KeyBinding(InputKey.ExtraMouseButton1, GlobalAction.Back),
|
||||
|
511
osu.Game/Migrations/20210514062639_AddAuthorIdToBeatmapMetadata.Designer.cs
generated
Normal file
511
osu.Game/Migrations/20210514062639_AddAuthorIdToBeatmapMetadata.Designer.cs
generated
Normal file
@ -0,0 +1,511 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using osu.Game.Database;
|
||||
|
||||
namespace osu.Game.Migrations
|
||||
{
|
||||
[DbContext(typeof(OsuDbContext))]
|
||||
[Migration("20210514062639_AddAuthorIdToBeatmapMetadata")]
|
||||
partial class AddAuthorIdToBeatmapMetadata
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "2.2.6-servicing-10079");
|
||||
|
||||
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapDifficulty", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<float>("ApproachRate");
|
||||
|
||||
b.Property<float>("CircleSize");
|
||||
|
||||
b.Property<float>("DrainRate");
|
||||
|
||||
b.Property<float>("OverallDifficulty");
|
||||
|
||||
b.Property<double>("SliderMultiplier");
|
||||
|
||||
b.Property<double>("SliderTickRate");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("BeatmapDifficulty");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapInfo", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<double>("AudioLeadIn");
|
||||
|
||||
b.Property<double>("BPM");
|
||||
|
||||
b.Property<int>("BaseDifficultyID");
|
||||
|
||||
b.Property<int>("BeatDivisor");
|
||||
|
||||
b.Property<int>("BeatmapSetInfoID");
|
||||
|
||||
b.Property<bool>("Countdown");
|
||||
|
||||
b.Property<double>("DistanceSpacing");
|
||||
|
||||
b.Property<bool>("EpilepsyWarning");
|
||||
|
||||
b.Property<int>("GridSize");
|
||||
|
||||
b.Property<string>("Hash");
|
||||
|
||||
b.Property<bool>("Hidden");
|
||||
|
||||
b.Property<double>("Length");
|
||||
|
||||
b.Property<bool>("LetterboxInBreaks");
|
||||
|
||||
b.Property<string>("MD5Hash");
|
||||
|
||||
b.Property<int?>("MetadataID");
|
||||
|
||||
b.Property<int?>("OnlineBeatmapID");
|
||||
|
||||
b.Property<string>("Path");
|
||||
|
||||
b.Property<int>("RulesetID");
|
||||
|
||||
b.Property<bool>("SpecialStyle");
|
||||
|
||||
b.Property<float>("StackLeniency");
|
||||
|
||||
b.Property<double>("StarDifficulty");
|
||||
|
||||
b.Property<int>("Status");
|
||||
|
||||
b.Property<string>("StoredBookmarks");
|
||||
|
||||
b.Property<double>("TimelineZoom");
|
||||
|
||||
b.Property<string>("Version");
|
||||
|
||||
b.Property<bool>("WidescreenStoryboard");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("BaseDifficultyID");
|
||||
|
||||
b.HasIndex("BeatmapSetInfoID");
|
||||
|
||||
b.HasIndex("Hash");
|
||||
|
||||
b.HasIndex("MD5Hash");
|
||||
|
||||
b.HasIndex("MetadataID");
|
||||
|
||||
b.HasIndex("OnlineBeatmapID")
|
||||
.IsUnique();
|
||||
|
||||
b.HasIndex("RulesetID");
|
||||
|
||||
b.ToTable("BeatmapInfo");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapMetadata", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("Artist");
|
||||
|
||||
b.Property<string>("ArtistUnicode");
|
||||
|
||||
b.Property<string>("AudioFile");
|
||||
|
||||
b.Property<int>("AuthorID")
|
||||
.HasColumnName("AuthorID");
|
||||
|
||||
b.Property<string>("AuthorString")
|
||||
.HasColumnName("Author");
|
||||
|
||||
b.Property<string>("BackgroundFile");
|
||||
|
||||
b.Property<int>("PreviewTime");
|
||||
|
||||
b.Property<string>("Source");
|
||||
|
||||
b.Property<string>("Tags");
|
||||
|
||||
b.Property<string>("Title");
|
||||
|
||||
b.Property<string>("TitleUnicode");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("BeatmapMetadata");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetFileInfo", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("BeatmapSetInfoID");
|
||||
|
||||
b.Property<int>("FileInfoID");
|
||||
|
||||
b.Property<string>("Filename")
|
||||
.IsRequired();
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("BeatmapSetInfoID");
|
||||
|
||||
b.HasIndex("FileInfoID");
|
||||
|
||||
b.ToTable("BeatmapSetFileInfo");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetInfo", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<DateTimeOffset>("DateAdded");
|
||||
|
||||
b.Property<bool>("DeletePending");
|
||||
|
||||
b.Property<string>("Hash");
|
||||
|
||||
b.Property<int?>("MetadataID");
|
||||
|
||||
b.Property<int?>("OnlineBeatmapSetID");
|
||||
|
||||
b.Property<bool>("Protected");
|
||||
|
||||
b.Property<int>("Status");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("DeletePending");
|
||||
|
||||
b.HasIndex("Hash")
|
||||
.IsUnique();
|
||||
|
||||
b.HasIndex("MetadataID");
|
||||
|
||||
b.HasIndex("OnlineBeatmapSetID")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("BeatmapSetInfo");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Configuration.DatabasedSetting", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("Key")
|
||||
.HasColumnName("Key");
|
||||
|
||||
b.Property<int?>("RulesetID");
|
||||
|
||||
b.Property<int?>("SkinInfoID");
|
||||
|
||||
b.Property<string>("StringValue")
|
||||
.HasColumnName("Value");
|
||||
|
||||
b.Property<int?>("Variant");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("SkinInfoID");
|
||||
|
||||
b.HasIndex("RulesetID", "Variant");
|
||||
|
||||
b.ToTable("Settings");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.IO.FileInfo", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("Hash");
|
||||
|
||||
b.Property<int>("ReferenceCount");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("Hash")
|
||||
.IsUnique();
|
||||
|
||||
b.HasIndex("ReferenceCount");
|
||||
|
||||
b.ToTable("FileInfo");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Input.Bindings.DatabasedKeyBinding", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("IntAction")
|
||||
.HasColumnName("Action");
|
||||
|
||||
b.Property<string>("KeysString")
|
||||
.HasColumnName("Keys");
|
||||
|
||||
b.Property<int?>("RulesetID");
|
||||
|
||||
b.Property<int?>("Variant");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("IntAction");
|
||||
|
||||
b.HasIndex("RulesetID", "Variant");
|
||||
|
||||
b.ToTable("KeyBinding");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Rulesets.RulesetInfo", b =>
|
||||
{
|
||||
b.Property<int?>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<bool>("Available");
|
||||
|
||||
b.Property<string>("InstantiationInfo");
|
||||
|
||||
b.Property<string>("Name");
|
||||
|
||||
b.Property<string>("ShortName");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("Available");
|
||||
|
||||
b.HasIndex("ShortName")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("RulesetInfo");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Scoring.ScoreFileInfo", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("FileInfoID");
|
||||
|
||||
b.Property<string>("Filename")
|
||||
.IsRequired();
|
||||
|
||||
b.Property<int?>("ScoreInfoID");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("FileInfoID");
|
||||
|
||||
b.HasIndex("ScoreInfoID");
|
||||
|
||||
b.ToTable("ScoreFileInfo");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Scoring.ScoreInfo", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<double>("Accuracy")
|
||||
.HasColumnType("DECIMAL(1,4)");
|
||||
|
||||
b.Property<int>("BeatmapInfoID");
|
||||
|
||||
b.Property<int>("Combo");
|
||||
|
||||
b.Property<DateTimeOffset>("Date");
|
||||
|
||||
b.Property<bool>("DeletePending");
|
||||
|
||||
b.Property<string>("Hash");
|
||||
|
||||
b.Property<int>("MaxCombo");
|
||||
|
||||
b.Property<string>("ModsJson")
|
||||
.HasColumnName("Mods");
|
||||
|
||||
b.Property<long?>("OnlineScoreID");
|
||||
|
||||
b.Property<double?>("PP");
|
||||
|
||||
b.Property<int>("Rank");
|
||||
|
||||
b.Property<int>("RulesetID");
|
||||
|
||||
b.Property<string>("StatisticsJson")
|
||||
.HasColumnName("Statistics");
|
||||
|
||||
b.Property<long>("TotalScore");
|
||||
|
||||
b.Property<int?>("UserID")
|
||||
.HasColumnName("UserID");
|
||||
|
||||
b.Property<string>("UserString")
|
||||
.HasColumnName("User");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("BeatmapInfoID");
|
||||
|
||||
b.HasIndex("OnlineScoreID")
|
||||
.IsUnique();
|
||||
|
||||
b.HasIndex("RulesetID");
|
||||
|
||||
b.ToTable("ScoreInfo");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Skinning.SkinFileInfo", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("FileInfoID");
|
||||
|
||||
b.Property<string>("Filename")
|
||||
.IsRequired();
|
||||
|
||||
b.Property<int>("SkinInfoID");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("FileInfoID");
|
||||
|
||||
b.HasIndex("SkinInfoID");
|
||||
|
||||
b.ToTable("SkinFileInfo");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Skinning.SkinInfo", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("Creator");
|
||||
|
||||
b.Property<bool>("DeletePending");
|
||||
|
||||
b.Property<string>("Hash");
|
||||
|
||||
b.Property<string>("InstantiationInfo");
|
||||
|
||||
b.Property<string>("Name");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("DeletePending");
|
||||
|
||||
b.HasIndex("Hash")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("SkinInfo");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapInfo", b =>
|
||||
{
|
||||
b.HasOne("osu.Game.Beatmaps.BeatmapDifficulty", "BaseDifficulty")
|
||||
.WithMany()
|
||||
.HasForeignKey("BaseDifficultyID")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
b.HasOne("osu.Game.Beatmaps.BeatmapSetInfo", "BeatmapSet")
|
||||
.WithMany("Beatmaps")
|
||||
.HasForeignKey("BeatmapSetInfoID")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
b.HasOne("osu.Game.Beatmaps.BeatmapMetadata", "Metadata")
|
||||
.WithMany("Beatmaps")
|
||||
.HasForeignKey("MetadataID");
|
||||
|
||||
b.HasOne("osu.Game.Rulesets.RulesetInfo", "Ruleset")
|
||||
.WithMany()
|
||||
.HasForeignKey("RulesetID")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetFileInfo", b =>
|
||||
{
|
||||
b.HasOne("osu.Game.Beatmaps.BeatmapSetInfo")
|
||||
.WithMany("Files")
|
||||
.HasForeignKey("BeatmapSetInfoID")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
b.HasOne("osu.Game.IO.FileInfo", "FileInfo")
|
||||
.WithMany()
|
||||
.HasForeignKey("FileInfoID")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetInfo", b =>
|
||||
{
|
||||
b.HasOne("osu.Game.Beatmaps.BeatmapMetadata", "Metadata")
|
||||
.WithMany("BeatmapSets")
|
||||
.HasForeignKey("MetadataID");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Configuration.DatabasedSetting", b =>
|
||||
{
|
||||
b.HasOne("osu.Game.Skinning.SkinInfo")
|
||||
.WithMany("Settings")
|
||||
.HasForeignKey("SkinInfoID");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Scoring.ScoreFileInfo", b =>
|
||||
{
|
||||
b.HasOne("osu.Game.IO.FileInfo", "FileInfo")
|
||||
.WithMany()
|
||||
.HasForeignKey("FileInfoID")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
b.HasOne("osu.Game.Scoring.ScoreInfo")
|
||||
.WithMany("Files")
|
||||
.HasForeignKey("ScoreInfoID");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Scoring.ScoreInfo", b =>
|
||||
{
|
||||
b.HasOne("osu.Game.Beatmaps.BeatmapInfo", "Beatmap")
|
||||
.WithMany("Scores")
|
||||
.HasForeignKey("BeatmapInfoID")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
b.HasOne("osu.Game.Rulesets.RulesetInfo", "Ruleset")
|
||||
.WithMany()
|
||||
.HasForeignKey("RulesetID")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Skinning.SkinFileInfo", b =>
|
||||
{
|
||||
b.HasOne("osu.Game.IO.FileInfo", "FileInfo")
|
||||
.WithMany()
|
||||
.HasForeignKey("FileInfoID")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
b.HasOne("osu.Game.Skinning.SkinInfo")
|
||||
.WithMany("Files")
|
||||
.HasForeignKey("SkinInfoID")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace osu.Game.Migrations
|
||||
{
|
||||
public partial class AddAuthorIdToBeatmapMetadata : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "AuthorID",
|
||||
table: "BeatmapMetadata",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "AuthorID",
|
||||
table: "BeatmapMetadata");
|
||||
}
|
||||
}
|
||||
}
|
@ -126,6 +126,9 @@ namespace osu.Game.Migrations
|
||||
|
||||
b.Property<string>("AudioFile");
|
||||
|
||||
b.Property<int>("AuthorID")
|
||||
.HasColumnName("AuthorID");
|
||||
|
||||
b.Property<string>("AuthorString")
|
||||
.HasColumnName("Author");
|
||||
|
||||
|
@ -270,7 +270,7 @@ namespace osu.Game.Online.API
|
||||
{
|
||||
try
|
||||
{
|
||||
return JObject.Parse(req.GetResponseString()).SelectToken("form_error", true).AsNonNull().ToObject<RegistrationRequest.RegistrationRequestErrors>();
|
||||
return JObject.Parse(req.GetResponseString().AsNonNull()).SelectToken("form_error", true).AsNonNull().ToObject<RegistrationRequest.RegistrationRequestErrors>();
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -8,6 +8,7 @@ using osu.Framework.Graphics;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Overlays;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Online.Chat
|
||||
@ -20,7 +21,10 @@ namespace osu.Game.Online.Chat
|
||||
/// <summary>
|
||||
/// Each word part of a chat link (split for word-wrap support).
|
||||
/// </summary>
|
||||
public List<Drawable> Parts;
|
||||
public readonly List<Drawable> Parts;
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
private OverlayColourProvider overlayColourProvider { get; set; }
|
||||
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => Parts.Any(d => d.ReceivePositionalInputAt(screenSpacePos));
|
||||
|
||||
@ -34,7 +38,7 @@ namespace osu.Game.Online.Chat
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
IdleColour = colours.Blue;
|
||||
IdleColour = overlayColourProvider?.Light2 ?? colours.Blue;
|
||||
}
|
||||
|
||||
protected override IEnumerable<Drawable> EffectTargets => Parts;
|
||||
|
@ -24,7 +24,13 @@ namespace osu.Game.Online.Spectator
|
||||
[Key(2)]
|
||||
public IEnumerable<APIMod> Mods { get; set; } = Enumerable.Empty<APIMod>();
|
||||
|
||||
public bool Equals(SpectatorState other) => BeatmapID == other?.BeatmapID && Mods.SequenceEqual(other?.Mods) && RulesetID == other?.RulesetID;
|
||||
public bool Equals(SpectatorState other)
|
||||
{
|
||||
if (ReferenceEquals(null, other)) return false;
|
||||
if (ReferenceEquals(this, other)) return true;
|
||||
|
||||
return BeatmapID == other.BeatmapID && Mods.SequenceEqual(other.Mods) && RulesetID == other.RulesetID;
|
||||
}
|
||||
|
||||
public override string ToString() => $"Beatmap:{BeatmapID} Mods:{string.Join(',', Mods)} Ruleset:{RulesetID}";
|
||||
}
|
||||
|
@ -339,22 +339,13 @@ namespace osu.Game.Overlays.KeyBinding
|
||||
}
|
||||
}
|
||||
|
||||
public class ClearButton : TriangleButton
|
||||
public class ClearButton : DangerousTriangleButton
|
||||
{
|
||||
public ClearButton()
|
||||
{
|
||||
Text = "Clear";
|
||||
Size = new Vector2(80, 20);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
BackgroundColour = colours.Pink;
|
||||
|
||||
Triangles.ColourDark = colours.PinkDark;
|
||||
Triangles.ColourLight = colours.PinkLight;
|
||||
}
|
||||
}
|
||||
|
||||
public class KeyButton : Container
|
||||
|
@ -11,7 +11,6 @@ using osu.Game.Input;
|
||||
using osu.Game.Overlays.Settings;
|
||||
using osu.Game.Rulesets;
|
||||
using osuTK;
|
||||
using osu.Game.Graphics;
|
||||
|
||||
namespace osu.Game.Overlays.KeyBinding
|
||||
{
|
||||
@ -55,10 +54,10 @@ namespace osu.Game.Overlays.KeyBinding
|
||||
}
|
||||
}
|
||||
|
||||
public class ResetButton : TriangleButton
|
||||
public class ResetButton : DangerousTriangleButton
|
||||
{
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
private void load()
|
||||
{
|
||||
Text = "Reset all bindings in section";
|
||||
RelativeSizeAxes = Axes.X;
|
||||
@ -66,10 +65,6 @@ namespace osu.Game.Overlays.KeyBinding
|
||||
Height = 20;
|
||||
|
||||
Content.CornerRadius = 5;
|
||||
|
||||
BackgroundColour = colours.PinkDark;
|
||||
Triangles.ColourDark = colours.PinkDarker;
|
||||
Triangles.ColourLight = colours.Pink;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,128 @@
|
||||
// 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 osu.Framework.Graphics;
|
||||
using System.IO;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.UserInterfaceV2;
|
||||
using osu.Game.Screens;
|
||||
using osuTK;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Framework.Screens;
|
||||
|
||||
namespace osu.Game.Overlays.Settings.Sections.Maintenance
|
||||
{
|
||||
public abstract class DirectorySelectScreen : OsuScreen
|
||||
{
|
||||
private TriangleButton selectionButton;
|
||||
|
||||
private DirectorySelector directorySelector;
|
||||
|
||||
/// <summary>
|
||||
/// Text to display in the header to inform the user of what they are selecting.
|
||||
/// </summary>
|
||||
public abstract LocalisableString HeaderText { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Called upon selection of a directory by the user.
|
||||
/// </summary>
|
||||
/// <param name="directory">The selected directory</param>
|
||||
protected abstract void OnSelection(DirectoryInfo directory);
|
||||
|
||||
/// <summary>
|
||||
/// Whether the current directory is considered to be valid and can be selected.
|
||||
/// </summary>
|
||||
/// <param name="info">The current directory.</param>
|
||||
/// <returns>Whether the selected directory is considered valid.</returns>
|
||||
protected virtual bool IsValidDirectory(DirectoryInfo info) => true;
|
||||
|
||||
/// <summary>
|
||||
/// The path at which to start selection from.
|
||||
/// </summary>
|
||||
protected virtual DirectoryInfo InitialPath => null;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
InternalChild = new Container
|
||||
{
|
||||
Masking = true,
|
||||
CornerRadius = 10,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(0.5f, 0.8f),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = colours.GreySeafoamDark
|
||||
},
|
||||
new GridContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
RowDimensions = new[]
|
||||
{
|
||||
new Dimension(),
|
||||
new Dimension(GridSizeMode.Relative, 0.8f),
|
||||
new Dimension(),
|
||||
},
|
||||
Content = new[]
|
||||
{
|
||||
new Drawable[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = HeaderText,
|
||||
Font = OsuFont.Default.With(size: 40),
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
}
|
||||
},
|
||||
new Drawable[]
|
||||
{
|
||||
directorySelector = new DirectorySelector
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
}
|
||||
},
|
||||
new Drawable[]
|
||||
{
|
||||
selectionButton = new TriangleButton
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Width = 300,
|
||||
Text = "Select directory",
|
||||
Action = () => OnSelection(directorySelector.CurrentPath.Value)
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
if (InitialPath != null)
|
||||
directorySelector.CurrentPath.Value = InitialPath;
|
||||
|
||||
directorySelector.CurrentPath.BindValueChanged(e => selectionButton.Enabled.Value = e.NewValue != null && IsValidDirectory(e.NewValue), true);
|
||||
base.LoadComplete();
|
||||
}
|
||||
|
||||
public override void OnSuspending(IScreen next)
|
||||
{
|
||||
base.OnSuspending(next);
|
||||
|
||||
this.FadeOut(250);
|
||||
}
|
||||
}
|
||||
}
|
@ -4,24 +4,19 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Graphics.UserInterfaceV2;
|
||||
using osu.Game.Screens;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Overlays.Settings.Sections.Maintenance
|
||||
{
|
||||
public class MigrationSelectScreen : OsuScreen
|
||||
public class MigrationSelectScreen : DirectorySelectScreen
|
||||
{
|
||||
private DirectorySelector directorySelector;
|
||||
[Resolved]
|
||||
private Storage storage { get; set; }
|
||||
|
||||
protected override DirectoryInfo InitialPath => new DirectoryInfo(storage.GetFullPath(string.Empty)).Parent;
|
||||
|
||||
public override bool AllowExternalScreenChange => false;
|
||||
|
||||
@ -29,84 +24,11 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
|
||||
|
||||
public override bool HideOverlaysOnEnter => true;
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(OsuGame game, Storage storage, OsuColour colours)
|
||||
public override LocalisableString HeaderText => "Please select a new location";
|
||||
|
||||
protected override void OnSelection(DirectoryInfo directory)
|
||||
{
|
||||
game?.Toolbar.Hide();
|
||||
|
||||
// begin selection in the parent directory of the current storage location
|
||||
var initialPath = new DirectoryInfo(storage.GetFullPath(string.Empty)).Parent?.FullName;
|
||||
|
||||
InternalChild = new Container
|
||||
{
|
||||
Masking = true,
|
||||
CornerRadius = 10,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(0.5f, 0.8f),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = colours.GreySeafoamDark,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
new GridContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
RowDimensions = new[]
|
||||
{
|
||||
new Dimension(),
|
||||
new Dimension(GridSizeMode.Relative, 0.8f),
|
||||
new Dimension(),
|
||||
},
|
||||
Content = new[]
|
||||
{
|
||||
new Drawable[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Text = "Please select a new location",
|
||||
Font = OsuFont.Default.With(size: 40)
|
||||
},
|
||||
},
|
||||
new Drawable[]
|
||||
{
|
||||
directorySelector = new DirectorySelector(initialPath)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
}
|
||||
},
|
||||
new Drawable[]
|
||||
{
|
||||
new TriangleButton
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Width = 300,
|
||||
Text = "Begin folder migration",
|
||||
Action = start
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public override void OnSuspending(IScreen next)
|
||||
{
|
||||
base.OnSuspending(next);
|
||||
|
||||
this.FadeOut(250);
|
||||
}
|
||||
|
||||
private void start()
|
||||
{
|
||||
var target = directorySelector.CurrentPath.Value;
|
||||
var target = directory;
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Edit.Checks;
|
||||
using osu.Game.Rulesets.Edit.Checks.Components;
|
||||
|
||||
@ -29,9 +28,9 @@ namespace osu.Game.Rulesets.Edit
|
||||
new CheckConcurrentObjects()
|
||||
};
|
||||
|
||||
public IEnumerable<Issue> Run(IBeatmap playableBeatmap, WorkingBeatmap workingBeatmap)
|
||||
public IEnumerable<Issue> Run(BeatmapVerifierContext context)
|
||||
{
|
||||
return checks.SelectMany(check => check.Run(playableBeatmap, workingBeatmap));
|
||||
return checks.SelectMany(check => check.Run(context));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
38
osu.Game/Rulesets/Edit/BeatmapVerifierContext.cs
Normal file
38
osu.Game/Rulesets/Edit/BeatmapVerifierContext.cs
Normal file
@ -0,0 +1,38 @@
|
||||
// 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 osu.Game.Beatmaps;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace osu.Game.Rulesets.Edit
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the context provided by the beatmap verifier to the checks it runs.
|
||||
/// Contains information about what is being checked and how it should be checked.
|
||||
/// </summary>
|
||||
public class BeatmapVerifierContext
|
||||
{
|
||||
/// <summary>
|
||||
/// The playable beatmap instance of the current beatmap.
|
||||
/// </summary>
|
||||
public readonly IBeatmap Beatmap;
|
||||
|
||||
/// <summary>
|
||||
/// The working beatmap instance of the current beatmap.
|
||||
/// </summary>
|
||||
public readonly IWorkingBeatmap WorkingBeatmap;
|
||||
|
||||
/// <summary>
|
||||
/// The difficulty level which the current beatmap is considered to be.
|
||||
/// </summary>
|
||||
public DifficultyRating InterpretedDifficulty;
|
||||
|
||||
public BeatmapVerifierContext(IBeatmap beatmap, IWorkingBeatmap workingBeatmap, DifficultyRating difficultyRating = DifficultyRating.ExpertPlus)
|
||||
{
|
||||
Beatmap = beatmap;
|
||||
WorkingBeatmap = workingBeatmap;
|
||||
InterpretedDifficulty = difficultyRating;
|
||||
}
|
||||
}
|
||||
}
|
@ -10,6 +10,6 @@ namespace osu.Game.Rulesets.Edit.Checks
|
||||
{
|
||||
protected override CheckCategory Category => CheckCategory.Audio;
|
||||
protected override string TypeOfFile => "audio";
|
||||
protected override string GetFilename(IBeatmap playableBeatmap) => playableBeatmap.Metadata?.AudioFile;
|
||||
protected override string GetFilename(IBeatmap beatmap) => beatmap.Metadata?.AudioFile;
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Edit.Checks.Components;
|
||||
|
||||
namespace osu.Game.Rulesets.Edit.Checks
|
||||
@ -26,13 +25,13 @@ namespace osu.Game.Rulesets.Edit.Checks
|
||||
new IssueTemplateNoBitrate(this)
|
||||
};
|
||||
|
||||
public IEnumerable<Issue> Run(IBeatmap playableBeatmap, IWorkingBeatmap workingBeatmap)
|
||||
public IEnumerable<Issue> Run(BeatmapVerifierContext context)
|
||||
{
|
||||
var audioFile = playableBeatmap.Metadata?.AudioFile;
|
||||
var audioFile = context.Beatmap.Metadata?.AudioFile;
|
||||
if (audioFile == null)
|
||||
yield break;
|
||||
|
||||
var track = workingBeatmap.Track;
|
||||
var track = context.WorkingBeatmap.Track;
|
||||
|
||||
if (track?.Bitrate == null || track.Bitrate.Value == 0)
|
||||
yield return new IssueTemplateNoBitrate(this).Create();
|
||||
|
@ -10,6 +10,6 @@ namespace osu.Game.Rulesets.Edit.Checks
|
||||
{
|
||||
protected override CheckCategory Category => CheckCategory.Resources;
|
||||
protected override string TypeOfFile => "background";
|
||||
protected override string GetFilename(IBeatmap playableBeatmap) => playableBeatmap.Metadata?.BackgroundFile;
|
||||
protected override string GetFilename(IBeatmap beatmap) => beatmap.Metadata?.BackgroundFile;
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Edit.Checks.Components;
|
||||
|
||||
namespace osu.Game.Rulesets.Edit.Checks
|
||||
@ -30,13 +29,13 @@ namespace osu.Game.Rulesets.Edit.Checks
|
||||
new IssueTemplateTooUncompressed(this)
|
||||
};
|
||||
|
||||
public IEnumerable<Issue> Run(IBeatmap playableBeatmap, IWorkingBeatmap workingBeatmap)
|
||||
public IEnumerable<Issue> Run(BeatmapVerifierContext context)
|
||||
{
|
||||
var backgroundFile = playableBeatmap.Metadata?.BackgroundFile;
|
||||
var backgroundFile = context.Beatmap.Metadata?.BackgroundFile;
|
||||
if (backgroundFile == null)
|
||||
yield break;
|
||||
|
||||
var texture = workingBeatmap.Background;
|
||||
var texture = context.WorkingBeatmap.Background;
|
||||
if (texture == null)
|
||||
yield break;
|
||||
|
||||
@ -48,8 +47,8 @@ namespace osu.Game.Rulesets.Edit.Checks
|
||||
else if (texture.Width < low_width || texture.Height < low_height)
|
||||
yield return new IssueTemplateLowResolution(this).Create(texture.Width, texture.Height);
|
||||
|
||||
string storagePath = playableBeatmap.BeatmapInfo.BeatmapSet.GetPathForFile(backgroundFile);
|
||||
double filesizeMb = workingBeatmap.GetStream(storagePath).Length / (1024d * 1024d);
|
||||
string storagePath = context.Beatmap.BeatmapInfo.BeatmapSet.GetPathForFile(backgroundFile);
|
||||
double filesizeMb = context.WorkingBeatmap.GetStream(storagePath).Length / (1024d * 1024d);
|
||||
|
||||
if (filesizeMb > max_filesize_mb)
|
||||
yield return new IssueTemplateTooUncompressed(this).Create(filesizeMb);
|
||||
|
@ -2,7 +2,6 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Edit.Checks.Components;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
@ -22,15 +21,17 @@ namespace osu.Game.Rulesets.Edit.Checks
|
||||
new IssueTemplateConcurrentDifferent(this)
|
||||
};
|
||||
|
||||
public IEnumerable<Issue> Run(IBeatmap playableBeatmap, IWorkingBeatmap workingBeatmap)
|
||||
public IEnumerable<Issue> Run(BeatmapVerifierContext context)
|
||||
{
|
||||
for (int i = 0; i < playableBeatmap.HitObjects.Count - 1; ++i)
|
||||
{
|
||||
var hitobject = playableBeatmap.HitObjects[i];
|
||||
var hitObjects = context.Beatmap.HitObjects;
|
||||
|
||||
for (int j = i + 1; j < playableBeatmap.HitObjects.Count; ++j)
|
||||
for (int i = 0; i < hitObjects.Count - 1; ++i)
|
||||
{
|
||||
var hitobject = hitObjects[i];
|
||||
|
||||
for (int j = i + 1; j < hitObjects.Count; ++j)
|
||||
{
|
||||
var nextHitobject = playableBeatmap.HitObjects[j];
|
||||
var nextHitobject = hitObjects[j];
|
||||
|
||||
// Accounts for rulesets with hitobjects separated by columns, such as Mania.
|
||||
// In these cases we only care about concurrent objects within the same column.
|
||||
|
@ -11,7 +11,7 @@ namespace osu.Game.Rulesets.Edit.Checks
|
||||
{
|
||||
protected abstract CheckCategory Category { get; }
|
||||
protected abstract string TypeOfFile { get; }
|
||||
protected abstract string GetFilename(IBeatmap playableBeatmap);
|
||||
protected abstract string GetFilename(IBeatmap beatmap);
|
||||
|
||||
public CheckMetadata Metadata => new CheckMetadata(Category, $"Missing {TypeOfFile}");
|
||||
|
||||
@ -21,9 +21,9 @@ namespace osu.Game.Rulesets.Edit.Checks
|
||||
new IssueTemplateDoesNotExist(this)
|
||||
};
|
||||
|
||||
public IEnumerable<Issue> Run(IBeatmap playableBeatmap, IWorkingBeatmap workingBeatmap)
|
||||
public IEnumerable<Issue> Run(BeatmapVerifierContext context)
|
||||
{
|
||||
var filename = GetFilename(playableBeatmap);
|
||||
var filename = GetFilename(context.Beatmap);
|
||||
|
||||
if (filename == null)
|
||||
{
|
||||
@ -33,7 +33,7 @@ namespace osu.Game.Rulesets.Edit.Checks
|
||||
}
|
||||
|
||||
// If the file is set, also make sure it still exists.
|
||||
var storagePath = playableBeatmap.BeatmapInfo.BeatmapSet.GetPathForFile(filename);
|
||||
var storagePath = context.Beatmap.BeatmapInfo.BeatmapSet.GetPathForFile(filename);
|
||||
if (storagePath != null)
|
||||
yield break;
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Edit.Checks.Components;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
@ -22,11 +21,11 @@ namespace osu.Game.Rulesets.Edit.Checks
|
||||
new IssueTemplateSmallUnsnap(this)
|
||||
};
|
||||
|
||||
public IEnumerable<Issue> Run(IBeatmap playableBeatmap, IWorkingBeatmap workingBeatmap)
|
||||
public IEnumerable<Issue> Run(BeatmapVerifierContext context)
|
||||
{
|
||||
var controlPointInfo = playableBeatmap.ControlPointInfo;
|
||||
var controlPointInfo = context.Beatmap.ControlPointInfo;
|
||||
|
||||
foreach (var hitobject in playableBeatmap.HitObjects)
|
||||
foreach (var hitobject in context.Beatmap.HitObjects)
|
||||
{
|
||||
double startUnsnap = hitobject.StartTime - controlPointInfo.GetClosestSnappedTime(hitobject.StartTime);
|
||||
string startPostfix = hitobject is IHasDuration ? "start" : "";
|
||||
|
@ -2,7 +2,6 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Beatmaps;
|
||||
|
||||
namespace osu.Game.Rulesets.Edit.Checks.Components
|
||||
{
|
||||
@ -24,8 +23,7 @@ namespace osu.Game.Rulesets.Edit.Checks.Components
|
||||
/// <summary>
|
||||
/// Runs this check and returns any issues detected for the provided beatmap.
|
||||
/// </summary>
|
||||
/// <param name="playableBeatmap">The playable beatmap of the beatmap to run the check on.</param>
|
||||
/// <param name="workingBeatmap">The working beatmap of the beatmap to run the check on.</param>
|
||||
public IEnumerable<Issue> Run(IBeatmap playableBeatmap, IWorkingBeatmap workingBeatmap);
|
||||
/// <param name="context">The beatmap verifier context associated with the beatmap.</param>
|
||||
public IEnumerable<Issue> Run(BeatmapVerifierContext context);
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Edit.Checks.Components;
|
||||
|
||||
namespace osu.Game.Rulesets.Edit
|
||||
@ -12,6 +11,6 @@ namespace osu.Game.Rulesets.Edit
|
||||
/// </summary>
|
||||
public interface IBeatmapVerifier
|
||||
{
|
||||
public IEnumerable<Issue> Run(IBeatmap playableBeatmap, WorkingBeatmap workingBeatmap);
|
||||
public IEnumerable<Issue> Run(BeatmapVerifierContext context);
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,7 @@
|
||||
// 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 osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
@ -18,14 +16,6 @@ namespace osu.Game.Rulesets.Mods
|
||||
public override ModType Type => ModType.DifficultyIncrease;
|
||||
public override bool Ranked => true;
|
||||
|
||||
/// <summary>
|
||||
/// Check whether the provided hitobject should be considered the "first" hideable object.
|
||||
/// Can be used to skip spinners, for instance.
|
||||
/// </summary>
|
||||
/// <param name="hitObject">The hitobject to check.</param>
|
||||
[Obsolete("Use IsFirstAdjustableObject() instead.")] // Can be removed 20210506
|
||||
protected virtual bool IsFirstHideableObject(DrawableHitObject hitObject) => true;
|
||||
|
||||
public void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)
|
||||
{
|
||||
// Default value of ScoreProcessor's Rank in Hidden Mod should be SS+
|
||||
@ -46,39 +36,5 @@ namespace osu.Game.Rulesets.Mods
|
||||
return rank;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void ApplyIncreasedVisibilityState(DrawableHitObject hitObject, ArmedState state)
|
||||
{
|
||||
#pragma warning disable 618
|
||||
ApplyFirstObjectIncreaseVisibilityState(hitObject, state);
|
||||
#pragma warning restore 618
|
||||
}
|
||||
|
||||
protected override void ApplyNormalVisibilityState(DrawableHitObject hitObject, ArmedState state)
|
||||
{
|
||||
#pragma warning disable 618
|
||||
ApplyHiddenState(hitObject, state);
|
||||
#pragma warning restore 618
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Apply a special visibility state to the first object in a beatmap, if the user chooses to turn on the "increase first object visibility" setting.
|
||||
/// </summary>
|
||||
/// <param name="hitObject">The hit object to apply the state change to.</param>
|
||||
/// <param name="state">The state of the hit object.</param>
|
||||
[Obsolete("Use ApplyIncreasedVisibilityState() instead.")] // Can be removed 20210506
|
||||
protected virtual void ApplyFirstObjectIncreaseVisibilityState(DrawableHitObject hitObject, ArmedState state)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Apply a hidden state to the provided object.
|
||||
/// </summary>
|
||||
/// <param name="hitObject">The hit object to apply the state change to.</param>
|
||||
/// <param name="state">The state of the hit object.</param>
|
||||
[Obsolete("Use ApplyNormalVisibilityState() instead.")] // Can be removed 20210506
|
||||
protected virtual void ApplyHiddenState(DrawableHitObject hitObject, ArmedState state)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Framework.Extensions.ObjectExtensions;
|
||||
using osu.Framework.Testing;
|
||||
|
||||
namespace osu.Game.Rulesets
|
||||
@ -27,7 +28,7 @@ namespace osu.Game.Rulesets
|
||||
{
|
||||
if (!Available) return null;
|
||||
|
||||
var ruleset = (Ruleset)Activator.CreateInstance(Type.GetType(InstantiationInfo));
|
||||
var ruleset = (Ruleset)Activator.CreateInstance(Type.GetType(InstantiationInfo).AsNonNull());
|
||||
|
||||
// overwrite the pre-populated RulesetInfo with a potentially database attached copy.
|
||||
ruleset.RulesetInfo = this;
|
||||
|
@ -7,6 +7,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using osu.Framework;
|
||||
using osu.Framework.Extensions.ObjectExtensions;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.Database;
|
||||
@ -111,7 +112,7 @@ namespace osu.Game.Rulesets
|
||||
{
|
||||
try
|
||||
{
|
||||
var instanceInfo = ((Ruleset)Activator.CreateInstance(Type.GetType(r.InstantiationInfo))).RulesetInfo;
|
||||
var instanceInfo = ((Ruleset)Activator.CreateInstance(Type.GetType(r.InstantiationInfo).AsNonNull())).RulesetInfo;
|
||||
|
||||
r.Name = instanceInfo.Name;
|
||||
r.ShortName = instanceInfo.ShortName;
|
||||
|
@ -3,9 +3,11 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
@ -24,6 +26,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
/// Includes selection and manipulation support via a <see cref="Components.SelectionHandler{T}"/>.
|
||||
/// </summary>
|
||||
public abstract class BlueprintContainer<T> : CompositeDrawable, IKeyBindingHandler<PlatformAction>
|
||||
where T : class
|
||||
{
|
||||
protected DragBox DragBox { get; private set; }
|
||||
|
||||
@ -39,6 +42,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
[Resolved(CanBeNull = true)]
|
||||
private IEditorChangeHandler changeHandler { get; set; }
|
||||
|
||||
protected readonly BindableList<T> SelectedItems = new BindableList<T>();
|
||||
|
||||
protected BlueprintContainer()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
@ -47,6 +52,24 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
SelectedItems.CollectionChanged += (selectedObjects, args) =>
|
||||
{
|
||||
switch (args.Action)
|
||||
{
|
||||
case NotifyCollectionChangedAction.Add:
|
||||
foreach (var o in args.NewItems)
|
||||
SelectionBlueprints.FirstOrDefault(b => b.Item == o)?.Select();
|
||||
|
||||
break;
|
||||
|
||||
case NotifyCollectionChangedAction.Remove:
|
||||
foreach (var o in args.OldItems)
|
||||
SelectionBlueprints.FirstOrDefault(b => b.Item == o)?.Deselect();
|
||||
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
SelectionHandler = CreateSelectionHandler();
|
||||
SelectionHandler.DeselectAll = deselectAll;
|
||||
|
||||
|
@ -2,10 +2,8 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input.Events;
|
||||
@ -25,8 +23,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
|
||||
protected readonly HitObjectComposer Composer;
|
||||
|
||||
private readonly BindableList<HitObject> selectedHitObjects = new BindableList<HitObject>();
|
||||
|
||||
protected EditorBlueprintContainer(HitObjectComposer composer)
|
||||
{
|
||||
Composer = composer;
|
||||
@ -35,23 +31,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
selectedHitObjects.BindTo(Beatmap.SelectedHitObjects);
|
||||
selectedHitObjects.CollectionChanged += (selectedObjects, args) =>
|
||||
{
|
||||
switch (args.Action)
|
||||
{
|
||||
case NotifyCollectionChangedAction.Add:
|
||||
foreach (var o in args.NewItems)
|
||||
SelectionBlueprints.FirstOrDefault(b => b.Item == o)?.Select();
|
||||
break;
|
||||
|
||||
case NotifyCollectionChangedAction.Remove:
|
||||
foreach (var o in args.OldItems)
|
||||
SelectionBlueprints.FirstOrDefault(b => b.Item == o)?.Deselect();
|
||||
|
||||
break;
|
||||
}
|
||||
};
|
||||
SelectedItems.BindTo(Beatmap.SelectedHitObjects);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
|
@ -84,8 +84,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
if (activeHandle?.IsHeld == true)
|
||||
return;
|
||||
|
||||
activeHandle = rotationHandles.SingleOrDefault(h => h.IsHeld || h.IsHovered);
|
||||
activeHandle ??= allDragHandles.SingleOrDefault(h => h.IsHovered);
|
||||
activeHandle = rotationHandles.FirstOrDefault(h => h.IsHeld || h.IsHovered);
|
||||
activeHandle ??= allDragHandles.FirstOrDefault(h => h.IsHovered);
|
||||
|
||||
if (activeHandle != null)
|
||||
{
|
||||
|
@ -635,6 +635,9 @@ namespace osu.Game.Screens.Edit
|
||||
case EditorScreenMode.Verify:
|
||||
currentScreen = new VerifyScreen();
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new InvalidOperationException("Editor menu bar switched to an unsupported mode");
|
||||
}
|
||||
|
||||
LoadComponentAsync(currentScreen, newScreen =>
|
||||
|
@ -37,6 +37,7 @@ namespace osu.Game.Screens.Edit.Verify
|
||||
|
||||
private IBeatmapVerifier rulesetVerifier;
|
||||
private BeatmapVerifier generalVerifier;
|
||||
private BeatmapVerifierContext context;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OverlayColourProvider colours)
|
||||
@ -44,6 +45,9 @@ namespace osu.Game.Screens.Edit.Verify
|
||||
generalVerifier = new BeatmapVerifier();
|
||||
rulesetVerifier = beatmap.BeatmapInfo.Ruleset?.CreateInstance()?.CreateBeatmapVerifier();
|
||||
|
||||
context = new BeatmapVerifierContext(beatmap, workingBeatmap.Value, verify.InterpretedDifficulty.Value);
|
||||
verify.InterpretedDifficulty.BindValueChanged(difficulty => context.InterpretedDifficulty = difficulty.NewValue);
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
@ -91,10 +95,10 @@ namespace osu.Game.Screens.Edit.Verify
|
||||
|
||||
private void refresh()
|
||||
{
|
||||
var issues = generalVerifier.Run(beatmap, workingBeatmap.Value);
|
||||
var issues = generalVerifier.Run(context);
|
||||
|
||||
if (rulesetVerifier != null)
|
||||
issues = issues.Concat(rulesetVerifier.Run(beatmap, workingBeatmap.Value));
|
||||
issues = issues.Concat(rulesetVerifier.Run(context));
|
||||
|
||||
issues = filter(issues);
|
||||
|
||||
|
@ -108,7 +108,7 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
difficultyIconContainer.Child = new DifficultyIcon(beatmap.Value, ruleset.Value, requiredMods) { Size = new Vector2(32) };
|
||||
|
||||
beatmapText.Clear();
|
||||
beatmapText.AddLink(Item.Beatmap.ToString(), LinkAction.OpenBeatmap, Item.Beatmap.Value.OnlineBeatmapID.ToString());
|
||||
beatmapText.AddLink(Item.Beatmap.Value.ToRomanisableString(), LinkAction.OpenBeatmap, Item.Beatmap.Value.OnlineBeatmapID.ToString());
|
||||
|
||||
authorText.Clear();
|
||||
|
||||
|
@ -150,7 +150,11 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
||||
protected void StartPlay()
|
||||
{
|
||||
sampleStart?.Play();
|
||||
ParentScreen?.Push(CreateGameplayScreen());
|
||||
|
||||
// fallback is to allow this class to operate when there is no parent OnlineScreen (testing purposes).
|
||||
var targetScreen = (Screen)ParentScreen ?? this;
|
||||
|
||||
targetScreen.Push(CreateGameplayScreen());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -27,6 +27,7 @@ using osu.Game.Screens.OnlinePlay.Match.Components;
|
||||
using osu.Game.Screens.OnlinePlay.Multiplayer.Match;
|
||||
using osu.Game.Screens.OnlinePlay.Multiplayer.Participants;
|
||||
using osu.Game.Screens.OnlinePlay.Multiplayer.Spectate;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Screens.Play.HUD;
|
||||
using osu.Game.Users;
|
||||
using osuTK;
|
||||
@ -452,7 +453,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
||||
return new MultiSpectatorScreen(userIds);
|
||||
|
||||
default:
|
||||
return new MultiplayerPlayer(SelectedItem.Value, userIds);
|
||||
return new PlayerLoader(() => new MultiplayerPlayer(SelectedItem.Value, userIds));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@ using osu.Game.Online.Rooms;
|
||||
using osu.Game.Screens.OnlinePlay.Components;
|
||||
using osu.Game.Screens.OnlinePlay.Match;
|
||||
using osu.Game.Screens.OnlinePlay.Match.Components;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Screens.Play.HUD;
|
||||
using osu.Game.Users;
|
||||
using osuTK;
|
||||
@ -271,9 +272,9 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
}, true);
|
||||
}
|
||||
|
||||
protected override Screen CreateGameplayScreen() => new PlaylistsPlayer(SelectedItem.Value)
|
||||
protected override Screen CreateGameplayScreen() => new PlayerLoader(() => new PlaylistsPlayer(SelectedItem.Value)
|
||||
{
|
||||
Exited = () => leaderboard.RefreshScores()
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
@ -14,6 +15,7 @@ using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Screens.Play.HUD;
|
||||
using osu.Game.Screens.Ranking.Expanded;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
@ -25,7 +27,7 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
private readonly WorkingBeatmap beatmap;
|
||||
private readonly Bindable<IReadOnlyList<Mod>> mods;
|
||||
private readonly Drawable facade;
|
||||
private readonly Drawable logoFacade;
|
||||
private LoadingSpinner loading;
|
||||
|
||||
public IBindable<IReadOnlyList<Mod>> Mods => mods;
|
||||
@ -41,19 +43,24 @@ namespace osu.Game.Screens.Play
|
||||
}
|
||||
}
|
||||
|
||||
public BeatmapMetadataDisplay(WorkingBeatmap beatmap, Bindable<IReadOnlyList<Mod>> mods, Drawable facade)
|
||||
public BeatmapMetadataDisplay(WorkingBeatmap beatmap, Bindable<IReadOnlyList<Mod>> mods, Drawable logoFacade)
|
||||
{
|
||||
this.beatmap = beatmap;
|
||||
this.facade = facade;
|
||||
this.logoFacade = logoFacade;
|
||||
|
||||
this.mods = new Bindable<IReadOnlyList<Mod>>();
|
||||
this.mods.BindTo(mods);
|
||||
}
|
||||
|
||||
private IBindable<StarDifficulty?> starDifficulty;
|
||||
|
||||
private FillFlowContainer versionFlow;
|
||||
private StarRatingDisplay starRatingDisplay;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
private void load(BeatmapDifficultyCache difficultyCache)
|
||||
{
|
||||
var metadata = beatmap.BeatmapInfo?.Metadata ?? new BeatmapMetadata();
|
||||
var metadata = beatmap.BeatmapInfo.Metadata;
|
||||
|
||||
AutoSizeAxes = Axes.Both;
|
||||
Children = new Drawable[]
|
||||
@ -66,7 +73,7 @@ namespace osu.Game.Screens.Play
|
||||
Direction = FillDirection.Vertical,
|
||||
Children = new[]
|
||||
{
|
||||
facade.With(d =>
|
||||
logoFacade.With(d =>
|
||||
{
|
||||
d.Anchor = Anchor.TopCentre;
|
||||
d.Origin = Anchor.TopCentre;
|
||||
@ -107,16 +114,30 @@ namespace osu.Game.Screens.Play
|
||||
loading = new LoadingLayer(true)
|
||||
}
|
||||
},
|
||||
new OsuSpriteText
|
||||
versionFlow = new FillFlowContainer
|
||||
{
|
||||
Text = beatmap?.BeatmapInfo?.Version,
|
||||
Font = OsuFont.GetFont(size: 26, italics: true),
|
||||
Origin = Anchor.TopCentre,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.TopCentre,
|
||||
Margin = new MarginPadding
|
||||
Origin = Anchor.TopCentre,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(5f),
|
||||
Margin = new MarginPadding { Bottom = 40 },
|
||||
Children = new Drawable[]
|
||||
{
|
||||
Bottom = 40
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = beatmap?.BeatmapInfo?.Version,
|
||||
Font = OsuFont.GetFont(size: 26, italics: true),
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
},
|
||||
starRatingDisplay = new StarRatingDisplay(default)
|
||||
{
|
||||
Alpha = 0f,
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
}
|
||||
}
|
||||
},
|
||||
new GridContainer
|
||||
{
|
||||
@ -159,9 +180,38 @@ namespace osu.Game.Screens.Play
|
||||
}
|
||||
};
|
||||
|
||||
starDifficulty = difficultyCache.GetBindableDifficulty(beatmap.BeatmapInfo);
|
||||
|
||||
Loading = true;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
if (starDifficulty.Value != null)
|
||||
{
|
||||
starRatingDisplay.Current.Value = starDifficulty.Value.Value;
|
||||
starRatingDisplay.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
starRatingDisplay.Hide();
|
||||
|
||||
starDifficulty.ValueChanged += d =>
|
||||
{
|
||||
Debug.Assert(d.NewValue != null);
|
||||
|
||||
starRatingDisplay.Current.Value = d.NewValue.Value;
|
||||
|
||||
versionFlow.AutoSizeDuration = 300;
|
||||
versionFlow.AutoSizeEasing = Easing.OutQuint;
|
||||
|
||||
starRatingDisplay.FadeIn(300, Easing.InQuint);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private class MetadataLineLabel : OsuSpriteText
|
||||
{
|
||||
public MetadataLineLabel(string text)
|
||||
|
@ -2,23 +2,13 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.Play.HUD
|
||||
{
|
||||
public class DefaultAccuracyCounter : GameplayAccuracyCounter, ISkinnableComponent
|
||||
public class DefaultAccuracyCounter : GameplayAccuracyCounter, ISkinnableDrawable
|
||||
{
|
||||
private readonly Vector2 offset = new Vector2(-20, 5);
|
||||
|
||||
public DefaultAccuracyCounter()
|
||||
{
|
||||
Origin = Anchor.TopRight;
|
||||
Anchor = Anchor.TopRight;
|
||||
}
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
private HUDOverlay hud { get; set; }
|
||||
|
||||
@ -27,17 +17,5 @@ namespace osu.Game.Screens.Play.HUD
|
||||
{
|
||||
Colour = colours.BlueLighter;
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (hud?.ScoreCounter.Drawable is DefaultScoreCounter score)
|
||||
{
|
||||
// for now align with the score counter. eventually this will be user customisable.
|
||||
Anchor = Anchor.TopLeft;
|
||||
Position = Parent.ToLocalSpace(score.ScreenSpaceDrawQuad.TopLeft) + offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,14 +9,11 @@ using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.Play.HUD
|
||||
{
|
||||
public class DefaultComboCounter : RollingCounter<int>, ISkinnableComponent
|
||||
public class DefaultComboCounter : RollingCounter<int>, ISkinnableDrawable
|
||||
{
|
||||
private readonly Vector2 offset = new Vector2(20, 5);
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
private HUDOverlay hud { get; set; }
|
||||
|
||||
@ -32,17 +29,6 @@ namespace osu.Game.Screens.Play.HUD
|
||||
Current.BindTo(scoreProcessor.Combo);
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (hud?.ScoreCounter.Drawable is DefaultScoreCounter score)
|
||||
{
|
||||
// for now align with the score counter. eventually this will be user customisable.
|
||||
Position = Parent.ToLocalSpace(score.ScreenSpaceDrawQuad.TopRight) + offset;
|
||||
}
|
||||
}
|
||||
|
||||
protected override string FormatCount(int count)
|
||||
{
|
||||
return $@"{count}x";
|
||||
|
@ -17,7 +17,7 @@ using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Screens.Play.HUD
|
||||
{
|
||||
public class DefaultHealthDisplay : HealthDisplay, IHasAccentColour, ISkinnableComponent
|
||||
public class DefaultHealthDisplay : HealthDisplay, IHasAccentColour, ISkinnableDrawable
|
||||
{
|
||||
/// <summary>
|
||||
/// The base opacity of the glow.
|
||||
|
@ -8,7 +8,7 @@ using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Screens.Play.HUD
|
||||
{
|
||||
public class DefaultScoreCounter : GameplayScoreCounter, ISkinnableComponent
|
||||
public class DefaultScoreCounter : GameplayScoreCounter, ISkinnableDrawable
|
||||
{
|
||||
public DefaultScoreCounter()
|
||||
: base(6)
|
||||
@ -24,12 +24,6 @@ namespace osu.Game.Screens.Play.HUD
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
Colour = colours.BlueLighter;
|
||||
|
||||
// todo: check if default once health display is skinnable
|
||||
hud?.ShowHealthbar.BindValueChanged(healthBar =>
|
||||
{
|
||||
this.MoveToY(healthBar.NewValue ? 30 : 0, HUDOverlay.FADE_DURATION, HUDOverlay.FADE_EASING);
|
||||
}, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,13 +13,12 @@ using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
||||
{
|
||||
public class BarHitErrorMeter : HitErrorMeter, ISkinnableComponent
|
||||
public class BarHitErrorMeter : HitErrorMeter
|
||||
{
|
||||
private readonly Anchor alignment;
|
||||
|
||||
|
@ -15,7 +15,7 @@ namespace osu.Game.Screens.Play.HUD
|
||||
/// <summary>
|
||||
/// Uses the 'x' symbol and has a pop-out effect while rolling over.
|
||||
/// </summary>
|
||||
public class LegacyComboCounter : CompositeDrawable, ISkinnableComponent
|
||||
public class LegacyComboCounter : CompositeDrawable, ISkinnableDrawable
|
||||
{
|
||||
public Bindable<int> Current { get; } = new BindableInt { MinValue = 0, };
|
||||
|
||||
@ -84,13 +84,13 @@ namespace osu.Game.Screens.Play.HUD
|
||||
{
|
||||
InternalChildren = new[]
|
||||
{
|
||||
popOutCount = new LegacySpriteText(skin, LegacyFont.Combo)
|
||||
popOutCount = new LegacySpriteText(LegacyFont.Combo)
|
||||
{
|
||||
Alpha = 0,
|
||||
Margin = new MarginPadding(0.05f),
|
||||
Blending = BlendingParameters.Additive,
|
||||
},
|
||||
displayedCountSpriteText = new LegacySpriteText(skin, LegacyFont.Combo)
|
||||
displayedCountSpriteText = new LegacySpriteText(LegacyFont.Combo)
|
||||
{
|
||||
Alpha = 0,
|
||||
},
|
||||
|
@ -1,16 +0,0 @@
|
||||
// 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 osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Screens.Play.HUD
|
||||
{
|
||||
public class SkinnableAccuracyCounter : SkinnableDrawable
|
||||
{
|
||||
public SkinnableAccuracyCounter()
|
||||
: base(new HUDSkinComponent(HUDSkinComponents.AccuracyCounter), _ => new DefaultAccuracyCounter())
|
||||
{
|
||||
CentreComponent = false;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
// 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 osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Screens.Play.HUD
|
||||
{
|
||||
public class SkinnableComboCounter : SkinnableDrawable
|
||||
{
|
||||
public SkinnableComboCounter()
|
||||
: base(new HUDSkinComponent(HUDSkinComponents.ComboCounter), skinComponent => new DefaultComboCounter())
|
||||
{
|
||||
CentreComponent = false;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
// 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 osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Screens.Play.HUD
|
||||
{
|
||||
public class SkinnableHealthDisplay : SkinnableDrawable
|
||||
{
|
||||
public SkinnableHealthDisplay()
|
||||
: base(new HUDSkinComponent(HUDSkinComponents.HealthDisplay), _ => new DefaultHealthDisplay())
|
||||
{
|
||||
CentreComponent = false;
|
||||
}
|
||||
}
|
||||
}
|
74
osu.Game/Screens/Play/HUD/SkinnableInfo.cs
Normal file
74
osu.Game/Screens/Play/HUD/SkinnableInfo.cs
Normal file
@ -0,0 +1,74 @@
|
||||
// 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 System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Extensions;
|
||||
using osu.Game.IO.Serialization;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.Play.HUD
|
||||
{
|
||||
/// <summary>
|
||||
/// Serialised information governing custom changes to an <see cref="ISkinnableDrawable"/>.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class SkinnableInfo : IJsonSerializable
|
||||
{
|
||||
public Type Type { get; set; }
|
||||
|
||||
public Vector2 Position { get; set; }
|
||||
|
||||
public float Rotation { get; set; }
|
||||
|
||||
public Vector2 Scale { get; set; }
|
||||
|
||||
public Anchor Anchor { get; set; }
|
||||
|
||||
public Anchor Origin { get; set; }
|
||||
|
||||
public List<SkinnableInfo> Children { get; } = new List<SkinnableInfo>();
|
||||
|
||||
[JsonConstructor]
|
||||
public SkinnableInfo()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Construct a new instance populating all attributes from the provided drawable.
|
||||
/// </summary>
|
||||
/// <param name="component">The drawable which attributes should be sourced from.</param>
|
||||
public SkinnableInfo(Drawable component)
|
||||
{
|
||||
Type = component.GetType();
|
||||
|
||||
Position = component.Position;
|
||||
Rotation = component.Rotation;
|
||||
Scale = component.Scale;
|
||||
Anchor = component.Anchor;
|
||||
Origin = component.Origin;
|
||||
|
||||
if (component is Container<Drawable> container)
|
||||
{
|
||||
foreach (var child in container.OfType<ISkinnableDrawable>().OfType<Drawable>())
|
||||
Children.Add(child.CreateSkinnableInfo());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Construct an instance of the drawable with all attributes applied.
|
||||
/// </summary>
|
||||
/// <returns>The new instance.</returns>
|
||||
public Drawable CreateInstance()
|
||||
{
|
||||
Drawable d = (Drawable)Activator.CreateInstance(Type);
|
||||
d.ApplySkinnableInfo(this);
|
||||
return d;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
// 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 osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Screens.Play.HUD
|
||||
{
|
||||
public class SkinnableScoreCounter : SkinnableDrawable
|
||||
{
|
||||
public SkinnableScoreCounter()
|
||||
: base(new HUDSkinComponent(HUDSkinComponents.ScoreCounter), _ => new DefaultScoreCounter())
|
||||
{
|
||||
CentreComponent = false;
|
||||
}
|
||||
}
|
||||
}
|
@ -3,8 +3,10 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.EnumExtensions;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -22,7 +24,7 @@ using osuTK;
|
||||
namespace osu.Game.Screens.Play
|
||||
{
|
||||
[Cached]
|
||||
public class HUDOverlay : Container, IKeyBindingHandler<GlobalAction>, IDefaultSkinnableTarget
|
||||
public class HUDOverlay : Container, IKeyBindingHandler<GlobalAction>
|
||||
{
|
||||
public const float FADE_DURATION = 300;
|
||||
|
||||
@ -33,10 +35,12 @@ namespace osu.Game.Screens.Play
|
||||
/// </summary>
|
||||
public float TopScoringElementsHeight { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The total height of all the bottom of screen scoring elements.
|
||||
/// </summary>
|
||||
public float BottomScoringElementsHeight { get; private set; }
|
||||
|
||||
public readonly KeyCounterDisplay KeyCounter;
|
||||
public readonly SkinnableScoreCounter ScoreCounter;
|
||||
public readonly SkinnableAccuracyCounter AccuracyCounter;
|
||||
public readonly SongProgress Progress;
|
||||
public readonly ModDisplay ModDisplay;
|
||||
public readonly HoldForMenuButton HoldToQuit;
|
||||
public readonly PlayerSettingsOverlay PlayerSettingsOverlay;
|
||||
@ -59,8 +63,6 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
private static bool hasShownNotificationOnce;
|
||||
|
||||
public Action<double> RequestSeek;
|
||||
|
||||
private readonly FillFlowContainer bottomRightElements;
|
||||
private readonly FillFlowContainer topRightElements;
|
||||
|
||||
@ -68,6 +70,8 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
private bool holdingForHUD;
|
||||
|
||||
private readonly SkinnableTargetContainer mainComponents;
|
||||
|
||||
private IEnumerable<Drawable> hideTargets => new Drawable[] { visibilityContainer, KeyCounter, topRightElements };
|
||||
|
||||
public HUDOverlay(DrawableRuleset drawableRuleset, IReadOnlyList<Mod> mods)
|
||||
@ -83,37 +87,22 @@ namespace osu.Game.Screens.Play
|
||||
visibilityContainer = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = new GridContainer
|
||||
Children = new Drawable[]
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Content = new[]
|
||||
mainComponents = new SkinnableTargetContainer(SkinnableTarget.MainHUDComponents)
|
||||
{
|
||||
new Drawable[]
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
CreateHealthDisplay(),
|
||||
AccuracyCounter = CreateAccuracyCounter(),
|
||||
ScoreCounter = CreateScoreCounter(),
|
||||
CreateComboCounter(),
|
||||
CreateHitErrorDisplayOverlay(),
|
||||
}
|
||||
},
|
||||
},
|
||||
new Drawable[]
|
||||
{
|
||||
Progress = CreateProgress(),
|
||||
// still need to be migrated; a bit more involved.
|
||||
new HitErrorDisplay(this.drawableRuleset?.FirstAvailableHitWindows),
|
||||
}
|
||||
},
|
||||
RowDimensions = new[]
|
||||
{
|
||||
new Dimension(),
|
||||
new Dimension(GridSizeMode.AutoSize)
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
topRightElements = new FillFlowContainer
|
||||
{
|
||||
@ -154,10 +143,6 @@ namespace osu.Game.Screens.Play
|
||||
if (drawableRuleset != null)
|
||||
{
|
||||
BindDrawableRuleset(drawableRuleset);
|
||||
|
||||
Progress.Objects = drawableRuleset.Objects;
|
||||
Progress.RequestSeek = time => RequestSeek(time);
|
||||
Progress.ReferenceClock = drawableRuleset.FrameStableClock;
|
||||
}
|
||||
|
||||
ModDisplay.Current.Value = mods;
|
||||
@ -196,12 +181,43 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
base.Update();
|
||||
|
||||
// HACK: for now align with the accuracy counter.
|
||||
// this is done for the sake of hacky legacy skins which extend the health bar to take up the full screen area.
|
||||
// it only works with the default skin due to padding offsetting it *just enough* to coexist.
|
||||
topRightElements.Y = TopScoringElementsHeight = ToLocalSpace(AccuracyCounter.Drawable.ScreenSpaceDrawQuad.BottomRight).Y;
|
||||
Vector2? lowestTopScreenSpace = null;
|
||||
Vector2? highestBottomScreenSpace = null;
|
||||
|
||||
bottomRightElements.Y = -Progress.Height;
|
||||
// LINQ cast can be removed when IDrawable interface includes Anchor / RelativeSizeAxes.
|
||||
foreach (var element in mainComponents.Components.Cast<Drawable>())
|
||||
{
|
||||
// for now align top-right components with the bottom-edge of the lowest top-anchored hud element.
|
||||
if (!element.RelativeSizeAxes.HasFlagFast(Axes.X))
|
||||
continue;
|
||||
|
||||
if (element.Anchor.HasFlagFast(Anchor.TopRight))
|
||||
{
|
||||
// health bars are excluded for the sake of hacky legacy skins which extend the health bar to take up the full screen area.
|
||||
if (element is LegacyHealthDisplay)
|
||||
continue;
|
||||
|
||||
var bottomRight = element.ScreenSpaceDrawQuad.BottomRight;
|
||||
if (lowestTopScreenSpace == null || bottomRight.Y > lowestTopScreenSpace.Value.Y)
|
||||
lowestTopScreenSpace = bottomRight;
|
||||
}
|
||||
else if (element.Anchor.HasFlagFast(Anchor.y2))
|
||||
{
|
||||
var topLeft = element.ScreenSpaceDrawQuad.TopLeft;
|
||||
if (highestBottomScreenSpace == null || topLeft.Y < highestBottomScreenSpace.Value.Y)
|
||||
highestBottomScreenSpace = topLeft;
|
||||
}
|
||||
}
|
||||
|
||||
if (lowestTopScreenSpace.HasValue)
|
||||
topRightElements.Y = TopScoringElementsHeight = ToLocalSpace(lowestTopScreenSpace.Value).Y;
|
||||
else
|
||||
topRightElements.Y = 0;
|
||||
|
||||
if (highestBottomScreenSpace.HasValue)
|
||||
bottomRightElements.Y = BottomScoringElementsHeight = -(DrawHeight - ToLocalSpace(highestBottomScreenSpace.Value).Y);
|
||||
else
|
||||
bottomRightElements.Y = 0;
|
||||
}
|
||||
|
||||
private void updateVisibility()
|
||||
@ -257,52 +273,33 @@ namespace osu.Game.Screens.Play
|
||||
(drawableRuleset as ICanAttachKeyCounter)?.Attach(KeyCounter);
|
||||
|
||||
replayLoaded.BindTo(drawableRuleset.HasReplayLoaded);
|
||||
|
||||
Progress.BindDrawableRuleset(drawableRuleset);
|
||||
}
|
||||
|
||||
protected SkinnableAccuracyCounter CreateAccuracyCounter() => new SkinnableAccuracyCounter();
|
||||
|
||||
protected SkinnableScoreCounter CreateScoreCounter() => new SkinnableScoreCounter();
|
||||
|
||||
protected SkinnableComboCounter CreateComboCounter() => new SkinnableComboCounter();
|
||||
|
||||
protected SkinnableHealthDisplay CreateHealthDisplay() => new SkinnableHealthDisplay();
|
||||
|
||||
protected virtual FailingLayer CreateFailingLayer() => new FailingLayer
|
||||
protected FailingLayer CreateFailingLayer() => new FailingLayer
|
||||
{
|
||||
ShowHealth = { BindTarget = ShowHealthbar }
|
||||
};
|
||||
|
||||
protected virtual KeyCounterDisplay CreateKeyCounter() => new KeyCounterDisplay
|
||||
protected KeyCounterDisplay CreateKeyCounter() => new KeyCounterDisplay
|
||||
{
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.BottomRight,
|
||||
};
|
||||
|
||||
protected virtual SongProgress CreateProgress() => new SongProgress
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
};
|
||||
|
||||
protected virtual HoldForMenuButton CreateHoldForMenuButton() => new HoldForMenuButton
|
||||
protected HoldForMenuButton CreateHoldForMenuButton() => new HoldForMenuButton
|
||||
{
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.BottomRight,
|
||||
};
|
||||
|
||||
protected virtual ModDisplay CreateModsContainer() => new ModDisplay
|
||||
protected ModDisplay CreateModsContainer() => new ModDisplay
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
};
|
||||
|
||||
protected virtual HitErrorDisplay CreateHitErrorDisplayOverlay() => new HitErrorDisplay(drawableRuleset?.FirstAvailableHitWindows);
|
||||
|
||||
protected virtual PlayerSettingsOverlay CreatePlayerSettingsOverlay() => new PlayerSettingsOverlay();
|
||||
protected PlayerSettingsOverlay CreatePlayerSettingsOverlay() => new PlayerSettingsOverlay();
|
||||
|
||||
public bool OnPressed(GlobalAction action)
|
||||
{
|
||||
|
@ -154,6 +154,9 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
if (!LoadedBeatmapSuccessfully)
|
||||
return;
|
||||
|
||||
// replays should never be recorded or played back when autoplay is enabled
|
||||
if (!Mods.Value.Any(m => m is ModAutoplay))
|
||||
PrepareReplay();
|
||||
@ -198,6 +201,7 @@ namespace osu.Game.Screens.Play
|
||||
LocalUserPlaying.BindTo(osuGame.LocalUserPlaying);
|
||||
|
||||
DrawableRuleset = ruleset.CreateDrawableRulesetWith(playableBeatmap, Mods.Value);
|
||||
dependencies.CacheAs(DrawableRuleset);
|
||||
|
||||
ScoreProcessor = ruleset.CreateScoreProcessor();
|
||||
ScoreProcessor.ApplyBeatmap(playableBeatmap);
|
||||
@ -357,11 +361,6 @@ namespace osu.Game.Screens.Play
|
||||
AlwaysVisible = { BindTarget = DrawableRuleset.HasReplayLoaded },
|
||||
IsCounting = false
|
||||
},
|
||||
RequestSeek = time =>
|
||||
{
|
||||
GameplayClockContainer.Seek(time);
|
||||
GameplayClockContainer.Start();
|
||||
},
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre
|
||||
},
|
||||
@ -566,6 +565,12 @@ namespace osu.Game.Screens.Play
|
||||
updateSampleDisabledState();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Seek to a specific time in gameplay.
|
||||
/// </summary>
|
||||
/// <param name="time">The destination time to seek to.</param>
|
||||
public void Seek(double time) => GameplayClockContainer.Seek(time);
|
||||
|
||||
/// <summary>
|
||||
/// Restart gameplay via a parent <see cref="PlayerLoader"/>.
|
||||
/// <remarks>This can be called from a child screen in order to trigger the restart process.</remarks>
|
||||
|
@ -18,7 +18,7 @@ using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
{
|
||||
public class SongProgress : OverlayContainer
|
||||
public class SongProgress : OverlayContainer, ISkinnableDrawable
|
||||
{
|
||||
private const int info_height = 20;
|
||||
private const int bottom_bar_height = 5;
|
||||
@ -40,9 +40,6 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
public readonly Bindable<bool> ShowGraph = new Bindable<bool>();
|
||||
|
||||
//TODO: this isn't always correct (consider mania where a non-last object may last for longer than the last in the list).
|
||||
private double lastHitTime => objects.Last().GetEndTime() + 1;
|
||||
|
||||
public override bool HandleNonPositionalInput => AllowSeeking.Value;
|
||||
public override bool HandlePositionalInput => AllowSeeking.Value;
|
||||
|
||||
@ -50,6 +47,9 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
private double firstHitTime => objects.First().StartTime;
|
||||
|
||||
//TODO: this isn't always correct (consider mania where a non-last object may last for longer than the last in the list).
|
||||
private double lastHitTime => objects.Last().GetEndTime() + 1;
|
||||
|
||||
private IEnumerable<HitObject> objects;
|
||||
|
||||
public IEnumerable<HitObject> Objects
|
||||
@ -66,51 +66,58 @@ namespace osu.Game.Screens.Play
|
||||
}
|
||||
}
|
||||
|
||||
public IClock ReferenceClock;
|
||||
[Resolved(canBeNull: true)]
|
||||
private Player player { get; set; }
|
||||
|
||||
private IClock gameplayClock;
|
||||
[Resolved(canBeNull: true)]
|
||||
private GameplayClock gameplayClock { get; set; }
|
||||
|
||||
private IClock referenceClock;
|
||||
|
||||
public SongProgress()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Anchor = Anchor.BottomRight;
|
||||
Origin = Anchor.BottomRight;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new SongProgressDisplay
|
||||
info = new SongProgressInfo
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
info = new SongProgressInfo
|
||||
{
|
||||
Origin = Anchor.BottomLeft,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = info_height,
|
||||
},
|
||||
graph = new SongProgressGraph
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Height = graph_height,
|
||||
Margin = new MarginPadding { Bottom = bottom_bar_height },
|
||||
},
|
||||
bar = new SongProgressBar(bottom_bar_height, graph_height, handle_size)
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
OnSeek = time => RequestSeek?.Invoke(time),
|
||||
},
|
||||
}
|
||||
Origin = Anchor.BottomLeft,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = info_height,
|
||||
},
|
||||
graph = new SongProgressGraph
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Height = graph_height,
|
||||
Margin = new MarginPadding { Bottom = bottom_bar_height },
|
||||
},
|
||||
bar = new SongProgressBar(bottom_bar_height, graph_height, handle_size)
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
OnSeek = time => player?.Seek(time),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(OsuColour colours, GameplayClock clock, OsuConfigManager config)
|
||||
private void load(OsuColour colours, OsuConfigManager config, DrawableRuleset drawableRuleset)
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
if (clock != null)
|
||||
gameplayClock = clock;
|
||||
if (drawableRuleset != null)
|
||||
{
|
||||
AllowSeeking.BindTo(drawableRuleset.HasReplayLoaded);
|
||||
|
||||
referenceClock = drawableRuleset.FrameStableClock;
|
||||
Objects = drawableRuleset.Objects;
|
||||
}
|
||||
|
||||
config.BindWith(OsuSetting.ShowProgressGraph, ShowGraph);
|
||||
|
||||
@ -125,11 +132,6 @@ namespace osu.Game.Screens.Play
|
||||
ShowGraph.BindValueChanged(_ => updateGraphVisibility(), true);
|
||||
}
|
||||
|
||||
public void BindDrawableRuleset(DrawableRuleset drawableRuleset)
|
||||
{
|
||||
AllowSeeking.BindTo(drawableRuleset.HasReplayLoaded);
|
||||
}
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
this.FadeIn(500, Easing.OutQuint);
|
||||
@ -148,7 +150,7 @@ namespace osu.Game.Screens.Play
|
||||
return;
|
||||
|
||||
double gameplayTime = gameplayClock?.CurrentTime ?? Time.Current;
|
||||
double frameStableTime = ReferenceClock?.CurrentTime ?? gameplayTime;
|
||||
double frameStableTime = referenceClock?.CurrentTime ?? gameplayTime;
|
||||
|
||||
double progress = Math.Min(1, (frameStableTime - firstHitTime) / (lastHitTime - firstHitTime));
|
||||
|
||||
@ -180,19 +182,5 @@ namespace osu.Game.Screens.Play
|
||||
float finalMargin = bottom_bar_height + (AllowSeeking.Value ? handle_size.Y : 0) + (ShowGraph.Value ? graph_height : 0);
|
||||
info.TransformTo(nameof(info.Margin), new MarginPadding { Bottom = finalMargin }, transition_duration, Easing.In);
|
||||
}
|
||||
|
||||
public class SongProgressDisplay : Container, ISkinnableComponent
|
||||
{
|
||||
public SongProgressDisplay()
|
||||
{
|
||||
// TODO: move actual implementation into this.
|
||||
// exists for skin customisation purposes.
|
||||
|
||||
Masking = true;
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
Anchor = Anchor.BottomCentre;
|
||||
Origin = Anchor.BottomCentre;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user