Merge remote-tracking branch 'origin/master' into fix-new-inspections

# Conflicts:
#	osu.Game.Rulesets.Catch/Judgements/CatchDropletJudgement.cs
#	osu.Game.Rulesets.Catch/Judgements/CatchJudgement.cs
#	osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs
#	osu.Game.Rulesets.Osu/Replays/OsuAutoGenerator.cs
#	osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs
#	osu.Game.Tests/Visual/SongSelect/TestCaseBeatmapScoresContainer.cs
#	osu.Game/Graphics/OsuFont.cs
#	osu.Game/Online/API/Requests/Responses/APILegacyScoreInfo.cs
#	osu.Game/Overlays/Profile/Header/BadgeContainer.cs
#	osu.Game/Overlays/Profile/ProfileHeader.cs
#	osu.Game/Screens/Select/PlaySongSelect.cs
#	osu.Game/Skinning/LegacySkinDecoder.cs
This commit is contained in:
smoogipoo
2019-05-07 13:20:17 +09:00
372 changed files with 5594 additions and 3030 deletions

View File

@ -16,6 +16,7 @@ using osuTK.Input;
using osu.Framework.Extensions.Color4Extensions;
using osu.Game.Graphics.Containers;
using osu.Framework.Audio.Track;
using osu.Framework.Graphics.Effects;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Events;
using osu.Game.Beatmaps.ControlPoints;
@ -63,6 +64,8 @@ namespace osu.Game.Screens.Menu
{
box = new Container
{
// box needs to be always present to ensure the button is always sized correctly for flow
AlwaysPresent = true,
Masking = true,
MaskingSmoothness = 2,
EdgeEffect = new EdgeEffectParameters

View File

@ -32,6 +32,7 @@ namespace osu.Game.Screens.Menu
RelativeSizeAxes = Axes.X,
Size = new Vector2(1, BUTTON_AREA_HEIGHT),
Alpha = 0,
AlwaysPresent = true, // Always needs to be present for correct tracking on initial -> toplevel state change
Children = new Drawable[]
{
buttonAreaBackground = new ButtonAreaBackground(),

View File

@ -9,6 +9,7 @@ using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Bindables;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
@ -17,6 +18,7 @@ using osu.Framework.Logging;
using osu.Framework.Platform;
using osu.Framework.Threading;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Input;
using osu.Game.Input.Bindings;
using osu.Game.Online.API;
@ -47,6 +49,10 @@ namespace osu.Game.Screens.Menu
private OsuLogo logo;
/// <summary>
/// Assign the <see cref="OsuLogo"/> that this ButtonSystem should manage the position of.
/// </summary>
/// <param name="logo">The instance of the logo to be assigned. If null, we are suspending from the screen that uses this ButtonSystem.</param>
public void SetOsuLogo(OsuLogo logo)
{
this.logo = logo;
@ -60,9 +66,13 @@ namespace osu.Game.Screens.Menu
updateLogoState();
}
else
{
// We should stop tracking as the facade is now out of scope.
logoTrackingContainer.StopTracking();
}
}
private readonly Drawable iconFacade;
private readonly ButtonArea buttonArea;
private readonly Button backButton;
@ -72,26 +82,29 @@ namespace osu.Game.Screens.Menu
private SampleChannel sampleBack;
private readonly LogoTrackingContainer logoTrackingContainer;
public ButtonSystem()
{
RelativeSizeAxes = Axes.Both;
Child = buttonArea = new ButtonArea();
buttonArea.AddRange(new[]
Child = logoTrackingContainer = new LogoTrackingContainer
{
new Button(@"settings", string.Empty, FontAwesome.Gear, new Color4(85, 85, 85, 255), () => OnSettings?.Invoke(), -WEDGE_WIDTH, Key.O),
RelativeSizeAxes = Axes.Both,
Child = buttonArea = new ButtonArea()
};
buttonArea.AddRange(new Drawable[]
{
new Button(@"settings", string.Empty, FontAwesome.Solid.Cog, new Color4(85, 85, 85, 255), () => OnSettings?.Invoke(), -WEDGE_WIDTH, Key.O),
backButton = new Button(@"back", @"button-back-select", OsuIcon.LeftCircle, new Color4(51, 58, 94, 255), () => State = ButtonSystemState.TopLevel, -WEDGE_WIDTH)
{
VisibleState = ButtonSystemState.Play,
},
iconFacade = new Container //need a container to make the osu! icon flow properly.
{
Size = new Vector2(0, ButtonArea.BUTTON_AREA_HEIGHT)
}
logoTrackingContainer.LogoFacade.With(d => d.Scale = new Vector2(0.74f))
});
buttonArea.Flow.CentreTarget = iconFacade;
buttonArea.Flow.CentreTarget = logoTrackingContainer.LogoFacade;
}
[Resolved(CanBeNull = true)]
@ -103,11 +116,14 @@ namespace osu.Game.Screens.Menu
[Resolved(CanBeNull = true)]
private NotificationOverlay notifications { get; set; }
[Resolved(CanBeNull = true)]
private LoginOverlay loginOverlay { get; set; }
[BackgroundDependencyLoader(true)]
private void load(AudioManager audio, IdleTracker idleTracker, GameHost host)
{
buttonsPlay.Add(new Button(@"solo", @"button-solo-select", FontAwesome.User, new Color4(102, 68, 204, 255), () => OnSolo?.Invoke(), WEDGE_WIDTH, Key.P));
buttonsPlay.Add(new Button(@"multi", @"button-generic-select", FontAwesome.Users, new Color4(94, 63, 186, 255), onMulti, 0, Key.M));
buttonsPlay.Add(new Button(@"solo", @"button-solo-select", FontAwesome.Solid.User, new Color4(102, 68, 204, 255), () => OnSolo?.Invoke(), WEDGE_WIDTH, Key.P));
buttonsPlay.Add(new Button(@"multi", @"button-generic-select", FontAwesome.Solid.Users, new Color4(94, 63, 186, 255), onMulti, 0, Key.M));
buttonsPlay.Add(new Button(@"chart", @"button-generic-select", OsuIcon.Charts, new Color4(80, 53, 160, 255), () => OnChart?.Invoke()));
buttonsPlay.ForEach(b => b.VisibleState = ButtonSystemState.Play);
@ -121,6 +137,15 @@ namespace osu.Game.Screens.Menu
buttonArea.AddRange(buttonsPlay);
buttonArea.AddRange(buttonsTopLevel);
buttonArea.ForEach(b =>
{
if (b is Button)
{
b.Origin = Anchor.CentreLeft;
b.Anchor = Anchor.CentreLeft;
}
});
isIdle.ValueChanged += idle => updateIdleState(idle.NewValue);
if (idleTracker != null) isIdle.BindTo(idleTracker.IsIdle);
@ -135,7 +160,12 @@ namespace osu.Game.Screens.Menu
notifications?.Post(new SimpleNotification
{
Text = "You gotta be logged in to multi 'yo!",
Icon = FontAwesome.Globe
Icon = FontAwesome.Solid.Globe,
Activated = () =>
{
loginOverlay?.Show();
return true;
}
});
return;
@ -255,13 +285,11 @@ namespace osu.Game.Screens.Menu
logoDelayedAction?.Cancel();
logoDelayedAction = Scheduler.AddDelayed(() =>
{
logoTracking = false;
logoTrackingContainer.StopTracking();
game?.Toolbar.Hide();
logo.ClearTransforms(targetMember: nameof(Position));
logo.RelativePositionAxes = Axes.Both;
logo.MoveTo(new Vector2(0.5f), 800, Easing.OutExpo);
logo.ScaleTo(1, 800, Easing.OutExpo);
}, buttonArea.Alpha * 150);
@ -276,20 +304,17 @@ namespace osu.Game.Screens.Menu
case ButtonSystemState.Initial:
logo.ClearTransforms(targetMember: nameof(Position));
logo.RelativePositionAxes = Axes.None;
bool impact = logo.Scale.X > 0.6f;
if (lastState == ButtonSystemState.Initial)
logo.ScaleTo(0.5f, 200, Easing.In);
logo.MoveTo(logoTrackingPosition, lastState == ButtonSystemState.EnteringMode ? 0 : 200, Easing.In);
logoTrackingContainer.StartTracking(logo, lastState == ButtonSystemState.EnteringMode ? 0 : 200, Easing.In);
logoDelayedAction?.Cancel();
logoDelayedAction = Scheduler.AddDelayed(() =>
{
logoTracking = true;
if (impact)
logo.Impact();
@ -299,8 +324,7 @@ namespace osu.Game.Screens.Menu
default:
logo.ClearTransforms(targetMember: nameof(Position));
logo.RelativePositionAxes = Axes.None;
logoTracking = true;
logoTrackingContainer.StartTracking(logo, 0, Easing.In);
logo.ScaleTo(0.5f, 200, Easing.OutQuint);
break;
}
@ -308,27 +332,10 @@ namespace osu.Game.Screens.Menu
break;
case ButtonSystemState.EnteringMode:
logoTracking = true;
logoTrackingContainer.StartTracking(logo, 0, Easing.In);
break;
}
}
private Vector2 logoTrackingPosition => logo.Parent.ToLocalSpace(iconFacade.ScreenSpaceDrawQuad.Centre);
private bool logoTracking;
protected override void Update()
{
base.Update();
if (logo != null)
{
if (logoTracking && logo.RelativePositionAxes == Axes.None && iconFacade.IsLoaded)
logo.Position = logoTrackingPosition;
iconFacade.Width = logo.SizeForFlow * 0.5f;
}
}
}
public enum ButtonSystemState

View File

@ -54,7 +54,7 @@ namespace osu.Game.Screens.Menu
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Icon = FontAwesome.Warning,
Icon = FontAwesome.Solid.ExclamationTriangle,
Size = new Vector2(icon_size),
Y = icon_y,
},
@ -128,7 +128,7 @@ namespace osu.Game.Screens.Menu
supportFlow.AddText(" to help support the game", format);
}
heart = supportFlow.AddIcon(FontAwesome.Heart, t =>
heart = supportFlow.AddIcon(FontAwesome.Solid.Heart, t =>
{
t.Padding = new MarginPadding { Left = 5 };
t.Font = t.Font.With(size: 12);

View File

@ -29,7 +29,7 @@ namespace osu.Game.Screens.Menu
if (CentreTarget == null)
return base.OriginPosition;
return CentreTarget.DrawPosition + CentreTarget.DrawSize / 2;
return CentreTarget.DrawPosition + CentreTarget.DrawSize / 2 * CentreTarget.Scale;
}
}
}

View File

@ -12,9 +12,13 @@ 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;
using osu.Framework.Extensions.Color4Extensions;
namespace osu.Game.Screens.Menu
{
@ -66,18 +70,25 @@ 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 += _ => updateColour();
skin.BindValueChanged(_ => updateColour(), true);
}
private void updateAmplitudes()
@ -107,6 +118,16 @@ namespace osu.Game.Screens.Menu
Scheduler.AddDelayed(updateAmplitudes, time_between_updates);
}
private void updateColour()
{
Color4 defaultColour = Color4.White.Opacity(0.2f);
if (user.Value?.IsSupporter ?? false)
AccentColour = skin.Value.GetValue<SkinConfiguration, Color4?>(s => s.CustomColours.ContainsKey("MenuGlow") ? s.CustomColours["MenuGlow"] : (Color4?)null) ?? defaultColour;
else
AccentColour = defaultColour;
}
protected override void LoadComplete()
{
base.LoadComplete();
@ -130,62 +151,67 @@ namespace osu.Game.Screens.Menu
Invalidate(Invalidation.DrawNode, shallPropagate: false);
}
protected override DrawNode CreateDrawNode() => new VisualisationDrawNode();
protected override void ApplyDrawNode(DrawNode node)
{
base.ApplyDrawNode(node);
var visNode = (VisualisationDrawNode)node;
visNode.Shader = shader;
visNode.Texture = texture;
visNode.Size = DrawSize.X;
visNode.Colour = AccentColour;
visNode.AudioData = frequencyAmplitudes;
}
protected override DrawNode CreateDrawNode() => new VisualisationDrawNode(this);
private class VisualisationDrawNode : DrawNode
{
public IShader Shader;
public Texture Texture;
protected new LogoVisualisation Source => (LogoVisualisation)base.Source;
private IShader shader;
private Texture texture;
//Asuming the logo is a circle, we don't need a second dimension.
public float Size;
private float size;
public Color4 Colour;
public float[] AudioData;
private Color4 colour;
private float[] audioData;
private readonly QuadBatch<TexturedVertex2D> vertexBatch = new QuadBatch<TexturedVertex2D>(100, 10);
public VisualisationDrawNode(LogoVisualisation source)
: base(source)
{
}
public override void ApplyState()
{
base.ApplyState();
shader = Source.shader;
texture = Source.texture;
size = Source.DrawSize.X;
colour = Source.AccentColour;
audioData = Source.frequencyAmplitudes;
}
public override void Draw(Action<TexturedVertex2D> vertexAction)
{
base.Draw(vertexAction);
Shader.Bind();
Texture.TextureGL.Bind();
shader.Bind();
texture.TextureGL.Bind();
Vector2 inflation = DrawInfo.MatrixInverse.ExtractScale().Xy;
ColourInfo colourInfo = DrawColourInfo.Colour;
colourInfo.ApplyChild(Colour);
colourInfo.ApplyChild(colour);
if (AudioData != null)
if (audioData != null)
{
for (int j = 0; j < visualiser_rounds; j++)
{
for (int i = 0; i < bars_per_visualiser; i++)
{
if (AudioData[i] < amplitude_dead_zone)
if (audioData[i] < amplitude_dead_zone)
continue;
float rotation = MathHelper.DegreesToRadians(i / (float)bars_per_visualiser * 360 + j * 360 / visualiser_rounds);
float rotationCos = (float)Math.Cos(rotation);
float rotationSin = (float)Math.Sin(rotation);
//taking the cos and sin to the 0..1 range
var barPosition = new Vector2(rotationCos / 2 + 0.5f, rotationSin / 2 + 0.5f) * Size;
var barPosition = new Vector2(rotationCos / 2 + 0.5f, rotationSin / 2 + 0.5f) * size;
var barSize = new Vector2(Size * (float)Math.Sqrt(2 * (1 - Math.Cos(MathHelper.DegreesToRadians(360f / bars_per_visualiser)))) / 2f, bar_length * AudioData[i]);
var barSize = new Vector2(size * (float)Math.Sqrt(2 * (1 - Math.Cos(MathHelper.DegreesToRadians(360f / bars_per_visualiser)))) / 2f, bar_length * audioData[i]);
//The distance between the position and the sides of the bar.
var bottomOffset = new Vector2(-rotationSin * barSize.X / 2, rotationCos * barSize.X / 2);
//The distance between the bottom side of the bar and the top side.
@ -198,7 +224,7 @@ namespace osu.Game.Screens.Menu
Vector2Extensions.Transform(barPosition + bottomOffset + amplitudeOffset, DrawInfo.Matrix)
);
Texture.DrawQuad(
texture.DrawQuad(
rectangle,
colourInfo,
null,
@ -209,7 +235,7 @@ namespace osu.Game.Screens.Menu
}
}
Shader.Unbind();
shader.Unbind();
}
protected override void Dispose(bool isDisposing)

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,12 @@ 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();
Children = new Drawable[]
{
@ -62,8 +70,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 +81,12 @@ namespace osu.Game.Screens.Menu
Height = 1.5f,
X = box_width,
Alpha = 0,
Blending = BlendingMode.Additive,
Colour = ColourInfo.GradientHorizontal(gradientDark, gradientLight)
Blending = BlendingMode.Additive
}
};
user.ValueChanged += _ => updateColour();
skin.BindValueChanged(_ => updateColour(), true);
}
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes)
@ -97,5 +106,20 @@ namespace osu.Game.Screens.Menu
.Then()
.FadeOut(beatLength, Easing.In);
}
private void updateColour()
{
Color4 baseColour = colours.Blue;
if (user.Value?.IsSupporter ?? false)
baseColour = skin.Value.GetValue<SkinConfiguration, Color4?>(s => s.CustomColours.ContainsKey("MenuGlow") ? s.CustomColours["MenuGlow"] : (Color4?)null) ?? baseColour;
// 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);
}
}
}

View File

@ -54,7 +54,13 @@ namespace osu.Game.Screens.Menu
/// </summary>
public Func<bool> Action;
public float SizeForFlow => logo == null ? 0 : logo.DrawSize.X * logo.Scale.X * logoBounceContainer.Scale.X * logoHoverContainer.Scale.X * 0.74f;
/// <summary>
/// The size of the logo Sprite with respect to the scale of its hover and bounce containers.
/// </summary>
/// <remarks>Does not account for the scale of this <see cref="OsuLogo"/></remarks>
public float SizeForFlow => logo == null ? 0 : logo.DrawSize.X * logo.Scale.X * logoBounceContainer.Scale.X * logoHoverContainer.Scale.X;
public bool IsTracking { get; set; }
private readonly Sprite ripple;