mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 11:35:35 +08:00
Merge branch 'master' into split-out-music-controller
This commit is contained in:
commit
4948e7d31c
@ -19,8 +19,9 @@ Detailed changelogs are published on the [official osu! site](https://osu.ppy.sh
|
||||
## Requirements
|
||||
|
||||
- A desktop platform with the [.NET Core SDK 2.2](https://www.microsoft.com/net/learn/get-started) or higher installed.
|
||||
- When running on linux, please have a system-wide ffmpeg installation available to support video decoding.
|
||||
- When running on Windows 7 or 8.1, **[additional prerequisites](https://docs.microsoft.com/en-us/dotnet/core/windows-prerequisites?tabs=netcore2x)** may be required to correctly run .NET Core applications if your operating system is not up-to-date with the latest service packs.
|
||||
- When working with the codebase, we recommend using an IDE with intellisense and syntax highlighting, such as [Visual Studio 2017+](https://visualstudio.microsoft.com/vs/), [Jetbrains Rider](https://www.jetbrains.com/rider/) or [Visual Studio Code](https://code.visualstudio.com/).
|
||||
- Note that there are **[additional requirements for Windows 7 and Windows 8.1](https://docs.microsoft.com/en-us/dotnet/core/windows-prerequisites?tabs=netcore2x)** which you may need to manually install if your operating system is not up-to-date.
|
||||
|
||||
## Running osu!
|
||||
|
||||
|
@ -0,0 +1,69 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Overlays.Profile.Header.Components;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSceneUserProfilePreviousUsernames : OsuTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(PreviousUsernames)
|
||||
};
|
||||
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; }
|
||||
|
||||
private readonly Bindable<User> user = new Bindable<User>();
|
||||
|
||||
public TestSceneUserProfilePreviousUsernames()
|
||||
{
|
||||
Child = new PreviousUsernames
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
User = { BindTarget = user },
|
||||
};
|
||||
|
||||
User[] users =
|
||||
{
|
||||
new User { PreviousUsernames = new[] { "username1" } },
|
||||
new User { PreviousUsernames = new[] { "longusername", "longerusername" } },
|
||||
new User { PreviousUsernames = new[] { "test", "angelsim", "verylongusername" } },
|
||||
new User { PreviousUsernames = new[] { "ihavenoidea", "howcani", "makethistext", "anylonger" } },
|
||||
new User { PreviousUsernames = new string[0] },
|
||||
null
|
||||
};
|
||||
|
||||
AddStep("single username", () => user.Value = users[0]);
|
||||
AddStep("two usernames", () => user.Value = users[1]);
|
||||
AddStep("three usernames", () => user.Value = users[2]);
|
||||
AddStep("four usernames", () => user.Value = users[3]);
|
||||
AddStep("no username", () => user.Value = users[4]);
|
||||
AddStep("null user", () => user.Value = users[5]);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
AddStep("online user (Angelsim)", () =>
|
||||
{
|
||||
var request = new GetUserRequest(1777162);
|
||||
request.Success += user => this.user.Value = user;
|
||||
api.Queue(request);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
168
osu.Game/Overlays/Profile/Header/Components/PreviousUsernames.cs
Normal file
168
osu.Game/Overlays/Profile/Header/Components/PreviousUsernames.cs
Normal file
@ -0,0 +1,168 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Users;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Header.Components
|
||||
{
|
||||
public class PreviousUsernames : CompositeDrawable
|
||||
{
|
||||
private const int duration = 200;
|
||||
private const int margin = 10;
|
||||
private const int width = 310;
|
||||
private const int move_offset = 15;
|
||||
|
||||
public readonly Bindable<User> User = new Bindable<User>();
|
||||
|
||||
private readonly TextFlowContainer text;
|
||||
private readonly Box background;
|
||||
private readonly SpriteText header;
|
||||
|
||||
public PreviousUsernames()
|
||||
{
|
||||
HoverIconContainer hoverIcon;
|
||||
|
||||
AutoSizeAxes = Axes.Y;
|
||||
Width = width;
|
||||
Masking = true;
|
||||
CornerRadius = 5;
|
||||
|
||||
AddRangeInternal(new Drawable[]
|
||||
{
|
||||
background = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
new GridContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Y,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
RowDimensions = new[]
|
||||
{
|
||||
new Dimension(GridSizeMode.AutoSize),
|
||||
new Dimension(GridSizeMode.AutoSize)
|
||||
},
|
||||
ColumnDimensions = new[]
|
||||
{
|
||||
new Dimension(GridSizeMode.AutoSize),
|
||||
new Dimension(GridSizeMode.Distributed)
|
||||
},
|
||||
Content = new[]
|
||||
{
|
||||
new Drawable[]
|
||||
{
|
||||
hoverIcon = new HoverIconContainer(),
|
||||
header = new SpriteText
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Text = @"formerly known as",
|
||||
Font = OsuFont.GetFont(size: 10, italics: true)
|
||||
}
|
||||
},
|
||||
new Drawable[]
|
||||
{
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
text = new TextFlowContainer(s => s.Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold, italics: true))
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Full,
|
||||
Margin = new MarginPadding { Bottom = margin, Top = margin / 2f }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
hoverIcon.ActivateHover += showContent;
|
||||
hideContent();
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
background.Colour = colours.GreySeafoamDarker;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
User.BindValueChanged(onUserChanged, true);
|
||||
}
|
||||
|
||||
private void onUserChanged(ValueChangedEvent<User> user)
|
||||
{
|
||||
text.Text = string.Empty;
|
||||
|
||||
var usernames = user.NewValue?.PreviousUsernames;
|
||||
|
||||
if (usernames?.Any() ?? false)
|
||||
{
|
||||
text.Text = string.Join(", ", usernames);
|
||||
Show();
|
||||
return;
|
||||
}
|
||||
|
||||
Hide();
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(HoverLostEvent e)
|
||||
{
|
||||
base.OnHoverLost(e);
|
||||
hideContent();
|
||||
}
|
||||
|
||||
private void showContent()
|
||||
{
|
||||
text.FadeIn(duration, Easing.OutQuint);
|
||||
header.FadeIn(duration, Easing.OutQuint);
|
||||
background.FadeIn(duration, Easing.OutQuint);
|
||||
this.MoveToY(-move_offset, duration, Easing.OutQuint);
|
||||
}
|
||||
|
||||
private void hideContent()
|
||||
{
|
||||
text.FadeOut(duration, Easing.OutQuint);
|
||||
header.FadeOut(duration, Easing.OutQuint);
|
||||
background.FadeOut(duration, Easing.OutQuint);
|
||||
this.MoveToY(0, duration, Easing.OutQuint);
|
||||
}
|
||||
|
||||
private class HoverIconContainer : Container
|
||||
{
|
||||
public Action ActivateHover;
|
||||
|
||||
public HoverIconContainer()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
Child = new SpriteIcon
|
||||
{
|
||||
Margin = new MarginPadding { Top = 6, Left = margin, Right = margin * 2 },
|
||||
Size = new Vector2(15),
|
||||
Icon = FontAwesome.Solid.IdCard,
|
||||
};
|
||||
}
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
ActivateHover?.Invoke();
|
||||
return base.OnHover(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -20,6 +20,9 @@ namespace osu.Game.Users
|
||||
[JsonProperty(@"username")]
|
||||
public string Username;
|
||||
|
||||
[JsonProperty(@"previous_usernames")]
|
||||
public string[] PreviousUsernames;
|
||||
|
||||
[JsonProperty(@"country")]
|
||||
public Country Country;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user