2020-04-16 16:01:36 +08:00
|
|
|
|
// 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.
|
|
|
|
|
|
2020-04-16 17:05:51 +08:00
|
|
|
|
using System;
|
2023-12-07 01:25:16 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Game.Online.Metadata;
|
|
|
|
|
using osu.Game.Online.Multiplayer;
|
2020-04-16 16:01:36 +08:00
|
|
|
|
using osu.Game.Overlays.Dashboard;
|
2020-04-16 17:05:51 +08:00
|
|
|
|
using osu.Game.Overlays.Dashboard.Friends;
|
2020-04-16 16:01:36 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays
|
|
|
|
|
{
|
2022-11-24 13:32:20 +08:00
|
|
|
|
public partial class DashboardOverlay : TabbableOnlineOverlay<DashboardOverlayHeader, DashboardOverlayTabs>
|
2020-04-16 16:01:36 +08:00
|
|
|
|
{
|
2023-12-07 01:25:16 +08:00
|
|
|
|
[Resolved]
|
|
|
|
|
private MetadataClient metadataClient { get; set; } = null!;
|
|
|
|
|
|
|
|
|
|
private IBindable<bool> metadataConnected = null!;
|
|
|
|
|
|
2020-04-16 16:01:36 +08:00
|
|
|
|
public DashboardOverlay()
|
2021-01-18 15:48:12 +08:00
|
|
|
|
: base(OverlayColourScheme.Purple)
|
2020-04-20 14:34:48 +08:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-18 15:48:12 +08:00
|
|
|
|
protected override DashboardOverlayHeader CreateHeader() => new DashboardOverlayHeader();
|
|
|
|
|
|
2022-05-28 18:04:25 +08:00
|
|
|
|
public override bool AcceptsFocus => false;
|
|
|
|
|
|
2021-01-19 02:22:50 +08:00
|
|
|
|
protected override void CreateDisplayToLoad(DashboardOverlayTabs tab)
|
2020-04-16 17:05:51 +08:00
|
|
|
|
{
|
2021-01-19 02:22:50 +08:00
|
|
|
|
switch (tab)
|
2020-04-16 17:05:51 +08:00
|
|
|
|
{
|
|
|
|
|
case DashboardOverlayTabs.Friends:
|
2021-01-19 02:22:50 +08:00
|
|
|
|
LoadDisplay(new FriendDisplay());
|
2020-04-16 17:05:51 +08:00
|
|
|
|
break;
|
|
|
|
|
|
2020-10-28 16:19:14 +08:00
|
|
|
|
case DashboardOverlayTabs.CurrentlyPlaying:
|
2023-12-07 01:25:16 +08:00
|
|
|
|
LoadDisplay(new CurrentlyOnlineDisplay());
|
2020-10-28 16:19:14 +08:00
|
|
|
|
break;
|
|
|
|
|
|
2020-04-16 17:05:51 +08:00
|
|
|
|
default:
|
2021-01-19 02:22:50 +08:00
|
|
|
|
throw new NotImplementedException($"Display for {tab} tab is not implemented");
|
2020-04-16 17:05:51 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-12-07 01:25:16 +08:00
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
|
|
|
|
metadataConnected = metadataClient.IsConnected.GetBoundCopy();
|
|
|
|
|
metadataConnected.BindValueChanged(_ => updateUserPresenceState());
|
|
|
|
|
State.BindValueChanged(_ => updateUserPresenceState());
|
|
|
|
|
updateUserPresenceState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateUserPresenceState()
|
|
|
|
|
{
|
|
|
|
|
if (!metadataConnected.Value)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (State.Value == Visibility.Visible)
|
|
|
|
|
metadataClient.BeginWatchingUserPresence().FireAndForget();
|
|
|
|
|
else
|
|
|
|
|
metadataClient.EndWatchingUserPresence().FireAndForget();
|
|
|
|
|
}
|
2020-04-16 16:01:36 +08:00
|
|
|
|
}
|
|
|
|
|
}
|