mirror of
https://github.com/ppy/osu.git
synced 2024-11-09 09:20:05 +08:00
4430255ec4
# Conflicts: # osu.Desktop.VisualTests/Tests/TestCasePlayer.cs # osu.Desktop/OsuGameDesktop.cs # osu.Game.Modes.Osu/Objects/Drawables/DrawableHitCircle.cs # osu.Game.Modes.Osu/Objects/Drawables/DrawableSlider.cs # osu.Game/Database/BeatmapDatabase.cs # osu.Game/Graphics/Cursor/OsuCursorContainer.cs # osu.Game/IPC/BeatmapImporter.cs # osu.Game/Modes/Mod.cs # osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs # osu.Game/Modes/UI/Playfield.cs # osu.Game/Screens/Play/Player.cs # osu.Game/Screens/Play/PlayerInputManager.cs
90 lines
2.7 KiB
C#
90 lines
2.7 KiB
C#
// 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.Allocation;
|
|
using OpenTK;
|
|
using osu.Framework.Graphics;
|
|
using osu.Framework.Graphics.Containers;
|
|
using osu.Framework.Input;
|
|
using osu.Game.Modes.Objects;
|
|
using osu.Game.Modes.Objects.Drawables;
|
|
using osu.Game.Screens.Play;
|
|
|
|
namespace osu.Game.Modes.UI
|
|
{
|
|
public abstract class Playfield<T> : Container
|
|
where T : HitObject
|
|
{
|
|
public HitObjectContainer<DrawableHitObject<T>> HitObjects;
|
|
|
|
public virtual void Add(DrawableHitObject<T> h) => HitObjects.Add(h);
|
|
|
|
public class HitObjectContainer<U> : Container<U>
|
|
where U : Drawable
|
|
{
|
|
public override bool Contains(Vector2 screenSpacePos) => true;
|
|
}
|
|
|
|
private Container<Drawable> scaledContent;
|
|
|
|
public override bool Contains(Vector2 screenSpacePos) => true;
|
|
|
|
protected override Container<Drawable> Content { get; }
|
|
|
|
private Container content;
|
|
|
|
public Playfield()
|
|
{
|
|
AddInternal(scaledContent = new ScaledContainer
|
|
{
|
|
RelativeSizeAxes = Axes.Both,
|
|
Children = new[]
|
|
{
|
|
content = new Container
|
|
{
|
|
RelativeSizeAxes = Axes.Both,
|
|
}
|
|
}
|
|
});
|
|
|
|
Add(HitObjects = new HitObjectContainer<DrawableHitObject<T>>
|
|
{
|
|
RelativeSizeAxes = Axes.Both,
|
|
});
|
|
}
|
|
|
|
/// <summary>
|
|
/// An optional inputManager to provide interactivity etc.
|
|
/// </summary>
|
|
public PlayerInputManager InputManager;
|
|
|
|
[BackgroundDependencyLoader]
|
|
private void load()
|
|
{
|
|
if (InputManager != null)
|
|
{
|
|
//if we've been provided an InputManager, we want it to sit inside the scaledcontainer
|
|
scaledContent.Remove(content);
|
|
scaledContent.Add(InputManager);
|
|
InputManager.Add(content);
|
|
}
|
|
}
|
|
|
|
public virtual void PostProcess()
|
|
{
|
|
}
|
|
|
|
public class ScaledContainer : Container
|
|
{
|
|
protected override Vector2 DrawScale => new Vector2(DrawSize.X / 512);
|
|
|
|
public override bool Contains(Vector2 screenSpacePos) => true;
|
|
}
|
|
|
|
public class HitObjectContainer : Container<DrawableHitObject>
|
|
{
|
|
public override bool Contains(Vector2 screenSpacePos) => true;
|
|
}
|
|
}
|
|
}
|