1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 19:22:54 +08:00

Rewrite CirclePiece to be referenced to 128x128px and handle accented hits more sanely.

This commit is contained in:
smoogipooo 2017-03-24 18:37:56 +09:00
parent 47065d8031
commit 5281842965
12 changed files with 221 additions and 323 deletions

@ -1 +1 @@
Subproject commit 00406e13d1b15683b3565a126e207b08bca7555f
Subproject commit 4bb8dca669c87c5acdd18e55a33f1ea5f566bb9c

View File

@ -2,7 +2,11 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Graphics.Containers;
using osu.Framework.Screens.Testing;
using osu.Game.Graphics;
using osu.Game.Modes.Taiko.Objects.Drawable.Pieces;
namespace osu.Desktop.VisualTests.Tests
@ -11,53 +15,151 @@ namespace osu.Desktop.VisualTests.Tests
{
public override string Description => "Taiko hit objects";
private bool kiai;
public override void Reset()
{
base.Reset();
Add(new CentreHitCirclePiece
AddToggle("Kiai", b =>
{
kiai = !kiai;
Reset();
});
Add(new CentreHitCircle(new CirclePiece(@"centre")
{
KiaiMode = kiai
})
{
Position = new Vector2(100, 100)
});
Add(new FinisherPiece(new CentreHitCirclePiece())
Add(new CentreHitCircle(new AccentedCirclePiece(@"centre")
{
KiaiMode = kiai
})
{
Position = new Vector2(350, 100)
});
Add(new RimHitCirclePiece
Add(new RimHitCircle(new CirclePiece(@"rim")
{
KiaiMode = kiai
})
{
Position = new Vector2(100, 300)
});
Add(new FinisherPiece(new RimHitCirclePiece())
Add(new RimHitCircle(new AccentedCirclePiece(@"rim")
{
KiaiMode = kiai
})
{
Position = new Vector2(350, 300)
});
Add(new BashCirclePiece
Add(new SwellCircle(new CirclePiece(@"swell")
{
KiaiMode = kiai
})
{
Position = new Vector2(100, 500)
});
Add(new FinisherPiece(new BashCirclePiece())
Add(new SwellCircle(new AccentedCirclePiece(@"swell")
{
KiaiMode = kiai
})
{
Position = new Vector2(350, 500)
});
Add(new DrumRollCirclePiece
Add(new DrumRollCircle(new CirclePiece(string.Empty)
{
Width = 250,
KiaiMode = kiai
})
{
Position = new Vector2(575, 100)
});
Add(new FinisherPiece(new DrumRollCirclePiece()
Add(new DrumRollCircle(new AccentedCirclePiece(string.Empty)
{
Width = 250
Width = 250,
KiaiMode = kiai
})
{
Position = new Vector2(575, 300)
});
}
private class SwellCircle : BaseCircle
{
public SwellCircle(CirclePiece piece)
: base(piece)
{
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Piece.AccentColour = colours.YellowDark;
}
}
private class DrumRollCircle : BaseCircle
{
public DrumRollCircle(CirclePiece piece)
: base(piece)
{
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Piece.AccentColour = colours.YellowDark;
}
}
private class CentreHitCircle : BaseCircle
{
public CentreHitCircle(CirclePiece piece)
: base(piece)
{
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Piece.AccentColour = colours.PinkDarker;
}
}
private class RimHitCircle : BaseCircle
{
public RimHitCircle(CirclePiece piece)
: base(piece)
{
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Piece.AccentColour = colours.BlueDarker;
}
}
private abstract class BaseCircle : Container
{
protected readonly CirclePiece Piece;
protected BaseCircle(CirclePiece piece)
{
Piece = piece;
Add(Piece);
}
}
}
}

View File

@ -49,6 +49,6 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable
UpdateScrollPosition(Time.Current);
}
protected abstract ScrollingPiece CreateCircle();
protected abstract CirclePiece CreateCircle();
}
}

View File

@ -0,0 +1,14 @@
using OpenTK;
namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces
{
public class AccentedCirclePiece : CirclePiece
{
public AccentedCirclePiece(string symbolName)
: base(symbolName)
{
}
public override Vector2 Size => new Vector2(base.Size.X, base.Size.Y * 1.5f);
}
}

View File

@ -1,36 +0,0 @@
// 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 osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Game.Graphics;
namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces
{
/// <summary>
/// A circle piece which is used to visualise Bash objects.
/// </summary>
public class BashCirclePiece : CirclePiece
{
private Sprite icon;
protected override Framework.Graphics.Drawable CreateIcon()
{
return icon ?? (icon = new Sprite
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
});
}
[BackgroundDependencyLoader]
private void load(OsuColour colours, TextureStore textures)
{
AccentColour = colours.YellowDark;
icon.Texture = textures.Get(@"Play/Taiko/bash-hit-inner");
}
}
}

View File

@ -1,42 +0,0 @@
// 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 osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using OpenTK;
namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces
{
/// <summary>
/// A circle piece which is used to visualise CentreHit objects.
/// </summary>
public class CentreHitCirclePiece : CirclePiece
{
protected override Framework.Graphics.Drawable CreateIcon()
{
return new CircularContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(45f),
Masking = true,
Children = new[]
{
new Box
{
RelativeSizeAxes = Axes.Both
}
}
};
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
AccentColour = colours.PinkDarker;
}
}
}

View File

@ -8,6 +8,9 @@ using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics.Backgrounds;
using OpenTK.Graphics;
using OpenTK;
using osu.Framework.Graphics.Textures;
using osu.Framework.Allocation;
using System;
namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces
{
@ -18,15 +21,30 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces
/// a regular "circle" is the result of setting Width to 0.
/// </para>
/// <para>
/// Hitobjects that have a length need only to set Width and the extra corner radius will be added internally.
/// Hitobjects that have a length (e.g. DrumRolls) need only to set Width and the extra corner radius will be added internally.
/// </para>
/// </summary>
public abstract class CirclePiece : ScrollingPiece
public class CirclePiece : Container
{
private Color4 accentColour;
/// <summary>
/// The colour of the inner circle and outer glows.
/// </summary>
public Color4 AccentColour { get; protected set; }
public Color4 AccentColour
{
get { return accentColour; }
set
{
accentColour = value;
innerBackground.Colour = AccentColour;
triangles.ColourLight = AccentColour;
triangles.ColourDark = AccentColour.Darken(0.1f);
resetEdgeEffects();
}
}
private bool kiaiMode;
/// <summary>
@ -39,129 +57,99 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces
{
kiaiMode = value;
if (innerCircleContainer != null)
innerCircleContainer.EdgeEffect = value ? createKiaiEdgeEffect() : default(EdgeEffect);
resetEdgeEffects();
}
}
public override Anchor Origin
{
get { return Anchor.CentreLeft; }
set { throw new InvalidOperationException($"{nameof(CirclePiece)} must always use CentreLeft origin."); }
}
public override Vector2 Size => new Vector2(base.Size.X, TaikoHitObject.CIRCLE_RADIUS * 2);
private readonly Container innerLayer;
private readonly Container backingGlowContainer;
private readonly Container innerCircleContainer;
private readonly Box innerBackground;
private readonly Triangles triangles;
private readonly Sprite symbol;
protected CirclePiece()
private readonly string symbolName;
public CirclePiece(string symbolName)
{
Container iconContainer;
this.symbolName = symbolName;
Children = new Framework.Graphics.Drawable[]
// The "inner layer" overshoots the the CirclePiece by Height/2 px on both sides
AddInternal(innerLayer = new Container
{
// The "inner layer" overshoots the ObjectPiece by 64px on both sides
innerLayer = new Container
Name = "Inner Layer",
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Y,
Children = new Framework.Graphics.Drawable[]
{
Name = "Inner Layer",
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Y,
Children = new Framework.Graphics.Drawable[]
innerCircleContainer = new CircularContainer
{
backingGlowContainer = new CircularContainer
Name = "Inner Circle",
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Masking = true,
Children = new Framework.Graphics.Drawable[]
{
Name = "Backing Glow",
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Masking = true,
Children = new[]
innerBackground = new Box
{
new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
AlwaysPresent = true
}
}
},
innerCircleContainer = new CircularContainer
{
Name = "Inner Circle",
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Masking = true,
Children = new Framework.Graphics.Drawable[]
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
},
triangles = new Triangles
{
innerBackground = new Box
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
},
triangles = new Triangles
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
}
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
}
},
new CircularContainer
{
Name = "Ring",
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
BorderThickness = 8,
BorderColour = Color4.White,
Masking = true,
Children = new[]
{
new Box
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Alpha = 0,
AlwaysPresent = true
}
}
},
iconContainer = new Container
{
Name = "Icon Container",
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
}
},
new CircularContainer
{
Name = "Ring",
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
BorderThickness = 8,
BorderColour = Color4.White,
Masking = true,
Children = new[]
{
new Box
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Alpha = 0,
AlwaysPresent = true
}
}
},
symbol = new Sprite
{
Name = "Symbol",
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both
}
},
};
Framework.Graphics.Drawable icon = CreateIcon();
if (icon != null)
iconContainer.Add(icon);
}
});
}
protected override void LoadComplete()
[BackgroundDependencyLoader]
private void load(TextureStore textures)
{
base.LoadComplete();
backingGlowContainer.EdgeEffect = new EdgeEffect
{
Type = EdgeEffectType.Glow,
Colour = AccentColour,
Radius = 8
};
if (KiaiMode)
innerCircleContainer.EdgeEffect = createKiaiEdgeEffect();
innerBackground.Colour = AccentColour;
triangles.ColourLight = AccentColour;
triangles.ColourDark = AccentColour.Darken(0.1f);
if (!string.IsNullOrEmpty(symbolName))
symbol.Texture = textures.Get($@"Play/Taiko/{symbolName}-symbol");
}
protected override void Update()
@ -169,20 +157,14 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces
innerLayer.Width = DrawWidth + DrawHeight;
}
private EdgeEffect createKiaiEdgeEffect()
private void resetEdgeEffects()
{
return new EdgeEffect
innerCircleContainer.EdgeEffect = new EdgeEffect
{
Type = EdgeEffectType.Glow,
Colour = AccentColour,
Radius = 50
Radius = KiaiMode ? 50 : 8
};
}
/// <summary>
/// Creates the icon that's shown in the middle of this object piece.
/// </summary>
/// <returns>The icon.</returns>
protected virtual Framework.Graphics.Drawable CreateIcon() => null;
}
}

View File

@ -1,20 +0,0 @@
// 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 osu.Game.Graphics;
namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces
{
/// <summary>
/// A circle piece which is used to visualise DrumRoll objects.
/// </summary>
public class DrumRollCirclePiece : CirclePiece
{
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
AccentColour = colours.YellowDark;
}
}
}

View File

@ -1,31 +0,0 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK;
namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces
{
/// <summary>
/// A type of circle piece that encapsulates a circle piece to visualise it as a "finisher" hitobject.
/// <para>
/// Finisher hitobjects are 1.5x larger, while maintaining the same length.
/// </para>
/// </summary>
public class FinisherPiece : ScrollingPiece
{
public FinisherPiece(ScrollingPiece original)
{
// First we scale the note up
Scale = new Vector2(1.5f);
Children = new[]
{
original
};
// Next we reduce the draw width for drum rolls to keep the width
// equal to that of a non-finisher drum roll
original.Width /= 1.5f;
}
}
}

View File

@ -1,47 +0,0 @@
// 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 osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using OpenTK;
using OpenTK.Graphics;
namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces
{
/// <summary>
/// A circle piece which is used to visualise RimHit objects.
/// </summary>
public class RimHitCirclePiece : CirclePiece
{
protected override Framework.Graphics.Drawable CreateIcon()
{
return new CircularContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(61f),
BorderThickness = 8,
BorderColour = Color4.White,
Masking = true,
Children = new[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
AlwaysPresent = true
}
}
};
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
AccentColour = colours.BlueDarker;
}
}
}

View File

@ -1,19 +0,0 @@
// 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;
using osu.Framework.Graphics.Containers;
namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces
{
/// <summary>
/// A type of circle piece that will be scrolling the screen.
/// <para>
/// A scrolling circle piece must always have a centre-left origin due to how scroll position is calculated.
/// </para>
/// </summary>
public class ScrollingPiece : Container
{
public override Anchor Origin => Anchor.CentreLeft;
}
}

View File

@ -54,16 +54,11 @@
<Compile Include="Judgements\TaikoHitResult.cs" />
<Compile Include="Objects\Drawable\DrawableTaikoHitObject.cs" />
<Compile Include="Objects\Bash.cs" />
<Compile Include="Objects\Drawable\Pieces\AccentedCirclePiece.cs" />
<Compile Include="Objects\DrumRoll.cs" />
<Compile Include="Objects\DrumRollTick.cs" />
<Compile Include="Objects\Hit.cs" />
<Compile Include="Objects\Drawable\Pieces\BashCirclePiece.cs" />
<Compile Include="Objects\Drawable\Pieces\CentreHitCirclePiece.cs" />
<Compile Include="Objects\Drawable\Pieces\CirclePiece.cs" />
<Compile Include="Objects\Drawable\Pieces\DrumRollCirclePiece.cs" />
<Compile Include="Objects\Drawable\Pieces\FinisherPiece.cs" />
<Compile Include="Objects\Drawable\Pieces\RimHitCirclePiece.cs" />
<Compile Include="Objects\Drawable\Pieces\ScrollingPiece.cs" />
<Compile Include="TaikoDifficultyCalculator.cs" />
<Compile Include="Objects\TaikoHitObject.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />