Merge branch 'master' into drawnode-composability

This commit is contained in:
Dean Herbert
2019-04-27 18:41:19 +09:00
committed by GitHub
144 changed files with 1303 additions and 626 deletions

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();
Child = logoTrackingContainer = new LogoTrackingContainer
{
RelativeSizeAxes = Axes.Both,
Child = buttonArea = new ButtonArea()
};
buttonArea.AddRange(new[]
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)]
@ -124,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);
@ -256,13 +278,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);
@ -275,20 +295,17 @@ namespace osu.Game.Screens.Menu
break;
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();
@ -297,35 +314,17 @@ namespace osu.Game.Screens.Menu
break;
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;
}
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

@ -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

@ -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;