2019-01-24 08:43:03 +00: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.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2019-01-09 06:15:54 +00:00
|
|
|
using System;
|
2018-04-13 09:19:50 +00:00
|
|
|
using osu.Framework.Allocation;
|
2019-02-07 08:59:14 +00:00
|
|
|
using osu.Framework.Configuration;
|
2018-04-13 09:19:50 +00:00
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Colour;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Cursor;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2019-01-09 06:15:54 +00:00
|
|
|
using osu.Game.Online.API;
|
|
|
|
using osu.Game.Online.API.Requests;
|
2018-04-13 09:19:50 +00:00
|
|
|
using osu.Game.Online.Multiplayer;
|
2018-12-10 10:20:41 +00:00
|
|
|
using osu.Game.Screens.Multi.Components;
|
2018-04-13 09:19:50 +00:00
|
|
|
using osu.Game.Users;
|
2018-11-20 07:51:59 +00:00
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2018-12-10 10:20:41 +00:00
|
|
|
namespace osu.Game.Screens.Multi.Lounge.Components
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-02-05 10:00:01 +00:00
|
|
|
public class RoomInspector : MultiplayerComposite
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
|
|
|
private const float transition_duration = 100;
|
|
|
|
|
2018-05-19 05:23:09 +00:00
|
|
|
private readonly MarginPadding contentPadding = new MarginPadding { Horizontal = 20, Vertical = 10 };
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2018-12-26 12:58:14 +00:00
|
|
|
private ParticipantCountDisplay participantCount;
|
2019-02-07 08:59:14 +00:00
|
|
|
private OsuSpriteText name;
|
2018-05-29 02:45:59 +00:00
|
|
|
private BeatmapTypeInfo beatmapTypeInfo;
|
2018-05-19 05:23:09 +00:00
|
|
|
private ParticipantInfo participantInfo;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2018-12-06 03:21:30 +00:00
|
|
|
[Resolved]
|
|
|
|
private BeatmapManager beatmaps { get; set; }
|
|
|
|
|
2019-02-07 08:59:14 +00:00
|
|
|
private readonly Bindable<RoomStatus> status = new Bindable<RoomStatus>(new RoomStatusNoneSelected());
|
|
|
|
|
2018-05-19 04:26:39 +00:00
|
|
|
[BackgroundDependencyLoader]
|
2018-05-29 02:33:13 +00:00
|
|
|
private void load(OsuColour colours)
|
2018-05-19 04:26:39 +00:00
|
|
|
{
|
2019-02-05 10:00:01 +00:00
|
|
|
InternalChildren = new Drawable[]
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = OsuColour.FromHex(@"343138"),
|
|
|
|
},
|
2019-01-09 06:15:54 +00:00
|
|
|
new GridContainer
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-01-09 06:15:54 +00:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
RowDimensions = new[]
|
|
|
|
{
|
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
|
|
|
new Dimension(GridSizeMode.Distributed),
|
|
|
|
},
|
|
|
|
Content = new[]
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-01-09 06:15:54 +00:00
|
|
|
new Drawable[]
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-01-09 06:15:54 +00:00
|
|
|
new FillFlowContainer
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-01-09 06:15:54 +00:00
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
Children = new Drawable[]
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-01-09 06:15:54 +00:00
|
|
|
new Container
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-01-09 06:15:54 +00:00
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Height = 200,
|
|
|
|
Masking = true,
|
|
|
|
Children = new Drawable[]
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-02-05 10:00:01 +00:00
|
|
|
new MultiplayerBackgroundSprite { RelativeSizeAxes = Axes.Both },
|
2019-01-09 06:15:54 +00:00
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = ColourInfo.GradientVertical(Color4.Black.Opacity(0.5f), Color4.Black.Opacity(0)),
|
|
|
|
},
|
|
|
|
new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Padding = new MarginPadding(20),
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
participantCount = new ParticipantCountDisplay
|
|
|
|
{
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
},
|
|
|
|
name = new OsuSpriteText
|
|
|
|
{
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
TextSize = 30,
|
2019-02-07 08:59:14 +00:00
|
|
|
Current = Name
|
2019-01-09 06:15:54 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2018-04-13 09:19:50 +00:00
|
|
|
},
|
2019-01-09 06:15:54 +00:00
|
|
|
},
|
2019-02-07 08:59:14 +00:00
|
|
|
new StatusColouredContainer(transition_duration)
|
2019-01-09 06:15:54 +00:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Height = 5,
|
2019-02-07 08:59:14 +00:00
|
|
|
Child = new Box { RelativeSizeAxes = Axes.Both }
|
2019-01-09 06:15:54 +00:00
|
|
|
},
|
|
|
|
new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Children = new Drawable[]
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-01-09 06:15:54 +00:00
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = OsuColour.FromHex(@"28242d"),
|
|
|
|
},
|
|
|
|
new FillFlowContainer
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
LayoutDuration = transition_duration,
|
|
|
|
Padding = contentPadding,
|
|
|
|
Spacing = new Vector2(0f, 5f),
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2019-02-07 08:59:14 +00:00
|
|
|
new StatusColouredContainer(transition_duration)
|
2019-01-09 06:15:54 +00:00
|
|
|
{
|
2019-02-07 08:59:14 +00:00
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Child = new StatusText
|
|
|
|
{
|
|
|
|
TextSize = 14,
|
|
|
|
Font = @"Exo2.0-Bold",
|
|
|
|
}
|
2019-01-09 06:15:54 +00:00
|
|
|
},
|
|
|
|
beatmapTypeInfo = new BeatmapTypeInfo(),
|
|
|
|
},
|
|
|
|
},
|
2018-04-13 09:19:50 +00:00
|
|
|
},
|
|
|
|
},
|
2019-01-09 06:15:54 +00:00
|
|
|
new Container
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-01-09 06:15:54 +00:00
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Padding = contentPadding,
|
|
|
|
Children = new Drawable[]
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-01-09 06:15:54 +00:00
|
|
|
participantInfo = new ParticipantInfo(),
|
2018-04-13 09:19:50 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-01-09 06:15:54 +00:00
|
|
|
new Drawable[]
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-02-05 10:00:01 +00:00
|
|
|
new MatchParticipants
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-01-09 06:15:54 +00:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-01-08 10:24:55 +00:00
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
};
|
|
|
|
|
2019-02-07 08:59:14 +00:00
|
|
|
Status.BindValueChanged(_ => updateStatus(), true);
|
|
|
|
RoomID.BindValueChanged(_ => updateStatus(), true);
|
2018-04-13 09:19:50 +00:00
|
|
|
}
|
|
|
|
|
2019-02-07 08:59:14 +00:00
|
|
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
2018-05-19 05:23:09 +00:00
|
|
|
{
|
2019-02-07 08:59:14 +00:00
|
|
|
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
2019-02-08 06:44:05 +00:00
|
|
|
dependencies.CacheAs(status, new CacheInfo(nameof(Room.Status), typeof(Room)));
|
2019-02-07 08:59:14 +00:00
|
|
|
return dependencies;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updateStatus()
|
|
|
|
{
|
|
|
|
if (RoomID.Value == null)
|
2018-05-19 05:23:09 +00:00
|
|
|
{
|
2019-02-07 08:59:14 +00:00
|
|
|
status.Value = new RoomStatusNoneSelected();
|
|
|
|
|
2018-05-29 03:51:56 +00:00
|
|
|
participantCount.FadeOut(transition_duration);
|
2018-05-29 02:45:59 +00:00
|
|
|
beatmapTypeInfo.FadeOut(transition_duration);
|
2018-05-19 05:51:51 +00:00
|
|
|
name.FadeOut(transition_duration);
|
|
|
|
participantInfo.FadeOut(transition_duration);
|
2018-05-19 05:23:09 +00:00
|
|
|
}
|
2019-02-07 08:59:14 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
status.Value = Status;
|
2018-12-11 10:07:40 +00:00
|
|
|
|
2019-02-07 08:59:14 +00:00
|
|
|
participantCount.FadeIn(transition_duration);
|
|
|
|
beatmapTypeInfo.FadeIn(transition_duration);
|
|
|
|
name.FadeIn(transition_duration);
|
|
|
|
participantInfo.FadeIn(transition_duration);
|
|
|
|
}
|
2018-05-19 05:23:09 +00:00
|
|
|
}
|
|
|
|
|
2019-01-09 06:15:54 +00:00
|
|
|
private class RoomStatusNoneSelected : RoomStatus
|
|
|
|
{
|
|
|
|
public override string Message => @"No Room Selected";
|
|
|
|
public override Color4 GetAppropriateColour(OsuColour colours) => colours.Gray8;
|
|
|
|
}
|
|
|
|
|
2019-02-07 08:59:14 +00:00
|
|
|
private class StatusText : OsuSpriteText
|
|
|
|
{
|
2019-02-08 06:44:05 +00:00
|
|
|
[Resolved(typeof(Room), nameof(Room.Status))]
|
2019-02-07 08:59:14 +00:00
|
|
|
private Bindable<RoomStatus> status { get; set; }
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
|
|
|
status.BindValueChanged(s => Text = s.Message, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-05 10:00:01 +00:00
|
|
|
private class MatchParticipants : MultiplayerComposite
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-01-09 06:15:54 +00:00
|
|
|
private readonly FillFlowContainer fill;
|
|
|
|
|
|
|
|
public MatchParticipants()
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-01-09 06:15:54 +00:00
|
|
|
Padding = new MarginPadding { Horizontal = 10 };
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2019-01-09 06:15:54 +00:00
|
|
|
InternalChild = new ScrollContainer
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-01-09 06:15:54 +00:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Child = fill = new FillFlowContainer
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-01-09 06:15:54 +00:00
|
|
|
Spacing = new Vector2(10),
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Direction = FillDirection.Full,
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
};
|
|
|
|
}
|
2018-05-19 05:23:09 +00:00
|
|
|
|
2019-02-05 10:00:01 +00:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
|
|
|
RoomID.BindValueChanged(_ => updateParticipants(), true);
|
|
|
|
}
|
|
|
|
|
2019-01-09 06:15:54 +00:00
|
|
|
[Resolved]
|
|
|
|
private APIAccess api { get; set; }
|
|
|
|
|
|
|
|
private GetRoomScoresRequest request;
|
|
|
|
|
|
|
|
private void updateParticipants()
|
|
|
|
{
|
2019-02-05 10:00:01 +00:00
|
|
|
var roomId = RoomID.Value ?? 0;
|
2019-01-09 06:15:54 +00:00
|
|
|
|
|
|
|
request?.Cancel();
|
|
|
|
|
|
|
|
// nice little progressive fade
|
|
|
|
int time = 500;
|
|
|
|
foreach (var c in fill.Children)
|
|
|
|
{
|
|
|
|
c.Delay(500 - time).FadeOut(time, Easing.Out);
|
|
|
|
time = Math.Max(20, time - 20);
|
|
|
|
c.Expire();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (roomId == 0) return;
|
|
|
|
|
|
|
|
request = new GetRoomScoresRequest(roomId);
|
|
|
|
request.Success += scores =>
|
|
|
|
{
|
2019-02-05 10:00:01 +00:00
|
|
|
if (roomId != RoomID.Value)
|
2019-01-09 06:15:54 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
fill.Clear();
|
|
|
|
foreach (var s in scores)
|
|
|
|
fill.Add(new UserTile(s.User));
|
|
|
|
|
|
|
|
fill.FadeInFromZero(1000, Easing.OutQuint);
|
|
|
|
};
|
|
|
|
|
|
|
|
api.Queue(request);
|
|
|
|
}
|
|
|
|
|
2019-01-17 06:14:30 +00:00
|
|
|
protected override void Dispose(bool isDisposing)
|
|
|
|
{
|
|
|
|
request?.Cancel();
|
|
|
|
base.Dispose(isDisposing);
|
|
|
|
}
|
|
|
|
|
2019-01-09 06:15:54 +00:00
|
|
|
private class UserTile : CompositeDrawable, IHasTooltip
|
|
|
|
{
|
|
|
|
private readonly User user;
|
|
|
|
|
|
|
|
public string TooltipText => user.Username;
|
|
|
|
|
|
|
|
public UserTile(User user)
|
|
|
|
{
|
|
|
|
this.user = user;
|
|
|
|
Size = new Vector2(70f);
|
|
|
|
CornerRadius = 5f;
|
|
|
|
Masking = true;
|
|
|
|
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = OsuColour.FromHex(@"27252d"),
|
|
|
|
},
|
|
|
|
new UpdateableAvatar
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
User = user,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
2018-05-19 05:23:09 +00:00
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
}
|
|
|
|
}
|