mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 16:52:54 +08:00
Merge remote-tracking branch 'refs/remotes/origin/master' into legacy-beatmap-saving
This commit is contained in:
commit
abf3f341b7
@ -54,6 +54,6 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.1010.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2019.1205.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2019.1212.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
11
osu.Desktop/Properties/launchSettings.json
Normal file
11
osu.Desktop/Properties/launchSettings.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"profiles": {
|
||||
"osu! Desktop": {
|
||||
"commandName": "Project"
|
||||
},
|
||||
"osu! Tournament": {
|
||||
"commandName": "Project",
|
||||
"commandLineArgs": "--tournament"
|
||||
}
|
||||
}
|
||||
}
|
@ -64,7 +64,7 @@ namespace osu.Game.Rulesets.Catch.Tests
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new[]
|
||||
{
|
||||
drawableRuleset = new DrawableCatchRuleset(new CatchRuleset(), beatmap, Array.Empty<Mod>())
|
||||
drawableRuleset = new DrawableCatchRuleset(new CatchRuleset(), beatmap.GetPlayableBeatmap(new CatchRuleset().RulesetInfo))
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -23,7 +23,7 @@ namespace osu.Game.Rulesets.Catch
|
||||
{
|
||||
public class CatchRuleset : Ruleset
|
||||
{
|
||||
public override DrawableRuleset CreateDrawableRulesetWith(IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods) => new DrawableCatchRuleset(this, beatmap, mods);
|
||||
public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList<Mod> mods = null) => new DrawableCatchRuleset(this, beatmap, mods);
|
||||
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new CatchBeatmapConverter(beatmap);
|
||||
public override IBeatmapProcessor CreateBeatmapProcessor(IBeatmap beatmap) => new CatchBeatmapProcessor(beatmap);
|
||||
|
||||
|
@ -12,14 +12,14 @@ namespace osu.Game.Rulesets.Catch.MathUtils
|
||||
{
|
||||
private const double int_to_real = 1.0 / (int.MaxValue + 1.0);
|
||||
private const uint int_mask = 0x7FFFFFFF;
|
||||
private const uint y = 842502087;
|
||||
private const uint z = 3579807591;
|
||||
private const uint w = 273326509;
|
||||
private uint _x, _y = y, _z = z, _w = w;
|
||||
private const uint y_initial = 842502087;
|
||||
private const uint z_initial = 3579807591;
|
||||
private const uint w_initial = 273326509;
|
||||
private uint x, y = y_initial, z = z_initial, w = w_initial;
|
||||
|
||||
public FastRandom(int seed)
|
||||
{
|
||||
_x = (uint)seed;
|
||||
x = (uint)seed;
|
||||
}
|
||||
|
||||
public FastRandom()
|
||||
@ -33,11 +33,11 @@ namespace osu.Game.Rulesets.Catch.MathUtils
|
||||
/// <returns>The random value.</returns>
|
||||
public uint NextUInt()
|
||||
{
|
||||
uint t = _x ^ (_x << 11);
|
||||
_x = _y;
|
||||
_y = _z;
|
||||
_z = _w;
|
||||
return _w = _w ^ (_w >> 19) ^ t ^ (t >> 8);
|
||||
uint t = x ^ (x << 11);
|
||||
x = y;
|
||||
y = z;
|
||||
z = w;
|
||||
return w = w ^ (w >> 19) ^ t ^ (t >> 8);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -2,23 +2,21 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Catch.Objects;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.UI;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.Scoring
|
||||
{
|
||||
public class CatchScoreProcessor : ScoreProcessor<CatchHitObject>
|
||||
public class CatchScoreProcessor : ScoreProcessor
|
||||
{
|
||||
public CatchScoreProcessor(DrawableRuleset<CatchHitObject> drawableRuleset)
|
||||
: base(drawableRuleset)
|
||||
public CatchScoreProcessor(IBeatmap beatmap)
|
||||
: base(beatmap)
|
||||
{
|
||||
}
|
||||
|
||||
private float hpDrainRate;
|
||||
|
||||
protected override void ApplyBeatmap(Beatmap<CatchHitObject> beatmap)
|
||||
protected override void ApplyBeatmap(IBeatmap beatmap)
|
||||
{
|
||||
base.ApplyBeatmap(beatmap);
|
||||
|
||||
|
@ -25,14 +25,14 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
|
||||
protected override bool UserScrollSpeedAdjustment => false;
|
||||
|
||||
public DrawableCatchRuleset(Ruleset ruleset, IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
||||
public DrawableCatchRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
|
||||
: base(ruleset, beatmap, mods)
|
||||
{
|
||||
Direction.Value = ScrollingDirection.Down;
|
||||
TimeRange.Value = BeatmapDifficulty.DifficultyRange(beatmap.Beatmap.BeatmapInfo.BaseDifficulty.ApproachRate, 1800, 1200, 450);
|
||||
TimeRange.Value = BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.BaseDifficulty.ApproachRate, 1800, 1200, 450);
|
||||
}
|
||||
|
||||
public override ScoreProcessor CreateScoreProcessor() => new CatchScoreProcessor(this);
|
||||
public override ScoreProcessor CreateScoreProcessor() => new CatchScoreProcessor(Beatmap);
|
||||
|
||||
protected override ReplayInputHandler CreateReplayInputHandler(Replay replay) => new CatchFramedReplayInputHandler(replay);
|
||||
|
||||
|
@ -16,7 +16,7 @@ namespace osu.Game.Rulesets.Mania.Edit
|
||||
{
|
||||
public new IScrollingInfo ScrollingInfo => base.ScrollingInfo;
|
||||
|
||||
public DrawableManiaEditRuleset(Ruleset ruleset, IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
||||
public DrawableManiaEditRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods)
|
||||
: base(ruleset, beatmap, mods)
|
||||
{
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ namespace osu.Game.Rulesets.Mania.Edit
|
||||
|
||||
public int TotalColumns => ((ManiaPlayfield)drawableRuleset.Playfield).TotalColumns;
|
||||
|
||||
protected override DrawableRuleset<ManiaHitObject> CreateDrawableRuleset(Ruleset ruleset, IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
||||
protected override DrawableRuleset<ManiaHitObject> CreateDrawableRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
|
||||
{
|
||||
drawableRuleset = new DrawableManiaEditRuleset(ruleset, beatmap, mods);
|
||||
|
||||
|
@ -31,7 +31,7 @@ namespace osu.Game.Rulesets.Mania
|
||||
{
|
||||
public class ManiaRuleset : Ruleset
|
||||
{
|
||||
public override DrawableRuleset CreateDrawableRulesetWith(IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods) => new DrawableManiaRuleset(this, beatmap, mods);
|
||||
public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList<Mod> mods = null) => new DrawableManiaRuleset(this, beatmap, mods);
|
||||
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new ManiaBeatmapConverter(beatmap);
|
||||
public override PerformanceCalculator CreatePerformanceCalculator(WorkingBeatmap beatmap, ScoreInfo score) => new ManiaPerformanceCalculator(this, beatmap, score);
|
||||
|
||||
|
@ -3,13 +3,11 @@
|
||||
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Mania.Objects;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.UI;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Scoring
|
||||
{
|
||||
internal class ManiaScoreProcessor : ScoreProcessor<ManiaHitObject>
|
||||
internal class ManiaScoreProcessor : ScoreProcessor
|
||||
{
|
||||
/// <summary>
|
||||
/// The hit HP multiplier at OD = 0.
|
||||
@ -51,12 +49,12 @@ namespace osu.Game.Rulesets.Mania.Scoring
|
||||
/// </summary>
|
||||
private double hpMultiplier = 1;
|
||||
|
||||
public ManiaScoreProcessor(DrawableRuleset<ManiaHitObject> drawableRuleset)
|
||||
: base(drawableRuleset)
|
||||
public ManiaScoreProcessor(IBeatmap beatmap)
|
||||
: base(beatmap)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void ApplyBeatmap(Beatmap<ManiaHitObject> beatmap)
|
||||
protected override void ApplyBeatmap(IBeatmap beatmap)
|
||||
{
|
||||
base.ApplyBeatmap(beatmap);
|
||||
|
||||
@ -65,7 +63,7 @@ namespace osu.Game.Rulesets.Mania.Scoring
|
||||
hpMissMultiplier = BeatmapDifficulty.DifficultyRange(difficulty.DrainRate, hp_multiplier_miss_min, hp_multiplier_miss_mid, hp_multiplier_miss_max);
|
||||
}
|
||||
|
||||
protected override void SimulateAutoplay(Beatmap<ManiaHitObject> beatmap)
|
||||
protected override void SimulateAutoplay(IBeatmap beatmap)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
|
@ -39,7 +39,7 @@ namespace osu.Game.Rulesets.Mania.UI
|
||||
|
||||
private readonly Bindable<ManiaScrollingDirection> configDirection = new Bindable<ManiaScrollingDirection>();
|
||||
|
||||
public DrawableManiaRuleset(Ruleset ruleset, IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
||||
public DrawableManiaRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
|
||||
: base(ruleset, beatmap, mods)
|
||||
{
|
||||
BarLines = new BarLineGenerator<BarLine>(Beatmap).BarLines;
|
||||
@ -67,7 +67,7 @@ namespace osu.Game.Rulesets.Mania.UI
|
||||
|
||||
protected override Playfield CreatePlayfield() => new ManiaPlayfield(Beatmap.Stages);
|
||||
|
||||
public override ScoreProcessor CreateScoreProcessor() => new ManiaScoreProcessor(this);
|
||||
public override ScoreProcessor CreateScoreProcessor() => new ManiaScoreProcessor(Beatmap);
|
||||
|
||||
public override int Variant => (int)(Beatmap.Stages.Count == 1 ? PlayfieldType.Single : PlayfieldType.Dual) + Beatmap.TotalColumns;
|
||||
|
||||
|
@ -11,6 +11,7 @@ using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
@ -20,10 +21,11 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
||||
{
|
||||
public class PathControlPointPiece : BlueprintPiece<Slider>
|
||||
{
|
||||
public Action<int, MouseButtonEvent> RequestSelection;
|
||||
public Action<PathControlPointPiece, MouseButtonEvent> RequestSelection;
|
||||
|
||||
public readonly BindableBool IsSelected = new BindableBool();
|
||||
public readonly int Index;
|
||||
|
||||
public readonly PathControlPoint ControlPoint;
|
||||
|
||||
private readonly Slider slider;
|
||||
private readonly Path path;
|
||||
@ -36,10 +38,14 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
||||
[Resolved]
|
||||
private OsuColour colours { get; set; }
|
||||
|
||||
public PathControlPointPiece(Slider slider, int index)
|
||||
private IBindable<Vector2> sliderPosition;
|
||||
private IBindable<int> pathVersion;
|
||||
|
||||
public PathControlPointPiece(Slider slider, PathControlPoint controlPoint)
|
||||
{
|
||||
this.slider = slider;
|
||||
Index = index;
|
||||
|
||||
ControlPoint = controlPoint;
|
||||
|
||||
Origin = Anchor.Centre;
|
||||
AutoSizeAxes = Axes.Both;
|
||||
@ -85,48 +91,41 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
||||
};
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.Update();
|
||||
base.LoadComplete();
|
||||
|
||||
Position = slider.StackedPosition + slider.Path.ControlPoints[Index].Position.Value;
|
||||
sliderPosition = slider.PositionBindable.GetBoundCopy();
|
||||
sliderPosition.BindValueChanged(_ => updateDisplay());
|
||||
|
||||
pathVersion = slider.Path.Version.GetBoundCopy();
|
||||
pathVersion.BindValueChanged(_ => updateDisplay());
|
||||
|
||||
IsSelected.BindValueChanged(_ => updateMarkerDisplay());
|
||||
|
||||
updateDisplay();
|
||||
}
|
||||
|
||||
private void updateDisplay()
|
||||
{
|
||||
updateMarkerDisplay();
|
||||
updateConnectingPath();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the state of the circular control point marker.
|
||||
/// </summary>
|
||||
private void updateMarkerDisplay()
|
||||
{
|
||||
markerRing.Alpha = IsSelected.Value ? 1 : 0;
|
||||
|
||||
Color4 colour = slider.Path.ControlPoints[Index].Type.Value.HasValue ? colours.Red : colours.Yellow;
|
||||
if (IsHovered || IsSelected.Value)
|
||||
colour = Color4.White;
|
||||
marker.Colour = colour;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the path connecting this control point to the previous one.
|
||||
/// </summary>
|
||||
private void updateConnectingPath()
|
||||
{
|
||||
path.ClearVertices();
|
||||
|
||||
if (Index != slider.Path.ControlPoints.Count - 1)
|
||||
{
|
||||
path.AddVertex(Vector2.Zero);
|
||||
path.AddVertex(slider.Path.ControlPoints[Index + 1].Position.Value - slider.Path.ControlPoints[Index].Position.Value);
|
||||
}
|
||||
|
||||
path.OriginPosition = path.PositionInBoundingBox(Vector2.Zero);
|
||||
}
|
||||
|
||||
// The connecting path is excluded from positional input
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => marker.ReceivePositionalInputAt(screenSpacePos);
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
updateMarkerDisplay();
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(HoverLostEvent e)
|
||||
{
|
||||
updateMarkerDisplay();
|
||||
}
|
||||
|
||||
protected override bool OnMouseDown(MouseDownEvent e)
|
||||
{
|
||||
if (RequestSelection == null)
|
||||
@ -135,12 +134,12 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
||||
switch (e.Button)
|
||||
{
|
||||
case MouseButton.Left:
|
||||
RequestSelection.Invoke(Index, e);
|
||||
RequestSelection.Invoke(this, e);
|
||||
return true;
|
||||
|
||||
case MouseButton.Right:
|
||||
if (!IsSelected.Value)
|
||||
RequestSelection.Invoke(Index, e);
|
||||
RequestSelection.Invoke(this, e);
|
||||
return false; // Allow context menu to show
|
||||
}
|
||||
|
||||
@ -155,7 +154,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
||||
|
||||
protected override bool OnDrag(DragEvent e)
|
||||
{
|
||||
if (Index == 0)
|
||||
if (ControlPoint == slider.Path.ControlPoints[0])
|
||||
{
|
||||
// Special handling for the head control point - the position of the slider changes which means the snapped position and time have to be taken into account
|
||||
(Vector2 snappedPosition, double snappedTime) = snapProvider?.GetSnappedPosition(e.MousePosition, slider.StartTime) ?? (e.MousePosition, slider.StartTime);
|
||||
@ -169,11 +168,47 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
||||
slider.Path.ControlPoints[i].Position.Value -= movementDelta;
|
||||
}
|
||||
else
|
||||
slider.Path.ControlPoints[Index].Position.Value += e.Delta;
|
||||
ControlPoint.Position.Value += e.Delta;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override bool OnDragEnd(DragEndEvent e) => true;
|
||||
|
||||
/// <summary>
|
||||
/// Updates the state of the circular control point marker.
|
||||
/// </summary>
|
||||
private void updateMarkerDisplay()
|
||||
{
|
||||
Position = slider.StackedPosition + ControlPoint.Position.Value;
|
||||
|
||||
markerRing.Alpha = IsSelected.Value ? 1 : 0;
|
||||
|
||||
Color4 colour = ControlPoint.Type.Value != null ? colours.Red : colours.Yellow;
|
||||
if (IsHovered || IsSelected.Value)
|
||||
colour = Color4.White;
|
||||
marker.Colour = colour;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the path connecting this control point to the previous one.
|
||||
/// </summary>
|
||||
private void updateConnectingPath()
|
||||
{
|
||||
path.ClearVertices();
|
||||
|
||||
int index = slider.Path.ControlPoints.IndexOf(ControlPoint);
|
||||
|
||||
if (index == -1)
|
||||
return;
|
||||
|
||||
if (++index != slider.Path.ControlPoints.Count)
|
||||
{
|
||||
path.AddVertex(Vector2.Zero);
|
||||
path.AddVertex(slider.Path.ControlPoints[index].Position.Value - ControlPoint.Position.Value);
|
||||
}
|
||||
|
||||
path.OriginPosition = path.PositionInBoundingBox(Vector2.Zero);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +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 System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Humanizer;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
@ -14,9 +15,8 @@ using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Screens.Edit.Compose;
|
||||
using osuTK;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
||||
@ -24,13 +24,16 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
||||
public class PathControlPointVisualiser : CompositeDrawable, IKeyBindingHandler<PlatformAction>, IHasContextMenu
|
||||
{
|
||||
internal readonly Container<PathControlPointPiece> Pieces;
|
||||
|
||||
private readonly Slider slider;
|
||||
|
||||
private readonly bool allowSelection;
|
||||
|
||||
private InputManager inputManager;
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
private IPlacementHandler placementHandler { get; set; }
|
||||
private IBindableList<PathControlPoint> controlPoints;
|
||||
|
||||
public Action<List<PathControlPoint>> RemoveControlPointsRequested;
|
||||
|
||||
public PathControlPointVisualiser(Slider slider, bool allowSelection)
|
||||
{
|
||||
@ -47,30 +50,40 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
||||
base.LoadComplete();
|
||||
|
||||
inputManager = GetContainingInputManager();
|
||||
|
||||
controlPoints = slider.Path.ControlPoints.GetBoundCopy();
|
||||
controlPoints.ItemsAdded += addControlPoints;
|
||||
controlPoints.ItemsRemoved += removeControlPoints;
|
||||
|
||||
addControlPoints(controlPoints);
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
private void addControlPoints(IEnumerable<PathControlPoint> controlPoints)
|
||||
{
|
||||
base.Update();
|
||||
|
||||
while (slider.Path.ControlPoints.Count > Pieces.Count)
|
||||
foreach (var point in controlPoints)
|
||||
{
|
||||
var piece = new PathControlPointPiece(slider, Pieces.Count);
|
||||
var piece = new PathControlPointPiece(slider, point);
|
||||
|
||||
if (allowSelection)
|
||||
piece.RequestSelection = selectPiece;
|
||||
|
||||
Pieces.Add(piece);
|
||||
}
|
||||
}
|
||||
|
||||
while (slider.Path.ControlPoints.Count < Pieces.Count)
|
||||
Pieces.Remove(Pieces[Pieces.Count - 1]);
|
||||
private void removeControlPoints(IEnumerable<PathControlPoint> controlPoints)
|
||||
{
|
||||
foreach (var point in controlPoints)
|
||||
Pieces.RemoveAll(p => p.ControlPoint == point);
|
||||
}
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
{
|
||||
foreach (var piece in Pieces)
|
||||
{
|
||||
piece.IsSelected.Value = false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -87,48 +100,26 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
||||
|
||||
public bool OnReleased(PlatformAction action) => action.ActionMethod == PlatformActionMethod.Delete;
|
||||
|
||||
private void selectPiece(int index, MouseButtonEvent e)
|
||||
private void selectPiece(PathControlPointPiece piece, MouseButtonEvent e)
|
||||
{
|
||||
if (e.Button == MouseButton.Left && inputManager.CurrentState.Keyboard.ControlPressed)
|
||||
Pieces[index].IsSelected.Toggle();
|
||||
piece.IsSelected.Toggle();
|
||||
else
|
||||
{
|
||||
foreach (var piece in Pieces)
|
||||
piece.IsSelected.Value = piece.Index == index;
|
||||
foreach (var p in Pieces)
|
||||
p.IsSelected.Value = p == piece;
|
||||
}
|
||||
}
|
||||
|
||||
private bool deleteSelected()
|
||||
{
|
||||
List<PathControlPoint> toRemove = Pieces.Where(p => p.IsSelected.Value).Select(p => slider.Path.ControlPoints[p.Index]).ToList();
|
||||
List<PathControlPoint> toRemove = Pieces.Where(p => p.IsSelected.Value).Select(p => p.ControlPoint).ToList();
|
||||
|
||||
// Ensure that there are any points to be deleted
|
||||
if (toRemove.Count == 0)
|
||||
return false;
|
||||
|
||||
foreach (var c in toRemove)
|
||||
{
|
||||
// The first control point in the slider must have a type, so take it from the previous "first" one
|
||||
// Todo: Should be handled within SliderPath itself
|
||||
if (c == slider.Path.ControlPoints[0] && slider.Path.ControlPoints.Count > 1 && slider.Path.ControlPoints[1].Type.Value == null)
|
||||
slider.Path.ControlPoints[1].Type.Value = slider.Path.ControlPoints[0].Type.Value;
|
||||
|
||||
slider.Path.ControlPoints.Remove(c);
|
||||
}
|
||||
|
||||
// If there are 0 or 1 remaining control points, the slider is in a degenerate (single point) form and should be deleted
|
||||
if (slider.Path.ControlPoints.Count <= 1)
|
||||
{
|
||||
placementHandler?.Delete(slider);
|
||||
return true;
|
||||
}
|
||||
|
||||
// The path will have a non-zero offset if the head is removed, but sliders don't support this behaviour since the head is positioned at the slider's position
|
||||
// So the slider needs to be offset by this amount instead, and all control points offset backwards such that the path is re-positioned at (0, 0)
|
||||
Vector2 first = slider.Path.ControlPoints[0].Position.Value;
|
||||
foreach (var c in slider.Path.ControlPoints)
|
||||
c.Position.Value -= first;
|
||||
slider.Position += first;
|
||||
RemoveControlPointsRequested?.Invoke(toRemove);
|
||||
|
||||
// Since pieces are re-used, they will not point to the deleted control points while remaining selected
|
||||
foreach (var piece in Pieces)
|
||||
@ -144,16 +135,63 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
||||
if (!Pieces.Any(p => p.IsHovered))
|
||||
return null;
|
||||
|
||||
int selectedPoints = Pieces.Count(p => p.IsSelected.Value);
|
||||
var selectedPieces = Pieces.Where(p => p.IsSelected.Value).ToList();
|
||||
int count = selectedPieces.Count;
|
||||
|
||||
if (selectedPoints == 0)
|
||||
if (count == 0)
|
||||
return null;
|
||||
|
||||
List<MenuItem> items = new List<MenuItem>();
|
||||
|
||||
if (!selectedPieces.Contains(Pieces[0]))
|
||||
items.Add(createMenuItemForPathType(null));
|
||||
|
||||
// todo: hide/disable items which aren't valid for selected points
|
||||
items.Add(createMenuItemForPathType(PathType.Linear));
|
||||
items.Add(createMenuItemForPathType(PathType.PerfectCurve));
|
||||
items.Add(createMenuItemForPathType(PathType.Bezier));
|
||||
items.Add(createMenuItemForPathType(PathType.Catmull));
|
||||
|
||||
return new MenuItem[]
|
||||
{
|
||||
new OsuMenuItem($"Delete {"control point".ToQuantity(selectedPoints, selectedPoints > 1 ? ShowQuantityAs.Numeric : ShowQuantityAs.None)}", MenuItemType.Destructive, () => deleteSelected())
|
||||
new OsuMenuItem($"Delete {"control point".ToQuantity(count, count > 1 ? ShowQuantityAs.Numeric : ShowQuantityAs.None)}", MenuItemType.Destructive, () => deleteSelected()),
|
||||
new OsuMenuItem("Curve type")
|
||||
{
|
||||
Items = items
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private MenuItem createMenuItemForPathType(PathType? type)
|
||||
{
|
||||
int totalCount = Pieces.Count(p => p.IsSelected.Value);
|
||||
int countOfState = Pieces.Where(p => p.IsSelected.Value).Count(p => p.ControlPoint.Type.Value == type);
|
||||
|
||||
var item = new PathTypeMenuItem(type, () =>
|
||||
{
|
||||
foreach (var p in Pieces.Where(p => p.IsSelected.Value))
|
||||
p.ControlPoint.Type.Value = type;
|
||||
});
|
||||
|
||||
if (countOfState == totalCount)
|
||||
item.State.Value = TernaryState.True;
|
||||
else if (countOfState > 0)
|
||||
item.State.Value = TernaryState.Indeterminate;
|
||||
else
|
||||
item.State.Value = TernaryState.False;
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
private class PathTypeMenuItem : TernaryStateMenuItem
|
||||
{
|
||||
public PathTypeMenuItem(PathType? type, Action action)
|
||||
: base(type == null ? "Inherit" : type.ToString().Humanize(), changeState, MenuItemType.Standard, _ => action?.Invoke())
|
||||
{
|
||||
}
|
||||
|
||||
private static TernaryState changeState(TernaryState state) => TernaryState.True;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +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 osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Input;
|
||||
@ -191,15 +190,5 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
||||
Initial,
|
||||
Body,
|
||||
}
|
||||
|
||||
private class Segment
|
||||
{
|
||||
public readonly List<Vector2> ControlPoints = new List<Vector2>();
|
||||
|
||||
public Segment(Vector2 offset)
|
||||
{
|
||||
ControlPoints.Add(offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +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.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
@ -14,6 +15,7 @@ using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||
using osu.Game.Screens.Edit.Compose;
|
||||
using osuTK;
|
||||
using osuTK.Input;
|
||||
|
||||
@ -29,6 +31,9 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
||||
[Resolved(CanBeNull = true)]
|
||||
private HitObjectComposer composer { get; set; }
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
private IPlacementHandler placementHandler { get; set; }
|
||||
|
||||
public SliderSelectionBlueprint(DrawableSlider slider)
|
||||
: base(slider)
|
||||
{
|
||||
@ -40,6 +45,9 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
||||
HeadBlueprint = CreateCircleSelectionBlueprint(slider, SliderPosition.Start),
|
||||
TailBlueprint = CreateCircleSelectionBlueprint(slider, SliderPosition.End),
|
||||
ControlPointVisualiser = new PathControlPointVisualiser(sliderObject, true)
|
||||
{
|
||||
RemoveControlPointsRequested = removeControlPoints
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -97,6 +105,8 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
||||
return true;
|
||||
}
|
||||
|
||||
private BindableList<PathControlPoint> controlPoints => HitObject.Path.ControlPoints;
|
||||
|
||||
private int addControlPoint(Vector2 position)
|
||||
{
|
||||
position -= HitObject.Position;
|
||||
@ -104,9 +114,9 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
||||
int insertionIndex = 0;
|
||||
float minDistance = float.MaxValue;
|
||||
|
||||
for (int i = 0; i < HitObject.Path.ControlPoints.Count - 1; i++)
|
||||
for (int i = 0; i < controlPoints.Count - 1; i++)
|
||||
{
|
||||
float dist = new Line(HitObject.Path.ControlPoints[i].Position.Value, HitObject.Path.ControlPoints[i + 1].Position.Value).DistanceToPoint(position);
|
||||
float dist = new Line(controlPoints[i].Position.Value, controlPoints[i + 1].Position.Value).DistanceToPoint(position);
|
||||
|
||||
if (dist < minDistance)
|
||||
{
|
||||
@ -116,11 +126,42 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
||||
}
|
||||
|
||||
// Move the control points from the insertion index onwards to make room for the insertion
|
||||
HitObject.Path.ControlPoints.Insert(insertionIndex, new PathControlPoint { Position = { Value = position } });
|
||||
controlPoints.Insert(insertionIndex, new PathControlPoint { Position = { Value = position } });
|
||||
|
||||
return insertionIndex;
|
||||
}
|
||||
|
||||
private void removeControlPoints(List<PathControlPoint> toRemove)
|
||||
{
|
||||
// Ensure that there are any points to be deleted
|
||||
if (toRemove.Count == 0)
|
||||
return;
|
||||
|
||||
foreach (var c in toRemove)
|
||||
{
|
||||
// The first control point in the slider must have a type, so take it from the previous "first" one
|
||||
// Todo: Should be handled within SliderPath itself
|
||||
if (c == controlPoints[0] && controlPoints.Count > 1 && controlPoints[1].Type.Value == null)
|
||||
controlPoints[1].Type.Value = controlPoints[0].Type.Value;
|
||||
|
||||
controlPoints.Remove(c);
|
||||
}
|
||||
|
||||
// If there are 0 or 1 remaining control points, the slider is in a degenerate (single point) form and should be deleted
|
||||
if (controlPoints.Count <= 1)
|
||||
{
|
||||
placementHandler?.Delete(HitObject);
|
||||
return;
|
||||
}
|
||||
|
||||
// The path will have a non-zero offset if the head is removed, but sliders don't support this behaviour since the head is positioned at the slider's position
|
||||
// So the slider needs to be offset by this amount instead, and all control points offset backwards such that the path is re-positioned at (0, 0)
|
||||
Vector2 first = controlPoints[0].Position.Value;
|
||||
foreach (var c in controlPoints)
|
||||
c.Position.Value -= first;
|
||||
HitObject.Position += first;
|
||||
}
|
||||
|
||||
private void updatePath()
|
||||
{
|
||||
HitObject.Path.ExpectedDistance.Value = composer?.GetSnappedDistanceFromDistance(HitObject.StartTime, (float)HitObject.Path.CalculatedDistance) ?? (float)HitObject.Path.CalculatedDistance;
|
||||
|
@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
/// </summary>
|
||||
private const double editor_hit_object_fade_out_extension = 500;
|
||||
|
||||
public DrawableOsuEditRuleset(Ruleset ruleset, IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
||||
public DrawableOsuEditRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods)
|
||||
: base(ruleset, beatmap, mods)
|
||||
{
|
||||
}
|
||||
|
@ -1,6 +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 JetBrains.Annotations;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Screens.Edit.Compose.Components;
|
||||
|
||||
@ -8,8 +9,8 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
{
|
||||
public class OsuDistanceSnapGrid : CircularDistanceSnapGrid
|
||||
{
|
||||
public OsuDistanceSnapGrid(OsuHitObject hitObject, OsuHitObject nextHitObject)
|
||||
: base(hitObject, nextHitObject, hitObject.StackedEndPosition)
|
||||
public OsuDistanceSnapGrid(OsuHitObject hitObject, [CanBeNull] OsuHitObject nextHitObject = null)
|
||||
: base(hitObject.StackedPosition, hitObject.StartTime, nextHitObject?.StartTime)
|
||||
{
|
||||
Masking = true;
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
{
|
||||
}
|
||||
|
||||
protected override DrawableRuleset<OsuHitObject> CreateDrawableRuleset(Ruleset ruleset, IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
||||
protected override DrawableRuleset<OsuHitObject> CreateDrawableRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
|
||||
=> new DrawableOsuEditRuleset(ruleset, beatmap, mods);
|
||||
|
||||
protected override IReadOnlyList<HitObjectCompositionTool> CompositionTools => new HitObjectCompositionTool[]
|
||||
|
@ -31,7 +31,7 @@ namespace osu.Game.Rulesets.Osu
|
||||
{
|
||||
public class OsuRuleset : Ruleset
|
||||
{
|
||||
public override DrawableRuleset CreateDrawableRulesetWith(IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods) => new DrawableOsuRuleset(this, beatmap, mods);
|
||||
public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList<Mod> mods = null) => new DrawableOsuRuleset(this, beatmap, mods);
|
||||
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new OsuBeatmapConverter(beatmap);
|
||||
public override IBeatmapProcessor CreateBeatmapProcessor(IBeatmap beatmap) => new OsuBeatmapProcessor(beatmap);
|
||||
|
||||
|
@ -5,22 +5,20 @@ using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Osu.Judgements;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.UI;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Scoring
|
||||
{
|
||||
internal class OsuScoreProcessor : ScoreProcessor<OsuHitObject>
|
||||
internal class OsuScoreProcessor : ScoreProcessor
|
||||
{
|
||||
public OsuScoreProcessor(DrawableRuleset<OsuHitObject> drawableRuleset)
|
||||
: base(drawableRuleset)
|
||||
public OsuScoreProcessor(IBeatmap beatmap)
|
||||
: base(beatmap)
|
||||
{
|
||||
}
|
||||
|
||||
private float hpDrainRate;
|
||||
|
||||
protected override void ApplyBeatmap(Beatmap<OsuHitObject> beatmap)
|
||||
protected override void ApplyBeatmap(IBeatmap beatmap)
|
||||
{
|
||||
base.ApplyBeatmap(beatmap);
|
||||
|
||||
|
@ -3,15 +3,14 @@
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Skinning;
|
||||
using osu.Game.Rulesets.Osu.UI.Cursor;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Skinning
|
||||
{
|
||||
public class LegacyCursor : CompositeDrawable
|
||||
public class LegacyCursor : OsuCursorSprite
|
||||
{
|
||||
private NonPlayfieldSprite cursor;
|
||||
private bool spin;
|
||||
|
||||
public LegacyCursor()
|
||||
@ -27,7 +26,7 @@ namespace osu.Game.Rulesets.Osu.Skinning
|
||||
{
|
||||
spin = skin.GetConfig<OsuSkinConfiguration, bool>(OsuSkinConfiguration.CursorRotate)?.Value ?? true;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
InternalChildren = new[]
|
||||
{
|
||||
new NonPlayfieldSprite
|
||||
{
|
||||
@ -35,7 +34,7 @@ namespace osu.Game.Rulesets.Osu.Skinning
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
},
|
||||
cursor = new NonPlayfieldSprite
|
||||
ExpandTarget = new NonPlayfieldSprite
|
||||
{
|
||||
Texture = skin.GetTexture("cursor"),
|
||||
Anchor = Anchor.Centre,
|
||||
@ -47,7 +46,7 @@ namespace osu.Game.Rulesets.Osu.Skinning
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
if (spin)
|
||||
cursor.Spin(10000, RotationDirection.Clockwise);
|
||||
ExpandTarget.Spin(10000, RotationDirection.Clockwise);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,9 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
||||
|
||||
private bool cursorExpand;
|
||||
|
||||
private Container expandTarget;
|
||||
private SkinnableDrawable cursorSprite;
|
||||
|
||||
private Drawable expandTarget => (cursorSprite.Drawable as OsuCursorSprite)?.ExpandTarget ?? cursorSprite;
|
||||
|
||||
public OsuCursor()
|
||||
{
|
||||
@ -37,12 +39,12 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
InternalChild = expandTarget = new Container
|
||||
InternalChild = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
Child = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.Cursor), _ => new DefaultCursor(), confineMode: ConfineMode.NoScaling)
|
||||
Child = cursorSprite = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.Cursor), _ => new DefaultCursor(), confineMode: ConfineMode.NoScaling)
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
@ -62,7 +64,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
||||
|
||||
public void Contract() => expandTarget.ScaleTo(released_scale, 100, Easing.OutQuad);
|
||||
|
||||
private class DefaultCursor : CompositeDrawable
|
||||
private class DefaultCursor : OsuCursorSprite
|
||||
{
|
||||
public DefaultCursor()
|
||||
{
|
||||
@ -71,10 +73,12 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
InternalChildren = new[]
|
||||
{
|
||||
new CircularContainer
|
||||
ExpandTarget = new CircularContainer
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = true,
|
||||
BorderThickness = size / 6,
|
||||
|
17
osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorSprite.cs
Normal file
17
osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorSprite.cs
Normal file
@ -0,0 +1,17 @@
|
||||
// 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 osu.Framework.Graphics.Containers;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.UI.Cursor
|
||||
{
|
||||
public abstract class OsuCursorSprite : CompositeDrawable
|
||||
{
|
||||
/// <summary>
|
||||
/// The an optional piece of the cursor to expand when in a clicked state.
|
||||
/// If null, the whole cursor will be affected by expansion.
|
||||
/// </summary>
|
||||
public Drawable ExpandTarget { get; protected set; }
|
||||
}
|
||||
}
|
@ -26,14 +26,14 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
{
|
||||
protected new OsuRulesetConfigManager Config => (OsuRulesetConfigManager)base.Config;
|
||||
|
||||
public DrawableOsuRuleset(Ruleset ruleset, IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
||||
public DrawableOsuRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
|
||||
: base(ruleset, beatmap, mods)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true; // always show the gameplay cursor
|
||||
|
||||
public override ScoreProcessor CreateScoreProcessor() => new OsuScoreProcessor(this);
|
||||
public override ScoreProcessor CreateScoreProcessor() => new OsuScoreProcessor(Beatmap);
|
||||
|
||||
protected override Playfield CreatePlayfield() => new OsuPlayfield();
|
||||
|
||||
|
@ -11,7 +11,6 @@ using osu.Framework.MathUtils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
@ -91,7 +90,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 768,
|
||||
Children = new[] { drawableRuleset = new DrawableTaikoRuleset(new TaikoRuleset(), beatmap, Array.Empty<Mod>()) }
|
||||
Children = new[] { drawableRuleset = new DrawableTaikoRuleset(new TaikoRuleset(), beatmap.GetPlayableBeatmap(new TaikoRuleset().RulesetInfo)) }
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,15 +1,15 @@
|
||||
// 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 osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.Taiko.Objects;
|
||||
using osu.Game.Rulesets.UI;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Scoring
|
||||
{
|
||||
internal class TaikoScoreProcessor : ScoreProcessor<TaikoHitObject>
|
||||
internal class TaikoScoreProcessor : ScoreProcessor
|
||||
{
|
||||
/// <summary>
|
||||
/// A value used for calculating <see cref="hpMultiplier"/>.
|
||||
@ -31,16 +31,16 @@ namespace osu.Game.Rulesets.Taiko.Scoring
|
||||
/// </summary>
|
||||
private double hpMissMultiplier;
|
||||
|
||||
public TaikoScoreProcessor(DrawableRuleset<TaikoHitObject> drawableRuleset)
|
||||
: base(drawableRuleset)
|
||||
public TaikoScoreProcessor(IBeatmap beatmap)
|
||||
: base(beatmap)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void ApplyBeatmap(Beatmap<TaikoHitObject> beatmap)
|
||||
protected override void ApplyBeatmap(IBeatmap beatmap)
|
||||
{
|
||||
base.ApplyBeatmap(beatmap);
|
||||
|
||||
hpMultiplier = 1 / (object_count_factor * beatmap.HitObjects.FindAll(o => o is Hit).Count * BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.BaseDifficulty.DrainRate, 0.5, 0.75, 0.98));
|
||||
hpMultiplier = 1 / (object_count_factor * beatmap.HitObjects.OfType<Hit>().Count() * BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.BaseDifficulty.DrainRate, 0.5, 0.75, 0.98));
|
||||
|
||||
hpMissMultiplier = BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.BaseDifficulty.DrainRate, 0.0018, 0.0075, 0.0120);
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ namespace osu.Game.Rulesets.Taiko
|
||||
{
|
||||
public class TaikoRuleset : Ruleset
|
||||
{
|
||||
public override DrawableRuleset CreateDrawableRulesetWith(IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods) => new DrawableTaikoRuleset(this, beatmap, mods);
|
||||
public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList<Mod> mods = null) => new DrawableTaikoRuleset(this, beatmap, mods);
|
||||
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new TaikoBeatmapConverter(beatmap);
|
||||
|
||||
public const string SHORT_NAME = "taiko";
|
||||
|
@ -27,7 +27,7 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
|
||||
protected override bool UserScrollSpeedAdjustment => false;
|
||||
|
||||
public DrawableTaikoRuleset(Ruleset ruleset, IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
||||
public DrawableTaikoRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
|
||||
: base(ruleset, beatmap, mods)
|
||||
{
|
||||
Direction.Value = ScrollingDirection.Left;
|
||||
@ -40,7 +40,7 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
new BarLineGenerator<BarLine>(Beatmap).BarLines.ForEach(bar => Playfield.Add(bar.Major ? new DrawableBarLineMajor(bar) : new DrawableBarLine(bar)));
|
||||
}
|
||||
|
||||
public override ScoreProcessor CreateScoreProcessor() => new TaikoScoreProcessor(this);
|
||||
public override ScoreProcessor CreateScoreProcessor() => new TaikoScoreProcessor(Beatmap);
|
||||
|
||||
public override PlayfieldAdjustmentContainer CreatePlayfieldAdjustmentContainer() => new TaikoPlayfieldAdjustmentContainer();
|
||||
|
||||
|
427
osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs
Normal file
427
osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs
Normal file
@ -0,0 +1,427 @@
|
||||
// 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 NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Input.States;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens;
|
||||
using osu.Game.Screens.Backgrounds;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Screens.Play.PlayerSettings;
|
||||
using osu.Game.Screens.Select;
|
||||
using osu.Game.Tests.Resources;
|
||||
using osu.Game.Users;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Background
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSceneUserDimBackgrounds : ManualInputManagerTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(ScreenWithBeatmapBackground),
|
||||
typeof(PlayerLoader),
|
||||
typeof(Player),
|
||||
typeof(UserDimContainer),
|
||||
typeof(OsuScreen)
|
||||
};
|
||||
|
||||
private DummySongSelect songSelect;
|
||||
private TestPlayerLoader playerLoader;
|
||||
private TestPlayer player;
|
||||
private BeatmapManager manager;
|
||||
private RulesetStore rulesets;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(GameHost host, AudioManager audio)
|
||||
{
|
||||
Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
|
||||
Dependencies.Cache(manager = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, host, Beatmap.Default));
|
||||
Dependencies.Cache(new OsuConfigManager(LocalStorage));
|
||||
|
||||
manager.Import(TestResources.GetTestBeatmapForImport()).Wait();
|
||||
|
||||
Beatmap.SetDefault();
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
public virtual void SetUp() => Schedule(() =>
|
||||
{
|
||||
Child = new OsuScreenStack(songSelect = new DummySongSelect())
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
};
|
||||
});
|
||||
|
||||
/// <summary>
|
||||
/// Check if <see cref="PlayerLoader"/> properly triggers the visual settings preview when a user hovers over the visual settings panel.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void PlayerLoaderSettingsHoverTest()
|
||||
{
|
||||
setupUserSettings();
|
||||
AddStep("Start player loader", () => songSelect.Push(playerLoader = new TestPlayerLoader(player = new TestPlayer { BlockLoad = true })));
|
||||
AddUntilStep("Wait for Player Loader to load", () => playerLoader?.IsLoaded ?? false);
|
||||
AddAssert("Background retained from song select", () => songSelect.IsBackgroundCurrent());
|
||||
AddStep("Trigger background preview", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(playerLoader.ScreenPos);
|
||||
InputManager.MoveMouseTo(playerLoader.VisualSettingsPos);
|
||||
});
|
||||
waitForDim();
|
||||
AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied());
|
||||
AddStep("Stop background preview", () => InputManager.MoveMouseTo(playerLoader.ScreenPos));
|
||||
waitForDim();
|
||||
AddAssert("Screen is undimmed and user blur removed", () => songSelect.IsBackgroundUndimmed() && playerLoader.IsBlurCorrect());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// In the case of a user triggering the dim preview the instant player gets loaded, then moving the cursor off of the visual settings:
|
||||
/// The OnHover of PlayerLoader will trigger, which could potentially cause visual settings to be unapplied unless checked for in PlayerLoader.
|
||||
/// We need to check that in this scenario, the dim and blur is still properly applied after entering player.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void PlayerLoaderTransitionTest()
|
||||
{
|
||||
performFullSetup();
|
||||
AddStep("Trigger hover event", () => playerLoader.TriggerOnHover());
|
||||
AddAssert("Background retained from song select", () => songSelect.IsBackgroundCurrent());
|
||||
waitForDim();
|
||||
AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Make sure the background is fully invisible (Alpha == 0) when the background should be disabled by the storyboard.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void StoryboardBackgroundVisibilityTest()
|
||||
{
|
||||
performFullSetup();
|
||||
createFakeStoryboard();
|
||||
AddStep("Enable Storyboard", () =>
|
||||
{
|
||||
player.ReplacesBackground.Value = true;
|
||||
player.StoryboardEnabled.Value = true;
|
||||
});
|
||||
waitForDim();
|
||||
AddAssert("Background is invisible, storyboard is visible", () => songSelect.IsBackgroundInvisible() && player.IsStoryboardVisible);
|
||||
AddStep("Disable Storyboard", () =>
|
||||
{
|
||||
player.ReplacesBackground.Value = false;
|
||||
player.StoryboardEnabled.Value = false;
|
||||
});
|
||||
waitForDim();
|
||||
AddAssert("Background is visible, storyboard is invisible", () => songSelect.IsBackgroundVisible() && !player.IsStoryboardVisible);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When exiting player, the screen that it suspends/exits to needs to have a fully visible (Alpha == 1) background.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void StoryboardTransitionTest()
|
||||
{
|
||||
performFullSetup();
|
||||
createFakeStoryboard();
|
||||
AddStep("Exit to song select", () => player.Exit());
|
||||
waitForDim();
|
||||
AddAssert("Background is visible", () => songSelect.IsBackgroundVisible());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensure <see cref="UserDimContainer"/> is properly accepting user-defined visual changes for a background.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void DisableUserDimBackgroundTest()
|
||||
{
|
||||
performFullSetup();
|
||||
waitForDim();
|
||||
AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied());
|
||||
AddStep("Enable user dim", () => songSelect.DimEnabled.Value = false);
|
||||
waitForDim();
|
||||
AddAssert("Screen is undimmed and user blur removed", () => songSelect.IsBackgroundUndimmed() && songSelect.IsUserBlurDisabled());
|
||||
AddStep("Disable user dim", () => songSelect.DimEnabled.Value = true);
|
||||
waitForDim();
|
||||
AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensure <see cref="UserDimContainer"/> is properly accepting user-defined visual changes for a storyboard.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void DisableUserDimStoryboardTest()
|
||||
{
|
||||
performFullSetup();
|
||||
createFakeStoryboard();
|
||||
AddStep("Enable Storyboard", () =>
|
||||
{
|
||||
player.ReplacesBackground.Value = true;
|
||||
player.StoryboardEnabled.Value = true;
|
||||
});
|
||||
AddStep("Enable user dim", () => player.DimmableStoryboard.EnableUserDim.Value = true);
|
||||
AddStep("Set dim level to 1", () => songSelect.DimLevel.Value = 1f);
|
||||
waitForDim();
|
||||
AddAssert("Storyboard is invisible", () => !player.IsStoryboardVisible);
|
||||
AddStep("Disable user dim", () => player.DimmableStoryboard.EnableUserDim.Value = false);
|
||||
waitForDim();
|
||||
AddAssert("Storyboard is visible", () => player.IsStoryboardVisible);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if the visual settings container retains dim and blur when pausing
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void PauseTest()
|
||||
{
|
||||
performFullSetup(true);
|
||||
AddStep("Pause", () => player.Pause());
|
||||
waitForDim();
|
||||
AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied());
|
||||
AddStep("Unpause", () => player.Resume());
|
||||
waitForDim();
|
||||
AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if the visual settings container removes user dim when suspending <see cref="Player"/> for <see cref="SoloResults"/>
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TransitionTest()
|
||||
{
|
||||
performFullSetup();
|
||||
FadeAccessibleResults results = null;
|
||||
AddStep("Transition to Results", () => player.Push(results =
|
||||
new FadeAccessibleResults(new ScoreInfo { User = new User { Username = "osu!" } })));
|
||||
AddUntilStep("Wait for results is current", () => results.IsCurrentScreen());
|
||||
waitForDim();
|
||||
AddAssert("Screen is undimmed, original background retained", () =>
|
||||
songSelect.IsBackgroundUndimmed() && songSelect.IsBackgroundCurrent() && results.IsBlurCorrect());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if background gets undimmed and unblurred when leaving <see cref="Player"/> for <see cref="PlaySongSelect"/>
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TransitionOutTest()
|
||||
{
|
||||
performFullSetup();
|
||||
AddStep("Exit to song select", () => player.Exit());
|
||||
waitForDim();
|
||||
AddAssert("Screen is undimmed and user blur removed", () => songSelect.IsBackgroundUndimmed() && songSelect.IsBlurCorrect());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if hovering on the visual settings dialogue after resuming from player still previews the background dim.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void ResumeFromPlayerTest()
|
||||
{
|
||||
performFullSetup();
|
||||
AddStep("Move mouse to Visual Settings", () => InputManager.MoveMouseTo(playerLoader.VisualSettingsPos));
|
||||
AddStep("Resume PlayerLoader", () => player.Restart());
|
||||
waitForDim();
|
||||
AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied());
|
||||
AddStep("Move mouse to center of screen", () => InputManager.MoveMouseTo(playerLoader.ScreenPos));
|
||||
waitForDim();
|
||||
AddAssert("Screen is undimmed and user blur removed", () => songSelect.IsBackgroundUndimmed() && playerLoader.IsBlurCorrect());
|
||||
}
|
||||
|
||||
private void waitForDim() => AddWaitStep("Wait for dim", 5);
|
||||
|
||||
private void createFakeStoryboard() => AddStep("Create storyboard", () =>
|
||||
{
|
||||
player.StoryboardEnabled.Value = false;
|
||||
player.ReplacesBackground.Value = false;
|
||||
player.DimmableStoryboard.Add(new OsuSpriteText
|
||||
{
|
||||
Size = new Vector2(500, 50),
|
||||
Alpha = 1,
|
||||
Colour = Color4.White,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Text = "THIS IS A STORYBOARD",
|
||||
Font = new FontUsage(size: 50)
|
||||
});
|
||||
});
|
||||
|
||||
private void performFullSetup(bool allowPause = false)
|
||||
{
|
||||
setupUserSettings();
|
||||
|
||||
AddStep("Start player loader", () => songSelect.Push(playerLoader = new TestPlayerLoader(player = new TestPlayer(allowPause))));
|
||||
|
||||
AddUntilStep("Wait for Player Loader to load", () => playerLoader.IsLoaded);
|
||||
AddStep("Move mouse to center of screen", () => InputManager.MoveMouseTo(playerLoader.ScreenPos));
|
||||
AddUntilStep("Wait for player to load", () => player.IsLoaded);
|
||||
}
|
||||
|
||||
private void setupUserSettings()
|
||||
{
|
||||
AddUntilStep("Song select has selection", () => songSelect.Carousel.SelectedBeatmap != null);
|
||||
AddStep("Set default user settings", () =>
|
||||
{
|
||||
Mods.Value = Mods.Value.Concat(new[] { new OsuModNoFail() }).ToArray();
|
||||
songSelect.DimLevel.Value = 0.7f;
|
||||
songSelect.BlurLevel.Value = 0.4f;
|
||||
});
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
rulesets?.Dispose();
|
||||
}
|
||||
|
||||
private class DummySongSelect : PlaySongSelect
|
||||
{
|
||||
protected override BackgroundScreen CreateBackground()
|
||||
{
|
||||
FadeAccessibleBackground background = new FadeAccessibleBackground(Beatmap.Value);
|
||||
DimEnabled.BindTo(background.EnableUserDim);
|
||||
return background;
|
||||
}
|
||||
|
||||
public readonly Bindable<bool> DimEnabled = new Bindable<bool>();
|
||||
public readonly Bindable<double> DimLevel = new Bindable<double>();
|
||||
public readonly Bindable<double> BlurLevel = new Bindable<double>();
|
||||
|
||||
public new BeatmapCarousel Carousel => base.Carousel;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager config)
|
||||
{
|
||||
config.BindWith(OsuSetting.DimLevel, DimLevel);
|
||||
config.BindWith(OsuSetting.BlurLevel, BlurLevel);
|
||||
}
|
||||
|
||||
public bool IsBackgroundDimmed() => ((FadeAccessibleBackground)Background).CurrentColour == OsuColour.Gray(1f - ((FadeAccessibleBackground)Background).CurrentDim);
|
||||
|
||||
public bool IsBackgroundUndimmed() => ((FadeAccessibleBackground)Background).CurrentColour == Color4.White;
|
||||
|
||||
public bool IsUserBlurApplied() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2((float)BlurLevel.Value * BackgroundScreenBeatmap.USER_BLUR_FACTOR);
|
||||
|
||||
public bool IsUserBlurDisabled() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2(0);
|
||||
|
||||
public bool IsBackgroundInvisible() => ((FadeAccessibleBackground)Background).CurrentAlpha == 0;
|
||||
|
||||
public bool IsBackgroundVisible() => ((FadeAccessibleBackground)Background).CurrentAlpha == 1;
|
||||
|
||||
public bool IsBlurCorrect() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2(BACKGROUND_BLUR);
|
||||
|
||||
/// <summary>
|
||||
/// Make sure every time a screen gets pushed, the background doesn't get replaced
|
||||
/// </summary>
|
||||
/// <returns>Whether or not the original background (The one created in DummySongSelect) is still the current background</returns>
|
||||
public bool IsBackgroundCurrent() => ((FadeAccessibleBackground)Background).IsCurrentScreen();
|
||||
}
|
||||
|
||||
private class FadeAccessibleResults : SoloResults
|
||||
{
|
||||
public FadeAccessibleResults(ScoreInfo score)
|
||||
: base(score)
|
||||
{
|
||||
}
|
||||
|
||||
protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value);
|
||||
|
||||
public bool IsBlurCorrect() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2(BACKGROUND_BLUR);
|
||||
}
|
||||
|
||||
private class TestPlayer : Visual.TestPlayer
|
||||
{
|
||||
protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value);
|
||||
|
||||
public new DimmableStoryboard DimmableStoryboard => base.DimmableStoryboard;
|
||||
|
||||
// Whether or not the player should be allowed to load.
|
||||
public bool BlockLoad;
|
||||
|
||||
public Bindable<bool> StoryboardEnabled;
|
||||
public readonly Bindable<bool> ReplacesBackground = new Bindable<bool>();
|
||||
public readonly Bindable<bool> IsPaused = new Bindable<bool>();
|
||||
|
||||
public TestPlayer(bool allowPause = true)
|
||||
: base(allowPause)
|
||||
{
|
||||
}
|
||||
|
||||
public bool IsStoryboardVisible => DimmableStoryboard.ContentDisplayed;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager config, CancellationToken token)
|
||||
{
|
||||
while (BlockLoad && !token.IsCancellationRequested)
|
||||
Thread.Sleep(1);
|
||||
|
||||
StoryboardEnabled = config.GetBindable<bool>(OsuSetting.ShowStoryboard);
|
||||
ReplacesBackground.BindTo(Background.StoryboardReplacesBackground);
|
||||
DrawableRuleset.IsPaused.BindTo(IsPaused);
|
||||
}
|
||||
}
|
||||
|
||||
private class TestPlayerLoader : PlayerLoader
|
||||
{
|
||||
public VisualSettings VisualSettingsPos => VisualSettings;
|
||||
public BackgroundScreen ScreenPos => Background;
|
||||
|
||||
public TestPlayerLoader(Player player)
|
||||
: base(() => player)
|
||||
{
|
||||
}
|
||||
|
||||
public void TriggerOnHover() => OnHover(new HoverEvent(new InputState()));
|
||||
|
||||
public bool IsBlurCorrect() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2(BACKGROUND_BLUR);
|
||||
|
||||
protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value);
|
||||
}
|
||||
|
||||
private class FadeAccessibleBackground : BackgroundScreenBeatmap
|
||||
{
|
||||
protected override DimmableBackground CreateFadeContainer() => dimmable = new TestDimmableBackground { RelativeSizeAxes = Axes.Both };
|
||||
|
||||
public Color4 CurrentColour => dimmable.CurrentColour;
|
||||
|
||||
public float CurrentAlpha => dimmable.CurrentAlpha;
|
||||
|
||||
public float CurrentDim => dimmable.DimLevel;
|
||||
|
||||
public Vector2 CurrentBlur => Background.BlurSigma;
|
||||
|
||||
private TestDimmableBackground dimmable;
|
||||
|
||||
public FadeAccessibleBackground(WorkingBeatmap beatmap)
|
||||
: base(beatmap)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private class TestDimmableBackground : BackgroundScreenBeatmap.DimmableBackground
|
||||
{
|
||||
public Color4 CurrentColour => Content.Colour;
|
||||
public float CurrentAlpha => Content.Alpha;
|
||||
|
||||
public new float DimLevel => base.DimLevel;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,423 +1,98 @@
|
||||
// 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 NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Input.States;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens;
|
||||
using osu.Game.Screens.Backgrounds;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Screens.Play.PlayerSettings;
|
||||
using osu.Game.Screens.Select;
|
||||
using osu.Game.Tests.Resources;
|
||||
using osu.Game.Users;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Background
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSceneUserDimContainer : ManualInputManagerTestScene
|
||||
public class TestSceneUserDimContainer : OsuTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(ScreenWithBeatmapBackground),
|
||||
typeof(PlayerLoader),
|
||||
typeof(Player),
|
||||
typeof(UserDimContainer),
|
||||
typeof(OsuScreen)
|
||||
};
|
||||
private TestUserDimContainer userDimContainer;
|
||||
|
||||
private DummySongSelect songSelect;
|
||||
private TestPlayerLoader playerLoader;
|
||||
private TestPlayer player;
|
||||
private BeatmapManager manager;
|
||||
private RulesetStore rulesets;
|
||||
private readonly BindableBool isBreakTime = new BindableBool();
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(GameHost host, AudioManager audio)
|
||||
{
|
||||
Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
|
||||
Dependencies.Cache(manager = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, host, Beatmap.Default));
|
||||
Dependencies.Cache(new OsuConfigManager(LocalStorage));
|
||||
|
||||
manager.Import(TestResources.GetTestBeatmapForImport()).Wait();
|
||||
|
||||
Beatmap.SetDefault();
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
public virtual void SetUp() => Schedule(() =>
|
||||
{
|
||||
Child = new OsuScreenStack(songSelect = new DummySongSelect())
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
};
|
||||
});
|
||||
|
||||
/// <summary>
|
||||
/// Check if <see cref="PlayerLoader"/> properly triggers the visual settings preview when a user hovers over the visual settings panel.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void PlayerLoaderSettingsHoverTest()
|
||||
{
|
||||
setupUserSettings();
|
||||
AddStep("Start player loader", () => songSelect.Push(playerLoader = new TestPlayerLoader(player = new TestPlayer { BlockLoad = true })));
|
||||
AddUntilStep("Wait for Player Loader to load", () => playerLoader?.IsLoaded ?? false);
|
||||
AddAssert("Background retained from song select", () => songSelect.IsBackgroundCurrent());
|
||||
AddStep("Trigger background preview", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(playerLoader.ScreenPos);
|
||||
InputManager.MoveMouseTo(playerLoader.VisualSettingsPos);
|
||||
});
|
||||
waitForDim();
|
||||
AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied());
|
||||
AddStep("Stop background preview", () => InputManager.MoveMouseTo(playerLoader.ScreenPos));
|
||||
waitForDim();
|
||||
AddAssert("Screen is undimmed and user blur removed", () => songSelect.IsBackgroundUndimmed() && playerLoader.IsBlurCorrect());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// In the case of a user triggering the dim preview the instant player gets loaded, then moving the cursor off of the visual settings:
|
||||
/// The OnHover of PlayerLoader will trigger, which could potentially cause visual settings to be unapplied unless checked for in PlayerLoader.
|
||||
/// We need to check that in this scenario, the dim and blur is still properly applied after entering player.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void PlayerLoaderTransitionTest()
|
||||
{
|
||||
performFullSetup();
|
||||
AddStep("Trigger hover event", () => playerLoader.TriggerOnHover());
|
||||
AddAssert("Background retained from song select", () => songSelect.IsBackgroundCurrent());
|
||||
waitForDim();
|
||||
AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Make sure the background is fully invisible (Alpha == 0) when the background should be disabled by the storyboard.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void StoryboardBackgroundVisibilityTest()
|
||||
{
|
||||
performFullSetup();
|
||||
createFakeStoryboard();
|
||||
AddStep("Enable Storyboard", () =>
|
||||
{
|
||||
player.ReplacesBackground.Value = true;
|
||||
player.StoryboardEnabled.Value = true;
|
||||
});
|
||||
waitForDim();
|
||||
AddAssert("Background is invisible, storyboard is visible", () => songSelect.IsBackgroundInvisible() && player.IsStoryboardVisible);
|
||||
AddStep("Disable Storyboard", () =>
|
||||
{
|
||||
player.ReplacesBackground.Value = false;
|
||||
player.StoryboardEnabled.Value = false;
|
||||
});
|
||||
waitForDim();
|
||||
AddAssert("Background is visible, storyboard is invisible", () => songSelect.IsBackgroundVisible() && !player.IsStoryboardVisible);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When exiting player, the screen that it suspends/exits to needs to have a fully visible (Alpha == 1) background.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void StoryboardTransitionTest()
|
||||
{
|
||||
performFullSetup();
|
||||
createFakeStoryboard();
|
||||
AddStep("Exit to song select", () => player.Exit());
|
||||
waitForDim();
|
||||
AddAssert("Background is visible", () => songSelect.IsBackgroundVisible());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensure <see cref="UserDimContainer"/> is properly accepting user-defined visual changes for a background.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void DisableUserDimBackgroundTest()
|
||||
{
|
||||
performFullSetup();
|
||||
waitForDim();
|
||||
AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied());
|
||||
AddStep("Enable user dim", () => songSelect.DimEnabled.Value = false);
|
||||
waitForDim();
|
||||
AddAssert("Screen is undimmed and user blur removed", () => songSelect.IsBackgroundUndimmed() && songSelect.IsUserBlurDisabled());
|
||||
AddStep("Disable user dim", () => songSelect.DimEnabled.Value = true);
|
||||
waitForDim();
|
||||
AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensure <see cref="UserDimContainer"/> is properly accepting user-defined visual changes for a storyboard.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void DisableUserDimStoryboardTest()
|
||||
{
|
||||
performFullSetup();
|
||||
createFakeStoryboard();
|
||||
AddStep("Enable Storyboard", () =>
|
||||
{
|
||||
player.ReplacesBackground.Value = true;
|
||||
player.StoryboardEnabled.Value = true;
|
||||
});
|
||||
AddStep("Enable user dim", () => player.DimmableStoryboard.EnableUserDim.Value = true);
|
||||
AddStep("Set dim level to 1", () => songSelect.DimLevel.Value = 1f);
|
||||
waitForDim();
|
||||
AddAssert("Storyboard is invisible", () => !player.IsStoryboardVisible);
|
||||
AddStep("Disable user dim", () => player.DimmableStoryboard.EnableUserDim.Value = false);
|
||||
waitForDim();
|
||||
AddAssert("Storyboard is visible", () => player.IsStoryboardVisible);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if the visual settings container retains dim and blur when pausing
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void PauseTest()
|
||||
{
|
||||
performFullSetup(true);
|
||||
AddStep("Pause", () => player.Pause());
|
||||
waitForDim();
|
||||
AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied());
|
||||
AddStep("Unpause", () => player.Resume());
|
||||
waitForDim();
|
||||
AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if the visual settings container removes user dim when suspending <see cref="Player"/> for <see cref="SoloResults"/>
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TransitionTest()
|
||||
{
|
||||
performFullSetup();
|
||||
FadeAccessibleResults results = null;
|
||||
AddStep("Transition to Results", () => player.Push(results =
|
||||
new FadeAccessibleResults(new ScoreInfo { User = new User { Username = "osu!" } })));
|
||||
AddUntilStep("Wait for results is current", () => results.IsCurrentScreen());
|
||||
waitForDim();
|
||||
AddAssert("Screen is undimmed, original background retained", () =>
|
||||
songSelect.IsBackgroundUndimmed() && songSelect.IsBackgroundCurrent() && results.IsBlurCorrect());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if background gets undimmed and unblurred when leaving <see cref="Player"/> for <see cref="PlaySongSelect"/>
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TransitionOutTest()
|
||||
{
|
||||
performFullSetup();
|
||||
AddStep("Exit to song select", () => player.Exit());
|
||||
waitForDim();
|
||||
AddAssert("Screen is undimmed and user blur removed", () => songSelect.IsBackgroundUndimmed() && songSelect.IsBlurCorrect());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if hovering on the visual settings dialogue after resuming from player still previews the background dim.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void ResumeFromPlayerTest()
|
||||
{
|
||||
performFullSetup();
|
||||
AddStep("Move mouse to Visual Settings", () => InputManager.MoveMouseTo(playerLoader.VisualSettingsPos));
|
||||
AddStep("Resume PlayerLoader", () => player.Restart());
|
||||
waitForDim();
|
||||
AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied());
|
||||
AddStep("Move mouse to center of screen", () => InputManager.MoveMouseTo(playerLoader.ScreenPos));
|
||||
waitForDim();
|
||||
AddAssert("Screen is undimmed and user blur removed", () => songSelect.IsBackgroundUndimmed() && playerLoader.IsBlurCorrect());
|
||||
}
|
||||
|
||||
private void waitForDim() => AddWaitStep("Wait for dim", 5);
|
||||
|
||||
private void createFakeStoryboard() => AddStep("Create storyboard", () =>
|
||||
{
|
||||
player.StoryboardEnabled.Value = false;
|
||||
player.ReplacesBackground.Value = false;
|
||||
player.DimmableStoryboard.Add(new OsuSpriteText
|
||||
{
|
||||
Size = new Vector2(500, 50),
|
||||
Alpha = 1,
|
||||
Colour = Color4.White,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Text = "THIS IS A STORYBOARD",
|
||||
Font = new FontUsage(size: 50)
|
||||
});
|
||||
});
|
||||
|
||||
private void performFullSetup(bool allowPause = false)
|
||||
{
|
||||
setupUserSettings();
|
||||
|
||||
AddStep("Start player loader", () => songSelect.Push(playerLoader = new TestPlayerLoader(player = new TestPlayer(allowPause))));
|
||||
|
||||
AddUntilStep("Wait for Player Loader to load", () => playerLoader.IsLoaded);
|
||||
AddStep("Move mouse to center of screen", () => InputManager.MoveMouseTo(playerLoader.ScreenPos));
|
||||
AddUntilStep("Wait for player to load", () => player.IsLoaded);
|
||||
}
|
||||
|
||||
private void setupUserSettings()
|
||||
{
|
||||
AddUntilStep("Song select has selection", () => songSelect.Carousel.SelectedBeatmap != null);
|
||||
AddStep("Set default user settings", () =>
|
||||
{
|
||||
Mods.Value = Mods.Value.Concat(new[] { new OsuModNoFail() }).ToArray();
|
||||
songSelect.DimLevel.Value = 0.7f;
|
||||
songSelect.BlurLevel.Value = 0.4f;
|
||||
});
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
rulesets?.Dispose();
|
||||
}
|
||||
|
||||
private class DummySongSelect : PlaySongSelect
|
||||
{
|
||||
protected override BackgroundScreen CreateBackground()
|
||||
{
|
||||
FadeAccessibleBackground background = new FadeAccessibleBackground(Beatmap.Value);
|
||||
DimEnabled.BindTo(background.EnableUserDim);
|
||||
return background;
|
||||
}
|
||||
|
||||
public readonly Bindable<bool> DimEnabled = new Bindable<bool>();
|
||||
public readonly Bindable<double> DimLevel = new Bindable<double>();
|
||||
public readonly Bindable<double> BlurLevel = new Bindable<double>();
|
||||
|
||||
public new BeatmapCarousel Carousel => base.Carousel;
|
||||
private Bindable<bool> lightenDuringBreaks = new Bindable<bool>();
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager config)
|
||||
{
|
||||
config.BindWith(OsuSetting.DimLevel, DimLevel);
|
||||
config.BindWith(OsuSetting.BlurLevel, BlurLevel);
|
||||
lightenDuringBreaks = config.GetBindable<bool>(OsuSetting.LightenDuringBreaks);
|
||||
}
|
||||
|
||||
public bool IsBackgroundDimmed() => ((FadeAccessibleBackground)Background).CurrentColour == OsuColour.Gray(1 - (float)DimLevel.Value);
|
||||
|
||||
public bool IsBackgroundUndimmed() => ((FadeAccessibleBackground)Background).CurrentColour == Color4.White;
|
||||
|
||||
public bool IsUserBlurApplied() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2((float)BlurLevel.Value * BackgroundScreenBeatmap.USER_BLUR_FACTOR);
|
||||
|
||||
public bool IsUserBlurDisabled() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2(0);
|
||||
|
||||
public bool IsBackgroundInvisible() => ((FadeAccessibleBackground)Background).CurrentAlpha == 0;
|
||||
|
||||
public bool IsBackgroundVisible() => ((FadeAccessibleBackground)Background).CurrentAlpha == 1;
|
||||
|
||||
public bool IsBlurCorrect() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2(BACKGROUND_BLUR);
|
||||
|
||||
/// <summary>
|
||||
/// Make sure every time a screen gets pushed, the background doesn't get replaced
|
||||
/// </summary>
|
||||
/// <returns>Whether or not the original background (The one created in DummySongSelect) is still the current background</returns>
|
||||
public bool IsBackgroundCurrent() => ((FadeAccessibleBackground)Background).IsCurrentScreen();
|
||||
}
|
||||
|
||||
private class FadeAccessibleResults : SoloResults
|
||||
[SetUp]
|
||||
public void SetUp() => Schedule(() =>
|
||||
{
|
||||
public FadeAccessibleResults(ScoreInfo score)
|
||||
: base(score)
|
||||
Child = userDimContainer = new TestUserDimContainer
|
||||
{
|
||||
}
|
||||
|
||||
protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value);
|
||||
|
||||
public bool IsBlurCorrect() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2(BACKGROUND_BLUR);
|
||||
}
|
||||
|
||||
private class TestPlayer : Visual.TestPlayer
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = new Box
|
||||
{
|
||||
protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value);
|
||||
Colour = Color4.White,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
};
|
||||
|
||||
public new DimmableStoryboard DimmableStoryboard => base.DimmableStoryboard;
|
||||
userDimContainer.IsBreakTime.BindTo(isBreakTime);
|
||||
isBreakTime.Value = false;
|
||||
|
||||
// Whether or not the player should be allowed to load.
|
||||
public bool BlockLoad;
|
||||
lightenDuringBreaks.Value = false;
|
||||
});
|
||||
|
||||
public Bindable<bool> StoryboardEnabled;
|
||||
public readonly Bindable<bool> ReplacesBackground = new Bindable<bool>();
|
||||
public readonly Bindable<bool> IsPaused = new Bindable<bool>();
|
||||
private const float test_user_dim = 0.6f;
|
||||
private const float test_user_dim_lightened = test_user_dim - UserDimContainer.BREAK_LIGHTEN_AMOUNT;
|
||||
|
||||
public TestPlayer(bool allowPause = true)
|
||||
: base(allowPause)
|
||||
[TestCase(test_user_dim, test_user_dim_lightened)]
|
||||
[TestCase(0.2f, 0.0f)]
|
||||
[TestCase(0.0f, 0.0f)]
|
||||
public void TestBreakLightening(float userDim, float expectedBreakDim)
|
||||
{
|
||||
AddStep($"set dim level {userDim}", () => userDimContainer.UserDimLevel.Value = userDim);
|
||||
AddStep("set lighten during break", () => lightenDuringBreaks.Value = true);
|
||||
|
||||
AddStep("set break", () => isBreakTime.Value = true);
|
||||
AddUntilStep("has lightened", () => userDimContainer.DimEqual(expectedBreakDim));
|
||||
AddStep("clear break", () => isBreakTime.Value = false);
|
||||
AddUntilStep("not lightened", () => userDimContainer.DimEqual(userDim));
|
||||
}
|
||||
|
||||
public bool IsStoryboardVisible => DimmableStoryboard.ContentDisplayed;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager config, CancellationToken token)
|
||||
[Test]
|
||||
public void TestEnableSettingDuringBreak()
|
||||
{
|
||||
while (BlockLoad && !token.IsCancellationRequested)
|
||||
Thread.Sleep(1);
|
||||
AddStep("set dim level 0.6", () => userDimContainer.UserDimLevel.Value = test_user_dim);
|
||||
|
||||
StoryboardEnabled = config.GetBindable<bool>(OsuSetting.ShowStoryboard);
|
||||
ReplacesBackground.BindTo(Background.StoryboardReplacesBackground);
|
||||
DrawableRuleset.IsPaused.BindTo(IsPaused);
|
||||
}
|
||||
AddStep("set break", () => isBreakTime.Value = true);
|
||||
AddUntilStep("not lightened", () => userDimContainer.DimEqual(test_user_dim));
|
||||
AddStep("set lighten during break", () => lightenDuringBreaks.Value = true);
|
||||
AddUntilStep("has lightened", () => userDimContainer.DimEqual(test_user_dim_lightened));
|
||||
}
|
||||
|
||||
private class TestPlayerLoader : PlayerLoader
|
||||
[Test]
|
||||
public void TestDisableSettingDuringBreak()
|
||||
{
|
||||
public VisualSettings VisualSettingsPos => VisualSettings;
|
||||
public BackgroundScreen ScreenPos => Background;
|
||||
AddStep("set dim level 0.6", () => userDimContainer.UserDimLevel.Value = test_user_dim);
|
||||
AddStep("set lighten during break", () => lightenDuringBreaks.Value = true);
|
||||
|
||||
public TestPlayerLoader(Player player)
|
||||
: base(() => player)
|
||||
AddStep("set break", () => isBreakTime.Value = true);
|
||||
AddUntilStep("has lightened", () => userDimContainer.DimEqual(test_user_dim_lightened));
|
||||
AddStep("clear lighten during break", () => lightenDuringBreaks.Value = false);
|
||||
AddUntilStep("not lightened", () => userDimContainer.DimEqual(test_user_dim));
|
||||
AddStep("clear break", () => isBreakTime.Value = false);
|
||||
AddUntilStep("not lightened", () => userDimContainer.DimEqual(test_user_dim));
|
||||
}
|
||||
|
||||
private class TestUserDimContainer : UserDimContainer
|
||||
{
|
||||
}
|
||||
public bool DimEqual(float expectedDimLevel) => Content.Colour == OsuColour.Gray(1f - expectedDimLevel);
|
||||
|
||||
public void TriggerOnHover() => OnHover(new HoverEvent(new InputState()));
|
||||
|
||||
public bool IsBlurCorrect() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2(BACKGROUND_BLUR);
|
||||
|
||||
protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value);
|
||||
}
|
||||
|
||||
private class FadeAccessibleBackground : BackgroundScreenBeatmap
|
||||
{
|
||||
protected override DimmableBackground CreateFadeContainer() => dimmable = new TestDimmableBackground { RelativeSizeAxes = Axes.Both };
|
||||
|
||||
public Color4 CurrentColour => dimmable.CurrentColour;
|
||||
|
||||
public float CurrentAlpha => dimmable.CurrentAlpha;
|
||||
|
||||
public Vector2 CurrentBlur => Background.BlurSigma;
|
||||
|
||||
private TestDimmableBackground dimmable;
|
||||
|
||||
public FadeAccessibleBackground(WorkingBeatmap beatmap)
|
||||
: base(beatmap)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private class TestDimmableBackground : BackgroundScreenBeatmap.DimmableBackground
|
||||
{
|
||||
public Color4 CurrentColour => Content.Colour;
|
||||
public float CurrentAlpha => Content.Alpha;
|
||||
public new Bindable<double> UserDimLevel => base.UserDimLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Osu.Beatmaps;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Screens.Edit;
|
||||
@ -44,7 +43,7 @@ namespace osu.Game.Tests.Visual.Editor
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.SlateGray
|
||||
},
|
||||
new TestDistanceSnapGrid(new HitObject(), grid_position)
|
||||
new TestDistanceSnapGrid()
|
||||
};
|
||||
});
|
||||
|
||||
@ -73,7 +72,7 @@ namespace osu.Game.Tests.Visual.Editor
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.SlateGray
|
||||
},
|
||||
new TestDistanceSnapGrid(new HitObject(), grid_position, new HitObject { StartTime = 100 })
|
||||
new TestDistanceSnapGrid(100)
|
||||
};
|
||||
});
|
||||
}
|
||||
@ -82,68 +81,68 @@ namespace osu.Game.Tests.Visual.Editor
|
||||
{
|
||||
public new float DistanceSpacing => base.DistanceSpacing;
|
||||
|
||||
public TestDistanceSnapGrid(HitObject hitObject, Vector2 centrePosition, HitObject nextHitObject = null)
|
||||
: base(hitObject, nextHitObject, centrePosition)
|
||||
public TestDistanceSnapGrid(double? endTime = null)
|
||||
: base(grid_position, 0, endTime)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void CreateContent(Vector2 centrePosition)
|
||||
protected override void CreateContent(Vector2 startPosition)
|
||||
{
|
||||
AddInternal(new Circle
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(5),
|
||||
Position = centrePosition
|
||||
Position = startPosition
|
||||
});
|
||||
|
||||
int beatIndex = 0;
|
||||
|
||||
for (float s = centrePosition.X + DistanceSpacing; s <= DrawWidth && beatIndex < MaxIntervals; s += DistanceSpacing, beatIndex++)
|
||||
for (float s = startPosition.X + DistanceSpacing; s <= DrawWidth && beatIndex < MaxIntervals; s += DistanceSpacing, beatIndex++)
|
||||
{
|
||||
AddInternal(new Circle
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(5, 10),
|
||||
Position = new Vector2(s, centrePosition.Y),
|
||||
Position = new Vector2(s, startPosition.Y),
|
||||
Colour = GetColourForBeatIndex(beatIndex)
|
||||
});
|
||||
}
|
||||
|
||||
beatIndex = 0;
|
||||
|
||||
for (float s = centrePosition.X - DistanceSpacing; s >= 0 && beatIndex < MaxIntervals; s -= DistanceSpacing, beatIndex++)
|
||||
for (float s = startPosition.X - DistanceSpacing; s >= 0 && beatIndex < MaxIntervals; s -= DistanceSpacing, beatIndex++)
|
||||
{
|
||||
AddInternal(new Circle
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(5, 10),
|
||||
Position = new Vector2(s, centrePosition.Y),
|
||||
Position = new Vector2(s, startPosition.Y),
|
||||
Colour = GetColourForBeatIndex(beatIndex)
|
||||
});
|
||||
}
|
||||
|
||||
beatIndex = 0;
|
||||
|
||||
for (float s = centrePosition.Y + DistanceSpacing; s <= DrawHeight && beatIndex < MaxIntervals; s += DistanceSpacing, beatIndex++)
|
||||
for (float s = startPosition.Y + DistanceSpacing; s <= DrawHeight && beatIndex < MaxIntervals; s += DistanceSpacing, beatIndex++)
|
||||
{
|
||||
AddInternal(new Circle
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(10, 5),
|
||||
Position = new Vector2(centrePosition.X, s),
|
||||
Position = new Vector2(startPosition.X, s),
|
||||
Colour = GetColourForBeatIndex(beatIndex)
|
||||
});
|
||||
}
|
||||
|
||||
beatIndex = 0;
|
||||
|
||||
for (float s = centrePosition.Y - DistanceSpacing; s >= 0 && beatIndex < MaxIntervals; s -= DistanceSpacing, beatIndex++)
|
||||
for (float s = startPosition.Y - DistanceSpacing; s >= 0 && beatIndex < MaxIntervals; s -= DistanceSpacing, beatIndex++)
|
||||
{
|
||||
AddInternal(new Circle
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(10, 5),
|
||||
Position = new Vector2(centrePosition.X, s),
|
||||
Position = new Vector2(startPosition.X, s),
|
||||
Colour = GetColourForBeatIndex(beatIndex)
|
||||
});
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
var ruleset = new TestScrollingRuleset();
|
||||
|
||||
drawableRuleset = (TestDrawableScrollingRuleset)ruleset.CreateDrawableRulesetWith(CreateWorkingBeatmap(beatmap), Array.Empty<Mod>());
|
||||
drawableRuleset = (TestDrawableScrollingRuleset)ruleset.CreateDrawableRulesetWith(CreateWorkingBeatmap(beatmap).GetPlayableBeatmap(ruleset.RulesetInfo));
|
||||
drawableRuleset.FrameStablePlayback = false;
|
||||
|
||||
overrideAction?.Invoke(drawableRuleset);
|
||||
@ -201,7 +201,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
public override IEnumerable<Mod> GetModsFor(ModType type) => throw new NotImplementedException();
|
||||
|
||||
public override DrawableRuleset CreateDrawableRulesetWith(IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods) => new TestDrawableScrollingRuleset(this, beatmap, mods);
|
||||
public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList<Mod> mods = null) => new TestDrawableScrollingRuleset(this, beatmap, mods);
|
||||
|
||||
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new TestBeatmapConverter(beatmap);
|
||||
|
||||
@ -222,7 +222,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
public new Bindable<double> TimeRange => base.TimeRange;
|
||||
|
||||
public TestDrawableScrollingRuleset(Ruleset ruleset, IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
||||
public TestDrawableScrollingRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
|
||||
: base(ruleset, beatmap, mods)
|
||||
{
|
||||
TimeRange.Value = time_range;
|
||||
|
@ -285,8 +285,6 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
protected class PausePlayer : TestPlayer
|
||||
{
|
||||
public new GameplayClockContainer GameplayClockContainer => base.GameplayClockContainer;
|
||||
|
||||
public new ScoreProcessor ScoreProcessor => base.ScoreProcessor;
|
||||
|
||||
public new HUDOverlay HUDOverlay => base.HUDOverlay;
|
||||
|
51
osu.Game.Tests/Visual/Gameplay/TestScenePauseWhenInactive.cs
Normal file
51
osu.Game.Tests/Visual/Gameplay/TestScenePauseWhenInactive.cs
Normal file
@ -0,0 +1,51 @@
|
||||
// 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 NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Screens.Play;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
[HeadlessTest] // we alter unsafe properties on the game host to test inactive window state.
|
||||
public class TestScenePauseWhenInactive : PlayerTestScene
|
||||
{
|
||||
protected new TestPlayer Player => (TestPlayer)base.Player;
|
||||
|
||||
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset)
|
||||
{
|
||||
var beatmap = (Beatmap)base.CreateBeatmap(ruleset);
|
||||
|
||||
beatmap.HitObjects.RemoveAll(h => h.StartTime < 30000);
|
||||
|
||||
return beatmap;
|
||||
}
|
||||
|
||||
[Resolved]
|
||||
private GameHost host { get; set; }
|
||||
|
||||
public TestScenePauseWhenInactive()
|
||||
: base(new OsuRuleset())
|
||||
{
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDoesntPauseDuringIntro()
|
||||
{
|
||||
AddStep("set inactive", () => ((Bindable<bool>)host.IsActive).Value = false);
|
||||
|
||||
AddStep("resume player", () => Player.GameplayClockContainer.Start());
|
||||
AddAssert("ensure not paused", () => !Player.GameplayClockContainer.IsPaused.Value);
|
||||
AddUntilStep("wait for pause", () => Player.GameplayClockContainer.IsPaused.Value);
|
||||
AddAssert("time of pause is after gameplay start time", () => Player.GameplayClockContainer.GameplayClock.CurrentTime >= Player.DrawableRuleset.GameplayStartTime);
|
||||
}
|
||||
|
||||
protected override Player CreatePlayer(Ruleset ruleset) => new TestPlayer(true, true, true);
|
||||
}
|
||||
}
|
@ -57,8 +57,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
beforeLoadAction?.Invoke();
|
||||
Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
|
||||
|
||||
foreach (var mod in Mods.Value.OfType<IApplicableToClock>())
|
||||
mod.ApplyToClock(Beatmap.Value.Track);
|
||||
foreach (var mod in Mods.Value.OfType<IApplicableToTrack>())
|
||||
mod.ApplyToTrack(Beatmap.Value.Track);
|
||||
|
||||
InputManager.Child = container = new TestPlayerLoaderContainer(
|
||||
loader = new TestPlayerLoader(() =>
|
||||
|
@ -68,9 +68,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
};
|
||||
|
||||
AddStep("Set country", () => countryBindable.Value = country);
|
||||
AddAssert("Check scope is Performance", () => scope.Value == RankingsScope.Performance);
|
||||
AddStep("Set scope to Score", () => scope.Value = RankingsScope.Score);
|
||||
AddAssert("Check country is Null", () => countryBindable.Value == null);
|
||||
AddStep("Set country with no flag", () => countryBindable.Value = unknownCountry);
|
||||
}
|
||||
}
|
||||
|
@ -43,11 +43,6 @@ namespace osu.Game.Tests.Visual.Online
|
||||
FullName = "United States"
|
||||
};
|
||||
|
||||
AddStep("Set country", () => countryBindable.Value = countryA);
|
||||
AddAssert("Check scope is Performance", () => scope.Value == RankingsScope.Performance);
|
||||
AddStep("Set scope to Score", () => scope.Value = RankingsScope.Score);
|
||||
AddAssert("Check country is Null", () => countryBindable.Value == null);
|
||||
|
||||
AddStep("Set country 1", () => countryBindable.Value = countryA);
|
||||
AddStep("Set country 2", () => countryBindable.Value = countryB);
|
||||
AddStep("Set null country", () => countryBindable.Value = null);
|
||||
|
86
osu.Game.Tests/Visual/Online/TestSceneRankingsOverlay.cs
Normal file
86
osu.Game.Tests/Visual/Online/TestSceneRankingsOverlay.cs
Normal file
@ -0,0 +1,86 @@
|
||||
// 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 osu.Game.Overlays.Rankings.Tables;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Overlays;
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Users;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Overlays.Rankings;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
public class TestSceneRankingsOverlay : OsuTestScene
|
||||
{
|
||||
protected override bool UseOnlineAPI => true;
|
||||
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(PerformanceTable),
|
||||
typeof(ScoresTable),
|
||||
typeof(CountriesTable),
|
||||
typeof(TableRowBackground),
|
||||
typeof(UserBasedTable),
|
||||
typeof(RankingsTable<>),
|
||||
typeof(RankingsOverlay)
|
||||
};
|
||||
|
||||
[Cached]
|
||||
private RankingsOverlay rankingsOverlay;
|
||||
|
||||
private readonly Bindable<Country> countryBindable = new Bindable<Country>();
|
||||
private readonly Bindable<RankingsScope> scope = new Bindable<RankingsScope>();
|
||||
|
||||
public TestSceneRankingsOverlay()
|
||||
{
|
||||
Add(rankingsOverlay = new TestRankingsOverlay
|
||||
{
|
||||
Country = { BindTarget = countryBindable },
|
||||
Scope = { BindTarget = scope },
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestShow()
|
||||
{
|
||||
AddStep("Show", rankingsOverlay.Show);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestFlagScopeDependency()
|
||||
{
|
||||
AddStep("Set scope to Score", () => scope.Value = RankingsScope.Score);
|
||||
AddAssert("Check country is Null", () => countryBindable.Value == null);
|
||||
AddStep("Set country", () => countryBindable.Value = us_country);
|
||||
AddAssert("Check scope is Performance", () => scope.Value == RankingsScope.Performance);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestShowCountry()
|
||||
{
|
||||
AddStep("Show US", () => rankingsOverlay.ShowCountry(us_country));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestHide()
|
||||
{
|
||||
AddStep("Hide", rankingsOverlay.Hide);
|
||||
}
|
||||
|
||||
private static readonly Country us_country = new Country
|
||||
{
|
||||
FlagName = "US",
|
||||
FullName = "United States"
|
||||
};
|
||||
|
||||
private class TestRankingsOverlay : RankingsOverlay
|
||||
{
|
||||
public new Bindable<Country> Country => base.Country;
|
||||
|
||||
public new Bindable<RankingsScope> Scope => base.Scope;
|
||||
}
|
||||
}
|
||||
}
|
65
osu.Game.Tests/Visual/Settings/TestSceneSettingsSource.cs
Normal file
65
osu.Game.Tests/Visual/Settings/TestSceneSettingsSource.cs
Normal file
@ -0,0 +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 NUnit.Framework;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Configuration;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Settings
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSceneSettingsSource : OsuTestScene
|
||||
{
|
||||
public TestSceneSettingsSource()
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(20),
|
||||
Width = 0.5f,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Padding = new MarginPadding(50),
|
||||
ChildrenEnumerable = new TestTargetClass().CreateSettingsControls()
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
private class TestTargetClass
|
||||
{
|
||||
[SettingSource("Sample bool", "Clicking this changes a setting")]
|
||||
public BindableBool TickBindable { get; } = new BindableBool();
|
||||
|
||||
[SettingSource("Sample float", "Change something for a mod")]
|
||||
public BindableFloat SliderBindable { get; } = new BindableFloat
|
||||
{
|
||||
MinValue = 0,
|
||||
MaxValue = 10,
|
||||
Default = 5,
|
||||
Value = 7
|
||||
};
|
||||
|
||||
[SettingSource("Sample enum", "Change something for a mod")]
|
||||
public Bindable<TestEnum> EnumBindable { get; } = new Bindable<TestEnum>
|
||||
{
|
||||
Default = TestEnum.Value1,
|
||||
Value = TestEnum.Value2
|
||||
};
|
||||
|
||||
[SettingSource("Sample string", "Change something for a mod")]
|
||||
public Bindable<string> StringBindable { get; } = new Bindable<string>();
|
||||
}
|
||||
|
||||
private enum TestEnum
|
||||
{
|
||||
Value1,
|
||||
Value2
|
||||
}
|
||||
}
|
||||
}
|
107
osu.Game.Tests/Visual/UserInterface/TestSceneModSettings.cs
Normal file
107
osu.Game.Tests/Visual/UserInterface/TestSceneModSettings.cs
Normal file
@ -0,0 +1,107 @@
|
||||
// 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.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Overlays.Mods;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
public class TestSceneModSettings : OsuTestScene
|
||||
{
|
||||
private TestModSelectOverlay modSelect;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Add(modSelect = new TestModSelectOverlay
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Origin = Anchor.BottomCentre,
|
||||
Anchor = Anchor.BottomCentre,
|
||||
});
|
||||
|
||||
var testMod = new TestModCustomisable1();
|
||||
|
||||
AddStep("open", modSelect.Show);
|
||||
AddAssert("button disabled", () => !modSelect.CustomiseButton.Enabled.Value);
|
||||
AddUntilStep("wait for button load", () => modSelect.ButtonsLoaded);
|
||||
AddStep("select mod", () => modSelect.SelectMod(testMod));
|
||||
AddAssert("button enabled", () => modSelect.CustomiseButton.Enabled.Value);
|
||||
AddStep("open Customisation", () => modSelect.CustomiseButton.Click());
|
||||
AddStep("deselect mod", () => modSelect.SelectMod(testMod));
|
||||
AddAssert("controls hidden", () => modSelect.ModSettingsContainer.Alpha == 0);
|
||||
}
|
||||
|
||||
private class TestModSelectOverlay : ModSelectOverlay
|
||||
{
|
||||
public new Container ModSettingsContainer => base.ModSettingsContainer;
|
||||
public new TriangleButton CustomiseButton => base.CustomiseButton;
|
||||
|
||||
public bool ButtonsLoaded => ModSectionsContainer.Children.All(c => c.ModIconsLoaded);
|
||||
|
||||
public void SelectMod(Mod mod) =>
|
||||
ModSectionsContainer.Children.Single(s => s.ModType == mod.Type)
|
||||
.ButtonsContainer.OfType<ModButton>().Single(b => b.Mods.Any(m => m.GetType() == mod.GetType())).SelectNext(1);
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
foreach (var section in ModSectionsContainer)
|
||||
{
|
||||
if (section.ModType == ModType.Conversion)
|
||||
{
|
||||
section.Mods = new Mod[]
|
||||
{
|
||||
new TestModCustomisable1(),
|
||||
new TestModCustomisable2()
|
||||
};
|
||||
}
|
||||
else
|
||||
section.Mods = Array.Empty<Mod>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class TestModCustomisable1 : TestModCustomisable
|
||||
{
|
||||
public override string Name => "Customisable Mod 1";
|
||||
|
||||
public override string Acronym => "CM1";
|
||||
}
|
||||
|
||||
private class TestModCustomisable2 : TestModCustomisable
|
||||
{
|
||||
public override string Name => "Customisable Mod 2";
|
||||
|
||||
public override string Acronym => "CM2";
|
||||
}
|
||||
|
||||
private abstract class TestModCustomisable : Mod, IApplicableMod
|
||||
{
|
||||
public override double ScoreMultiplier => 1.0;
|
||||
|
||||
public override ModType Type => ModType.Conversion;
|
||||
|
||||
[SettingSource("Sample float", "Change something for a mod")]
|
||||
public BindableFloat SliderBindable { get; } = new BindableFloat
|
||||
{
|
||||
MinValue = 0,
|
||||
MaxValue = 10,
|
||||
Default = 5,
|
||||
Value = 7
|
||||
};
|
||||
|
||||
[SettingSource("Sample bool", "Clicking this changes a setting")]
|
||||
public BindableBool TickBindable { get; } = new BindableBool();
|
||||
}
|
||||
}
|
||||
}
|
@ -83,22 +83,16 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
|
||||
};
|
||||
}
|
||||
|
||||
private ScrollState _scrollState;
|
||||
private ScrollState scrollState;
|
||||
|
||||
private ScrollState scrollState
|
||||
private void setScrollState(ScrollState newstate)
|
||||
{
|
||||
get => _scrollState;
|
||||
|
||||
set
|
||||
{
|
||||
if (_scrollState == value)
|
||||
if (scrollState == newstate)
|
||||
return;
|
||||
|
||||
_scrollState = value;
|
||||
|
||||
delayedStateChangeDelegate?.Cancel();
|
||||
|
||||
switch (value)
|
||||
switch (scrollState = newstate)
|
||||
{
|
||||
case ScrollState.Scrolling:
|
||||
resetSelected();
|
||||
@ -113,7 +107,7 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
|
||||
speedTo(0f, 2000);
|
||||
tracker.FadeIn(200);
|
||||
|
||||
delayedStateChangeDelegate = Scheduler.AddDelayed(() => scrollState = ScrollState.Stopped, 2300);
|
||||
delayedStateChangeDelegate = Scheduler.AddDelayed(() => setScrollState(ScrollState.Stopped), 2300);
|
||||
break;
|
||||
|
||||
case ScrollState.Stopped:
|
||||
@ -153,7 +147,7 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
|
||||
st.Selected = true;
|
||||
OnSelected?.Invoke(st.Team);
|
||||
|
||||
delayedStateChangeDelegate = Scheduler.AddDelayed(() => scrollState = ScrollState.Idle, 10000);
|
||||
delayedStateChangeDelegate = Scheduler.AddDelayed(() => setScrollState(ScrollState.Idle), 10000);
|
||||
break;
|
||||
|
||||
case ScrollState.Idle:
|
||||
@ -166,7 +160,6 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void AddTeam(TournamentTeam team)
|
||||
{
|
||||
@ -176,7 +169,7 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
|
||||
availableTeams.Add(team);
|
||||
|
||||
RemoveAll(c => c is ScrollingTeam);
|
||||
scrollState = ScrollState.Idle;
|
||||
setScrollState(ScrollState.Idle);
|
||||
}
|
||||
|
||||
public void AddTeams(IEnumerable<TournamentTeam> teams)
|
||||
@ -192,7 +185,7 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
|
||||
{
|
||||
availableTeams.Clear();
|
||||
RemoveAll(c => c is ScrollingTeam);
|
||||
scrollState = ScrollState.Idle;
|
||||
setScrollState(ScrollState.Idle);
|
||||
}
|
||||
|
||||
public void RemoveTeam(TournamentTeam team)
|
||||
@ -217,7 +210,7 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
|
||||
if (availableTeams.Count == 0)
|
||||
return;
|
||||
|
||||
scrollState = ScrollState.Scrolling;
|
||||
setScrollState(ScrollState.Scrolling);
|
||||
}
|
||||
|
||||
public void StopScrolling()
|
||||
@ -232,13 +225,13 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
|
||||
return;
|
||||
}
|
||||
|
||||
scrollState = ScrollState.Stopping;
|
||||
setScrollState(ScrollState.Stopping);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
scrollState = ScrollState.Idle;
|
||||
setScrollState(ScrollState.Idle);
|
||||
}
|
||||
|
||||
protected override void UpdateAfterChildren()
|
||||
@ -305,7 +298,7 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
|
||||
private void speedTo(float value, double duration = 0, Easing easing = Easing.None) =>
|
||||
this.TransformTo(nameof(speed), value, duration, easing);
|
||||
|
||||
private enum ScrollState
|
||||
protected enum ScrollState
|
||||
{
|
||||
None,
|
||||
Idle,
|
||||
|
@ -57,7 +57,7 @@ namespace osu.Game.Beatmaps
|
||||
{
|
||||
public override IEnumerable<Mod> GetModsFor(ModType type) => new Mod[] { };
|
||||
|
||||
public override DrawableRuleset CreateDrawableRulesetWith(IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
||||
public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using osu.Framework.IO.File;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Game.Beatmaps.Timing;
|
||||
using osu.Game.Rulesets.Objects.Legacy;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
@ -113,7 +113,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
switch (pair.Key)
|
||||
{
|
||||
case @"AudioFilename":
|
||||
metadata.AudioFile = FileSafety.PathStandardise(pair.Value);
|
||||
metadata.AudioFile = pair.Value.ToStandardisedPath();
|
||||
break;
|
||||
|
||||
case @"AudioLeadIn":
|
||||
@ -301,12 +301,12 @@ namespace osu.Game.Beatmaps.Formats
|
||||
{
|
||||
case LegacyEventType.Background:
|
||||
string bgFilename = split[2].Trim('"');
|
||||
beatmap.BeatmapInfo.Metadata.BackgroundFile = FileSafety.PathStandardise(bgFilename);
|
||||
beatmap.BeatmapInfo.Metadata.BackgroundFile = bgFilename.ToStandardisedPath();
|
||||
break;
|
||||
|
||||
case LegacyEventType.Video:
|
||||
string videoFilename = split[2].Trim('"');
|
||||
beatmap.BeatmapInfo.Metadata.VideoFile = FileSafety.PathStandardise(videoFilename);
|
||||
beatmap.BeatmapInfo.Metadata.VideoFile = videoFilename.ToStandardisedPath();
|
||||
break;
|
||||
|
||||
case LegacyEventType.Break:
|
||||
|
@ -8,8 +8,8 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.IO.File;
|
||||
using osu.Game.IO;
|
||||
using osu.Game.Storyboards;
|
||||
using osu.Game.Beatmaps.Legacy;
|
||||
@ -336,6 +336,6 @@ namespace osu.Game.Beatmaps.Formats
|
||||
}
|
||||
}
|
||||
|
||||
private string cleanFilename(string path) => FileSafety.PathStandardise(path.Trim('"'));
|
||||
private string cleanFilename(string path) => path.Trim('"').ToStandardisedPath();
|
||||
}
|
||||
}
|
||||
|
@ -62,6 +62,6 @@ namespace osu.Game.Beatmaps
|
||||
/// <param name="mods">The <see cref="Mod"/>s to apply to the <see cref="IBeatmap"/>.</param>
|
||||
/// <returns>The converted <see cref="IBeatmap"/>.</returns>
|
||||
/// <exception cref="BeatmapInvalidForRulesetException">If <see cref="Beatmap"/> could not be converted to <paramref name="ruleset"/>.</exception>
|
||||
IBeatmap GetPlayableBeatmap(RulesetInfo ruleset, IReadOnlyList<Mod> mods);
|
||||
IBeatmap GetPlayableBeatmap(RulesetInfo ruleset, IReadOnlyList<Mod> mods = null);
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ using osu.Game.Rulesets.Mods;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Storyboards;
|
||||
using osu.Framework.IO.File;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
@ -83,7 +82,10 @@ namespace osu.Game.Beatmaps
|
||||
/// <returns>The absolute path of the output file.</returns>
|
||||
public string Save()
|
||||
{
|
||||
var path = FileSafety.GetTempPath(Guid.NewGuid().ToString().Replace("-", string.Empty) + ".json");
|
||||
string directory = Path.Combine(Path.GetTempPath(), @"osu!");
|
||||
Directory.CreateDirectory(directory);
|
||||
|
||||
var path = Path.Combine(directory, Guid.NewGuid().ToString().Replace("-", string.Empty) + ".json");
|
||||
using (var sw = new StreamWriter(path))
|
||||
sw.WriteLine(Beatmap.Serialize());
|
||||
return path;
|
||||
@ -97,8 +99,10 @@ namespace osu.Game.Beatmaps
|
||||
/// <returns>The applicable <see cref="IBeatmapConverter"/>.</returns>
|
||||
protected virtual IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap, Ruleset ruleset) => ruleset.CreateBeatmapConverter(beatmap);
|
||||
|
||||
public IBeatmap GetPlayableBeatmap(RulesetInfo ruleset, IReadOnlyList<Mod> mods)
|
||||
public IBeatmap GetPlayableBeatmap(RulesetInfo ruleset, IReadOnlyList<Mod> mods = null)
|
||||
{
|
||||
mods ??= Array.Empty<Mod>();
|
||||
|
||||
var rulesetInstance = ruleset.CreateInstance();
|
||||
|
||||
IBeatmapConverter converter = CreateBeatmapConverter(Beatmap, rulesetInstance);
|
||||
|
@ -80,6 +80,7 @@ namespace osu.Game.Configuration
|
||||
// Gameplay
|
||||
Set(OsuSetting.DimLevel, 0.3, 0, 1, 0.01);
|
||||
Set(OsuSetting.BlurLevel, 0, 0, 1, 0.01);
|
||||
Set(OsuSetting.LightenDuringBreaks, true);
|
||||
|
||||
Set(OsuSetting.HitLighting, true);
|
||||
|
||||
@ -142,6 +143,7 @@ namespace osu.Game.Configuration
|
||||
AutoCursorSize,
|
||||
DimLevel,
|
||||
BlurLevel,
|
||||
LightenDuringBreaks,
|
||||
ShowStoryboard,
|
||||
ShowVideoBackground,
|
||||
KeyOverlay,
|
||||
|
110
osu.Game/Configuration/SettingSourceAttribute.cs
Normal file
110
osu.Game/Configuration/SettingSourceAttribute.cs
Normal file
@ -0,0 +1,110 @@
|
||||
// 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.Reflection;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Game.Overlays.Settings;
|
||||
|
||||
namespace osu.Game.Configuration
|
||||
{
|
||||
/// <summary>
|
||||
/// An attribute to mark a bindable as being exposed to the user via settings controls.
|
||||
/// Can be used in conjunction with <see cref="SettingSourceExtensions.CreateSettingsControls"/> to automatically create UI controls.
|
||||
/// </summary>
|
||||
[MeansImplicitUse]
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
public class SettingSourceAttribute : Attribute
|
||||
{
|
||||
public string Label { get; }
|
||||
|
||||
public string Description { get; }
|
||||
|
||||
public SettingSourceAttribute(string label, string description = null)
|
||||
{
|
||||
Label = label ?? string.Empty;
|
||||
Description = description ?? string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public static class SettingSourceExtensions
|
||||
{
|
||||
public static IEnumerable<Drawable> CreateSettingsControls(this object obj)
|
||||
{
|
||||
foreach (var property in obj.GetType().GetProperties(BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.Instance))
|
||||
{
|
||||
var attr = property.GetCustomAttribute<SettingSourceAttribute>(true);
|
||||
|
||||
if (attr == null)
|
||||
continue;
|
||||
|
||||
var prop = property.GetValue(obj);
|
||||
|
||||
switch (prop)
|
||||
{
|
||||
case BindableNumber<float> bNumber:
|
||||
yield return new SettingsSlider<float>
|
||||
{
|
||||
LabelText = attr.Label,
|
||||
Bindable = bNumber
|
||||
};
|
||||
|
||||
break;
|
||||
|
||||
case BindableNumber<double> bNumber:
|
||||
yield return new SettingsSlider<double>
|
||||
{
|
||||
LabelText = attr.Label,
|
||||
Bindable = bNumber
|
||||
};
|
||||
|
||||
break;
|
||||
|
||||
case BindableNumber<int> bNumber:
|
||||
yield return new SettingsSlider<int>
|
||||
{
|
||||
LabelText = attr.Label,
|
||||
Bindable = bNumber
|
||||
};
|
||||
|
||||
break;
|
||||
|
||||
case Bindable<bool> bBool:
|
||||
yield return new SettingsCheckbox
|
||||
{
|
||||
LabelText = attr.Label,
|
||||
Bindable = bBool
|
||||
};
|
||||
|
||||
break;
|
||||
|
||||
case Bindable<string> bString:
|
||||
yield return new SettingsTextBox
|
||||
{
|
||||
LabelText = attr.Label,
|
||||
Bindable = bString
|
||||
};
|
||||
|
||||
break;
|
||||
|
||||
case IBindable bindable:
|
||||
var dropdownType = typeof(SettingsEnumDropdown<>).MakeGenericType(bindable.GetType().GetGenericArguments()[0]);
|
||||
var dropdown = (Drawable)Activator.CreateInstance(dropdownType);
|
||||
|
||||
dropdown.GetType().GetProperty(nameof(IHasCurrentValue<object>.Current))?.SetValue(dropdown, obj);
|
||||
|
||||
yield return dropdown;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new InvalidOperationException($"{nameof(SettingSourceAttribute)} was attached to an unsupported type ({prop})");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -13,7 +13,6 @@ using Microsoft.EntityFrameworkCore;
|
||||
using osu.Framework;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.IO.File;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Threading;
|
||||
@ -493,7 +492,7 @@ namespace osu.Game.Database
|
||||
{
|
||||
fileInfos.Add(new TFileModel
|
||||
{
|
||||
Filename = FileSafety.PathStandardise(file.Substring(prefix.Length)),
|
||||
Filename = file.Substring(prefix.Length).ToStandardisedPath(),
|
||||
FileInfo = files.Add(s)
|
||||
});
|
||||
}
|
||||
|
@ -149,8 +149,16 @@ namespace osu.Game.Database
|
||||
lock (writeLock)
|
||||
{
|
||||
recycleThreadContexts();
|
||||
|
||||
try
|
||||
{
|
||||
storage.DeleteDatabase(database_name);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// for now we are not sure why file handles are kept open by EF, but this is generally only used in testing
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,13 @@
|
||||
// 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.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Screens.Play;
|
||||
|
||||
namespace osu.Game.Graphics.Containers
|
||||
{
|
||||
@ -14,7 +16,12 @@ namespace osu.Game.Graphics.Containers
|
||||
/// </summary>
|
||||
public abstract class UserDimContainer : Container
|
||||
{
|
||||
protected const float BACKGROUND_FADE_DURATION = 800;
|
||||
/// <summary>
|
||||
/// Amount of lightening to apply to current dim level during break times.
|
||||
/// </summary>
|
||||
public const float BREAK_LIGHTEN_AMOUNT = 0.3f;
|
||||
|
||||
protected const double BACKGROUND_FADE_DURATION = 800;
|
||||
|
||||
/// <summary>
|
||||
/// Whether or not user-configured dim levels should be applied to the container.
|
||||
@ -26,6 +33,12 @@ namespace osu.Game.Graphics.Containers
|
||||
/// </summary>
|
||||
public readonly Bindable<bool> StoryboardReplacesBackground = new Bindable<bool>();
|
||||
|
||||
/// <summary>
|
||||
/// Whether player is in break time.
|
||||
/// Must be bound to <see cref="BreakOverlay.IsBreakTime"/> to allow for dim adjustments in gameplay.
|
||||
/// </summary>
|
||||
public readonly IBindable<bool> IsBreakTime = new Bindable<bool>();
|
||||
|
||||
/// <summary>
|
||||
/// Whether the content of this container is currently being displayed.
|
||||
/// </summary>
|
||||
@ -33,11 +46,14 @@ namespace osu.Game.Graphics.Containers
|
||||
|
||||
protected Bindable<double> UserDimLevel { get; private set; }
|
||||
|
||||
protected Bindable<bool> LightenDuringBreaks { get; private set; }
|
||||
|
||||
protected Bindable<bool> ShowStoryboard { get; private set; }
|
||||
|
||||
protected Bindable<bool> ShowVideo { get; private set; }
|
||||
|
||||
protected double DimLevel => EnableUserDim.Value ? UserDimLevel.Value : 0;
|
||||
private float breakLightening => LightenDuringBreaks.Value && IsBreakTime.Value ? BREAK_LIGHTEN_AMOUNT : 0;
|
||||
protected float DimLevel => Math.Max(EnableUserDim.Value ? (float)UserDimLevel.Value - breakLightening : 0, 0);
|
||||
|
||||
protected override Container<Drawable> Content => dimContent;
|
||||
|
||||
@ -55,11 +71,14 @@ namespace osu.Game.Graphics.Containers
|
||||
private void load(OsuConfigManager config)
|
||||
{
|
||||
UserDimLevel = config.GetBindable<double>(OsuSetting.DimLevel);
|
||||
LightenDuringBreaks = config.GetBindable<bool>(OsuSetting.LightenDuringBreaks);
|
||||
ShowStoryboard = config.GetBindable<bool>(OsuSetting.ShowStoryboard);
|
||||
ShowVideo = config.GetBindable<bool>(OsuSetting.ShowVideoBackground);
|
||||
|
||||
EnableUserDim.ValueChanged += _ => UpdateVisuals();
|
||||
UserDimLevel.ValueChanged += _ => UpdateVisuals();
|
||||
LightenDuringBreaks.ValueChanged += _ => UpdateVisuals();
|
||||
IsBreakTime.ValueChanged += _ => UpdateVisuals();
|
||||
ShowStoryboard.ValueChanged += _ => UpdateVisuals();
|
||||
ShowVideo.ValueChanged += _ => UpdateVisuals();
|
||||
StoryboardReplacesBackground.ValueChanged += _ => UpdateVisuals();
|
||||
@ -84,7 +103,7 @@ namespace osu.Game.Graphics.Containers
|
||||
ContentDisplayed = ShowDimContent;
|
||||
|
||||
dimContent.FadeTo(ContentDisplayed ? 1 : 0, BACKGROUND_FADE_DURATION, Easing.OutQuint);
|
||||
dimContent.FadeColour(OsuColour.Gray(1 - (float)DimLevel), BACKGROUND_FADE_DURATION, Easing.OutQuint);
|
||||
dimContent.FadeColour(OsuColour.Gray(1f - DimLevel), BACKGROUND_FADE_DURATION, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,13 +8,14 @@ namespace osu.Game.Online.API.Requests
|
||||
{
|
||||
public class GetUserRankingsRequest : GetRankingsRequest<GetUsersResponse>
|
||||
{
|
||||
public readonly UserRankingsType Type;
|
||||
|
||||
private readonly string country;
|
||||
private readonly UserRankingsType type;
|
||||
|
||||
public GetUserRankingsRequest(RulesetInfo ruleset, UserRankingsType type = UserRankingsType.Performance, int page = 1, string country = null)
|
||||
: base(ruleset, page)
|
||||
{
|
||||
this.type = type;
|
||||
Type = type;
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
@ -28,7 +29,7 @@ namespace osu.Game.Online.API.Requests
|
||||
return req;
|
||||
}
|
||||
|
||||
protected override string TargetPostfix() => type.ToString().ToLowerInvariant();
|
||||
protected override string TargetPostfix() => Type.ToString().ToLowerInvariant();
|
||||
}
|
||||
|
||||
public enum UserRankingsType
|
||||
|
@ -26,7 +26,7 @@ namespace osu.Game.Online
|
||||
/// </summary>
|
||||
protected readonly Bindable<DownloadState> State = new Bindable<DownloadState>();
|
||||
|
||||
protected readonly Bindable<double> Progress = new Bindable<double>();
|
||||
protected readonly BindableNumber<double> Progress = new BindableNumber<double> { MinValue = 0, MaxValue = 1 };
|
||||
|
||||
protected DownloadTrackingComposite(TModel model = null)
|
||||
{
|
||||
|
@ -45,23 +45,25 @@ namespace osu.Game.Online.Multiplayer
|
||||
[JsonProperty("beatmap")]
|
||||
private APIBeatmap apiBeatmap { get; set; }
|
||||
|
||||
private APIMod[] allowedModsBacking;
|
||||
|
||||
[JsonProperty("allowed_mods")]
|
||||
private APIMod[] allowedMods
|
||||
{
|
||||
get => AllowedMods.Select(m => new APIMod { Acronym = m.Acronym }).ToArray();
|
||||
set => _allowedMods = value;
|
||||
set => allowedModsBacking = value;
|
||||
}
|
||||
|
||||
private APIMod[] requiredModsBacking;
|
||||
|
||||
[JsonProperty("required_mods")]
|
||||
private APIMod[] requiredMods
|
||||
{
|
||||
get => RequiredMods.Select(m => new APIMod { Acronym = m.Acronym }).ToArray();
|
||||
set => _requiredMods = value;
|
||||
set => requiredModsBacking = value;
|
||||
}
|
||||
|
||||
private BeatmapInfo beatmap;
|
||||
private APIMod[] _allowedMods;
|
||||
private APIMod[] _requiredMods;
|
||||
|
||||
public void MapObjects(BeatmapManager beatmaps, RulesetStore rulesets)
|
||||
{
|
||||
@ -70,20 +72,20 @@ namespace osu.Game.Online.Multiplayer
|
||||
Beatmap = apiBeatmap == null ? beatmaps.QueryBeatmap(b => b.OnlineBeatmapID == BeatmapID) : apiBeatmap.ToBeatmap(rulesets);
|
||||
Ruleset = rulesets.GetRuleset(RulesetID);
|
||||
|
||||
if (_allowedMods != null)
|
||||
if (allowedModsBacking != null)
|
||||
{
|
||||
AllowedMods.Clear();
|
||||
AllowedMods.AddRange(Ruleset.CreateInstance().GetAllMods().Where(mod => _allowedMods.Any(m => m.Acronym == mod.Acronym)));
|
||||
AllowedMods.AddRange(Ruleset.CreateInstance().GetAllMods().Where(mod => allowedModsBacking.Any(m => m.Acronym == mod.Acronym)));
|
||||
|
||||
_allowedMods = null;
|
||||
allowedModsBacking = null;
|
||||
}
|
||||
|
||||
if (_requiredMods != null)
|
||||
if (requiredModsBacking != null)
|
||||
{
|
||||
RequiredMods.Clear();
|
||||
RequiredMods.AddRange(Ruleset.CreateInstance().GetAllMods().Where(mod => _requiredMods.Any(m => m.Acronym == mod.Acronym)));
|
||||
RequiredMods.AddRange(Ruleset.CreateInstance().GetAllMods().Where(mod => requiredModsBacking.Any(m => m.Acronym == mod.Acronym)));
|
||||
|
||||
_requiredMods = null;
|
||||
requiredModsBacking = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
56
osu.Game/Overlays/Mods/ModControlSection.cs
Normal file
56
osu.Game/Overlays/Mods/ModControlSection.cs
Normal file
@ -0,0 +1,56 @@
|
||||
// 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;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Overlays.Mods
|
||||
{
|
||||
public class ModControlSection : Container
|
||||
{
|
||||
protected FillFlowContainer FlowContent;
|
||||
protected override Container<Drawable> Content => FlowContent;
|
||||
|
||||
public readonly Mod Mod;
|
||||
|
||||
public ModControlSection(Mod mod)
|
||||
{
|
||||
Mod = mod;
|
||||
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
|
||||
FlowContent = new FillFlowContainer
|
||||
{
|
||||
Margin = new MarginPadding { Top = 30 },
|
||||
Spacing = new Vector2(0, 5),
|
||||
Direction = FillDirection.Vertical,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
};
|
||||
|
||||
AddRange(Mod.CreateSettingsControls());
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
AddRangeInternal(new Drawable[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = Mod.Name,
|
||||
Font = OsuFont.GetFont(weight: FontWeight.Bold),
|
||||
Colour = colours.Yellow,
|
||||
},
|
||||
FlowContent
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -57,6 +57,15 @@ namespace osu.Game.Overlays.Mods
|
||||
}).ToArray();
|
||||
|
||||
modsLoadCts?.Cancel();
|
||||
|
||||
if (modContainers.Length == 0)
|
||||
{
|
||||
ModIconsLoaded = true;
|
||||
headerLabel.Hide();
|
||||
Hide();
|
||||
return;
|
||||
}
|
||||
|
||||
ModIconsLoaded = false;
|
||||
|
||||
LoadComponentsAsync(modContainers, c =>
|
||||
@ -67,18 +76,9 @@ namespace osu.Game.Overlays.Mods
|
||||
|
||||
buttons = modContainers.OfType<ModButton>().ToArray();
|
||||
|
||||
if (value.Any())
|
||||
{
|
||||
headerLabel.FadeIn(200);
|
||||
this.FadeIn(200);
|
||||
}
|
||||
else
|
||||
{
|
||||
// transition here looks weird as mods instantly disappear.
|
||||
headerLabel.Hide();
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ModButton[] buttons = { };
|
||||
|
@ -13,6 +13,7 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Backgrounds;
|
||||
using osu.Game.Graphics.Containers;
|
||||
@ -31,6 +32,7 @@ namespace osu.Game.Overlays.Mods
|
||||
public class ModSelectOverlay : WaveOverlayContainer
|
||||
{
|
||||
protected readonly TriangleButton DeselectAllButton;
|
||||
protected readonly TriangleButton CustomiseButton;
|
||||
protected readonly TriangleButton CloseButton;
|
||||
|
||||
protected readonly OsuSpriteText MultiplierLabel;
|
||||
@ -42,6 +44,10 @@ namespace osu.Game.Overlays.Mods
|
||||
|
||||
protected readonly FillFlowContainer<ModSection> ModSectionsContainer;
|
||||
|
||||
protected readonly FillFlowContainer<ModControlSection> ModSettingsContent;
|
||||
|
||||
protected readonly Container ModSettingsContainer;
|
||||
|
||||
protected readonly Bindable<IReadOnlyList<Mod>> SelectedMods = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());
|
||||
|
||||
protected readonly IBindable<RulesetInfo> Ruleset = new Bindable<RulesetInfo>();
|
||||
@ -226,6 +232,17 @@ namespace osu.Game.Overlays.Mods
|
||||
Right = 20
|
||||
}
|
||||
},
|
||||
CustomiseButton = new TriangleButton
|
||||
{
|
||||
Width = 180,
|
||||
Text = "Customisation",
|
||||
Action = () => ModSettingsContainer.Alpha = ModSettingsContainer.Alpha == 1 ? 0 : 1,
|
||||
Enabled = { Value = false },
|
||||
Margin = new MarginPadding
|
||||
{
|
||||
Right = 20
|
||||
}
|
||||
},
|
||||
CloseButton = new TriangleButton
|
||||
{
|
||||
Width = 180,
|
||||
@ -271,6 +288,36 @@ namespace osu.Game.Overlays.Mods
|
||||
},
|
||||
},
|
||||
},
|
||||
ModSettingsContainer = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.BottomRight,
|
||||
Width = 0.25f,
|
||||
Alpha = 0,
|
||||
X = -100,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = new Color4(0, 0, 0, 192)
|
||||
},
|
||||
new OsuScrollContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = ModSettingsContent = new FillFlowContainer<ModControlSection>
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Spacing = new Vector2(0f, 10f),
|
||||
Padding = new MarginPadding(20),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -381,12 +428,14 @@ namespace osu.Game.Overlays.Mods
|
||||
refreshSelectedMods();
|
||||
}
|
||||
|
||||
private void selectedModsChanged(ValueChangedEvent<IReadOnlyList<Mod>> e)
|
||||
private void selectedModsChanged(ValueChangedEvent<IReadOnlyList<Mod>> mods)
|
||||
{
|
||||
foreach (var section in ModSectionsContainer.Children)
|
||||
section.SelectTypes(e.NewValue.Select(m => m.GetType()).ToList());
|
||||
section.SelectTypes(mods.NewValue.Select(m => m.GetType()).ToList());
|
||||
|
||||
updateMods();
|
||||
|
||||
updateModSettings(mods);
|
||||
}
|
||||
|
||||
private void updateMods()
|
||||
@ -411,6 +460,25 @@ namespace osu.Game.Overlays.Mods
|
||||
UnrankedLabel.FadeTo(ranked ? 0 : 1, 200);
|
||||
}
|
||||
|
||||
private void updateModSettings(ValueChangedEvent<IReadOnlyList<Mod>> selectedMods)
|
||||
{
|
||||
foreach (var added in selectedMods.NewValue.Except(selectedMods.OldValue))
|
||||
{
|
||||
var controls = added.CreateSettingsControls().ToList();
|
||||
if (controls.Count > 0)
|
||||
ModSettingsContent.Add(new ModControlSection(added) { Children = controls });
|
||||
}
|
||||
|
||||
foreach (var removed in selectedMods.OldValue.Except(selectedMods.NewValue))
|
||||
ModSettingsContent.RemoveAll(section => section.Mod == removed);
|
||||
|
||||
bool hasSettings = ModSettingsContent.Children.Count > 0;
|
||||
CustomiseButton.Enabled.Value = hasSettings;
|
||||
|
||||
if (!hasSettings)
|
||||
ModSettingsContainer.Hide();
|
||||
}
|
||||
|
||||
private void modButtonPressed(Mod selectedMod)
|
||||
{
|
||||
if (selectedMod != null)
|
||||
|
@ -261,8 +261,8 @@ namespace osu.Game.Overlays
|
||||
|
||||
if (allowRateAdjustments)
|
||||
{
|
||||
foreach (var mod in mods.Value.OfType<IApplicableToClock>())
|
||||
mod.ApplyToClock(track);
|
||||
foreach (var mod in mods.Value.OfType<IApplicableToTrack>())
|
||||
mod.ApplyToTrack(track);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,13 +74,7 @@ namespace osu.Game.Overlays.Rankings
|
||||
base.LoadComplete();
|
||||
}
|
||||
|
||||
private void onScopeChanged(ValueChangedEvent<RankingsScope> scope)
|
||||
{
|
||||
scopeText.Text = scope.NewValue.ToString();
|
||||
|
||||
if (scope.NewValue != RankingsScope.Performance)
|
||||
Country.Value = null;
|
||||
}
|
||||
private void onScopeChanged(ValueChangedEvent<RankingsScope> scope) => scopeText.Text = scope.NewValue.ToString();
|
||||
|
||||
private void onCountryChanged(ValueChangedEvent<Country> country)
|
||||
{
|
||||
@ -90,8 +84,6 @@ namespace osu.Game.Overlays.Rankings
|
||||
return;
|
||||
}
|
||||
|
||||
Scope.Value = RankingsScope.Performance;
|
||||
|
||||
flag.Country = country.NewValue;
|
||||
flag.Show();
|
||||
}
|
||||
|
214
osu.Game/Overlays/RankingsOverlay.cs
Normal file
214
osu.Game/Overlays/RankingsOverlay.cs
Normal file
@ -0,0 +1,214 @@
|
||||
// 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;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Overlays.Rankings;
|
||||
using osu.Game.Users;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.API;
|
||||
using System.Threading;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Overlays.Rankings.Tables;
|
||||
|
||||
namespace osu.Game.Overlays
|
||||
{
|
||||
public class RankingsOverlay : FullscreenOverlay
|
||||
{
|
||||
protected readonly Bindable<Country> Country = new Bindable<Country>();
|
||||
protected readonly Bindable<RankingsScope> Scope = new Bindable<RankingsScope>();
|
||||
private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
|
||||
|
||||
private readonly BasicScrollContainer scrollFlow;
|
||||
private readonly Box background;
|
||||
private readonly Container tableContainer;
|
||||
private readonly DimmedLoadingLayer loading;
|
||||
|
||||
private APIRequest lastRequest;
|
||||
private CancellationTokenSource cancellationToken;
|
||||
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; }
|
||||
|
||||
public RankingsOverlay()
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
background = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
scrollFlow = new BasicScrollContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
ScrollbarVisible = false,
|
||||
Child = new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Y,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Direction = FillDirection.Vertical,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new RankingsHeader
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Country = { BindTarget = Country },
|
||||
Scope = { BindTarget = Scope },
|
||||
Ruleset = { BindTarget = ruleset }
|
||||
},
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
tableContainer = new Container
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Margin = new MarginPadding { Vertical = 10 }
|
||||
},
|
||||
loading = new DimmedLoadingLayer(),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colour)
|
||||
{
|
||||
Waves.FirstWaveColour = colour.Green;
|
||||
Waves.SecondWaveColour = colour.GreenLight;
|
||||
Waves.ThirdWaveColour = colour.GreenDark;
|
||||
Waves.FourthWaveColour = colour.GreenDarker;
|
||||
|
||||
background.Colour = OsuColour.Gray(0.1f);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
Country.BindValueChanged(_ =>
|
||||
{
|
||||
// if a country is requested, force performance scope.
|
||||
if (Country.Value != null)
|
||||
Scope.Value = RankingsScope.Performance;
|
||||
|
||||
Scheduler.AddOnce(loadNewContent);
|
||||
}, true);
|
||||
|
||||
Scope.BindValueChanged(_ =>
|
||||
{
|
||||
// country filtering is only valid for performance scope.
|
||||
if (Scope.Value != RankingsScope.Performance)
|
||||
Country.Value = null;
|
||||
|
||||
Scheduler.AddOnce(loadNewContent);
|
||||
}, true);
|
||||
|
||||
ruleset.BindValueChanged(_ => Scheduler.AddOnce(loadNewContent), true);
|
||||
|
||||
base.LoadComplete();
|
||||
}
|
||||
|
||||
public void ShowCountry(Country requested)
|
||||
{
|
||||
if (requested == null)
|
||||
return;
|
||||
|
||||
Show();
|
||||
|
||||
Country.Value = requested;
|
||||
}
|
||||
|
||||
private void loadNewContent()
|
||||
{
|
||||
loading.Show();
|
||||
|
||||
cancellationToken?.Cancel();
|
||||
lastRequest?.Cancel();
|
||||
|
||||
var request = createScopedRequest();
|
||||
lastRequest = request;
|
||||
|
||||
if (request == null)
|
||||
{
|
||||
loadTable(null);
|
||||
return;
|
||||
}
|
||||
|
||||
request.Success += () => loadTable(createTableFromResponse(request));
|
||||
request.Failure += _ => loadTable(null);
|
||||
|
||||
api.Queue(request);
|
||||
}
|
||||
|
||||
private APIRequest createScopedRequest()
|
||||
{
|
||||
switch (Scope.Value)
|
||||
{
|
||||
case RankingsScope.Performance:
|
||||
return new GetUserRankingsRequest(ruleset.Value, country: Country.Value?.FlagName);
|
||||
|
||||
case RankingsScope.Country:
|
||||
return new GetCountryRankingsRequest(ruleset.Value);
|
||||
|
||||
case RankingsScope.Score:
|
||||
return new GetUserRankingsRequest(ruleset.Value, UserRankingsType.Score);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private Drawable createTableFromResponse(APIRequest request)
|
||||
{
|
||||
switch (request)
|
||||
{
|
||||
case GetUserRankingsRequest userRequest:
|
||||
switch (userRequest.Type)
|
||||
{
|
||||
case UserRankingsType.Performance:
|
||||
return new PerformanceTable(1, userRequest.Result.Users);
|
||||
|
||||
case UserRankingsType.Score:
|
||||
return new ScoresTable(1, userRequest.Result.Users);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
case GetCountryRankingsRequest countryRequest:
|
||||
return new CountriesTable(1, countryRequest.Result.Countries);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void loadTable(Drawable table)
|
||||
{
|
||||
scrollFlow.ScrollToStart();
|
||||
|
||||
if (table == null)
|
||||
{
|
||||
tableContainer.Clear();
|
||||
loading.Hide();
|
||||
return;
|
||||
}
|
||||
|
||||
LoadComponentAsync(table, t =>
|
||||
{
|
||||
loading.Hide();
|
||||
tableContainer.Child = table;
|
||||
}, (cancellationToken = new CancellationTokenSource()).Token);
|
||||
}
|
||||
}
|
||||
}
|
@ -30,6 +30,11 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
|
||||
KeyboardStep = 0.01f
|
||||
},
|
||||
new SettingsCheckbox
|
||||
{
|
||||
LabelText = "Lighten playfield during breaks",
|
||||
Bindable = config.GetBindable<bool>(OsuSetting.LightenDuringBreaks)
|
||||
},
|
||||
new SettingsCheckbox
|
||||
{
|
||||
LabelText = "Show score overlay",
|
||||
Bindable = config.GetBindable<bool>(OsuSetting.ShowInterface)
|
||||
|
@ -53,27 +53,10 @@ namespace osu.Game.Overlays.Settings
|
||||
}
|
||||
}
|
||||
|
||||
// hold a reference to the provided bindable so we don't have to in every settings section.
|
||||
private Bindable<T> bindable;
|
||||
|
||||
public virtual Bindable<T> Bindable
|
||||
{
|
||||
get => bindable;
|
||||
|
||||
set
|
||||
{
|
||||
if (bindable != null)
|
||||
controlWithCurrent?.Current.UnbindFrom(bindable);
|
||||
|
||||
bindable = value;
|
||||
controlWithCurrent?.Current.BindTo(bindable);
|
||||
|
||||
if (ShowsDefaultIndicator)
|
||||
{
|
||||
restoreDefaultButton.Bindable = bindable.GetBoundCopy();
|
||||
restoreDefaultButton.Bindable.TriggerChange();
|
||||
}
|
||||
}
|
||||
get => controlWithCurrent.Current;
|
||||
set => controlWithCurrent.Current = value;
|
||||
}
|
||||
|
||||
public virtual IEnumerable<string> FilterTerms => Keywords == null ? new[] { LabelText } : new List<string>(Keywords) { LabelText }.ToArray();
|
||||
@ -110,7 +93,12 @@ namespace osu.Game.Overlays.Settings
|
||||
private void load()
|
||||
{
|
||||
if (controlWithCurrent != null)
|
||||
{
|
||||
controlWithCurrent.Current.DisabledChanged += disabled => { Colour = disabled ? Color4.Gray : Color4.White; };
|
||||
|
||||
if (ShowsDefaultIndicator)
|
||||
restoreDefaultButton.Bindable = controlWithCurrent.Current;
|
||||
}
|
||||
}
|
||||
|
||||
private class RestoreDefaultValueButton : Container, IHasTooltip
|
||||
@ -125,6 +113,7 @@ namespace osu.Game.Overlays.Settings
|
||||
bindable = value;
|
||||
bindable.ValueChanged += _ => UpdateState();
|
||||
bindable.DisabledChanged += _ => UpdateState();
|
||||
UpdateState();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,8 +4,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Difficulty.Preprocessing;
|
||||
using osu.Game.Rulesets.Difficulty.Skills;
|
||||
@ -41,10 +41,10 @@ namespace osu.Game.Rulesets.Difficulty
|
||||
|
||||
IBeatmap playableBeatmap = beatmap.GetPlayableBeatmap(ruleset.RulesetInfo, mods);
|
||||
|
||||
var clock = new StopwatchClock();
|
||||
mods.OfType<IApplicableToClock>().ForEach(m => m.ApplyToClock(clock));
|
||||
var track = new TrackVirtual(10000);
|
||||
mods.OfType<IApplicableToTrack>().ForEach(m => m.ApplyToTrack(track));
|
||||
|
||||
return calculate(playableBeatmap, mods, clock.Rate);
|
||||
return calculate(playableBeatmap, mods, track.Rate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -3,8 +3,8 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Scoring;
|
||||
@ -35,9 +35,9 @@ namespace osu.Game.Rulesets.Difficulty
|
||||
|
||||
protected virtual void ApplyMods(Mod[] mods)
|
||||
{
|
||||
var clock = new StopwatchClock();
|
||||
mods.OfType<IApplicableToClock>().ForEach(m => m.ApplyToClock(clock));
|
||||
TimeRate = clock.Rate;
|
||||
var track = new TrackVirtual(10000);
|
||||
mods.OfType<IApplicableToTrack>().ForEach(m => m.ApplyToTrack(track));
|
||||
TimeRate = track.Rate;
|
||||
}
|
||||
|
||||
public abstract double Calculate(Dictionary<string, double> categoryDifficulty = null);
|
||||
|
@ -48,7 +48,6 @@ namespace osu.Game.Rulesets.Edit
|
||||
[Resolved]
|
||||
private BindableBeatDivisor beatDivisor { get; set; }
|
||||
|
||||
private IWorkingBeatmap workingBeatmap;
|
||||
private Beatmap<TObject> playableBeatmap;
|
||||
private IBeatmapProcessor beatmapProcessor;
|
||||
|
||||
@ -71,7 +70,7 @@ namespace osu.Game.Rulesets.Edit
|
||||
{
|
||||
try
|
||||
{
|
||||
drawableRulesetWrapper = new DrawableEditRulesetWrapper<TObject>(CreateDrawableRuleset(Ruleset, workingBeatmap, Array.Empty<Mod>()))
|
||||
drawableRulesetWrapper = new DrawableEditRulesetWrapper<TObject>(CreateDrawableRuleset(Ruleset, playableBeatmap))
|
||||
{
|
||||
Clock = framedClock,
|
||||
ProcessCustomClock = false
|
||||
@ -145,8 +144,7 @@ namespace osu.Game.Rulesets.Edit
|
||||
{
|
||||
var parentWorkingBeatmap = parent.Get<IBindable<WorkingBeatmap>>().Value;
|
||||
|
||||
playableBeatmap = (Beatmap<TObject>)parentWorkingBeatmap.GetPlayableBeatmap(Ruleset.RulesetInfo, Array.Empty<Mod>());
|
||||
workingBeatmap = new EditorWorkingBeatmap<TObject>(playableBeatmap, parentWorkingBeatmap);
|
||||
playableBeatmap = (Beatmap<TObject>)parentWorkingBeatmap.GetPlayableBeatmap(Ruleset.RulesetInfo);
|
||||
|
||||
beatmapProcessor = Ruleset.CreateBeatmapProcessor(playableBeatmap);
|
||||
|
||||
@ -250,7 +248,7 @@ namespace osu.Game.Rulesets.Edit
|
||||
|
||||
protected abstract IReadOnlyList<HitObjectCompositionTool> CompositionTools { get; }
|
||||
|
||||
protected abstract DrawableRuleset<TObject> CreateDrawableRuleset(Ruleset ruleset, IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods);
|
||||
protected abstract DrawableRuleset<TObject> CreateDrawableRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null);
|
||||
|
||||
public void BeginPlacement(HitObject hitObject)
|
||||
{
|
||||
|
@ -1,15 +1,15 @@
|
||||
// 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.Timing;
|
||||
using osu.Framework.Audio.Track;
|
||||
|
||||
namespace osu.Game.Rulesets.Mods
|
||||
{
|
||||
/// <summary>
|
||||
/// An interface for mods that make adjustments to the track.
|
||||
/// </summary>
|
||||
public interface IApplicableToClock : IApplicableMod
|
||||
public interface IApplicableToTrack : IApplicableMod
|
||||
{
|
||||
void ApplyToClock(IAdjustableClock clock);
|
||||
void ApplyToTrack(Track track);
|
||||
}
|
||||
}
|
@ -69,7 +69,7 @@ namespace osu.Game.Rulesets.Mods
|
||||
/// <summary>
|
||||
/// Creates a copy of this <see cref="Mod"/> initialised to a default state.
|
||||
/// </summary>
|
||||
public virtual Mod CreateCopy() => (Mod)Activator.CreateInstance(GetType());
|
||||
public virtual Mod CreateCopy() => (Mod)MemberwiseClone();
|
||||
|
||||
public bool Equals(IMod other) => GetType() == other?.GetType();
|
||||
}
|
||||
|
@ -1,9 +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 osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Timing;
|
||||
|
||||
namespace osu.Game.Rulesets.Mods
|
||||
{
|
||||
@ -14,12 +13,9 @@ namespace osu.Game.Rulesets.Mods
|
||||
public override IconUsage Icon => FontAwesome.Solid.Question;
|
||||
public override string Description => "Whoaaaaa...";
|
||||
|
||||
public override void ApplyToClock(IAdjustableClock clock)
|
||||
public override void ApplyToTrack(Track track)
|
||||
{
|
||||
if (clock is IHasPitchAdjust pitchAdjust)
|
||||
pitchAdjust.PitchAdjust *= RateAdjust;
|
||||
else
|
||||
base.ApplyToClock(clock);
|
||||
track.Frequency.Value *= RateAdjust;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ using osu.Game.Graphics;
|
||||
|
||||
namespace osu.Game.Rulesets.Mods
|
||||
{
|
||||
public abstract class ModDoubleTime : ModTimeAdjust, IApplicableToClock
|
||||
public abstract class ModDoubleTime : ModTimeAdjust
|
||||
{
|
||||
public override string Name => "Double Time";
|
||||
public override string Acronym => "DT";
|
||||
|
@ -8,7 +8,7 @@ using osu.Game.Graphics;
|
||||
|
||||
namespace osu.Game.Rulesets.Mods
|
||||
{
|
||||
public abstract class ModHalfTime : ModTimeAdjust, IApplicableToClock
|
||||
public abstract class ModHalfTime : ModTimeAdjust
|
||||
{
|
||||
public override string Name => "Half Time";
|
||||
public override string Acronym => "HT";
|
||||
|
@ -1,9 +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 osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Graphics;
|
||||
|
||||
namespace osu.Game.Rulesets.Mods
|
||||
@ -15,12 +14,9 @@ namespace osu.Game.Rulesets.Mods
|
||||
public override IconUsage Icon => OsuIcon.ModNightcore;
|
||||
public override string Description => "Uguuuuuuuu...";
|
||||
|
||||
public override void ApplyToClock(IAdjustableClock clock)
|
||||
public override void ApplyToTrack(Track track)
|
||||
{
|
||||
if (clock is IHasPitchAdjust pitchAdjust)
|
||||
pitchAdjust.PitchAdjust *= RateAdjust;
|
||||
else
|
||||
base.ApplyToClock(clock);
|
||||
track.Frequency.Value *= RateAdjust;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,23 +2,19 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Framework.Audio.Track;
|
||||
|
||||
namespace osu.Game.Rulesets.Mods
|
||||
{
|
||||
public abstract class ModTimeAdjust : Mod
|
||||
public abstract class ModTimeAdjust : Mod, IApplicableToTrack
|
||||
{
|
||||
public override Type[] IncompatibleMods => new[] { typeof(ModTimeRamp) };
|
||||
|
||||
protected abstract double RateAdjust { get; }
|
||||
|
||||
public virtual void ApplyToClock(IAdjustableClock clock)
|
||||
public virtual void ApplyToTrack(Track track)
|
||||
{
|
||||
if (clock is IHasTempoAdjust tempo)
|
||||
tempo.TempoAdjust *= RateAdjust;
|
||||
else
|
||||
clock.Rate *= RateAdjust;
|
||||
track.Tempo.Value *= RateAdjust;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,15 +3,14 @@
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
|
||||
namespace osu.Game.Rulesets.Mods
|
||||
{
|
||||
public abstract class ModTimeRamp : Mod, IUpdatableByPlayfield, IApplicableToClock, IApplicableToBeatmap
|
||||
public abstract class ModTimeRamp : Mod, IUpdatableByPlayfield, IApplicableToTrack, IApplicableToBeatmap
|
||||
{
|
||||
/// <summary>
|
||||
/// The point in the beatmap at which the final ramping rate should be reached.
|
||||
@ -24,11 +23,11 @@ namespace osu.Game.Rulesets.Mods
|
||||
|
||||
private double finalRateTime;
|
||||
private double beginRampTime;
|
||||
private IAdjustableClock clock;
|
||||
private Track track;
|
||||
|
||||
public virtual void ApplyToClock(IAdjustableClock clock)
|
||||
public virtual void ApplyToTrack(Track track)
|
||||
{
|
||||
this.clock = clock;
|
||||
this.track = track;
|
||||
|
||||
lastAdjust = 1;
|
||||
|
||||
@ -46,7 +45,7 @@ namespace osu.Game.Rulesets.Mods
|
||||
|
||||
public virtual void Update(Playfield playfield)
|
||||
{
|
||||
applyAdjustment((clock.CurrentTime - beginRampTime) / finalRateTime);
|
||||
applyAdjustment((track.CurrentTime - beginRampTime) / finalRateTime);
|
||||
}
|
||||
|
||||
private double lastAdjust = 1;
|
||||
@ -59,23 +58,8 @@ namespace osu.Game.Rulesets.Mods
|
||||
{
|
||||
double adjust = 1 + (Math.Sign(FinalRateAdjustment) * Math.Clamp(amount, 0, 1) * Math.Abs(FinalRateAdjustment));
|
||||
|
||||
switch (clock)
|
||||
{
|
||||
case IHasPitchAdjust pitch:
|
||||
pitch.PitchAdjust /= lastAdjust;
|
||||
pitch.PitchAdjust *= adjust;
|
||||
break;
|
||||
|
||||
case IHasTempoAdjust tempo:
|
||||
tempo.TempoAdjust /= lastAdjust;
|
||||
tempo.TempoAdjust *= adjust;
|
||||
break;
|
||||
|
||||
default:
|
||||
clock.Rate /= lastAdjust;
|
||||
clock.Rate *= adjust;
|
||||
break;
|
||||
}
|
||||
track.Tempo.Value /= lastAdjust;
|
||||
track.Tempo.Value *= adjust;
|
||||
|
||||
lastAdjust = adjust;
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ namespace osu.Game.Rulesets
|
||||
/// <param name="mods">The <see cref="Mod"/>s to apply.</param>
|
||||
/// <exception cref="BeatmapInvalidForRulesetException">Unable to successfully load the beatmap to be usable with this ruleset.</exception>
|
||||
/// <returns></returns>
|
||||
public abstract DrawableRuleset CreateDrawableRulesetWith(IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods);
|
||||
public abstract DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList<Mod> mods = null);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="IBeatmapConverter"/> to convert a <see cref="IBeatmap"/> to one that is applicable for this <see cref="Ruleset"/>.
|
||||
|
@ -13,13 +13,16 @@ using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Scoring;
|
||||
|
||||
namespace osu.Game.Rulesets.Scoring
|
||||
{
|
||||
public abstract class ScoreProcessor
|
||||
public class ScoreProcessor
|
||||
{
|
||||
private const double base_portion = 0.3;
|
||||
private const double combo_portion = 0.7;
|
||||
private const double max_score = 1000000;
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when the <see cref="ScoreProcessor"/> is in a failed state.
|
||||
/// This may occur regardless of whether an <see cref="AllJudged"/> event is invoked.
|
||||
@ -67,11 +70,6 @@ namespace osu.Game.Rulesets.Scoring
|
||||
/// </summary>
|
||||
public readonly Bindable<IReadOnlyList<Mod>> Mods = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());
|
||||
|
||||
/// <summary>
|
||||
/// Create a <see cref="HitWindows"/> for this processor.
|
||||
/// </summary>
|
||||
public virtual HitWindows CreateHitWindows() => new HitWindows();
|
||||
|
||||
/// <summary>
|
||||
/// The current rank.
|
||||
/// </summary>
|
||||
@ -90,132 +88,23 @@ namespace osu.Game.Rulesets.Scoring
|
||||
/// <summary>
|
||||
/// Whether all <see cref="Judgement"/>s have been processed.
|
||||
/// </summary>
|
||||
public virtual bool HasCompleted => false;
|
||||
|
||||
/// <summary>
|
||||
/// The total number of judged <see cref="HitObject"/>s at the current point in time.
|
||||
/// </summary>
|
||||
public int JudgedHits { get; protected set; }
|
||||
public bool HasCompleted => JudgedHits == MaxHits;
|
||||
|
||||
/// <summary>
|
||||
/// Whether this ScoreProcessor has already triggered the failed state.
|
||||
/// </summary>
|
||||
public virtual bool HasFailed { get; private set; }
|
||||
public bool HasFailed { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The default conditions for failing.
|
||||
/// The maximum number of hits that can be judged.
|
||||
/// </summary>
|
||||
protected virtual bool DefaultFailCondition => Precision.AlmostBigger(Health.MinValue, Health.Value);
|
||||
|
||||
protected ScoreProcessor()
|
||||
{
|
||||
Combo.ValueChanged += delegate { HighestCombo.Value = Math.Max(HighestCombo.Value, Combo.Value); };
|
||||
Accuracy.ValueChanged += delegate
|
||||
{
|
||||
Rank.Value = rankFrom(Accuracy.Value);
|
||||
foreach (var mod in Mods.Value.OfType<IApplicableToScoreProcessor>())
|
||||
Rank.Value = mod.AdjustRank(Rank.Value, Accuracy.Value);
|
||||
};
|
||||
}
|
||||
|
||||
private ScoreRank rankFrom(double acc)
|
||||
{
|
||||
if (acc == 1)
|
||||
return ScoreRank.X;
|
||||
if (acc > 0.95)
|
||||
return ScoreRank.S;
|
||||
if (acc > 0.9)
|
||||
return ScoreRank.A;
|
||||
if (acc > 0.8)
|
||||
return ScoreRank.B;
|
||||
if (acc > 0.7)
|
||||
return ScoreRank.C;
|
||||
|
||||
return ScoreRank.D;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets this ScoreProcessor to a default state.
|
||||
/// </summary>
|
||||
/// <param name="storeResults">Whether to store the current state of the <see cref="ScoreProcessor"/> for future use.</param>
|
||||
protected virtual void Reset(bool storeResults)
|
||||
{
|
||||
TotalScore.Value = 0;
|
||||
Accuracy.Value = 1;
|
||||
Health.Value = 1;
|
||||
Combo.Value = 0;
|
||||
Rank.Value = ScoreRank.X;
|
||||
HighestCombo.Value = 0;
|
||||
|
||||
JudgedHits = 0;
|
||||
|
||||
HasFailed = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the score is in a failed state and notifies subscribers.
|
||||
/// <para>
|
||||
/// This can only ever notify subscribers once.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
protected void UpdateFailed(JudgementResult result)
|
||||
{
|
||||
if (HasFailed)
|
||||
return;
|
||||
|
||||
if (!DefaultFailCondition && FailConditions?.Invoke(this, result) != true)
|
||||
return;
|
||||
|
||||
if (Failed?.Invoke() != false)
|
||||
HasFailed = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Notifies subscribers of <see cref="NewJudgement"/> that a new judgement has occurred.
|
||||
/// </summary>
|
||||
/// <param name="result">The judgement scoring result to notify subscribers of.</param>
|
||||
protected void NotifyNewJudgement(JudgementResult result)
|
||||
{
|
||||
NewJudgement?.Invoke(result);
|
||||
|
||||
if (HasCompleted)
|
||||
AllJudged?.Invoke();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve a score populated with data for the current play this processor is responsible for.
|
||||
/// </summary>
|
||||
public virtual void PopulateScore(ScoreInfo score)
|
||||
{
|
||||
score.TotalScore = (long)Math.Round(TotalScore.Value);
|
||||
score.Combo = Combo.Value;
|
||||
score.MaxCombo = HighestCombo.Value;
|
||||
score.Accuracy = Math.Round(Accuracy.Value, 4);
|
||||
score.Rank = Rank.Value;
|
||||
score.Date = DateTimeOffset.Now;
|
||||
|
||||
var hitWindows = CreateHitWindows();
|
||||
|
||||
foreach (var result in Enum.GetValues(typeof(HitResult)).OfType<HitResult>().Where(r => r > HitResult.None && hitWindows.IsHitResultAllowed(r)))
|
||||
score.Statistics[result] = GetStatistic(result);
|
||||
}
|
||||
|
||||
public abstract int GetStatistic(HitResult result);
|
||||
|
||||
public abstract double GetStandardisedScore();
|
||||
}
|
||||
|
||||
public class ScoreProcessor<TObject> : ScoreProcessor
|
||||
where TObject : HitObject
|
||||
{
|
||||
private const double base_portion = 0.3;
|
||||
private const double combo_portion = 0.7;
|
||||
private const double max_score = 1000000;
|
||||
|
||||
public sealed override bool HasCompleted => JudgedHits == MaxHits;
|
||||
|
||||
protected int MaxHits { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The total number of judged <see cref="HitObject"/>s at the current point in time.
|
||||
/// </summary>
|
||||
public int JudgedHits { get; private set; }
|
||||
|
||||
private double maxHighestCombo;
|
||||
|
||||
private double maxBaseScore;
|
||||
@ -225,17 +114,22 @@ namespace osu.Game.Rulesets.Scoring
|
||||
|
||||
private double scoreMultiplier = 1;
|
||||
|
||||
public ScoreProcessor(DrawableRuleset<TObject> drawableRuleset)
|
||||
public ScoreProcessor(IBeatmap beatmap)
|
||||
{
|
||||
Debug.Assert(base_portion + combo_portion == 1.0);
|
||||
|
||||
drawableRuleset.OnNewResult += applyResult;
|
||||
drawableRuleset.OnRevertResult += revertResult;
|
||||
Combo.ValueChanged += combo => HighestCombo.Value = Math.Max(HighestCombo.Value, combo.NewValue);
|
||||
Accuracy.ValueChanged += accuracy =>
|
||||
{
|
||||
Rank.Value = rankFrom(accuracy.NewValue);
|
||||
foreach (var mod in Mods.Value.OfType<IApplicableToScoreProcessor>())
|
||||
Rank.Value = mod.AdjustRank(Rank.Value, accuracy.NewValue);
|
||||
};
|
||||
|
||||
ApplyBeatmap(drawableRuleset.Beatmap);
|
||||
ApplyBeatmap(beatmap);
|
||||
|
||||
Reset(false);
|
||||
SimulateAutoplay(drawableRuleset.Beatmap);
|
||||
SimulateAutoplay(beatmap);
|
||||
Reset(true);
|
||||
|
||||
if (maxBaseScore == 0 || maxHighestCombo == 0)
|
||||
@ -257,19 +151,19 @@ namespace osu.Game.Rulesets.Scoring
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Applies any properties of the <see cref="Beatmap{TObject}"/> which affect scoring to this <see cref="ScoreProcessor{TObject}"/>.
|
||||
/// Applies any properties of the <see cref="IBeatmap"/> which affect scoring to this <see cref="ScoreProcessor"/>.
|
||||
/// </summary>
|
||||
/// <param name="beatmap">The <see cref="Beatmap{TObject}"/> to read properties from.</param>
|
||||
protected virtual void ApplyBeatmap(Beatmap<TObject> beatmap)
|
||||
/// <param name="beatmap">The <see cref="IBeatmap"/> to read properties from.</param>
|
||||
protected virtual void ApplyBeatmap(IBeatmap beatmap)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Simulates an autoplay of the <see cref="Beatmap{TObject}"/> to determine scoring values.
|
||||
/// Simulates an autoplay of the <see cref="IBeatmap"/> to determine scoring values.
|
||||
/// </summary>
|
||||
/// <remarks>This provided temporarily. DO NOT USE.</remarks>
|
||||
/// <param name="beatmap">The <see cref="Beatmap{TObject}"/> to simulate.</param>
|
||||
protected virtual void SimulateAutoplay(Beatmap<TObject> beatmap)
|
||||
/// <param name="beatmap">The <see cref="IBeatmap"/> to simulate.</param>
|
||||
protected virtual void SimulateAutoplay(IBeatmap beatmap)
|
||||
{
|
||||
foreach (var obj in beatmap.HitObjects)
|
||||
simulate(obj);
|
||||
@ -289,7 +183,7 @@ namespace osu.Game.Rulesets.Scoring
|
||||
|
||||
result.Type = judgement.MaxResult;
|
||||
|
||||
applyResult(result);
|
||||
ApplyResult(result);
|
||||
}
|
||||
}
|
||||
|
||||
@ -297,22 +191,26 @@ namespace osu.Game.Rulesets.Scoring
|
||||
/// Applies the score change of a <see cref="JudgementResult"/> to this <see cref="ScoreProcessor"/>.
|
||||
/// </summary>
|
||||
/// <param name="result">The <see cref="JudgementResult"/> to apply.</param>
|
||||
private void applyResult(JudgementResult result)
|
||||
public void ApplyResult(JudgementResult result)
|
||||
{
|
||||
ApplyResult(result);
|
||||
updateScore();
|
||||
ApplyResultInternal(result);
|
||||
|
||||
UpdateFailed(result);
|
||||
NotifyNewJudgement(result);
|
||||
updateScore();
|
||||
updateFailed(result);
|
||||
|
||||
NewJudgement?.Invoke(result);
|
||||
|
||||
if (HasCompleted)
|
||||
AllJudged?.Invoke();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reverts the score change of a <see cref="JudgementResult"/> that was applied to this <see cref="ScoreProcessor"/>.
|
||||
/// </summary>
|
||||
/// <param name="result">The judgement scoring result.</param>
|
||||
private void revertResult(JudgementResult result)
|
||||
public void RevertResult(JudgementResult result)
|
||||
{
|
||||
RevertResult(result);
|
||||
RevertResultInternal(result);
|
||||
updateScore();
|
||||
}
|
||||
|
||||
@ -322,10 +220,10 @@ namespace osu.Game.Rulesets.Scoring
|
||||
/// Applies the score change of a <see cref="JudgementResult"/> to this <see cref="ScoreProcessor"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Any changes applied via this method can be reverted via <see cref="RevertResult"/>.
|
||||
/// Any changes applied via this method can be reverted via <see cref="RevertResultInternal"/>.
|
||||
/// </remarks>
|
||||
/// <param name="result">The <see cref="JudgementResult"/> to apply.</param>
|
||||
protected virtual void ApplyResult(JudgementResult result)
|
||||
protected virtual void ApplyResultInternal(JudgementResult result)
|
||||
{
|
||||
result.ComboAtJudgement = Combo.Value;
|
||||
result.HighestComboAtJudgement = HighestCombo.Value;
|
||||
@ -372,10 +270,10 @@ namespace osu.Game.Rulesets.Scoring
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reverts the score change of a <see cref="JudgementResult"/> that was applied to this <see cref="ScoreProcessor"/> via <see cref="ApplyResult"/>.
|
||||
/// Reverts the score change of a <see cref="JudgementResult"/> that was applied to this <see cref="ScoreProcessor"/> via <see cref="ApplyResultInternal"/>.
|
||||
/// </summary>
|
||||
/// <param name="result">The judgement scoring result.</param>
|
||||
protected virtual void RevertResult(JudgementResult result)
|
||||
protected virtual void RevertResultInternal(JudgementResult result)
|
||||
{
|
||||
Combo.Value = result.ComboAtJudgement;
|
||||
HighestCombo.Value = result.HighestComboAtJudgement;
|
||||
@ -432,11 +330,49 @@ namespace osu.Game.Rulesets.Scoring
|
||||
}
|
||||
}
|
||||
|
||||
public override int GetStatistic(HitResult result) => scoreResultCounts.GetOrDefault(result);
|
||||
/// <summary>
|
||||
/// Checks if the score is in a failed state and notifies subscribers.
|
||||
/// <para>
|
||||
/// This can only ever notify subscribers once.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
private void updateFailed(JudgementResult result)
|
||||
{
|
||||
if (HasFailed)
|
||||
return;
|
||||
|
||||
public override double GetStandardisedScore() => getScore(ScoringMode.Standardised);
|
||||
if (!DefaultFailCondition && FailConditions?.Invoke(this, result) != true)
|
||||
return;
|
||||
|
||||
protected override void Reset(bool storeResults)
|
||||
if (Failed?.Invoke() != false)
|
||||
HasFailed = true;
|
||||
}
|
||||
|
||||
private ScoreRank rankFrom(double acc)
|
||||
{
|
||||
if (acc == 1)
|
||||
return ScoreRank.X;
|
||||
if (acc > 0.95)
|
||||
return ScoreRank.S;
|
||||
if (acc > 0.9)
|
||||
return ScoreRank.A;
|
||||
if (acc > 0.8)
|
||||
return ScoreRank.B;
|
||||
if (acc > 0.7)
|
||||
return ScoreRank.C;
|
||||
|
||||
return ScoreRank.D;
|
||||
}
|
||||
|
||||
public int GetStatistic(HitResult result) => scoreResultCounts.GetOrDefault(result);
|
||||
|
||||
public double GetStandardisedScore() => getScore(ScoringMode.Standardised);
|
||||
|
||||
/// <summary>
|
||||
/// Resets this ScoreProcessor to a default state.
|
||||
/// </summary>
|
||||
/// <param name="storeResults">Whether to store the current state of the <see cref="ScoreProcessor"/> for future use.</param>
|
||||
protected virtual void Reset(bool storeResults)
|
||||
{
|
||||
scoreResultCounts.Clear();
|
||||
|
||||
@ -447,13 +383,49 @@ namespace osu.Game.Rulesets.Scoring
|
||||
maxBaseScore = baseScore;
|
||||
}
|
||||
|
||||
base.Reset(storeResults);
|
||||
|
||||
JudgedHits = 0;
|
||||
baseScore = 0;
|
||||
rollingMaxBaseScore = 0;
|
||||
bonusScore = 0;
|
||||
|
||||
TotalScore.Value = 0;
|
||||
Accuracy.Value = 1;
|
||||
Health.Value = 1;
|
||||
Combo.Value = 0;
|
||||
Rank.Value = ScoreRank.X;
|
||||
HighestCombo.Value = 0;
|
||||
|
||||
HasFailed = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve a score populated with data for the current play this processor is responsible for.
|
||||
/// </summary>
|
||||
public virtual void PopulateScore(ScoreInfo score)
|
||||
{
|
||||
score.TotalScore = (long)Math.Round(TotalScore.Value);
|
||||
score.Combo = Combo.Value;
|
||||
score.MaxCombo = HighestCombo.Value;
|
||||
score.Accuracy = Math.Round(Accuracy.Value, 4);
|
||||
score.Rank = Rank.Value;
|
||||
score.Date = DateTimeOffset.Now;
|
||||
|
||||
var hitWindows = CreateHitWindows();
|
||||
|
||||
foreach (var result in Enum.GetValues(typeof(HitResult)).OfType<HitResult>().Where(r => r > HitResult.None && hitWindows.IsHitResultAllowed(r)))
|
||||
score.Statistics[result] = GetStatistic(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The default conditions for failing.
|
||||
/// </summary>
|
||||
protected virtual bool DefaultFailCondition => Precision.AlmostBigger(Health.MinValue, Health.Value);
|
||||
|
||||
/// <summary>
|
||||
/// Create a <see cref="HitWindows"/> for this processor.
|
||||
/// </summary>
|
||||
public virtual HitWindows CreateHitWindows() => new HitWindows();
|
||||
|
||||
/// <summary>
|
||||
/// Creates the <see cref="JudgementResult"/> that represents the scoring result for a <see cref="HitObject"/>.
|
||||
/// </summary>
|
||||
|
@ -45,6 +45,10 @@ namespace osu.Game.Rulesets.UI
|
||||
public abstract class DrawableRuleset<TObject> : DrawableRuleset, IProvideCursor, ICanAttachKeyCounter
|
||||
where TObject : HitObject
|
||||
{
|
||||
public override event Action<JudgementResult> OnNewResult;
|
||||
|
||||
public override event Action<JudgementResult> OnRevertResult;
|
||||
|
||||
/// <summary>
|
||||
/// The selected variant.
|
||||
/// </summary>
|
||||
@ -91,20 +95,10 @@ namespace osu.Game.Rulesets.UI
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when a <see cref="JudgementResult"/> has been applied by a <see cref="DrawableHitObject"/>.
|
||||
/// </summary>
|
||||
public event Action<JudgementResult> OnNewResult;
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when a <see cref="JudgementResult"/> is being reverted by a <see cref="DrawableHitObject"/>.
|
||||
/// </summary>
|
||||
public event Action<JudgementResult> OnRevertResult;
|
||||
|
||||
/// <summary>
|
||||
/// The beatmap.
|
||||
/// </summary>
|
||||
public Beatmap<TObject> Beatmap;
|
||||
public readonly Beatmap<TObject> Beatmap;
|
||||
|
||||
public override IEnumerable<HitObject> Objects => Beatmap.HitObjects;
|
||||
|
||||
@ -124,20 +118,22 @@ namespace osu.Game.Rulesets.UI
|
||||
/// Creates a ruleset visualisation for the provided ruleset and beatmap.
|
||||
/// </summary>
|
||||
/// <param name="ruleset">The ruleset being represented.</param>
|
||||
/// <param name="workingBeatmap">The beatmap to create the hit renderer for.</param>
|
||||
/// <param name="beatmap">The beatmap to create the hit renderer for.</param>
|
||||
/// <param name="mods">The <see cref="Mod"/>s to apply.</param>
|
||||
protected DrawableRuleset(Ruleset ruleset, IWorkingBeatmap workingBeatmap, IReadOnlyList<Mod> mods)
|
||||
protected DrawableRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
|
||||
: base(ruleset)
|
||||
{
|
||||
if (workingBeatmap == null)
|
||||
throw new ArgumentException("Beatmap cannot be null.", nameof(workingBeatmap));
|
||||
if (beatmap == null)
|
||||
throw new ArgumentNullException(nameof(beatmap), "Beatmap cannot be null.");
|
||||
|
||||
this.mods = mods.ToArray();
|
||||
if (!(beatmap is Beatmap<TObject> tBeatmap))
|
||||
throw new ArgumentException($"{GetType()} expected the beatmap to contain hitobjects of type {typeof(TObject)}.", nameof(beatmap));
|
||||
|
||||
Beatmap = tBeatmap;
|
||||
this.mods = mods?.ToArray() ?? Array.Empty<Mod>();
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
Beatmap = (Beatmap<TObject>)workingBeatmap.GetPlayableBeatmap(ruleset.RulesetInfo, mods);
|
||||
|
||||
KeyBindingInputManager = CreateInputManager();
|
||||
playfield = new Lazy<Playfield>(CreatePlayfield);
|
||||
|
||||
@ -309,7 +305,7 @@ namespace osu.Game.Rulesets.UI
|
||||
/// <returns>The Playfield.</returns>
|
||||
protected abstract Playfield CreatePlayfield();
|
||||
|
||||
public override ScoreProcessor CreateScoreProcessor() => new ScoreProcessor<TObject>(this);
|
||||
public override ScoreProcessor CreateScoreProcessor() => new ScoreProcessor(Beatmap);
|
||||
|
||||
/// <summary>
|
||||
/// Applies the active mods to this DrawableRuleset.
|
||||
@ -366,6 +362,16 @@ namespace osu.Game.Rulesets.UI
|
||||
/// </summary>
|
||||
public abstract class DrawableRuleset : CompositeDrawable
|
||||
{
|
||||
/// <summary>
|
||||
/// Invoked when a <see cref="JudgementResult"/> has been applied by a <see cref="DrawableHitObject"/>.
|
||||
/// </summary>
|
||||
public abstract event Action<JudgementResult> OnNewResult;
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when a <see cref="JudgementResult"/> is being reverted by a <see cref="DrawableHitObject"/>.
|
||||
/// </summary>
|
||||
public abstract event Action<JudgementResult> OnRevertResult;
|
||||
|
||||
/// <summary>
|
||||
/// Whether a replay is currently loaded.
|
||||
/// </summary>
|
||||
@ -511,15 +517,19 @@ namespace osu.Game.Rulesets.UI
|
||||
|
||||
public IEnumerable<string> GetAvailableResources() => throw new NotImplementedException();
|
||||
|
||||
public void AddAdjustment(AdjustableProperty type, BindableDouble adjustBindable) => throw new NotImplementedException();
|
||||
public void AddAdjustment(AdjustableProperty type, BindableNumber<double> adjustBindable) => throw new NotImplementedException();
|
||||
|
||||
public void RemoveAdjustment(AdjustableProperty type, BindableDouble adjustBindable) => throw new NotImplementedException();
|
||||
public void RemoveAdjustment(AdjustableProperty type, BindableNumber<double> adjustBindable) => throw new NotImplementedException();
|
||||
|
||||
public BindableDouble Volume => throw new NotImplementedException();
|
||||
public BindableNumber<double> Volume => throw new NotImplementedException();
|
||||
|
||||
public BindableDouble Balance => throw new NotImplementedException();
|
||||
public BindableNumber<double> Balance => throw new NotImplementedException();
|
||||
|
||||
public BindableDouble Frequency => throw new NotImplementedException();
|
||||
public BindableNumber<double> Frequency => throw new NotImplementedException();
|
||||
|
||||
public BindableNumber<double> Tempo => throw new NotImplementedException();
|
||||
|
||||
public IBindable<double> GetAggregate(AdjustableProperty type) => throw new NotImplementedException();
|
||||
|
||||
public IBindable<double> AggregateVolume => throw new NotImplementedException();
|
||||
|
||||
@ -527,6 +537,8 @@ namespace osu.Game.Rulesets.UI
|
||||
|
||||
public IBindable<double> AggregateFrequency => throw new NotImplementedException();
|
||||
|
||||
public IBindable<double> AggregateTempo => throw new NotImplementedException();
|
||||
|
||||
public int PlaybackConcurrency
|
||||
{
|
||||
get => throw new NotImplementedException();
|
||||
|
@ -85,7 +85,7 @@ namespace osu.Game.Rulesets.UI.Scrolling
|
||||
[Cached(Type = typeof(IScrollingInfo))]
|
||||
private readonly LocalScrollingInfo scrollingInfo;
|
||||
|
||||
protected DrawableScrollingRuleset(Ruleset ruleset, IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
||||
protected DrawableScrollingRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
|
||||
: base(ruleset, beatmap, mods)
|
||||
{
|
||||
scrollingInfo = new LocalScrollingInfo();
|
||||
|
@ -38,6 +38,8 @@ namespace osu.Game.Screens.Backgrounds
|
||||
/// </summary>
|
||||
public readonly Bindable<float> BlurAmount = new Bindable<float>();
|
||||
|
||||
internal readonly IBindable<bool> IsBreakTime = new Bindable<bool>();
|
||||
|
||||
private readonly DimmableBackground dimmable;
|
||||
|
||||
protected virtual DimmableBackground CreateFadeContainer() => new DimmableBackground { RelativeSizeAxes = Axes.Both };
|
||||
@ -48,6 +50,7 @@ namespace osu.Game.Screens.Backgrounds
|
||||
|
||||
InternalChild = dimmable = CreateFadeContainer();
|
||||
dimmable.EnableUserDim.BindTo(EnableUserDim);
|
||||
dimmable.IsBreakTime.BindTo(IsBreakTime);
|
||||
dimmable.BlurAmount.BindTo(BlurAmount);
|
||||
}
|
||||
|
||||
|
@ -5,19 +5,18 @@ using System;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Compose.Components
|
||||
{
|
||||
public abstract class CircularDistanceSnapGrid : DistanceSnapGrid
|
||||
{
|
||||
protected CircularDistanceSnapGrid(HitObject hitObject, HitObject nextHitObject, Vector2 centrePosition)
|
||||
: base(hitObject, nextHitObject, centrePosition)
|
||||
protected CircularDistanceSnapGrid(Vector2 startPosition, double startTime, double? endTime = null)
|
||||
: base(startPosition, startTime, endTime)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void CreateContent(Vector2 centrePosition)
|
||||
protected override void CreateContent(Vector2 startPosition)
|
||||
{
|
||||
const float crosshair_thickness = 1;
|
||||
const float crosshair_max_size = 10;
|
||||
@ -27,7 +26,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
new Box
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Position = centrePosition,
|
||||
Position = startPosition,
|
||||
Width = crosshair_thickness,
|
||||
EdgeSmoothness = new Vector2(1),
|
||||
Height = Math.Min(crosshair_max_size, DistanceSpacing * 2),
|
||||
@ -35,15 +34,15 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
new Box
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Position = centrePosition,
|
||||
Position = startPosition,
|
||||
EdgeSmoothness = new Vector2(1),
|
||||
Width = Math.Min(crosshair_max_size, DistanceSpacing * 2),
|
||||
Height = crosshair_thickness,
|
||||
}
|
||||
});
|
||||
|
||||
float dx = Math.Max(centrePosition.X, DrawWidth - centrePosition.X);
|
||||
float dy = Math.Max(centrePosition.Y, DrawHeight - centrePosition.Y);
|
||||
float dx = Math.Max(startPosition.X, DrawWidth - startPosition.X);
|
||||
float dy = Math.Max(startPosition.Y, DrawHeight - startPosition.Y);
|
||||
float maxDistance = new Vector2(dx, dy).Length;
|
||||
int requiredCircles = Math.Min(MaxIntervals, (int)(maxDistance / DistanceSpacing));
|
||||
|
||||
@ -54,7 +53,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
AddInternal(new CircularProgress
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Position = centrePosition,
|
||||
Position = startPosition,
|
||||
Current = { Value = 1 },
|
||||
Size = new Vector2(radius),
|
||||
InnerRadius = 4 * 1f / radius,
|
||||
@ -66,9 +65,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
public override (Vector2 position, double time) GetSnappedPosition(Vector2 position)
|
||||
{
|
||||
if (MaxIntervals == 0)
|
||||
return (CentrePosition, StartTime);
|
||||
return (StartPosition, StartTime);
|
||||
|
||||
Vector2 direction = position - CentrePosition;
|
||||
Vector2 direction = position - StartPosition;
|
||||
if (direction == Vector2.Zero)
|
||||
direction = new Vector2(0.001f, 0.001f);
|
||||
|
||||
@ -78,9 +77,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
int radialCount = Math.Clamp((int)MathF.Round(distance / radius), 1, MaxIntervals);
|
||||
|
||||
Vector2 normalisedDirection = direction * new Vector2(1f / distance);
|
||||
Vector2 snappedPosition = CentrePosition + normalisedDirection * radialCount * radius;
|
||||
Vector2 snappedPosition = StartPosition + normalisedDirection * radialCount * radius;
|
||||
|
||||
return (snappedPosition, StartTime + SnapProvider.GetSnappedDurationFromDistance(StartTime, (snappedPosition - CentrePosition).Length));
|
||||
return (snappedPosition, StartTime + SnapProvider.GetSnappedDurationFromDistance(StartTime, (snappedPosition - StartPosition).Length));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +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 JetBrains.Annotations;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Caching;
|
||||
using osu.Framework.Graphics;
|
||||
@ -9,7 +8,6 @@ using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Compose.Components
|
||||
@ -24,21 +22,21 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
/// </summary>
|
||||
protected float DistanceSpacing { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The snapping time at <see cref="CentrePosition"/>.
|
||||
/// </summary>
|
||||
protected double StartTime { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The maximum number of distance snapping intervals allowed.
|
||||
/// </summary>
|
||||
protected int MaxIntervals { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The position which the grid is centred on.
|
||||
/// The first beat snapping tick is located at <see cref="CentrePosition"/> + <see cref="DistanceSpacing"/> in the desired direction.
|
||||
/// The position which the grid should start.
|
||||
/// The first beat snapping tick is located at <see cref="StartPosition"/> + <see cref="DistanceSpacing"/> away from this point.
|
||||
/// </summary>
|
||||
protected readonly Vector2 CentrePosition;
|
||||
protected readonly Vector2 StartPosition;
|
||||
|
||||
/// <summary>
|
||||
/// The snapping time at <see cref="StartPosition"/>.
|
||||
/// </summary>
|
||||
protected readonly double StartTime;
|
||||
|
||||
[Resolved]
|
||||
protected OsuColour Colours { get; private set; }
|
||||
@ -53,25 +51,23 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
private BindableBeatDivisor beatDivisor { get; set; }
|
||||
|
||||
private readonly Cached gridCache = new Cached();
|
||||
private readonly HitObject hitObject;
|
||||
private readonly HitObject nextHitObject;
|
||||
private readonly double? endTime;
|
||||
|
||||
protected DistanceSnapGrid(HitObject hitObject, [CanBeNull] HitObject nextHitObject, Vector2 centrePosition)
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="DistanceSnapGrid"/>.
|
||||
/// </summary>
|
||||
/// <param name="startPosition">The position at which the grid should start. The first tick is located one distance spacing length away from this point.</param>
|
||||
/// <param name="startTime">The snapping time at <see cref="StartPosition"/>.</param>
|
||||
/// <param name="endTime">The time at which the snapping grid should end. If null, the grid will continue until the bounds of the screen are exceeded.</param>
|
||||
protected DistanceSnapGrid(Vector2 startPosition, double startTime, double? endTime = null)
|
||||
{
|
||||
this.hitObject = hitObject;
|
||||
this.nextHitObject = nextHitObject;
|
||||
|
||||
CentrePosition = centrePosition;
|
||||
this.endTime = endTime;
|
||||
StartPosition = startPosition;
|
||||
StartTime = startTime;
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
StartTime = hitObject.GetEndTime();
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
@ -83,12 +79,12 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
{
|
||||
DistanceSpacing = SnapProvider.GetBeatSnapDistanceAt(StartTime);
|
||||
|
||||
if (nextHitObject == null)
|
||||
if (endTime == null)
|
||||
MaxIntervals = int.MaxValue;
|
||||
else
|
||||
{
|
||||
// +1 is added since a snapped hitobject may have its start time slightly less than the snapped time due to floating point errors
|
||||
double maxDuration = nextHitObject.StartTime - StartTime + 1;
|
||||
double maxDuration = endTime.Value - StartTime + 1;
|
||||
MaxIntervals = (int)(maxDuration / SnapProvider.DistanceToDuration(StartTime, DistanceSpacing));
|
||||
}
|
||||
|
||||
@ -110,7 +106,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
if (!gridCache.IsValid)
|
||||
{
|
||||
ClearInternal();
|
||||
CreateContent(CentrePosition);
|
||||
CreateContent(StartPosition);
|
||||
gridCache.Validate();
|
||||
}
|
||||
}
|
||||
@ -118,7 +114,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
/// <summary>
|
||||
/// Creates the content which visualises the grid ticks.
|
||||
/// </summary>
|
||||
protected abstract void CreateContent(Vector2 centrePosition);
|
||||
protected abstract void CreateContent(Vector2 startPosition);
|
||||
|
||||
/// <summary>
|
||||
/// Snaps a position to this grid.
|
||||
|
@ -4,7 +4,6 @@
|
||||
using System;
|
||||
using osuTK.Graphics;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Screens.Backgrounds;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
@ -29,14 +28,13 @@ using osu.Game.Input.Bindings;
|
||||
using osu.Game.Screens.Edit.Compose;
|
||||
using osu.Game.Screens.Edit.Setup;
|
||||
using osu.Game.Screens.Edit.Timing;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Screens.Edit
|
||||
{
|
||||
public class Editor : OsuScreen, IKeyBindingHandler<GlobalAction>
|
||||
public class Editor : ScreenWithBeatmapBackground, IKeyBindingHandler<GlobalAction>
|
||||
{
|
||||
protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4");
|
||||
|
||||
public override float BackgroundParallaxAmount => 0.1f;
|
||||
|
||||
public override bool AllowBackButton => false;
|
||||
@ -250,8 +248,12 @@ namespace osu.Game.Screens.Edit
|
||||
{
|
||||
base.OnEntering(last);
|
||||
|
||||
// todo: temporary. we want to be applying dim using the UserDimContainer eventually.
|
||||
Background.FadeColour(Color4.DarkGray, 500);
|
||||
|
||||
Background.EnableUserDim.Value = false;
|
||||
Background.BlurAmount.Value = 0;
|
||||
|
||||
resetTrack(true);
|
||||
}
|
||||
|
||||
|
@ -1,49 +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 System.Collections.Generic;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Graphics.Video;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Skinning;
|
||||
using osu.Game.Storyboards;
|
||||
|
||||
namespace osu.Game.Screens.Edit
|
||||
{
|
||||
/// <summary>
|
||||
/// Encapsulates a <see cref="WorkingBeatmap"/> while providing an overridden <see cref="Beatmap{TObject}"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="TObject"></typeparam>
|
||||
public class EditorWorkingBeatmap<TObject> : IWorkingBeatmap
|
||||
where TObject : HitObject
|
||||
{
|
||||
private readonly Beatmap<TObject> playableBeatmap;
|
||||
private readonly WorkingBeatmap workingBeatmap;
|
||||
|
||||
public EditorWorkingBeatmap(Beatmap<TObject> playableBeatmap, WorkingBeatmap workingBeatmap)
|
||||
{
|
||||
this.playableBeatmap = playableBeatmap;
|
||||
this.workingBeatmap = workingBeatmap;
|
||||
}
|
||||
|
||||
public IBeatmap Beatmap => workingBeatmap.Beatmap;
|
||||
|
||||
public Texture Background => workingBeatmap.Background;
|
||||
|
||||
public VideoSprite Video => workingBeatmap.Video;
|
||||
|
||||
public Track Track => workingBeatmap.Track;
|
||||
|
||||
public Waveform Waveform => workingBeatmap.Waveform;
|
||||
|
||||
public Storyboard Storyboard => workingBeatmap.Storyboard;
|
||||
|
||||
public ISkin Skin => workingBeatmap.Skin;
|
||||
|
||||
public IBeatmap GetPlayableBeatmap(RulesetInfo ruleset, IReadOnlyList<Mod> mods) => playableBeatmap;
|
||||
}
|
||||
}
|
@ -28,9 +28,9 @@ namespace osu.Game.Screens.Play
|
||||
private readonly IReadOnlyList<Mod> mods;
|
||||
|
||||
/// <summary>
|
||||
/// The original source (usually a <see cref="WorkingBeatmap"/>'s track).
|
||||
/// The <see cref="WorkingBeatmap"/>'s track.
|
||||
/// </summary>
|
||||
private IAdjustableClock sourceClock;
|
||||
private Track track;
|
||||
|
||||
public readonly BindableBool IsPaused = new BindableBool();
|
||||
|
||||
@ -72,8 +72,8 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
sourceClock = (IAdjustableClock)beatmap.Track ?? new StopwatchClock();
|
||||
(sourceClock as IAdjustableAudioComponent)?.AddAdjustment(AdjustableProperty.Frequency, pauseFreqAdjust);
|
||||
track = beatmap.Track;
|
||||
track.AddAdjustment(AdjustableProperty.Frequency, pauseFreqAdjust);
|
||||
|
||||
adjustableClock = new DecoupleableInterpolatingFramedClock { IsCoupled = false };
|
||||
|
||||
@ -127,11 +127,11 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
sourceClock.Reset();
|
||||
track.Reset();
|
||||
|
||||
Schedule(() =>
|
||||
{
|
||||
adjustableClock.ChangeSource(sourceClock);
|
||||
adjustableClock.ChangeSource(track);
|
||||
updateRate();
|
||||
|
||||
if (!IsPaused.Value)
|
||||
@ -197,13 +197,13 @@ namespace osu.Game.Screens.Play
|
||||
/// </summary>
|
||||
public void StopUsingBeatmapClock()
|
||||
{
|
||||
if (sourceClock != beatmap.Track)
|
||||
if (track != beatmap.Track)
|
||||
return;
|
||||
|
||||
removeSourceClockAdjustments();
|
||||
|
||||
sourceClock = new TrackVirtual(beatmap.Track.Length);
|
||||
adjustableClock.ChangeSource(sourceClock);
|
||||
track = new TrackVirtual(beatmap.Track.Length);
|
||||
adjustableClock.ChangeSource(track);
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
@ -218,18 +218,15 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
private void updateRate()
|
||||
{
|
||||
if (sourceClock == null) return;
|
||||
if (track == null) return;
|
||||
|
||||
speedAdjustmentsApplied = true;
|
||||
sourceClock.ResetSpeedAdjustments();
|
||||
track.ResetSpeedAdjustments();
|
||||
|
||||
if (sourceClock is IHasTempoAdjust tempo)
|
||||
tempo.TempoAdjust = UserPlaybackRate.Value;
|
||||
else
|
||||
sourceClock.Rate = UserPlaybackRate.Value;
|
||||
track.Tempo.Value = UserPlaybackRate.Value;
|
||||
|
||||
foreach (var mod in mods.OfType<IApplicableToClock>())
|
||||
mod.ApplyToClock(sourceClock);
|
||||
foreach (var mod in mods.OfType<IApplicableToTrack>())
|
||||
mod.ApplyToTrack(track);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
@ -237,18 +234,18 @@ namespace osu.Game.Screens.Play
|
||||
base.Dispose(isDisposing);
|
||||
|
||||
removeSourceClockAdjustments();
|
||||
sourceClock = null;
|
||||
track = null;
|
||||
}
|
||||
|
||||
private void removeSourceClockAdjustments()
|
||||
{
|
||||
if (speedAdjustmentsApplied)
|
||||
{
|
||||
sourceClock.ResetSpeedAdjustments();
|
||||
track.ResetSpeedAdjustments();
|
||||
speedAdjustmentsApplied = false;
|
||||
}
|
||||
|
||||
(sourceClock as IAdjustableAudioComponent)?.RemoveAdjustment(AdjustableProperty.Frequency, pauseFreqAdjust);
|
||||
track.RemoveAdjustment(AdjustableProperty.Frequency, pauseFreqAdjust);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -188,26 +188,22 @@ namespace osu.Game.Screens.Play
|
||||
InternalButtons.Add(button);
|
||||
}
|
||||
|
||||
private int _selectionIndex = -1;
|
||||
private int selectionIndex = -1;
|
||||
|
||||
private int selectionIndex
|
||||
private void setSelected(int value)
|
||||
{
|
||||
get => _selectionIndex;
|
||||
set
|
||||
{
|
||||
if (_selectionIndex == value)
|
||||
if (selectionIndex == value)
|
||||
return;
|
||||
|
||||
// Deselect the previously-selected button
|
||||
if (_selectionIndex != -1)
|
||||
InternalButtons[_selectionIndex].Selected.Value = false;
|
||||
if (selectionIndex != -1)
|
||||
InternalButtons[selectionIndex].Selected.Value = false;
|
||||
|
||||
_selectionIndex = value;
|
||||
selectionIndex = value;
|
||||
|
||||
// Select the newly-selected button
|
||||
if (_selectionIndex != -1)
|
||||
InternalButtons[_selectionIndex].Selected.Value = true;
|
||||
}
|
||||
if (selectionIndex != -1)
|
||||
InternalButtons[selectionIndex].Selected.Value = true;
|
||||
}
|
||||
|
||||
protected override bool OnKeyDown(KeyDownEvent e)
|
||||
@ -218,16 +214,16 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
case Key.Up:
|
||||
if (selectionIndex == -1 || selectionIndex == 0)
|
||||
selectionIndex = InternalButtons.Count - 1;
|
||||
setSelected(InternalButtons.Count - 1);
|
||||
else
|
||||
selectionIndex--;
|
||||
setSelected(selectionIndex - 1);
|
||||
return true;
|
||||
|
||||
case Key.Down:
|
||||
if (selectionIndex == -1 || selectionIndex == InternalButtons.Count - 1)
|
||||
selectionIndex = 0;
|
||||
setSelected(0);
|
||||
else
|
||||
selectionIndex++;
|
||||
setSelected(selectionIndex + 1);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -266,9 +262,9 @@ namespace osu.Game.Screens.Play
|
||||
private void buttonSelectionChanged(DialogButton button, bool isSelected)
|
||||
{
|
||||
if (!isSelected)
|
||||
selectionIndex = -1;
|
||||
setSelected(-1);
|
||||
else
|
||||
selectionIndex = InternalButtons.IndexOf(button);
|
||||
setSelected(InternalButtons.IndexOf(button));
|
||||
}
|
||||
|
||||
private void updateRetryCount()
|
||||
|
@ -114,38 +114,47 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
Mods.Value = base.Mods.Value.Select(m => m.CreateCopy()).ToArray();
|
||||
|
||||
WorkingBeatmap working = loadBeatmap();
|
||||
if (Beatmap.Value is DummyWorkingBeatmap)
|
||||
return;
|
||||
|
||||
if (working == null)
|
||||
IBeatmap playableBeatmap = loadPlayableBeatmap();
|
||||
|
||||
if (playableBeatmap == null)
|
||||
return;
|
||||
|
||||
sampleRestart = audio.Samples.Get(@"Gameplay/restart");
|
||||
|
||||
mouseWheelDisabled = config.GetBindable<bool>(OsuSetting.MouseDisableWheel);
|
||||
|
||||
DrawableRuleset = ruleset.CreateDrawableRulesetWith(playableBeatmap, Mods.Value);
|
||||
|
||||
ScoreProcessor = DrawableRuleset.CreateScoreProcessor();
|
||||
ScoreProcessor.Mods.BindTo(Mods);
|
||||
|
||||
if (!ScoreProcessor.Mode.Disabled)
|
||||
config.BindWith(OsuSetting.ScoreDisplayMode, ScoreProcessor.Mode);
|
||||
|
||||
InternalChild = GameplayClockContainer = new GameplayClockContainer(working, Mods.Value, DrawableRuleset.GameplayStartTime);
|
||||
InternalChild = GameplayClockContainer = new GameplayClockContainer(Beatmap.Value, Mods.Value, DrawableRuleset.GameplayStartTime);
|
||||
|
||||
addUnderlayComponents(GameplayClockContainer);
|
||||
addGameplayComponents(GameplayClockContainer, working);
|
||||
addOverlayComponents(GameplayClockContainer, working);
|
||||
addGameplayComponents(GameplayClockContainer, Beatmap.Value);
|
||||
addOverlayComponents(GameplayClockContainer, Beatmap.Value);
|
||||
|
||||
DrawableRuleset.HasReplayLoaded.BindValueChanged(e => HUDOverlay.HoldToQuit.PauseOnFocusLost = !e.NewValue && PauseOnFocusLost, true);
|
||||
DrawableRuleset.HasReplayLoaded.BindValueChanged(_ => updatePauseOnFocusLostState(), true);
|
||||
|
||||
// bind clock into components that require it
|
||||
DrawableRuleset.IsPaused.BindTo(GameplayClockContainer.IsPaused);
|
||||
|
||||
DrawableRuleset.OnNewResult += ScoreProcessor.ApplyResult;
|
||||
DrawableRuleset.OnRevertResult += ScoreProcessor.RevertResult;
|
||||
|
||||
// Bind ScoreProcessor to ourselves
|
||||
ScoreProcessor.AllJudged += onCompletion;
|
||||
ScoreProcessor.Failed += onFail;
|
||||
|
||||
foreach (var mod in Mods.Value.OfType<IApplicableToScoreProcessor>())
|
||||
mod.ApplyToScoreProcessor(ScoreProcessor);
|
||||
breakOverlay.IsBreakTime.ValueChanged += _ => updatePauseOnFocusLostState();
|
||||
}
|
||||
|
||||
private void addUnderlayComponents(Container target)
|
||||
@ -241,36 +250,37 @@ namespace osu.Game.Screens.Play
|
||||
});
|
||||
}
|
||||
|
||||
private WorkingBeatmap loadBeatmap()
|
||||
private void updatePauseOnFocusLostState() =>
|
||||
HUDOverlay.HoldToQuit.PauseOnFocusLost = PauseOnFocusLost
|
||||
&& !DrawableRuleset.HasReplayLoaded.Value
|
||||
&& !breakOverlay.IsBreakTime.Value;
|
||||
|
||||
private IBeatmap loadPlayableBeatmap()
|
||||
{
|
||||
WorkingBeatmap working = Beatmap.Value;
|
||||
if (working is DummyWorkingBeatmap)
|
||||
return null;
|
||||
IBeatmap playable;
|
||||
|
||||
try
|
||||
{
|
||||
var beatmap = working.Beatmap;
|
||||
|
||||
if (beatmap == null)
|
||||
if (Beatmap.Value.Beatmap == null)
|
||||
throw new InvalidOperationException("Beatmap was not loaded");
|
||||
|
||||
rulesetInfo = Ruleset.Value ?? beatmap.BeatmapInfo.Ruleset;
|
||||
rulesetInfo = Ruleset.Value ?? Beatmap.Value.BeatmapInfo.Ruleset;
|
||||
ruleset = rulesetInfo.CreateInstance();
|
||||
|
||||
try
|
||||
{
|
||||
DrawableRuleset = ruleset.CreateDrawableRulesetWith(working, Mods.Value);
|
||||
playable = Beatmap.Value.GetPlayableBeatmap(ruleset.RulesetInfo, Mods.Value);
|
||||
}
|
||||
catch (BeatmapInvalidForRulesetException)
|
||||
{
|
||||
// we may fail to create a DrawableRuleset if the beatmap cannot be loaded with the user's preferred ruleset
|
||||
// let's try again forcing the beatmap's ruleset.
|
||||
rulesetInfo = beatmap.BeatmapInfo.Ruleset;
|
||||
// A playable beatmap may not be creatable with the user's preferred ruleset, so try using the beatmap's default ruleset
|
||||
rulesetInfo = Beatmap.Value.BeatmapInfo.Ruleset;
|
||||
ruleset = rulesetInfo.CreateInstance();
|
||||
DrawableRuleset = ruleset.CreateDrawableRulesetWith(Beatmap.Value, Mods.Value);
|
||||
|
||||
playable = Beatmap.Value.GetPlayableBeatmap(rulesetInfo, Mods.Value);
|
||||
}
|
||||
|
||||
if (!DrawableRuleset.Objects.Any())
|
||||
if (playable.HitObjects.Count == 0)
|
||||
{
|
||||
Logger.Log("Beatmap contains no hit objects!", level: LogLevel.Error);
|
||||
return null;
|
||||
@ -283,7 +293,7 @@ namespace osu.Game.Screens.Play
|
||||
return null;
|
||||
}
|
||||
|
||||
return working;
|
||||
return playable;
|
||||
}
|
||||
|
||||
private void performImmediateExit()
|
||||
@ -501,6 +511,11 @@ namespace osu.Game.Screens.Play
|
||||
Background.EnableUserDim.Value = true;
|
||||
Background.BlurAmount.Value = 0;
|
||||
|
||||
// bind component bindables.
|
||||
Background.IsBreakTime.BindTo(breakOverlay.IsBreakTime);
|
||||
DimmableStoryboard.IsBreakTime.BindTo(breakOverlay.IsBreakTime);
|
||||
DimmableVideo.IsBreakTime.BindTo(breakOverlay.IsBreakTime);
|
||||
|
||||
Background.StoryboardReplacesBackground.BindTo(storyboardReplacesBackground);
|
||||
DimmableStoryboard.StoryboardReplacesBackground.BindTo(storyboardReplacesBackground);
|
||||
|
||||
|
@ -13,7 +13,7 @@ namespace osu.Game.Tests.Visual
|
||||
base.Update();
|
||||
|
||||
// note that this will override any mod rate application
|
||||
Beatmap.Value.Track.TempoAdjust = Clock.Rate;
|
||||
Beatmap.Value.Track.Tempo.Value = Clock.Rate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,13 +8,16 @@ namespace osu.Game.Tests.Visual
|
||||
{
|
||||
public class TestPlayer : Player
|
||||
{
|
||||
protected override bool PauseOnFocusLost => false;
|
||||
protected override bool PauseOnFocusLost { get; }
|
||||
|
||||
public new DrawableRuleset DrawableRuleset => base.DrawableRuleset;
|
||||
|
||||
public TestPlayer(bool allowPause = true, bool showResults = true)
|
||||
public new GameplayClockContainer GameplayClockContainer => base.GameplayClockContainer;
|
||||
|
||||
public TestPlayer(bool allowPause = true, bool showResults = true, bool pauseOnFocusLost = false)
|
||||
: base(allowPause, showResults)
|
||||
{
|
||||
PauseOnFocusLost = pauseOnFocusLost;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace osu.Game.Users
|
||||
{
|
||||
public class Country
|
||||
public class Country : IEquatable<Country>
|
||||
{
|
||||
/// <summary>
|
||||
/// The name of this country.
|
||||
@ -18,5 +19,7 @@ namespace osu.Game.Users
|
||||
/// </summary>
|
||||
[JsonProperty(@"code")]
|
||||
public string FlagName;
|
||||
|
||||
public bool Equals(Country other) => FlagName == other?.FlagName;
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +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 osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Overlays;
|
||||
|
||||
namespace osu.Game.Users.Drawables
|
||||
{
|
||||
@ -34,5 +37,14 @@ namespace osu.Game.Users.Drawables
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
};
|
||||
}
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
private RankingsOverlay rankingsOverlay { get; set; }
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
{
|
||||
rankingsOverlay?.ShowCountry(Country);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.1010.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2019.1205.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2019.1212.0" />
|
||||
<PackageReference Include="Sentry" Version="1.2.0" />
|
||||
<PackageReference Include="SharpCompress" Version="0.24.0" />
|
||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||
|
@ -74,7 +74,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup Label="Package References">
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.1010.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2019.1205.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2019.1212.0" />
|
||||
</ItemGroup>
|
||||
<!-- Xamarin.iOS does not automatically handle transitive dependencies from NuGet packages. -->
|
||||
<ItemGroup Label="Transitive Dependencies">
|
||||
@ -82,7 +82,7 @@
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2019.1205.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2019.1212.0" />
|
||||
<PackageReference Include="SharpCompress" Version="0.24.0" />
|
||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||
<PackageReference Include="SharpRaven" Version="2.4.0" />
|
||||
|
Loading…
Reference in New Issue
Block a user