1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 12:57:36 +08:00

Basic implementation of hold notes (not finalized yet).

This commit is contained in:
smoogipooo 2017-05-04 18:02:43 +09:00
parent f945c636c2
commit 4ad3e3d64e
7 changed files with 214 additions and 37 deletions

View File

@ -12,6 +12,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenTK.Graphics;
using OpenTK;
namespace osu.Desktop.VisualTests.Tests
{
@ -21,19 +22,48 @@ namespace osu.Desktop.VisualTests.Tests
{
base.Reset();
Add(new Container
Add(new FillFlowContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Y,
Width = 50,
Children = new[]
Direction = FillDirection.Horizontal,
Spacing = new Vector2(10, 0),
// Imagine that the containers containing the drawable notes are the "columns"
Children = new Drawable[]
{
new DrawableNote(new Note())
new Container
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
AccentColour = Color4.Red
RelativeSizeAxes = Axes.Y,
Width = 50,
Children = new[]
{
new DrawableNote(new Note())
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
AccentColour = Color4.Red
}
}
},
new Container
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Y,
Width = 50,
Children = new[]
{
new DrawableHoldNote(new HoldNote())
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
AccentColour = Color4.Red,
Length = 0.4f
}
}
}
}
});

View File

@ -0,0 +1,72 @@
// 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.Game.Rulesets.Objects.Drawables;
using osu.Framework.Graphics;
using osu.Framework.Allocation;
using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces;
using OpenTK.Graphics;
namespace osu.Game.Rulesets.Mania.Objects.Drawables
{
public class DrawableHoldNote : DrawableManiaHitObject<HoldNote>
{
/// <summary>
/// Length of this hold note, relative to its parent.
/// </summary>
public float Length;
private NotePiece headPiece;
private BodyPiece bodyPiece;
private NotePiece tailPiece;
public DrawableHoldNote(HoldNote hitObject)
: base(hitObject)
{
Children = new Drawable[]
{
headPiece = new NotePiece
{
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre
},
bodyPiece = new BodyPiece
{
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
},
tailPiece = new NotePiece
{
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre
}
};
}
public override Color4 AccentColour
{
get { return AccentColour; }
set
{
if (base.AccentColour == value)
return;
base.AccentColour = value;
headPiece.AccentColour = value;
bodyPiece.AccentColour = value;
tailPiece.AccentColour = value;
}
}
protected override void Update()
{
bodyPiece.Height = Parent.DrawSize.Y * Length;
}
protected override void UpdateState(ArmedState state)
{
}
}
}

View File

@ -4,6 +4,7 @@
using OpenTK.Graphics;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Rulesets.Mania.Judgements;
using osu.Game.Rulesets.Objects.Drawables;
@ -12,20 +13,12 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
public abstract class DrawableManiaHitObject<TObject> : DrawableHitObject<ManiaHitObject, ManiaJudgement>
where TObject : ManiaHitObject
{
public override Color4 AccentColour
{
get { return base.AccentColour; }
set
{
base.AccentColour = value;
UpdateAccent();
}
}
public new TObject HitObject;
private readonly Container glowContainer;
protected override Container<Drawable> Content => noteFlow;
private FlowContainer<Drawable> noteFlow;
private readonly FlowContainer<Drawable> noteFlow;
public DrawableManiaHitObject(TObject hitObject)
: base(hitObject)
@ -35,18 +28,53 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
AddInternal(noteFlow = new FillFlowContainer<Drawable>
InternalChildren = new Drawable[]
{
Name = "Main container",
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y
});
glowContainer = new Container
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Masking = true,
Children = new[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
AlwaysPresent = true,
Alpha = 0
}
}
},
noteFlow = new FillFlowContainer<Drawable>
{
Name = "Main container",
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y
}
};
}
public override Color4 AccentColour
{
get { return base.AccentColour; }
set
{
if (base.AccentColour == value)
return;
base.AccentColour = value;
glowContainer.EdgeEffect = new EdgeEffect
{
Type = EdgeEffectType.Glow,
Radius = 5,
Colour = value
};
}
}
protected override ManiaJudgement CreateJudgement() => new ManiaJudgement();
protected virtual void UpdateAccent() { }
}
}

View File

@ -21,10 +21,17 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
Add(headPiece = new NotePiece());
}
[BackgroundDependencyLoader]
private void load()
public override Color4 AccentColour
{
headPiece.AccentColour = AccentColour;
get { return AccentColour; }
set
{
if (base.AccentColour == value)
return;
base.AccentColour = value;
headPiece.AccentColour = value;
}
}
protected override void UpdateState(ArmedState state)

View File

@ -0,0 +1,47 @@
using System;
using OpenTK.Graphics;
using osu.Framework.Graphics;
// 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.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces
{
internal class BodyPiece : Container, IHasAccentColour
{
private Box box;
public BodyPiece()
{
RelativeSizeAxes = Axes.X;
Masking = true;
Children = new[]
{
box = new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0.3f
}
};
}
private Color4 accentColour;
public Color4 AccentColour
{
get { return accentColour; }
set
{
if (accentColour == value)
return;
accentColour = value;
box.Colour = accentColour;
}
}
}
}

View File

@ -22,8 +22,6 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces
RelativeSizeAxes = Axes.X;
Height = head_height;
Masking = true;
Children = new[]
{
new Box
@ -52,13 +50,6 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces
accentColour = value;
colouredBox.Colour = AccentColour.Lighten(0.9f);
EdgeEffect = new EdgeEffect
{
Type = EdgeEffectType.Glow,
Radius = 5,
Colour = AccentColour
};
}
}
}

View File

@ -51,8 +51,10 @@
<Compile Include="Judgements\HitWindows.cs" />
<Compile Include="Judgements\ManiaJudgement.cs" />
<Compile Include="ManiaDifficultyCalculator.cs" />
<Compile Include="Objects\Drawables\DrawableHoldNote.cs" />
<Compile Include="Objects\Drawables\DrawableManiaHitObject.cs" />
<Compile Include="Objects\Drawables\DrawableNote.cs" />
<Compile Include="Objects\Drawables\Pieces\BodyPiece.cs" />
<Compile Include="Objects\Drawables\Pieces\NotePiece.cs" />
<Compile Include="Objects\Types\IHasColumn.cs" />
<Compile Include="Scoring\ManiaScoreProcessor.cs" />