mirror of
https://github.com/osukey/osukey.git
synced 2025-05-11 08:37:34 +09:00
Merge branch 'master' into fix-user-lookup-failure-crashes
This commit is contained in:
commit
20ae84a466
56
Gemfile.lock
56
Gemfile.lock
@ -1,27 +1,27 @@
|
|||||||
GEM
|
GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
CFPropertyList (3.0.2)
|
CFPropertyList (3.0.3)
|
||||||
addressable (2.7.0)
|
addressable (2.7.0)
|
||||||
public_suffix (>= 2.0.2, < 5.0)
|
public_suffix (>= 2.0.2, < 5.0)
|
||||||
atomos (0.1.3)
|
atomos (0.1.3)
|
||||||
aws-eventstream (1.1.0)
|
aws-eventstream (1.1.0)
|
||||||
aws-partitions (1.354.0)
|
aws-partitions (1.413.0)
|
||||||
aws-sdk-core (3.104.3)
|
aws-sdk-core (3.110.0)
|
||||||
aws-eventstream (~> 1, >= 1.0.2)
|
aws-eventstream (~> 1, >= 1.0.2)
|
||||||
aws-partitions (~> 1, >= 1.239.0)
|
aws-partitions (~> 1, >= 1.239.0)
|
||||||
aws-sigv4 (~> 1.1)
|
aws-sigv4 (~> 1.1)
|
||||||
jmespath (~> 1.0)
|
jmespath (~> 1.0)
|
||||||
aws-sdk-kms (1.36.0)
|
aws-sdk-kms (1.40.0)
|
||||||
aws-sdk-core (~> 3, >= 3.99.0)
|
aws-sdk-core (~> 3, >= 3.109.0)
|
||||||
aws-sigv4 (~> 1.1)
|
aws-sigv4 (~> 1.1)
|
||||||
aws-sdk-s3 (1.78.0)
|
aws-sdk-s3 (1.87.0)
|
||||||
aws-sdk-core (~> 3, >= 3.104.3)
|
aws-sdk-core (~> 3, >= 3.109.0)
|
||||||
aws-sdk-kms (~> 1)
|
aws-sdk-kms (~> 1)
|
||||||
aws-sigv4 (~> 1.1)
|
aws-sigv4 (~> 1.1)
|
||||||
aws-sigv4 (1.2.1)
|
aws-sigv4 (1.2.2)
|
||||||
aws-eventstream (~> 1, >= 1.0.2)
|
aws-eventstream (~> 1, >= 1.0.2)
|
||||||
babosa (1.0.3)
|
babosa (1.0.4)
|
||||||
claide (1.0.3)
|
claide (1.0.3)
|
||||||
colored (1.2)
|
colored (1.2)
|
||||||
colored2 (3.1.2)
|
colored2 (3.1.2)
|
||||||
@ -29,22 +29,23 @@ GEM
|
|||||||
highline (~> 1.7.2)
|
highline (~> 1.7.2)
|
||||||
declarative (0.0.20)
|
declarative (0.0.20)
|
||||||
declarative-option (0.1.0)
|
declarative-option (0.1.0)
|
||||||
digest-crc (0.6.1)
|
digest-crc (0.6.3)
|
||||||
rake (~> 13.0)
|
rake (>= 12.0.0, < 14.0.0)
|
||||||
domain_name (0.5.20190701)
|
domain_name (0.5.20190701)
|
||||||
unf (>= 0.0.5, < 1.0.0)
|
unf (>= 0.0.5, < 1.0.0)
|
||||||
dotenv (2.7.6)
|
dotenv (2.7.6)
|
||||||
emoji_regex (3.0.0)
|
emoji_regex (3.2.1)
|
||||||
excon (0.76.0)
|
excon (0.78.1)
|
||||||
faraday (1.0.1)
|
faraday (1.2.0)
|
||||||
multipart-post (>= 1.2, < 3)
|
multipart-post (>= 1.2, < 3)
|
||||||
faraday-cookie_jar (0.0.6)
|
ruby2_keywords
|
||||||
faraday (>= 0.7.4)
|
faraday-cookie_jar (0.0.7)
|
||||||
|
faraday (>= 0.8.0)
|
||||||
http-cookie (~> 1.0.0)
|
http-cookie (~> 1.0.0)
|
||||||
faraday_middleware (1.0.0)
|
faraday_middleware (1.0.0)
|
||||||
faraday (~> 1.0)
|
faraday (~> 1.0)
|
||||||
fastimage (2.2.0)
|
fastimage (2.2.1)
|
||||||
fastlane (2.156.0)
|
fastlane (2.170.0)
|
||||||
CFPropertyList (>= 2.3, < 4.0.0)
|
CFPropertyList (>= 2.3, < 4.0.0)
|
||||||
addressable (>= 2.3, < 3.0.0)
|
addressable (>= 2.3, < 3.0.0)
|
||||||
aws-sdk-s3 (~> 1.0)
|
aws-sdk-s3 (~> 1.0)
|
||||||
@ -96,17 +97,17 @@ GEM
|
|||||||
google-cloud-core (1.5.0)
|
google-cloud-core (1.5.0)
|
||||||
google-cloud-env (~> 1.0)
|
google-cloud-env (~> 1.0)
|
||||||
google-cloud-errors (~> 1.0)
|
google-cloud-errors (~> 1.0)
|
||||||
google-cloud-env (1.3.3)
|
google-cloud-env (1.4.0)
|
||||||
faraday (>= 0.17.3, < 2.0)
|
faraday (>= 0.17.3, < 2.0)
|
||||||
google-cloud-errors (1.0.1)
|
google-cloud-errors (1.0.1)
|
||||||
google-cloud-storage (1.27.0)
|
google-cloud-storage (1.29.2)
|
||||||
addressable (~> 2.5)
|
addressable (~> 2.5)
|
||||||
digest-crc (~> 0.4)
|
digest-crc (~> 0.4)
|
||||||
google-api-client (~> 0.33)
|
google-api-client (~> 0.33)
|
||||||
google-cloud-core (~> 1.2)
|
google-cloud-core (~> 1.2)
|
||||||
googleauth (~> 0.9)
|
googleauth (~> 0.9)
|
||||||
mini_mime (~> 1.0)
|
mini_mime (~> 1.0)
|
||||||
googleauth (0.13.1)
|
googleauth (0.14.0)
|
||||||
faraday (>= 0.17.3, < 2.0)
|
faraday (>= 0.17.3, < 2.0)
|
||||||
jwt (>= 1.4, < 3.0)
|
jwt (>= 1.4, < 3.0)
|
||||||
memoist (~> 0.16)
|
memoist (~> 0.16)
|
||||||
@ -118,10 +119,10 @@ GEM
|
|||||||
domain_name (~> 0.5)
|
domain_name (~> 0.5)
|
||||||
httpclient (2.8.3)
|
httpclient (2.8.3)
|
||||||
jmespath (1.4.0)
|
jmespath (1.4.0)
|
||||||
json (2.3.1)
|
json (2.5.1)
|
||||||
jwt (2.2.1)
|
jwt (2.2.2)
|
||||||
memoist (0.16.2)
|
memoist (0.16.2)
|
||||||
mini_magick (4.10.1)
|
mini_magick (4.11.0)
|
||||||
mini_mime (1.0.2)
|
mini_mime (1.0.2)
|
||||||
mini_portile2 (2.4.0)
|
mini_portile2 (2.4.0)
|
||||||
multi_json (1.15.0)
|
multi_json (1.15.0)
|
||||||
@ -132,14 +133,15 @@ GEM
|
|||||||
mini_portile2 (~> 2.4.0)
|
mini_portile2 (~> 2.4.0)
|
||||||
os (1.1.1)
|
os (1.1.1)
|
||||||
plist (3.5.0)
|
plist (3.5.0)
|
||||||
public_suffix (4.0.5)
|
public_suffix (4.0.6)
|
||||||
rake (13.0.1)
|
rake (13.0.3)
|
||||||
representable (3.0.4)
|
representable (3.0.4)
|
||||||
declarative (< 0.1.0)
|
declarative (< 0.1.0)
|
||||||
declarative-option (< 0.2.0)
|
declarative-option (< 0.2.0)
|
||||||
uber (< 0.2.0)
|
uber (< 0.2.0)
|
||||||
retriable (3.1.2)
|
retriable (3.1.2)
|
||||||
rouge (2.0.7)
|
rouge (2.0.7)
|
||||||
|
ruby2_keywords (0.0.2)
|
||||||
rubyzip (2.3.0)
|
rubyzip (2.3.0)
|
||||||
security (0.1.3)
|
security (0.1.3)
|
||||||
signet (0.14.0)
|
signet (0.14.0)
|
||||||
@ -168,7 +170,7 @@ GEM
|
|||||||
unf_ext (0.0.7.7)
|
unf_ext (0.0.7.7)
|
||||||
unicode-display_width (1.7.0)
|
unicode-display_width (1.7.0)
|
||||||
word_wrap (1.0.0)
|
word_wrap (1.0.0)
|
||||||
xcodeproj (1.18.0)
|
xcodeproj (1.19.0)
|
||||||
CFPropertyList (>= 2.3.3, < 4.0)
|
CFPropertyList (>= 2.3.3, < 4.0)
|
||||||
atomos (~> 0.1.3)
|
atomos (~> 0.1.3)
|
||||||
claide (>= 1.0.2, < 2.0)
|
claide (>= 1.0.2, < 2.0)
|
||||||
|
@ -52,6 +52,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.1202.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.1202.0" />
|
||||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2020.1222.0" />
|
<PackageReference Include="ppy.osu.Framework.Android" Version="2020.1228.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -20,14 +20,17 @@ using osu.Game.Rulesets.Osu.Scoring;
|
|||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
using osu.Game.Screens.Play.HUD;
|
using osu.Game.Screens.Play.HUD;
|
||||||
|
using osu.Game.Tests.Visual.Multiplayer;
|
||||||
using osu.Game.Tests.Visual.Online;
|
using osu.Game.Tests.Visual.Online;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Gameplay
|
namespace osu.Game.Tests.Visual.Gameplay
|
||||||
{
|
{
|
||||||
public class TestSceneMultiplayerGameplayLeaderboard : OsuTestScene
|
public class TestSceneMultiplayerGameplayLeaderboard : MultiplayerTestScene
|
||||||
{
|
{
|
||||||
|
private const int users = 16;
|
||||||
|
|
||||||
[Cached(typeof(SpectatorStreamingClient))]
|
[Cached(typeof(SpectatorStreamingClient))]
|
||||||
private TestMultiplayerStreaming streamingClient = new TestMultiplayerStreaming(16);
|
private TestMultiplayerStreaming streamingClient = new TestMultiplayerStreaming(users);
|
||||||
|
|
||||||
[Cached(typeof(UserLookupCache))]
|
[Cached(typeof(UserLookupCache))]
|
||||||
private UserLookupCache lookupCache = new TestSceneCurrentlyPlayingDisplay.TestUserLookupCache();
|
private UserLookupCache lookupCache = new TestSceneCurrentlyPlayingDisplay.TestUserLookupCache();
|
||||||
@ -47,10 +50,12 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
}
|
}
|
||||||
|
|
||||||
[SetUpSteps]
|
[SetUpSteps]
|
||||||
public void SetUpSteps()
|
public override void SetUpSteps()
|
||||||
{
|
{
|
||||||
AddStep("create leaderboard", () =>
|
AddStep("create leaderboard", () =>
|
||||||
{
|
{
|
||||||
|
leaderboard?.Expire();
|
||||||
|
|
||||||
OsuScoreProcessor scoreProcessor;
|
OsuScoreProcessor scoreProcessor;
|
||||||
Beatmap.Value = CreateWorkingBeatmap(Ruleset.Value);
|
Beatmap.Value = CreateWorkingBeatmap(Ruleset.Value);
|
||||||
|
|
||||||
@ -58,6 +63,9 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
streamingClient.Start(Beatmap.Value.BeatmapInfo.OnlineBeatmapID ?? 0);
|
streamingClient.Start(Beatmap.Value.BeatmapInfo.OnlineBeatmapID ?? 0);
|
||||||
|
|
||||||
|
Client.PlayingUsers.Clear();
|
||||||
|
Client.PlayingUsers.AddRange(streamingClient.PlayingUsers);
|
||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
scoreProcessor = new OsuScoreProcessor(),
|
scoreProcessor = new OsuScoreProcessor(),
|
||||||
@ -81,6 +89,12 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
AddRepeatStep("update state", () => streamingClient.RandomlyUpdateState(), 100);
|
AddRepeatStep("update state", () => streamingClient.RandomlyUpdateState(), 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestUserQuit()
|
||||||
|
{
|
||||||
|
AddRepeatStep("mark user quit", () => Client.PlayingUsers.RemoveAt(0), users);
|
||||||
|
}
|
||||||
|
|
||||||
public class TestMultiplayerStreaming : SpectatorStreamingClient
|
public class TestMultiplayerStreaming : SpectatorStreamingClient
|
||||||
{
|
{
|
||||||
public new BindableList<int> PlayingUsers => (BindableList<int>)base.PlayingUsers;
|
public new BindableList<int> PlayingUsers => (BindableList<int>)base.PlayingUsers;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -13,13 +14,12 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
public class TestSceneAccountCreationOverlay : OsuTestScene
|
public class TestSceneAccountCreationOverlay : OsuTestScene
|
||||||
{
|
{
|
||||||
private readonly Container userPanelArea;
|
private readonly Container userPanelArea;
|
||||||
|
private readonly AccountCreationOverlay accountCreation;
|
||||||
|
|
||||||
private IBindable<User> localUser;
|
private IBindable<User> localUser;
|
||||||
|
|
||||||
public TestSceneAccountCreationOverlay()
|
public TestSceneAccountCreationOverlay()
|
||||||
{
|
{
|
||||||
AccountCreationOverlay accountCreation;
|
|
||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
accountCreation = new AccountCreationOverlay(),
|
accountCreation = new AccountCreationOverlay(),
|
||||||
@ -31,8 +31,6 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
Origin = Anchor.TopRight,
|
Origin = Anchor.TopRight,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
AddStep("show", () => accountCreation.Show());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -42,8 +40,19 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
|
|
||||||
localUser = API.LocalUser.GetBoundCopy();
|
localUser = API.LocalUser.GetBoundCopy();
|
||||||
localUser.BindValueChanged(user => { userPanelArea.Child = new UserGridPanel(user.NewValue) { Width = 200 }; }, true);
|
localUser.BindValueChanged(user => { userPanelArea.Child = new UserGridPanel(user.NewValue) { Width = 200 }; }, true);
|
||||||
|
}
|
||||||
|
|
||||||
AddStep("logout", API.Logout);
|
[Test]
|
||||||
|
public void TestOverlayVisibility()
|
||||||
|
{
|
||||||
|
AddStep("start hidden", () => accountCreation.Hide());
|
||||||
|
AddStep("log out", API.Logout);
|
||||||
|
|
||||||
|
AddStep("show manually", () => accountCreation.Show());
|
||||||
|
AddUntilStep("overlay is visible", () => accountCreation.State.Value == Visibility.Visible);
|
||||||
|
|
||||||
|
AddStep("log back in", () => API.Login("dummy", "password"));
|
||||||
|
AddUntilStep("overlay is hidden", () => accountCreation.State.Value == Visibility.Hidden);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Humanizer;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
using osu.Game.Online.API;
|
||||||
|
using osu.Game.Online.API.Requests;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Overlays.Changelog;
|
using osu.Game.Overlays.Changelog;
|
||||||
@ -12,13 +17,61 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestSceneChangelogOverlay : OsuTestScene
|
public class TestSceneChangelogOverlay : OsuTestScene
|
||||||
{
|
{
|
||||||
|
private DummyAPIAccess dummyAPI => (DummyAPIAccess)API;
|
||||||
|
|
||||||
|
private readonly Dictionary<string, APIUpdateStream> streams;
|
||||||
|
private readonly Dictionary<string, APIChangelogBuild> builds;
|
||||||
|
|
||||||
|
private APIChangelogBuild requestedBuild;
|
||||||
private TestChangelogOverlay changelog;
|
private TestChangelogOverlay changelog;
|
||||||
|
|
||||||
protected override bool UseOnlineAPI => true;
|
public TestSceneChangelogOverlay()
|
||||||
|
{
|
||||||
|
streams = APIUpdateStream.KNOWN_STREAMS.Keys.Select((stream, id) => new APIUpdateStream
|
||||||
|
{
|
||||||
|
Id = id + 1,
|
||||||
|
Name = stream,
|
||||||
|
DisplayName = stream.Humanize(), // not quite there, but good enough.
|
||||||
|
}).ToDictionary(stream => stream.Name);
|
||||||
|
|
||||||
|
string version = DateTimeOffset.Now.ToString("yyyy.Mdd.0");
|
||||||
|
builds = APIUpdateStream.KNOWN_STREAMS.Keys.Select(stream => new APIChangelogBuild
|
||||||
|
{
|
||||||
|
Version = version,
|
||||||
|
DisplayVersion = version,
|
||||||
|
UpdateStream = streams[stream],
|
||||||
|
ChangelogEntries = new List<APIChangelogEntry>()
|
||||||
|
}).ToDictionary(build => build.UpdateStream.Name);
|
||||||
|
|
||||||
|
foreach (var stream in streams.Values)
|
||||||
|
stream.LatestBuild = builds[stream.Name];
|
||||||
|
}
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void SetUp() => Schedule(() =>
|
public void SetUp() => Schedule(() =>
|
||||||
{
|
{
|
||||||
|
requestedBuild = null;
|
||||||
|
|
||||||
|
dummyAPI.HandleRequest = request =>
|
||||||
|
{
|
||||||
|
switch (request)
|
||||||
|
{
|
||||||
|
case GetChangelogRequest changelogRequest:
|
||||||
|
var changelogResponse = new APIChangelogIndex
|
||||||
|
{
|
||||||
|
Streams = streams.Values.ToList(),
|
||||||
|
Builds = builds.Values.ToList()
|
||||||
|
};
|
||||||
|
changelogRequest.TriggerSuccess(changelogResponse);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GetChangelogBuildRequest buildRequest:
|
||||||
|
if (requestedBuild != null)
|
||||||
|
buildRequest.TriggerSuccess(requestedBuild);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Child = changelog = new TestChangelogOverlay();
|
Child = changelog = new TestChangelogOverlay();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -41,26 +94,60 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
[Ignore("needs to be updated to not be so server dependent")]
|
|
||||||
public void ShowWithBuild()
|
public void ShowWithBuild()
|
||||||
{
|
{
|
||||||
AddStep(@"Show with Lazer 2018.712.0", () =>
|
showBuild(() => new APIChangelogBuild
|
||||||
{
|
{
|
||||||
changelog.ShowBuild(new APIChangelogBuild
|
Version = "2018.712.0",
|
||||||
|
DisplayVersion = "2018.712.0",
|
||||||
|
UpdateStream = streams[OsuGameBase.CLIENT_STREAM_NAME],
|
||||||
|
ChangelogEntries = new List<APIChangelogEntry>
|
||||||
{
|
{
|
||||||
Version = "2018.712.0",
|
new APIChangelogEntry
|
||||||
DisplayVersion = "2018.712.0",
|
|
||||||
UpdateStream = new APIUpdateStream { Id = 5, Name = OsuGameBase.CLIENT_STREAM_NAME },
|
|
||||||
ChangelogEntries = new List<APIChangelogEntry>
|
|
||||||
{
|
{
|
||||||
new APIChangelogEntry
|
Type = ChangelogEntryType.Fix,
|
||||||
|
Category = "osu!",
|
||||||
|
Title = "Fix thing",
|
||||||
|
MessageHtml = "Additional info goes here.",
|
||||||
|
Repository = "osu",
|
||||||
|
GithubPullRequestId = 11100,
|
||||||
|
GithubUser = new APIChangelogUser
|
||||||
{
|
{
|
||||||
Category = "Test",
|
OsuUsername = "smoogipoo",
|
||||||
Title = "Title",
|
UserId = 1040328
|
||||||
MessageHtml = "Message",
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
new APIChangelogEntry
|
||||||
|
{
|
||||||
|
Type = ChangelogEntryType.Add,
|
||||||
|
Category = "osu!",
|
||||||
|
Title = "Add thing",
|
||||||
|
Major = true,
|
||||||
|
Repository = "ppy/osu-framework",
|
||||||
|
GithubPullRequestId = 4444,
|
||||||
|
GithubUser = new APIChangelogUser
|
||||||
|
{
|
||||||
|
DisplayName = "frenzibyte",
|
||||||
|
GithubUrl = "https://github.com/frenzibyte"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new APIChangelogEntry
|
||||||
|
{
|
||||||
|
Type = ChangelogEntryType.Misc,
|
||||||
|
Category = "Code quality",
|
||||||
|
Title = "Clean up thing",
|
||||||
|
GithubUser = new APIChangelogUser
|
||||||
|
{
|
||||||
|
DisplayName = "some dude"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new APIChangelogEntry
|
||||||
|
{
|
||||||
|
Type = ChangelogEntryType.Misc,
|
||||||
|
Category = "Code quality",
|
||||||
|
Title = "Clean up another thing"
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
AddUntilStep(@"wait for streams", () => changelog.Streams?.Count > 0);
|
AddUntilStep(@"wait for streams", () => changelog.Streams?.Count > 0);
|
||||||
@ -71,35 +158,38 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestHTMLUnescaping()
|
public void TestHTMLUnescaping()
|
||||||
{
|
{
|
||||||
AddStep(@"Ensure HTML string unescaping", () =>
|
showBuild(() => new APIChangelogBuild
|
||||||
{
|
{
|
||||||
changelog.ShowBuild(new APIChangelogBuild
|
Version = "2019.920.0",
|
||||||
|
DisplayVersion = "2019.920.0",
|
||||||
|
UpdateStream = new APIUpdateStream
|
||||||
{
|
{
|
||||||
Version = "2019.920.0",
|
Name = "Test",
|
||||||
DisplayVersion = "2019.920.0",
|
DisplayName = "Test"
|
||||||
UpdateStream = new APIUpdateStream
|
},
|
||||||
|
ChangelogEntries = new List<APIChangelogEntry>
|
||||||
|
{
|
||||||
|
new APIChangelogEntry
|
||||||
{
|
{
|
||||||
Name = "Test",
|
Category = "Testing HTML strings unescaping",
|
||||||
DisplayName = "Test"
|
Title = "Ensuring HTML strings are being unescaped",
|
||||||
},
|
MessageHtml = """"This text should appear triple-quoted""" >_<",
|
||||||
ChangelogEntries = new List<APIChangelogEntry>
|
GithubUser = new APIChangelogUser
|
||||||
{
|
|
||||||
new APIChangelogEntry
|
|
||||||
{
|
{
|
||||||
Category = "Testing HTML strings unescaping",
|
DisplayName = "Dummy",
|
||||||
Title = "Ensuring HTML strings are being unescaped",
|
OsuUsername = "Dummy",
|
||||||
MessageHtml = """"This text should appear triple-quoted""" >_<",
|
}
|
||||||
GithubUser = new APIChangelogUser
|
},
|
||||||
{
|
}
|
||||||
DisplayName = "Dummy",
|
|
||||||
OsuUsername = "Dummy",
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showBuild(Func<APIChangelogBuild> build)
|
||||||
|
{
|
||||||
|
AddStep("set up build", () => requestedBuild = build.Invoke());
|
||||||
|
AddStep("show build", () => changelog.ShowBuild(requestedBuild));
|
||||||
|
}
|
||||||
|
|
||||||
private class TestChangelogOverlay : ChangelogOverlay
|
private class TestChangelogOverlay : ChangelogOverlay
|
||||||
{
|
{
|
||||||
public new List<APIUpdateStream> Streams => base.Streams;
|
public new List<APIUpdateStream> Streams => base.Streams;
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using osu.Framework.Graphics.Colour;
|
using osu.Framework.Graphics.Colour;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
@ -27,34 +28,16 @@ namespace osu.Game.Online.API.Requests.Responses
|
|||||||
|
|
||||||
public bool Equals(APIUpdateStream other) => Id == other?.Id;
|
public bool Equals(APIUpdateStream other) => Id == other?.Id;
|
||||||
|
|
||||||
public ColourInfo Colour
|
internal static readonly Dictionary<string, Color4> KNOWN_STREAMS = new Dictionary<string, Color4>
|
||||||
{
|
{
|
||||||
get
|
["stable40"] = new Color4(102, 204, 255, 255),
|
||||||
{
|
["stable"] = new Color4(34, 153, 187, 255),
|
||||||
switch (Name)
|
["beta40"] = new Color4(255, 221, 85, 255),
|
||||||
{
|
["cuttingedge"] = new Color4(238, 170, 0, 255),
|
||||||
case "stable40":
|
[OsuGameBase.CLIENT_STREAM_NAME] = new Color4(237, 18, 33, 255),
|
||||||
return new Color4(102, 204, 255, 255);
|
["web"] = new Color4(136, 102, 238, 255)
|
||||||
|
};
|
||||||
|
|
||||||
case "stable":
|
public ColourInfo Colour => KNOWN_STREAMS.TryGetValue(Name, out var colour) ? colour : new Color4(0, 0, 0, 255);
|
||||||
return new Color4(34, 153, 187, 255);
|
|
||||||
|
|
||||||
case "beta40":
|
|
||||||
return new Color4(255, 221, 85, 255);
|
|
||||||
|
|
||||||
case "cuttingedge":
|
|
||||||
return new Color4(238, 170, 0, 255);
|
|
||||||
|
|
||||||
case OsuGameBase.CLIENT_STREAM_NAME:
|
|
||||||
return new Color4(237, 18, 33, 255);
|
|
||||||
|
|
||||||
case "web":
|
|
||||||
return new Color4(136, 102, 238, 255);
|
|
||||||
|
|
||||||
default:
|
|
||||||
return new Color4(0, 0, 0, 255);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ namespace osu.Game.Online.Leaderboards
|
|||||||
|
|
||||||
statisticsLabels = GetStatistics(score).Select(s => new ScoreComponentLabel(s)).ToList();
|
statisticsLabels = GetStatistics(score).Select(s => new ScoreComponentLabel(s)).ToList();
|
||||||
|
|
||||||
DrawableAvatar innerAvatar;
|
ClickableAvatar innerAvatar;
|
||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
@ -115,7 +115,7 @@ namespace osu.Game.Online.Leaderboards
|
|||||||
Children = new[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
avatar = new DelayedLoadWrapper(
|
avatar = new DelayedLoadWrapper(
|
||||||
innerAvatar = new DrawableAvatar(user)
|
innerAvatar = new ClickableAvatar(user)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
CornerRadius = corner_radius,
|
CornerRadius = corner_radius,
|
||||||
|
@ -9,6 +9,7 @@ using osu.Framework.Graphics.Containers;
|
|||||||
using osu.Framework.Graphics.Effects;
|
using osu.Framework.Graphics.Effects;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
|
using osu.Framework.Threading;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
@ -93,6 +94,11 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
if (welcomeScreen.GetChildScreen() != null)
|
if (welcomeScreen.GetChildScreen() != null)
|
||||||
welcomeScreen.MakeCurrent();
|
welcomeScreen.MakeCurrent();
|
||||||
|
|
||||||
|
// there might be a stale scheduled hide from a previous API state change.
|
||||||
|
// cancel it here so that the overlay is not hidden again after one frame.
|
||||||
|
scheduledHide?.Cancel();
|
||||||
|
scheduledHide = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void PopOut()
|
protected override void PopOut()
|
||||||
@ -101,7 +107,9 @@ namespace osu.Game.Overlays
|
|||||||
this.FadeOut(100);
|
this.FadeOut(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void apiStateChanged(ValueChangedEvent<APIState> state) => Schedule(() =>
|
private ScheduledDelegate scheduledHide;
|
||||||
|
|
||||||
|
private void apiStateChanged(ValueChangedEvent<APIState> state)
|
||||||
{
|
{
|
||||||
switch (state.NewValue)
|
switch (state.NewValue)
|
||||||
{
|
{
|
||||||
@ -113,9 +121,10 @@ namespace osu.Game.Overlays
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case APIState.Online:
|
case APIState.Online:
|
||||||
Hide();
|
scheduledHide?.Cancel();
|
||||||
|
scheduledHide = Schedule(Hide);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,14 +9,8 @@ using osu.Game.Graphics.Containers;
|
|||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Users;
|
|
||||||
using osuTK.Graphics;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using System.Net;
|
|
||||||
using osuTK;
|
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Changelog
|
namespace osu.Game.Overlays.Changelog
|
||||||
{
|
{
|
||||||
@ -63,126 +57,7 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
Margin = new MarginPadding { Top = 35, Bottom = 15 },
|
Margin = new MarginPadding { Top = 35, Bottom = 15 },
|
||||||
});
|
});
|
||||||
|
|
||||||
var fontLarge = OsuFont.GetFont(size: 16);
|
ChangelogEntries.AddRange(categoryEntries.Select(entry => new ChangelogEntry(entry)));
|
||||||
var fontMedium = OsuFont.GetFont(size: 12);
|
|
||||||
|
|
||||||
foreach (var entry in categoryEntries)
|
|
||||||
{
|
|
||||||
var entryColour = entry.Major ? colours.YellowLight : Color4.White;
|
|
||||||
|
|
||||||
LinkFlowContainer title;
|
|
||||||
|
|
||||||
var titleContainer = new Container
|
|
||||||
{
|
|
||||||
AutoSizeAxes = Axes.Y,
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
Margin = new MarginPadding { Vertical = 5 },
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new SpriteIcon
|
|
||||||
{
|
|
||||||
Anchor = Anchor.CentreLeft,
|
|
||||||
Origin = Anchor.CentreRight,
|
|
||||||
Size = new Vector2(10),
|
|
||||||
Icon = entry.Type == ChangelogEntryType.Fix ? FontAwesome.Solid.Check : FontAwesome.Solid.Plus,
|
|
||||||
Colour = entryColour.Opacity(0.5f),
|
|
||||||
Margin = new MarginPadding { Right = 5 },
|
|
||||||
},
|
|
||||||
title = new LinkFlowContainer
|
|
||||||
{
|
|
||||||
Direction = FillDirection.Full,
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
AutoSizeAxes = Axes.Y,
|
|
||||||
TextAnchor = Anchor.BottomLeft,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
title.AddText(entry.Title, t =>
|
|
||||||
{
|
|
||||||
t.Font = fontLarge;
|
|
||||||
t.Colour = entryColour;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(entry.Repository))
|
|
||||||
{
|
|
||||||
title.AddText(" (", t =>
|
|
||||||
{
|
|
||||||
t.Font = fontLarge;
|
|
||||||
t.Colour = entryColour;
|
|
||||||
});
|
|
||||||
title.AddLink($"{entry.Repository.Replace("ppy/", "")}#{entry.GithubPullRequestId}", entry.GithubUrl,
|
|
||||||
creationParameters: t =>
|
|
||||||
{
|
|
||||||
t.Font = fontLarge;
|
|
||||||
t.Colour = entryColour;
|
|
||||||
});
|
|
||||||
title.AddText(")", t =>
|
|
||||||
{
|
|
||||||
t.Font = fontLarge;
|
|
||||||
t.Colour = entryColour;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
title.AddText("by ", t =>
|
|
||||||
{
|
|
||||||
t.Font = fontMedium;
|
|
||||||
t.Colour = entryColour;
|
|
||||||
t.Padding = new MarginPadding { Left = 10 };
|
|
||||||
});
|
|
||||||
|
|
||||||
if (entry.GithubUser != null)
|
|
||||||
{
|
|
||||||
if (entry.GithubUser.UserId != null)
|
|
||||||
{
|
|
||||||
title.AddUserLink(new User
|
|
||||||
{
|
|
||||||
Username = entry.GithubUser.OsuUsername,
|
|
||||||
Id = entry.GithubUser.UserId.Value
|
|
||||||
}, t =>
|
|
||||||
{
|
|
||||||
t.Font = fontMedium;
|
|
||||||
t.Colour = entryColour;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else if (entry.GithubUser.GithubUrl != null)
|
|
||||||
{
|
|
||||||
title.AddLink(entry.GithubUser.DisplayName, entry.GithubUser.GithubUrl, t =>
|
|
||||||
{
|
|
||||||
t.Font = fontMedium;
|
|
||||||
t.Colour = entryColour;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
title.AddText(entry.GithubUser.DisplayName, t =>
|
|
||||||
{
|
|
||||||
t.Font = fontMedium;
|
|
||||||
t.Colour = entryColour;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ChangelogEntries.Add(titleContainer);
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(entry.MessageHtml))
|
|
||||||
{
|
|
||||||
var message = new TextFlowContainer
|
|
||||||
{
|
|
||||||
AutoSizeAxes = Axes.Y,
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
};
|
|
||||||
|
|
||||||
// todo: use markdown parsing once API returns markdown
|
|
||||||
message.AddText(WebUtility.HtmlDecode(Regex.Replace(entry.MessageHtml, @"<(.|\n)*?>", string.Empty)), t =>
|
|
||||||
{
|
|
||||||
t.Font = fontMedium;
|
|
||||||
t.Colour = colourProvider.Foreground1;
|
|
||||||
});
|
|
||||||
|
|
||||||
ChangelogEntries.Add(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
202
osu.Game/Overlays/Changelog/ChangelogEntry.cs
Normal file
202
osu.Game/Overlays/Changelog/ChangelogEntry.cs
Normal file
@ -0,0 +1,202 @@
|
|||||||
|
// 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.Net;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
|
using osu.Game.Users;
|
||||||
|
using osuTK;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.Changelog
|
||||||
|
{
|
||||||
|
public class ChangelogEntry : FillFlowContainer
|
||||||
|
{
|
||||||
|
private readonly APIChangelogEntry entry;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OsuColour colours { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OverlayColourProvider colourProvider { get; set; }
|
||||||
|
|
||||||
|
private FontUsage fontLarge;
|
||||||
|
private FontUsage fontMedium;
|
||||||
|
|
||||||
|
public ChangelogEntry(APIChangelogEntry entry)
|
||||||
|
{
|
||||||
|
this.entry = entry;
|
||||||
|
|
||||||
|
RelativeSizeAxes = Axes.X;
|
||||||
|
AutoSizeAxes = Axes.Y;
|
||||||
|
Direction = FillDirection.Vertical;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
fontLarge = OsuFont.GetFont(size: 16);
|
||||||
|
fontMedium = OsuFont.GetFont(size: 12);
|
||||||
|
|
||||||
|
Children = new[]
|
||||||
|
{
|
||||||
|
createTitle(),
|
||||||
|
createMessage()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private Drawable createTitle()
|
||||||
|
{
|
||||||
|
var entryColour = entry.Major ? colours.YellowLight : Color4.White;
|
||||||
|
|
||||||
|
LinkFlowContainer title;
|
||||||
|
|
||||||
|
var titleContainer = new Container
|
||||||
|
{
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Margin = new MarginPadding { Vertical = 5 },
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new SpriteIcon
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreLeft,
|
||||||
|
Origin = Anchor.CentreRight,
|
||||||
|
Size = new Vector2(10),
|
||||||
|
Icon = getIconForChangelogEntry(entry.Type),
|
||||||
|
Colour = entryColour.Opacity(0.5f),
|
||||||
|
Margin = new MarginPadding { Right = 5 },
|
||||||
|
},
|
||||||
|
title = new LinkFlowContainer
|
||||||
|
{
|
||||||
|
Direction = FillDirection.Full,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
TextAnchor = Anchor.BottomLeft,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
title.AddText(entry.Title, t =>
|
||||||
|
{
|
||||||
|
t.Font = fontLarge;
|
||||||
|
t.Colour = entryColour;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(entry.Repository))
|
||||||
|
addRepositoryReference(title, entryColour);
|
||||||
|
|
||||||
|
if (entry.GithubUser != null)
|
||||||
|
addGithubAuthorReference(title, entryColour);
|
||||||
|
|
||||||
|
return titleContainer;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addRepositoryReference(LinkFlowContainer title, Color4 entryColour)
|
||||||
|
{
|
||||||
|
title.AddText(" (", t =>
|
||||||
|
{
|
||||||
|
t.Font = fontLarge;
|
||||||
|
t.Colour = entryColour;
|
||||||
|
});
|
||||||
|
title.AddLink($"{entry.Repository.Replace("ppy/", "")}#{entry.GithubPullRequestId}", entry.GithubUrl,
|
||||||
|
t =>
|
||||||
|
{
|
||||||
|
t.Font = fontLarge;
|
||||||
|
t.Colour = entryColour;
|
||||||
|
});
|
||||||
|
title.AddText(")", t =>
|
||||||
|
{
|
||||||
|
t.Font = fontLarge;
|
||||||
|
t.Colour = entryColour;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addGithubAuthorReference(LinkFlowContainer title, Color4 entryColour)
|
||||||
|
{
|
||||||
|
title.AddText("by ", t =>
|
||||||
|
{
|
||||||
|
t.Font = fontMedium;
|
||||||
|
t.Colour = entryColour;
|
||||||
|
t.Padding = new MarginPadding { Left = 10 };
|
||||||
|
});
|
||||||
|
|
||||||
|
if (entry.GithubUser.UserId != null)
|
||||||
|
{
|
||||||
|
title.AddUserLink(new User
|
||||||
|
{
|
||||||
|
Username = entry.GithubUser.OsuUsername,
|
||||||
|
Id = entry.GithubUser.UserId.Value
|
||||||
|
}, t =>
|
||||||
|
{
|
||||||
|
t.Font = fontMedium;
|
||||||
|
t.Colour = entryColour;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (entry.GithubUser.GithubUrl != null)
|
||||||
|
{
|
||||||
|
title.AddLink(entry.GithubUser.DisplayName, entry.GithubUser.GithubUrl, t =>
|
||||||
|
{
|
||||||
|
t.Font = fontMedium;
|
||||||
|
t.Colour = entryColour;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
title.AddText(entry.GithubUser.DisplayName, t =>
|
||||||
|
{
|
||||||
|
t.Font = fontMedium;
|
||||||
|
t.Colour = entryColour;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Drawable createMessage()
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(entry.MessageHtml))
|
||||||
|
return Empty();
|
||||||
|
|
||||||
|
var message = new TextFlowContainer
|
||||||
|
{
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
};
|
||||||
|
|
||||||
|
// todo: use markdown parsing once API returns markdown
|
||||||
|
message.AddText(WebUtility.HtmlDecode(Regex.Replace(entry.MessageHtml, @"<(.|\n)*?>", string.Empty)), t =>
|
||||||
|
{
|
||||||
|
t.Font = fontMedium;
|
||||||
|
t.Colour = colourProvider.Foreground1;
|
||||||
|
});
|
||||||
|
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IconUsage getIconForChangelogEntry(ChangelogEntryType entryType)
|
||||||
|
{
|
||||||
|
// compare: https://github.com/ppy/osu-web/blob/master/resources/assets/coffee/react/_components/changelog-entry.coffee#L8-L11
|
||||||
|
switch (entryType)
|
||||||
|
{
|
||||||
|
case ChangelogEntryType.Add:
|
||||||
|
return FontAwesome.Solid.Plus;
|
||||||
|
|
||||||
|
case ChangelogEntryType.Fix:
|
||||||
|
return FontAwesome.Solid.Check;
|
||||||
|
|
||||||
|
case ChangelogEntryType.Misc:
|
||||||
|
return FontAwesome.Regular.Circle;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new ArgumentOutOfRangeException(nameof(entryType), $"Unrecognised entry type {entryType}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -8,5 +8,11 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
public class ChangelogUpdateStreamControl : OverlayStreamControl<APIUpdateStream>
|
public class ChangelogUpdateStreamControl : OverlayStreamControl<APIUpdateStream>
|
||||||
{
|
{
|
||||||
protected override OverlayStreamItem<APIUpdateStream> CreateStreamItem(APIUpdateStream value) => new ChangelogUpdateStreamItem(value);
|
protected override OverlayStreamItem<APIUpdateStream> CreateStreamItem(APIUpdateStream value) => new ChangelogUpdateStreamItem(value);
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
// suppress base logic of immediately selecting first item if one exists
|
||||||
|
// (we always want to start with no stream selected).
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ namespace osu.Game.Overlays.Chat.Tabs
|
|||||||
if (value.Type != ChannelType.PM)
|
if (value.Type != ChannelType.PM)
|
||||||
throw new ArgumentException("Argument value needs to have the targettype user!");
|
throw new ArgumentException("Argument value needs to have the targettype user!");
|
||||||
|
|
||||||
DrawableAvatar avatar;
|
ClickableAvatar avatar;
|
||||||
|
|
||||||
AddRange(new Drawable[]
|
AddRange(new Drawable[]
|
||||||
{
|
{
|
||||||
@ -48,7 +48,7 @@ namespace osu.Game.Overlays.Chat.Tabs
|
|||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Masking = true,
|
Masking = true,
|
||||||
Child = new DelayedLoadWrapper(avatar = new DrawableAvatar(value.Users.First())
|
Child = new DelayedLoadWrapper(avatar = new ClickableAvatar(value.Users.First())
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
OpenOnClick = { Value = false },
|
OpenOnClick = { Value = false },
|
||||||
|
@ -34,6 +34,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
public BindableDouble TotalScore { get; } = new BindableDouble();
|
public BindableDouble TotalScore { get; } = new BindableDouble();
|
||||||
public BindableDouble Accuracy { get; } = new BindableDouble(1);
|
public BindableDouble Accuracy { get; } = new BindableDouble(1);
|
||||||
public BindableInt Combo { get; } = new BindableInt();
|
public BindableInt Combo { get; } = new BindableInt();
|
||||||
|
public BindableBool HasQuit { get; } = new BindableBool();
|
||||||
|
|
||||||
private int? scorePosition;
|
private int? scorePosition;
|
||||||
|
|
||||||
@ -51,7 +52,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
positionText.Text = $"#{scorePosition.Value.FormatRank()}";
|
positionText.Text = $"#{scorePosition.Value.FormatRank()}";
|
||||||
|
|
||||||
positionText.FadeTo(scorePosition.HasValue ? 1 : 0);
|
positionText.FadeTo(scorePosition.HasValue ? 1 : 0);
|
||||||
updateColour();
|
updateState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,6 +79,8 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
|
Container avatarContainer;
|
||||||
|
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
mainFillContainer = new Container
|
mainFillContainer = new Container
|
||||||
@ -152,7 +155,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
Spacing = new Vector2(4f, 0f),
|
Spacing = new Vector2(4f, 0f),
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new CircularContainer
|
avatarContainer = new CircularContainer
|
||||||
{
|
{
|
||||||
Masking = true,
|
Masking = true,
|
||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
@ -166,11 +169,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
Alpha = 0.3f,
|
Alpha = 0.3f,
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Colour = colours.Gray4,
|
Colour = colours.Gray4,
|
||||||
},
|
}
|
||||||
new UpdateableAvatar(User)
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
usernameText = new OsuSpriteText
|
usernameText = new OsuSpriteText
|
||||||
@ -227,23 +226,36 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
LoadComponentAsync(new DrawableAvatar(User), avatarContainer.Add);
|
||||||
|
|
||||||
TotalScore.BindValueChanged(v => scoreText.Text = v.NewValue.ToString("N0"), true);
|
TotalScore.BindValueChanged(v => scoreText.Text = v.NewValue.ToString("N0"), true);
|
||||||
Accuracy.BindValueChanged(v => accuracyText.Text = v.NewValue.FormatAccuracy(), true);
|
Accuracy.BindValueChanged(v => accuracyText.Text = v.NewValue.FormatAccuracy(), true);
|
||||||
Combo.BindValueChanged(v => comboText.Text = $"{v.NewValue}x", true);
|
Combo.BindValueChanged(v => comboText.Text = $"{v.NewValue}x", true);
|
||||||
|
HasQuit.BindValueChanged(_ => updateState());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
updateColour();
|
updateState();
|
||||||
FinishTransforms(true);
|
FinishTransforms(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private const double panel_transition_duration = 500;
|
private const double panel_transition_duration = 500;
|
||||||
|
|
||||||
private void updateColour()
|
private void updateState()
|
||||||
{
|
{
|
||||||
|
if (HasQuit.Value)
|
||||||
|
{
|
||||||
|
// we will probably want to display this in a better way once we have a design.
|
||||||
|
// and also show states other than quit.
|
||||||
|
mainFillContainer.ResizeWidthTo(regular_width, panel_transition_duration, Easing.OutElastic);
|
||||||
|
panelColour = Color4.Gray;
|
||||||
|
textColour = Color4.White;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (scorePosition == 1)
|
if (scorePosition == 1)
|
||||||
{
|
{
|
||||||
mainFillContainer.ResizeWidthTo(EXTENDED_WIDTH, panel_transition_duration, Easing.OutElastic);
|
mainFillContainer.ResizeWidthTo(EXTENDED_WIDTH, panel_transition_duration, Easing.OutElastic);
|
||||||
|
@ -10,5 +10,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
BindableDouble TotalScore { get; }
|
BindableDouble TotalScore { get; }
|
||||||
BindableDouble Accuracy { get; }
|
BindableDouble Accuracy { get; }
|
||||||
BindableInt Combo { get; }
|
BindableInt Combo { get; }
|
||||||
|
|
||||||
|
BindableBool HasQuit { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,15 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.Specialized;
|
||||||
|
using System.Linq;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
|
using osu.Game.Online.Multiplayer;
|
||||||
using osu.Game.Online.Spectator;
|
using osu.Game.Online.Spectator;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
|
||||||
@ -18,10 +21,21 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
{
|
{
|
||||||
private readonly ScoreProcessor scoreProcessor;
|
private readonly ScoreProcessor scoreProcessor;
|
||||||
|
|
||||||
private readonly int[] userIds;
|
|
||||||
|
|
||||||
private readonly Dictionary<int, TrackedUserData> userScores = new Dictionary<int, TrackedUserData>();
|
private readonly Dictionary<int, TrackedUserData> userScores = new Dictionary<int, TrackedUserData>();
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private SpectatorStreamingClient streamingClient { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private StatefulMultiplayerClient multiplayerClient { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private UserLookupCache userLookupCache { get; set; }
|
||||||
|
|
||||||
|
private Bindable<ScoringMode> scoringMode;
|
||||||
|
|
||||||
|
private readonly BindableList<int> playingUsers;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Construct a new leaderboard.
|
/// Construct a new leaderboard.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -33,43 +47,68 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
this.scoreProcessor = scoreProcessor;
|
this.scoreProcessor = scoreProcessor;
|
||||||
|
|
||||||
// todo: this will likely be passed in as User instances.
|
// todo: this will likely be passed in as User instances.
|
||||||
this.userIds = userIds;
|
playingUsers = new BindableList<int>(userIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Resolved]
|
|
||||||
private SpectatorStreamingClient streamingClient { get; set; }
|
|
||||||
|
|
||||||
[Resolved]
|
|
||||||
private UserLookupCache userLookupCache { get; set; }
|
|
||||||
|
|
||||||
private Bindable<ScoringMode> scoringMode;
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuConfigManager config, IAPIProvider api)
|
private void load(OsuConfigManager config, IAPIProvider api)
|
||||||
{
|
{
|
||||||
streamingClient.OnNewFrames += handleIncomingFrames;
|
streamingClient.OnNewFrames += handleIncomingFrames;
|
||||||
|
|
||||||
foreach (var user in userIds)
|
foreach (var userId in playingUsers)
|
||||||
{
|
{
|
||||||
streamingClient.WatchUser(user);
|
streamingClient.WatchUser(userId);
|
||||||
|
|
||||||
// probably won't be required in the final implementation.
|
// probably won't be required in the final implementation.
|
||||||
var resolvedUser = userLookupCache.GetUserAsync(user).Result;
|
var resolvedUser = userLookupCache.GetUserAsync(userId).Result;
|
||||||
|
|
||||||
var trackedUser = new TrackedUserData();
|
var trackedUser = new TrackedUserData();
|
||||||
|
|
||||||
userScores[user] = trackedUser;
|
userScores[userId] = trackedUser;
|
||||||
var leaderboardScore = AddPlayer(resolvedUser, resolvedUser.Id == api.LocalUser.Value.Id);
|
var leaderboardScore = AddPlayer(resolvedUser, resolvedUser.Id == api.LocalUser.Value.Id);
|
||||||
|
|
||||||
((IBindable<double>)leaderboardScore.Accuracy).BindTo(trackedUser.Accuracy);
|
((IBindable<double>)leaderboardScore.Accuracy).BindTo(trackedUser.Accuracy);
|
||||||
((IBindable<double>)leaderboardScore.TotalScore).BindTo(trackedUser.Score);
|
((IBindable<double>)leaderboardScore.TotalScore).BindTo(trackedUser.Score);
|
||||||
((IBindable<int>)leaderboardScore.Combo).BindTo(trackedUser.CurrentCombo);
|
((IBindable<int>)leaderboardScore.Combo).BindTo(trackedUser.CurrentCombo);
|
||||||
|
((IBindable<bool>)leaderboardScore.HasQuit).BindTo(trackedUser.UserQuit);
|
||||||
}
|
}
|
||||||
|
|
||||||
scoringMode = config.GetBindable<ScoringMode>(OsuSetting.ScoreDisplayMode);
|
scoringMode = config.GetBindable<ScoringMode>(OsuSetting.ScoreDisplayMode);
|
||||||
scoringMode.BindValueChanged(updateAllScores, true);
|
scoringMode.BindValueChanged(updateAllScores, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
// BindableList handles binding in a really bad way (Clear then AddRange) so we need to do this manually..
|
||||||
|
foreach (int userId in playingUsers)
|
||||||
|
{
|
||||||
|
if (!multiplayerClient.PlayingUsers.Contains(userId))
|
||||||
|
usersChanged(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, new[] { userId }));
|
||||||
|
}
|
||||||
|
|
||||||
|
playingUsers.BindTo(multiplayerClient.PlayingUsers);
|
||||||
|
playingUsers.BindCollectionChanged(usersChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void usersChanged(object sender, NotifyCollectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
switch (e.Action)
|
||||||
|
{
|
||||||
|
case NotifyCollectionChangedAction.Remove:
|
||||||
|
foreach (var userId in e.OldItems.OfType<int>())
|
||||||
|
{
|
||||||
|
streamingClient.StopWatchingUser(userId);
|
||||||
|
|
||||||
|
if (userScores.TryGetValue(userId, out var trackedData))
|
||||||
|
trackedData.MarkUserQuit();
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void updateAllScores(ValueChangedEvent<ScoringMode> mode)
|
private void updateAllScores(ValueChangedEvent<ScoringMode> mode)
|
||||||
{
|
{
|
||||||
foreach (var trackedData in userScores.Values)
|
foreach (var trackedData in userScores.Values)
|
||||||
@ -91,7 +130,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
|
|
||||||
if (streamingClient != null)
|
if (streamingClient != null)
|
||||||
{
|
{
|
||||||
foreach (var user in userIds)
|
foreach (var user in playingUsers)
|
||||||
{
|
{
|
||||||
streamingClient.StopWatchingUser(user);
|
streamingClient.StopWatchingUser(user);
|
||||||
}
|
}
|
||||||
@ -114,9 +153,15 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
|
|
||||||
private readonly BindableInt currentCombo = new BindableInt();
|
private readonly BindableInt currentCombo = new BindableInt();
|
||||||
|
|
||||||
|
public IBindable<bool> UserQuit => userQuit;
|
||||||
|
|
||||||
|
private readonly BindableBool userQuit = new BindableBool();
|
||||||
|
|
||||||
[CanBeNull]
|
[CanBeNull]
|
||||||
public FrameHeader LastHeader;
|
public FrameHeader LastHeader;
|
||||||
|
|
||||||
|
public void MarkUserQuit() => userQuit.Value = true;
|
||||||
|
|
||||||
public void UpdateScore(ScoreProcessor processor, ScoringMode mode)
|
public void UpdateScore(ScoreProcessor processor, ScoringMode mode)
|
||||||
{
|
{
|
||||||
if (LastHeader == null)
|
if (LastHeader == null)
|
||||||
|
73
osu.Game/Users/Drawables/ClickableAvatar.cs
Normal file
73
osu.Game/Users/Drawables/ClickableAvatar.cs
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
// 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 osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Textures;
|
||||||
|
using osu.Framework.Input.Events;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
|
|
||||||
|
namespace osu.Game.Users.Drawables
|
||||||
|
{
|
||||||
|
public class ClickableAvatar : Container
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Whether to open the user's profile when clicked.
|
||||||
|
/// </summary>
|
||||||
|
public readonly BindableBool OpenOnClick = new BindableBool(true);
|
||||||
|
|
||||||
|
private readonly User user;
|
||||||
|
|
||||||
|
[Resolved(CanBeNull = true)]
|
||||||
|
private OsuGame game { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A clickable avatar for the specified user, with UI sounds included.
|
||||||
|
/// If <see cref="OpenOnClick"/> is <c>true</c>, clicking will open the user's profile.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="user">The user. A null value will get a placeholder avatar.</param>
|
||||||
|
public ClickableAvatar(User user = null)
|
||||||
|
{
|
||||||
|
this.user = user;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(LargeTextureStore textures)
|
||||||
|
{
|
||||||
|
ClickableArea clickableArea;
|
||||||
|
Add(clickableArea = new ClickableArea
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Action = openProfile
|
||||||
|
});
|
||||||
|
|
||||||
|
LoadComponentAsync(new DrawableAvatar(user), clickableArea.Add);
|
||||||
|
|
||||||
|
clickableArea.Enabled.BindTo(OpenOnClick);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void openProfile()
|
||||||
|
{
|
||||||
|
if (!OpenOnClick.Value)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (user?.Id > 1)
|
||||||
|
game?.ShowUser(user.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ClickableArea : OsuClickableContainer
|
||||||
|
{
|
||||||
|
public override string TooltipText => Enabled.Value ? @"view profile" : null;
|
||||||
|
|
||||||
|
protected override bool OnClick(ClickEvent e)
|
||||||
|
{
|
||||||
|
if (!Enabled.Value)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return base.OnClick(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,88 +1,45 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
using osu.Framework.Input.Events;
|
|
||||||
using osu.Game.Graphics.Containers;
|
|
||||||
|
|
||||||
namespace osu.Game.Users.Drawables
|
namespace osu.Game.Users.Drawables
|
||||||
{
|
{
|
||||||
[LongRunningLoad]
|
[LongRunningLoad]
|
||||||
public class DrawableAvatar : Container
|
public class DrawableAvatar : Sprite
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Whether to open the user's profile when clicked.
|
|
||||||
/// </summary>
|
|
||||||
public readonly BindableBool OpenOnClick = new BindableBool(true);
|
|
||||||
|
|
||||||
private readonly User user;
|
private readonly User user;
|
||||||
|
|
||||||
[Resolved(CanBeNull = true)]
|
|
||||||
private OsuGame game { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An avatar for specified user.
|
/// A simple, non-interactable avatar sprite for the specified user.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="user">The user. A null value will get a placeholder avatar.</param>
|
/// <param name="user">The user. A null value will get a placeholder avatar.</param>
|
||||||
public DrawableAvatar(User user = null)
|
public DrawableAvatar(User user = null)
|
||||||
{
|
{
|
||||||
this.user = user;
|
this.user = user;
|
||||||
|
|
||||||
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
FillMode = FillMode.Fit;
|
||||||
|
Anchor = Anchor.Centre;
|
||||||
|
Origin = Anchor.Centre;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(LargeTextureStore textures)
|
private void load(LargeTextureStore textures)
|
||||||
{
|
{
|
||||||
if (textures == null)
|
if (user != null && user.Id > 1)
|
||||||
throw new ArgumentNullException(nameof(textures));
|
Texture = textures.Get($@"https://a.ppy.sh/{user.Id}");
|
||||||
|
|
||||||
Texture texture = null;
|
Texture ??= textures.Get(@"Online/avatar-guest");
|
||||||
if (user != null && user.Id > 1) texture = textures.Get($@"https://a.ppy.sh/{user.Id}");
|
|
||||||
texture ??= textures.Get(@"Online/avatar-guest");
|
|
||||||
|
|
||||||
ClickableArea clickableArea;
|
|
||||||
Add(clickableArea = new ClickableArea
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Child = new Sprite
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Texture = texture,
|
|
||||||
FillMode = FillMode.Fit,
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre
|
|
||||||
},
|
|
||||||
Action = openProfile
|
|
||||||
});
|
|
||||||
|
|
||||||
clickableArea.Enabled.BindTo(OpenOnClick);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openProfile()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
if (!OpenOnClick.Value)
|
base.LoadComplete();
|
||||||
return;
|
this.FadeInFromZero(300, Easing.OutQuint);
|
||||||
|
|
||||||
if (user?.Id > 1)
|
|
||||||
game?.ShowUser(user.Id);
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ClickableArea : OsuClickableContainer
|
|
||||||
{
|
|
||||||
public override string TooltipText => Enabled.Value ? @"view profile" : null;
|
|
||||||
|
|
||||||
protected override bool OnClick(ClickEvent e)
|
|
||||||
{
|
|
||||||
if (!Enabled.Value)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return base.OnClick(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,12 +65,11 @@ namespace osu.Game.Users.Drawables
|
|||||||
if (user == null && !ShowGuestOnNull)
|
if (user == null && !ShowGuestOnNull)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var avatar = new DrawableAvatar(user)
|
var avatar = new ClickableAvatar(user)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
};
|
};
|
||||||
|
|
||||||
avatar.OnLoadComplete += d => d.FadeInFromZero(300, Easing.OutQuint);
|
|
||||||
avatar.OpenOnClick.BindTo(OpenOnClick);
|
avatar.OpenOnClick.BindTo(OpenOnClick);
|
||||||
|
|
||||||
return avatar;
|
return avatar;
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||||
<PackageReference Include="ppy.osu.Framework" Version="2020.1222.0" />
|
<PackageReference Include="ppy.osu.Framework" Version="2020.1228.0" />
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.1202.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.1202.0" />
|
||||||
<PackageReference Include="Sentry" Version="2.1.8" />
|
<PackageReference Include="Sentry" Version="2.1.8" />
|
||||||
<PackageReference Include="SharpCompress" Version="0.26.0" />
|
<PackageReference Include="SharpCompress" Version="0.26.0" />
|
||||||
|
@ -70,7 +70,7 @@
|
|||||||
<Reference Include="System.Net.Http" />
|
<Reference Include="System.Net.Http" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup Label="Package References">
|
<ItemGroup Label="Package References">
|
||||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2020.1222.0" />
|
<PackageReference Include="ppy.osu.Framework.iOS" Version="2020.1228.0" />
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.1202.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.1202.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net5.0 / net6.0) -->
|
<!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net5.0 / net6.0) -->
|
||||||
@ -88,7 +88,7 @@
|
|||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||||
<PackageReference Include="ppy.osu.Framework" Version="2020.1222.0" />
|
<PackageReference Include="ppy.osu.Framework" Version="2020.1228.0" />
|
||||||
<PackageReference Include="SharpCompress" Version="0.26.0" />
|
<PackageReference Include="SharpCompress" Version="0.26.0" />
|
||||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||||
<PackageReference Include="SharpRaven" Version="2.4.0" />
|
<PackageReference Include="SharpRaven" Version="2.4.0" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user