Merge pull request #1093 from peppy/catch

Stored bindings, more catch and less HitRenderer
This commit is contained in:
Dan Balasescu 2017-08-09 15:26:54 +09:00 committed by GitHub
commit bd84e507de
46 changed files with 619 additions and 322 deletions

@ -1 +1 @@
Subproject commit d29abdf0d042d832f0849c013d14762db04730e7 Subproject commit 67d89a36016f98c0ede576b859a2ccafe114fce8

View File

@ -1,7 +1,10 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Catch;
using osu.Game.Rulesets.Catch.UI; using osu.Game.Rulesets.Catch.UI;
using OpenTK; using OpenTK;
@ -9,20 +12,23 @@ namespace osu.Desktop.Tests.Visual
{ {
internal class TestCaseCatcher : OsuTestCase internal class TestCaseCatcher : OsuTestCase
{ {
protected override void LoadComplete() [BackgroundDependencyLoader]
private void load(RulesetStore rulesets)
{ {
base.LoadComplete();
Children = new Drawable[] Children = new Drawable[]
{ {
new CatcherArea new CatchInputManager(rulesets.GetRuleset(2))
{ {
RelativePositionAxes = Axes.Both,
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Anchor = Anchor.BottomLeft, Child = new CatcherArea
Origin = Anchor.BottomLeft, {
Size = new Vector2(1, 0.2f), RelativePositionAxes = Axes.Both,
} RelativeSizeAxes = Axes.Both,
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Size = new Vector2(1, 0.2f),
}
},
}; };
} }
} }

View File

@ -11,11 +11,15 @@ using osu.Framework.Timing;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Rulesets.Catch;
using osu.Game.Rulesets.Catch.UI; using osu.Game.Rulesets.Catch.UI;
using osu.Game.Rulesets.Mania;
using osu.Game.Rulesets.Mania.UI; using osu.Game.Rulesets.Mania.UI;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.UI; using osu.Game.Rulesets.Osu.UI;
using osu.Game.Rulesets.Taiko;
using osu.Game.Rulesets.Taiko.UI; using osu.Game.Rulesets.Taiko.UI;
using OpenTK; using OpenTK;
@ -84,25 +88,25 @@ namespace osu.Desktop.Tests.Visual
Clock = new FramedClock(), Clock = new FramedClock(),
Children = new Drawable[] Children = new Drawable[]
{ {
new OsuHitRenderer(beatmap, false) new OsuRulesetContainer(new OsuRuleset(new RulesetInfo()), beatmap, false)
{ {
Scale = new Vector2(0.5f), Scale = new Vector2(0.5f),
Anchor = Anchor.TopLeft, Anchor = Anchor.TopLeft,
Origin = Anchor.TopLeft Origin = Anchor.TopLeft
}, },
new TaikoHitRenderer(beatmap, false) new TaikoRulesetContainer(new TaikoRuleset(new RulesetInfo()),beatmap, false)
{ {
Scale = new Vector2(0.5f), Scale = new Vector2(0.5f),
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
Origin = Anchor.TopRight Origin = Anchor.TopRight
}, },
new CatchHitRenderer(beatmap, false) new CatchRulesetContainer(new CatchRuleset(new RulesetInfo()),beatmap, false)
{ {
Scale = new Vector2(0.5f), Scale = new Vector2(0.5f),
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft Origin = Anchor.BottomLeft
}, },
new ManiaHitRenderer(beatmap, false) new ManiaRulesetContainer(new ManiaRuleset(new RulesetInfo()),beatmap, false)
{ {
Scale = new Vector2(0.5f), Scale = new Vector2(0.5f),
Anchor = Anchor.BottomRight, Anchor = Anchor.BottomRight,

View File

@ -50,25 +50,25 @@ namespace osu.Desktop.Tests.Visual
WorkingBeatmap beatmap = new TestWorkingBeatmap(b); WorkingBeatmap beatmap = new TestWorkingBeatmap(b);
TestHitRenderer horizontalHitRenderer; TestRulesetContainer horizontalRulesetContainer;
Add(horizontalHitRenderer = new TestHitRenderer(Axes.X, beatmap, true)); Add(horizontalRulesetContainer = new TestRulesetContainer(Axes.X, beatmap, true));
TestHitRenderer verticalHitRenderer; TestRulesetContainer verticalRulesetContainer;
Add(verticalHitRenderer = new TestHitRenderer(Axes.Y, beatmap, true)); Add(verticalRulesetContainer = new TestRulesetContainer(Axes.Y, beatmap, true));
AddStep("Reverse direction", () => AddStep("Reverse direction", () =>
{ {
horizontalHitRenderer.Playfield.Reversed.Toggle(); horizontalRulesetContainer.Playfield.Reversed.Toggle();
verticalHitRenderer.Playfield.Reversed.Toggle(); verticalRulesetContainer.Playfield.Reversed.Toggle();
}); });
} }
private class TestHitRenderer : ScrollingHitRenderer<TestPlayfield, TestHitObject, TestJudgement> private class TestRulesetContainer : ScrollingRulesetContainer<TestPlayfield, TestHitObject, TestJudgement>
{ {
private readonly Axes scrollingAxes; private readonly Axes scrollingAxes;
public TestHitRenderer(Axes scrollingAxes, WorkingBeatmap beatmap, bool isForCurrentRuleset) public TestRulesetContainer(Axes scrollingAxes, WorkingBeatmap beatmap, bool isForCurrentRuleset)
: base(beatmap, isForCurrentRuleset) : base(null, beatmap, isForCurrentRuleset)
{ {
this.scrollingAxes = scrollingAxes; this.scrollingAxes = scrollingAxes;
} }

View File

@ -0,0 +1,32 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using osu.Game.Input;
using OpenTK.Input;
namespace osu.Game.Rulesets.Catch
{
public class CatchInputManager : ActionMappingInputManager<CatchAction>
{
public CatchInputManager(RulesetInfo ruleset) : base(ruleset)
{
Mappings = new Dictionary<Key, CatchAction>
{
{ Key.Z, CatchAction.MoveLeft },
{ Key.Left, CatchAction.MoveLeft },
{ Key.X, CatchAction.MoveRight },
{ Key.Right, CatchAction.MoveRight },
{ Key.LShift, CatchAction.Dash },
{ Key.RShift, CatchAction.Dash },
};
}
}
public enum CatchAction
{
MoveLeft,
MoveRight,
Dash
}
}

View File

@ -18,7 +18,7 @@ namespace osu.Game.Rulesets.Catch
{ {
public class CatchRuleset : Ruleset public class CatchRuleset : Ruleset
{ {
public override HitRenderer CreateHitRendererWith(WorkingBeatmap beatmap, bool isForCurrentRuleset) => new CatchHitRenderer(beatmap, isForCurrentRuleset); public override RulesetContainer CreateRulesetContainerWith(WorkingBeatmap beatmap, bool isForCurrentRuleset) => new CatchRulesetContainer(this, beatmap, isForCurrentRuleset);
public override IEnumerable<Mod> GetModsFor(ModType type) public override IEnumerable<Mod> GetModsFor(ModType type)
{ {
@ -102,5 +102,10 @@ namespace osu.Game.Rulesets.Catch
public override ScoreProcessor CreateScoreProcessor() => new CatchScoreProcessor(); public override ScoreProcessor CreateScoreProcessor() => new CatchScoreProcessor();
public override int LegacyID => 2; public override int LegacyID => 2;
public CatchRuleset(RulesetInfo rulesetInfo)
: base(rulesetInfo)
{
}
} }
} }

View File

@ -1,6 +1,7 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -15,12 +16,16 @@ using OpenTK.Graphics;
namespace osu.Game.Rulesets.Catch.Objects.Drawable namespace osu.Game.Rulesets.Catch.Objects.Drawable
{ {
internal class DrawableFruit : DrawableHitObject<CatchBaseHit, CatchJudgement> public class DrawableFruit : DrawableScrollingHitObject<CatchBaseHit, CatchJudgement>
{ {
private const float pulp_size = 30;
private class Pulp : Circle, IHasAccentColour private class Pulp : Circle, IHasAccentColour
{ {
public Pulp() public Pulp()
{ {
Size = new Vector2(pulp_size);
EdgeEffect = new EdgeEffectParameters EdgeEffect = new EdgeEffectParameters
{ {
Type = EdgeEffectType.Glow, Type = EdgeEffectType.Glow,
@ -33,84 +38,91 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
} }
public DrawableFruit(CatchBaseHit h) : base(h) public DrawableFruit(CatchBaseHit h)
: base(h)
{ {
Origin = Anchor.Centre; Origin = Anchor.Centre;
Size = new Vector2(50); Size = new Vector2(pulp_size * 2, pulp_size * 2.6f);
RelativePositionAxes = Axes.Both;
Position = new Vector2(h.Position, -0.1f);
Rotation = (float)(RNG.NextDouble() - 0.5f) * 40;
Alpha = 0; RelativePositionAxes = Axes.Both;
X = h.Position;
Colour = new Color4(RNG.NextSingle(), RNG.NextSingle(), RNG.NextSingle(), 1);
Rotation = (float)(RNG.NextDouble() - 0.5f) * 40;
} }
public Func<CatchBaseHit, bool> CheckPosition;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
Children = new Framework.Graphics.Drawable[] Children = new Framework.Graphics.Drawable[]
{ {
new Box //todo: share this more
new BufferedContainer
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Colour = Color4.Red, CacheDrawnFrameBuffer = true,
}, Children = new Framework.Graphics.Drawable[]
new Pulp {
{ new Pulp
RelativePositionAxes = Axes.Both, {
RelativeSizeAxes = Axes.Both, RelativePositionAxes = Axes.Both,
Anchor = Anchor.TopCentre, Anchor = Anchor.TopCentre,
Origin = Anchor.Centre, Origin = Anchor.TopCentre,
Scale = new Vector2(0.12f), Scale = new Vector2(0.6f),
Y = 0.08f, },
}, new Pulp
new Pulp {
{ RelativePositionAxes = Axes.Both,
RelativePositionAxes = Axes.Both, Anchor = Anchor.CentreLeft,
RelativeSizeAxes = Axes.Both, Origin = Anchor.CentreLeft,
Anchor = Anchor.TopCentre, Y = -0.08f
Origin = Anchor.Centre, },
Scale = new Vector2(0.32f), new Pulp
Position = new Vector2(-0.16f, 0.3f), {
}, RelativePositionAxes = Axes.Both,
new Pulp Anchor = Anchor.CentreRight,
{ Origin = Anchor.CentreRight,
RelativePositionAxes = Axes.Both, Y = -0.08f
RelativeSizeAxes = Axes.Both, },
Anchor = Anchor.TopCentre, new Pulp
Origin = Anchor.Centre, {
Scale = new Vector2(0.32f), RelativePositionAxes = Axes.Both,
Position = new Vector2(0.16f, 0.3f), Anchor = Anchor.BottomCentre,
}, Origin = Anchor.BottomCentre,
new Pulp },
{ }
RelativePositionAxes = Axes.Both, }
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.TopCentre,
Origin = Anchor.Centre,
Scale = new Vector2(0.32f),
Position = new Vector2(0, 0.6f),
},
}; };
Alpha = 0;
} }
protected override CatchJudgement CreateJudgement() => new CatchJudgement(); protected override CatchJudgement CreateJudgement() => new CatchJudgement();
private const float preempt = 1000; private const float preempt = 1000;
protected override void CheckJudgement(bool userTriggered)
{
if (Judgement.TimeOffset > 0)
Judgement.Result = CheckPosition?.Invoke(HitObject) ?? false ? HitResult.Hit : HitResult.Miss;
}
protected override void UpdateState(ArmedState state) protected override void UpdateState(ArmedState state)
{ {
using (BeginAbsoluteSequence(HitObject.StartTime - preempt)) using (BeginAbsoluteSequence(HitObject.StartTime - preempt))
{ {
// default state
this.MoveToY(-0.1f).FadeOut();
// animation // animation
this.FadeIn(200).MoveToY(1, preempt); this.FadeIn(200);
} }
Expire(true); switch (state)
{
case ArmedState.Miss:
using (BeginAbsoluteSequence(HitObject.StartTime, true))
this.FadeOut(250).RotateTo(Rotation * 2, 250, Easing.Out);
break;
}
} }
} }
} }

View File

@ -14,11 +14,19 @@ namespace osu.Game.Rulesets.Catch.Scoring
{ {
} }
public CatchScoreProcessor(HitRenderer<CatchBaseHit, CatchJudgement> hitRenderer) public CatchScoreProcessor(RulesetContainer<CatchBaseHit, CatchJudgement> rulesetContainer)
: base(hitRenderer) : base(rulesetContainer)
{ {
} }
protected override void Reset()
{
base.Reset();
Health.Value = 1;
Accuracy.Value = 1;
}
protected override void OnNewJudgement(CatchJudgement judgement) protected override void OnNewJudgement(CatchJudgement judgement)
{ {
} }

View File

@ -6,21 +6,35 @@ using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI;
using OpenTK; using OpenTK;
using osu.Game.Rulesets.Catch.Judgements; using osu.Game.Rulesets.Catch.Judgements;
using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Catch.Objects.Drawable;
using osu.Game.Rulesets.Objects.Drawables;
namespace osu.Game.Rulesets.Catch.UI namespace osu.Game.Rulesets.Catch.UI
{ {
public class CatchPlayfield : Playfield<CatchBaseHit, CatchJudgement> public class CatchPlayfield : ScrollingPlayfield<CatchBaseHit, CatchJudgement>
{ {
protected override Container<Drawable> Content => content;
private readonly Container<Drawable> content;
private readonly CatcherArea catcherArea;
public CatchPlayfield() public CatchPlayfield()
: base(Axes.Y)
{ {
Reversed.Value = true;
Size = new Vector2(1); Size = new Vector2(1);
Anchor = Anchor.TopCentre; Anchor = Anchor.TopCentre;
Origin = Anchor.TopCentre; Origin = Anchor.TopCentre;
Children = new Drawable[] InternalChildren = new Drawable[]
{ {
new CatcherArea content = new Container<Drawable>
{
RelativeSizeAxes = Axes.Both,
},
catcherArea = new CatcherArea
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,
@ -29,5 +43,24 @@ namespace osu.Game.Rulesets.Catch.UI
} }
}; };
} }
public override void Add(DrawableHitObject<CatchBaseHit, CatchJudgement> h)
{
base.Add(h);
var fruit = (DrawableFruit)h;
fruit.CheckPosition = catcherArea.CheckIfWeCanCatch;
fruit.OnJudgement += Fruit_OnJudgement;
}
private void Fruit_OnJudgement(DrawableHitObject<CatchBaseHit, CatchJudgement> obj)
{
if (obj.Judgement.Result == HitResult.Hit)
{
Vector2 screenPosition = obj.ScreenSpaceDrawQuad.Centre;
Remove(obj);
catcherArea.Add(obj, screenPosition);
}
}
} }
} }

View File

@ -1,6 +1,7 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Input;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets.Beatmaps; using osu.Game.Rulesets.Beatmaps;
using osu.Game.Rulesets.Catch.Beatmaps; using osu.Game.Rulesets.Catch.Beatmaps;
@ -14,10 +15,10 @@ using osu.Game.Rulesets.UI;
namespace osu.Game.Rulesets.Catch.UI namespace osu.Game.Rulesets.Catch.UI
{ {
public class CatchHitRenderer : HitRenderer<CatchBaseHit, CatchJudgement> public class CatchRulesetContainer : ScrollingRulesetContainer<CatchPlayfield, CatchBaseHit, CatchJudgement>
{ {
public CatchHitRenderer(WorkingBeatmap beatmap, bool isForCurrentRuleset) public CatchRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap, bool isForCurrentRuleset)
: base(beatmap, isForCurrentRuleset) : base(ruleset, beatmap, isForCurrentRuleset)
{ {
} }
@ -27,6 +28,8 @@ namespace osu.Game.Rulesets.Catch.UI
protected override Playfield<CatchBaseHit, CatchJudgement> CreatePlayfield() => new CatchPlayfield(); protected override Playfield<CatchBaseHit, CatchJudgement> CreatePlayfield() => new CatchPlayfield();
protected override PassThroughInputManager CreateActionMappingInputManager() => new CatchInputManager(Ruleset.RulesetInfo);
protected override DrawableHitObject<CatchBaseHit, CatchJudgement> GetVisualRepresentation(CatchBaseHit h) protected override DrawableHitObject<CatchBaseHit, CatchJudgement> GetVisualRepresentation(CatchBaseHit h)
{ {
if (h is Fruit) if (h is Fruit)

View File

@ -2,145 +2,185 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System; using System;
using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Framework.Input; using osu.Framework.Input;
using osu.Framework.MathUtils;
using osu.Game.Rulesets.Catch.Judgements;
using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Catch.Objects.Drawable;
using osu.Game.Rulesets.Objects.Drawables;
using OpenTK; using OpenTK;
using OpenTK.Input;
namespace osu.Game.Rulesets.Catch.UI namespace osu.Game.Rulesets.Catch.UI
{ {
public class CatcherArea : Container public class CatcherArea : Container
{ {
public override bool HandleInput => true; private Catcher catcher;
private Sprite catcher; public void Add(DrawableHitObject<CatchBaseHit, CatchJudgement> fruit, Vector2 screenPosition) => catcher.AddToStack(fruit, screenPosition);
private Drawable createAdditiveFrame() => new Sprite public bool CheckIfWeCanCatch(CatchBaseHit obj) => Math.Abs(catcher.Position.X - obj.Position) < catcher.DrawSize.X / DrawSize.X / 2;
{
RelativePositionAxes = Axes.Both,
Anchor = Anchor.TopLeft,
Origin = Anchor.TopCentre,
RelativeSizeAxes = Axes.Both,
FillMode = FillMode.Fit,
Texture = catcher.Texture,
BlendingMode = BlendingMode.Additive,
Position = catcher.Position,
Scale = catcher.Scale,
};
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(TextureStore textures) private void load()
{ {
Children = new Drawable[] Children = new Drawable[]
{ {
catcher = new Sprite catcher = new Catcher
{ {
RelativePositionAxes = Axes.Both, RelativePositionAxes = Axes.Both,
Anchor = Anchor.TopLeft, Anchor = Anchor.TopLeft,
Origin = Anchor.TopCentre, Origin = Anchor.TopCentre,
RelativeSizeAxes = Axes.Both,
FillMode = FillMode.Fit,
X = 0.5f, X = 0.5f,
Texture = textures.Get(@"Play/Catch/fruit-catcher-idle"), }
},
}; };
} }
private bool leftPressed;
private bool rightPressed;
private int currentDirection;
private bool dashing;
protected bool Dashing
{
get
{
return dashing;
}
set
{
if (value == dashing) return;
dashing = value;
if (dashing)
Schedule(addAdditiveSprite);
}
}
private void addAdditiveSprite()
{
if (!dashing) return;
var additive = createAdditiveFrame();
Add(additive);
additive.FadeTo(0.4f).FadeOut(800, Easing.OutQuint).Expire();
Scheduler.AddDelayed(addAdditiveSprite, 50);
}
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{
if (args.Repeat) return true;
switch (args.Key)
{
case Key.Left:
currentDirection = -1;
leftPressed = true;
return true;
case Key.Right:
currentDirection = 1;
rightPressed = true;
return true;
case Key.ShiftLeft:
Dashing = true;
return true;
}
return base.OnKeyDown(state, args);
}
protected override bool OnKeyUp(InputState state, KeyUpEventArgs args)
{
switch (args.Key)
{
case Key.Left:
currentDirection = rightPressed ? 1 : 0;
leftPressed = false;
return true;
case Key.Right:
currentDirection = leftPressed ? -1 : 0;
rightPressed = false;
return true;
case Key.ShiftLeft:
Dashing = false;
return true;
}
return base.OnKeyUp(state, args);
}
protected override void Update() protected override void Update()
{ {
base.Update(); base.Update();
if (currentDirection == 0) return; catcher.Size = new Vector2(DrawSize.Y);
}
float speed = Dashing ? 1.5f : 1; private class Catcher : Container
{
private Texture texture;
catcher.Scale = new Vector2(Math.Sign(currentDirection), 1); [BackgroundDependencyLoader]
catcher.X = (float)MathHelper.Clamp(catcher.X + currentDirection * Clock.ElapsedFrameTime / 1800 * speed, 0, 1); private void load(TextureStore textures)
{
texture = textures.Get(@"Play/Catch/fruit-catcher-idle");
Child = createCatcherSprite();
}
private int currentDirection;
private bool dashing;
protected bool Dashing
{
get { return dashing; }
set
{
if (value == dashing) return;
dashing = value;
if (dashing)
Schedule(addAdditiveSprite);
}
}
private void addAdditiveSprite()
{
if (!dashing) return;
var additive = createCatcherSprite();
additive.RelativePositionAxes = Axes.Both;
additive.BlendingMode = BlendingMode.Additive;
additive.Position = Position;
additive.Scale = Scale;
((CatcherArea)Parent).Add(additive);
additive.FadeTo(0.4f).FadeOut(800, Easing.OutQuint).Expire();
Scheduler.AddDelayed(addAdditiveSprite, 50);
}
private Sprite createCatcherSprite() => new Sprite
{
RelativeSizeAxes = Axes.Both,
FillMode = FillMode.Fit,
Texture = texture,
OriginPosition = new Vector2(DrawWidth / 2, 10) //temporary until the sprite is aligned correctly.
};
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{
if (args.Repeat) return true;
if (state.Data is CatchAction)
{
switch ((CatchAction)state.Data)
{
case CatchAction.MoveLeft:
currentDirection--;
return true;
case CatchAction.MoveRight:
currentDirection++;
return true;
case CatchAction.Dash:
Dashing = true;
return true;
}
}
return base.OnKeyDown(state, args);
}
protected override bool OnKeyUp(InputState state, KeyUpEventArgs args)
{
if (state.Data is CatchAction)
{
switch ((CatchAction)state.Data)
{
case CatchAction.MoveLeft:
currentDirection++;
return true;
case CatchAction.MoveRight:
currentDirection--;
return true;
case CatchAction.Dash:
Dashing = false;
return true;
}
}
return base.OnKeyUp(state, args);
}
protected override void Update()
{
base.Update();
if (currentDirection == 0) return;
float speed = Dashing ? 1.5f : 1;
Scale = new Vector2(Math.Sign(currentDirection), 1);
X = (float)MathHelper.Clamp(X + Math.Sign(currentDirection) * Clock.ElapsedFrameTime / 1800 * speed, 0, 1);
}
public void AddToStack(DrawableHitObject<CatchBaseHit, CatchJudgement> fruit, Vector2 absolutePosition)
{
fruit.RelativePositionAxes = Axes.None;
fruit.Position = new Vector2(ToLocalSpace(absolutePosition).X - DrawSize.X / 2, 0);
fruit.Anchor = Anchor.TopCentre;
fruit.Origin = Anchor.BottomCentre;
fruit.Scale *= 0.7f;
fruit.LifetimeEnd = double.MaxValue;
fruit.Depth = (float)Time.Current;
float distance = fruit.DrawSize.X / 2 * fruit.Scale.X;
while (Children.OfType<DrawableFruit>().Any(f => Vector2.DistanceSquared(f.Position, fruit.Position) < distance * distance))
{
fruit.X += RNG.Next(-5, 5);
fruit.Y -= RNG.Next(0, 5);
}
Add(fruit);
}
} }
} }
} }

View File

@ -38,6 +38,7 @@
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Collections" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
@ -50,6 +51,7 @@
<ItemGroup> <ItemGroup>
<Compile Include="Beatmaps\CatchBeatmapConverter.cs" /> <Compile Include="Beatmaps\CatchBeatmapConverter.cs" />
<Compile Include="CatchDifficultyCalculator.cs" /> <Compile Include="CatchDifficultyCalculator.cs" />
<Compile Include="CatchInputManager.cs" />
<Compile Include="Scoring\CatchScoreProcessor.cs" /> <Compile Include="Scoring\CatchScoreProcessor.cs" />
<Compile Include="Judgements\CatchJudgement.cs" /> <Compile Include="Judgements\CatchJudgement.cs" />
<Compile Include="Objects\CatchBaseHit.cs" /> <Compile Include="Objects\CatchBaseHit.cs" />
@ -58,7 +60,7 @@
<Compile Include="Objects\Fruit.cs" /> <Compile Include="Objects\Fruit.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UI\CatcherArea.cs" /> <Compile Include="UI\CatcherArea.cs" />
<Compile Include="UI\CatchHitRenderer.cs" /> <Compile Include="UI\CatchRulesetContainer.cs" />
<Compile Include="UI\CatchPlayfield.cs" /> <Compile Include="UI\CatchPlayfield.cs" />
<Compile Include="CatchRuleset.cs" /> <Compile Include="CatchRuleset.cs" />
<Compile Include="Mods\CatchMod.cs" /> <Compile Include="Mods\CatchMod.cs" />

View File

@ -17,7 +17,7 @@ namespace osu.Game.Rulesets.Mania
{ {
public class ManiaRuleset : Ruleset public class ManiaRuleset : Ruleset
{ {
public override HitRenderer CreateHitRendererWith(WorkingBeatmap beatmap, bool isForCurrentRuleset) => new ManiaHitRenderer(beatmap, isForCurrentRuleset); public override RulesetContainer CreateRulesetContainerWith(WorkingBeatmap beatmap, bool isForCurrentRuleset) => new ManiaRulesetContainer(this, beatmap, isForCurrentRuleset);
public override IEnumerable<Mod> GetModsFor(ModType type) public override IEnumerable<Mod> GetModsFor(ModType type)
{ {
@ -118,5 +118,10 @@ namespace osu.Game.Rulesets.Mania
public override ScoreProcessor CreateScoreProcessor() => new ManiaScoreProcessor(); public override ScoreProcessor CreateScoreProcessor() => new ManiaScoreProcessor();
public override int LegacyID => 3; public override int LegacyID => 3;
public ManiaRuleset(RulesetInfo rulesetInfo)
: base(rulesetInfo)
{
}
} }
} }

View File

@ -15,9 +15,9 @@ namespace osu.Game.Rulesets.Mania.Mods
/// <summary> /// <summary>
/// Applies this mod to a hit renderer. /// Applies this mod to a hit renderer.
/// </summary> /// </summary>
/// <param name="hitRenderer">The hit renderer to apply to.</param> /// <param name="rulesetContainer">The hit renderer to apply to.</param>
/// <param name="hitObjectTimingChanges">The per-column list of speed adjustments for hit objects.</param> /// <param name="hitObjectTimingChanges">The per-column list of speed adjustments for hit objects.</param>
/// <param name="barlineTimingChanges">The list of speed adjustments for bar lines.</param> /// <param name="barlineTimingChanges">The list of speed adjustments for bar lines.</param>
void ApplyToHitRenderer(ManiaHitRenderer hitRenderer, ref List<SpeedAdjustmentContainer>[] hitObjectTimingChanges, ref List<SpeedAdjustmentContainer> barlineTimingChanges); void ApplyToRulesetContainer(ManiaRulesetContainer rulesetContainer, ref List<SpeedAdjustmentContainer>[] hitObjectTimingChanges, ref List<SpeedAdjustmentContainer> barlineTimingChanges);
} }
} }

View File

@ -20,12 +20,12 @@ namespace osu.Game.Rulesets.Mania.Mods
public override FontAwesome Icon => FontAwesome.fa_sort_desc; public override FontAwesome Icon => FontAwesome.fa_sort_desc;
public void ApplyToHitRenderer(ManiaHitRenderer hitRenderer, ref List<SpeedAdjustmentContainer>[] hitObjectTimingChanges, ref List<SpeedAdjustmentContainer> barlineTimingChanges) public void ApplyToRulesetContainer(ManiaRulesetContainer rulesetContainer, ref List<SpeedAdjustmentContainer>[] hitObjectTimingChanges, ref List<SpeedAdjustmentContainer> barlineTimingChanges)
{ {
// We have to generate one speed adjustment per hit object for gravity // We have to generate one speed adjustment per hit object for gravity
foreach (ManiaHitObject obj in hitRenderer.Objects) foreach (ManiaHitObject obj in rulesetContainer.Objects)
{ {
MultiplierControlPoint controlPoint = hitRenderer.CreateControlPointAt(obj.StartTime); MultiplierControlPoint controlPoint = rulesetContainer.CreateControlPointAt(obj.StartTime);
// Beat length has too large of an effect for gravity, so we'll force it to a constant value for now // Beat length has too large of an effect for gravity, so we'll force it to a constant value for now
controlPoint.TimingPoint.BeatLength = 1000; controlPoint.TimingPoint.BeatLength = 1000;
@ -33,9 +33,9 @@ namespace osu.Game.Rulesets.Mania.Mods
} }
// Like with hit objects, we need to generate one speed adjustment per bar line // Like with hit objects, we need to generate one speed adjustment per bar line
foreach (DrawableBarLine barLine in hitRenderer.BarLines) foreach (DrawableBarLine barLine in rulesetContainer.BarLines)
{ {
var controlPoint = hitRenderer.CreateControlPointAt(barLine.HitObject.StartTime); var controlPoint = rulesetContainer.CreateControlPointAt(barLine.HitObject.StartTime);
// Beat length has too large of an effect for gravity, so we'll force it to a constant value for now // Beat length has too large of an effect for gravity, so we'll force it to a constant value for now
controlPoint.TimingPoint.BeatLength = 1000; controlPoint.TimingPoint.BeatLength = 1000;

View File

@ -155,8 +155,8 @@ namespace osu.Game.Rulesets.Mania.Scoring
{ {
} }
public ManiaScoreProcessor(HitRenderer<ManiaHitObject, ManiaJudgement> hitRenderer) public ManiaScoreProcessor(RulesetContainer<ManiaHitObject, ManiaJudgement> rulesetContainer)
: base(hitRenderer) : base(rulesetContainer)
{ {
} }

View File

@ -29,7 +29,7 @@ using osu.Game.Rulesets.UI;
namespace osu.Game.Rulesets.Mania.UI namespace osu.Game.Rulesets.Mania.UI
{ {
public class ManiaHitRenderer : ScrollingHitRenderer<ManiaPlayfield, ManiaHitObject, ManiaJudgement> public class ManiaRulesetContainer : ScrollingRulesetContainer<ManiaPlayfield, ManiaHitObject, ManiaJudgement>
{ {
/// <summary> /// <summary>
/// Preferred column count. This will only have an effect during the initialization of the play field. /// Preferred column count. This will only have an effect during the initialization of the play field.
@ -38,8 +38,8 @@ namespace osu.Game.Rulesets.Mania.UI
public IEnumerable<DrawableBarLine> BarLines; public IEnumerable<DrawableBarLine> BarLines;
public ManiaHitRenderer(WorkingBeatmap beatmap, bool isForCurrentRuleset) public ManiaRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap, bool isForCurrentRuleset)
: base(beatmap, isForCurrentRuleset) : base(ruleset, beatmap, isForCurrentRuleset)
{ {
// Generate the bar lines // Generate the bar lines
double lastObjectTime = (Objects.LastOrDefault() as IHasEndTime)?.EndTime ?? Objects.LastOrDefault()?.StartTime ?? double.MaxValue; double lastObjectTime = (Objects.LastOrDefault() as IHasEndTime)?.EndTime ?? Objects.LastOrDefault()?.StartTime ?? double.MaxValue;

View File

@ -82,7 +82,7 @@
<Compile Include="Timing\GravityScrollingContainer.cs" /> <Compile Include="Timing\GravityScrollingContainer.cs" />
<Compile Include="Timing\ScrollingAlgorithm.cs" /> <Compile Include="Timing\ScrollingAlgorithm.cs" />
<Compile Include="UI\Column.cs" /> <Compile Include="UI\Column.cs" />
<Compile Include="UI\ManiaHitRenderer.cs" /> <Compile Include="UI\ManiaRulesetContainer.cs" />
<Compile Include="UI\ManiaPlayfield.cs" /> <Compile Include="UI\ManiaPlayfield.cs" />
<Compile Include="ManiaRuleset.cs" /> <Compile Include="ManiaRuleset.cs" />
<Compile Include="Mods\ManiaMod.cs" /> <Compile Include="Mods\ManiaMod.cs" />

View File

@ -3,14 +3,13 @@
using System.Linq; using System.Linq;
using osu.Framework.Input; using osu.Framework.Input;
using osu.Game.Screens.Play;
using OpenTK.Input; using OpenTK.Input;
using KeyboardState = osu.Framework.Input.KeyboardState; using KeyboardState = osu.Framework.Input.KeyboardState;
using MouseState = osu.Framework.Input.MouseState; using MouseState = osu.Framework.Input.MouseState;
namespace osu.Game.Rulesets.Osu namespace osu.Game.Rulesets.Osu
{ {
public class OsuKeyConversionInputManager : KeyConversionInputManager public class OsuKeyConversionInputManager : PassThroughInputManager
{ {
private bool leftViaKeyboard; private bool leftViaKeyboard;
private bool rightViaKeyboard; private bool rightViaKeyboard;

View File

@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Osu
{ {
public class OsuRuleset : Ruleset public class OsuRuleset : Ruleset
{ {
public override HitRenderer CreateHitRendererWith(WorkingBeatmap beatmap, bool isForCurrentRuleset) => new OsuHitRenderer(beatmap, isForCurrentRuleset); public override RulesetContainer CreateRulesetContainerWith(WorkingBeatmap beatmap, bool isForCurrentRuleset) => new OsuRulesetContainer(this, beatmap, isForCurrentRuleset);
public override IEnumerable<BeatmapStatistic> GetBeatmapStatistics(WorkingBeatmap beatmap) => new[] public override IEnumerable<BeatmapStatistic> GetBeatmapStatistics(WorkingBeatmap beatmap) => new[]
{ {
@ -126,5 +126,10 @@ namespace osu.Game.Rulesets.Osu
public override SettingsSubsection CreateSettings() => new OsuSettings(); public override SettingsSubsection CreateSettings() => new OsuSettings();
public override int LegacyID => 0; public override int LegacyID => 0;
public OsuRuleset(RulesetInfo rulesetInfo)
: base(rulesetInfo)
{
}
} }
} }

View File

@ -18,8 +18,8 @@ namespace osu.Game.Rulesets.Osu.Scoring
{ {
} }
public OsuScoreProcessor(HitRenderer<OsuHitObject, OsuJudgement> hitRenderer) public OsuScoreProcessor(RulesetContainer<OsuHitObject, OsuJudgement> rulesetContainer)
: base(hitRenderer) : base(rulesetContainer)
{ {
} }

View File

@ -1,6 +1,7 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Input;
using OpenTK; using OpenTK;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets.Beatmaps; using osu.Game.Rulesets.Beatmaps;
@ -12,14 +13,13 @@ using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Rulesets.Osu.Scoring; using osu.Game.Rulesets.Osu.Scoring;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI;
using osu.Game.Screens.Play;
namespace osu.Game.Rulesets.Osu.UI namespace osu.Game.Rulesets.Osu.UI
{ {
public class OsuHitRenderer : HitRenderer<OsuHitObject, OsuJudgement> public class OsuRulesetContainer : RulesetContainer<OsuHitObject, OsuJudgement>
{ {
public OsuHitRenderer(WorkingBeatmap beatmap, bool isForCurrentRuleset) public OsuRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap, bool isForCurrentRuleset)
: base(beatmap, isForCurrentRuleset) : base(ruleset, beatmap, isForCurrentRuleset)
{ {
} }
@ -31,7 +31,7 @@ namespace osu.Game.Rulesets.Osu.UI
protected override Playfield<OsuHitObject, OsuJudgement> CreatePlayfield() => new OsuPlayfield(); protected override Playfield<OsuHitObject, OsuJudgement> CreatePlayfield() => new OsuPlayfield();
protected override KeyConversionInputManager CreateKeyConversionInputManager() => new OsuKeyConversionInputManager(); protected override PassThroughInputManager CreateActionMappingInputManager() => new OsuKeyConversionInputManager();
protected override DrawableHitObject<OsuHitObject, OsuJudgement> GetVisualRepresentation(OsuHitObject h) protected override DrawableHitObject<OsuHitObject, OsuJudgement> GetVisualRepresentation(OsuHitObject h)
{ {

View File

@ -80,7 +80,7 @@
<Compile Include="OsuKeyConversionInputManager.cs" /> <Compile Include="OsuKeyConversionInputManager.cs" />
<Compile Include="UI\OsuSettings.cs" /> <Compile Include="UI\OsuSettings.cs" />
<Compile Include="Scoring\OsuScoreProcessor.cs" /> <Compile Include="Scoring\OsuScoreProcessor.cs" />
<Compile Include="UI\OsuHitRenderer.cs" /> <Compile Include="UI\OsuRulesetContainer.cs" />
<Compile Include="UI\OsuPlayfield.cs" /> <Compile Include="UI\OsuPlayfield.cs" />
<Compile Include="OsuRuleset.cs" /> <Compile Include="OsuRuleset.cs" />
<Compile Include="Objects\HitCircle.cs" /> <Compile Include="Objects\HitCircle.cs" />

View File

@ -113,8 +113,8 @@ namespace osu.Game.Rulesets.Taiko.Scoring
{ {
} }
public TaikoScoreProcessor(HitRenderer<TaikoHitObject, TaikoJudgement> hitRenderer) public TaikoScoreProcessor(RulesetContainer<TaikoHitObject, TaikoJudgement> rulesetContainer)
: base(hitRenderer) : base(rulesetContainer)
{ {
} }

View File

@ -18,7 +18,7 @@ namespace osu.Game.Rulesets.Taiko
{ {
public class TaikoRuleset : Ruleset public class TaikoRuleset : Ruleset
{ {
public override HitRenderer CreateHitRendererWith(WorkingBeatmap beatmap, bool isForCurrentRuleset) => new TaikoHitRenderer(beatmap, isForCurrentRuleset); public override RulesetContainer CreateRulesetContainerWith(WorkingBeatmap beatmap, bool isForCurrentRuleset) => new TaikoRulesetContainer(this, beatmap, isForCurrentRuleset);
public override IEnumerable<Mod> GetModsFor(ModType type) public override IEnumerable<Mod> GetModsFor(ModType type)
{ {
@ -103,5 +103,10 @@ namespace osu.Game.Rulesets.Taiko
public override ScoreProcessor CreateScoreProcessor() => new TaikoScoreProcessor(); public override ScoreProcessor CreateScoreProcessor() => new TaikoScoreProcessor();
public override int LegacyID => 1; public override int LegacyID => 1;
public TaikoRuleset(RulesetInfo rulesetInfo)
: base(rulesetInfo)
{
}
} }
} }

View File

@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Taiko.UI
public class TaikoPlayfield : Playfield<TaikoHitObject, TaikoJudgement> public class TaikoPlayfield : Playfield<TaikoHitObject, TaikoJudgement>
{ {
/// <summary> /// <summary>
/// Default height of a <see cref="TaikoPlayfield"/> when inside a <see cref="TaikoHitRenderer"/>. /// Default height of a <see cref="TaikoPlayfield"/> when inside a <see cref="TaikoRulesetContainer"/>.
/// </summary> /// </summary>
public const float DEFAULT_HEIGHT = 178; public const float DEFAULT_HEIGHT = 178;

View File

@ -21,10 +21,10 @@ using System.Linq;
namespace osu.Game.Rulesets.Taiko.UI namespace osu.Game.Rulesets.Taiko.UI
{ {
public class TaikoHitRenderer : HitRenderer<TaikoHitObject, TaikoJudgement> public class TaikoRulesetContainer : RulesetContainer<TaikoHitObject, TaikoJudgement>
{ {
public TaikoHitRenderer(WorkingBeatmap beatmap, bool isForCurrentRuleset) public TaikoRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap, bool isForCurrentRuleset)
: base(beatmap, isForCurrentRuleset) : base(ruleset, beatmap, isForCurrentRuleset)
{ {
} }
@ -93,7 +93,6 @@ namespace osu.Game.Rulesets.Taiko.UI
return new Vector2(1, default_relative_height * aspectAdjust); return new Vector2(1, default_relative_height * aspectAdjust);
} }
public override ScoreProcessor CreateScoreProcessor() => new TaikoScoreProcessor(this); public override ScoreProcessor CreateScoreProcessor() => new TaikoScoreProcessor(this);
protected override BeatmapConverter<TaikoHitObject> CreateBeatmapConverter() => new TaikoBeatmapConverter(); protected override BeatmapConverter<TaikoHitObject> CreateBeatmapConverter() => new TaikoBeatmapConverter();

View File

@ -91,7 +91,7 @@
<Compile Include="UI\KiaiHitExplosion.cs" /> <Compile Include="UI\KiaiHitExplosion.cs" />
<Compile Include="UI\DrawableTaikoJudgement.cs" /> <Compile Include="UI\DrawableTaikoJudgement.cs" />
<Compile Include="UI\HitExplosion.cs" /> <Compile Include="UI\HitExplosion.cs" />
<Compile Include="UI\TaikoHitRenderer.cs" /> <Compile Include="UI\TaikoRulesetContainer.cs" />
<Compile Include="UI\TaikoPlayfield.cs" /> <Compile Include="UI\TaikoPlayfield.cs" />
<Compile Include="TaikoRuleset.cs" /> <Compile Include="TaikoRuleset.cs" />
<Compile Include="Mods\TaikoMod.cs" /> <Compile Include="Mods\TaikoMod.cs" />

View File

@ -54,7 +54,7 @@ namespace osu.Game.Beatmaps
private class DummyRulesetInfo : RulesetInfo private class DummyRulesetInfo : RulesetInfo
{ {
public override Ruleset CreateInstance() => new DummyRuleset(); public override Ruleset CreateInstance() => new DummyRuleset(this);
private class DummyRuleset : Ruleset private class DummyRuleset : Ruleset
{ {
@ -62,7 +62,7 @@ namespace osu.Game.Beatmaps
public override Mod GetAutoplayMod() => new ModAutoplay(); public override Mod GetAutoplayMod() => new ModAutoplay();
public override HitRenderer CreateHitRendererWith(WorkingBeatmap beatmap, bool isForCurrentRuleset) public override RulesetContainer CreateRulesetContainerWith(WorkingBeatmap beatmap, bool isForCurrentRuleset)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@ -77,6 +77,11 @@ namespace osu.Game.Beatmaps
public override string Description => "dummy"; public override string Description => "dummy";
public override IEnumerable<KeyCounter> CreateGameplayKeys() => new List<KeyCounter>(); public override IEnumerable<KeyCounter> CreateGameplayKeys() => new List<KeyCounter>();
public DummyRuleset(RulesetInfo rulesetInfo)
: base(rulesetInfo)
{
}
} }
} }
} }

View File

@ -0,0 +1,74 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using osu.Framework.Allocation;
using osu.Framework.Input;
using osu.Game.Rulesets;
using OpenTK.Input;
namespace osu.Game.Input
{
/// <summary>
/// Maps custom action data of type <see cref="T"/> and stores to <see cref="InputState.Data"/>.
/// </summary>
/// <typeparam name="T">The type of the custom action.</typeparam>
public class ActionMappingInputManager<T> : PassThroughInputManager
where T : struct
{
private readonly RulesetInfo ruleset;
private readonly int? variant;
/// <summary>
/// Create a new instance.
/// </summary>
/// <param name="ruleset">A reference to identify the current <see cref="Ruleset"/>. Used to lookup mappings. Null for global mappings.</param>
/// <param name="variant">An optional variant for the specified <see cref="Ruleset"/>. Used when a ruleset has more than one possible keyboard layouts.</param>
protected ActionMappingInputManager(RulesetInfo ruleset = null, int? variant = null)
{
this.ruleset = ruleset;
this.variant = variant;
}
protected IDictionary<Key, T> Mappings { get; set; }
[BackgroundDependencyLoader]
private void load(BindingStore bindings)
{
var rulesetId = ruleset?.ID;
foreach (var b in bindings.Query<Binding>(b => b.RulesetID == rulesetId && b.Variant == variant))
Mappings[b.Key] = (T)(object)b.Action;
}
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{
mapKey(state, args.Key);
return base.OnKeyDown(state, args);
}
protected override bool OnKeyUp(InputState state, KeyUpEventArgs args)
{
mapKey(state, args.Key);
return base.OnKeyUp(state, args);
}
private void mapKey(InputState state, Key key)
{
T mappedData;
if (Mappings.TryGetValue(key, out mappedData))
state.Data = mappedData;
}
private T parseStringRepresentation(string str)
{
T res;
if (Enum.TryParse(str, out res))
return res;
return default(T);
}
}
}

23
osu.Game/Input/Binding.cs Normal file
View File

@ -0,0 +1,23 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Game.Rulesets;
using OpenTK.Input;
using SQLite.Net.Attributes;
using SQLiteNetExtensions.Attributes;
namespace osu.Game.Input
{
public class Binding
{
[ForeignKey(typeof(RulesetInfo))]
public int? RulesetID { get; set; }
[Indexed]
public int? Variant { get; set; }
public Key Key { get; set; }
public int Action { get; set; }
}
}

View File

@ -0,0 +1,29 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Framework.Platform;
using osu.Game.Database;
using SQLite.Net;
namespace osu.Game.Input
{
public class BindingStore : DatabaseBackedStore
{
public BindingStore(SQLiteConnection connection, Storage storage = null)
: base(connection, storage)
{
}
protected override void Prepare(bool reset = false)
{
Connection.CreateTable<Binding>();
}
protected override Type[] ValidTypes => new[]
{
typeof(Binding)
};
}
}

View File

@ -19,6 +19,7 @@ using osu.Game.Online.API;
using SQLite.Net; using SQLite.Net;
using osu.Framework.Graphics.Performance; using osu.Framework.Graphics.Performance;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.Input;
using osu.Game.IO; using osu.Game.IO;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
@ -37,6 +38,8 @@ namespace osu.Game
protected ScoreStore ScoreStore; protected ScoreStore ScoreStore;
protected BindingStore BindingStore;
protected override string MainResourceFile => @"osu.Game.Resources.dll"; protected override string MainResourceFile => @"osu.Game.Resources.dll";
public APIAccess API; public APIAccess API;
@ -104,6 +107,7 @@ namespace osu.Game
dependencies.Cache(FileStore = new FileStore(connection, Host.Storage)); dependencies.Cache(FileStore = new FileStore(connection, Host.Storage));
dependencies.Cache(BeatmapManager = new BeatmapManager(Host.Storage, FileStore, connection, RulesetStore, Host)); dependencies.Cache(BeatmapManager = new BeatmapManager(Host.Storage, FileStore, connection, RulesetStore, Host));
dependencies.Cache(ScoreStore = new ScoreStore(Host.Storage, connection, Host, BeatmapManager)); dependencies.Cache(ScoreStore = new ScoreStore(Host.Storage, connection, Host, BeatmapManager));
dependencies.Cache(BindingStore = new BindingStore(connection));
dependencies.Cache(new OsuColour()); dependencies.Cache(new OsuColour());
//this completely overrides the framework default. will need to change once we make a proper FontStore. //this completely overrides the framework default. will need to change once we make a proper FontStore.

View File

@ -7,16 +7,16 @@ using osu.Game.Rulesets.UI;
namespace osu.Game.Rulesets.Mods namespace osu.Game.Rulesets.Mods
{ {
/// <summary> /// <summary>
/// An interface for mods that are applied to a HitRenderer. /// An interface for mods that are applied to a RulesetContainer.
/// </summary> /// </summary>
/// <typeparam name="TObject">The type of HitObject the HitRenderer contains.</typeparam> /// <typeparam name="TObject">The type of HitObject the RulesetContainer contains.</typeparam>
public interface IApplicableMod<TObject> public interface IApplicableMod<TObject>
where TObject : HitObject where TObject : HitObject
{ {
/// <summary> /// <summary>
/// Applies the mod to a HitRenderer. /// Applies the mod to a RulesetContainer.
/// </summary> /// </summary>
/// <param name="hitRenderer">The HitRenderer to apply the mod to.</param> /// <param name="rulesetContainer">The RulesetContainer to apply the mod to.</param>
void ApplyToHitRenderer(HitRenderer<TObject> hitRenderer); void ApplyToRulesetContainer(RulesetContainer<TObject> rulesetContainer);
} }
} }

View File

@ -15,9 +15,9 @@ namespace osu.Game.Rulesets.Mods
{ {
protected abstract Score CreateReplayScore(Beatmap<T> beatmap); protected abstract Score CreateReplayScore(Beatmap<T> beatmap);
public void ApplyToHitRenderer(HitRenderer<T> hitRenderer) public void ApplyToRulesetContainer(RulesetContainer<T> rulesetContainer)
{ {
hitRenderer.SetReplay(CreateReplayScore(hitRenderer.Beatmap)?.Replay); rulesetContainer.SetReplay(CreateReplayScore(rulesetContainer.Beatmap)?.Replay);
} }
} }

View File

@ -15,12 +15,19 @@ namespace osu.Game.Rulesets
{ {
public abstract class Ruleset public abstract class Ruleset
{ {
public readonly RulesetInfo RulesetInfo;
public virtual IEnumerable<BeatmapStatistic> GetBeatmapStatistics(WorkingBeatmap beatmap) => new BeatmapStatistic[] { }; public virtual IEnumerable<BeatmapStatistic> GetBeatmapStatistics(WorkingBeatmap beatmap) => new BeatmapStatistic[] { };
public abstract IEnumerable<Mod> GetModsFor(ModType type); public abstract IEnumerable<Mod> GetModsFor(ModType type);
public abstract Mod GetAutoplayMod(); public abstract Mod GetAutoplayMod();
protected Ruleset(RulesetInfo rulesetInfo)
{
RulesetInfo = rulesetInfo;
}
/// <summary> /// <summary>
/// Attempt to create a hit renderer for a beatmap /// Attempt to create a hit renderer for a beatmap
/// </summary> /// </summary>
@ -28,7 +35,7 @@ namespace osu.Game.Rulesets
/// <param name="isForCurrentRuleset">Whether the hit renderer should assume the beatmap is for the current ruleset.</param> /// <param name="isForCurrentRuleset">Whether the hit renderer should assume the beatmap is for the current ruleset.</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 HitRenderer CreateHitRendererWith(WorkingBeatmap beatmap, bool isForCurrentRuleset); public abstract RulesetContainer CreateRulesetContainerWith(WorkingBeatmap beatmap, bool isForCurrentRuleset);
public abstract DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap); public abstract DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap);

View File

@ -20,6 +20,6 @@ namespace osu.Game.Rulesets
[Indexed] [Indexed]
public bool Available { get; set; } public bool Available { get; set; }
public virtual Ruleset CreateInstance() => (Ruleset)Activator.CreateInstance(Type.GetType(InstantiationInfo)); public virtual Ruleset CreateInstance() => (Ruleset)Activator.CreateInstance(Type.GetType(InstantiationInfo), this);
} }
} }

View File

@ -44,7 +44,7 @@ namespace osu.Game.Rulesets
continue; continue;
foreach (Type rulesetType in rulesets) foreach (Type rulesetType in rulesets)
instances.Add((Ruleset)Activator.CreateInstance(rulesetType)); instances.Add((Ruleset)Activator.CreateInstance(rulesetType, new RulesetInfo()));
} }
catch (Exception) { } catch (Exception) { }
} }

View File

@ -150,13 +150,13 @@ namespace osu.Game.Rulesets.Scoring
{ {
} }
protected ScoreProcessor(HitRenderer<TObject, TJudgement> hitRenderer) protected ScoreProcessor(RulesetContainer<TObject, TJudgement> rulesetContainer)
{ {
Judgements.Capacity = hitRenderer.Beatmap.HitObjects.Count; Judgements.Capacity = rulesetContainer.Beatmap.HitObjects.Count;
hitRenderer.OnJudgement += AddJudgement; rulesetContainer.OnJudgement += AddJudgement;
ComputeTargets(hitRenderer.Beatmap); ComputeTargets(rulesetContainer.Beatmap);
Reset(); Reset();
} }

View File

@ -14,6 +14,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using osu.Framework.Input;
using osu.Game.Rulesets.Replays; using osu.Game.Rulesets.Replays;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using OpenTK; using OpenTK;
@ -22,12 +23,12 @@ using osu.Game.Rulesets.Beatmaps;
namespace osu.Game.Rulesets.UI namespace osu.Game.Rulesets.UI
{ {
/// <summary> /// <summary>
/// Base HitRenderer. Doesn't hold objects. /// Base RulesetContainer. Doesn't hold objects.
/// <para> /// <para>
/// Should not be derived - derive <see cref="HitRenderer{TObject, TJudgement}"/> instead. /// Should not be derived - derive <see cref="RulesetContainer{TObject,TJudgement}"/> instead.
/// </para> /// </para>
/// </summary> /// </summary>
public abstract class HitRenderer : Container public abstract class RulesetContainer : Container
{ {
/// <summary> /// <summary>
/// Invoked when all the judgeable HitObjects have been judged. /// Invoked when all the judgeable HitObjects have been judged.
@ -40,14 +41,14 @@ namespace osu.Game.Rulesets.UI
public bool AspectAdjust = true; public bool AspectAdjust = true;
/// <summary> /// <summary>
/// The input manager for this HitRenderer. /// The input manager for this RulesetContainer.
/// </summary> /// </summary>
internal readonly PlayerInputManager InputManager = new PlayerInputManager(); internal readonly PlayerInputManager InputManager = new PlayerInputManager();
/// <summary> /// <summary>
/// The key conversion input manager for this HitRenderer. /// The key conversion input manager for this RulesetContainer.
/// </summary> /// </summary>
protected readonly KeyConversionInputManager KeyConversionInputManager; protected readonly PassThroughInputManager KeyConversionInputManager;
/// <summary> /// <summary>
/// Whether we are currently providing the local user a gameplay cursor. /// Whether we are currently providing the local user a gameplay cursor.
@ -66,9 +67,16 @@ namespace osu.Game.Rulesets.UI
/// </summary> /// </summary>
protected abstract bool AllObjectsJudged { get; } protected abstract bool AllObjectsJudged { get; }
internal HitRenderer() protected readonly Ruleset Ruleset;
/// <summary>
/// A visual representation of a <see cref="Rulesets.Ruleset"/>.
/// </summary>
/// <param name="ruleset">The ruleset being repesented.</param>
internal RulesetContainer(Ruleset ruleset)
{ {
KeyConversionInputManager = CreateKeyConversionInputManager(); Ruleset = ruleset;
KeyConversionInputManager = CreateActionMappingInputManager();
KeyConversionInputManager.RelativeSizeAxes = Axes.Both; KeyConversionInputManager.RelativeSizeAxes = Axes.Both;
} }
@ -87,7 +95,7 @@ namespace osu.Game.Rulesets.UI
/// Creates a key conversion input manager. /// Creates a key conversion input manager.
/// </summary> /// </summary>
/// <returns>The input manager.</returns> /// <returns>The input manager.</returns>
protected virtual KeyConversionInputManager CreateKeyConversionInputManager() => new KeyConversionInputManager(); protected virtual PassThroughInputManager CreateActionMappingInputManager() => new PassThroughInputManager();
protected virtual FramedReplayInputHandler CreateReplayInputHandler(Replay replay) => new FramedReplayInputHandler(replay); protected virtual FramedReplayInputHandler CreateReplayInputHandler(Replay replay) => new FramedReplayInputHandler(replay);
@ -105,14 +113,14 @@ namespace osu.Game.Rulesets.UI
} }
/// <summary> /// <summary>
/// HitRenderer that applies conversion to Beatmaps. Does not contain a Playfield /// RulesetContainer that applies conversion to Beatmaps. Does not contain a Playfield
/// and does not load drawable hit objects. /// and does not load drawable hit objects.
/// <para> /// <para>
/// Should not be derived - derive <see cref="HitRenderer{TObject, TJudgement}"/> instead. /// Should not be derived - derive <see cref="RulesetContainer{TObject,TJudgement}"/> instead.
/// </para> /// </para>
/// </summary> /// </summary>
/// <typeparam name="TObject">The type of HitObject contained by this HitRenderer.</typeparam> /// <typeparam name="TObject">The type of HitObject contained by this RulesetContainer.</typeparam>
public abstract class HitRenderer<TObject> : HitRenderer public abstract class RulesetContainer<TObject> : RulesetContainer
where TObject : HitObject where TObject : HitObject
{ {
/// <summary> /// <summary>
@ -133,11 +141,12 @@ namespace osu.Game.Rulesets.UI
/// <summary> /// <summary>
/// Creates a hit renderer for a beatmap. /// Creates a hit renderer for a beatmap.
/// </summary> /// </summary>
/// <param name="ruleset">The ruleset being repesented.</param>
/// <param name="beatmap">The beatmap to create the hit renderer for.</param> /// <param name="beatmap">The beatmap to create the hit renderer for.</param>
/// <param name="isForCurrentRuleset">Whether to assume the beatmap is for the current ruleset.</param> /// <param name="isForCurrentRuleset">Whether to assume the beatmap is for the current ruleset.</param>
internal HitRenderer(WorkingBeatmap beatmap, bool isForCurrentRuleset) internal RulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap, bool isForCurrentRuleset) : base(ruleset)
{ {
Debug.Assert(beatmap != null, "HitRenderer initialized with a null beatmap."); Debug.Assert(beatmap != null, "RulesetContainer initialized with a null beatmap.");
Mods = beatmap.Mods.Value; Mods = beatmap.Mods.Value;
@ -171,7 +180,7 @@ namespace osu.Game.Rulesets.UI
} }
/// <summary> /// <summary>
/// Applies the active mods to this HitRenderer. /// Applies the active mods to this RulesetContainer.
/// </summary> /// </summary>
/// <param name="mods"></param> /// <param name="mods"></param>
private void applyMods(IEnumerable<Mod> mods) private void applyMods(IEnumerable<Mod> mods)
@ -180,7 +189,7 @@ namespace osu.Game.Rulesets.UI
return; return;
foreach (var mod in mods.OfType<IApplicableMod<TObject>>()) foreach (var mod in mods.OfType<IApplicableMod<TObject>>())
mod.ApplyToHitRenderer(this); mod.ApplyToRulesetContainer(this);
} }
/// <summary> /// <summary>
@ -203,11 +212,11 @@ namespace osu.Game.Rulesets.UI
} }
/// <summary> /// <summary>
/// A derivable HitRenderer that manages the Playfield and HitObjects. /// A derivable RulesetContainer that manages the Playfield and HitObjects.
/// </summary> /// </summary>
/// <typeparam name="TObject">The type of HitObject contained by this HitRenderer.</typeparam> /// <typeparam name="TObject">The type of HitObject contained by this RulesetContainer.</typeparam>
/// <typeparam name="TJudgement">The type of Judgement of DrawableHitObjects contained by this HitRenderer.</typeparam> /// <typeparam name="TJudgement">The type of Judgement of DrawableHitObjects contained by this RulesetContainer.</typeparam>
public abstract class HitRenderer<TObject, TJudgement> : HitRenderer<TObject> public abstract class RulesetContainer<TObject, TJudgement> : RulesetContainer<TObject>
where TObject : HitObject where TObject : HitObject
where TJudgement : Judgement where TJudgement : Judgement
{ {
@ -235,10 +244,11 @@ namespace osu.Game.Rulesets.UI
/// <summary> /// <summary>
/// Creates a hit renderer for a beatmap. /// Creates a hit renderer for a beatmap.
/// </summary> /// </summary>
/// <param name="ruleset">The ruleset being repesented.</param>
/// <param name="beatmap">The beatmap to create the hit renderer for.</param> /// <param name="beatmap">The beatmap to create the hit renderer for.</param>
/// <param name="isForCurrentRuleset">Whether to assume the beatmap is for the current ruleset.</param> /// <param name="isForCurrentRuleset">Whether to assume the beatmap is for the current ruleset.</param>
protected HitRenderer(WorkingBeatmap beatmap, bool isForCurrentRuleset) protected RulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap, bool isForCurrentRuleset)
: base(beatmap, isForCurrentRuleset) : base(ruleset, beatmap, isForCurrentRuleset)
{ {
InputManager.Add(content = new Container InputManager.Add(content = new Container
{ {
@ -324,12 +334,12 @@ namespace osu.Game.Rulesets.UI
} }
/// <summary> /// <summary>
/// A derivable HitRenderer that manages the Playfield and HitObjects. /// A derivable RulesetContainer that manages the Playfield and HitObjects.
/// </summary> /// </summary>
/// <typeparam name="TPlayfield">The type of Playfield contained by this HitRenderer.</typeparam> /// <typeparam name="TPlayfield">The type of Playfield contained by this RulesetContainer.</typeparam>
/// <typeparam name="TObject">The type of HitObject contained by this HitRenderer.</typeparam> /// <typeparam name="TObject">The type of HitObject contained by this RulesetContainer.</typeparam>
/// <typeparam name="TJudgement">The type of Judgement of DrawableHitObjects contained by this HitRenderer.</typeparam> /// <typeparam name="TJudgement">The type of Judgement of DrawableHitObjects contained by this RulesetContainer.</typeparam>
public abstract class HitRenderer<TPlayfield, TObject, TJudgement> : HitRenderer<TObject, TJudgement> public abstract class RulesetContainer<TPlayfield, TObject, TJudgement> : RulesetContainer<TObject, TJudgement>
where TObject : HitObject where TObject : HitObject
where TJudgement : Judgement where TJudgement : Judgement
where TPlayfield : Playfield<TObject, TJudgement> where TPlayfield : Playfield<TObject, TJudgement>
@ -342,10 +352,11 @@ namespace osu.Game.Rulesets.UI
/// <summary> /// <summary>
/// Creates a hit renderer for a beatmap. /// Creates a hit renderer for a beatmap.
/// </summary> /// </summary>
/// <param name="ruleset">The ruleset being repesented.</param>
/// <param name="beatmap">The beatmap to create the hit renderer for.</param> /// <param name="beatmap">The beatmap to create the hit renderer for.</param>
/// <param name="isForCurrentRuleset">Whether to assume the beatmap is for the current ruleset.</param> /// <param name="isForCurrentRuleset">Whether to assume the beatmap is for the current ruleset.</param>
protected HitRenderer(WorkingBeatmap beatmap, bool isForCurrentRuleset) protected RulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap, bool isForCurrentRuleset)
: base(beatmap, isForCurrentRuleset) : base(ruleset, beatmap, isForCurrentRuleset)
{ {
} }
} }

View File

@ -17,23 +17,23 @@ using osu.Game.Rulesets.Timing;
namespace osu.Game.Rulesets.UI namespace osu.Game.Rulesets.UI
{ {
/// <summary> /// <summary>
/// A type of <see cref="HitRenderer{TPlayfield, TObject, TJudgement}"/> that supports a <see cref="ScrollingPlayfield{TObject, TJudgement}"/>. /// A type of <see cref="RulesetContainer{TPlayfield,TObject,TJudgement}"/> that supports a <see cref="ScrollingPlayfield{TObject, TJudgement}"/>.
/// <see cref="HitObject"/>s inside this <see cref="HitRenderer{TPlayfield, TObject, TJudgement}"/> will scroll within the playfield. /// <see cref="HitObject"/>s inside this <see cref="RulesetContainer{TPlayfield,TObject,TJudgement}"/> will scroll within the playfield.
/// </summary> /// </summary>
public abstract class ScrollingHitRenderer<TPlayfield, TObject, TJudgement> : HitRenderer<TPlayfield, TObject, TJudgement> public abstract class ScrollingRulesetContainer<TPlayfield, TObject, TJudgement> : RulesetContainer<TPlayfield, TObject, TJudgement>
where TObject : HitObject where TObject : HitObject
where TJudgement : Judgement where TJudgement : Judgement
where TPlayfield : ScrollingPlayfield<TObject, TJudgement> where TPlayfield : ScrollingPlayfield<TObject, TJudgement>
{ {
/// <summary> /// <summary>
/// Provides the default <see cref="MultiplierControlPoint"/>s that adjust the scrolling rate of <see cref="HitObject"/>s /// Provides the default <see cref="MultiplierControlPoint"/>s that adjust the scrolling rate of <see cref="HitObject"/>s
/// inside this <see cref="HitRenderer{TPlayfield, TObject, TJudgement}"/>. /// inside this <see cref="RulesetContainer{TPlayfield,TObject,TJudgement}"/>.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
protected readonly SortedList<MultiplierControlPoint> DefaultControlPoints = new SortedList<MultiplierControlPoint>(Comparer<MultiplierControlPoint>.Default); protected readonly SortedList<MultiplierControlPoint> DefaultControlPoints = new SortedList<MultiplierControlPoint>(Comparer<MultiplierControlPoint>.Default);
protected ScrollingHitRenderer(WorkingBeatmap beatmap, bool isForCurrentRuleset) protected ScrollingRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap, bool isForCurrentRuleset)
: base(beatmap, isForCurrentRuleset) : base(ruleset, beatmap, isForCurrentRuleset)
{ {
} }

View File

@ -90,11 +90,11 @@ namespace osu.Game.Screens.Play
} }
} }
public virtual void BindHitRenderer(HitRenderer hitRenderer) public virtual void BindRulesetContainer(RulesetContainer rulesetContainer)
{ {
hitRenderer.InputManager.Add(KeyCounter.GetReceptor()); rulesetContainer.InputManager.Add(KeyCounter.GetReceptor());
replayLoaded = hitRenderer.HasReplayLoaded; replayLoaded = rulesetContainer.HasReplayLoaded;
// in the case a replay isn't loaded, we want some elements to only appear briefly. // in the case a replay isn't loaded, we want some elements to only appear briefly.
if (!replayLoaded) if (!replayLoaded)

View File

@ -1,16 +0,0 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Input;
namespace osu.Game.Screens.Play
{
/// <summary>
/// An InputManager primarily used to map keys to new functions.
/// By default this does nothing; override TransformState to make alterations.
/// </summary>
public class KeyConversionInputManager : PassThroughInputManager
{
}
}

View File

@ -32,7 +32,7 @@ namespace osu.Game.Screens.Play
internal override bool ShowOverlays => false; internal override bool ShowOverlays => false;
internal override bool HasLocalCursorDisplayed => !pauseContainer.IsPaused && !HasFailed && HitRenderer.ProvidingUserCursor; internal override bool HasLocalCursorDisplayed => !pauseContainer.IsPaused && !HasFailed && RulesetContainer.ProvidingUserCursor;
public Action RestartRequested; public Action RestartRequested;
@ -51,7 +51,7 @@ namespace osu.Game.Screens.Play
private RulesetInfo ruleset; private RulesetInfo ruleset;
private ScoreProcessor scoreProcessor; private ScoreProcessor scoreProcessor;
protected HitRenderer HitRenderer; protected RulesetContainer RulesetContainer;
#region User Settings #region User Settings
@ -66,7 +66,7 @@ namespace osu.Game.Screens.Play
private HUDOverlay hudOverlay; private HUDOverlay hudOverlay;
private FailOverlay failOverlay; private FailOverlay failOverlay;
private bool loadedSuccessfully => HitRenderer?.Objects.Any() == true; private bool loadedSuccessfully => RulesetContainer?.Objects.Any() == true;
[BackgroundDependencyLoader(permitNulls: true)] [BackgroundDependencyLoader(permitNulls: true)]
private void load(AudioManager audio, OsuConfigManager config, OsuGame osu) private void load(AudioManager audio, OsuConfigManager config, OsuGame osu)
@ -93,18 +93,18 @@ namespace osu.Game.Screens.Play
try try
{ {
HitRenderer = rulesetInstance.CreateHitRendererWith(working, ruleset.ID == beatmap.BeatmapInfo.Ruleset.ID); RulesetContainer = rulesetInstance.CreateRulesetContainerWith(working, ruleset.ID == beatmap.BeatmapInfo.Ruleset.ID);
} }
catch (BeatmapInvalidForRulesetException) catch (BeatmapInvalidForRulesetException)
{ {
// we may fail to create a HitRenderer if the beatmap cannot be loaded with the user's preferred ruleset // we may fail to create a RulesetContainer if the beatmap cannot be loaded with the user's preferred ruleset
// let's try again forcing the beatmap's ruleset. // let's try again forcing the beatmap's ruleset.
ruleset = beatmap.BeatmapInfo.Ruleset; ruleset = beatmap.BeatmapInfo.Ruleset;
rulesetInstance = ruleset.CreateInstance(); rulesetInstance = ruleset.CreateInstance();
HitRenderer = rulesetInstance.CreateHitRendererWith(Beatmap, true); RulesetContainer = rulesetInstance.CreateRulesetContainerWith(Beatmap, true);
} }
if (!HitRenderer.Objects.Any()) if (!RulesetContainer.Objects.Any())
throw new InvalidOperationException("Beatmap contains no hit objects!"); throw new InvalidOperationException("Beatmap contains no hit objects!");
} }
catch (Exception e) catch (Exception e)
@ -119,7 +119,7 @@ namespace osu.Game.Screens.Play
adjustableSourceClock = (IAdjustableClock)working.Track ?? new StopwatchClock(); adjustableSourceClock = (IAdjustableClock)working.Track ?? new StopwatchClock();
decoupledClock = new DecoupleableInterpolatingFramedClock { IsCoupled = false }; decoupledClock = new DecoupleableInterpolatingFramedClock { IsCoupled = false };
var firstObjectTime = HitRenderer.Objects.First().StartTime; var firstObjectTime = RulesetContainer.Objects.First().StartTime;
decoupledClock.Seek(Math.Min(0, firstObjectTime - Math.Max(beatmap.ControlPointInfo.TimingPointAt(firstObjectTime).BeatLength * 4, beatmap.BeatmapInfo.AudioLeadIn))); decoupledClock.Seek(Math.Min(0, firstObjectTime - Math.Max(beatmap.ControlPointInfo.TimingPointAt(firstObjectTime).BeatLength * 4, beatmap.BeatmapInfo.AudioLeadIn)));
decoupledClock.ProcessFrame(); decoupledClock.ProcessFrame();
@ -147,7 +147,7 @@ namespace osu.Game.Screens.Play
FramedClock = offsetClock, FramedClock = offsetClock,
OnRetry = Restart, OnRetry = Restart,
OnQuit = Exit, OnQuit = Exit,
CheckCanPause = () => ValidForResume && !HasFailed && !HitRenderer.HasReplayLoaded, CheckCanPause = () => ValidForResume && !HasFailed && !RulesetContainer.HasReplayLoaded,
Retries = RestartCount, Retries = RestartCount,
OnPause = () => { OnPause = () => {
hudOverlay.KeyCounter.IsCounting = pauseContainer.IsPaused; hudOverlay.KeyCounter.IsCounting = pauseContainer.IsPaused;
@ -164,7 +164,7 @@ namespace osu.Game.Screens.Play
Clock = offsetClock, Clock = offsetClock,
Children = new Drawable[] Children = new Drawable[]
{ {
HitRenderer, RulesetContainer,
} }
}, },
hudOverlay = new HUDOverlay hudOverlay = new HUDOverlay
@ -184,27 +184,27 @@ namespace osu.Game.Screens.Play
Action = () => { Action = () => {
//we want to hide the hitrenderer immediately (looks better). //we want to hide the hitrenderer immediately (looks better).
//we may be able to remove this once the mouse cursor trail is improved. //we may be able to remove this once the mouse cursor trail is improved.
HitRenderer?.Hide(); RulesetContainer?.Hide();
Restart(); Restart();
}, },
} }
}; };
scoreProcessor = HitRenderer.CreateScoreProcessor(); scoreProcessor = RulesetContainer.CreateScoreProcessor();
hudOverlay.KeyCounter.AddRange(rulesetInstance.CreateGameplayKeys()); hudOverlay.KeyCounter.AddRange(rulesetInstance.CreateGameplayKeys());
hudOverlay.BindProcessor(scoreProcessor); hudOverlay.BindProcessor(scoreProcessor);
hudOverlay.BindHitRenderer(HitRenderer); hudOverlay.BindRulesetContainer(RulesetContainer);
hudOverlay.Progress.Objects = HitRenderer.Objects; hudOverlay.Progress.Objects = RulesetContainer.Objects;
hudOverlay.Progress.AudioClock = decoupledClock; hudOverlay.Progress.AudioClock = decoupledClock;
hudOverlay.Progress.AllowSeeking = HitRenderer.HasReplayLoaded; hudOverlay.Progress.AllowSeeking = RulesetContainer.HasReplayLoaded;
hudOverlay.Progress.OnSeek = pos => decoupledClock.Seek(pos); hudOverlay.Progress.OnSeek = pos => decoupledClock.Seek(pos);
hudOverlay.ModDisplay.Current.BindTo(working.Mods); hudOverlay.ModDisplay.Current.BindTo(working.Mods);
//bind HitRenderer to ScoreProcessor and ourselves (for a pass situation) //bind RulesetContainer to ScoreProcessor and ourselves (for a pass situation)
HitRenderer.OnAllJudged += onCompletion; RulesetContainer.OnAllJudged += onCompletion;
//bind ScoreProcessor to ourselves (for a fail situation) //bind ScoreProcessor to ourselves (for a fail situation)
scoreProcessor.Failed += onFail; scoreProcessor.Failed += onFail;
@ -238,7 +238,7 @@ namespace osu.Game.Screens.Play
Ruleset = ruleset Ruleset = ruleset
}; };
scoreProcessor.PopulateScore(score); scoreProcessor.PopulateScore(score);
score.User = HitRenderer.Replay?.User ?? (Game as OsuGame)?.API?.LocalUser?.Value; score.User = RulesetContainer.Replay?.User ?? (Game as OsuGame)?.API?.LocalUser?.Value;
Push(new Results(score)); Push(new Results(score));
}); });
} }
@ -295,7 +295,7 @@ namespace osu.Game.Screens.Play
protected override bool OnExiting(Screen next) protected override bool OnExiting(Screen next)
{ {
if (HasFailed || !ValidForResume || pauseContainer?.AllowExit != false || HitRenderer?.HasReplayLoaded != false) if (HasFailed || !ValidForResume || pauseContainer?.AllowExit != false || RulesetContainer?.HasReplayLoaded != false)
{ {
fadeOut(); fadeOut();
return base.OnExiting(next); return base.OnExiting(next);
@ -313,7 +313,7 @@ namespace osu.Game.Screens.Play
{ {
const float fade_out_duration = 250; const float fade_out_duration = 250;
HitRenderer?.FadeOut(fade_out_duration); RulesetContainer?.FadeOut(fade_out_duration);
Content.FadeOut(fade_out_duration); Content.FadeOut(fade_out_duration);
hudOverlay?.ScaleTo(0.7f, fade_out_duration * 3, Easing.In); hudOverlay?.ScaleTo(0.7f, fade_out_duration * 3, Easing.In);

View File

@ -17,7 +17,7 @@ namespace osu.Game.Screens.Play
protected override void LoadComplete() protected override void LoadComplete()
{ {
base.LoadComplete(); base.LoadComplete();
HitRenderer.SetReplay(Replay); RulesetContainer.SetReplay(Replay);
} }
} }
} }

View File

@ -92,6 +92,8 @@
<Compile Include="Graphics\UserInterface\MenuItemType.cs" /> <Compile Include="Graphics\UserInterface\MenuItemType.cs" />
<Compile Include="Graphics\UserInterface\OsuContextMenu.cs" /> <Compile Include="Graphics\UserInterface\OsuContextMenu.cs" />
<Compile Include="Graphics\UserInterface\OsuContextMenuItem.cs" /> <Compile Include="Graphics\UserInterface\OsuContextMenuItem.cs" />
<Compile Include="Input\Binding.cs" />
<Compile Include="Input\BindingStore.cs" />
<Compile Include="IO\FileStore.cs" /> <Compile Include="IO\FileStore.cs" />
<Compile Include="IO\FileInfo.cs" /> <Compile Include="IO\FileInfo.cs" />
<Compile Include="Online\API\Requests\GetUsersRequest.cs" /> <Compile Include="Online\API\Requests\GetUsersRequest.cs" />
@ -118,6 +120,7 @@
<Compile Include="Overlays\Profile\Sections\RecentSection.cs" /> <Compile Include="Overlays\Profile\Sections\RecentSection.cs" />
<Compile Include="Graphics\Containers\ConstrainedIconContainer.cs" /> <Compile Include="Graphics\Containers\ConstrainedIconContainer.cs" />
<Compile Include="Rulesets\Mods\IApplicableToDifficulty.cs" /> <Compile Include="Rulesets\Mods\IApplicableToDifficulty.cs" />
<Compile Include="Input\ActionMappingInputManager.cs" />
<Compile Include="Users\UserCoverBackground.cs" /> <Compile Include="Users\UserCoverBackground.cs" />
<Compile Include="Overlays\UserProfileOverlay.cs" /> <Compile Include="Overlays\UserProfileOverlay.cs" />
<Compile Include="Overlays\Profile\ProfileHeader.cs" /> <Compile Include="Overlays\Profile\ProfileHeader.cs" />
@ -309,7 +312,6 @@
<Compile Include="Screens\Multiplayer\MatchCreate.cs" /> <Compile Include="Screens\Multiplayer\MatchCreate.cs" />
<Compile Include="Screens\Play\FailOverlay.cs" /> <Compile Include="Screens\Play\FailOverlay.cs" />
<Compile Include="Screens\Play\MenuOverlay.cs" /> <Compile Include="Screens\Play\MenuOverlay.cs" />
<Compile Include="Screens\Play\KeyConversionInputManager.cs" />
<Compile Include="Screens\Play\PlayerInputManager.cs" /> <Compile Include="Screens\Play\PlayerInputManager.cs" />
<Compile Include="Screens\Play\PlayerLoader.cs" /> <Compile Include="Screens\Play\PlayerLoader.cs" />
<Compile Include="Screens\Play\ReplayPlayer.cs" /> <Compile Include="Screens\Play\ReplayPlayer.cs" />
@ -338,9 +340,9 @@
<Compile Include="Screens\Select\Options\BeatmapOptionsOverlay.cs" /> <Compile Include="Screens\Select\Options\BeatmapOptionsOverlay.cs" />
<Compile Include="Screens\Select\PlaySongSelect.cs" /> <Compile Include="Screens\Select\PlaySongSelect.cs" />
<Compile Include="Screens\Select\SongSelect.cs" /> <Compile Include="Screens\Select\SongSelect.cs" />
<Compile Include="Rulesets\UI\HitRenderer.cs" /> <Compile Include="Rulesets\UI\RulesetContainer.cs" />
<Compile Include="Rulesets\UI\Playfield.cs" /> <Compile Include="Rulesets\UI\Playfield.cs" />
<Compile Include="Rulesets\UI\ScrollingHitRenderer.cs" /> <Compile Include="Rulesets\UI\ScrollingRulesetContainer.cs" />
<Compile Include="Rulesets\UI\ScrollingPlayfield.cs" /> <Compile Include="Rulesets\UI\ScrollingPlayfield.cs" />
<Compile Include="Screens\Select\EditSongSelect.cs" /> <Compile Include="Screens\Select\EditSongSelect.cs" />
<Compile Include="Screens\Play\HUD\ComboCounter.cs" /> <Compile Include="Screens\Play\HUD\ComboCounter.cs" />