1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-23 00:37:18 +08:00

Remove unnecessary container logic

This commit is contained in:
Dean Herbert 2020-04-15 18:44:12 +09:00
parent 3137417994
commit 07632cd1e5
3 changed files with 35 additions and 63 deletions

View File

@ -30,7 +30,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
/// </summary>
private int rollingHits;
private Container<DrawableDrumRollTick> tickContainer;
private Container tickContainer;
private Color4 colourIdle;
private Color4 colourEngaged;
@ -49,7 +49,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
updateColour();
((Container)MainPiece.Drawable).Add(tickContainer = new Container<DrawableDrumRollTick> { RelativeSizeAxes = Axes.Both });
Content.Add(tickContainer = new Container { RelativeSizeAxes = Axes.Both });
if (MainPiece.Drawable is IHasAccentColour accentMain)
accentMain.AccentColour = colourIdle;
@ -139,6 +139,12 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
protected override DrawableStrongNestedHit CreateStrongHit(StrongHitObject hitObject) => new StrongNestedHit(hitObject, this);
private void updateColour()
{
Color4 newColour = Interpolation.ValueAt((float)rollingHits / rolling_hits_for_engaged_colour, colourIdle, colourEngaged, 0, 1);
(MainPiece.Drawable as IHasAccentColour)?.FadeAccent(newColour, 100);
}
private class StrongNestedHit : DrawableStrongNestedHit
{
public StrongNestedHit(StrongHitObject strong, DrawableDrumRoll drumRoll)
@ -156,11 +162,5 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
public override bool OnPressed(TaikoAction action) => false;
}
private void updateColour()
{
Color4 newColour = Interpolation.ValueAt((float)rollingHits / rolling_hits_for_engaged_colour, colourIdle, colourEngaged, 0, 1);
(MainPiece.Drawable as IHasAccentColour)?.FadeAccent(newColour, 100);
}
}
}

View File

@ -1,7 +1,9 @@
// 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.Game.Graphics;
namespace osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces
{
@ -12,18 +14,15 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces
RelativeSizeAxes = Axes.Y;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
AccentColour = colours.YellowDark;
}
protected override void Update()
{
base.Update();
var padding = Content.DrawHeight * Content.Width / 2;
Content.Padding = new MarginPadding
{
Left = padding,
Right = padding,
};
Width = Parent.DrawSize.X + DrawHeight;
}
}

View File

@ -11,12 +11,8 @@ using osuTK.Graphics;
namespace osu.Game.Rulesets.Taiko.Skinning
{
public class LegacyDrumRoll : Container, IHasAccentColour
public class LegacyDrumRoll : CompositeDrawable, IHasAccentColour
{
protected override Container<Drawable> Content => content;
private Container content;
private LegacyCirclePiece headCircle;
private Sprite body;
@ -25,42 +21,34 @@ namespace osu.Game.Rulesets.Taiko.Skinning
public LegacyDrumRoll()
{
RelativeSizeAxes = Axes.Y;
RelativeSizeAxes = Axes.Both;
}
[BackgroundDependencyLoader]
private void load(ISkinSource skin)
private void load(ISkinSource skin, OsuColour colours)
{
InternalChildren = new Drawable[]
{
content = new Container
end = new Sprite
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreLeft,
RelativeSizeAxes = Axes.Both,
Texture = skin.GetTexture("taiko-roll-end"),
FillMode = FillMode.Fit,
},
body = new Sprite
{
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
headCircle = new LegacyCirclePiece
{
Depth = float.MinValue,
RelativeSizeAxes = Axes.Y,
Anchor = Anchor.TopLeft,
Origin = Anchor.TopLeft,
},
body = new Sprite
{
RelativeSizeAxes = Axes.Both,
Texture = skin.GetTexture("taiko-roll-middle"),
},
end = new Sprite
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreLeft,
RelativeSizeAxes = Axes.Both,
Texture = skin.GetTexture("taiko-roll-end"),
FillMode = FillMode.Fit,
},
},
Texture = skin.GetTexture("taiko-roll-middle"),
},
headCircle = new LegacyCirclePiece
{
RelativeSizeAxes = Axes.Y,
},
};
AccentColour = colours.YellowDark;
}
protected override void LoadComplete()
@ -69,21 +57,6 @@ namespace osu.Game.Rulesets.Taiko.Skinning
updateAccentColour();
}
protected override void Update()
{
base.Update();
var padding = Content.DrawHeight * Content.Width / 2;
Content.Padding = new MarginPadding
{
Left = padding,
Right = padding,
};
Width = Parent.DrawSize.X + DrawHeight;
}
private Color4 accentColour;
public Color4 AccentColour