mirror of https://github.com/ppy/osu
Dropdown actions, +User.Status, +UserStatusDoNotDisturb, properly align UserDropdownMenuItem
This commit is contained in:
parent
b57a3f2056
commit
efd4c57431
|
@ -26,6 +26,7 @@ public class LoginSettings : FillFlowContainer, IOnlineComponent
|
||||||
{
|
{
|
||||||
private bool bounding = true;
|
private bool bounding = true;
|
||||||
private LoginForm form;
|
private LoginForm form;
|
||||||
|
private OsuColour colours;
|
||||||
|
|
||||||
public override RectangleF BoundingBox => bounding ? base.BoundingBox : RectangleF.Empty;
|
public override RectangleF BoundingBox => bounding ? base.BoundingBox : RectangleF.Empty;
|
||||||
|
|
||||||
|
@ -48,8 +49,9 @@ public LoginSettings()
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader(permitNulls: true)]
|
[BackgroundDependencyLoader(permitNulls: true)]
|
||||||
private void load(APIAccess api)
|
private void load(OsuColour colours, APIAccess api)
|
||||||
{
|
{
|
||||||
|
this.colours = colours;
|
||||||
api?.Register(this);
|
api?.Register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,6 +95,8 @@ public void APIStateChanged(APIAccess api, APIState state)
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case APIState.Online:
|
case APIState.Online:
|
||||||
|
UserDropdown dropdown;
|
||||||
|
UserPanel panel;
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new FillFlowContainer
|
new FillFlowContainer
|
||||||
|
@ -121,17 +125,40 @@ public void APIStateChanged(APIAccess api, APIState state)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
new UserPanel(api.LocalUser.Value)
|
panel = new UserPanel(api.LocalUser.Value)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
},
|
},
|
||||||
new UserDropdown
|
dropdown = new UserDropdown
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
panel.Status.BindTo(api.LocalUser.Value.Status);
|
||||||
|
dropdown.Current.ValueChanged += newValue =>
|
||||||
|
{
|
||||||
|
switch (newValue)
|
||||||
|
{
|
||||||
|
case UserAction.Online:
|
||||||
|
api.LocalUser.Value.Status.Value = new UserStatusOnline();
|
||||||
|
dropdown.StatusColour = colours.Green;
|
||||||
|
break;
|
||||||
|
case UserAction.DoNotDisturb:
|
||||||
|
api.LocalUser.Value.Status.Value = new UserStatusDoNotDisturb();
|
||||||
|
dropdown.StatusColour = colours.Red;
|
||||||
|
break;
|
||||||
|
case UserAction.AppearOffline:
|
||||||
|
api.LocalUser.Value.Status.Value = new UserStatusOffline();
|
||||||
|
dropdown.StatusColour = colours.Gray7;
|
||||||
|
break;
|
||||||
|
case UserAction.SignOut:
|
||||||
|
api.Logout();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
dropdown.Current.TriggerChange();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,6 +252,14 @@ private class UserDropdown : OsuEnumDropdown<UserAction>
|
||||||
protected override Menu CreateMenu() => new UserDropdownMenu();
|
protected override Menu CreateMenu() => new UserDropdownMenu();
|
||||||
protected override DropdownMenuItem<UserAction> CreateMenuItem(string text, UserAction value) => new UserDropdownMenuItem(text, value) { AccentColour = AccentColour };
|
protected override DropdownMenuItem<UserAction> CreateMenuItem(string text, UserAction value) => new UserDropdownMenuItem(text, value) { AccentColour = AccentColour };
|
||||||
|
|
||||||
|
public Color4 StatusColour
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
(Header as UserDropdownHeader).StatusColour = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
|
@ -235,6 +270,14 @@ private class UserDropdownHeader : OsuDropdownHeader
|
||||||
{
|
{
|
||||||
protected readonly TextAwesome statusIcon;
|
protected readonly TextAwesome statusIcon;
|
||||||
|
|
||||||
|
public Color4 StatusColour
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
statusIcon.FadeColour(value, 500, EasingTypes.OutQuint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public UserDropdownHeader()
|
public UserDropdownHeader()
|
||||||
{
|
{
|
||||||
Foreground.Padding = new MarginPadding { Left = 10, Right = 10 };
|
Foreground.Padding = new MarginPadding { Left = 10, Right = 10 };
|
||||||
|
@ -268,8 +311,6 @@ private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
BackgroundColour = colours.Gray3;
|
BackgroundColour = colours.Gray3;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetStatusColour(Color4 colour) => statusIcon.FadeColour(colour, 500, EasingTypes.OutQuint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class UserDropdownMenu : OsuMenu
|
private class UserDropdownMenu : OsuMenu
|
||||||
|
@ -298,7 +339,8 @@ private class UserDropdownMenuItem : OsuDropdownMenuItem
|
||||||
{
|
{
|
||||||
public UserDropdownMenuItem(string text, UserAction current) : base(text, current)
|
public UserDropdownMenuItem(string text, UserAction current) : base(text, current)
|
||||||
{
|
{
|
||||||
Foreground.Padding = new MarginPadding(5);
|
//todo: Another magic number
|
||||||
|
Foreground.Padding = new MarginPadding { Top = 5, Bottom = 5, Left = 19, Right = 5 };
|
||||||
CornerRadius = 5;
|
CornerRadius = 5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
// 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 Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using osu.Framework.Configuration;
|
||||||
|
|
||||||
namespace osu.Game.Users
|
namespace osu.Game.Users
|
||||||
{
|
{
|
||||||
|
@ -19,6 +20,8 @@ public class User
|
||||||
[JsonProperty(@"country")]
|
[JsonProperty(@"country")]
|
||||||
public Country Country;
|
public Country Country;
|
||||||
|
|
||||||
|
public Bindable<UserStatus> Status = new Bindable<UserStatus>();
|
||||||
|
|
||||||
//public Team Team;
|
//public Team Team;
|
||||||
|
|
||||||
[JsonProperty(@"profile_colour")]
|
[JsonProperty(@"profile_colour")]
|
||||||
|
|
|
@ -58,4 +58,10 @@ public class UserStatusModding : UserStatus
|
||||||
public override string Message => @"Modding a map";
|
public override string Message => @"Modding a map";
|
||||||
public override Color4 GetAppropriateColour(OsuColour colours) => colours.PurpleDark;
|
public override Color4 GetAppropriateColour(OsuColour colours) => colours.PurpleDark;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class UserStatusDoNotDisturb : UserStatus
|
||||||
|
{
|
||||||
|
public override string Message => @"Do not disturb";
|
||||||
|
public override Color4 GetAppropriateColour(OsuColour colours) => colours.RedDark;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue