1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-26 16:12:54 +08:00

make menu flashes and visualisation colourable by skin

This commit is contained in:
LeNitrous 2019-03-31 20:10:44 +08:00
parent 1d4c9436eb
commit 698e38c4e0
2 changed files with 58 additions and 10 deletions

View File

@ -12,6 +12,9 @@ using osu.Framework.Graphics.Shaders;
using osu.Framework.Graphics.Textures;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Skinning;
using osu.Game.Online.API;
using osu.Game.Users;
using System;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
@ -66,18 +69,27 @@ namespace osu.Game.Screens.Menu
private IShader shader;
private readonly Texture texture;
private Bindable<User> user;
private Bindable<Skin> skin;
public LogoVisualisation()
{
texture = Texture.WhitePixel;
AccentColour = new Color4(1, 1, 1, 0.2f);
Blending = BlendingMode.Additive;
}
[BackgroundDependencyLoader]
private void load(ShaderManager shaders, IBindable<WorkingBeatmap> beatmap)
private void load(ShaderManager shaders, IBindable<WorkingBeatmap> beatmap, IAPIProvider api, SkinManager skinManager)
{
this.beatmap.BindTo(beatmap);
shader = shaders.Load(VertexShaderDescriptor.TEXTURE_2, FragmentShaderDescriptor.TEXTURE_ROUNDED);
user = api.LocalUser.GetBoundCopy();
skin = skinManager.CurrentSkin.GetBoundCopy();
user.ValueChanged += _ => changeColour();
skin.ValueChanged += _ => changeColour();
changeColour();
}
private void updateAmplitudes()
@ -107,6 +119,14 @@ namespace osu.Game.Screens.Menu
Scheduler.AddDelayed(updateAmplitudes, time_between_updates);
}
private void changeColour()
{
if (user.Value?.IsSupporter ?? false)
AccentColour = skin.Value.GetValue<SkinConfiguration, Color4?>(s => s.CustomColours.ContainsKey("MenuGlow") ? s.CustomColours["MenuGlow"] : (Color4?)null) ?? new Color4(1, 1, 1, 0.2f);
else
AccentColour = new Color4(1, 1, 1, 0.2f);
}
protected override void LoadComplete()
{
base.LoadComplete();

View File

@ -12,6 +12,9 @@ using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Skinning;
using osu.Game.Online.API;
using osu.Game.Users;
using System;
using osu.Framework.Bindables;
@ -32,6 +35,12 @@ namespace osu.Game.Screens.Menu
private const double box_fade_in_time = 65;
private const int box_width = 200;
private Bindable<User> user;
private Bindable<Skin> skin;
[Resolved]
private OsuColour colours { get; set; }
public MenuSideFlashes()
{
EarlyActivationMilliseconds = box_fade_in_time;
@ -42,13 +51,15 @@ namespace osu.Game.Screens.Menu
}
[BackgroundDependencyLoader]
private void load(IBindable<WorkingBeatmap> beatmap, OsuColour colours)
private void load(IBindable<WorkingBeatmap> beatmap, IAPIProvider api, SkinManager skinManager)
{
this.beatmap.BindTo(beatmap);
// linear colour looks better in this case, so let's use it for now.
Color4 gradientDark = colours.Blue.Opacity(0).ToLinear();
Color4 gradientLight = colours.Blue.Opacity(0.6f).ToLinear();
user = api.LocalUser.GetBoundCopy();
skin = skinManager.CurrentSkin.GetBoundCopy();
user.ValueChanged += _ => changeColour();
skin.ValueChanged += _ => changeColour();
Children = new Drawable[]
{
@ -62,8 +73,7 @@ namespace osu.Game.Screens.Menu
// align off-screen to make sure our edges don't become visible during parallax.
X = -box_width,
Alpha = 0,
Blending = BlendingMode.Additive,
Colour = ColourInfo.GradientHorizontal(gradientLight, gradientDark)
Blending = BlendingMode.Additive
},
rightBox = new Box
{
@ -74,10 +84,11 @@ namespace osu.Game.Screens.Menu
Height = 1.5f,
X = box_width,
Alpha = 0,
Blending = BlendingMode.Additive,
Colour = ColourInfo.GradientHorizontal(gradientDark, gradientLight)
Blending = BlendingMode.Additive
}
};
changeColour();
}
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes)
@ -97,5 +108,22 @@ namespace osu.Game.Screens.Menu
.Then()
.FadeOut(beatLength, Easing.In);
}
private void changeColour()
{
Color4 baseColour;
if (user.Value?.IsSupporter ?? false)
baseColour = skin.Value.GetValue<SkinConfiguration, Color4?>(s => s.CustomColours.ContainsKey("MenuGlow") ? s.CustomColours["MenuGlow"] : (Color4?)null) ?? colours.Blue;
else
baseColour = colours.Blue;
// linear colour looks better in this case, so let's use it for now.
Color4 gradientDark = baseColour.Opacity(0).ToLinear();
Color4 gradientLight = baseColour.Opacity(0.6f).ToLinear();
leftBox.Colour = ColourInfo.GradientHorizontal(gradientLight, gradientDark);
rightBox.Colour = ColourInfo.GradientHorizontal(gradientDark, gradientLight);
}
}
}