mirror of
https://github.com/ppy/osu.git
synced 2025-03-17 22:17:25 +08:00
Combine logic of Difficulty and Timing pieces where feasible
This commit is contained in:
parent
afbb674e52
commit
be08b9d1ef
@ -25,7 +25,7 @@ namespace osu.Game.Beatmaps.ControlPoints
|
||||
MaxValue = 10
|
||||
};
|
||||
|
||||
public override Color4 GetRepresentingColour(OsuColour colours) => colours.GreenDark;
|
||||
public override Color4 GetRepresentingColour(OsuColour colours) => colours.Lime1;
|
||||
|
||||
/// <summary>
|
||||
/// The speed multiplier at this control point.
|
||||
|
@ -1,67 +1,27 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
{
|
||||
public class DifficultyPointPiece : CompositeDrawable
|
||||
public class DifficultyPointPiece : TopPointPiece
|
||||
{
|
||||
private readonly DifficultyControlPoint difficultyPoint;
|
||||
|
||||
private OsuSpriteText speedMultiplierText;
|
||||
private readonly BindableNumber<double> speedMultiplier;
|
||||
|
||||
public DifficultyPointPiece(DifficultyControlPoint difficultyPoint)
|
||||
public DifficultyPointPiece(DifficultyControlPoint point)
|
||||
: base(point)
|
||||
{
|
||||
this.difficultyPoint = difficultyPoint;
|
||||
speedMultiplier = difficultyPoint.SpeedMultiplierBindable.GetBoundCopy();
|
||||
speedMultiplier = point.SpeedMultiplierBindable.GetBoundCopy();
|
||||
|
||||
Y = Height;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y;
|
||||
AutoSizeAxes = Axes.X;
|
||||
|
||||
Color4 colour = difficultyPoint.GetRepresentingColour(colours);
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = colour,
|
||||
Width = 2,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
},
|
||||
new Container
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = colour,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
speedMultiplierText = new OsuSpriteText
|
||||
{
|
||||
Font = OsuFont.Default.With(weight: FontWeight.Bold),
|
||||
Colour = Color4.White,
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
speedMultiplier.BindValueChanged(multiplier => speedMultiplierText.Text = $"{multiplier.NewValue:n2}x", true);
|
||||
base.LoadComplete();
|
||||
speedMultiplier.BindValueChanged(multiplier => Label.Text = $"{multiplier.NewValue:n2}x", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,58 +3,27 @@
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
{
|
||||
public class TimingPointPiece : CompositeDrawable
|
||||
public class TimingPointPiece : TopPointPiece
|
||||
{
|
||||
private readonly TimingControlPoint point;
|
||||
|
||||
private readonly BindableNumber<double> beatLength;
|
||||
private OsuSpriteText bpmText;
|
||||
|
||||
public TimingPointPiece(TimingControlPoint point)
|
||||
: base(point)
|
||||
{
|
||||
this.point = point;
|
||||
beatLength = point.BeatLengthBindable.GetBoundCopy();
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
Margin = new MarginPadding { Vertical = 10 };
|
||||
|
||||
const float corner_radius = 5;
|
||||
|
||||
AutoSizeAxes = Axes.Both;
|
||||
Masking = true;
|
||||
CornerRadius = corner_radius;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = point.GetRepresentingColour(colours),
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
bpmText = new OsuSpriteText
|
||||
{
|
||||
Alpha = 0.9f,
|
||||
Padding = new MarginPadding { Vertical = 3, Horizontal = 6 },
|
||||
Font = OsuFont.Default.With(size: 20, weight: FontWeight.SemiBold),
|
||||
Colour = colours.B5,
|
||||
}
|
||||
};
|
||||
|
||||
beatLength.BindValueChanged(beatLength =>
|
||||
{
|
||||
bpmText.Text = $"{60000 / beatLength.NewValue:n1} BPM";
|
||||
Label.Text = $"{60000 / beatLength.NewValue:n1} BPM";
|
||||
}, true);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,55 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
{
|
||||
public class TopPointPiece : CompositeDrawable
|
||||
{
|
||||
private readonly ControlPoint point;
|
||||
|
||||
protected OsuSpriteText Label { get; private set; }
|
||||
|
||||
public TopPointPiece(ControlPoint point)
|
||||
{
|
||||
this.point = point;
|
||||
AutoSizeAxes = Axes.X;
|
||||
Height = 16;
|
||||
Margin = new MarginPadding(4);
|
||||
|
||||
Masking = true;
|
||||
CornerRadius = Height / 2;
|
||||
|
||||
Origin = Anchor.TopCentre;
|
||||
Anchor = Anchor.TopCentre;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = point.GetRepresentingColour(colours),
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
Label = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Padding = new MarginPadding(3),
|
||||
Font = OsuFont.Default.With(size: 14, weight: FontWeight.SemiBold),
|
||||
Colour = colours.B5,
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user