Avoid storing locals in UserPanel.

Also make clickable region more correct.
This commit is contained in:
Dean Herbert 2017-07-13 14:32:47 +09:00
parent b79e309c2f
commit d1a5a042d7
1 changed files with 15 additions and 9 deletions

View File

@ -1,6 +1,7 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Allocation; using osu.Framework.Allocation;
@ -15,23 +16,25 @@
namespace osu.Game.Users namespace osu.Game.Users
{ {
public class UserPanel : Container public class UserPanel : ClickableContainer
{ {
private readonly User user;
private const float height = 100; private const float height = 100;
private const float content_padding = 10; private const float content_padding = 10;
private const float status_height = 30; private const float status_height = 30;
private OsuColour colours;
private UserProfileOverlay profile;
private readonly Container statusBar; private readonly Container statusBar;
private readonly Box statusBg; private readonly Box statusBg;
private readonly OsuSpriteText statusMessage; private readonly OsuSpriteText statusMessage;
public readonly Bindable<UserStatus> Status = new Bindable<UserStatus>(); public readonly Bindable<UserStatus> Status = new Bindable<UserStatus>();
public new Action Action;
public UserPanel(User user) public UserPanel(User user)
{ {
this.user = user;
Height = height - status_height; Height = height - status_height;
Masking = true; Masking = true;
CornerRadius = 5; CornerRadius = 5;
@ -77,7 +80,7 @@ public UserPanel(User user)
Radius = 4, Radius = 4,
}, },
}, },
new ClickableContainer new Container
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Left = height - status_height - content_padding }, Padding = new MarginPadding { Left = height - status_height - content_padding },
@ -117,7 +120,6 @@ public UserPanel(User user)
}, },
}, },
}, },
Action = () => profile?.ShowUser(user)
}, },
}, },
}, },
@ -166,9 +168,14 @@ public UserPanel(User user)
[BackgroundDependencyLoader(permitNulls: true)] [BackgroundDependencyLoader(permitNulls: true)]
private void load(OsuColour colours, UserProfileOverlay profile) private void load(OsuColour colours, UserProfileOverlay profile)
{ {
this.colours = colours;
this.profile = profile;
Status.ValueChanged += displayStatus; Status.ValueChanged += displayStatus;
Status.ValueChanged += status => statusBg.FadeColour(status.GetAppropriateColour(colours), 500, EasingTypes.OutQuint);
base.Action = () =>
{
Action?.Invoke();
profile?.ShowUser(user);
};
} }
protected override void LoadComplete() protected override void LoadComplete()
@ -193,7 +200,6 @@ private void displayStatus(UserStatus status)
statusBar.FadeIn(transition_duration, EasingTypes.OutQuint); statusBar.FadeIn(transition_duration, EasingTypes.OutQuint);
ResizeHeightTo(height, transition_duration, EasingTypes.OutQuint); ResizeHeightTo(height, transition_duration, EasingTypes.OutQuint);
statusBg.FadeColour(status.GetAppropriateColour(colours), 500, EasingTypes.OutQuint);
statusMessage.Text = status.Message; statusMessage.Text = status.Message;
} }
} }