mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Move InputManager to a higher and more implicit level.
Also makes KeyCounterCollection work with replays.
This commit is contained in:
@ -11,6 +11,7 @@ using osu.Game.Modes.Objects;
|
||||
using osu.Game.Modes.Objects.Drawables;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Screens.Play;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Modes.UI
|
||||
{
|
||||
@ -20,6 +21,13 @@ namespace osu.Game.Modes.UI
|
||||
|
||||
public event Action OnAllJudged;
|
||||
|
||||
internal readonly PlayerInputManager InputManager = new PlayerInputManager();
|
||||
|
||||
/// <summary>
|
||||
/// A function to convert coordinates from gamefield to screen space.
|
||||
/// </summary>
|
||||
public abstract Func<Vector2, Vector2> MapPlayfieldToScreenSpace { get; }
|
||||
|
||||
public abstract bool AllObjectsJudged { get; }
|
||||
|
||||
protected void TriggerOnJudgement(JudgementInfo j)
|
||||
@ -35,10 +43,10 @@ namespace osu.Game.Modes.UI
|
||||
{
|
||||
private List<TObject> objects;
|
||||
|
||||
public PlayerInputManager InputManager;
|
||||
|
||||
protected Playfield<TObject> Playfield;
|
||||
|
||||
public override Func<Vector2, Vector2> MapPlayfieldToScreenSpace => Playfield.ScaledContent.ToScreenSpace;
|
||||
|
||||
public override bool AllObjectsJudged => Playfield.HitObjects.Children.First()?.Judgement.Result != null; //reverse depth sort means First() instead of Last().
|
||||
|
||||
public IEnumerable<DrawableHitObject> DrawableObjects => Playfield.HitObjects.Children;
|
||||
@ -62,16 +70,26 @@ namespace osu.Game.Modes.UI
|
||||
protected HitRenderer()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
InputManager.Add(content = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new[]
|
||||
{
|
||||
Playfield = CreatePlayfield(),
|
||||
}
|
||||
});
|
||||
|
||||
AddInternal(InputManager);
|
||||
}
|
||||
|
||||
protected override Container<Drawable> Content => content;
|
||||
|
||||
private Container content;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Playfield = CreatePlayfield();
|
||||
Playfield.InputManager = InputManager;
|
||||
|
||||
Add(Playfield);
|
||||
|
||||
loadObjects();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user