2018-04-13 17:19:50 +08:00
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
2019-01-09 14:15:54 +08:00
|
|
|
using System;
|
2018-04-13 17:19:50 +08:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Configuration;
|
|
|
|
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.Beatmaps.Drawables;
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2019-01-09 14:15:54 +08:00
|
|
|
using osu.Game.Online.API;
|
|
|
|
using osu.Game.Online.API.Requests;
|
2018-04-13 17:19:50 +08:00
|
|
|
using osu.Game.Online.Multiplayer;
|
2018-12-10 18:20:41 +08:00
|
|
|
using osu.Game.Screens.Multi.Components;
|
2018-04-13 17:19:50 +08:00
|
|
|
using osu.Game.Users;
|
2018-11-20 15:51:59 +08:00
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2018-12-10 18:20:41 +08:00
|
|
|
namespace osu.Game.Screens.Multi.Lounge.Components
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
|
|
|
public class RoomInspector : Container
|
|
|
|
{
|
|
|
|
private const float transition_duration = 100;
|
|
|
|
|
2018-12-20 19:58:34 +08:00
|
|
|
public readonly IBindable<Room> Room = new Bindable<Room>();
|
2018-12-11 18:07:40 +08:00
|
|
|
|
2018-05-19 13:23:09 +08:00
|
|
|
private readonly MarginPadding contentPadding = new MarginPadding { Horizontal = 20, Vertical = 10 };
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2018-12-22 13:01:06 +08:00
|
|
|
private readonly RoomBindings bindings = new RoomBindings();
|
2018-12-06 11:21:30 +08:00
|
|
|
|
2018-05-19 13:23:09 +08:00
|
|
|
private OsuColour colours;
|
|
|
|
private Box statusStrip;
|
2018-12-06 11:21:30 +08:00
|
|
|
private UpdateableBeatmapBackgroundSprite background;
|
2018-12-26 20:58:14 +08:00
|
|
|
private ParticipantCountDisplay participantCount;
|
2018-05-19 13:23:09 +08:00
|
|
|
private OsuSpriteText name, status;
|
2018-05-29 10:45:59 +08:00
|
|
|
private BeatmapTypeInfo beatmapTypeInfo;
|
2018-05-19 13:23:09 +08:00
|
|
|
private ParticipantInfo participantInfo;
|
2019-01-09 14:15:54 +08:00
|
|
|
private MatchParticipants participants;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2018-12-06 11:21:30 +08:00
|
|
|
[Resolved]
|
|
|
|
private BeatmapManager beatmaps { get; set; }
|
|
|
|
|
2018-05-19 12:26:39 +08:00
|
|
|
[BackgroundDependencyLoader]
|
2018-05-29 10:33:13 +08:00
|
|
|
private void load(OsuColour colours)
|
2018-05-19 12:26:39 +08:00
|
|
|
{
|
2018-05-19 13:23:09 +08:00
|
|
|
this.colours = colours;
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = OsuColour.FromHex(@"343138"),
|
|
|
|
},
|
2019-01-09 14:15:54 +08:00
|
|
|
new GridContainer
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2019-01-09 14:15:54 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
RowDimensions = new[]
|
|
|
|
{
|
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
|
|
|
new Dimension(GridSizeMode.Distributed),
|
|
|
|
},
|
|
|
|
Content = new[]
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2019-01-09 14:15:54 +08:00
|
|
|
new Drawable[]
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2019-01-09 14:15:54 +08:00
|
|
|
new FillFlowContainer
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2019-01-09 14:15:54 +08:00
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
Children = new Drawable[]
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2019-01-09 14:15:54 +08:00
|
|
|
new Container
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2019-01-09 14:15:54 +08:00
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Height = 200,
|
|
|
|
Masking = true,
|
|
|
|
Children = new Drawable[]
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2019-01-09 14:15:54 +08:00
|
|
|
background = new UpdateableBeatmapBackgroundSprite { RelativeSizeAxes = Axes.Both },
|
|
|
|
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,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2018-04-13 17:19:50 +08:00
|
|
|
},
|
2019-01-09 14:15:54 +08:00
|
|
|
},
|
|
|
|
statusStrip = new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Height = 5,
|
|
|
|
},
|
|
|
|
new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Children = new Drawable[]
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2019-01-09 14:15:54 +08: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[]
|
|
|
|
{
|
|
|
|
status = new OsuSpriteText
|
|
|
|
{
|
|
|
|
TextSize = 14,
|
|
|
|
Font = @"Exo2.0-Bold",
|
|
|
|
},
|
|
|
|
beatmapTypeInfo = new BeatmapTypeInfo(),
|
|
|
|
},
|
|
|
|
},
|
2018-04-13 17:19:50 +08:00
|
|
|
},
|
|
|
|
},
|
2019-01-09 14:15:54 +08:00
|
|
|
new Container
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2019-01-09 14:15:54 +08:00
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Padding = contentPadding,
|
|
|
|
Children = new Drawable[]
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2019-01-09 14:15:54 +08:00
|
|
|
participantInfo = new ParticipantInfo(),
|
2018-04-13 17:19:50 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-01-09 14:15:54 +08:00
|
|
|
new Drawable[]
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2019-01-09 14:15:54 +08:00
|
|
|
participants = new MatchParticipants
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2019-01-09 14:15:54 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-01-08 18:24:55 +08:00
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
};
|
|
|
|
|
2018-12-22 13:01:06 +08:00
|
|
|
participantInfo.Host.BindTo(bindings.Host);
|
2018-12-26 20:58:14 +08:00
|
|
|
participantInfo.ParticipantCount.BindTo(bindings.ParticipantCount);
|
2018-12-22 13:01:06 +08:00
|
|
|
participantInfo.Participants.BindTo(bindings.Participants);
|
|
|
|
participantCount.Participants.BindTo(bindings.Participants);
|
2018-12-27 16:15:43 +08:00
|
|
|
participantCount.ParticipantCount.BindTo(bindings.ParticipantCount);
|
2018-12-22 13:01:06 +08:00
|
|
|
participantCount.MaxParticipants.BindTo(bindings.MaxParticipants);
|
2018-12-27 17:16:17 +08:00
|
|
|
beatmapTypeInfo.Beatmap.BindTo(bindings.CurrentBeatmap);
|
|
|
|
beatmapTypeInfo.Ruleset.BindTo(bindings.CurrentRuleset);
|
2018-12-22 13:01:06 +08:00
|
|
|
beatmapTypeInfo.Type.BindTo(bindings.Type);
|
|
|
|
background.Beatmap.BindTo(bindings.CurrentBeatmap);
|
|
|
|
bindings.Status.BindValueChanged(displayStatus);
|
|
|
|
bindings.Name.BindValueChanged(n => name.Text = n);
|
2018-12-11 18:07:40 +08:00
|
|
|
Room.BindValueChanged(updateRoom, true);
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
|
2018-12-22 13:01:06 +08:00
|
|
|
private void updateRoom(Room room)
|
2018-05-19 13:23:09 +08:00
|
|
|
{
|
2018-12-22 13:01:06 +08:00
|
|
|
bindings.Room = room;
|
2019-01-09 14:15:54 +08:00
|
|
|
participants.Room = room;
|
2018-05-19 13:23:09 +08:00
|
|
|
|
2018-12-22 13:01:06 +08:00
|
|
|
if (room != null)
|
2018-12-11 18:07:40 +08:00
|
|
|
{
|
|
|
|
participantCount.FadeIn(transition_duration);
|
|
|
|
beatmapTypeInfo.FadeIn(transition_duration);
|
|
|
|
name.FadeIn(transition_duration);
|
|
|
|
participantInfo.FadeIn(transition_duration);
|
|
|
|
}
|
|
|
|
else
|
2018-05-19 13:23:09 +08:00
|
|
|
{
|
2018-05-29 11:51:56 +08:00
|
|
|
participantCount.FadeOut(transition_duration);
|
2018-05-29 10:45:59 +08:00
|
|
|
beatmapTypeInfo.FadeOut(transition_duration);
|
2018-05-19 13:51:51 +08:00
|
|
|
name.FadeOut(transition_duration);
|
|
|
|
participantInfo.FadeOut(transition_duration);
|
2018-05-19 13:23:09 +08:00
|
|
|
|
|
|
|
displayStatus(new RoomStatusNoneSelected());
|
|
|
|
}
|
2018-12-13 17:38:03 +08:00
|
|
|
}
|
|
|
|
|
2018-12-11 18:07:40 +08:00
|
|
|
private void displayStatus(RoomStatus s)
|
|
|
|
{
|
|
|
|
status.Text = s.Message;
|
|
|
|
|
|
|
|
Color4 c = s.GetAppropriateColour(colours);
|
|
|
|
statusStrip.FadeColour(c, transition_duration);
|
|
|
|
status.FadeColour(c, transition_duration);
|
2018-05-19 13:23:09 +08:00
|
|
|
}
|
|
|
|
|
2019-01-09 14:15:54 +08:00
|
|
|
private class RoomStatusNoneSelected : RoomStatus
|
|
|
|
{
|
|
|
|
public override string Message => @"No Room Selected";
|
|
|
|
public override Color4 GetAppropriateColour(OsuColour colours) => colours.Gray8;
|
|
|
|
}
|
|
|
|
|
|
|
|
private class MatchParticipants : CompositeDrawable
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2019-01-09 14:15:54 +08:00
|
|
|
private Room room;
|
|
|
|
private readonly FillFlowContainer fill;
|
|
|
|
|
|
|
|
public Room Room
|
|
|
|
{
|
|
|
|
get { return room; }
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (room == value)
|
|
|
|
return;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2019-01-09 14:15:54 +08:00
|
|
|
room = value;
|
|
|
|
updateParticipants();
|
|
|
|
}
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2019-01-09 14:15:54 +08:00
|
|
|
public MatchParticipants()
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2019-01-09 14:15:54 +08:00
|
|
|
Padding = new MarginPadding { Horizontal = 10 };
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2019-01-09 14:15:54 +08:00
|
|
|
InternalChild = new ScrollContainer
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2019-01-09 14:15:54 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Child = fill = new FillFlowContainer
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2019-01-09 14:15:54 +08:00
|
|
|
Spacing = new Vector2(10),
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Direction = FillDirection.Full,
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
};
|
|
|
|
}
|
2018-05-19 13:23:09 +08:00
|
|
|
|
2019-01-09 14:15:54 +08:00
|
|
|
[Resolved]
|
|
|
|
private APIAccess api { get; set; }
|
|
|
|
|
|
|
|
private GetRoomScoresRequest request;
|
|
|
|
|
|
|
|
private void updateParticipants()
|
|
|
|
{
|
|
|
|
var roomId = room.RoomID.Value ?? 0;
|
|
|
|
|
|
|
|
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 =>
|
|
|
|
{
|
|
|
|
if (roomId != room.RoomID.Value)
|
|
|
|
return;
|
|
|
|
|
|
|
|
fill.Clear();
|
|
|
|
foreach (var s in scores)
|
|
|
|
fill.Add(new UserTile(s.User));
|
|
|
|
|
|
|
|
fill.FadeInFromZero(1000, Easing.OutQuint);
|
|
|
|
};
|
|
|
|
|
|
|
|
api.Queue(request);
|
|
|
|
}
|
|
|
|
|
|
|
|
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 13:23:09 +08:00
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
}
|