1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 10:12:54 +08:00

Merge branch 'master' into expand-social-tab

This commit is contained in:
Dean Herbert 2018-01-12 15:54:42 +09:00 committed by GitHub
commit 8f7c048c4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 183 additions and 147 deletions

@ -1 +1 @@
Subproject commit 80bcb82ef8d2e1af1ce077f4a037b6d279ad9e74
Subproject commit 65947291229541de3eb1aff0e703f6968b07f976

View File

@ -101,7 +101,7 @@ namespace osu.Game.Rulesets.Catch
public override int LegacyID => 2;
public CatchRuleset(RulesetInfo rulesetInfo)
public CatchRuleset(RulesetInfo rulesetInfo = null)
: base(rulesetInfo)
{
}

View File

@ -9,7 +9,7 @@ namespace osu.Game.Rulesets.Catch.Tests
[Ignore("getting CI working")]
public class TestCaseCatchPlayer : Game.Tests.Visual.TestCasePlayer
{
public TestCaseCatchPlayer() : base(typeof(CatchRuleset))
public TestCaseCatchPlayer() : base(new CatchRuleset())
{
}
}

View File

@ -12,7 +12,7 @@ namespace osu.Game.Rulesets.Catch.Tests
public class TestCaseCatchStacker : Game.Tests.Visual.TestCasePlayer
{
public TestCaseCatchStacker()
: base(typeof(CatchRuleset))
: base(new CatchRuleset())
{
}

View File

@ -12,7 +12,7 @@ namespace osu.Game.Rulesets.Catch.Tests
public class TestCaseHyperdash : Game.Tests.Visual.TestCasePlayer
{
public TestCaseHyperdash()
: base(typeof(CatchRuleset))
: base(new CatchRuleset())
{
}

View File

@ -9,7 +9,7 @@ namespace osu.Game.Rulesets.Catch.Tests
public class TestCasePerformancePoints : Game.Tests.Visual.TestCasePerformancePoints
{
public TestCasePerformancePoints()
: base(new CatchRuleset(new RulesetInfo()))
: base(new CatchRuleset())
{
}
}

View File

@ -3,7 +3,6 @@
using osu.Framework.Graphics;
using osu.Game.Rulesets.UI;
using OpenTK;
using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Catch.Objects;
@ -23,7 +22,7 @@ namespace osu.Game.Rulesets.Catch.UI
private readonly CatcherArea catcherArea;
public CatchPlayfield(BeatmapDifficulty difficulty)
: base(Axes.Y)
: base(Axes.Y, BASE_WIDTH)
{
Container explodingFruitContainer;
@ -32,7 +31,10 @@ namespace osu.Game.Rulesets.Catch.UI
Anchor = Anchor.TopCentre;
Origin = Anchor.TopCentre;
InternalChildren = new Drawable[]
ScaledContent.Anchor = Anchor.BottomLeft;
ScaledContent.Origin = Anchor.BottomLeft;
ScaledContent.AddRange(new Drawable[]
{
content = new Container<Drawable>
{
@ -48,7 +50,7 @@ namespace osu.Game.Rulesets.Catch.UI
Anchor = Anchor.BottomLeft,
Origin = Anchor.TopLeft,
}
};
});
}
public bool CheckIfWeCanCatch(CatchHitObject obj) => catcherArea.AttemptCatch(obj);
@ -63,18 +65,6 @@ namespace osu.Game.Rulesets.Catch.UI
fruit.CheckPosition = CheckIfWeCanCatch;
}
public override void OnJudgement(DrawableHitObject judgedObject, Judgement judgement)
{
if (judgement.IsHit)
{
Vector2 screenPosition = judgedObject.ScreenSpaceDrawQuad.Centre;
// todo: don't do this
(judgedObject.Parent as Container<DrawableHitObject>)?.Remove(judgedObject);
(judgedObject.Parent as Container)?.Remove(judgedObject);
catcherArea.Add(judgedObject, screenPosition);
}
}
public override void OnJudgement(DrawableHitObject judgedObject, Judgement judgement) => catcherArea.OnJudgement((DrawableCatchHitObject)judgedObject, judgement);
}
}

View File

@ -12,6 +12,8 @@ using osu.Framework.Input.Bindings;
using osu.Framework.MathUtils;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Catch.Objects.Drawable;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects.Drawables;
using OpenTK;
using OpenTK.Graphics;
@ -39,17 +41,34 @@ namespace osu.Game.Rulesets.Catch.UI
};
}
public void Add(DrawableHitObject fruit, Vector2 absolutePosition)
public void OnJudgement(DrawableCatchHitObject fruit, Judgement judgement)
{
fruit.RelativePositionAxes = Axes.None;
fruit.Position = new Vector2(MovableCatcher.ToLocalSpace(absolutePosition).X - MovableCatcher.DrawSize.X / 2, 0);
if (judgement.IsHit)
{
var screenSpacePosition = fruit.ScreenSpaceDrawQuad.Centre;
fruit.Anchor = Anchor.TopCentre;
fruit.Origin = Anchor.BottomCentre;
fruit.Scale *= 0.7f;
fruit.LifetimeEnd = double.MaxValue;
// todo: make this less ugly, somehow.
(fruit.Parent as Container<DrawableHitObject>)?.Remove(fruit);
(fruit.Parent as Container)?.Remove(fruit);
MovableCatcher.Add(fruit);
fruit.RelativePositionAxes = Axes.None;
fruit.Position = new Vector2(MovableCatcher.ToLocalSpace(screenSpacePosition).X - MovableCatcher.DrawSize.X / 2, 0);
fruit.Anchor = Anchor.TopCentre;
fruit.Origin = Anchor.Centre;
fruit.Scale *= 0.7f;
fruit.LifetimeEnd = double.MaxValue;
MovableCatcher.Add(fruit);
}
if (fruit.HitObject.LastInCombo)
{
if (judgement.IsHit)
MovableCatcher.Explode();
else
MovableCatcher.Drop();
}
}
public bool AttemptCatch(CatchHitObject obj) => MovableCatcher.AttemptCatch(obj);
@ -84,12 +103,12 @@ namespace osu.Game.Rulesets.Catch.UI
Children = new Drawable[]
{
createCatcherSprite(),
caughtFruit = new Container<DrawableHitObject>
{
Anchor = Anchor.TopCentre,
Origin = Anchor.BottomCentre,
}
},
createCatcherSprite(),
};
}
@ -167,20 +186,23 @@ namespace osu.Game.Rulesets.Catch.UI
/// <param name="fruit">The fruit that was caught.</param>
public void Add(DrawableHitObject fruit)
{
float distance = fruit.DrawSize.X / 2 * fruit.Scale.X;
float ourRadius = fruit.DrawSize.X / 2 * fruit.Scale.X;
float theirRadius = 0;
while (caughtFruit.Any(f => f.LifetimeEnd == double.MaxValue && Vector2Extensions.DistanceSquared(f.Position, fruit.Position) < distance * distance))
const float allowance = 6;
while (caughtFruit.Any(f =>
f.LifetimeEnd == double.MaxValue &&
Vector2Extensions.Distance(f.Position, fruit.Position) < (ourRadius + (theirRadius = f.DrawSize.X / 2 * f.Scale.X)) / (allowance / 2)))
{
fruit.X += RNG.Next(-5, 5);
fruit.Y -= RNG.Next(0, 5);
float diff = (ourRadius + theirRadius) / allowance;
fruit.X += (RNG.NextSingle() - 0.5f) * 2 * diff;
fruit.Y -= RNG.NextSingle() * diff;
}
fruit.X = MathHelper.Clamp(fruit.X, -CATCHER_SIZE / 2, CATCHER_SIZE / 2);
caughtFruit.Add(fruit);
var catchObject = (CatchHitObject)fruit.HitObject;
if (catchObject.LastInCombo)
explode();
}
/// <summary>
@ -190,15 +212,15 @@ namespace osu.Game.Rulesets.Catch.UI
/// <returns>Whether the catch is possible.</returns>
public bool AttemptCatch(CatchHitObject fruit)
{
const double relative_catcher_width = CATCHER_SIZE / 2;
double halfCatcherWidth = CATCHER_SIZE * Math.Abs(Scale.X) * 0.5f;
// this stuff wil disappear once we move fruit to non-relative coordinate space in the future.
var catchObjectPosition = fruit.X * CatchPlayfield.BASE_WIDTH;
var catcherPosition = Position.X * CatchPlayfield.BASE_WIDTH;
var validCatch =
catchObjectPosition >= catcherPosition - relative_catcher_width / 2 &&
catchObjectPosition <= catcherPosition + relative_catcher_width / 2;
catchObjectPosition >= catcherPosition - halfCatcherWidth &&
catchObjectPosition <= catcherPosition + halfCatcherWidth;
if (validCatch && fruit.HyperDash)
{
@ -309,7 +331,35 @@ namespace osu.Game.Rulesets.Catch.UI
X = (float)MathHelper.Clamp(X + direction * Clock.ElapsedFrameTime * BASE_SPEED * dashModifier, 0, 1);
}
private void explode()
/// <summary>
/// Drop any fruit off the plate.
/// </summary>
public void Drop()
{
var fruit = caughtFruit.ToArray();
foreach (var f in fruit)
{
if (ExplodingFruitTarget != null)
{
f.Anchor = Anchor.TopLeft;
f.Position = caughtFruit.ToSpaceOfOtherDrawable(f.DrawPosition, ExplodingFruitTarget);
caughtFruit.Remove(f);
ExplodingFruitTarget.Add(f);
}
f.MoveToY(f.Y + 75, 750, Easing.InSine);
f.FadeOut(750);
f.Expire();
}
}
/// <summary>
/// Explode any fruit off the plate.
/// </summary>
public void Explode()
{
var fruit = caughtFruit.ToArray();

View File

@ -113,7 +113,7 @@ namespace osu.Game.Rulesets.Mania
public override int LegacyID => 3;
public ManiaRuleset(RulesetInfo rulesetInfo)
public ManiaRuleset(RulesetInfo rulesetInfo = null)
: base(rulesetInfo)
{
}

View File

@ -9,7 +9,7 @@ namespace osu.Game.Rulesets.Mania.Tests
public class TestCasePerformancePoints : Game.Tests.Visual.TestCasePerformancePoints
{
public TestCasePerformancePoints()
: base(new ManiaRuleset(new RulesetInfo()))
: base(new ManiaRuleset())
{
}
}

View File

@ -145,7 +145,7 @@ namespace osu.Game.Rulesets.Osu
public override int LegacyID => 0;
public OsuRuleset(RulesetInfo rulesetInfo)
public OsuRuleset(RulesetInfo rulesetInfo = null)
: base(rulesetInfo)
{
}

View File

@ -9,7 +9,7 @@ namespace osu.Game.Rulesets.Osu.Tests
public class TestCasePerformancePoints : Game.Tests.Visual.TestCasePerformancePoints
{
public TestCasePerformancePoints()
: base(new OsuRuleset(new RulesetInfo()))
: base(new OsuRuleset())
{
}
}

View File

@ -103,7 +103,7 @@ namespace osu.Game.Rulesets.Taiko
public override int LegacyID => 1;
public TaikoRuleset(RulesetInfo rulesetInfo)
public TaikoRuleset(RulesetInfo rulesetInfo = null)
: base(rulesetInfo)
{
}

View File

@ -9,7 +9,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
public class TestCasePerformancePoints : Game.Tests.Visual.TestCasePerformancePoints
{
public TestCasePerformancePoints()
: base(new TaikoRuleset(new RulesetInfo()))
: base(new TaikoRuleset())
{
}
}

View File

@ -56,25 +56,25 @@ namespace osu.Game.Tests.Visual
Clock = new FramedClock(),
Children = new Drawable[]
{
new OsuRulesetContainer(new OsuRuleset(new RulesetInfo()), beatmap, false)
new OsuRulesetContainer(new OsuRuleset(), beatmap, false)
{
Scale = new Vector2(0.5f),
Anchor = Anchor.TopLeft,
Origin = Anchor.TopLeft
},
new TaikoRulesetContainer(new TaikoRuleset(new RulesetInfo()),beatmap, false)
new TaikoRulesetContainer(new TaikoRuleset(),beatmap, false)
{
Scale = new Vector2(0.5f),
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight
},
new CatchRulesetContainer(new CatchRuleset(new RulesetInfo()),beatmap, false)
new CatchRulesetContainer(new CatchRuleset(),beatmap, false)
{
Scale = new Vector2(0.5f),
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft
},
new ManiaRulesetContainer(new ManiaRuleset(new RulesetInfo()),beatmap, false)
new ManiaRulesetContainer(new ManiaRuleset(),beatmap, false)
{
Scale = new Vector2(0.5f),
Anchor = Anchor.BottomRight,

View File

@ -691,19 +691,19 @@ namespace osu.Game.Beatmaps
protected override Storyboard GetStoryboard()
{
if (BeatmapInfo?.Path == null && BeatmapSetInfo?.StoryboardFile == null)
return new Storyboard();
try
{
Decoder decoder;
using (var stream = new StreamReader(store.GetStream(getPathForFile(BeatmapInfo?.Path))))
decoder = Decoder.GetDecoder(stream);
// try for .osb first and fall back to .osu
string storyboardFile = BeatmapSetInfo.StoryboardFile ?? BeatmapInfo.Path;
using (var stream = new StreamReader(store.GetStream(getPathForFile(storyboardFile))))
return decoder.GetStoryboardDecoder().DecodeStoryboard(stream);
using (var beatmap = new StreamReader(store.GetStream(getPathForFile(BeatmapInfo.Path))))
{
Decoder decoder = Decoder.GetDecoder(beatmap);
if (BeatmapSetInfo?.StoryboardFile == null)
return decoder.GetStoryboardDecoder().DecodeStoryboard(beatmap);
using (var storyboard = new StreamReader(store.GetStream(getPathForFile(BeatmapSetInfo.StoryboardFile))))
return decoder.GetStoryboardDecoder().DecodeStoryboard(beatmap, storyboard);
}
}
catch
{

View File

@ -64,7 +64,7 @@ namespace osu.Game.Beatmaps
public override string ShortName => "dummy";
public DummyRuleset(RulesetInfo rulesetInfo)
public DummyRuleset(RulesetInfo rulesetInfo = null)
: base(rulesetInfo)
{
}

View File

@ -70,10 +70,11 @@ namespace osu.Game.Beatmaps.Formats
protected abstract void ParseBeatmap(StreamReader stream, Beatmap beatmap);
public virtual Storyboard DecodeStoryboard(StreamReader stream)
public virtual Storyboard DecodeStoryboard(params StreamReader[] streams)
{
var storyboard = new Storyboard();
ParseStoryboard(stream, storyboard);
foreach (StreamReader stream in streams)
ParseStoryboard(stream, storyboard);
return storyboard;
}

View File

@ -65,6 +65,7 @@ namespace osu.Game.Configuration
// Gameplay
Set(OsuSetting.DimLevel, 0.3, 0, 1, 0.01);
Set(OsuSetting.BlurLevel, 0, 0, 1, 0.01);
Set(OsuSetting.ShowInterface, true);
Set(OsuSetting.KeyOverlay, false);
@ -90,6 +91,7 @@ namespace osu.Game.Configuration
GameplayCursorSize,
AutoCursorSize,
DimLevel,
BlurLevel,
ShowStoryboard,
KeyOverlay,
FloatingComments,

View File

@ -33,15 +33,6 @@ namespace osu.Game.Graphics.Containers
// receive input outside our bounds so we can trigger a close event on ourselves.
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => BlockScreenWideMouse || base.ReceiveMouseInputAt(screenSpacePos);
protected override bool OnWheel(InputState state)
{
// always allow wheel to pass through to stuff outside our DrawRectangle.
if (!base.ReceiveMouseInputAt(state.Mouse.NativeState.Position))
return false;
return BlockPassThroughMouse;
}
protected override bool OnClick(InputState state)
{
if (!base.ReceiveMouseInputAt(state.Mouse.NativeState.Position))

View File

@ -3,12 +3,13 @@
using System;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input;
using osu.Framework.Input.Bindings;
using osu.Game.Input.Bindings;
namespace osu.Game.Graphics.UserInterface.Volume
{
public class VolumeControlReceptor : Container, IKeyBindingHandler<GlobalAction>
public class VolumeControlReceptor : Container, IKeyBindingHandler<GlobalAction>, IHandleGlobalInput
{
public Func<GlobalAction, bool> ActionRequested;

View File

@ -22,6 +22,12 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
Bindable = config.GetBindable<double>(OsuSetting.DimLevel),
KeyboardStep = 0.1f
},
new SettingsSlider<double>
{
LabelText = "Background blur",
Bindable = config.GetBindable<double>(OsuSetting.BlurLevel),
KeyboardStep = 0.1f
},
new SettingsCheckbox
{
LabelText = "Show score overlay",

View File

@ -34,9 +34,9 @@ namespace osu.Game.Rulesets
public Mod GetAutoplayMod() => GetAllMods().First(mod => mod is ModAutoplay);
protected Ruleset(RulesetInfo rulesetInfo)
protected Ruleset(RulesetInfo rulesetInfo = null)
{
RulesetInfo = rulesetInfo;
RulesetInfo = rulesetInfo ?? createRulesetInfo();
}
/// <summary>
@ -88,5 +88,17 @@ namespace osu.Game.Rulesets
/// <param name="variant">The variant.</param>
/// <returns>A descriptive name of the variant.</returns>
public virtual string GetVariantName(int variant) => string.Empty;
/// <summary>
/// Create a ruleset info based on this ruleset.
/// </summary>
/// <returns>A filled <see cref="RulesetInfo"/>.</returns>
private RulesetInfo createRulesetInfo() => new RulesetInfo
{
Name = Description,
ShortName = ShortName,
InstantiationInfo = GetType().AssemblyQualifiedName,
ID = LegacyID
};
}
}

View File

@ -58,30 +58,21 @@ namespace osu.Game.Rulesets
{
var context = GetContext();
var instances = loaded_assemblies.Values.Select(r => (Ruleset)Activator.CreateInstance(r, new RulesetInfo())).ToList();
var instances = loaded_assemblies.Values.Select(r => (Ruleset)Activator.CreateInstance(r, (RulesetInfo)null)).ToList();
//add all legacy modes in correct order
foreach (var r in instances.Where(r => r.LegacyID >= 0).OrderBy(r => r.LegacyID))
{
var rulesetInfo = createRulesetInfo(r);
if (context.RulesetInfo.SingleOrDefault(rsi => rsi.ID == rulesetInfo.ID) == null)
{
context.RulesetInfo.Add(rulesetInfo);
}
if (context.RulesetInfo.SingleOrDefault(rsi => rsi.ID == r.RulesetInfo.ID) == null)
context.RulesetInfo.Add(r.RulesetInfo);
}
context.SaveChanges();
//add any other modes
foreach (var r in instances.Where(r => r.LegacyID < 0))
{
var us = createRulesetInfo(r);
var existing = context.RulesetInfo.FirstOrDefault(ri => ri.InstantiationInfo == us.InstantiationInfo);
if (existing == null)
context.RulesetInfo.Add(us);
}
if (context.RulesetInfo.FirstOrDefault(ri => ri.InstantiationInfo == r.RulesetInfo.InstantiationInfo) == null)
context.RulesetInfo.Add(r.RulesetInfo);
context.SaveChanges();
@ -124,13 +115,5 @@ namespace osu.Game.Rulesets
{
}
}
private RulesetInfo createRulesetInfo(Ruleset ruleset) => new RulesetInfo
{
Name = ruleset.Description,
ShortName = ruleset.ShortName,
InstantiationInfo = ruleset.GetType().AssemblyQualifiedName,
ID = ruleset.LegacyID
};
}
}

View File

@ -110,6 +110,12 @@ namespace osu.Game.Rulesets.UI
//dividing by the customwidth will effectively scale our content to the required container size.
protected override Vector2 DrawScale => CustomWidth.HasValue ? new Vector2(DrawSize.X / CustomWidth.Value) : base.DrawScale;
protected override void Update()
{
base.Update();
RelativeChildSize = new Vector2(DrawScale.X, RelativeChildSize.Y);
}
}
}
}

View File

@ -4,6 +4,7 @@
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Textures;
using osu.Framework.Graphics.Transforms;
using OpenTK;
using osu.Game.Beatmaps;
using osu.Game.Graphics.Backgrounds;
@ -19,10 +20,7 @@ namespace osu.Game.Screens.Backgrounds
public WorkingBeatmap Beatmap
{
get
{
return beatmap;
}
get { return beatmap; }
set
{
if (beatmap == value && beatmap != null)
@ -56,11 +54,8 @@ namespace osu.Game.Screens.Backgrounds
Beatmap = beatmap;
}
public void BlurTo(Vector2 sigma, double duration, Easing easing = Easing.None)
{
background?.BlurTo(sigma, duration, easing);
blurTarget = sigma;
}
public TransformSequence<Background> BlurTo(Vector2 sigma, double duration, Easing easing = Easing.None)
=> background?.BlurTo(blurTarget = sigma, duration, easing);
public override bool Equals(BackgroundScreen other)
{

View File

@ -24,10 +24,10 @@ using osu.Game.Rulesets.Scoring;
using osu.Game.Screens.Ranking;
using osu.Framework.Audio.Sample;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Online.API;
using osu.Game.Screens.Play.BreaksOverlay;
using osu.Game.Storyboards.Drawables;
using OpenTK.Graphics;
namespace osu.Game.Screens.Play
{
@ -67,6 +67,7 @@ namespace osu.Game.Screens.Play
#region User Settings
private Bindable<double> dimLevel;
private Bindable<double> blurLevel;
private Bindable<bool> showStoryboard;
private Bindable<bool> mouseWheelDisabled;
private Bindable<double> userAudioOffset;
@ -90,6 +91,7 @@ namespace osu.Game.Screens.Play
this.api = api;
dimLevel = config.GetBindable<double>(OsuSetting.DimLevel);
blurLevel = config.GetBindable<double>(OsuSetting.BlurLevel);
showStoryboard = config.GetBindable<bool>(OsuSetting.ShowStoryboard);
mouseWheelDisabled = config.GetBindable<bool>(OsuSetting.MouseDisableWheel);
@ -316,10 +318,9 @@ namespace osu.Game.Screens.Play
if (!loadedSuccessfully)
return;
(Background as BackgroundScreenBeatmap)?.BlurTo(Vector2.Zero, 1000, Easing.OutQuint);
dimLevel.ValueChanged += dimLevel_ValueChanged;
showStoryboard.ValueChanged += showStoryboard_ValueChanged;
dimLevel.ValueChanged += _ => updateBackgroundElements();
blurLevel.ValueChanged += _ => updateBackgroundElements();
showStoryboard.ValueChanged += _ => updateBackgroundElements();
updateBackgroundElements();
Content.Alpha = 0;
@ -375,14 +376,12 @@ namespace osu.Game.Screens.Play
return true;
}
private void dimLevel_ValueChanged(double newValue)
=> updateBackgroundElements();
private void showStoryboard_ValueChanged(bool newValue)
=> updateBackgroundElements();
private void updateBackgroundElements()
{
if (!IsCurrentScreen) return;
const float duration = 800;
var opacity = 1 - (float)dimLevel;
if (showStoryboard && storyboard == null)
@ -391,17 +390,16 @@ namespace osu.Game.Screens.Play
var beatmap = Beatmap.Value;
var storyboardVisible = showStoryboard && beatmap.Storyboard.HasDrawable;
storyboardContainer.FadeColour(new Color4(opacity, opacity, opacity, 1), 800);
storyboardContainer.FadeTo(storyboardVisible && opacity > 0 ? 1 : 0);
storyboardContainer
.FadeColour(OsuColour.Gray(opacity), duration, Easing.OutQuint)
.FadeTo(storyboardVisible && opacity > 0 ? 1 : 0, duration, Easing.OutQuint);
Background?.FadeTo(!storyboardVisible || beatmap.Background == null ? opacity : 0, 800, Easing.OutQuint);
(Background as BackgroundScreenBeatmap)?.BlurTo(new Vector2((float)blurLevel.Value * 25), duration, Easing.OutQuint);
Background?.FadeTo(!storyboardVisible || beatmap.Background == null ? opacity : 0, duration, Easing.OutQuint);
}
private void fadeOut()
{
dimLevel.ValueChanged -= dimLevel_ValueChanged;
showStoryboard.ValueChanged -= showStoryboard_ValueChanged;
const float fade_out_duration = 250;
RulesetContainer?.FadeOut(fade_out_duration);

View File

@ -1,7 +1,6 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.IO;
using System.Linq;
using System.Text;
@ -18,24 +17,19 @@ namespace osu.Game.Tests.Visual
{
public abstract class TestCasePlayer : ScreenTestCase
{
private readonly Type ruleset;
private readonly Ruleset ruleset;
protected Player Player;
private TestWorkingBeatmap working;
/// <summary>
/// Create a TestCase which runs through the Player screen.
/// </summary>
/// <param name="ruleset">An optional ruleset type which we want to target. If not provided we'll allow all rulesets to be tested.</param>
protected TestCasePlayer(Type ruleset)
protected TestCasePlayer(Ruleset ruleset)
{
this.ruleset = ruleset;
}
protected TestCasePlayer()
{
}
[BackgroundDependencyLoader]
@ -48,14 +42,21 @@ namespace osu.Game.Tests.Visual
Depth = int.MaxValue
});
string instantiation = ruleset?.AssemblyQualifiedName;
foreach (var r in rulesets.AvailableRulesets.Where(rs => instantiation == null || rs.InstantiationInfo == instantiation))
if (ruleset != null)
{
Player p = null;
AddStep(r.Name, () => p = loadPlayerFor(r));
AddStep(ruleset.RulesetInfo.Name, () => p = loadPlayerFor(ruleset));
AddUntilStep(() => p.IsLoaded);
}
else
{
foreach (var r in rulesets.AvailableRulesets)
{
Player p = null;
AddStep(r.Name, () => p = loadPlayerFor(r));
AddUntilStep(() => p.IsLoaded);
}
}
}
protected virtual Beatmap CreateBeatmap()
@ -69,21 +70,21 @@ namespace osu.Game.Tests.Visual
return beatmap;
}
private Player loadPlayerFor(RulesetInfo r)
private Player loadPlayerFor(RulesetInfo ri) => loadPlayerFor(ri.CreateInstance());
private Player loadPlayerFor(Ruleset r)
{
var beatmap = CreateBeatmap();
beatmap.BeatmapInfo.Ruleset = r;
var instance = r.CreateInstance();
beatmap.BeatmapInfo.Ruleset = r.RulesetInfo;
working = new TestWorkingBeatmap(beatmap);
working.Mods.Value = new[] { instance.GetAllMods().First(m => m is ModNoFail) };
working.Mods.Value = new[] { r.GetAllMods().First(m => m is ModNoFail) };
if (Player != null)
Remove(Player);
var player = CreatePlayer(working, instance);
var player = CreatePlayer(working, r);
LoadComponentAsync(player, LoadScreen);