1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 16:07:25 +08:00

Use AccentColour everywhere in drawable osu! hit objects.

This commit is contained in:
smoogipooo 2017-03-23 15:37:16 +09:00
parent 16787a6ac2
commit 2c76a2350c
9 changed files with 70 additions and 38 deletions

View File

@ -44,11 +44,8 @@ namespace osu.Game.Modes.Osu.Beatmaps
{
StartTime = original.StartTime,
Sample = original.Sample,
CurveObject = curveData,
Position = positionData?.Position ?? Vector2.Zero,
NewCombo = comboData?.NewCombo ?? false
};
}
@ -60,7 +57,6 @@ namespace osu.Game.Modes.Osu.Beatmaps
StartTime = original.StartTime,
Sample = original.Sample,
Position = new Vector2(512, 384) / 2,
EndTime = endTimeData.EndTime
};
}
@ -69,9 +65,7 @@ namespace osu.Game.Modes.Osu.Beatmaps
{
StartTime = original.StartTime,
Sample = original.Sample,
Position = positionData?.Position ?? Vector2.Zero,
NewCombo = comboData?.NewCombo ?? false
};
}

View File

@ -13,8 +13,6 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
{
public class DrawableHitCircle : DrawableOsuHitObject, IDrawableHitObjectWithProxiedApproach
{
private readonly OsuHitObject osuObject;
public ApproachCircle ApproachCircle;
private readonly CirclePiece circle;
private readonly RingPiece ring;
@ -27,20 +25,18 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
{
Origin = Anchor.Centre;
osuObject = h;
Position = osuObject.StackedPosition;
Scale = new Vector2(osuObject.Scale);
Position = HitObject.StackedPosition;
Scale = new Vector2(HitObject.Scale);
Children = new Drawable[]
{
glow = new GlowPiece
{
Colour = osuObject.ComboColour
Colour = AccentColour
},
circle = new CirclePiece
{
Colour = osuObject.ComboColour,
Colour = AccentColour,
Hit = () =>
{
if (Judgement.Result.HasValue) return false;
@ -58,11 +54,11 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
flash = new FlashPiece(),
explode = new ExplodePiece
{
Colour = osuObject.ComboColour,
Colour = AccentColour,
},
ApproachCircle = new ApproachCircle
{
Colour = osuObject.ComboColour,
Colour = AccentColour,
}
};
@ -115,8 +111,8 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
ApproachCircle.FadeOut();
double endTime = (osuObject as IHasEndTime)?.EndTime ?? osuObject.StartTime;
double duration = endTime - osuObject.StartTime;
double endTime = (HitObject as IHasEndTime)?.EndTime ?? HitObject.StartTime;
double duration = endTime - HitObject.StartTime;
glow.Delay(duration);
glow.FadeOut(400);

View File

@ -13,9 +13,10 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
public const float TIME_FADEIN = 400;
public const float TIME_FADEOUT = 500;
public DrawableOsuHitObject(OsuHitObject hitObject)
protected DrawableOsuHitObject(OsuHitObject hitObject)
: base(hitObject)
{
AccentColour = HitObject.ComboColour;
}
protected override OsuJudgementInfo CreateJudgementInfo() => new OsuJudgementInfo { MaxScore = OsuScoreResult.Hit300 };

View File

@ -56,6 +56,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
ball = new SliderBall(s)
{
Scale = new Vector2(s.Scale),
AccentColour = AccentColour
},
initialCircle = new DrawableHitCircle(new HitCircle
{

View File

@ -48,7 +48,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = sliderTick.ComboColour,
Colour = AccentColour,
Alpha = 0.3f,
}
};

View File

@ -48,7 +48,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
Alpha = 0,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
DiscColour = s.ComboColour
DiscColour = AccentColour
},
circleContainer = new Container
{

View File

@ -12,10 +12,26 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
{
public class SliderBall : CircularContainer, ISliderProgress
{
private const float width = 128;
private Color4 accentColour = Color4.Black;
/// <summary>
/// The colour that is used for the slider ball.
/// </summary>
public Color4 AccentColour
{
get { return accentColour; }
set
{
accentColour = value;
if (ball != null)
ball.Colour = value;
}
}
private readonly Slider slider;
private readonly Box follow;
private const float width = 128;
private readonly Box ball;
public SliderBall(Slider slider)
{
@ -49,9 +65,9 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
Alpha = 1,
Children = new[]
{
new Box
ball = new Box
{
Colour = slider.ComboColour,
Colour = AccentColour,
Alpha = 0.4f,
Width = width,
Height = width,

View File

@ -13,6 +13,7 @@ using osu.Framework.Graphics.Textures;
using osu.Game.Configuration;
using OpenTK;
using OpenTK.Graphics.ES30;
using OpenTK.Graphics;
namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
{
@ -24,15 +25,31 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
public float PathWidth
{
get { return path.PathWidth; }
set
{
path.PathWidth = value;
}
set { path.PathWidth = value; }
}
public double? SnakedStart { get; private set; }
public double? SnakedEnd { get; private set; }
private Color4 accentColour;
/// <summary>
/// Used to colour the path.
/// </summary>
public Color4 AccentColour
{
get { return accentColour; }
set
{
if (accentColour == value)
return;
accentColour = value;
reloadTexture();
}
}
private int textureWidth => (int)PathWidth * 2;
private readonly Slider slider;
public SliderBody(Slider s)
{
@ -82,7 +99,15 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
snakingIn = config.GetBindable<bool>(OsuConfig.SnakingInSliders);
snakingOut = config.GetBindable<bool>(OsuConfig.SnakingOutSliders);
int textureWidth = (int)PathWidth * 2;
path.Texture = new Texture(textureWidth, 1);
reloadTexture();
}
private void reloadTexture()
{
if (path.Texture == null)
return;
//initialise background
var upload = new TextureUpload(textureWidth * 4);
@ -110,16 +135,15 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
{
progress -= border_portion;
bytes[i * 4] = (byte)(slider.ComboColour.R * 255);
bytes[i * 4 + 1] = (byte)(slider.ComboColour.G * 255);
bytes[i * 4 + 2] = (byte)(slider.ComboColour.B * 255);
bytes[i * 4 + 3] = (byte)((opacity_at_edge - (opacity_at_edge - opacity_at_centre) * progress / gradient_portion) * (slider.ComboColour.A * 255));
bytes[i * 4] = (byte)(AccentColour.R * 255);
bytes[i * 4 + 1] = (byte)(AccentColour.G * 255);
bytes[i * 4 + 2] = (byte)(AccentColour.B * 255);
bytes[i * 4 + 3] = (byte)((opacity_at_edge - (opacity_at_edge - opacity_at_centre) * progress / gradient_portion) * (AccentColour.A * 255));
}
}
var texture = new Texture(textureWidth, 1);
texture.SetData(upload);
path.Texture = texture;
path.Texture.SetData(upload);
path.Invalidate(Invalidation.DrawNode, this);
}
private readonly List<Vector2> currentCurve = new List<Vector2>();

View File

@ -36,7 +36,7 @@ namespace osu.Game.Modes.Osu.Objects
public float Scale { get; set; } = 1;
public Color4 ComboColour { get; set; }
public Color4 ComboColour { get; set; } = Color4.Black;
public virtual bool NewCombo { get; set; }
public int ComboIndex { get; set; }