mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 21:43:04 +08:00
Merge all changes from 2019.321.0 to android
This commit is contained in:
commit
00c659a5ca
@ -13,7 +13,7 @@ using osuTK;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch.Tests
|
namespace osu.Game.Rulesets.Catch.Tests
|
||||||
{
|
{
|
||||||
public class TestCaseAutoJuiceStream : TestCasePlayer
|
public class TestCaseAutoJuiceStream : PlayerTestCase
|
||||||
{
|
{
|
||||||
public TestCaseAutoJuiceStream()
|
public TestCaseAutoJuiceStream()
|
||||||
: base(new CatchRuleset())
|
: base(new CatchRuleset())
|
||||||
|
@ -8,11 +8,12 @@ using osu.Game.Beatmaps;
|
|||||||
using osu.Game.Rulesets.Catch.Objects;
|
using osu.Game.Rulesets.Catch.Objects;
|
||||||
using osu.Game.Rulesets.Catch.Objects.Drawable;
|
using osu.Game.Rulesets.Catch.Objects.Drawable;
|
||||||
using osu.Game.Rulesets.Catch.UI;
|
using osu.Game.Rulesets.Catch.UI;
|
||||||
|
using osu.Game.Tests.Visual;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch.Tests
|
namespace osu.Game.Rulesets.Catch.Tests
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestCaseBananaShower : Game.Tests.Visual.TestCasePlayer
|
public class TestCaseBananaShower : PlayerTestCase
|
||||||
{
|
{
|
||||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||||
{
|
{
|
||||||
@ -20,7 +21,7 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
typeof(DrawableBananaShower),
|
typeof(DrawableBananaShower),
|
||||||
|
|
||||||
typeof(CatchRuleset),
|
typeof(CatchRuleset),
|
||||||
typeof(CatchRulesetContainer),
|
typeof(DrawableCatchRuleset),
|
||||||
};
|
};
|
||||||
|
|
||||||
public TestCaseBananaShower()
|
public TestCaseBananaShower()
|
||||||
|
@ -2,11 +2,12 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
using osu.Game.Tests.Visual;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch.Tests
|
namespace osu.Game.Rulesets.Catch.Tests
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestCaseCatchPlayer : Game.Tests.Visual.TestCasePlayer
|
public class TestCaseCatchPlayer : PlayerTestCase
|
||||||
{
|
{
|
||||||
public TestCaseCatchPlayer()
|
public TestCaseCatchPlayer()
|
||||||
: base(new CatchRuleset())
|
: base(new CatchRuleset())
|
||||||
|
@ -4,11 +4,12 @@
|
|||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets.Catch.Objects;
|
using osu.Game.Rulesets.Catch.Objects;
|
||||||
|
using osu.Game.Tests.Visual;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch.Tests
|
namespace osu.Game.Rulesets.Catch.Tests
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestCaseCatchStacker : Game.Tests.Visual.TestCasePlayer
|
public class TestCaseCatchStacker : PlayerTestCase
|
||||||
{
|
{
|
||||||
public TestCaseCatchStacker()
|
public TestCaseCatchStacker()
|
||||||
: base(new CatchRuleset())
|
: base(new CatchRuleset())
|
||||||
|
@ -1,22 +1,28 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets.Catch.Objects;
|
using osu.Game.Rulesets.Catch.Objects;
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Tests.Visual;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch.Tests
|
namespace osu.Game.Rulesets.Catch.Tests
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestCaseHyperDash : Game.Tests.Visual.TestCasePlayer
|
public class TestCaseHyperDash : PlayerTestCase
|
||||||
{
|
{
|
||||||
public TestCaseHyperDash()
|
public TestCaseHyperDash()
|
||||||
: base(new CatchRuleset())
|
: base(new CatchRuleset())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
AddAssert("First note is hyperdash", () => Beatmap.Value.Beatmap.HitObjects[0] is Fruit f && f.HyperDash);
|
||||||
|
}
|
||||||
|
|
||||||
protected override IBeatmap CreateBeatmap(Ruleset ruleset)
|
protected override IBeatmap CreateBeatmap(Ruleset ruleset)
|
||||||
{
|
{
|
||||||
var beatmap = new Beatmap
|
var beatmap = new Beatmap
|
||||||
@ -28,7 +34,7 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Should produce a hperdash
|
// Should produce a hyper-dash
|
||||||
beatmap.HitObjects.Add(new Fruit { StartTime = 816, X = 308 / 512f, NewCombo = true });
|
beatmap.HitObjects.Add(new Fruit { StartTime = 816, X = 308 / 512f, NewCombo = true });
|
||||||
beatmap.HitObjects.Add(new Fruit { StartTime = 1008, X = 56 / 512f, });
|
beatmap.HitObjects.Add(new Fruit { StartTime = 1008, X = 56 / 512f, });
|
||||||
|
|
||||||
@ -38,11 +44,5 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
|
|
||||||
return beatmap;
|
return beatmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void AddCheckSteps(Func<Player> player)
|
|
||||||
{
|
|
||||||
base.AddCheckSteps(player);
|
|
||||||
AddAssert("First note is hyperdash", () => Beatmap.Value.Beatmap.HitObjects[0] is Fruit f && f.HyperDash);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Catch
|
|||||||
{
|
{
|
||||||
public class CatchRuleset : Ruleset
|
public class CatchRuleset : Ruleset
|
||||||
{
|
{
|
||||||
public override RulesetContainer CreateRulesetContainerWith(WorkingBeatmap beatmap) => new CatchRulesetContainer(this, beatmap);
|
public override DrawableRuleset CreateDrawableRulesetWith(WorkingBeatmap beatmap) => new DrawableCatchRuleset(this, beatmap);
|
||||||
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new CatchBeatmapConverter(beatmap);
|
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new CatchBeatmapConverter(beatmap);
|
||||||
public override IBeatmapProcessor CreateBeatmapProcessor(IBeatmap beatmap) => new CatchBeatmapProcessor(beatmap);
|
public override IBeatmapProcessor CreateBeatmapProcessor(IBeatmap beatmap) => new CatchBeatmapProcessor(beatmap);
|
||||||
|
|
||||||
|
@ -23,16 +23,9 @@ namespace osu.Game.Rulesets.Catch.Difficulty
|
|||||||
|
|
||||||
protected override int SectionLength => 750;
|
protected override int SectionLength => 750;
|
||||||
|
|
||||||
private readonly float halfCatchWidth;
|
|
||||||
|
|
||||||
public CatchDifficultyCalculator(Ruleset ruleset, WorkingBeatmap beatmap)
|
public CatchDifficultyCalculator(Ruleset ruleset, WorkingBeatmap beatmap)
|
||||||
: base(ruleset, beatmap)
|
: base(ruleset, beatmap)
|
||||||
{
|
{
|
||||||
var catcher = new CatcherArea.Catcher(beatmap.BeatmapInfo.BaseDifficulty);
|
|
||||||
halfCatchWidth = catcher.CatchWidth * 0.5f;
|
|
||||||
|
|
||||||
// We're only using 80% of the catcher's width to simulate imperfect gameplay.
|
|
||||||
halfCatchWidth *= 0.8f;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beatmap, Mod[] mods, Skill[] skills, double clockRate)
|
protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beatmap, Mod[] mods, Skill[] skills, double clockRate)
|
||||||
@ -54,6 +47,14 @@ namespace osu.Game.Rulesets.Catch.Difficulty
|
|||||||
|
|
||||||
protected override IEnumerable<DifficultyHitObject> CreateDifficultyHitObjects(IBeatmap beatmap, double clockRate)
|
protected override IEnumerable<DifficultyHitObject> CreateDifficultyHitObjects(IBeatmap beatmap, double clockRate)
|
||||||
{
|
{
|
||||||
|
float halfCatchWidth;
|
||||||
|
|
||||||
|
using (var catcher = new CatcherArea.Catcher(beatmap.BeatmapInfo.BaseDifficulty))
|
||||||
|
{
|
||||||
|
halfCatchWidth = catcher.CatchWidth * 0.5f;
|
||||||
|
halfCatchWidth *= 0.8f; // We're only using 80% of the catcher's width to simulate imperfect gameplay.
|
||||||
|
}
|
||||||
|
|
||||||
CatchHitObject lastObject = null;
|
CatchHitObject lastObject = null;
|
||||||
|
|
||||||
foreach (var hitObject in beatmap.HitObjects.OfType<CatchHitObject>())
|
foreach (var hitObject in beatmap.HitObjects.OfType<CatchHitObject>())
|
||||||
|
@ -21,10 +21,10 @@ namespace osu.Game.Rulesets.Catch.Mods
|
|||||||
|
|
||||||
private CatchPlayfield playfield;
|
private CatchPlayfield playfield;
|
||||||
|
|
||||||
public override void ApplyToRulesetContainer(RulesetContainer<CatchHitObject> rulesetContainer)
|
public override void ApplyToDrawableRuleset(DrawableRuleset<CatchHitObject> drawableRuleset)
|
||||||
{
|
{
|
||||||
playfield = (CatchPlayfield)rulesetContainer.Playfield;
|
playfield = (CatchPlayfield)drawableRuleset.Playfield;
|
||||||
base.ApplyToRulesetContainer(rulesetContainer);
|
base.ApplyToDrawableRuleset(drawableRuleset);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class CatchFlashlight : Flashlight
|
private class CatchFlashlight : Flashlight
|
||||||
|
@ -15,77 +15,107 @@ namespace osu.Game.Rulesets.Catch.Mods
|
|||||||
public override double ScoreMultiplier => 1.12;
|
public override double ScoreMultiplier => 1.12;
|
||||||
public override bool Ranked => true;
|
public override bool Ranked => true;
|
||||||
|
|
||||||
private float lastStartX;
|
private float? lastPosition;
|
||||||
private int lastStartTime;
|
private double lastStartTime;
|
||||||
|
|
||||||
public void ApplyToHitObject(HitObject hitObject)
|
public void ApplyToHitObject(HitObject hitObject)
|
||||||
{
|
{
|
||||||
|
if (hitObject is JuiceStream stream)
|
||||||
|
{
|
||||||
|
lastPosition = stream.EndX;
|
||||||
|
lastStartTime = stream.EndTime;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(hitObject is Fruit))
|
||||||
|
return;
|
||||||
|
|
||||||
var catchObject = (CatchHitObject)hitObject;
|
var catchObject = (CatchHitObject)hitObject;
|
||||||
|
|
||||||
float position = catchObject.X;
|
float position = catchObject.X;
|
||||||
int startTime = (int)hitObject.StartTime;
|
double startTime = hitObject.StartTime;
|
||||||
|
|
||||||
if (lastStartX == 0)
|
if (lastPosition == null)
|
||||||
{
|
{
|
||||||
lastStartX = position;
|
lastPosition = position;
|
||||||
lastStartTime = startTime;
|
lastStartTime = startTime;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
float diff = lastStartX - position;
|
float positionDiff = position - lastPosition.Value;
|
||||||
int timeDiff = startTime - lastStartTime;
|
double timeDiff = startTime - lastStartTime;
|
||||||
|
|
||||||
if (timeDiff > 1000)
|
if (timeDiff > 1000)
|
||||||
{
|
{
|
||||||
lastStartX = position;
|
lastPosition = position;
|
||||||
lastStartTime = startTime;
|
lastStartTime = startTime;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (diff == 0)
|
if (positionDiff == 0)
|
||||||
{
|
{
|
||||||
bool right = RNG.NextBool();
|
applyRandomOffset(ref position, timeDiff / 4d);
|
||||||
|
|
||||||
float rand = Math.Min(20, (float)RNG.NextDouble(0, timeDiff / 4d)) / CatchPlayfield.BASE_WIDTH;
|
|
||||||
|
|
||||||
if (right)
|
|
||||||
{
|
|
||||||
if (position + rand <= 1)
|
|
||||||
position += rand;
|
|
||||||
else
|
|
||||||
position -= rand;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (position - rand >= 0)
|
|
||||||
position -= rand;
|
|
||||||
else
|
|
||||||
position += rand;
|
|
||||||
}
|
|
||||||
|
|
||||||
catchObject.X = position;
|
catchObject.X = position;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Math.Abs(diff) < timeDiff / 3d)
|
if (Math.Abs(positionDiff * CatchPlayfield.BASE_WIDTH) < timeDiff / 3d)
|
||||||
{
|
applyOffset(ref position, positionDiff);
|
||||||
if (diff > 0)
|
|
||||||
{
|
|
||||||
if (position - diff > 0)
|
|
||||||
position -= diff;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (position - diff < 1)
|
|
||||||
position -= diff;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
catchObject.X = position;
|
catchObject.X = position;
|
||||||
|
|
||||||
lastStartX = position;
|
lastPosition = position;
|
||||||
lastStartTime = startTime;
|
lastStartTime = startTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Applies a random offset in a random direction to a position, ensuring that the final position remains within the boundary of the playfield.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="position">The position which the offset should be applied to.</param>
|
||||||
|
/// <param name="maxOffset">The maximum offset, cannot exceed 20px.</param>
|
||||||
|
private void applyRandomOffset(ref float position, double maxOffset)
|
||||||
|
{
|
||||||
|
bool right = RNG.NextBool();
|
||||||
|
float rand = Math.Min(20, (float)RNG.NextDouble(0, Math.Max(0, maxOffset))) / CatchPlayfield.BASE_WIDTH;
|
||||||
|
|
||||||
|
if (right)
|
||||||
|
{
|
||||||
|
// Clamp to the right bound
|
||||||
|
if (position + rand <= 1)
|
||||||
|
position += rand;
|
||||||
|
else
|
||||||
|
position -= rand;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Clamp to the left bound
|
||||||
|
if (position - rand >= 0)
|
||||||
|
position -= rand;
|
||||||
|
else
|
||||||
|
position += rand;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Applies an offset to a position, ensuring that the final position remains within the boundary of the playfield.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="position">The position which the offset should be applied to.</param>
|
||||||
|
/// <param name="amount">The amount to offset by.</param>
|
||||||
|
private void applyOffset(ref float position, float amount)
|
||||||
|
{
|
||||||
|
if (amount > 0)
|
||||||
|
{
|
||||||
|
// Clamp to the right bound
|
||||||
|
if (position + amount < 1)
|
||||||
|
position += amount;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Clamp to the left bound
|
||||||
|
if (position + amount > 0)
|
||||||
|
position += amount;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,8 @@ namespace osu.Game.Rulesets.Catch.Scoring
|
|||||||
{
|
{
|
||||||
public class CatchScoreProcessor : ScoreProcessor<CatchHitObject>
|
public class CatchScoreProcessor : ScoreProcessor<CatchHitObject>
|
||||||
{
|
{
|
||||||
public CatchScoreProcessor(RulesetContainer<CatchHitObject> rulesetContainer)
|
public CatchScoreProcessor(DrawableRuleset<CatchHitObject> drawableRuleset)
|
||||||
: base(rulesetContainer)
|
: base(drawableRuleset)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
if (lastPlateableFruit.IsLoaded)
|
if (lastPlateableFruit.IsLoaded)
|
||||||
action();
|
action();
|
||||||
else
|
else
|
||||||
lastPlateableFruit.OnLoadComplete = _ => action();
|
lastPlateableFruit.OnLoadComplete += _ => action();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.IsHit && fruit.CanBePlated)
|
if (result.IsHit && fruit.CanBePlated)
|
||||||
|
@ -17,13 +17,13 @@ using osu.Game.Rulesets.UI.Scrolling;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch.UI
|
namespace osu.Game.Rulesets.Catch.UI
|
||||||
{
|
{
|
||||||
public class CatchRulesetContainer : ScrollingRulesetContainer<CatchPlayfield, CatchHitObject>
|
public class DrawableCatchRuleset : DrawableScrollingRuleset<CatchHitObject>
|
||||||
{
|
{
|
||||||
protected override ScrollVisualisationMethod VisualisationMethod => ScrollVisualisationMethod.Constant;
|
protected override ScrollVisualisationMethod VisualisationMethod => ScrollVisualisationMethod.Constant;
|
||||||
|
|
||||||
protected override bool UserScrollSpeedAdjustment => false;
|
protected override bool UserScrollSpeedAdjustment => false;
|
||||||
|
|
||||||
public CatchRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap)
|
public DrawableCatchRuleset(Ruleset ruleset, WorkingBeatmap beatmap)
|
||||||
: base(ruleset, beatmap)
|
: base(ruleset, beatmap)
|
||||||
{
|
{
|
||||||
Direction.Value = ScrollingDirection.Down;
|
Direction.Value = ScrollingDirection.Down;
|
||||||
@ -36,7 +36,7 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
|
|
||||||
protected override Playfield CreatePlayfield() => new CatchPlayfield(Beatmap.BeatmapInfo.BaseDifficulty, GetVisualRepresentation);
|
protected override Playfield CreatePlayfield() => new CatchPlayfield(Beatmap.BeatmapInfo.BaseDifficulty, GetVisualRepresentation);
|
||||||
|
|
||||||
public override PassThroughInputManager CreateInputManager() => new CatchInputManager(Ruleset.RulesetInfo);
|
protected override PassThroughInputManager CreateInputManager() => new CatchInputManager(Ruleset.RulesetInfo);
|
||||||
|
|
||||||
public override DrawableHitObject<CatchHitObject> GetVisualRepresentation(CatchHitObject h)
|
public override DrawableHitObject<CatchHitObject> GetVisualRepresentation(CatchHitObject h)
|
||||||
{
|
{
|
@ -10,11 +10,11 @@ using osu.Game.Rulesets.UI.Scrolling;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.Edit
|
namespace osu.Game.Rulesets.Mania.Edit
|
||||||
{
|
{
|
||||||
public class ManiaEditRulesetContainer : ManiaRulesetContainer
|
public class DrawableManiaEditRuleset : DrawableManiaRuleset
|
||||||
{
|
{
|
||||||
public new IScrollingInfo ScrollingInfo => base.ScrollingInfo;
|
public new IScrollingInfo ScrollingInfo => base.ScrollingInfo;
|
||||||
|
|
||||||
public ManiaEditRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap)
|
public DrawableManiaEditRuleset(Ruleset ruleset, WorkingBeatmap beatmap)
|
||||||
: base(ruleset, beatmap)
|
: base(ruleset, beatmap)
|
||||||
{
|
{
|
||||||
}
|
}
|
@ -20,7 +20,7 @@ namespace osu.Game.Rulesets.Mania.Edit
|
|||||||
[Cached(Type = typeof(IManiaHitObjectComposer))]
|
[Cached(Type = typeof(IManiaHitObjectComposer))]
|
||||||
public class ManiaHitObjectComposer : HitObjectComposer<ManiaHitObject>, IManiaHitObjectComposer
|
public class ManiaHitObjectComposer : HitObjectComposer<ManiaHitObject>, IManiaHitObjectComposer
|
||||||
{
|
{
|
||||||
protected new ManiaEditRulesetContainer RulesetContainer { get; private set; }
|
protected new DrawableManiaEditRuleset DrawableRuleset { get; private set; }
|
||||||
|
|
||||||
public ManiaHitObjectComposer(Ruleset ruleset)
|
public ManiaHitObjectComposer(Ruleset ruleset)
|
||||||
: base(ruleset)
|
: base(ruleset)
|
||||||
@ -32,23 +32,23 @@ namespace osu.Game.Rulesets.Mania.Edit
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="screenSpacePosition">The screen-space position.</param>
|
/// <param name="screenSpacePosition">The screen-space position.</param>
|
||||||
/// <returns>The column which intersects with <paramref name="screenSpacePosition"/>.</returns>
|
/// <returns>The column which intersects with <paramref name="screenSpacePosition"/>.</returns>
|
||||||
public Column ColumnAt(Vector2 screenSpacePosition) => RulesetContainer.GetColumnByPosition(screenSpacePosition);
|
public Column ColumnAt(Vector2 screenSpacePosition) => DrawableRuleset.GetColumnByPosition(screenSpacePosition);
|
||||||
|
|
||||||
private DependencyContainer dependencies;
|
private DependencyContainer dependencies;
|
||||||
|
|
||||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||||
=> dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
=> dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
||||||
|
|
||||||
public int TotalColumns => ((ManiaPlayfield)RulesetContainer.Playfield).TotalColumns;
|
public int TotalColumns => ((ManiaPlayfield)DrawableRuleset.Playfield).TotalColumns;
|
||||||
|
|
||||||
protected override RulesetContainer<ManiaHitObject> CreateRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap)
|
protected override DrawableRuleset<ManiaHitObject> CreateDrawableRuleset(Ruleset ruleset, WorkingBeatmap beatmap)
|
||||||
{
|
{
|
||||||
RulesetContainer = new ManiaEditRulesetContainer(ruleset, beatmap);
|
DrawableRuleset = new DrawableManiaEditRuleset(ruleset, beatmap);
|
||||||
|
|
||||||
// This is the earliest we can cache the scrolling info to ourselves, before masks are added to the hierarchy and inject it
|
// This is the earliest we can cache the scrolling info to ourselves, before masks are added to the hierarchy and inject it
|
||||||
dependencies.CacheAs(RulesetContainer.ScrollingInfo);
|
dependencies.CacheAs(DrawableRuleset.ScrollingInfo);
|
||||||
|
|
||||||
return RulesetContainer;
|
return DrawableRuleset;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override IReadOnlyList<HitObjectCompositionTool> CompositionTools => new HitObjectCompositionTool[]
|
protected override IReadOnlyList<HitObjectCompositionTool> CompositionTools => new HitObjectCompositionTool[]
|
||||||
|
@ -31,7 +31,7 @@ namespace osu.Game.Rulesets.Mania
|
|||||||
{
|
{
|
||||||
public class ManiaRuleset : Ruleset
|
public class ManiaRuleset : Ruleset
|
||||||
{
|
{
|
||||||
public override RulesetContainer CreateRulesetContainerWith(WorkingBeatmap beatmap) => new ManiaRulesetContainer(this, beatmap);
|
public override DrawableRuleset CreateDrawableRulesetWith(WorkingBeatmap beatmap) => new DrawableManiaRuleset(this, beatmap);
|
||||||
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new ManiaBeatmapConverter(beatmap);
|
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new ManiaBeatmapConverter(beatmap);
|
||||||
public override PerformanceCalculator CreatePerformanceCalculator(WorkingBeatmap beatmap, ScoreInfo score) => new ManiaPerformanceCalculator(this, beatmap, score);
|
public override PerformanceCalculator CreatePerformanceCalculator(WorkingBeatmap beatmap, ScoreInfo score) => new ManiaPerformanceCalculator(this, beatmap, score);
|
||||||
|
|
||||||
|
@ -92,8 +92,8 @@ namespace osu.Game.Rulesets.Mania.Scoring
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public ManiaScoreProcessor(RulesetContainer<ManiaHitObject> rulesetContainer)
|
public ManiaScoreProcessor(DrawableRuleset<ManiaHitObject> drawableRuleset)
|
||||||
: base(rulesetContainer)
|
: base(drawableRuleset)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,8 +28,10 @@ using osuTK;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.UI
|
namespace osu.Game.Rulesets.Mania.UI
|
||||||
{
|
{
|
||||||
public class ManiaRulesetContainer : ScrollingRulesetContainer<ManiaPlayfield, ManiaHitObject>
|
public class DrawableManiaRuleset : DrawableScrollingRuleset<ManiaHitObject>
|
||||||
{
|
{
|
||||||
|
protected new ManiaPlayfield Playfield => (ManiaPlayfield)base.Playfield;
|
||||||
|
|
||||||
public new ManiaBeatmap Beatmap => (ManiaBeatmap)base.Beatmap;
|
public new ManiaBeatmap Beatmap => (ManiaBeatmap)base.Beatmap;
|
||||||
|
|
||||||
public IEnumerable<BarLine> BarLines;
|
public IEnumerable<BarLine> BarLines;
|
||||||
@ -38,7 +40,7 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
|
|
||||||
private readonly Bindable<ManiaScrollingDirection> configDirection = new Bindable<ManiaScrollingDirection>();
|
private readonly Bindable<ManiaScrollingDirection> configDirection = new Bindable<ManiaScrollingDirection>();
|
||||||
|
|
||||||
public ManiaRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap)
|
public DrawableManiaRuleset(Ruleset ruleset, WorkingBeatmap beatmap)
|
||||||
: base(ruleset, beatmap)
|
: base(ruleset, beatmap)
|
||||||
{
|
{
|
||||||
// Generate the bar lines
|
// Generate the bar lines
|
||||||
@ -97,7 +99,7 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
|
|
||||||
public override int Variant => (int)(Beatmap.Stages.Count == 1 ? PlayfieldType.Single : PlayfieldType.Dual) + Beatmap.TotalColumns;
|
public override int Variant => (int)(Beatmap.Stages.Count == 1 ? PlayfieldType.Single : PlayfieldType.Dual) + Beatmap.TotalColumns;
|
||||||
|
|
||||||
public override PassThroughInputManager CreateInputManager() => new ManiaInputManager(Ruleset.RulesetInfo, Variant);
|
protected override PassThroughInputManager CreateInputManager() => new ManiaInputManager(Ruleset.RulesetInfo, Variant);
|
||||||
|
|
||||||
public override DrawableHitObject<ManiaHitObject> GetVisualRepresentation(ManiaHitObject h)
|
public override DrawableHitObject<ManiaHitObject> GetVisualRepresentation(ManiaHitObject h)
|
||||||
{
|
{
|
@ -4,12 +4,13 @@
|
|||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
|
using osu.Game.Tests.Visual;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Tests
|
namespace osu.Game.Rulesets.Osu.Tests
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestCaseHitCircleLongCombo : Game.Tests.Visual.TestCasePlayer
|
public class TestCaseHitCircleLongCombo : PlayerTestCase
|
||||||
{
|
{
|
||||||
public TestCaseHitCircleLongCombo()
|
public TestCaseHitCircleLongCombo()
|
||||||
: base(new OsuRuleset())
|
: base(new OsuRuleset())
|
||||||
|
@ -2,11 +2,12 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
using osu.Game.Tests.Visual;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Tests
|
namespace osu.Game.Rulesets.Osu.Tests
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestCaseOsuPlayer : Game.Tests.Visual.TestCasePlayer
|
public class TestCaseOsuPlayer : PlayerTestCase
|
||||||
{
|
{
|
||||||
public TestCaseOsuPlayer()
|
public TestCaseOsuPlayer()
|
||||||
: base(new OsuRuleset())
|
: base(new OsuRuleset())
|
||||||
|
@ -354,9 +354,9 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
judgementResults = new List<JudgementResult>();
|
judgementResults = new List<JudgementResult>();
|
||||||
});
|
});
|
||||||
|
|
||||||
AddUntilStep(() => Beatmap.Value.Track.CurrentTime == 0, "Beatmap at 0");
|
AddUntilStep("Beatmap at 0", () => Beatmap.Value.Track.CurrentTime == 0);
|
||||||
AddUntilStep(() => currentPlayer.IsCurrentScreen(), "Wait until player is loaded");
|
AddUntilStep("Wait until player is loaded", () => currentPlayer.IsCurrentScreen());
|
||||||
AddUntilStep(() => allJudgedFired, "Wait for all judged");
|
AddUntilStep("Wait for all judged", () => allJudgedFired);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ScoreAccessibleReplayPlayer : ReplayPlayer
|
private class ScoreAccessibleReplayPlayer : ReplayPlayer
|
||||||
|
@ -8,9 +8,9 @@ using osuTK;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Edit
|
namespace osu.Game.Rulesets.Osu.Edit
|
||||||
{
|
{
|
||||||
public class OsuEditRulesetContainer : OsuRulesetContainer
|
public class DrawableOsuEditRuleset : DrawableOsuRuleset
|
||||||
{
|
{
|
||||||
public OsuEditRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap)
|
public DrawableOsuEditRuleset(Ruleset ruleset, WorkingBeatmap beatmap)
|
||||||
: base(ruleset, beatmap)
|
: base(ruleset, beatmap)
|
||||||
{
|
{
|
||||||
}
|
}
|
@ -26,8 +26,8 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override RulesetContainer<OsuHitObject> CreateRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap)
|
protected override DrawableRuleset<OsuHitObject> CreateDrawableRuleset(Ruleset ruleset, WorkingBeatmap beatmap)
|
||||||
=> new OsuEditRulesetContainer(ruleset, beatmap);
|
=> new DrawableOsuEditRuleset(ruleset, beatmap);
|
||||||
|
|
||||||
protected override IReadOnlyList<HitObjectCompositionTool> CompositionTools => new HitObjectCompositionTool[]
|
protected override IReadOnlyList<HitObjectCompositionTool> CompositionTools => new HitObjectCompositionTool[]
|
||||||
{
|
{
|
||||||
|
@ -18,7 +18,7 @@ using osuTK.Graphics;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Mods
|
namespace osu.Game.Rulesets.Osu.Mods
|
||||||
{
|
{
|
||||||
public class OsuModBlinds : Mod, IApplicableToRulesetContainer<OsuHitObject>, IApplicableToScoreProcessor
|
public class OsuModBlinds : Mod, IApplicableToDrawableRuleset<OsuHitObject>, IApplicableToScoreProcessor
|
||||||
{
|
{
|
||||||
public override string Name => "Blinds";
|
public override string Name => "Blinds";
|
||||||
public override string Description => "Play with blinds on your screen.";
|
public override string Description => "Play with blinds on your screen.";
|
||||||
@ -32,9 +32,9 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
public override double ScoreMultiplier => 1.12;
|
public override double ScoreMultiplier => 1.12;
|
||||||
private DrawableOsuBlinds blinds;
|
private DrawableOsuBlinds blinds;
|
||||||
|
|
||||||
public void ApplyToRulesetContainer(RulesetContainer<OsuHitObject> rulesetContainer)
|
public void ApplyToDrawableRuleset(DrawableRuleset<OsuHitObject> drawableRuleset)
|
||||||
{
|
{
|
||||||
rulesetContainer.Overlays.Add(blinds = new DrawableOsuBlinds(rulesetContainer.Playfield.HitObjectContainer, rulesetContainer.Beatmap));
|
drawableRuleset.Overlays.Add(blinds = new DrawableOsuBlinds(drawableRuleset.Playfield.HitObjectContainer, drawableRuleset.Beatmap));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)
|
public void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)
|
||||||
|
@ -13,7 +13,7 @@ using static osu.Game.Input.Handlers.ReplayInputHandler;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Mods
|
namespace osu.Game.Rulesets.Osu.Mods
|
||||||
{
|
{
|
||||||
public class OsuModRelax : ModRelax, IApplicableFailOverride, IUpdatableByPlayfield, IApplicableToRulesetContainer<OsuHitObject>
|
public class OsuModRelax : ModRelax, IApplicableFailOverride, IUpdatableByPlayfield, IApplicableToDrawableRuleset<OsuHitObject>
|
||||||
{
|
{
|
||||||
public override string Description => @"You don't need to click. Give your clicking/tapping fingers a break from the heat of things.";
|
public override string Description => @"You don't need to click. Give your clicking/tapping fingers a break from the heat of things.";
|
||||||
public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(OsuModAutopilot)).ToArray();
|
public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(OsuModAutopilot)).ToArray();
|
||||||
@ -79,10 +79,10 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
state.Apply(osuInputManager.CurrentState, osuInputManager);
|
state.Apply(osuInputManager.CurrentState, osuInputManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ApplyToRulesetContainer(RulesetContainer<OsuHitObject> rulesetContainer)
|
public void ApplyToDrawableRuleset(DrawableRuleset<OsuHitObject> drawableRuleset)
|
||||||
{
|
{
|
||||||
// grab the input manager for future use.
|
// grab the input manager for future use.
|
||||||
osuInputManager = (OsuInputManager)rulesetContainer.KeyBindingInputManager;
|
osuInputManager = (OsuInputManager)drawableRuleset.KeyBindingInputManager;
|
||||||
osuInputManager.AllowUserPresses = false;
|
osuInputManager.AllowUserPresses = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ namespace osu.Game.Rulesets.Osu
|
|||||||
{
|
{
|
||||||
public class OsuRuleset : Ruleset
|
public class OsuRuleset : Ruleset
|
||||||
{
|
{
|
||||||
public override RulesetContainer CreateRulesetContainerWith(WorkingBeatmap beatmap) => new OsuRulesetContainer(this, beatmap);
|
public override DrawableRuleset CreateDrawableRulesetWith(WorkingBeatmap beatmap) => new DrawableOsuRuleset(this, beatmap);
|
||||||
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new OsuBeatmapConverter(beatmap);
|
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new OsuBeatmapConverter(beatmap);
|
||||||
public override IBeatmapProcessor CreateBeatmapProcessor(IBeatmap beatmap) => new OsuBeatmapProcessor(beatmap);
|
public override IBeatmapProcessor CreateBeatmapProcessor(IBeatmap beatmap) => new OsuBeatmapProcessor(beatmap);
|
||||||
|
|
||||||
|
@ -15,8 +15,8 @@ namespace osu.Game.Rulesets.Osu.Scoring
|
|||||||
{
|
{
|
||||||
internal class OsuScoreProcessor : ScoreProcessor<OsuHitObject>
|
internal class OsuScoreProcessor : ScoreProcessor<OsuHitObject>
|
||||||
{
|
{
|
||||||
public OsuScoreProcessor(RulesetContainer<OsuHitObject> rulesetContainer)
|
public OsuScoreProcessor(DrawableRuleset<OsuHitObject> drawableRuleset)
|
||||||
: base(rulesetContainer)
|
: base(drawableRuleset)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,11 +17,11 @@ using osu.Game.Rulesets.UI;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.UI
|
namespace osu.Game.Rulesets.Osu.UI
|
||||||
{
|
{
|
||||||
public class OsuRulesetContainer : RulesetContainer<OsuPlayfield, OsuHitObject>
|
public class DrawableOsuRuleset : DrawableRuleset<OsuHitObject>
|
||||||
{
|
{
|
||||||
protected new OsuRulesetConfigManager Config => (OsuRulesetConfigManager)base.Config;
|
protected new OsuRulesetConfigManager Config => (OsuRulesetConfigManager)base.Config;
|
||||||
|
|
||||||
public OsuRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap)
|
public DrawableOsuRuleset(Ruleset ruleset, WorkingBeatmap beatmap)
|
||||||
: base(ruleset, beatmap)
|
: base(ruleset, beatmap)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -30,7 +30,7 @@ namespace osu.Game.Rulesets.Osu.UI
|
|||||||
|
|
||||||
protected override Playfield CreatePlayfield() => new OsuPlayfield();
|
protected override Playfield CreatePlayfield() => new OsuPlayfield();
|
||||||
|
|
||||||
public override PassThroughInputManager CreateInputManager() => new OsuInputManager(Ruleset.RulesetInfo);
|
protected override PassThroughInputManager CreateInputManager() => new OsuInputManager(Ruleset.RulesetInfo);
|
||||||
|
|
||||||
public override DrawableHitObject<OsuHitObject> GetVisualRepresentation(OsuHitObject h)
|
public override DrawableHitObject<OsuHitObject> GetVisualRepresentation(OsuHitObject h)
|
||||||
{
|
{
|
@ -33,7 +33,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
|||||||
protected override double TimePerAction => default_duration * 2;
|
protected override double TimePerAction => default_duration * 2;
|
||||||
|
|
||||||
private readonly Random rng = new Random(1337);
|
private readonly Random rng = new Random(1337);
|
||||||
private TaikoRulesetContainer rulesetContainer;
|
private DrawableTaikoRuleset drawableRuleset;
|
||||||
private Container playfieldContainer;
|
private Container playfieldContainer;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -86,7 +86,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
|||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Height = 768,
|
Height = 768,
|
||||||
Children = new[] { rulesetContainer = new TaikoRulesetContainer(new TaikoRuleset(), beatmap) }
|
Children = new[] { drawableRuleset = new DrawableTaikoRuleset(new TaikoRuleset(), beatmap) }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
|||||||
|
|
||||||
var h = new DrawableTestHit(hit) { X = RNG.NextSingle(hitResult == HitResult.Good ? -0.1f : -0.05f, hitResult == HitResult.Good ? 0.1f : 0.05f) };
|
var h = new DrawableTestHit(hit) { X = RNG.NextSingle(hitResult == HitResult.Good ? -0.1f : -0.05f, hitResult == HitResult.Good ? 0.1f : 0.05f) };
|
||||||
|
|
||||||
((TaikoPlayfield)rulesetContainer.Playfield).OnNewResult(h, new JudgementResult(new TaikoJudgement()) { Type = hitResult });
|
((TaikoPlayfield)drawableRuleset.Playfield).OnNewResult(h, new JudgementResult(new TaikoJudgement()) { Type = hitResult });
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addStrongHitJudgement(bool kiai)
|
private void addStrongHitJudgement(bool kiai)
|
||||||
@ -154,33 +154,33 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
|||||||
|
|
||||||
var h = new DrawableTestHit(hit) { X = RNG.NextSingle(hitResult == HitResult.Good ? -0.1f : -0.05f, hitResult == HitResult.Good ? 0.1f : 0.05f) };
|
var h = new DrawableTestHit(hit) { X = RNG.NextSingle(hitResult == HitResult.Good ? -0.1f : -0.05f, hitResult == HitResult.Good ? 0.1f : 0.05f) };
|
||||||
|
|
||||||
((TaikoPlayfield)rulesetContainer.Playfield).OnNewResult(h, new JudgementResult(new TaikoJudgement()) { Type = hitResult });
|
((TaikoPlayfield)drawableRuleset.Playfield).OnNewResult(h, new JudgementResult(new TaikoJudgement()) { Type = hitResult });
|
||||||
((TaikoPlayfield)rulesetContainer.Playfield).OnNewResult(new TestStrongNestedHit(h), new JudgementResult(new TaikoStrongJudgement()) { Type = HitResult.Great });
|
((TaikoPlayfield)drawableRuleset.Playfield).OnNewResult(new TestStrongNestedHit(h), new JudgementResult(new TaikoStrongJudgement()) { Type = HitResult.Great });
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addMissJudgement()
|
private void addMissJudgement()
|
||||||
{
|
{
|
||||||
((TaikoPlayfield)rulesetContainer.Playfield).OnNewResult(new DrawableTestHit(new Hit()), new JudgementResult(new TaikoJudgement()) { Type = HitResult.Miss });
|
((TaikoPlayfield)drawableRuleset.Playfield).OnNewResult(new DrawableTestHit(new Hit()), new JudgementResult(new TaikoJudgement()) { Type = HitResult.Miss });
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addBarLine(bool major, double delay = scroll_time)
|
private void addBarLine(bool major, double delay = scroll_time)
|
||||||
{
|
{
|
||||||
BarLine bl = new BarLine { StartTime = rulesetContainer.Playfield.Time.Current + delay };
|
BarLine bl = new BarLine { StartTime = drawableRuleset.Playfield.Time.Current + delay };
|
||||||
|
|
||||||
rulesetContainer.Playfield.Add(major ? new DrawableBarLineMajor(bl) : new DrawableBarLine(bl));
|
drawableRuleset.Playfield.Add(major ? new DrawableBarLineMajor(bl) : new DrawableBarLine(bl));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addSwell(double duration = default_duration)
|
private void addSwell(double duration = default_duration)
|
||||||
{
|
{
|
||||||
var swell = new Swell
|
var swell = new Swell
|
||||||
{
|
{
|
||||||
StartTime = rulesetContainer.Playfield.Time.Current + scroll_time,
|
StartTime = drawableRuleset.Playfield.Time.Current + scroll_time,
|
||||||
Duration = duration,
|
Duration = duration,
|
||||||
};
|
};
|
||||||
|
|
||||||
swell.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
swell.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
||||||
|
|
||||||
rulesetContainer.Playfield.Add(new DrawableSwell(swell));
|
drawableRuleset.Playfield.Add(new DrawableSwell(swell));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addDrumRoll(bool strong, double duration = default_duration)
|
private void addDrumRoll(bool strong, double duration = default_duration)
|
||||||
@ -190,40 +190,40 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
|||||||
|
|
||||||
var d = new DrumRoll
|
var d = new DrumRoll
|
||||||
{
|
{
|
||||||
StartTime = rulesetContainer.Playfield.Time.Current + scroll_time,
|
StartTime = drawableRuleset.Playfield.Time.Current + scroll_time,
|
||||||
IsStrong = strong,
|
IsStrong = strong,
|
||||||
Duration = duration,
|
Duration = duration,
|
||||||
};
|
};
|
||||||
|
|
||||||
d.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
d.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
||||||
|
|
||||||
rulesetContainer.Playfield.Add(new DrawableDrumRoll(d));
|
drawableRuleset.Playfield.Add(new DrawableDrumRoll(d));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addCentreHit(bool strong)
|
private void addCentreHit(bool strong)
|
||||||
{
|
{
|
||||||
Hit h = new Hit
|
Hit h = new Hit
|
||||||
{
|
{
|
||||||
StartTime = rulesetContainer.Playfield.Time.Current + scroll_time,
|
StartTime = drawableRuleset.Playfield.Time.Current + scroll_time,
|
||||||
IsStrong = strong
|
IsStrong = strong
|
||||||
};
|
};
|
||||||
|
|
||||||
h.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
h.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
||||||
|
|
||||||
rulesetContainer.Playfield.Add(new DrawableCentreHit(h));
|
drawableRuleset.Playfield.Add(new DrawableCentreHit(h));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addRimHit(bool strong)
|
private void addRimHit(bool strong)
|
||||||
{
|
{
|
||||||
Hit h = new Hit
|
Hit h = new Hit
|
||||||
{
|
{
|
||||||
StartTime = rulesetContainer.Playfield.Time.Current + scroll_time,
|
StartTime = drawableRuleset.Playfield.Time.Current + scroll_time,
|
||||||
IsStrong = strong
|
IsStrong = strong
|
||||||
};
|
};
|
||||||
|
|
||||||
h.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
h.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
||||||
|
|
||||||
rulesetContainer.Playfield.Add(new DrawableRimHit(h));
|
drawableRuleset.Playfield.Add(new DrawableRimHit(h));
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TestStrongNestedHit : DrawableStrongNestedHit
|
private class TestStrongNestedHit : DrawableStrongNestedHit
|
||||||
|
@ -22,10 +22,10 @@ namespace osu.Game.Rulesets.Taiko.Mods
|
|||||||
|
|
||||||
private TaikoPlayfield playfield;
|
private TaikoPlayfield playfield;
|
||||||
|
|
||||||
public override void ApplyToRulesetContainer(RulesetContainer<TaikoHitObject> rulesetContainer)
|
public override void ApplyToDrawableRuleset(DrawableRuleset<TaikoHitObject> drawableRuleset)
|
||||||
{
|
{
|
||||||
playfield = (TaikoPlayfield)rulesetContainer.Playfield;
|
playfield = (TaikoPlayfield)drawableRuleset.Playfield;
|
||||||
base.ApplyToRulesetContainer(rulesetContainer);
|
base.ApplyToDrawableRuleset(drawableRuleset);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TaikoFlashlight : Flashlight
|
private class TaikoFlashlight : Flashlight
|
||||||
|
@ -32,8 +32,8 @@ namespace osu.Game.Rulesets.Taiko.Scoring
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private double hpMissMultiplier;
|
private double hpMissMultiplier;
|
||||||
|
|
||||||
public TaikoScoreProcessor(RulesetContainer<TaikoHitObject> rulesetContainer)
|
public TaikoScoreProcessor(DrawableRuleset<TaikoHitObject> drawableRuleset)
|
||||||
: base(rulesetContainer)
|
: base(drawableRuleset)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ namespace osu.Game.Rulesets.Taiko
|
|||||||
{
|
{
|
||||||
public class TaikoRuleset : Ruleset
|
public class TaikoRuleset : Ruleset
|
||||||
{
|
{
|
||||||
public override RulesetContainer CreateRulesetContainerWith(WorkingBeatmap beatmap) => new TaikoRulesetContainer(this, beatmap);
|
public override DrawableRuleset CreateDrawableRulesetWith(WorkingBeatmap beatmap) => new DrawableTaikoRuleset(this, beatmap);
|
||||||
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new TaikoBeatmapConverter(beatmap);
|
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new TaikoBeatmapConverter(beatmap);
|
||||||
|
|
||||||
public override IEnumerable<KeyBinding> GetDefaultKeyBindings(int variant = 0) => new[]
|
public override IEnumerable<KeyBinding> GetDefaultKeyBindings(int variant = 0) => new[]
|
||||||
|
@ -20,13 +20,13 @@ using osu.Game.Rulesets.UI.Scrolling;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Taiko.UI
|
namespace osu.Game.Rulesets.Taiko.UI
|
||||||
{
|
{
|
||||||
public class TaikoRulesetContainer : ScrollingRulesetContainer<TaikoPlayfield, TaikoHitObject>
|
public class DrawableTaikoRuleset : DrawableScrollingRuleset<TaikoHitObject>
|
||||||
{
|
{
|
||||||
protected override ScrollVisualisationMethod VisualisationMethod => ScrollVisualisationMethod.Overlapping;
|
protected override ScrollVisualisationMethod VisualisationMethod => ScrollVisualisationMethod.Overlapping;
|
||||||
|
|
||||||
protected override bool UserScrollSpeedAdjustment => false;
|
protected override bool UserScrollSpeedAdjustment => false;
|
||||||
|
|
||||||
public TaikoRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap)
|
public DrawableTaikoRuleset(Ruleset ruleset, WorkingBeatmap beatmap)
|
||||||
: base(ruleset, beatmap)
|
: base(ruleset, beatmap)
|
||||||
{
|
{
|
||||||
Direction.Value = ScrollingDirection.Left;
|
Direction.Value = ScrollingDirection.Left;
|
||||||
@ -81,7 +81,7 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
|
|
||||||
public override ScoreProcessor CreateScoreProcessor() => new TaikoScoreProcessor(this);
|
public override ScoreProcessor CreateScoreProcessor() => new TaikoScoreProcessor(this);
|
||||||
|
|
||||||
public override PassThroughInputManager CreateInputManager() => new TaikoInputManager(Ruleset.RulesetInfo);
|
protected override PassThroughInputManager CreateInputManager() => new TaikoInputManager(Ruleset.RulesetInfo);
|
||||||
|
|
||||||
protected override Playfield CreatePlayfield() => new TaikoPlayfield(Beatmap.ControlPointInfo);
|
protected override Playfield CreatePlayfield() => new TaikoPlayfield(Beatmap.ControlPointInfo);
|
||||||
|
|
@ -24,7 +24,7 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
public class TaikoPlayfield : ScrollingPlayfield
|
public class TaikoPlayfield : ScrollingPlayfield
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Default height of a <see cref="TaikoPlayfield"/> when inside a <see cref="TaikoRulesetContainer"/>.
|
/// Default height of a <see cref="TaikoPlayfield"/> when inside a <see cref="DrawableTaikoRuleset"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const float DEFAULT_HEIGHT = 178;
|
public const float DEFAULT_HEIGHT = 178;
|
||||||
|
|
||||||
|
@ -242,6 +242,61 @@ namespace osu.Game.Tests.Beatmaps.IO
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestImportWithDuplicateBeatmapIDs()
|
||||||
|
{
|
||||||
|
//unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here.
|
||||||
|
using (HeadlessGameHost host = new CleanRunHeadlessGameHost("TestImportWithDuplicateBeatmapID"))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var osu = loadOsu(host);
|
||||||
|
|
||||||
|
var metadata = new BeatmapMetadata
|
||||||
|
{
|
||||||
|
Artist = "SomeArtist",
|
||||||
|
AuthorString = "SomeAuthor"
|
||||||
|
};
|
||||||
|
|
||||||
|
var difficulty = new BeatmapDifficulty();
|
||||||
|
|
||||||
|
var toImport = new BeatmapSetInfo
|
||||||
|
{
|
||||||
|
OnlineBeatmapSetID = 1,
|
||||||
|
Metadata = metadata,
|
||||||
|
Beatmaps = new List<BeatmapInfo>
|
||||||
|
{
|
||||||
|
new BeatmapInfo
|
||||||
|
{
|
||||||
|
OnlineBeatmapID = 2,
|
||||||
|
Metadata = metadata,
|
||||||
|
BaseDifficulty = difficulty
|
||||||
|
},
|
||||||
|
new BeatmapInfo
|
||||||
|
{
|
||||||
|
OnlineBeatmapID = 2,
|
||||||
|
Metadata = metadata,
|
||||||
|
Status = BeatmapSetOnlineStatus.Loved,
|
||||||
|
BaseDifficulty = difficulty
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var manager = osu.Dependencies.Get<BeatmapManager>();
|
||||||
|
|
||||||
|
var imported = manager.Import(toImport);
|
||||||
|
|
||||||
|
Assert.NotNull(imported);
|
||||||
|
Assert.AreEqual(null, imported.Beatmaps[0].OnlineBeatmapID);
|
||||||
|
Assert.AreEqual(null, imported.Beatmaps[1].OnlineBeatmapID);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
host.Exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
[NonParallelizable]
|
[NonParallelizable]
|
||||||
[Ignore("Binding IPC on Appveyor isn't working (port in use). Need to figure out why")]
|
[Ignore("Binding IPC on Appveyor isn't working (port in use). Need to figure out why")]
|
||||||
|
@ -1,12 +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 NUnit.Framework;
|
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual
|
|
||||||
{
|
|
||||||
[TestFixture]
|
|
||||||
public class TestCaseAllPlayers : TestCasePlayer
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
@ -11,7 +10,7 @@ using osu.Game.Screens.Play;
|
|||||||
namespace osu.Game.Tests.Visual
|
namespace osu.Game.Tests.Visual
|
||||||
{
|
{
|
||||||
[Description("Player instantiated with an autoplay mod.")]
|
[Description("Player instantiated with an autoplay mod.")]
|
||||||
public class TestCaseAutoplay : TestCasePlayer
|
public class TestCaseAutoplay : AllPlayersTestCase
|
||||||
{
|
{
|
||||||
protected override Player CreatePlayer(Ruleset ruleset)
|
protected override Player CreatePlayer(Ruleset ruleset)
|
||||||
{
|
{
|
||||||
@ -24,11 +23,10 @@ namespace osu.Game.Tests.Visual
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void AddCheckSteps(Func<Player> player)
|
protected override void AddCheckSteps()
|
||||||
{
|
{
|
||||||
base.AddCheckSteps(player);
|
AddUntilStep("score above zero", () => ((ScoreAccessiblePlayer)Player).ScoreProcessor.TotalScore.Value > 0);
|
||||||
AddUntilStep(() => ((ScoreAccessiblePlayer)player()).ScoreProcessor.TotalScore.Value > 0, "score above zero");
|
AddUntilStep("key counter counted keys", () => ((ScoreAccessiblePlayer)Player).HUDOverlay.KeyCounter.Children.Any(kc => kc.CountPresses > 0));
|
||||||
AddUntilStep(() => ((ScoreAccessiblePlayer)player()).HUDOverlay.KeyCounter.Children.Any(kc => kc.CountPresses > 0), "key counter counted keys");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ScoreAccessiblePlayer : Player
|
private class ScoreAccessiblePlayer : Player
|
||||||
|
@ -48,8 +48,8 @@ namespace osu.Game.Tests.Visual
|
|||||||
};
|
};
|
||||||
|
|
||||||
private DummySongSelect songSelect;
|
private DummySongSelect songSelect;
|
||||||
private DimAccessiblePlayerLoader playerLoader;
|
private TestPlayerLoader playerLoader;
|
||||||
private DimAccessiblePlayer player;
|
private TestPlayer player;
|
||||||
private DatabaseContextFactory factory;
|
private DatabaseContextFactory factory;
|
||||||
private BeatmapManager manager;
|
private BeatmapManager manager;
|
||||||
private RulesetStore rulesets;
|
private RulesetStore rulesets;
|
||||||
@ -74,31 +74,27 @@ namespace osu.Game.Tests.Visual
|
|||||||
Dependencies.Cache(manager = new BeatmapManager(LocalStorage, factory, rulesets, null, null, host, Beatmap.Default));
|
Dependencies.Cache(manager = new BeatmapManager(LocalStorage, factory, rulesets, null, null, host, Beatmap.Default));
|
||||||
Dependencies.Cache(new OsuConfigManager(LocalStorage));
|
Dependencies.Cache(new OsuConfigManager(LocalStorage));
|
||||||
|
|
||||||
|
manager.Import(TestResources.GetTestBeatmapForImport());
|
||||||
|
|
||||||
Beatmap.SetDefault();
|
Beatmap.SetDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public virtual void SetUp()
|
public virtual void SetUp() => Schedule(() =>
|
||||||
{
|
{
|
||||||
Schedule(() =>
|
Child = screenStackContainer = new ScreenStackCacheContainer { RelativeSizeAxes = Axes.Both };
|
||||||
{
|
screenStackContainer.ScreenStack.Push(songSelect = new DummySongSelect());
|
||||||
manager.Delete(manager.GetAllUsableBeatmapSets());
|
});
|
||||||
var temp = TestResources.GetTestBeatmapForImport();
|
|
||||||
manager.Import(temp);
|
|
||||||
Child = screenStackContainer = new ScreenStackCacheContainer { RelativeSizeAxes = Axes.Both };
|
|
||||||
screenStackContainer.ScreenStack.Push(songSelect = new DummySongSelect());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check if <see cref="PlayerLoader"/> properly triggers background dim previews when a user hovers over the visual settings panel.
|
/// Check if <see cref="PlayerLoader"/> properly triggers the visual settings preview when a user hovers over the visual settings panel.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Test]
|
[Test]
|
||||||
public void PlayerLoaderSettingsHoverTest()
|
public void PlayerLoaderSettingsHoverTest()
|
||||||
{
|
{
|
||||||
setupUserSettings();
|
setupUserSettings();
|
||||||
AddStep("Start player loader", () => songSelect.Push(playerLoader = new DimAccessiblePlayerLoader(player = new DimAccessiblePlayer())));
|
AddStep("Start player loader", () => songSelect.Push(playerLoader = new TestPlayerLoader(player = new TestPlayer())));
|
||||||
AddUntilStep(() => playerLoader?.IsLoaded ?? false, "Wait for Player Loader to load");
|
AddUntilStep("Wait for Player Loader to load", () => playerLoader?.IsLoaded ?? false);
|
||||||
AddAssert("Background retained from song select", () => songSelect.IsBackgroundCurrent());
|
AddAssert("Background retained from song select", () => songSelect.IsBackgroundCurrent());
|
||||||
AddStep("Trigger background preview", () =>
|
AddStep("Trigger background preview", () =>
|
||||||
{
|
{
|
||||||
@ -106,16 +102,16 @@ namespace osu.Game.Tests.Visual
|
|||||||
InputManager.MoveMouseTo(playerLoader.VisualSettingsPos);
|
InputManager.MoveMouseTo(playerLoader.VisualSettingsPos);
|
||||||
});
|
});
|
||||||
waitForDim();
|
waitForDim();
|
||||||
AddAssert("Screen is dimmed", () => songSelect.IsBackgroundDimmed());
|
AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied());
|
||||||
AddStep("Stop background preview", () => InputManager.MoveMouseTo(playerLoader.ScreenPos));
|
AddStep("Stop background preview", () => InputManager.MoveMouseTo(playerLoader.ScreenPos));
|
||||||
waitForDim();
|
waitForDim();
|
||||||
AddAssert("Screen is undimmed", () => songSelect.IsBackgroundUndimmed());
|
AddAssert("Screen is undimmed and user blur removed", () => songSelect.IsBackgroundUndimmed() && playerLoader.IsBlurCorrect());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <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:
|
/// 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 trigger an undim unless checked for in PlayerLoader.
|
/// 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 is still properly applied after entering player.
|
/// We need to check that in this scenario, the dim and blur is still properly applied after entering player.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Test]
|
[Test]
|
||||||
public void PlayerLoaderTransitionTest()
|
public void PlayerLoaderTransitionTest()
|
||||||
@ -124,7 +120,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
AddStep("Trigger hover event", () => playerLoader.TriggerOnHover());
|
AddStep("Trigger hover event", () => playerLoader.TriggerOnHover());
|
||||||
AddAssert("Background retained from song select", () => songSelect.IsBackgroundCurrent());
|
AddAssert("Background retained from song select", () => songSelect.IsBackgroundCurrent());
|
||||||
waitForDim();
|
waitForDim();
|
||||||
AddAssert("Screen is dimmed and unblurred", () => songSelect.IsBackgroundDimmed() && songSelect.IsBackgroundUnblurred());
|
AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -165,24 +161,24 @@ namespace osu.Game.Tests.Visual
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check if the <see cref="UserDimContainer"/> is properly accepting user dim changes at all.
|
/// Check if the <see cref="UserDimContainer"/> is properly accepting user-defined visual changes at all.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Test]
|
[Test]
|
||||||
public void DisableUserDimTest()
|
public void DisableUserDimTest()
|
||||||
{
|
{
|
||||||
performFullSetup();
|
performFullSetup();
|
||||||
waitForDim();
|
waitForDim();
|
||||||
AddAssert("Screen is dimmed", () => songSelect.IsBackgroundDimmed());
|
AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied());
|
||||||
AddStep("EnableUserDim disabled", () => songSelect.DimEnabled.Value = false);
|
AddStep("EnableUserDim disabled", () => songSelect.DimEnabled.Value = false);
|
||||||
waitForDim();
|
waitForDim();
|
||||||
AddAssert("Screen is undimmed", () => songSelect.IsBackgroundUndimmed());
|
AddAssert("Screen is undimmed and user blur removed", () => songSelect.IsBackgroundUndimmed() && songSelect.IsUserBlurDisabled());
|
||||||
AddStep("EnableUserDim enabled", () => songSelect.DimEnabled.Value = true);
|
AddStep("EnableUserDim enabled", () => songSelect.DimEnabled.Value = true);
|
||||||
waitForDim();
|
waitForDim();
|
||||||
AddAssert("Screen is dimmed", () => songSelect.IsBackgroundDimmed());
|
AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check if the fade container retains dim when pausing
|
/// Check if the visual settings container retains dim and blur when pausing
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Test]
|
[Test]
|
||||||
public void PauseTest()
|
public void PauseTest()
|
||||||
@ -190,26 +186,29 @@ namespace osu.Game.Tests.Visual
|
|||||||
performFullSetup(true);
|
performFullSetup(true);
|
||||||
AddStep("Pause", () => player.CurrentPausableGameplayContainer.Pause());
|
AddStep("Pause", () => player.CurrentPausableGameplayContainer.Pause());
|
||||||
waitForDim();
|
waitForDim();
|
||||||
AddAssert("Screen is dimmed", () => songSelect.IsBackgroundDimmed());
|
AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied());
|
||||||
AddStep("Unpause", () => player.CurrentPausableGameplayContainer.Resume());
|
AddStep("Unpause", () => player.CurrentPausableGameplayContainer.Resume());
|
||||||
waitForDim();
|
waitForDim();
|
||||||
AddAssert("Screen is dimmed", () => songSelect.IsBackgroundDimmed());
|
AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check if the fade container removes user dim when suspending <see cref="Player"/> for <see cref="SoloResults"/>
|
/// Check if the visual settings container removes user dim when suspending <see cref="Player"/> for <see cref="SoloResults"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Test]
|
[Test]
|
||||||
public void TransitionTest()
|
public void TransitionTest()
|
||||||
{
|
{
|
||||||
performFullSetup();
|
performFullSetup();
|
||||||
AddStep("Transition to Results", () => player.Push(new FadeAccessibleResults(new ScoreInfo { User = new User { Username = "osu!" } })));
|
var results = new FadeAccessibleResults(new ScoreInfo { User = new User { Username = "osu!" } });
|
||||||
|
AddStep("Transition to Results", () => player.Push(results));
|
||||||
|
AddUntilStep("Wait for results is current", results.IsCurrentScreen);
|
||||||
waitForDim();
|
waitForDim();
|
||||||
AddAssert("Screen is undimmed and is original background", () => songSelect.IsBackgroundUndimmed() && songSelect.IsBackgroundCurrent());
|
AddAssert("Screen is undimmed, original background retained", () =>
|
||||||
|
songSelect.IsBackgroundUndimmed() && songSelect.IsBackgroundCurrent() && results.IsBlurCorrect());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check if background gets undimmed when leaving <see cref="Player"/> for <see cref="PlaySongSelect"/>
|
/// Check if background gets undimmed and unblurred when leaving <see cref="Player"/> for <see cref="PlaySongSelect"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Test]
|
[Test]
|
||||||
public void TransitionOutTest()
|
public void TransitionOutTest()
|
||||||
@ -217,10 +216,26 @@ namespace osu.Game.Tests.Visual
|
|||||||
performFullSetup();
|
performFullSetup();
|
||||||
AddStep("Exit to song select", () => player.Exit());
|
AddStep("Exit to song select", () => player.Exit());
|
||||||
waitForDim();
|
waitForDim();
|
||||||
AddAssert("Screen is undimmed", () => songSelect.IsBackgroundUndimmed());
|
AddAssert("Screen is undimmed and user blur removed", () => songSelect.IsBackgroundUndimmed() && songSelect.IsBlurCorrect());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void waitForDim() => AddWaitStep(5, "Wait for dim");
|
/// <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", () =>
|
private void createFakeStoryboard() => AddStep("Create storyboard", () =>
|
||||||
{
|
{
|
||||||
@ -243,25 +258,25 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
AddStep("Start player loader", () =>
|
AddStep("Start player loader", () =>
|
||||||
{
|
{
|
||||||
songSelect.Push(playerLoader = new DimAccessiblePlayerLoader(player = new DimAccessiblePlayer
|
songSelect.Push(playerLoader = new TestPlayerLoader(player = new TestPlayer
|
||||||
{
|
{
|
||||||
AllowPause = allowPause,
|
AllowPause = allowPause,
|
||||||
Ready = true,
|
Ready = true,
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
AddUntilStep(() => playerLoader.IsLoaded, "Wait for Player Loader to load");
|
AddUntilStep("Wait for Player Loader to load", () => playerLoader.IsLoaded);
|
||||||
AddStep("Move mouse to center of screen", () => InputManager.MoveMouseTo(playerLoader.ScreenPos));
|
AddStep("Move mouse to center of screen", () => InputManager.MoveMouseTo(playerLoader.ScreenPos));
|
||||||
AddUntilStep(() => player.IsLoaded, "Wait for player to load");
|
AddUntilStep("Wait for player to load", () => player.IsLoaded);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupUserSettings()
|
private void setupUserSettings()
|
||||||
{
|
{
|
||||||
AddUntilStep(() => songSelect.Carousel.SelectedBeatmap != null, "Song select has selection");
|
AddUntilStep("Song select has selection", () => songSelect.Carousel.SelectedBeatmap != null);
|
||||||
AddStep("Set default user settings", () =>
|
AddStep("Set default user settings", () =>
|
||||||
{
|
{
|
||||||
Beatmap.Value.Mods.Value = Beatmap.Value.Mods.Value.Concat(new[] { new OsuModNoFail() });
|
Beatmap.Value.Mods.Value = Beatmap.Value.Mods.Value.Concat(new[] { new OsuModNoFail() });
|
||||||
songSelect.DimLevel.Value = 0.7f;
|
songSelect.DimLevel.Value = 0.7f;
|
||||||
songSelect.BlurLevel.Value = 0.0f;
|
songSelect.BlurLevel.Value = 0.4f;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,14 +304,18 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
public bool IsBackgroundDimmed() => ((FadeAccessibleBackground)Background).CurrentColour == OsuColour.Gray(1 - (float)DimLevel.Value);
|
public bool IsBackgroundDimmed() => ((FadeAccessibleBackground)Background).CurrentColour == OsuColour.Gray(1 - (float)DimLevel.Value);
|
||||||
|
|
||||||
public bool IsBackgroundUnblurred() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2(0);
|
|
||||||
|
|
||||||
public bool IsBackgroundUndimmed() => ((FadeAccessibleBackground)Background).CurrentColour == Color4.White;
|
public bool IsBackgroundUndimmed() => ((FadeAccessibleBackground)Background).CurrentColour == Color4.White;
|
||||||
|
|
||||||
|
public bool IsUserBlurApplied() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2((float)BlurLevel.Value * 25);
|
||||||
|
|
||||||
|
public bool IsUserBlurDisabled() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2(0);
|
||||||
|
|
||||||
public bool IsBackgroundInvisible() => ((FadeAccessibleBackground)Background).CurrentAlpha == 0;
|
public bool IsBackgroundInvisible() => ((FadeAccessibleBackground)Background).CurrentAlpha == 0;
|
||||||
|
|
||||||
public bool IsBackgroundVisible() => ((FadeAccessibleBackground)Background).CurrentAlpha == 1;
|
public bool IsBackgroundVisible() => ((FadeAccessibleBackground)Background).CurrentAlpha == 1;
|
||||||
|
|
||||||
|
public bool IsBlurCorrect() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2(BACKGROUND_BLUR);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Make sure every time a screen gets pushed, the background doesn't get replaced
|
/// Make sure every time a screen gets pushed, the background doesn't get replaced
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -312,9 +331,11 @@ namespace osu.Game.Tests.Visual
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value);
|
protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value);
|
||||||
|
|
||||||
|
public bool IsBlurCorrect() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2(BACKGROUND_BLUR);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class DimAccessiblePlayer : Player
|
private class TestPlayer : Player
|
||||||
{
|
{
|
||||||
protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value);
|
protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value);
|
||||||
|
|
||||||
@ -350,7 +371,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
Thread.Sleep(1);
|
Thread.Sleep(1);
|
||||||
StoryboardEnabled = config.GetBindable<bool>(OsuSetting.ShowStoryboard);
|
StoryboardEnabled = config.GetBindable<bool>(OsuSetting.ShowStoryboard);
|
||||||
ReplacesBackground.BindTo(Background.StoryboardReplacesBackground);
|
ReplacesBackground.BindTo(Background.StoryboardReplacesBackground);
|
||||||
RulesetContainer.IsPaused.BindTo(IsPaused);
|
DrawableRuleset.IsPaused.BindTo(IsPaused);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -368,18 +389,20 @@ namespace osu.Game.Tests.Visual
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class DimAccessiblePlayerLoader : PlayerLoader
|
private class TestPlayerLoader : PlayerLoader
|
||||||
{
|
{
|
||||||
public VisualSettings VisualSettingsPos => VisualSettings;
|
public VisualSettings VisualSettingsPos => VisualSettings;
|
||||||
public BackgroundScreen ScreenPos => Background;
|
public BackgroundScreen ScreenPos => Background;
|
||||||
|
|
||||||
public DimAccessiblePlayerLoader(Player player)
|
public TestPlayerLoader(Player player)
|
||||||
: base(() => player)
|
: base(() => player)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TriggerOnHover() => OnHover(new HoverEvent(new InputState()));
|
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);
|
protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -388,6 +411,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
protected override UserDimContainer CreateFadeContainer() => fadeContainer = new TestUserDimContainer { RelativeSizeAxes = Axes.Both };
|
protected override UserDimContainer CreateFadeContainer() => fadeContainer = new TestUserDimContainer { RelativeSizeAxes = Axes.Both };
|
||||||
|
|
||||||
public Color4 CurrentColour => fadeContainer.CurrentColour;
|
public Color4 CurrentColour => fadeContainer.CurrentColour;
|
||||||
|
|
||||||
public float CurrentAlpha => fadeContainer.CurrentAlpha;
|
public float CurrentAlpha => fadeContainer.CurrentAlpha;
|
||||||
|
|
||||||
public Vector2 CurrentBlur => Background.BlurSigma;
|
public Vector2 CurrentBlur => Background.BlurSigma;
|
||||||
|
@ -87,7 +87,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
carousel.BeatmapSetsChanged = () => changed = true;
|
carousel.BeatmapSetsChanged = () => changed = true;
|
||||||
carousel.BeatmapSets = beatmapSets;
|
carousel.BeatmapSets = beatmapSets;
|
||||||
});
|
});
|
||||||
AddUntilStep(() => changed, "Wait for load");
|
AddUntilStep("Wait for load", () => changed);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ensureRandomFetchSuccess() =>
|
private void ensureRandomFetchSuccess() =>
|
||||||
@ -214,7 +214,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
checkSelected(3, 2);
|
checkSelected(3, 2);
|
||||||
|
|
||||||
AddStep("Un-filter (debounce)", () => carousel.Filter(new FilterCriteria()));
|
AddStep("Un-filter (debounce)", () => carousel.Filter(new FilterCriteria()));
|
||||||
AddUntilStep(() => !carousel.PendingFilterTask, "Wait for debounce");
|
AddUntilStep("Wait for debounce", () => !carousel.PendingFilterTask);
|
||||||
checkVisibleItemCount(diff: false, count: set_count);
|
checkVisibleItemCount(diff: false, count: set_count);
|
||||||
checkVisibleItemCount(diff: true, count: 3);
|
checkVisibleItemCount(diff: true, count: 3);
|
||||||
|
|
||||||
@ -327,13 +327,13 @@ namespace osu.Game.Tests.Visual
|
|||||||
AddStep("Remove first", () => carousel.RemoveBeatmapSet(carousel.BeatmapSets.First()));
|
AddStep("Remove first", () => carousel.RemoveBeatmapSet(carousel.BeatmapSets.First()));
|
||||||
checkSelected(1);
|
checkSelected(1);
|
||||||
|
|
||||||
AddUntilStep(() =>
|
AddUntilStep("Remove all", () =>
|
||||||
{
|
{
|
||||||
if (!carousel.BeatmapSets.Any()) return true;
|
if (!carousel.BeatmapSets.Any()) return true;
|
||||||
|
|
||||||
carousel.RemoveBeatmapSet(carousel.BeatmapSets.Last());
|
carousel.RemoveBeatmapSet(carousel.BeatmapSets.Last());
|
||||||
return false;
|
return false;
|
||||||
}, "Remove all");
|
});
|
||||||
|
|
||||||
checkNoSelection();
|
checkNoSelection();
|
||||||
}
|
}
|
||||||
|
@ -56,11 +56,11 @@ namespace osu.Game.Tests.Visual
|
|||||||
// select part is redundant, but wait for load isn't
|
// select part is redundant, but wait for load isn't
|
||||||
selectBeatmap(Beatmap.Value.Beatmap);
|
selectBeatmap(Beatmap.Value.Beatmap);
|
||||||
|
|
||||||
AddWaitStep(3);
|
AddWaitStep("wait for select", 3);
|
||||||
|
|
||||||
AddStep("hide", () => { infoWedge.State = Visibility.Hidden; });
|
AddStep("hide", () => { infoWedge.State = Visibility.Hidden; });
|
||||||
|
|
||||||
AddWaitStep(3);
|
AddWaitStep("wait for hide", 3);
|
||||||
|
|
||||||
AddStep("show", () => { infoWedge.State = Visibility.Visible; });
|
AddStep("show", () => { infoWedge.State = Visibility.Visible; });
|
||||||
|
|
||||||
@ -135,7 +135,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
infoWedge.Beatmap = Beatmap.Value = b == null ? Beatmap.Default : new TestWorkingBeatmap(b);
|
infoWedge.Beatmap = Beatmap.Value = b == null ? Beatmap.Default : new TestWorkingBeatmap(b);
|
||||||
});
|
});
|
||||||
|
|
||||||
AddUntilStep(() => infoWedge.Info != infoBefore, "wait for async load");
|
AddUntilStep("wait for async load", () => infoWedge.Info != infoBefore);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IBeatmap createTestBeatmap(RulesetInfo ruleset)
|
private IBeatmap createTestBeatmap(RulesetInfo ruleset)
|
||||||
|
@ -90,7 +90,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
AddStep("set second channel", () => channelTabControl.Current.Value = channelTabControl.Items.Skip(1).First());
|
AddStep("set second channel", () => channelTabControl.Current.Value = channelTabControl.Items.Skip(1).First());
|
||||||
AddAssert("selector tab is inactive", () => !channelTabControl.ChannelSelectorActive.Value);
|
AddAssert("selector tab is inactive", () => !channelTabControl.ChannelSelectorActive.Value);
|
||||||
|
|
||||||
AddUntilStep(() =>
|
AddUntilStep("remove all channels", () =>
|
||||||
{
|
{
|
||||||
var first = channelTabControl.Items.First();
|
var first = channelTabControl.Items.First();
|
||||||
if (first.Name == "+")
|
if (first.Name == "+")
|
||||||
@ -98,7 +98,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
channelTabControl.RemoveChannel(first);
|
channelTabControl.RemoveChannel(first);
|
||||||
return false;
|
return false;
|
||||||
}, "remove all channels");
|
});
|
||||||
|
|
||||||
AddAssert("selector tab is active", () => channelTabControl.ChannelSelectorActive.Value);
|
AddAssert("selector tab is active", () => channelTabControl.ChannelSelectorActive.Value);
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
Scheduler.AddDelayed(() => newLine.Message = new DummyMessage(completeText ?? text), delay);
|
Scheduler.AddDelayed(() => newLine.Message = new DummyMessage(completeText ?? text), delay);
|
||||||
});
|
});
|
||||||
|
|
||||||
AddUntilStep(() => textContainer.All(line => line.Message is DummyMessage), $"wait for msg #{echoCounter}");
|
AddUntilStep($"wait for msg #{echoCounter}", () => textContainer.All(line => line.Message is DummyMessage));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,16 +2,31 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Screens.Menu;
|
using osu.Game.Screens.Menu;
|
||||||
|
using osu.Game.Users;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual
|
namespace osu.Game.Tests.Visual
|
||||||
{
|
{
|
||||||
public class TestCaseDisclaimer : ScreenTestCase
|
public class TestCaseDisclaimer : ScreenTestCase
|
||||||
{
|
{
|
||||||
|
[Cached(typeof(IAPIProvider))]
|
||||||
|
private readonly DummyAPIAccess api = new DummyAPIAccess();
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
LoadScreen(new Disclaimer());
|
AddStep("load disclaimer", () => LoadScreen(new Disclaimer()));
|
||||||
|
|
||||||
|
AddStep("toggle support", () =>
|
||||||
|
{
|
||||||
|
api.LocalUser.Value = new User
|
||||||
|
{
|
||||||
|
Username = api.LocalUser.Value.Username,
|
||||||
|
Id = api.LocalUser.Value.Id,
|
||||||
|
IsSupporter = !api.LocalUser.Value.IsSupporter,
|
||||||
|
};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,9 +32,9 @@ namespace osu.Game.Tests.Visual
|
|||||||
var text = holdForMenuButton.Children.OfType<SpriteText>().First();
|
var text = holdForMenuButton.Children.OfType<SpriteText>().First();
|
||||||
|
|
||||||
AddStep("Trigger text fade in", () => InputManager.MoveMouseTo(holdForMenuButton));
|
AddStep("Trigger text fade in", () => InputManager.MoveMouseTo(holdForMenuButton));
|
||||||
AddUntilStep(() => text.IsPresent && !exitAction, "Text visible");
|
AddUntilStep("Text visible", () => text.IsPresent && !exitAction);
|
||||||
AddStep("Trigger text fade out", () => InputManager.MoveMouseTo(Vector2.One));
|
AddStep("Trigger text fade out", () => InputManager.MoveMouseTo(Vector2.One));
|
||||||
AddUntilStep(() => !text.IsPresent && !exitAction, "Text is not visible");
|
AddUntilStep("Text is not visible", () => !text.IsPresent && !exitAction);
|
||||||
|
|
||||||
AddStep("Trigger exit action", () =>
|
AddStep("Trigger exit action", () =>
|
||||||
{
|
{
|
||||||
@ -47,7 +47,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
AddAssert("action not triggered", () => !exitAction);
|
AddAssert("action not triggered", () => !exitAction);
|
||||||
|
|
||||||
AddStep("Trigger exit action", () => InputManager.PressButton(MouseButton.Left));
|
AddStep("Trigger exit action", () => InputManager.PressButton(MouseButton.Left));
|
||||||
AddUntilStep(() => exitAction, $"{nameof(holdForMenuButton.Action)} was triggered");
|
AddUntilStep($"{nameof(holdForMenuButton.Action)} was triggered", () => exitAction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
AddStep("start confirming", () => overlay.Begin());
|
AddStep("start confirming", () => overlay.Begin());
|
||||||
|
|
||||||
AddUntilStep(() => fired, "wait until confirmed");
|
AddUntilStep("wait until confirmed", () => fired);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TestHoldToConfirmOverlay : ExitConfirmOverlay
|
private class TestHoldToConfirmOverlay : ExitConfirmOverlay
|
||||||
|
@ -59,7 +59,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
{
|
{
|
||||||
AddStep("move mouse to top left", () => InputManager.MoveMouseTo(box1.ScreenSpaceDrawQuad.Centre));
|
AddStep("move mouse to top left", () => InputManager.MoveMouseTo(box1.ScreenSpaceDrawQuad.Centre));
|
||||||
|
|
||||||
AddUntilStep(() => box1.IsIdle && box2.IsIdle && box3.IsIdle && box4.IsIdle, "Wait for all idle");
|
AddUntilStep("Wait for all idle", () => box1.IsIdle && box2.IsIdle && box3.IsIdle && box4.IsIdle);
|
||||||
|
|
||||||
AddStep("nudge mouse", () => InputManager.MoveMouseTo(box1.ScreenSpaceDrawQuad.Centre + new Vector2(1)));
|
AddStep("nudge mouse", () => InputManager.MoveMouseTo(box1.ScreenSpaceDrawQuad.Centre + new Vector2(1)));
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
AddAssert("check idle", () => !box3.IsIdle);
|
AddAssert("check idle", () => !box3.IsIdle);
|
||||||
AddAssert("check idle", () => !box4.IsIdle);
|
AddAssert("check idle", () => !box4.IsIdle);
|
||||||
|
|
||||||
AddUntilStep(() => box1.IsIdle && box2.IsIdle && box3.IsIdle && box4.IsIdle, "Wait for all idle");
|
AddUntilStep("Wait for all idle", () => box1.IsIdle && box2.IsIdle && box3.IsIdle && box4.IsIdle);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -96,13 +96,13 @@ namespace osu.Game.Tests.Visual
|
|||||||
AddStep("move mouse", () => InputManager.MoveMouseTo(ScreenSpaceDrawQuad.Centre));
|
AddStep("move mouse", () => InputManager.MoveMouseTo(ScreenSpaceDrawQuad.Centre));
|
||||||
|
|
||||||
AddAssert("check not idle", () => !box1.IsIdle && !box2.IsIdle && !box3.IsIdle && !box4.IsIdle);
|
AddAssert("check not idle", () => !box1.IsIdle && !box2.IsIdle && !box3.IsIdle && !box4.IsIdle);
|
||||||
AddUntilStep(() => box1.IsIdle, "Wait for idle");
|
AddUntilStep("Wait for idle", () => box1.IsIdle);
|
||||||
AddAssert("check not idle", () => !box2.IsIdle && !box3.IsIdle && !box4.IsIdle);
|
AddAssert("check not idle", () => !box2.IsIdle && !box3.IsIdle && !box4.IsIdle);
|
||||||
AddUntilStep(() => box2.IsIdle, "Wait for idle");
|
AddUntilStep("Wait for idle", () => box2.IsIdle);
|
||||||
AddAssert("check not idle", () => !box3.IsIdle && !box4.IsIdle);
|
AddAssert("check not idle", () => !box3.IsIdle && !box4.IsIdle);
|
||||||
AddUntilStep(() => box3.IsIdle, "Wait for idle");
|
AddUntilStep("Wait for idle", () => box3.IsIdle);
|
||||||
|
|
||||||
AddUntilStep(() => box1.IsIdle && box2.IsIdle && box3.IsIdle && box4.IsIdle, "Wait for all idle");
|
AddUntilStep("Wait for all idle", () => box1.IsIdle && box2.IsIdle && box3.IsIdle && box4.IsIdle);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class IdleTrackingBox : CompositeDrawable
|
private class IdleTrackingBox : CompositeDrawable
|
||||||
|
@ -25,30 +25,30 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
bool logoVisible = false;
|
bool logoVisible = false;
|
||||||
AddStep("almost instant display", () => Child = loader = new TestLoader(250));
|
AddStep("almost instant display", () => Child = loader = new TestLoader(250));
|
||||||
AddUntilStep(() =>
|
AddUntilStep("loaded", () =>
|
||||||
{
|
{
|
||||||
logoVisible = loader.Logo?.Alpha > 0;
|
logoVisible = loader.Logo?.Alpha > 0;
|
||||||
return loader.Logo != null && loader.ScreenLoaded;
|
return loader.Logo != null && loader.ScreenLoaded;
|
||||||
}, "loaded");
|
});
|
||||||
AddAssert("logo not visible", () => !logoVisible);
|
AddAssert("logo not visible", () => !logoVisible);
|
||||||
|
|
||||||
AddStep("short load", () => Child = loader = new TestLoader(800));
|
AddStep("short load", () => Child = loader = new TestLoader(800));
|
||||||
AddUntilStep(() =>
|
AddUntilStep("loaded", () =>
|
||||||
{
|
{
|
||||||
logoVisible = loader.Logo?.Alpha > 0;
|
logoVisible = loader.Logo?.Alpha > 0;
|
||||||
return loader.Logo != null && loader.ScreenLoaded;
|
return loader.Logo != null && loader.ScreenLoaded;
|
||||||
}, "loaded");
|
});
|
||||||
AddAssert("logo visible", () => logoVisible);
|
AddAssert("logo visible", () => logoVisible);
|
||||||
AddUntilStep(() => loader.Logo?.Alpha == 0, "logo gone");
|
AddUntilStep("logo gone", () => loader.Logo?.Alpha == 0);
|
||||||
|
|
||||||
AddStep("longer load", () => Child = loader = new TestLoader(1400));
|
AddStep("longer load", () => Child = loader = new TestLoader(1400));
|
||||||
AddUntilStep(() =>
|
AddUntilStep("loaded", () =>
|
||||||
{
|
{
|
||||||
logoVisible = loader.Logo?.Alpha > 0;
|
logoVisible = loader.Logo?.Alpha > 0;
|
||||||
return loader.Logo != null && loader.ScreenLoaded;
|
return loader.Logo != null && loader.ScreenLoaded;
|
||||||
}, "loaded");
|
});
|
||||||
AddAssert("logo visible", () => logoVisible);
|
AddAssert("logo visible", () => logoVisible);
|
||||||
AddUntilStep(() => loader.Logo?.Alpha == 0, "logo gone");
|
AddUntilStep("logo gone", () => loader.Logo?.Alpha == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TestLoader : Loader
|
private class TestLoader : Loader
|
||||||
|
@ -28,7 +28,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private APIAccess api { get; set; }
|
private IAPIProvider api { get; set; }
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
|
@ -111,7 +111,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
settings.ApplyButton.Action.Invoke();
|
settings.ApplyButton.Action.Invoke();
|
||||||
});
|
});
|
||||||
|
|
||||||
AddUntilStep(() => !settings.ErrorText.IsPresent, "error not displayed");
|
AddUntilStep("error not displayed", () => !settings.ErrorText.IsPresent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TestRoomSettings : MatchSettingsOverlay
|
private class TestRoomSettings : MatchSettingsOverlay
|
||||||
|
@ -208,22 +208,22 @@ namespace osu.Game.Tests.Visual
|
|||||||
{
|
{
|
||||||
checkLabelColor(Color4.White);
|
checkLabelColor(Color4.White);
|
||||||
selectNext(mod);
|
selectNext(mod);
|
||||||
AddWaitStep(1, "wait for changing colour");
|
AddWaitStep("wait for changing colour", 1);
|
||||||
checkLabelColor(colour);
|
checkLabelColor(colour);
|
||||||
selectPrevious(mod);
|
selectPrevious(mod);
|
||||||
AddWaitStep(1, "wait for changing colour");
|
AddWaitStep("wait for changing colour", 1);
|
||||||
checkLabelColor(Color4.White);
|
checkLabelColor(Color4.White);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testRankedText(Mod mod)
|
private void testRankedText(Mod mod)
|
||||||
{
|
{
|
||||||
AddWaitStep(1, "wait for fade");
|
AddWaitStep("wait for fade", 1);
|
||||||
AddAssert("check for ranked", () => modSelect.UnrankedLabel.Alpha == 0);
|
AddAssert("check for ranked", () => modSelect.UnrankedLabel.Alpha == 0);
|
||||||
selectNext(mod);
|
selectNext(mod);
|
||||||
AddWaitStep(1, "wait for fade");
|
AddWaitStep("wait for fade", 1);
|
||||||
AddAssert("check for unranked", () => modSelect.UnrankedLabel.Alpha != 0);
|
AddAssert("check for unranked", () => modSelect.UnrankedLabel.Alpha != 0);
|
||||||
selectPrevious(mod);
|
selectPrevious(mod);
|
||||||
AddWaitStep(1, "wait for fade");
|
AddWaitStep("wait for fade", 1);
|
||||||
AddAssert("check for ranked", () => modSelect.UnrankedLabel.Alpha == 0);
|
AddAssert("check for ranked", () => modSelect.UnrankedLabel.Alpha == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
setState(Visibility.Hidden);
|
setState(Visibility.Hidden);
|
||||||
|
|
||||||
AddRepeatStep(@"add many simple", sendManyNotifications, 3);
|
AddRepeatStep(@"add many simple", sendManyNotifications, 3);
|
||||||
AddWaitStep(5);
|
AddWaitStep("wait some", 5);
|
||||||
|
|
||||||
checkProgressingCount(0);
|
checkProgressingCount(0);
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
AddAssert("Displayed count is 33", () => manager.UnreadCount.Value == 33);
|
AddAssert("Displayed count is 33", () => manager.UnreadCount.Value == 33);
|
||||||
|
|
||||||
AddWaitStep(10);
|
AddWaitStep("wait some", 10);
|
||||||
|
|
||||||
checkProgressingCount(0);
|
checkProgressingCount(0);
|
||||||
|
|
||||||
|
@ -112,10 +112,10 @@ namespace osu.Game.Tests.Visual
|
|||||||
createSongSelect();
|
createSongSelect();
|
||||||
AddAssert("dummy selected", () => songSelect.CurrentBeatmap == defaultBeatmap);
|
AddAssert("dummy selected", () => songSelect.CurrentBeatmap == defaultBeatmap);
|
||||||
|
|
||||||
AddUntilStep(() => songSelect.CurrentBeatmapDetailsBeatmap == defaultBeatmap, "dummy shown on wedge");
|
AddUntilStep("dummy shown on wedge", () => songSelect.CurrentBeatmapDetailsBeatmap == defaultBeatmap);
|
||||||
|
|
||||||
addManyTestMaps();
|
addManyTestMaps();
|
||||||
AddWaitStep(3);
|
AddWaitStep("wait for select", 3);
|
||||||
|
|
||||||
AddAssert("random map selected", () => songSelect.CurrentBeatmap != defaultBeatmap);
|
AddAssert("random map selected", () => songSelect.CurrentBeatmap != defaultBeatmap);
|
||||||
}
|
}
|
||||||
@ -125,7 +125,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
{
|
{
|
||||||
createSongSelect();
|
createSongSelect();
|
||||||
addManyTestMaps();
|
addManyTestMaps();
|
||||||
AddWaitStep(3);
|
AddWaitStep("wait for add", 3);
|
||||||
|
|
||||||
AddAssert("random map selected", () => songSelect.CurrentBeatmap != defaultBeatmap);
|
AddAssert("random map selected", () => songSelect.CurrentBeatmap != defaultBeatmap);
|
||||||
|
|
||||||
@ -142,7 +142,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
createSongSelect();
|
createSongSelect();
|
||||||
changeRuleset(2);
|
changeRuleset(2);
|
||||||
importForRuleset(0);
|
importForRuleset(0);
|
||||||
AddUntilStep(() => songSelect.Carousel.SelectedBeatmap == null, "no selection");
|
AddUntilStep("no selection", () => songSelect.Carousel.SelectedBeatmap == null);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -152,13 +152,13 @@ namespace osu.Game.Tests.Visual
|
|||||||
changeRuleset(2);
|
changeRuleset(2);
|
||||||
importForRuleset(2);
|
importForRuleset(2);
|
||||||
importForRuleset(1);
|
importForRuleset(1);
|
||||||
AddUntilStep(() => songSelect.Carousel.SelectedBeatmap.RulesetID == 2, "has selection");
|
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmap.RulesetID == 2);
|
||||||
|
|
||||||
changeRuleset(1);
|
changeRuleset(1);
|
||||||
AddUntilStep(() => songSelect.Carousel.SelectedBeatmap.RulesetID == 1, "has selection");
|
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmap.RulesetID == 1);
|
||||||
|
|
||||||
changeRuleset(0);
|
changeRuleset(0);
|
||||||
AddUntilStep(() => songSelect.Carousel.SelectedBeatmap == null, "no selection");
|
AddUntilStep("no selection", () => songSelect.Carousel.SelectedBeatmap == null);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -196,7 +196,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
{
|
{
|
||||||
createSongSelect();
|
createSongSelect();
|
||||||
addManyTestMaps();
|
addManyTestMaps();
|
||||||
AddUntilStep(() => songSelect.Carousel.SelectedBeatmap != null, "has selection");
|
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmap != null);
|
||||||
|
|
||||||
bool startRequested = false;
|
bool startRequested = false;
|
||||||
|
|
||||||
@ -225,7 +225,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
private void createSongSelect()
|
private void createSongSelect()
|
||||||
{
|
{
|
||||||
AddStep("create song select", () => LoadScreen(songSelect = new TestSongSelect()));
|
AddStep("create song select", () => LoadScreen(songSelect = new TestSongSelect()));
|
||||||
AddUntilStep(() => songSelect.IsCurrentScreen(), "wait for present");
|
AddUntilStep("wait for present", () => songSelect.IsCurrentScreen());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addManyTestMaps()
|
private void addManyTestMaps()
|
||||||
|
@ -37,15 +37,15 @@ namespace osu.Game.Tests.Visual
|
|||||||
AllowResults = false,
|
AllowResults = false,
|
||||||
})));
|
})));
|
||||||
|
|
||||||
AddUntilStep(() => loader.IsCurrentScreen(), "wait for current");
|
AddUntilStep("wait for current", () => loader.IsCurrentScreen());
|
||||||
|
|
||||||
AddStep("mouse in centre", () => InputManager.MoveMouseTo(loader.ScreenSpaceDrawQuad.Centre));
|
AddStep("mouse in centre", () => InputManager.MoveMouseTo(loader.ScreenSpaceDrawQuad.Centre));
|
||||||
|
|
||||||
AddUntilStep(() => !loader.IsCurrentScreen(), "wait for no longer current");
|
AddUntilStep("wait for no longer current", () => !loader.IsCurrentScreen());
|
||||||
|
|
||||||
AddStep("exit loader", () => loader.Exit());
|
AddStep("exit loader", () => loader.Exit());
|
||||||
|
|
||||||
AddUntilStep(() => !loader.IsAlive, "wait for no longer alive");
|
AddUntilStep("wait for no longer alive", () => !loader.IsAlive);
|
||||||
|
|
||||||
AddStep("load slow dummy beatmap", () =>
|
AddStep("load slow dummy beatmap", () =>
|
||||||
{
|
{
|
||||||
@ -61,7 +61,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
Scheduler.AddDelayed(() => slow.Ready = true, 5000);
|
Scheduler.AddDelayed(() => slow.Ready = true, 5000);
|
||||||
});
|
});
|
||||||
|
|
||||||
AddUntilStep(() => !loader.IsCurrentScreen(), "wait for no longer current");
|
AddUntilStep("wait for no longer current", () => !loader.IsCurrentScreen());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class SlowLoadPlayer : Player
|
protected class SlowLoadPlayer : Player
|
||||||
|
56
osu.Game.Tests/Visual/TestCasePlayerReferenceLeaking.cs
Normal file
56
osu.Game.Tests/Visual/TestCasePlayerReferenceLeaking.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 System;
|
||||||
|
using osu.Framework.Lists;
|
||||||
|
using osu.Framework.Timing;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Rulesets;
|
||||||
|
using osu.Game.Screens.Play;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual
|
||||||
|
{
|
||||||
|
public class TestCasePlayerReferenceLeaking : AllPlayersTestCase
|
||||||
|
{
|
||||||
|
private readonly WeakList<WorkingBeatmap> workingWeakReferences = new WeakList<WorkingBeatmap>();
|
||||||
|
|
||||||
|
private readonly WeakList<Player> playerWeakReferences = new WeakList<Player>();
|
||||||
|
|
||||||
|
protected override void AddCheckSteps()
|
||||||
|
{
|
||||||
|
AddUntilStep("no leaked beatmaps", () =>
|
||||||
|
{
|
||||||
|
GC.Collect();
|
||||||
|
GC.WaitForPendingFinalizers();
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
workingWeakReferences.ForEachAlive(_ => count++);
|
||||||
|
return count == 1;
|
||||||
|
});
|
||||||
|
|
||||||
|
AddUntilStep("no leaked players", () =>
|
||||||
|
{
|
||||||
|
GC.Collect();
|
||||||
|
GC.WaitForPendingFinalizers();
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
playerWeakReferences.ForEachAlive(_ => count++);
|
||||||
|
return count == 1;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, IFrameBasedClock clock)
|
||||||
|
{
|
||||||
|
var working = base.CreateWorkingBeatmap(beatmap, clock);
|
||||||
|
workingWeakReferences.Add(working);
|
||||||
|
return working;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override Player CreatePlayer(Ruleset ruleset)
|
||||||
|
{
|
||||||
|
var player = base.CreatePlayer(ruleset);
|
||||||
|
playerWeakReferences.Add(player);
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
@ -12,7 +11,7 @@ using osu.Game.Screens.Play;
|
|||||||
namespace osu.Game.Tests.Visual
|
namespace osu.Game.Tests.Visual
|
||||||
{
|
{
|
||||||
[Description("Player instantiated with a replay.")]
|
[Description("Player instantiated with a replay.")]
|
||||||
public class TestCaseReplay : TestCasePlayer
|
public class TestCaseReplay : AllPlayersTestCase
|
||||||
{
|
{
|
||||||
protected override Player CreatePlayer(Ruleset ruleset)
|
protected override Player CreatePlayer(Ruleset ruleset)
|
||||||
{
|
{
|
||||||
@ -21,11 +20,10 @@ namespace osu.Game.Tests.Visual
|
|||||||
return new ScoreAccessibleReplayPlayer(ruleset.GetAutoplayMod().CreateReplayScore(beatmap));
|
return new ScoreAccessibleReplayPlayer(ruleset.GetAutoplayMod().CreateReplayScore(beatmap));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void AddCheckSteps(Func<Player> player)
|
protected override void AddCheckSteps()
|
||||||
{
|
{
|
||||||
base.AddCheckSteps(player);
|
AddUntilStep("score above zero", () => ((ScoreAccessibleReplayPlayer)Player).ScoreProcessor.TotalScore.Value > 0);
|
||||||
AddUntilStep(() => ((ScoreAccessibleReplayPlayer)player()).ScoreProcessor.TotalScore.Value > 0, "score above zero");
|
AddUntilStep("key counter counted keys", () => ((ScoreAccessibleReplayPlayer)Player).HUDOverlay.KeyCounter.Children.Any(kc => kc.CountPresses > 0));
|
||||||
AddUntilStep(() => ((ScoreAccessibleReplayPlayer)player()).HUDOverlay.KeyCounter.Children.Any(kc => kc.CountPresses > 0), "key counter counted keys");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ScoreAccessibleReplayPlayer : ReplayPlayer
|
private class ScoreAccessibleReplayPlayer : ReplayPlayer
|
||||||
|
@ -74,7 +74,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void pushNext() => AddStep(@"push next screen", () => ((TestScreen)screenStack.CurrentScreen).PushNext());
|
private void pushNext() => AddStep(@"push next screen", () => ((TestScreen)screenStack.CurrentScreen).PushNext());
|
||||||
private void waitForCurrent() => AddUntilStep(() => screenStack.CurrentScreen.IsCurrentScreen(), "current screen");
|
private void waitForCurrent() => AddUntilStep("current screen", () => screenStack.CurrentScreen.IsCurrentScreen());
|
||||||
|
|
||||||
private abstract class TestScreen : OsuScreen
|
private abstract class TestScreen : OsuScreen
|
||||||
{
|
{
|
||||||
|
@ -46,23 +46,23 @@ namespace osu.Game.Tests.Visual
|
|||||||
Origin = Anchor.TopLeft,
|
Origin = Anchor.TopLeft,
|
||||||
});
|
});
|
||||||
|
|
||||||
AddWaitStep(5);
|
AddWaitStep("wait some", 5);
|
||||||
AddAssert("ensure not created", () => graph.CreationCount == 0);
|
AddAssert("ensure not created", () => graph.CreationCount == 0);
|
||||||
|
|
||||||
AddStep("display values", displayNewValues);
|
AddStep("display values", displayNewValues);
|
||||||
AddWaitStep(5);
|
AddWaitStep("wait some", 5);
|
||||||
AddUntilStep(() => graph.CreationCount == 1, "wait for creation count");
|
AddUntilStep("wait for creation count", () => graph.CreationCount == 1);
|
||||||
|
|
||||||
AddStep("Toggle Bar", () => progress.AllowSeeking = !progress.AllowSeeking);
|
AddStep("Toggle Bar", () => progress.AllowSeeking = !progress.AllowSeeking);
|
||||||
AddWaitStep(5);
|
AddWaitStep("wait some", 5);
|
||||||
AddUntilStep(() => graph.CreationCount == 1, "wait for creation count");
|
AddUntilStep("wait for creation count", () => graph.CreationCount == 1);
|
||||||
|
|
||||||
AddStep("Toggle Bar", () => progress.AllowSeeking = !progress.AllowSeeking);
|
AddStep("Toggle Bar", () => progress.AllowSeeking = !progress.AllowSeeking);
|
||||||
AddWaitStep(5);
|
AddWaitStep("wait some", 5);
|
||||||
AddUntilStep(() => graph.CreationCount == 1, "wait for creation count");
|
AddUntilStep("wait for creation count", () => graph.CreationCount == 1);
|
||||||
AddRepeatStep("New Values", displayNewValues, 5);
|
AddRepeatStep("New Values", displayNewValues, 5);
|
||||||
|
|
||||||
AddWaitStep(5);
|
AddWaitStep("wait some", 5);
|
||||||
AddAssert("ensure debounced", () => graph.CreationCount == 2);
|
AddAssert("ensure debounced", () => graph.CreationCount == 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
private BeatmapManager beatmaps { get; set; }
|
private BeatmapManager beatmaps { get; set; }
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuGameBase osu, APIAccess api, RulesetStore rulesets)
|
private void load(OsuGameBase osu, IAPIProvider api, RulesetStore rulesets)
|
||||||
{
|
{
|
||||||
Bindable<BeatmapInfo> beatmapBindable = new Bindable<BeatmapInfo>();
|
Bindable<BeatmapInfo> beatmapBindable = new Bindable<BeatmapInfo>();
|
||||||
|
|
||||||
@ -36,18 +36,18 @@ namespace osu.Game.Tests.Visual
|
|||||||
api.Queue(req);
|
api.Queue(req);
|
||||||
|
|
||||||
AddStep("load null beatmap", () => beatmapBindable.Value = null);
|
AddStep("load null beatmap", () => beatmapBindable.Value = null);
|
||||||
AddUntilStep(() => backgroundSprite.ChildCount == 1, "wait for cleanup...");
|
AddUntilStep("wait for cleanup...", () => backgroundSprite.ChildCount == 1);
|
||||||
AddStep("load imported beatmap", () => beatmapBindable.Value = imported.Beatmaps.First());
|
AddStep("load imported beatmap", () => beatmapBindable.Value = imported.Beatmaps.First());
|
||||||
AddUntilStep(() => backgroundSprite.ChildCount == 1, "wait for cleanup...");
|
AddUntilStep("wait for cleanup...", () => backgroundSprite.ChildCount == 1);
|
||||||
|
|
||||||
if (api.IsLoggedIn)
|
if (api.IsLoggedIn)
|
||||||
{
|
{
|
||||||
AddUntilStep(() => req.Result != null, "wait for api response");
|
AddUntilStep("wait for api response", () => req.Result != null);
|
||||||
AddStep("load online beatmap", () => beatmapBindable.Value = new BeatmapInfo
|
AddStep("load online beatmap", () => beatmapBindable.Value = new BeatmapInfo
|
||||||
{
|
{
|
||||||
BeatmapSet = req.Result?.ToBeatmapSet(rulesets)
|
BeatmapSet = req.Result?.ToBeatmapSet(rulesets)
|
||||||
});
|
});
|
||||||
AddUntilStep(() => backgroundSprite.ChildCount == 1, "wait for cleanup...");
|
AddUntilStep("wait for cleanup...", () => backgroundSprite.ChildCount == 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -19,7 +19,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
public class TestCaseUserProfile : OsuTestCase
|
public class TestCaseUserProfile : OsuTestCase
|
||||||
{
|
{
|
||||||
private readonly TestUserProfileOverlay profile;
|
private readonly TestUserProfileOverlay profile;
|
||||||
private APIAccess api;
|
private IAPIProvider api;
|
||||||
|
|
||||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||||
{
|
{
|
||||||
@ -36,7 +36,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(APIAccess api)
|
private void load(IAPIProvider api)
|
||||||
{
|
{
|
||||||
this.api = api;
|
this.api = api;
|
||||||
}
|
}
|
||||||
@ -108,7 +108,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
private void checkSupporterTag(bool isSupporter)
|
private void checkSupporterTag(bool isSupporter)
|
||||||
{
|
{
|
||||||
AddUntilStep(() => profile.Header.User != null, "wait for load");
|
AddUntilStep("wait for load", () => profile.Header.User != null);
|
||||||
if (isSupporter)
|
if (isSupporter)
|
||||||
AddAssert("is supporter", () => profile.Header.SupporterTag.Alpha == 1);
|
AddAssert("is supporter", () => profile.Header.SupporterTag.Alpha == 1);
|
||||||
else
|
else
|
||||||
|
@ -64,7 +64,7 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
private readonly BeatmapStore beatmaps;
|
private readonly BeatmapStore beatmaps;
|
||||||
|
|
||||||
private readonly APIAccess api;
|
private readonly IAPIProvider api;
|
||||||
|
|
||||||
private readonly AudioManager audioManager;
|
private readonly AudioManager audioManager;
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
private readonly List<DownloadBeatmapSetRequest> currentDownloads = new List<DownloadBeatmapSetRequest>();
|
private readonly List<DownloadBeatmapSetRequest> currentDownloads = new List<DownloadBeatmapSetRequest>();
|
||||||
|
|
||||||
public BeatmapManager(Storage storage, IDatabaseContextFactory contextFactory, RulesetStore rulesets, APIAccess api, AudioManager audioManager, GameHost host = null,
|
public BeatmapManager(Storage storage, IDatabaseContextFactory contextFactory, RulesetStore rulesets, IAPIProvider api, AudioManager audioManager, GameHost host = null,
|
||||||
WorkingBeatmap defaultBeatmap = null)
|
WorkingBeatmap defaultBeatmap = null)
|
||||||
: base(storage, contextFactory, new BeatmapStore(contextFactory), host)
|
: base(storage, contextFactory, new BeatmapStore(contextFactory), host)
|
||||||
{
|
{
|
||||||
@ -105,11 +105,14 @@ namespace osu.Game.Beatmaps
|
|||||||
validateOnlineIds(beatmapSet);
|
validateOnlineIds(beatmapSet);
|
||||||
|
|
||||||
foreach (BeatmapInfo b in beatmapSet.Beatmaps)
|
foreach (BeatmapInfo b in beatmapSet.Beatmaps)
|
||||||
fetchAndPopulateOnlineValues(b, beatmapSet.Beatmaps);
|
fetchAndPopulateOnlineValues(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void PreImport(BeatmapSetInfo beatmapSet)
|
protected override void PreImport(BeatmapSetInfo beatmapSet)
|
||||||
{
|
{
|
||||||
|
if (beatmapSet.Beatmaps.Any(b => b.BaseDifficulty == null))
|
||||||
|
throw new InvalidOperationException($"Cannot import {nameof(BeatmapInfo)} with null {nameof(BeatmapInfo.BaseDifficulty)}.");
|
||||||
|
|
||||||
// check if a set already exists with the same online id, delete if it does.
|
// check if a set already exists with the same online id, delete if it does.
|
||||||
if (beatmapSet.OnlineBeatmapSetID != null)
|
if (beatmapSet.OnlineBeatmapSetID != null)
|
||||||
{
|
{
|
||||||
@ -382,7 +385,7 @@ namespace osu.Game.Beatmaps
|
|||||||
/// <param name="otherBeatmaps">The other beatmaps contained within this set.</param>
|
/// <param name="otherBeatmaps">The other beatmaps contained within this set.</param>
|
||||||
/// <param name="force">Whether to re-query if the provided beatmap already has populated values.</param>
|
/// <param name="force">Whether to re-query if the provided beatmap already has populated values.</param>
|
||||||
/// <returns>True if population was successful.</returns>
|
/// <returns>True if population was successful.</returns>
|
||||||
private bool fetchAndPopulateOnlineValues(BeatmapInfo beatmap, IEnumerable<BeatmapInfo> otherBeatmaps, bool force = false)
|
private bool fetchAndPopulateOnlineValues(BeatmapInfo beatmap, bool force = false)
|
||||||
{
|
{
|
||||||
if (api?.State != APIState.Online)
|
if (api?.State != APIState.Online)
|
||||||
return false;
|
return false;
|
||||||
@ -405,13 +408,6 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
beatmap.Status = res.Status;
|
beatmap.Status = res.Status;
|
||||||
beatmap.BeatmapSet.Status = res.BeatmapSet.Status;
|
beatmap.BeatmapSet.Status = res.BeatmapSet.Status;
|
||||||
|
|
||||||
if (otherBeatmaps.Any(b => b.OnlineBeatmapID == res.OnlineBeatmapID))
|
|
||||||
{
|
|
||||||
Logger.Log("Another beatmap in the same set already mapped to this ID. We'll skip adding it this time.", LoggingTarget.Database);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
beatmap.BeatmapSet.OnlineBeatmapSetID = res.OnlineBeatmapSetID;
|
beatmap.BeatmapSet.OnlineBeatmapSetID = res.OnlineBeatmapSetID;
|
||||||
beatmap.OnlineBeatmapID = res.OnlineBeatmapID;
|
beatmap.OnlineBeatmapID = res.OnlineBeatmapID;
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ namespace osu.Game.Beatmaps.Drawables
|
|||||||
drawable.Anchor = Anchor.Centre;
|
drawable.Anchor = Anchor.Centre;
|
||||||
drawable.Origin = Anchor.Centre;
|
drawable.Origin = Anchor.Centre;
|
||||||
drawable.FillMode = FillMode.Fill;
|
drawable.FillMode = FillMode.Fill;
|
||||||
drawable.OnLoadComplete = d => d.FadeInFromZero(400);
|
drawable.OnLoadComplete += d => d.FadeInFromZero(400);
|
||||||
|
|
||||||
return drawable;
|
return drawable;
|
||||||
}
|
}
|
||||||
|
@ -67,16 +67,19 @@ namespace osu.Game.Beatmaps.Drawables
|
|||||||
|
|
||||||
if (beatmapSet != null)
|
if (beatmapSet != null)
|
||||||
{
|
{
|
||||||
|
BeatmapSetCover cover;
|
||||||
|
|
||||||
Add(displayedCover = new DelayedLoadWrapper(
|
Add(displayedCover = new DelayedLoadWrapper(
|
||||||
new BeatmapSetCover(beatmapSet, coverType)
|
cover = new BeatmapSetCover(beatmapSet, coverType)
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
FillMode = FillMode.Fill,
|
FillMode = FillMode.Fill,
|
||||||
OnLoadComplete = d => d.FadeInFromZero(400, Easing.Out),
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
cover.OnLoadComplete += d => d.FadeInFromZero(400, Easing.Out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ namespace osu.Game.Beatmaps
|
|||||||
{
|
{
|
||||||
public override IEnumerable<Mod> GetModsFor(ModType type) => new Mod[] { };
|
public override IEnumerable<Mod> GetModsFor(ModType type) => new Mod[] { };
|
||||||
|
|
||||||
public override RulesetContainer CreateRulesetContainerWith(WorkingBeatmap beatmap)
|
public override DrawableRuleset CreateDrawableRulesetWith(WorkingBeatmap beatmap)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
@ -1,27 +1,26 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Graphics.Backgrounds;
|
||||||
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Graphics.Containers
|
namespace osu.Game.Graphics.Containers
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A container that applies user-configured dim levels to its contents.
|
/// A container that applies user-configured visual settings to its contents.
|
||||||
/// This container specifies behavior that applies to both Storyboards and Backgrounds.
|
/// This container specifies behavior that applies to both Storyboards and Backgrounds.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class UserDimContainer : Container
|
public class UserDimContainer : Container
|
||||||
{
|
{
|
||||||
private const float background_fade_duration = 800;
|
private const float background_fade_duration = 800;
|
||||||
|
|
||||||
private Bindable<double> dimLevel { get; set; }
|
|
||||||
|
|
||||||
private Bindable<bool> showStoryboard { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether or not user-configured dim levels should be applied to the container.
|
/// Whether or not user-configured dim levels should be applied to the container.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -32,19 +31,40 @@ namespace osu.Game.Graphics.Containers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly Bindable<bool> StoryboardReplacesBackground = new Bindable<bool>();
|
public readonly Bindable<bool> StoryboardReplacesBackground = new Bindable<bool>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The amount of blur to be applied to the background in addition to user-specified blur.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Used in contexts where there can potentially be both user and screen-specified blurring occuring at the same time, such as in <see cref="PlayerLoader"/>
|
||||||
|
/// </remarks>
|
||||||
|
public readonly Bindable<float> BlurAmount = new Bindable<float>();
|
||||||
|
|
||||||
|
private Bindable<double> userDimLevel { get; set; }
|
||||||
|
|
||||||
|
private Bindable<double> userBlurLevel { get; set; }
|
||||||
|
|
||||||
|
private Bindable<bool> showStoryboard { get; set; }
|
||||||
|
|
||||||
protected Container DimContainer { get; }
|
protected Container DimContainer { get; }
|
||||||
|
|
||||||
protected override Container<Drawable> Content => DimContainer;
|
protected override Container<Drawable> Content => DimContainer;
|
||||||
|
|
||||||
private readonly bool isStoryboard;
|
private readonly bool isStoryboard;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// As an optimisation, we add the two blur portions to be applied rather than actually applying two separate blurs.
|
||||||
|
/// </summary>
|
||||||
|
private Vector2 blurTarget => EnableUserDim.Value
|
||||||
|
? new Vector2(BlurAmount.Value + (float)userBlurLevel.Value * 25)
|
||||||
|
: new Vector2(BlurAmount.Value);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new <see cref="UserDimContainer"/>.
|
/// Creates a new <see cref="UserDimContainer"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="isStoryboard"> Whether or not this instance of UserDimContainer contains a storyboard.
|
/// <param name="isStoryboard"> Whether or not this instance contains a storyboard.
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// While both backgrounds and storyboards allow user dim levels to be applied, storyboards can be toggled via <see cref="showStoryboard"/>
|
/// While both backgrounds and storyboards allow user dim levels to be applied, storyboards can be toggled via <see cref="showStoryboard"/>
|
||||||
/// and can cause backgrounds to become hidden via <see cref="StoryboardReplacesBackground"/>.
|
/// and can cause backgrounds to become hidden via <see cref="StoryboardReplacesBackground"/>. Storyboards are also currently unable to be blurred.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// </param>
|
/// </param>
|
||||||
public UserDimContainer(bool isStoryboard = false)
|
public UserDimContainer(bool isStoryboard = false)
|
||||||
@ -53,36 +73,62 @@ namespace osu.Game.Graphics.Containers
|
|||||||
AddInternal(DimContainer = new Container { RelativeSizeAxes = Axes.Both });
|
AddInternal(DimContainer = new Container { RelativeSizeAxes = Axes.Both });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Background background;
|
||||||
|
|
||||||
|
public Background Background
|
||||||
|
{
|
||||||
|
get => background;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
base.Add(background = value);
|
||||||
|
background.BlurTo(blurTarget, 0, Easing.OutQuint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Add(Drawable drawable)
|
||||||
|
{
|
||||||
|
if (drawable is Background)
|
||||||
|
throw new InvalidOperationException($"Use {nameof(Background)} to set a background.");
|
||||||
|
|
||||||
|
base.Add(drawable);
|
||||||
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuConfigManager config)
|
private void load(OsuConfigManager config)
|
||||||
{
|
{
|
||||||
dimLevel = config.GetBindable<double>(OsuSetting.DimLevel);
|
userDimLevel = config.GetBindable<double>(OsuSetting.DimLevel);
|
||||||
|
userBlurLevel = config.GetBindable<double>(OsuSetting.BlurLevel);
|
||||||
showStoryboard = config.GetBindable<bool>(OsuSetting.ShowStoryboard);
|
showStoryboard = config.GetBindable<bool>(OsuSetting.ShowStoryboard);
|
||||||
EnableUserDim.ValueChanged += _ => updateBackgroundDim();
|
|
||||||
dimLevel.ValueChanged += _ => updateBackgroundDim();
|
EnableUserDim.ValueChanged += _ => updateVisuals();
|
||||||
showStoryboard.ValueChanged += _ => updateBackgroundDim();
|
userDimLevel.ValueChanged += _ => updateVisuals();
|
||||||
StoryboardReplacesBackground.ValueChanged += _ => updateBackgroundDim();
|
userBlurLevel.ValueChanged += _ => updateVisuals();
|
||||||
|
showStoryboard.ValueChanged += _ => updateVisuals();
|
||||||
|
StoryboardReplacesBackground.ValueChanged += _ => updateVisuals();
|
||||||
|
BlurAmount.ValueChanged += _ => updateVisuals();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
updateBackgroundDim();
|
updateVisuals();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateBackgroundDim()
|
private void updateVisuals()
|
||||||
{
|
{
|
||||||
if (isStoryboard)
|
if (isStoryboard)
|
||||||
{
|
{
|
||||||
DimContainer.FadeTo(!showStoryboard.Value || dimLevel.Value == 1 ? 0 : 1, background_fade_duration, Easing.OutQuint);
|
DimContainer.FadeTo(!showStoryboard.Value || userDimLevel.Value == 1 ? 0 : 1, background_fade_duration, Easing.OutQuint);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// The background needs to be hidden in the case of it being replaced by the storyboard
|
// The background needs to be hidden in the case of it being replaced by the storyboard
|
||||||
DimContainer.FadeTo(showStoryboard.Value && StoryboardReplacesBackground.Value ? 0 : 1, background_fade_duration, Easing.OutQuint);
|
DimContainer.FadeTo(showStoryboard.Value && StoryboardReplacesBackground.Value ? 0 : 1, background_fade_duration, Easing.OutQuint);
|
||||||
|
|
||||||
|
Background?.BlurTo(blurTarget, background_fade_duration, Easing.OutQuint);
|
||||||
}
|
}
|
||||||
|
|
||||||
DimContainer.FadeColour(EnableUserDim.Value ? OsuColour.Gray(1 - (float)dimLevel.Value) : Color4.White, background_fade_duration, Easing.OutQuint);
|
DimContainer.FadeColour(EnableUserDim.Value ? OsuColour.Gray(1 - (float)userDimLevel.Value) : Color4.White, background_fade_duration, Easing.OutQuint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ namespace osu.Game.Online.API
|
|||||||
private readonly OsuConfigManager config;
|
private readonly OsuConfigManager config;
|
||||||
private readonly OAuth authentication;
|
private readonly OAuth authentication;
|
||||||
|
|
||||||
public string Endpoint = @"https://osu.ppy.sh";
|
public string Endpoint => @"https://osu.ppy.sh";
|
||||||
private const string client_id = @"5";
|
private const string client_id = @"5";
|
||||||
private const string client_secret = @"FGc9GAtyHzeQDshWP5Ah7dega8hJACAJpQtw6OXk";
|
private const string client_secret = @"FGc9GAtyHzeQDshWP5Ah7dega8hJACAJpQtw6OXk";
|
||||||
|
|
||||||
|
@ -61,9 +61,12 @@ namespace osu.Game.Online.API
|
|||||||
|
|
||||||
private Action pendingFailure;
|
private Action pendingFailure;
|
||||||
|
|
||||||
public void Perform(APIAccess api)
|
public void Perform(IAPIProvider api)
|
||||||
{
|
{
|
||||||
API = api;
|
if (!(api is APIAccess apiAccess))
|
||||||
|
throw new NotSupportedException($"A {nameof(APIAccess)} is required to perform requests.");
|
||||||
|
|
||||||
|
API = apiAccess;
|
||||||
|
|
||||||
if (checkAndScheduleFailure())
|
if (checkAndScheduleFailure())
|
||||||
return;
|
return;
|
||||||
@ -71,7 +74,7 @@ namespace osu.Game.Online.API
|
|||||||
WebRequest = CreateWebRequest();
|
WebRequest = CreateWebRequest();
|
||||||
WebRequest.Failed += Fail;
|
WebRequest.Failed += Fail;
|
||||||
WebRequest.AllowRetryOnTimeout = false;
|
WebRequest.AllowRetryOnTimeout = false;
|
||||||
WebRequest.AddHeader("Authorization", $"Bearer {api.AccessToken}");
|
WebRequest.AddHeader("Authorization", $"Bearer {API.AccessToken}");
|
||||||
|
|
||||||
if (checkAndScheduleFailure())
|
if (checkAndScheduleFailure())
|
||||||
return;
|
return;
|
||||||
@ -85,7 +88,7 @@ namespace osu.Game.Online.API
|
|||||||
if (checkAndScheduleFailure())
|
if (checkAndScheduleFailure())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
api.Schedule(delegate { Success?.Invoke(); });
|
API.Schedule(delegate { Success?.Invoke(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Cancel() => Fail(new OperationCanceledException(@"Request cancelled"));
|
public void Cancel() => Fail(new OperationCanceledException(@"Request cancelled"));
|
||||||
|
@ -11,14 +11,16 @@ namespace osu.Game.Online.API
|
|||||||
public Bindable<User> LocalUser { get; } = new Bindable<User>(new User
|
public Bindable<User> LocalUser { get; } = new Bindable<User>(new User
|
||||||
{
|
{
|
||||||
Username = @"Dummy",
|
Username = @"Dummy",
|
||||||
Id = 1,
|
Id = 1001,
|
||||||
});
|
});
|
||||||
|
|
||||||
public bool IsLoggedIn => true;
|
public bool IsLoggedIn => true;
|
||||||
|
|
||||||
public void Update()
|
public string ProvidedUsername => LocalUser.Value.Username;
|
||||||
{
|
|
||||||
}
|
public string Endpoint => "http://localhost";
|
||||||
|
|
||||||
|
public APIState State => LocalUser.Value.Id == 1 ? APIState.Offline : APIState.Online;
|
||||||
|
|
||||||
public virtual void Queue(APIRequest request)
|
public virtual void Queue(APIRequest request)
|
||||||
{
|
{
|
||||||
@ -26,6 +28,28 @@ namespace osu.Game.Online.API
|
|||||||
|
|
||||||
public void Register(IOnlineComponent component)
|
public void Register(IOnlineComponent component)
|
||||||
{
|
{
|
||||||
|
// todo: add support
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Unregister(IOnlineComponent component)
|
||||||
|
{
|
||||||
|
// todo: add support
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Login(string username, string password)
|
||||||
|
{
|
||||||
|
LocalUser.Value = new User
|
||||||
|
{
|
||||||
|
Username = @"Dummy",
|
||||||
|
Id = 1001,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Logout()
|
||||||
|
{
|
||||||
|
LocalUser.Value = new GuestUser();
|
||||||
|
}
|
||||||
|
|
||||||
|
public RegistrationRequest.RegistrationRequestErrors CreateAccount(string email, string username, string password) => null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,19 @@ namespace osu.Game.Online.API
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
bool IsLoggedIn { get; }
|
bool IsLoggedIn { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The last username provided by the end-user.
|
||||||
|
/// May not be authenticated.
|
||||||
|
/// </summary>
|
||||||
|
string ProvidedUsername { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The URL endpoint for this API. Does not include a trailing slash.
|
||||||
|
/// </summary>
|
||||||
|
string Endpoint { get; }
|
||||||
|
|
||||||
|
APIState State { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Queue a new request.
|
/// Queue a new request.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -29,5 +42,32 @@ namespace osu.Game.Online.API
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="component">The component to register.</param>
|
/// <param name="component">The component to register.</param>
|
||||||
void Register(IOnlineComponent component);
|
void Register(IOnlineComponent component);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Unregisters a component to receive state changes.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="component">The component to unregister.</param>
|
||||||
|
void Unregister(IOnlineComponent component);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Attempt to login using the provided credentials. This is a non-blocking operation.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="username">The user's username.</param>
|
||||||
|
/// <param name="password">The user's password.</param>
|
||||||
|
void Login(string username, string password);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Log out the current user.
|
||||||
|
/// </summary>
|
||||||
|
void Logout();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create a new user account. This is a blocking operation.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="email">The email to create the account with.</param>
|
||||||
|
/// <param name="username">The username to create the account with.</param>
|
||||||
|
/// <param name="password">The password to create the account with.</param>
|
||||||
|
/// <returns>Any errors encoutnered during account creation.</returns>
|
||||||
|
RegistrationRequest.RegistrationRequestErrors CreateAccount(string email, string username, string password);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,6 @@ namespace osu.Game.Online.API
|
|||||||
{
|
{
|
||||||
public interface IOnlineComponent
|
public interface IOnlineComponent
|
||||||
{
|
{
|
||||||
void APIStateChanged(APIAccess api, APIState state);
|
void APIStateChanged(IAPIProvider api, APIState state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -174,12 +174,12 @@ namespace osu.Game.Online.Leaderboards
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private APIAccess api;
|
private IAPIProvider api;
|
||||||
|
|
||||||
private ScheduledDelegate pendingUpdateScores;
|
private ScheduledDelegate pendingUpdateScores;
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(APIAccess api)
|
private void load(IAPIProvider api)
|
||||||
{
|
{
|
||||||
this.api = api;
|
this.api = api;
|
||||||
api?.Register(this);
|
api?.Register(this);
|
||||||
@ -195,7 +195,7 @@ namespace osu.Game.Online.Leaderboards
|
|||||||
|
|
||||||
private APIRequest getScoresRequest;
|
private APIRequest getScoresRequest;
|
||||||
|
|
||||||
public void APIStateChanged(APIAccess api, APIState state)
|
public void APIStateChanged(IAPIProvider api, APIState state)
|
||||||
{
|
{
|
||||||
if (state == APIState.Online)
|
if (state == APIState.Online)
|
||||||
UpdateScores();
|
UpdateScores();
|
||||||
|
@ -64,6 +64,8 @@ namespace osu.Game.Online.Leaderboards
|
|||||||
|
|
||||||
statisticsLabels = GetStatistics(score).Select(s => new ScoreComponentLabel(s)).ToList();
|
statisticsLabels = GetStatistics(score).Select(s => new ScoreComponentLabel(s)).ToList();
|
||||||
|
|
||||||
|
Avatar innerAvatar;
|
||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new Container
|
new Container
|
||||||
@ -109,12 +111,11 @@ namespace osu.Game.Online.Leaderboards
|
|||||||
Children = new[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
avatar = new DelayedLoadWrapper(
|
avatar = new DelayedLoadWrapper(
|
||||||
new Avatar(user)
|
innerAvatar = new Avatar(user)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
CornerRadius = corner_radius,
|
CornerRadius = corner_radius,
|
||||||
Masking = true,
|
Masking = true,
|
||||||
OnLoadComplete = d => d.FadeInFromZero(200),
|
|
||||||
EdgeEffect = new EdgeEffectParameters
|
EdgeEffect = new EdgeEffectParameters
|
||||||
{
|
{
|
||||||
Type = EdgeEffectType.Shadow,
|
Type = EdgeEffectType.Shadow,
|
||||||
@ -214,6 +215,8 @@ namespace osu.Game.Online.Leaderboards
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
innerAvatar.OnLoadComplete += d => d.FadeInFromZero(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Show()
|
public override void Show()
|
||||||
|
@ -152,7 +152,6 @@ namespace osu.Game
|
|||||||
|
|
||||||
API = new APIAccess(LocalConfig);
|
API = new APIAccess(LocalConfig);
|
||||||
|
|
||||||
dependencies.Cache(API);
|
|
||||||
dependencies.CacheAs<IAPIProvider>(API);
|
dependencies.CacheAs<IAPIProvider>(API);
|
||||||
|
|
||||||
var defaultBeatmap = new DummyWorkingBeatmap(this);
|
var defaultBeatmap = new DummyWorkingBeatmap(this);
|
||||||
|
@ -33,7 +33,7 @@ namespace osu.Game.Overlays.AccountCreation
|
|||||||
private OsuTextBox emailTextBox;
|
private OsuTextBox emailTextBox;
|
||||||
private OsuPasswordTextBox passwordTextBox;
|
private OsuPasswordTextBox passwordTextBox;
|
||||||
|
|
||||||
private APIAccess api;
|
private IAPIProvider api;
|
||||||
private ShakeContainer registerShake;
|
private ShakeContainer registerShake;
|
||||||
private IEnumerable<Drawable> characterCheckText;
|
private IEnumerable<Drawable> characterCheckText;
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ namespace osu.Game.Overlays.AccountCreation
|
|||||||
private GameHost host;
|
private GameHost host;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours, APIAccess api, GameHost host)
|
private void load(OsuColour colours, IAPIProvider api, GameHost host)
|
||||||
{
|
{
|
||||||
this.api = api;
|
this.api = api;
|
||||||
this.host = host;
|
this.host = host;
|
||||||
|
@ -22,7 +22,7 @@ namespace osu.Game.Overlays.AccountCreation
|
|||||||
{
|
{
|
||||||
private OsuTextFlowContainer multiAccountExplanationText;
|
private OsuTextFlowContainer multiAccountExplanationText;
|
||||||
private LinkFlowContainer furtherAssistance;
|
private LinkFlowContainer furtherAssistance;
|
||||||
private APIAccess api;
|
private IAPIProvider api;
|
||||||
|
|
||||||
private const string help_centre_url = "/help/wiki/Help_Centre#login";
|
private const string help_centre_url = "/help/wiki/Help_Centre#login";
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ namespace osu.Game.Overlays.AccountCreation
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(OsuColour colours, APIAccess api, OsuGame game, TextureStore textures)
|
private void load(OsuColour colours, IAPIProvider api, OsuGame game, TextureStore textures)
|
||||||
{
|
{
|
||||||
this.api = api;
|
this.api = api;
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ namespace osu.Game.Overlays
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours, APIAccess api)
|
private void load(OsuColour colours, IAPIProvider api)
|
||||||
{
|
{
|
||||||
api.Register(this);
|
api.Register(this);
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ namespace osu.Game.Overlays
|
|||||||
this.FadeOut(100);
|
this.FadeOut(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void APIStateChanged(APIAccess api, APIState state)
|
public void APIStateChanged(IAPIProvider api, APIState state)
|
||||||
{
|
{
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
|
@ -39,7 +39,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(APIAccess api, BeatmapManager beatmaps)
|
private void load(IAPIProvider api, BeatmapManager beatmaps)
|
||||||
{
|
{
|
||||||
FillFlowContainer textSprites;
|
FillFlowContainer textSprites;
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
|||||||
}
|
}
|
||||||
|
|
||||||
private GetScoresRequest getScoresRequest;
|
private GetScoresRequest getScoresRequest;
|
||||||
private APIAccess api;
|
private IAPIProvider api;
|
||||||
|
|
||||||
public BeatmapInfo Beatmap
|
public BeatmapInfo Beatmap
|
||||||
{
|
{
|
||||||
@ -129,7 +129,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(APIAccess api)
|
private void load(IAPIProvider api)
|
||||||
{
|
{
|
||||||
this.api = api;
|
this.api = api;
|
||||||
updateDisplay();
|
updateDisplay();
|
||||||
|
@ -31,7 +31,7 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
private readonly Header header;
|
private readonly Header header;
|
||||||
|
|
||||||
private APIAccess api;
|
private IAPIProvider api;
|
||||||
private RulesetStore rulesets;
|
private RulesetStore rulesets;
|
||||||
|
|
||||||
private readonly ScrollContainer scroll;
|
private readonly ScrollContainer scroll;
|
||||||
@ -101,7 +101,7 @@ namespace osu.Game.Overlays
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(APIAccess api, RulesetStore rulesets)
|
private void load(IAPIProvider api, RulesetStore rulesets)
|
||||||
{
|
{
|
||||||
this.api = api;
|
this.api = api;
|
||||||
this.rulesets = rulesets;
|
this.rulesets = rulesets;
|
||||||
|
@ -28,6 +28,8 @@ namespace osu.Game.Overlays.Chat.Tabs
|
|||||||
if (value.Type != ChannelType.PM)
|
if (value.Type != ChannelType.PM)
|
||||||
throw new ArgumentException("Argument value needs to have the targettype user!");
|
throw new ArgumentException("Argument value needs to have the targettype user!");
|
||||||
|
|
||||||
|
Avatar avatar;
|
||||||
|
|
||||||
AddRange(new Drawable[]
|
AddRange(new Drawable[]
|
||||||
{
|
{
|
||||||
new Container
|
new Container
|
||||||
@ -49,11 +51,10 @@ namespace osu.Game.Overlays.Chat.Tabs
|
|||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Masking = true,
|
Masking = true,
|
||||||
Child = new DelayedLoadWrapper(new Avatar(value.Users.First())
|
Child = new DelayedLoadWrapper(avatar = new Avatar(value.Users.First())
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
OpenOnClick = { Value = false },
|
OpenOnClick = { Value = false },
|
||||||
OnLoadComplete = d => d.FadeInFromZero(300, Easing.OutQuint),
|
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
@ -63,6 +64,8 @@ namespace osu.Game.Overlays.Chat.Tabs
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
avatar.OnLoadComplete += d => d.FadeInFromZero(300, Easing.OutQuint);
|
||||||
|
|
||||||
Text.X = ChatOverlay.TAB_AREA_HEIGHT;
|
Text.X = ChatOverlay.TAB_AREA_HEIGHT;
|
||||||
TextBold.X = ChatOverlay.TAB_AREA_HEIGHT;
|
TextBold.X = ChatOverlay.TAB_AREA_HEIGHT;
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
private const float panel_padding = 10f;
|
private const float panel_padding = 10f;
|
||||||
|
|
||||||
private APIAccess api;
|
private IAPIProvider api;
|
||||||
private RulesetStore rulesets;
|
private RulesetStore rulesets;
|
||||||
|
|
||||||
private readonly FillFlowContainer resultCountsContainer;
|
private readonly FillFlowContainer resultCountsContainer;
|
||||||
@ -164,7 +164,7 @@ namespace osu.Game.Overlays
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours, APIAccess api, RulesetStore rulesets, PreviewTrackManager previewTrackManager)
|
private void load(OsuColour colours, IAPIProvider api, RulesetStore rulesets, PreviewTrackManager previewTrackManager)
|
||||||
{
|
{
|
||||||
this.api = api;
|
this.api = api;
|
||||||
this.rulesets = rulesets;
|
this.rulesets = rulesets;
|
||||||
|
@ -109,7 +109,7 @@ namespace osu.Game.Overlays.MedalSplash
|
|||||||
s.Font = s.Font.With(size: 16);
|
s.Font = s.Font.With(size: 16);
|
||||||
});
|
});
|
||||||
|
|
||||||
medalContainer.OnLoadComplete = d =>
|
medalContainer.OnLoadComplete += d =>
|
||||||
{
|
{
|
||||||
unlocked.Position = new Vector2(0f, medalContainer.DrawSize.Y / 2 + 10);
|
unlocked.Position = new Vector2(0f, medalContainer.DrawSize.Y / 2 + 10);
|
||||||
infoFlow.Position = new Vector2(0f, unlocked.Position.Y + 90);
|
infoFlow.Position = new Vector2(0f, unlocked.Position.Y + 90);
|
||||||
|
@ -335,9 +335,12 @@ namespace osu.Game.Overlays.Profile
|
|||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
FillMode = FillMode.Fill,
|
FillMode = FillMode.Fill,
|
||||||
OnLoadComplete = d => d.FadeInFromZero(200),
|
|
||||||
Depth = float.MaxValue,
|
Depth = float.MaxValue,
|
||||||
}, coverContainer.Add);
|
}, background =>
|
||||||
|
{
|
||||||
|
coverContainer.Add(background);
|
||||||
|
background.FadeInFromZero(200);
|
||||||
|
});
|
||||||
|
|
||||||
if (user.IsSupporter)
|
if (user.IsSupporter)
|
||||||
SupporterTag.Show();
|
SupporterTag.Show();
|
||||||
|
@ -28,7 +28,7 @@ namespace osu.Game.Overlays.Profile.Sections
|
|||||||
|
|
||||||
protected readonly Bindable<User> User = new Bindable<User>();
|
protected readonly Bindable<User> User = new Bindable<User>();
|
||||||
|
|
||||||
protected APIAccess Api;
|
protected IAPIProvider Api;
|
||||||
protected APIRequest RetrievalRequest;
|
protected APIRequest RetrievalRequest;
|
||||||
protected RulesetStore Rulesets;
|
protected RulesetStore Rulesets;
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ namespace osu.Game.Overlays.Profile.Sections
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(APIAccess api, RulesetStore rulesets)
|
private void load(IAPIProvider api, RulesetStore rulesets)
|
||||||
{
|
{
|
||||||
Api = api;
|
Api = api;
|
||||||
Rulesets = rulesets;
|
Rulesets = rulesets;
|
||||||
|
@ -16,7 +16,7 @@ namespace osu.Game.Overlays.Profile.Sections.Recent
|
|||||||
{
|
{
|
||||||
public class DrawableRecentActivity : DrawableProfileRow
|
public class DrawableRecentActivity : DrawableProfileRow
|
||||||
{
|
{
|
||||||
private APIAccess api;
|
private IAPIProvider api;
|
||||||
|
|
||||||
private readonly APIRecentActivity activity;
|
private readonly APIRecentActivity activity;
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ namespace osu.Game.Overlays.Profile.Sections.Recent
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(APIAccess api)
|
private void load(IAPIProvider api)
|
||||||
{
|
{
|
||||||
this.api = api;
|
this.api = api;
|
||||||
|
|
||||||
|
@ -58,14 +58,14 @@ namespace osu.Game.Overlays.Settings.Sections.General
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader(permitNulls: true)]
|
[BackgroundDependencyLoader(permitNulls: true)]
|
||||||
private void load(OsuColour colours, APIAccess api)
|
private void load(OsuColour colours, IAPIProvider api)
|
||||||
{
|
{
|
||||||
this.colours = colours;
|
this.colours = colours;
|
||||||
|
|
||||||
api?.Register(this);
|
api?.Register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void APIStateChanged(APIAccess api, APIState state)
|
public void APIStateChanged(IAPIProvider api, APIState state)
|
||||||
{
|
{
|
||||||
form = null;
|
form = null;
|
||||||
|
|
||||||
@ -194,7 +194,7 @@ namespace osu.Game.Overlays.Settings.Sections.General
|
|||||||
{
|
{
|
||||||
private TextBox username;
|
private TextBox username;
|
||||||
private TextBox password;
|
private TextBox password;
|
||||||
private APIAccess api;
|
private IAPIProvider api;
|
||||||
|
|
||||||
public Action RequestHide;
|
public Action RequestHide;
|
||||||
|
|
||||||
@ -205,7 +205,7 @@ namespace osu.Game.Overlays.Settings.Sections.General
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader(permitNulls: true)]
|
[BackgroundDependencyLoader(permitNulls: true)]
|
||||||
private void load(APIAccess api, OsuConfigManager config, AccountCreationOverlay accountCreation)
|
private void load(IAPIProvider api, OsuConfigManager config, AccountCreationOverlay accountCreation)
|
||||||
{
|
{
|
||||||
this.api = api;
|
this.api = api;
|
||||||
Direction = FillDirection.Vertical;
|
Direction = FillDirection.Vertical;
|
||||||
|
@ -22,7 +22,7 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
public class SocialOverlay : SearchableListOverlay<SocialTab, SocialSortCriteria, SortDirection>, IOnlineComponent
|
public class SocialOverlay : SearchableListOverlay<SocialTab, SocialSortCriteria, SortDirection>, IOnlineComponent
|
||||||
{
|
{
|
||||||
private APIAccess api;
|
private IAPIProvider api;
|
||||||
private readonly LoadingAnimation loading;
|
private readonly LoadingAnimation loading;
|
||||||
private FillFlowContainer<SocialPanel> panels;
|
private FillFlowContainer<SocialPanel> panels;
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ namespace osu.Game.Overlays
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(APIAccess api)
|
private void load(IAPIProvider api)
|
||||||
{
|
{
|
||||||
this.api = api;
|
this.api = api;
|
||||||
api.Register(this);
|
api.Register(this);
|
||||||
@ -193,7 +193,7 @@ namespace osu.Game.Overlays
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void APIStateChanged(APIAccess api, APIState state)
|
public void APIStateChanged(IAPIProvider api, APIState state)
|
||||||
{
|
{
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
|
@ -43,12 +43,12 @@ namespace osu.Game.Overlays.Toolbar
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(APIAccess api)
|
private void load(IAPIProvider api)
|
||||||
{
|
{
|
||||||
api.Register(this);
|
api.Register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void APIStateChanged(APIAccess api, APIState state)
|
public void APIStateChanged(IAPIProvider api, APIState state)
|
||||||
{
|
{
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
|
@ -26,7 +26,7 @@ namespace osu.Game.Overlays
|
|||||||
private ProfileSection lastSection;
|
private ProfileSection lastSection;
|
||||||
private ProfileSection[] sections;
|
private ProfileSection[] sections;
|
||||||
private GetUserRequest userReq;
|
private GetUserRequest userReq;
|
||||||
private APIAccess api;
|
private IAPIProvider api;
|
||||||
protected ProfileHeader Header;
|
protected ProfileHeader Header;
|
||||||
private SectionsContainer<ProfileSection> sectionsContainer;
|
private SectionsContainer<ProfileSection> sectionsContainer;
|
||||||
private ProfileTabControl tabs;
|
private ProfileTabControl tabs;
|
||||||
@ -56,7 +56,7 @@ namespace osu.Game.Overlays
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(APIAccess api)
|
private void load(IAPIProvider api)
|
||||||
{
|
{
|
||||||
this.api = api;
|
this.api = api;
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,8 @@ namespace osu.Game.Rulesets.Difficulty
|
|||||||
/// <returns>A structure describing the difficulty of the beatmap.</returns>
|
/// <returns>A structure describing the difficulty of the beatmap.</returns>
|
||||||
public DifficultyAttributes Calculate(params Mod[] mods)
|
public DifficultyAttributes Calculate(params Mod[] mods)
|
||||||
{
|
{
|
||||||
|
mods = mods.Select(m => m.CreateCopy()).ToArray();
|
||||||
|
|
||||||
beatmap.Mods.Value = mods;
|
beatmap.Mods.Value = mods;
|
||||||
IBeatmap playableBeatmap = beatmap.GetPlayableBeatmap(ruleset.RulesetInfo);
|
IBeatmap playableBeatmap = beatmap.GetPlayableBeatmap(ruleset.RulesetInfo);
|
||||||
|
|
||||||
|
@ -11,14 +11,14 @@ using osu.Game.Rulesets.UI;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Edit
|
namespace osu.Game.Rulesets.Edit
|
||||||
{
|
{
|
||||||
public abstract class EditRulesetContainer : CompositeDrawable
|
public abstract class DrawableEditRuleset : CompositeDrawable
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The <see cref="Playfield"/> contained by this <see cref="EditRulesetContainer"/>.
|
/// The <see cref="Playfield"/> contained by this <see cref="DrawableEditRuleset"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract Playfield Playfield { get; }
|
public abstract Playfield Playfield { get; }
|
||||||
|
|
||||||
internal EditRulesetContainer()
|
internal DrawableEditRuleset()
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
}
|
}
|
||||||
@ -38,21 +38,21 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
internal abstract DrawableHitObject Remove(HitObject hitObject);
|
internal abstract DrawableHitObject Remove(HitObject hitObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class EditRulesetContainer<TObject> : EditRulesetContainer
|
public class DrawableEditRuleset<TObject> : DrawableEditRuleset
|
||||||
where TObject : HitObject
|
where TObject : HitObject
|
||||||
{
|
{
|
||||||
public override Playfield Playfield => rulesetContainer.Playfield;
|
public override Playfield Playfield => drawableRuleset.Playfield;
|
||||||
|
|
||||||
private Ruleset ruleset => rulesetContainer.Ruleset;
|
private Ruleset ruleset => drawableRuleset.Ruleset;
|
||||||
private Beatmap<TObject> beatmap => rulesetContainer.Beatmap;
|
private Beatmap<TObject> beatmap => drawableRuleset.Beatmap;
|
||||||
|
|
||||||
private readonly RulesetContainer<TObject> rulesetContainer;
|
private readonly DrawableRuleset<TObject> drawableRuleset;
|
||||||
|
|
||||||
public EditRulesetContainer(RulesetContainer<TObject> rulesetContainer)
|
public DrawableEditRuleset(DrawableRuleset<TObject> drawableRuleset)
|
||||||
{
|
{
|
||||||
this.rulesetContainer = rulesetContainer;
|
this.drawableRuleset = drawableRuleset;
|
||||||
|
|
||||||
InternalChild = rulesetContainer;
|
InternalChild = drawableRuleset;
|
||||||
|
|
||||||
Playfield.DisplayJudgements.Value = false;
|
Playfield.DisplayJudgements.Value = false;
|
||||||
}
|
}
|
||||||
@ -73,10 +73,10 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
processor?.PostProcess();
|
processor?.PostProcess();
|
||||||
|
|
||||||
// Add visual representation
|
// Add visual representation
|
||||||
var drawableObject = rulesetContainer.GetVisualRepresentation(tObject);
|
var drawableObject = drawableRuleset.GetVisualRepresentation(tObject);
|
||||||
|
|
||||||
rulesetContainer.Playfield.Add(drawableObject);
|
drawableRuleset.Playfield.Add(drawableObject);
|
||||||
rulesetContainer.Playfield.PostProcess();
|
drawableRuleset.Playfield.PostProcess();
|
||||||
|
|
||||||
return drawableObject;
|
return drawableObject;
|
||||||
}
|
}
|
||||||
@ -97,8 +97,8 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
// Remove visual representation
|
// Remove visual representation
|
||||||
var drawableObject = Playfield.AllHitObjects.Single(d => d.HitObject == hitObject);
|
var drawableObject = Playfield.AllHitObjects.Single(d => d.HitObject == hitObject);
|
||||||
|
|
||||||
rulesetContainer.Playfield.Remove(drawableObject);
|
drawableRuleset.Playfield.Remove(drawableObject);
|
||||||
rulesetContainer.Playfield.PostProcess();
|
drawableRuleset.Playfield.PostProcess();
|
||||||
|
|
||||||
return drawableObject;
|
return drawableObject;
|
||||||
}
|
}
|
@ -24,7 +24,7 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
{
|
{
|
||||||
public abstract class HitObjectComposer : CompositeDrawable
|
public abstract class HitObjectComposer : CompositeDrawable
|
||||||
{
|
{
|
||||||
public IEnumerable<DrawableHitObject> HitObjects => RulesetContainer.Playfield.AllHitObjects;
|
public IEnumerable<DrawableHitObject> HitObjects => DrawableRuleset.Playfield.AllHitObjects;
|
||||||
|
|
||||||
protected readonly Ruleset Ruleset;
|
protected readonly Ruleset Ruleset;
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
|
|
||||||
private readonly List<Container> layerContainers = new List<Container>();
|
private readonly List<Container> layerContainers = new List<Container>();
|
||||||
|
|
||||||
protected EditRulesetContainer RulesetContainer { get; private set; }
|
protected DrawableEditRuleset DrawableRuleset { get; private set; }
|
||||||
|
|
||||||
private BlueprintContainer blueprintContainer;
|
private BlueprintContainer blueprintContainer;
|
||||||
|
|
||||||
@ -54,8 +54,8 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
RulesetContainer = CreateRulesetContainer();
|
DrawableRuleset = CreateDrawableRuleset();
|
||||||
RulesetContainer.Clock = framedClock;
|
DrawableRuleset.Clock = framedClock;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@ -97,7 +97,7 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
layerBelowRuleset,
|
layerBelowRuleset,
|
||||||
RulesetContainer,
|
DrawableRuleset,
|
||||||
layerAboveRuleset
|
layerAboveRuleset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -140,27 +140,27 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
|
|
||||||
layerContainers.ForEach(l =>
|
layerContainers.ForEach(l =>
|
||||||
{
|
{
|
||||||
l.Anchor = RulesetContainer.Playfield.Anchor;
|
l.Anchor = DrawableRuleset.Playfield.Anchor;
|
||||||
l.Origin = RulesetContainer.Playfield.Origin;
|
l.Origin = DrawableRuleset.Playfield.Origin;
|
||||||
l.Position = RulesetContainer.Playfield.Position;
|
l.Position = DrawableRuleset.Playfield.Position;
|
||||||
l.Size = RulesetContainer.Playfield.Size;
|
l.Size = DrawableRuleset.Playfield.Size;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether the user's cursor is currently in an area of the <see cref="HitObjectComposer"/> that is valid for placement.
|
/// Whether the user's cursor is currently in an area of the <see cref="HitObjectComposer"/> that is valid for placement.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual bool CursorInPlacementArea => RulesetContainer.Playfield.ReceivePositionalInputAt(inputManager.CurrentState.Mouse.Position);
|
public virtual bool CursorInPlacementArea => DrawableRuleset.Playfield.ReceivePositionalInputAt(inputManager.CurrentState.Mouse.Position);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds a <see cref="HitObject"/> to the <see cref="Beatmaps.Beatmap"/> and visualises it.
|
/// Adds a <see cref="HitObject"/> to the <see cref="Beatmaps.Beatmap"/> and visualises it.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="hitObject">The <see cref="HitObject"/> to add.</param>
|
/// <param name="hitObject">The <see cref="HitObject"/> to add.</param>
|
||||||
public void Add(HitObject hitObject) => blueprintContainer.AddBlueprintFor(RulesetContainer.Add(hitObject));
|
public void Add(HitObject hitObject) => blueprintContainer.AddBlueprintFor(DrawableRuleset.Add(hitObject));
|
||||||
|
|
||||||
public void Remove(HitObject hitObject) => blueprintContainer.RemoveBlueprintFor(RulesetContainer.Remove(hitObject));
|
public void Remove(HitObject hitObject) => blueprintContainer.RemoveBlueprintFor(DrawableRuleset.Remove(hitObject));
|
||||||
|
|
||||||
internal abstract EditRulesetContainer CreateRulesetContainer();
|
internal abstract DrawableEditRuleset CreateDrawableRuleset();
|
||||||
|
|
||||||
protected abstract IReadOnlyList<HitObjectCompositionTool> CompositionTools { get; }
|
protected abstract IReadOnlyList<HitObjectCompositionTool> CompositionTools { get; }
|
||||||
|
|
||||||
@ -189,9 +189,9 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override EditRulesetContainer CreateRulesetContainer()
|
internal override DrawableEditRuleset CreateDrawableRuleset()
|
||||||
=> new EditRulesetContainer<TObject>(CreateRulesetContainer(Ruleset, Beatmap.Value));
|
=> new DrawableEditRuleset<TObject>(CreateDrawableRuleset(Ruleset, Beatmap.Value));
|
||||||
|
|
||||||
protected abstract RulesetContainer<TObject> CreateRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap);
|
protected abstract DrawableRuleset<TObject> CreateDrawableRuleset(Ruleset ruleset, WorkingBeatmap beatmap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,15 +7,15 @@ using osu.Game.Rulesets.UI;
|
|||||||
namespace osu.Game.Rulesets.Mods
|
namespace osu.Game.Rulesets.Mods
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An interface for <see cref="Mod"/>s that can be applied to <see cref="RulesetContainer"/>s.
|
/// An interface for <see cref="Mod"/>s that can be applied to <see cref="DrawableRuleset"/>s.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IApplicableToRulesetContainer<TObject> : IApplicableMod
|
public interface IApplicableToDrawableRuleset<TObject> : IApplicableMod
|
||||||
where TObject : HitObject
|
where TObject : HitObject
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Applies this <see cref="IApplicableToRulesetContainer{TObject}"/> to a <see cref="RulesetContainer{TObject}"/>.
|
/// Applies this <see cref="IApplicableToDrawableRuleset{TObject}"/> to a <see cref="DrawableRuleset{TObject}"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="rulesetContainer">The <see cref="RulesetContainer{TObject}"/> to apply to.</param>
|
/// <param name="drawableRuleset">The <see cref="DrawableRuleset{TObject}"/> to apply to.</param>
|
||||||
void ApplyToRulesetContainer(RulesetContainer<TObject> rulesetContainer);
|
void ApplyToDrawableRuleset(DrawableRuleset<TObject> drawableRuleset);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -65,5 +65,10 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public virtual Type[] IncompatibleMods => new Type[] { };
|
public virtual Type[] IncompatibleMods => new Type[] { };
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a copy of this <see cref="Mod"/> initialised to a default state.
|
||||||
|
/// </summary>
|
||||||
|
public virtual Mod CreateCopy() => (Mod)Activator.CreateInstance(GetType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,10 +11,10 @@ using osu.Game.Scoring;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Mods
|
namespace osu.Game.Rulesets.Mods
|
||||||
{
|
{
|
||||||
public abstract class ModAutoplay<T> : ModAutoplay, IApplicableToRulesetContainer<T>
|
public abstract class ModAutoplay<T> : ModAutoplay, IApplicableToDrawableRuleset<T>
|
||||||
where T : HitObject
|
where T : HitObject
|
||||||
{
|
{
|
||||||
public virtual void ApplyToRulesetContainer(RulesetContainer<T> rulesetContainer) => rulesetContainer.SetReplayScore(CreateReplayScore(rulesetContainer.Beatmap));
|
public virtual void ApplyToDrawableRuleset(DrawableRuleset<T> drawableRuleset) => drawableRuleset.SetReplayScore(CreateReplayScore(drawableRuleset.Beatmap));
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract class ModAutoplay : Mod, IApplicableFailOverride
|
public abstract class ModAutoplay : Mod, IApplicableFailOverride
|
||||||
|
@ -34,7 +34,7 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract class ModFlashlight<T> : ModFlashlight, IApplicableToRulesetContainer<T>, IApplicableToScoreProcessor
|
public abstract class ModFlashlight<T> : ModFlashlight, IApplicableToDrawableRuleset<T>, IApplicableToScoreProcessor
|
||||||
where T : HitObject
|
where T : HitObject
|
||||||
{
|
{
|
||||||
public const double FLASHLIGHT_FADE_DURATION = 800;
|
public const double FLASHLIGHT_FADE_DURATION = 800;
|
||||||
@ -45,15 +45,15 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
Combo.BindTo(scoreProcessor.Combo);
|
Combo.BindTo(scoreProcessor.Combo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void ApplyToRulesetContainer(RulesetContainer<T> rulesetContainer)
|
public virtual void ApplyToDrawableRuleset(DrawableRuleset<T> drawableRuleset)
|
||||||
{
|
{
|
||||||
var flashlight = CreateFlashlight();
|
var flashlight = CreateFlashlight();
|
||||||
flashlight.Combo = Combo;
|
flashlight.Combo = Combo;
|
||||||
flashlight.RelativeSizeAxes = Axes.Both;
|
flashlight.RelativeSizeAxes = Axes.Both;
|
||||||
flashlight.Colour = Color4.Black;
|
flashlight.Colour = Color4.Black;
|
||||||
rulesetContainer.KeyBindingInputManager.Add(flashlight);
|
drawableRuleset.KeyBindingInputManager.Add(flashlight);
|
||||||
|
|
||||||
flashlight.Breaks = rulesetContainer.Beatmap.Breaks;
|
flashlight.Breaks = drawableRuleset.Beatmap.Breaks;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract Flashlight CreateFlashlight();
|
public abstract Flashlight CreateFlashlight();
|
||||||
|
@ -8,12 +8,14 @@ namespace osu.Game.Rulesets.Objects.Legacy.Catch
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Legacy osu!catch Spinner-type, used for parsing Beatmaps.
|
/// Legacy osu!catch Spinner-type, used for parsing Beatmaps.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class ConvertSpinner : HitObject, IHasEndTime, IHasCombo
|
internal sealed class ConvertSpinner : HitObject, IHasEndTime, IHasXPosition, IHasCombo
|
||||||
{
|
{
|
||||||
public double EndTime { get; set; }
|
public double EndTime { get; set; }
|
||||||
|
|
||||||
public double Duration => EndTime - StartTime;
|
public double Duration => EndTime - StartTime;
|
||||||
|
|
||||||
|
public float X => 256; // Required for CatchBeatmapConverter
|
||||||
|
|
||||||
public bool NewCombo { get; set; }
|
public bool NewCombo { get; set; }
|
||||||
|
|
||||||
public int ComboOffset { get; set; }
|
public int ComboOffset { get; set; }
|
||||||
|
@ -55,7 +55,7 @@ namespace osu.Game.Rulesets
|
|||||||
/// <param name="beatmap">The beatmap to create the hit renderer for.</param>
|
/// <param name="beatmap">The beatmap to create the hit renderer for.</param>
|
||||||
/// <exception cref="BeatmapInvalidForRulesetException">Unable to successfully load the beatmap to be usable with this ruleset.</exception>
|
/// <exception cref="BeatmapInvalidForRulesetException">Unable to successfully load the beatmap to be usable with this ruleset.</exception>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public abstract RulesetContainer CreateRulesetContainerWith(WorkingBeatmap beatmap);
|
public abstract DrawableRuleset CreateDrawableRulesetWith(WorkingBeatmap beatmap);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a <see cref="IBeatmapConverter"/> to convert a <see cref="IBeatmap"/> to one that is applicable for this <see cref="Ruleset"/>.
|
/// Creates a <see cref="IBeatmapConverter"/> to convert a <see cref="IBeatmap"/> to one that is applicable for this <see cref="Ruleset"/>.
|
||||||
|
@ -210,15 +210,15 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScoreProcessor(RulesetContainer<TObject> rulesetContainer)
|
public ScoreProcessor(DrawableRuleset<TObject> drawableRuleset)
|
||||||
{
|
{
|
||||||
Debug.Assert(base_portion + combo_portion == 1.0);
|
Debug.Assert(base_portion + combo_portion == 1.0);
|
||||||
|
|
||||||
rulesetContainer.OnNewResult += applyResult;
|
drawableRuleset.OnNewResult += applyResult;
|
||||||
rulesetContainer.OnRevertResult += revertResult;
|
drawableRuleset.OnRevertResult += revertResult;
|
||||||
|
|
||||||
ApplyBeatmap(rulesetContainer.Beatmap);
|
ApplyBeatmap(drawableRuleset.Beatmap);
|
||||||
SimulateAutoplay(rulesetContainer.Beatmap);
|
SimulateAutoplay(drawableRuleset.Beatmap);
|
||||||
Reset(true);
|
Reset(true);
|
||||||
|
|
||||||
if (maxBaseScore == 0 || maxHighestCombo == 0)
|
if (maxBaseScore == 0 || maxHighestCombo == 0)
|
||||||
|
@ -25,16 +25,16 @@ using osu.Game.Replays;
|
|||||||
using osu.Game.Rulesets.Configuration;
|
using osu.Game.Rulesets.Configuration;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
|
using osu.Game.Screens.Play;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.UI
|
namespace osu.Game.Rulesets.UI
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Base RulesetContainer. Doesn't hold objects.
|
/// Displays an interactive ruleset gameplay instance.
|
||||||
/// <para>
|
|
||||||
/// Should not be derived - derive <see cref="RulesetContainer{TObject}"/> instead.
|
|
||||||
/// </para>
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class RulesetContainer : Container, IProvideCursor
|
/// <typeparam name="TObject">The type of HitObject contained by this DrawableRuleset.</typeparam>
|
||||||
|
public abstract class DrawableRuleset<TObject> : DrawableRuleset, IProvideCursor, ICanAttachKeyCounter
|
||||||
|
where TObject : HitObject
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The selected variant.
|
/// The selected variant.
|
||||||
@ -42,27 +42,11 @@ namespace osu.Game.Rulesets.UI
|
|||||||
public virtual int Variant => 0;
|
public virtual int Variant => 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The input manager for this RulesetContainer.
|
/// The key conversion input manager for this DrawableRuleset.
|
||||||
/// </summary>
|
|
||||||
internal IHasReplayHandler ReplayInputManager => KeyBindingInputManager as IHasReplayHandler;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The key conversion input manager for this RulesetContainer.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public PassThroughInputManager KeyBindingInputManager;
|
public PassThroughInputManager KeyBindingInputManager;
|
||||||
|
|
||||||
/// <summary>
|
public override double GameplayStartTime => Objects.First().StartTime - 2000;
|
||||||
/// Whether a replay is currently loaded.
|
|
||||||
/// </summary>
|
|
||||||
public readonly BindableBool HasReplayLoaded = new BindableBool();
|
|
||||||
|
|
||||||
public abstract IEnumerable<HitObject> Objects { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The point in time at which gameplay starts, including any required lead-in for display purposes.
|
|
||||||
/// Defaults to two seconds before the first <see cref="HitObject"/>. Override as necessary.
|
|
||||||
/// </summary>
|
|
||||||
public virtual double GameplayStartTime => Objects.First().StartTime - 2000;
|
|
||||||
|
|
||||||
private readonly Lazy<Playfield> playfield;
|
private readonly Lazy<Playfield> playfield;
|
||||||
|
|
||||||
@ -74,27 +58,54 @@ namespace osu.Game.Rulesets.UI
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Place to put drawables above hit objects but below UI.
|
/// Place to put drawables above hit objects but below UI.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Container Overlays { get; protected set; }
|
public Container Overlays { get; private set; }
|
||||||
|
|
||||||
public CursorContainer Cursor => Playfield.Cursor;
|
/// <summary>
|
||||||
|
/// Invoked when a <see cref="JudgementResult"/> has been applied by a <see cref="DrawableHitObject"/>.
|
||||||
|
/// </summary>
|
||||||
|
public event Action<JudgementResult> OnNewResult;
|
||||||
|
|
||||||
public bool ProvidingUserCursor => Playfield.Cursor != null && !HasReplayLoaded.Value;
|
/// <summary>
|
||||||
|
/// Invoked when a <see cref="JudgementResult"/> is being reverted by a <see cref="DrawableHitObject"/>.
|
||||||
|
/// </summary>
|
||||||
|
public event Action<JudgementResult> OnRevertResult;
|
||||||
|
|
||||||
protected override bool OnHover(HoverEvent e) => true; // required for IProvideCursor
|
/// <summary>
|
||||||
|
/// The beatmap.
|
||||||
|
/// </summary>
|
||||||
|
public Beatmap<TObject> Beatmap;
|
||||||
|
|
||||||
public readonly Ruleset Ruleset;
|
public override IEnumerable<HitObject> Objects => Beatmap.HitObjects;
|
||||||
|
|
||||||
protected IRulesetConfigManager Config { get; private set; }
|
protected IRulesetConfigManager Config { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The mods which are to be applied.
|
||||||
|
/// </summary>
|
||||||
|
private readonly IEnumerable<Mod> mods;
|
||||||
|
|
||||||
|
private FrameStabilityContainer frameStabilityContainer;
|
||||||
|
|
||||||
private OnScreenDisplay onScreenDisplay;
|
private OnScreenDisplay onScreenDisplay;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A visual representation of a <see cref="Rulesets.Ruleset"/>.
|
/// Creates a ruleset visualisation for the provided ruleset and beatmap.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="ruleset">The ruleset being repesented.</param>
|
/// <param name="ruleset">The ruleset being represented.</param>
|
||||||
protected RulesetContainer(Ruleset ruleset)
|
/// <param name="workingBeatmap">The beatmap to create the hit renderer for.</param>
|
||||||
|
protected DrawableRuleset(Ruleset ruleset, WorkingBeatmap workingBeatmap)
|
||||||
|
: base(ruleset)
|
||||||
{
|
{
|
||||||
Ruleset = ruleset;
|
Debug.Assert(workingBeatmap != null, "DrawableRuleset initialized with a null beatmap.");
|
||||||
|
|
||||||
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
|
Beatmap = (Beatmap<TObject>)workingBeatmap.GetPlayableBeatmap(ruleset.RulesetInfo);
|
||||||
|
|
||||||
|
mods = workingBeatmap.Mods.Value;
|
||||||
|
applyBeatmapMods(mods);
|
||||||
|
|
||||||
|
KeyBindingInputManager = CreateInputManager();
|
||||||
playfield = new Lazy<Playfield>(CreatePlayfield);
|
playfield = new Lazy<Playfield>(CreatePlayfield);
|
||||||
|
|
||||||
IsPaused.ValueChanged += paused =>
|
IsPaused.ValueChanged += paused =>
|
||||||
@ -122,156 +133,101 @@ namespace osu.Game.Rulesets.UI
|
|||||||
return dependencies;
|
return dependencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract ScoreProcessor CreateScoreProcessor();
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuConfigManager config)
|
||||||
|
{
|
||||||
|
KeyBindingInputManager.AddRange(new Drawable[]
|
||||||
|
{
|
||||||
|
Playfield
|
||||||
|
});
|
||||||
|
|
||||||
|
InternalChildren = new Drawable[]
|
||||||
|
{
|
||||||
|
frameStabilityContainer = new FrameStabilityContainer
|
||||||
|
{
|
||||||
|
Child = KeyBindingInputManager,
|
||||||
|
},
|
||||||
|
Overlays = new Container { RelativeSizeAxes = Axes.Both }
|
||||||
|
};
|
||||||
|
|
||||||
|
applyRulesetMods(mods, config);
|
||||||
|
|
||||||
|
loadObjects();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates and adds drawable representations of hit objects to the play field.
|
||||||
|
/// </summary>
|
||||||
|
private void loadObjects()
|
||||||
|
{
|
||||||
|
foreach (TObject h in Beatmap.HitObjects)
|
||||||
|
addRepresentation(h);
|
||||||
|
|
||||||
|
Playfield.PostProcess();
|
||||||
|
|
||||||
|
foreach (var mod in mods.OfType<IApplicableToDrawableHitObjects>())
|
||||||
|
mod.ApplyToDrawableHitObjects(Playfield.HitObjectContainer.Objects);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates and adds the visual representation of a <see cref="TObject"/> to this <see cref="DrawableRuleset{TObject}"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hitObject">The <see cref="TObject"/> to add the visual representation for.</param>
|
||||||
|
private void addRepresentation(TObject hitObject)
|
||||||
|
{
|
||||||
|
var drawableObject = GetVisualRepresentation(hitObject);
|
||||||
|
|
||||||
|
if (drawableObject == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
drawableObject.OnNewResult += (_, r) => OnNewResult?.Invoke(r);
|
||||||
|
drawableObject.OnRevertResult += (_, r) => OnRevertResult?.Invoke(r);
|
||||||
|
|
||||||
|
Playfield.Add(drawableObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void SetReplayScore(Score replayScore)
|
||||||
|
{
|
||||||
|
if (!(KeyBindingInputManager is IHasReplayHandler replayInputManager))
|
||||||
|
throw new InvalidOperationException($"A {nameof(KeyBindingInputManager)} which supports replay loading is not available");
|
||||||
|
|
||||||
|
var handler = (ReplayScore = replayScore) != null ? CreateReplayInputHandler(replayScore.Replay) : null;
|
||||||
|
|
||||||
|
replayInputManager.ReplayInputHandler = handler;
|
||||||
|
frameStabilityContainer.ReplayInputHandler = handler;
|
||||||
|
|
||||||
|
HasReplayLoaded.Value = replayInputManager.ReplayInputHandler != null;
|
||||||
|
|
||||||
|
if (replayInputManager.ReplayInputHandler != null)
|
||||||
|
replayInputManager.ReplayInputHandler.GamefieldToScreenSpace = Playfield.GamefieldToScreenSpace;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a DrawableHitObject from a HitObject.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="h">The HitObject to make drawable.</param>
|
||||||
|
/// <returns>The DrawableHitObject.</returns>
|
||||||
|
public abstract DrawableHitObject<TObject> GetVisualRepresentation(TObject h);
|
||||||
|
|
||||||
|
public void Attach(KeyCounterCollection keyCounter) =>
|
||||||
|
(KeyBindingInputManager as ICanAttachKeyCounter)?.Attach(keyCounter);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a key conversion input manager. An exception will be thrown if a valid <see cref="RulesetInputManager{T}"/> is not returned.
|
/// Creates a key conversion input manager. An exception will be thrown if a valid <see cref="RulesetInputManager{T}"/> is not returned.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>The input manager.</returns>
|
/// <returns>The input manager.</returns>
|
||||||
public abstract PassThroughInputManager CreateInputManager();
|
protected abstract PassThroughInputManager CreateInputManager();
|
||||||
|
|
||||||
protected virtual ReplayInputHandler CreateReplayInputHandler(Replay replay) => null;
|
protected virtual ReplayInputHandler CreateReplayInputHandler(Replay replay) => null;
|
||||||
|
|
||||||
public Score ReplayScore { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Whether the game is paused. Used to block user input.
|
|
||||||
/// </summary>
|
|
||||||
public readonly BindableBool IsPaused = new BindableBool();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sets a replay to be used, overriding local input.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="replayScore">The replay, null for local input.</param>
|
|
||||||
public virtual void SetReplayScore(Score replayScore)
|
|
||||||
{
|
|
||||||
if (ReplayInputManager == null)
|
|
||||||
throw new InvalidOperationException($"A {nameof(KeyBindingInputManager)} which supports replay loading is not available");
|
|
||||||
|
|
||||||
ReplayScore = replayScore;
|
|
||||||
ReplayInputManager.ReplayInputHandler = replayScore != null ? CreateReplayInputHandler(replayScore.Replay) : null;
|
|
||||||
|
|
||||||
HasReplayLoaded.Value = ReplayInputManager.ReplayInputHandler != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates the cursor. May be null if the <see cref="RulesetContainer"/> doesn't provide a custom cursor.
|
|
||||||
/// </summary>
|
|
||||||
protected virtual CursorContainer CreateCursor() => null;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a Playfield.
|
/// Creates a Playfield.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>The Playfield.</returns>
|
/// <returns>The Playfield.</returns>
|
||||||
protected abstract Playfield CreatePlayfield();
|
protected abstract Playfield CreatePlayfield();
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
|
||||||
{
|
|
||||||
base.Dispose(isDisposing);
|
|
||||||
|
|
||||||
if (Config != null)
|
|
||||||
{
|
|
||||||
onScreenDisplay?.StopTracking(this, Config);
|
|
||||||
Config = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// RulesetContainer that applies conversion to Beatmaps. Does not contain a Playfield
|
|
||||||
/// and does not load drawable hit objects.
|
|
||||||
/// <para>
|
|
||||||
/// Should not be derived - derive <see cref="RulesetContainer{TPlayfield, TObject}"/> instead.
|
|
||||||
/// </para>
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="TObject">The type of HitObject contained by this RulesetContainer.</typeparam>
|
|
||||||
public abstract class RulesetContainer<TObject> : RulesetContainer
|
|
||||||
where TObject : HitObject
|
|
||||||
{
|
|
||||||
/// <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;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// All the converted hit objects contained by this hit renderer.
|
|
||||||
/// </summary>
|
|
||||||
public override IEnumerable<HitObject> Objects => Beatmap.HitObjects;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The mods which are to be applied.
|
|
||||||
/// </summary>
|
|
||||||
protected IEnumerable<Mod> Mods;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The <see cref="WorkingBeatmap"/> this <see cref="RulesetContainer{TObject}"/> was created with.
|
|
||||||
/// </summary>
|
|
||||||
protected readonly WorkingBeatmap WorkingBeatmap;
|
|
||||||
|
|
||||||
public override ScoreProcessor CreateScoreProcessor() => new ScoreProcessor<TObject>(this);
|
public override ScoreProcessor CreateScoreProcessor() => new ScoreProcessor<TObject>(this);
|
||||||
|
|
||||||
protected override Container<Drawable> Content => content;
|
|
||||||
private Container content;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Whether to assume the beatmap passed into this <see cref="RulesetContainer{TObject}"/> is for the current ruleset.
|
|
||||||
/// Creates a hit renderer for a beatmap.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="ruleset">The ruleset being repesented.</param>
|
|
||||||
/// <param name="workingBeatmap">The beatmap to create the hit renderer for.</param>
|
|
||||||
protected RulesetContainer(Ruleset ruleset, WorkingBeatmap workingBeatmap)
|
|
||||||
: base(ruleset)
|
|
||||||
{
|
|
||||||
Debug.Assert(workingBeatmap != null, "RulesetContainer initialized with a null beatmap.");
|
|
||||||
|
|
||||||
WorkingBeatmap = workingBeatmap;
|
|
||||||
// ReSharper disable once PossibleNullReferenceException
|
|
||||||
Mods = workingBeatmap.Mods.Value;
|
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.Both;
|
|
||||||
|
|
||||||
Beatmap = (Beatmap<TObject>)workingBeatmap.GetPlayableBeatmap(ruleset.RulesetInfo);
|
|
||||||
|
|
||||||
KeyBindingInputManager = CreateInputManager();
|
|
||||||
KeyBindingInputManager.RelativeSizeAxes = Axes.Both;
|
|
||||||
|
|
||||||
applyBeatmapMods(Mods);
|
|
||||||
}
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load(OsuConfigManager config)
|
|
||||||
{
|
|
||||||
KeyBindingInputManager.AddRange(new Drawable[]
|
|
||||||
{
|
|
||||||
content = new Container
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
},
|
|
||||||
Playfield
|
|
||||||
});
|
|
||||||
|
|
||||||
InternalChildren = new Drawable[]
|
|
||||||
{
|
|
||||||
KeyBindingInputManager,
|
|
||||||
Overlays = new Container { RelativeSizeAxes = Axes.Both }
|
|
||||||
};
|
|
||||||
|
|
||||||
// Apply mods
|
|
||||||
applyRulesetMods(Mods, config);
|
|
||||||
|
|
||||||
loadObjects();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Applies the active mods to the Beatmap.
|
/// Applies the active mods to the Beatmap.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -286,7 +242,7 @@ namespace osu.Game.Rulesets.UI
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Applies the active mods to this RulesetContainer.
|
/// Applies the active mods to this DrawableRuleset.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="mods"></param>
|
/// <param name="mods"></param>
|
||||||
private void applyRulesetMods(IEnumerable<Mod> mods, OsuConfigManager config)
|
private void applyRulesetMods(IEnumerable<Mod> mods, OsuConfigManager config)
|
||||||
@ -294,83 +250,101 @@ namespace osu.Game.Rulesets.UI
|
|||||||
if (mods == null)
|
if (mods == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (var mod in mods.OfType<IApplicableToRulesetContainer<TObject>>())
|
foreach (var mod in mods.OfType<IApplicableToDrawableRuleset<TObject>>())
|
||||||
mod.ApplyToRulesetContainer(this);
|
mod.ApplyToDrawableRuleset(this);
|
||||||
|
|
||||||
foreach (var mod in mods.OfType<IReadFromConfig>())
|
foreach (var mod in mods.OfType<IReadFromConfig>())
|
||||||
mod.ReadFromConfig(config);
|
mod.ReadFromConfig(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SetReplayScore(Score replayScore)
|
#region IProvideCursor
|
||||||
|
|
||||||
|
protected override bool OnHover(HoverEvent e) => true; // required for IProvideCursor
|
||||||
|
|
||||||
|
public override CursorContainer Cursor => Playfield.Cursor;
|
||||||
|
|
||||||
|
public bool ProvidingUserCursor => Playfield.Cursor != null && !HasReplayLoaded.Value;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
base.SetReplayScore(replayScore);
|
base.Dispose(isDisposing);
|
||||||
|
|
||||||
if (ReplayInputManager?.ReplayInputHandler != null)
|
if (Config != null)
|
||||||
ReplayInputManager.ReplayInputHandler.GamefieldToScreenSpace = Playfield.GamefieldToScreenSpace;
|
{
|
||||||
|
onScreenDisplay?.StopTracking(this, Config);
|
||||||
|
Config = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates and adds drawable representations of hit objects to the play field.
|
|
||||||
/// </summary>
|
|
||||||
private void loadObjects()
|
|
||||||
{
|
|
||||||
foreach (TObject h in Beatmap.HitObjects)
|
|
||||||
AddRepresentation(h);
|
|
||||||
|
|
||||||
Playfield.PostProcess();
|
|
||||||
|
|
||||||
foreach (var mod in Mods.OfType<IApplicableToDrawableHitObjects>())
|
|
||||||
mod.ApplyToDrawableHitObjects(Playfield.HitObjectContainer.Objects);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates and adds the visual representation of a <see cref="TObject"/> to this <see cref="RulesetContainer{TObject}"/>.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="hitObject">The <see cref="TObject"/> to add the visual representation for.</param>
|
|
||||||
internal void AddRepresentation(TObject hitObject)
|
|
||||||
{
|
|
||||||
var drawableObject = GetVisualRepresentation(hitObject);
|
|
||||||
|
|
||||||
if (drawableObject == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
drawableObject.OnNewResult += (_, r) => OnNewResult?.Invoke(r);
|
|
||||||
drawableObject.OnRevertResult += (_, r) => OnRevertResult?.Invoke(r);
|
|
||||||
|
|
||||||
Playfield.Add(drawableObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates a DrawableHitObject from a HitObject.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="h">The HitObject to make drawable.</param>
|
|
||||||
/// <returns>The DrawableHitObject.</returns>
|
|
||||||
public abstract DrawableHitObject<TObject> GetVisualRepresentation(TObject h);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A derivable RulesetContainer that manages the Playfield and HitObjects.
|
/// Displays an interactive ruleset gameplay instance.
|
||||||
|
/// <remarks>
|
||||||
|
/// This type is required only for adding non-generic type to the draw hierarchy.
|
||||||
|
/// Once IDrawable is a thing, this can also become an interface.
|
||||||
|
/// </remarks>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TPlayfield">The type of Playfield contained by this RulesetContainer.</typeparam>
|
public abstract class DrawableRuleset : CompositeDrawable
|
||||||
/// <typeparam name="TObject">The type of HitObject contained by this RulesetContainer.</typeparam>
|
|
||||||
public abstract class RulesetContainer<TPlayfield, TObject> : RulesetContainer<TObject>
|
|
||||||
where TObject : HitObject
|
|
||||||
where TPlayfield : Playfield
|
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The playfield.
|
/// Whether a replay is currently loaded.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected new TPlayfield Playfield => (TPlayfield)base.Playfield;
|
public readonly BindableBool HasReplayLoaded = new BindableBool();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a hit renderer for a beatmap.
|
/// Whether the game is paused. Used to block user input.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="ruleset">The ruleset being repesented.</param>
|
public readonly BindableBool IsPaused = new BindableBool();
|
||||||
/// <param name="beatmap">The beatmap to create the hit renderer for.</param>
|
|
||||||
protected RulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap)
|
/// <summary>~
|
||||||
: base(ruleset, beatmap)
|
/// The associated ruleset.
|
||||||
|
/// </summary>
|
||||||
|
public readonly Ruleset Ruleset;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a ruleset visualisation for the provided ruleset.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ruleset">The ruleset.</param>
|
||||||
|
internal DrawableRuleset(Ruleset ruleset)
|
||||||
{
|
{
|
||||||
|
Ruleset = ruleset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// All the converted hit objects contained by this hit renderer.
|
||||||
|
/// </summary>
|
||||||
|
public abstract IEnumerable<HitObject> Objects { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The point in time at which gameplay starts, including any required lead-in for display purposes.
|
||||||
|
/// Defaults to two seconds before the first <see cref="HitObject"/>. Override as necessary.
|
||||||
|
/// </summary>
|
||||||
|
public abstract double GameplayStartTime { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The currently loaded replay. Usually null in the case of a local player.
|
||||||
|
/// </summary>
|
||||||
|
public Score ReplayScore { get; protected set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The cursor being displayed by the <see cref="Playfield"/>. May be null if no cursor is provided.
|
||||||
|
/// </summary>
|
||||||
|
public abstract CursorContainer Cursor { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets a replay to be used, overriding local input.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="replayScore">The replay, null for local input.</param>
|
||||||
|
public abstract void SetReplayScore(Score replayScore);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create a <see cref="ScoreProcessor"/> for the associated ruleset and link with this
|
||||||
|
/// <see cref="DrawableRuleset"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A score processor.</returns>
|
||||||
|
public abstract ScoreProcessor CreateScoreProcessor();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BeatmapInvalidForRulesetException : ArgumentException
|
public class BeatmapInvalidForRulesetException : ArgumentException
|
153
osu.Game/Rulesets/UI/FrameStabilityContainer.cs
Normal file
153
osu.Game/Rulesets/UI/FrameStabilityContainer.cs
Normal file
@ -0,0 +1,153 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Timing;
|
||||||
|
using osu.Game.Input.Handlers;
|
||||||
|
using osu.Game.Screens.Play;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.UI
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A container which consumes a parent gameplay clock and standardises frame counts for children.
|
||||||
|
/// Will ensure a minimum of 40 frames per clock second is maintained, regardless of any system lag or seeks.
|
||||||
|
/// </summary>
|
||||||
|
public class FrameStabilityContainer : Container, IHasReplayHandler
|
||||||
|
{
|
||||||
|
public FrameStabilityContainer()
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
gameplayClock = new GameplayClock(framedClock = new FramedClock(manualClock = new ManualClock()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly ManualClock manualClock;
|
||||||
|
|
||||||
|
private readonly FramedClock framedClock;
|
||||||
|
|
||||||
|
[Cached]
|
||||||
|
private GameplayClock gameplayClock;
|
||||||
|
|
||||||
|
private IFrameBasedClock parentGameplayClock;
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader(true)]
|
||||||
|
private void load(GameplayClock clock)
|
||||||
|
{
|
||||||
|
if (clock != null)
|
||||||
|
parentGameplayClock = clock;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
setClock();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether we are running up-to-date with our parent clock.
|
||||||
|
/// If not, we will need to keep processing children until we catch up.
|
||||||
|
/// </summary>
|
||||||
|
private bool requireMoreUpdateLoops;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether we are in a valid state (ie. should we keep processing children frames).
|
||||||
|
/// This should be set to false when the replay is, for instance, waiting for future frames to arrive.
|
||||||
|
/// </summary>
|
||||||
|
private bool validState;
|
||||||
|
|
||||||
|
protected override bool RequiresChildrenUpdate => base.RequiresChildrenUpdate && validState;
|
||||||
|
|
||||||
|
private bool isAttached => ReplayInputHandler != null;
|
||||||
|
|
||||||
|
private const int max_catch_up_updates_per_frame = 50;
|
||||||
|
|
||||||
|
private const double sixty_frame_time = 1000.0 / 60;
|
||||||
|
|
||||||
|
public override bool UpdateSubTree()
|
||||||
|
{
|
||||||
|
requireMoreUpdateLoops = true;
|
||||||
|
validState = true;
|
||||||
|
|
||||||
|
int loops = 0;
|
||||||
|
|
||||||
|
while (validState && requireMoreUpdateLoops && loops++ < max_catch_up_updates_per_frame)
|
||||||
|
{
|
||||||
|
updateClock();
|
||||||
|
|
||||||
|
if (validState)
|
||||||
|
{
|
||||||
|
base.UpdateSubTree();
|
||||||
|
UpdateSubTreeMasking(this, ScreenSpaceDrawQuad.AABBFloat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateClock()
|
||||||
|
{
|
||||||
|
if (parentGameplayClock == null)
|
||||||
|
setClock(); // LoadComplete may not be run yet, but we still want the clock.
|
||||||
|
|
||||||
|
validState = true;
|
||||||
|
|
||||||
|
manualClock.Rate = parentGameplayClock.Rate;
|
||||||
|
manualClock.IsRunning = parentGameplayClock.IsRunning;
|
||||||
|
|
||||||
|
var newProposedTime = parentGameplayClock.CurrentTime;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (Math.Abs(manualClock.CurrentTime - newProposedTime) > sixty_frame_time * 1.2f)
|
||||||
|
{
|
||||||
|
newProposedTime = manualClock.Rate > 0
|
||||||
|
? Math.Min(newProposedTime, manualClock.CurrentTime + sixty_frame_time)
|
||||||
|
: Math.Max(newProposedTime, manualClock.CurrentTime - sixty_frame_time);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isAttached)
|
||||||
|
{
|
||||||
|
manualClock.CurrentTime = newProposedTime;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
double? newTime = ReplayInputHandler.SetFrameFromTime(newProposedTime);
|
||||||
|
|
||||||
|
if (newTime == null)
|
||||||
|
{
|
||||||
|
// we shouldn't execute for this time value. probably waiting on more replay data.
|
||||||
|
validState = false;
|
||||||
|
|
||||||
|
requireMoreUpdateLoops = true;
|
||||||
|
manualClock.CurrentTime = newProposedTime;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
manualClock.CurrentTime = newTime.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
requireMoreUpdateLoops = manualClock.CurrentTime != parentGameplayClock.CurrentTime;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// The manual clock time has changed in the above code. The framed clock now needs to be updated
|
||||||
|
// to ensure that the its time is valid for our children before input is processed
|
||||||
|
framedClock.ProcessFrame();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setClock()
|
||||||
|
{
|
||||||
|
// in case a parent gameplay clock isn't available, just use the parent clock.
|
||||||
|
if (parentGameplayClock == null)
|
||||||
|
parentGameplayClock = Clock;
|
||||||
|
|
||||||
|
Clock = gameplayClock;
|
||||||
|
ProcessCustomClock = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReplayInputHandler ReplayInputHandler { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
@ -12,7 +11,6 @@ using osu.Framework.Input.Bindings;
|
|||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Framework.Input.StateChanges.Events;
|
using osu.Framework.Input.StateChanges.Events;
|
||||||
using osu.Framework.Input.States;
|
using osu.Framework.Input.States;
|
||||||
using osu.Framework.Timing;
|
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Input.Bindings;
|
using osu.Game.Input.Bindings;
|
||||||
using osu.Game.Input.Handlers;
|
using osu.Game.Input.Handlers;
|
||||||
@ -41,7 +39,12 @@ namespace osu.Game.Rulesets.UI
|
|||||||
protected RulesetInputManager(RulesetInfo ruleset, int variant, SimultaneousBindingMode unique)
|
protected RulesetInputManager(RulesetInfo ruleset, int variant, SimultaneousBindingMode unique)
|
||||||
{
|
{
|
||||||
InternalChild = KeyBindingContainer = CreateKeyBindingContainer(ruleset, variant, unique);
|
InternalChild = KeyBindingContainer = CreateKeyBindingContainer(ruleset, variant, unique);
|
||||||
gameplayClock = new GameplayClock(framedClock = new FramedClock(manualClock = new ManualClock()));
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader(true)]
|
||||||
|
private void load(OsuConfigManager config)
|
||||||
|
{
|
||||||
|
mouseDisabled = config.GetBindable<bool>(OsuSetting.MouseDisableButtons);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Action mapping (for replays)
|
#region Action mapping (for replays)
|
||||||
@ -85,137 +88,6 @@ namespace osu.Game.Rulesets.UI
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Clock control
|
|
||||||
|
|
||||||
private readonly ManualClock manualClock;
|
|
||||||
|
|
||||||
private readonly FramedClock framedClock;
|
|
||||||
|
|
||||||
[Cached]
|
|
||||||
private GameplayClock gameplayClock;
|
|
||||||
|
|
||||||
private IFrameBasedClock parentGameplayClock;
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
|
||||||
private void load(OsuConfigManager config, GameplayClock clock)
|
|
||||||
{
|
|
||||||
mouseDisabled = config.GetBindable<bool>(OsuSetting.MouseDisableButtons);
|
|
||||||
|
|
||||||
if (clock != null)
|
|
||||||
parentGameplayClock = clock;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void LoadComplete()
|
|
||||||
{
|
|
||||||
base.LoadComplete();
|
|
||||||
setClock();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Whether we are running up-to-date with our parent clock.
|
|
||||||
/// If not, we will need to keep processing children until we catch up.
|
|
||||||
/// </summary>
|
|
||||||
private bool requireMoreUpdateLoops;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Whether we are in a valid state (ie. should we keep processing children frames).
|
|
||||||
/// This should be set to false when the replay is, for instance, waiting for future frames to arrive.
|
|
||||||
/// </summary>
|
|
||||||
private bool validState;
|
|
||||||
|
|
||||||
protected override bool RequiresChildrenUpdate => base.RequiresChildrenUpdate && validState;
|
|
||||||
|
|
||||||
private bool isAttached => replayInputHandler != null && !UseParentInput;
|
|
||||||
|
|
||||||
private const int max_catch_up_updates_per_frame = 50;
|
|
||||||
|
|
||||||
private const double sixty_frame_time = 1000.0 / 60;
|
|
||||||
|
|
||||||
public override bool UpdateSubTree()
|
|
||||||
{
|
|
||||||
requireMoreUpdateLoops = true;
|
|
||||||
validState = true;
|
|
||||||
|
|
||||||
int loops = 0;
|
|
||||||
|
|
||||||
while (validState && requireMoreUpdateLoops && loops++ < max_catch_up_updates_per_frame)
|
|
||||||
{
|
|
||||||
updateClock();
|
|
||||||
|
|
||||||
if (validState)
|
|
||||||
{
|
|
||||||
base.UpdateSubTree();
|
|
||||||
UpdateSubTreeMasking(this, ScreenSpaceDrawQuad.AABBFloat);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateClock()
|
|
||||||
{
|
|
||||||
if (parentGameplayClock == null)
|
|
||||||
setClock(); // LoadComplete may not be run yet, but we still want the clock.
|
|
||||||
|
|
||||||
validState = true;
|
|
||||||
|
|
||||||
manualClock.Rate = parentGameplayClock.Rate;
|
|
||||||
manualClock.IsRunning = parentGameplayClock.IsRunning;
|
|
||||||
|
|
||||||
var newProposedTime = parentGameplayClock.CurrentTime;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (Math.Abs(manualClock.CurrentTime - newProposedTime) > sixty_frame_time * 1.2f)
|
|
||||||
{
|
|
||||||
newProposedTime = manualClock.Rate > 0
|
|
||||||
? Math.Min(newProposedTime, manualClock.CurrentTime + sixty_frame_time)
|
|
||||||
: Math.Max(newProposedTime, manualClock.CurrentTime - sixty_frame_time);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isAttached)
|
|
||||||
{
|
|
||||||
manualClock.CurrentTime = newProposedTime;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
double? newTime = replayInputHandler.SetFrameFromTime(newProposedTime);
|
|
||||||
|
|
||||||
if (newTime == null)
|
|
||||||
{
|
|
||||||
// we shouldn't execute for this time value. probably waiting on more replay data.
|
|
||||||
validState = false;
|
|
||||||
|
|
||||||
requireMoreUpdateLoops = true;
|
|
||||||
manualClock.CurrentTime = newProposedTime;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
manualClock.CurrentTime = newTime.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
requireMoreUpdateLoops = manualClock.CurrentTime != parentGameplayClock.CurrentTime;
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
// The manual clock time has changed in the above code. The framed clock now needs to be updated
|
|
||||||
// to ensure that the its time is valid for our children before input is processed
|
|
||||||
framedClock.ProcessFrame();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setClock()
|
|
||||||
{
|
|
||||||
// in case a parent gameplay clock isn't available, just use the parent clock.
|
|
||||||
if (parentGameplayClock == null)
|
|
||||||
parentGameplayClock = Clock;
|
|
||||||
|
|
||||||
Clock = gameplayClock;
|
|
||||||
ProcessCustomClock = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Setting application (disables etc.)
|
#region Setting application (disables etc.)
|
||||||
|
|
||||||
private Bindable<bool> mouseDisabled;
|
private Bindable<bool> mouseDisabled;
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user