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

Merge branch 'master' into fix-music-controller-drag

This commit is contained in:
Dean Herbert 2018-06-15 17:08:01 +09:00 committed by GitHub
commit db9141a6cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 139 additions and 74 deletions

View File

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Overlays.Volume; using osu.Game.Overlays.Volume;
using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
namespace osu.Game.Tests.Visual namespace osu.Game.Tests.Visual
@ -17,13 +18,21 @@ namespace osu.Game.Tests.Visual
{ {
VolumeMeter meter; VolumeMeter meter;
MuteButton mute; MuteButton mute;
Add(meter = new VolumeMeter("MASTER", 125, Color4.Blue)); Add(meter = new VolumeMeter("MASTER", 125, Color4.Blue) { Position = new Vector2(10) });
AddSliderStep("master volume", 0, 10, 0, i => meter.Bindable.Value = i * 0.1);
Add(new VolumeMeter("BIG", 250, Color4.Red)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Position = new Vector2(10),
});
Add(mute = new MuteButton Add(mute = new MuteButton
{ {
Margin = new MarginPadding { Top = 200 } Margin = new MarginPadding { Top = 200 }
}); });
AddSliderStep("master volume", 0, 10, 0, i => meter.Bindable.Value = i * 0.1);
AddToggleStep("mute", b => mute.Current.Value = b); AddToggleStep("mute", b => mute.Current.Value = b);
} }
} }

View File

@ -24,6 +24,8 @@ namespace osu.Game.Overlays.Volume
public class VolumeMeter : Container, IKeyBindingHandler<GlobalAction> public class VolumeMeter : Container, IKeyBindingHandler<GlobalAction>
{ {
private CircularProgress volumeCircle; private CircularProgress volumeCircle;
private CircularProgress volumeCircleGlow;
public BindableDouble Bindable { get; } = new BindableDouble { MinValue = 0, MaxValue = 1 }; public BindableDouble Bindable { get; } = new BindableDouble { MinValue = 0, MaxValue = 1 };
private readonly float circleSize; private readonly float circleSize;
private readonly Color4 meterColour; private readonly Color4 meterColour;
@ -44,90 +46,143 @@ namespace osu.Game.Overlays.Volume
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
Add(new Container Color4 backgroundColour = colours.Gray1;
{
Size = new Vector2(120, 20),
CornerRadius = 10,
Masking = true,
Margin = new MarginPadding { Left = circleSize + 10 },
Origin = Anchor.CentreLeft,
Anchor = Anchor.CentreLeft,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = colours.Gray1,
Alpha = 0.9f,
},
new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Font = "Exo2.0-Bold",
Text = name
}
}
});
CircularProgress bgProgress; CircularProgress bgProgress;
Add(new CircularContainer const float progress_start_radius = 0.75f;
const float progress_size = 0.03f;
const float progress_end_radius = progress_start_radius + progress_size;
const float blur_amount = 5;
Children = new Drawable[]
{ {
Masking = true, new Container
Size = new Vector2(circleSize),
Children = new Drawable[]
{ {
new Box Size = new Vector2(circleSize),
Children = new Drawable[]
{ {
RelativeSizeAxes = Axes.Both, new BufferedContainer
Colour = colours.Gray1,
Alpha = 0.9f,
},
bgProgress = new CircularProgress
{
RelativeSizeAxes = Axes.Both,
InnerRadius = 0.05f,
Rotation = 180,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Colour = colours.Gray2,
Size = new Vector2(0.8f)
},
new Container
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Size = new Vector2(0.8f),
Padding = new MarginPadding(-Blur.KernelSize(5)),
Rotation = 180,
Child = (volumeCircle = new CircularProgress
{ {
Alpha = 0.9f,
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
InnerRadius = 0.05f, Children = new Drawable[]
{
new Circle
{
RelativeSizeAxes = Axes.Both,
Colour = backgroundColour,
},
new CircularContainer
{
Masking = true,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Size = new Vector2(progress_end_radius),
Children = new Drawable[]
{
bgProgress = new CircularProgress
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Rotation = 180,
Colour = backgroundColour,
},
new Container
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Name = "Progress under covers for smoothing",
RelativeSizeAxes = Axes.Both,
Rotation = 180,
Child = volumeCircle = new CircularProgress
{
RelativeSizeAxes = Axes.Both,
}
},
}
},
new Circle
{
Name = "Inner Cover",
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Colour = backgroundColour,
Size = new Vector2(progress_start_radius),
},
new Container
{
Name = "Progress overlay for glow",
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Size = new Vector2(progress_start_radius + progress_size / 1.5f),
Rotation = 180,
Padding = new MarginPadding(-Blur.KernelSize(blur_amount)),
Child = (volumeCircleGlow = new CircularProgress
{
RelativeSizeAxes = Axes.Both,
InnerRadius = progress_size * 0.8f,
}).WithEffect(new GlowEffect
{
Colour = meterColour,
BlurSigma = new Vector2(blur_amount),
Strength = 5,
PadExtent = true
}),
},
},
},
maxGlow = (text = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Font = "Venera",
TextSize = 0.16f * circleSize
}).WithEffect(new GlowEffect }).WithEffect(new GlowEffect
{ {
Colour = meterColour, Colour = Color4.Transparent,
Strength = 2, PadExtent = true,
PadExtent = true })
}), }
}, },
maxGlow = (text = new OsuSpriteText new Container
{
Size = new Vector2(120, 20),
CornerRadius = 10,
Masking = true,
Margin = new MarginPadding { Left = circleSize + 10 },
Origin = Anchor.CentreLeft,
Anchor = Anchor.CentreLeft,
Children = new Drawable[]
{ {
Anchor = Anchor.Centre, new Box
Origin = Anchor.Centre, {
Font = "Venera", Alpha = 0.9f,
TextSize = 0.16f * circleSize RelativeSizeAxes = Axes.Both,
}).WithEffect(new GlowEffect Colour = backgroundColour,
{ },
Colour = Color4.Transparent, new OsuSpriteText
PadExtent = true, {
}) Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Font = "Exo2.0-Bold",
Text = name
}
}
} }
}); };
Bindable.ValueChanged += newVolume =>
Bindable.ValueChanged += newVolume => { this.TransformTo("DisplayVolume", newVolume, 400, Easing.OutQuint); }; {
this.TransformTo("DisplayVolume",
newVolume,
400,
Easing.OutQuint);
};
bgProgress.Current.Value = 0.75f; bgProgress.Current.Value = 0.75f;
} }
@ -158,6 +213,7 @@ namespace osu.Game.Overlays.Volume
} }
volumeCircle.Current.Value = displayVolume * 0.75f; volumeCircle.Current.Value = displayVolume * 0.75f;
volumeCircleGlow.Current.Value = displayVolume * 0.75f;
} }
} }