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> /// </summary>
private int rollingHits; private int rollingHits;
private Container<DrawableDrumRollTick> tickContainer; private Container tickContainer;
private Color4 colourIdle; private Color4 colourIdle;
private Color4 colourEngaged; private Color4 colourEngaged;
@ -49,7 +49,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
updateColour(); 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) if (MainPiece.Drawable is IHasAccentColour accentMain)
accentMain.AccentColour = colourIdle; accentMain.AccentColour = colourIdle;
@ -139,6 +139,12 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
protected override DrawableStrongNestedHit CreateStrongHit(StrongHitObject hitObject) => new StrongNestedHit(hitObject, this); 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 private class StrongNestedHit : DrawableStrongNestedHit
{ {
public StrongNestedHit(StrongHitObject strong, DrawableDrumRoll drumRoll) public StrongNestedHit(StrongHitObject strong, DrawableDrumRoll drumRoll)
@ -156,11 +162,5 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
public override bool OnPressed(TaikoAction action) => false; 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. // 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. // See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Graphics;
namespace osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces namespace osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces
{ {
@ -12,18 +14,15 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces
RelativeSizeAxes = Axes.Y; RelativeSizeAxes = Axes.Y;
} }
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
AccentColour = colours.YellowDark;
}
protected override void Update() protected override void Update()
{ {
base.Update(); base.Update();
var padding = Content.DrawHeight * Content.Width / 2;
Content.Padding = new MarginPadding
{
Left = padding,
Right = padding,
};
Width = Parent.DrawSize.X + DrawHeight; Width = Parent.DrawSize.X + DrawHeight;
} }
} }

View File

@ -11,12 +11,8 @@ using osuTK.Graphics;
namespace osu.Game.Rulesets.Taiko.Skinning 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 LegacyCirclePiece headCircle;
private Sprite body; private Sprite body;
@ -25,31 +21,14 @@ namespace osu.Game.Rulesets.Taiko.Skinning
public LegacyDrumRoll() public LegacyDrumRoll()
{ {
RelativeSizeAxes = Axes.Y; RelativeSizeAxes = Axes.Both;
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(ISkinSource skin) private void load(ISkinSource skin, OsuColour colours)
{ {
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
content = new Container
{
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 end = new Sprite
{ {
Anchor = Anchor.CentreRight, Anchor = Anchor.CentreRight,
@ -58,9 +37,18 @@ namespace osu.Game.Rulesets.Taiko.Skinning
Texture = skin.GetTexture("taiko-roll-end"), Texture = skin.GetTexture("taiko-roll-end"),
FillMode = FillMode.Fit, FillMode = FillMode.Fit,
}, },
body = new Sprite
{
RelativeSizeAxes = Axes.Both,
Texture = skin.GetTexture("taiko-roll-middle"),
}, },
headCircle = new LegacyCirclePiece
{
RelativeSizeAxes = Axes.Y,
}, },
}; };
AccentColour = colours.YellowDark;
} }
protected override void LoadComplete() protected override void LoadComplete()
@ -69,21 +57,6 @@ namespace osu.Game.Rulesets.Taiko.Skinning
updateAccentColour(); 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; private Color4 accentColour;
public Color4 AccentColour public Color4 AccentColour