1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 02:42:54 +08:00

Use OsuColour instead of static colours

This commit is contained in:
DrabWeb 2017-03-24 00:41:14 -03:00
parent f1f6f2041f
commit 0edee04200
3 changed files with 36 additions and 13 deletions

View File

@ -8,6 +8,8 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Transforms; using osu.Framework.Graphics.Transforms;
using System; using System;
using osu.Game.Graphics;
using osu.Framework.Allocation;
namespace osu.Game.Screens.Play namespace osu.Game.Screens.Play
{ {
@ -15,11 +17,10 @@ namespace osu.Game.Screens.Play
{ {
private const int progress_height = 5; private const int progress_height = 5;
private readonly Vector2 handleSize = new Vector2(14, 25); private readonly Vector2 handleSize = new Vector2(14, 25);
private readonly Color4 fillColour = new Color4(221, 255, 255, 255);
private const float transition_duration = 200; private const float transition_duration = 200;
private readonly SongProgressBar bar; private SongProgressBar bar;
private readonly SongProgressGraph graph; private SongProgressGraph graph;
public Action<double> OnSeek; public Action<double> OnSeek;
@ -51,6 +52,12 @@ namespace osu.Game.Screens.Play
set { graph.Values = value; } set { graph.Values = value; }
} }
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
graph.FillColour = bar.FillColour = colours.BlueLighter;
}
public SongProgress() public SongProgress()
{ {
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
@ -64,12 +71,9 @@ namespace osu.Game.Screens.Play
Origin = Anchor.BottomLeft, Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,
Height = SongProgressGraph.Column.HEIGHT, Height = SongProgressGraph.Column.HEIGHT,
Margin = new MarginPadding Margin = new MarginPadding { Bottom = progress_height },
{
Bottom = progress_height,
},
}, },
bar = new SongProgressBar(progress_height, SongProgressGraph.Column.HEIGHT, handleSize, fillColour) bar = new SongProgressBar(progress_height, SongProgressGraph.Column.HEIGHT, handleSize)
{ {
Origin = Anchor.BottomLeft, Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,

View File

@ -12,9 +12,14 @@ namespace osu.Game.Screens.Play
{ {
public class SongProgressBar : DragBar public class SongProgressBar : DragBar
{ {
public SongProgressBar(float barHeight, float handleBarHeight, Vector2 handleSize, Color4 fillColour) public Color4 FillColour
{
get { return Fill.Colour; }
set { Fill.Colour = value; }
}
public SongProgressBar(float barHeight, float handleBarHeight, Vector2 handleSize)
{ {
Fill.Colour = fillColour;
Height = barHeight + handleBarHeight + handleSize.Y; Height = barHeight + handleBarHeight + handleSize.Y;
FillContainer.RelativeSizeAxes = Axes.X; FillContainer.RelativeSizeAxes = Axes.X;
FillContainer.Height = barHeight; FillContainer.Height = barHeight;

View File

@ -47,6 +47,19 @@ namespace osu.Game.Screens.Play
} }
} }
private Color4 fillColour;
public Color4 FillColour
{
get { return fillColour; }
set
{
if (value == fillColour) return;
fillColour = value;
redrawFilled();
}
}
public SongProgressGraph() public SongProgressGraph()
{ {
CacheDrawnFrameBuffer = true; CacheDrawnFrameBuffer = true;
@ -121,7 +134,7 @@ namespace osu.Game.Screens.Play
for (float x = 0; x < DrawWidth; x += Column.WIDTH) for (float x = 0; x < DrawWidth; x += Column.WIDTH)
{ {
newColumns.Add(new Column newColumns.Add(new Column(fillColour)
{ {
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft, Origin = Anchor.BottomLeft,
@ -141,7 +154,7 @@ namespace osu.Game.Screens.Play
public class Column : Container, IStateful<ColumnState> public class Column : Container, IStateful<ColumnState>
{ {
private readonly Color4 emptyColour = Color4.White.Opacity(100); private readonly Color4 emptyColour = Color4.White.Opacity(100);
private readonly Color4 litColour = new Color4(221, 255, 255, 255); private readonly Color4 litColour;
private readonly Color4 dimmedColour = Color4.White.Opacity(175); private readonly Color4 dimmedColour = Color4.White.Opacity(175);
private const float cube_count = 6; private const float cube_count = 6;
@ -178,9 +191,10 @@ namespace osu.Game.Screens.Play
} }
} }
public Column() public Column(Color4 litColour)
{ {
Size = new Vector2(WIDTH, HEIGHT); Size = new Vector2(WIDTH, HEIGHT);
this.litColour = litColour;
for (int r = 0; r < cube_count; r++) for (int r = 0; r < cube_count; r++)
{ {