mirror of
https://github.com/ppy/osu.git
synced 2025-01-26 18:52:55 +08:00
Merge branch 'fix-tournament-user-population' into multiplayer-participant-rank
This commit is contained in:
commit
d7c91a7c6f
@ -69,6 +69,20 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
AddAssert("last room joined", () => RoomManager.Rooms.Last().Status.Value is JoinedRoomStatus);
|
AddAssert("last room joined", () => RoomManager.Rooms.Last().Status.Value is JoinedRoomStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestClickDeselection()
|
||||||
|
{
|
||||||
|
AddRooms(1);
|
||||||
|
|
||||||
|
AddAssert("no selection", () => checkRoomSelected(null));
|
||||||
|
|
||||||
|
press(Key.Down);
|
||||||
|
AddAssert("first room selected", () => checkRoomSelected(RoomManager.Rooms.First()));
|
||||||
|
|
||||||
|
AddStep("click away", () => InputManager.Click(MouseButton.Left));
|
||||||
|
AddAssert("no selection", () => checkRoomSelected(null));
|
||||||
|
}
|
||||||
|
|
||||||
private void press(Key down)
|
private void press(Key down)
|
||||||
{
|
{
|
||||||
AddStep($"press {down}", () => InputManager.Key(down));
|
AddStep($"press {down}", () => InputManager.Key(down));
|
||||||
|
@ -277,7 +277,8 @@ namespace osu.Game.Tournament.Screens.Editors
|
|||||||
userId.Value = user.Id.ToString();
|
userId.Value = user.Id.ToString();
|
||||||
userId.BindValueChanged(idString =>
|
userId.BindValueChanged(idString =>
|
||||||
{
|
{
|
||||||
int.TryParse(idString.NewValue, out var parsed);
|
if (!(int.TryParse(idString.NewValue, out var parsed)))
|
||||||
|
return;
|
||||||
|
|
||||||
user.Id = parsed;
|
user.Id = parsed;
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ namespace osu.Game.Tournament
|
|||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(p.Username) || p.Statistics == null)
|
if (string.IsNullOrEmpty(p.Username) || p.Statistics == null)
|
||||||
{
|
{
|
||||||
PopulateUser(p);
|
PopulateUser(p, immediate: true);
|
||||||
addedInfo = true;
|
addedInfo = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -211,7 +211,7 @@ namespace osu.Game.Tournament
|
|||||||
return addedInfo;
|
return addedInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PopulateUser(User user, Action success = null, Action failure = null)
|
public void PopulateUser(User user, Action success = null, Action failure = null, bool immediate = false)
|
||||||
{
|
{
|
||||||
var req = new GetUserRequest(user.Id, Ruleset.Value);
|
var req = new GetUserRequest(user.Id, Ruleset.Value);
|
||||||
|
|
||||||
@ -225,13 +225,12 @@ namespace osu.Game.Tournament
|
|||||||
success?.Invoke();
|
success?.Invoke();
|
||||||
};
|
};
|
||||||
|
|
||||||
req.Failure += _ =>
|
req.Failure += _ => failure?.Invoke();
|
||||||
{
|
|
||||||
user.Id = 1;
|
|
||||||
failure?.Invoke();
|
|
||||||
};
|
|
||||||
|
|
||||||
API.Queue(req);
|
if (immediate)
|
||||||
|
API.Perform(req);
|
||||||
|
else
|
||||||
|
API.Queue(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
|
19
osu.Game/Online/Rooms/ItemAttemptsCount.cs
Normal file
19
osu.Game/Online/Rooms/ItemAttemptsCount.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// 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 Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace osu.Game.Online.Rooms
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents attempts on a specific playlist item.
|
||||||
|
/// </summary>
|
||||||
|
public class ItemAttemptsCount
|
||||||
|
{
|
||||||
|
[JsonProperty("id")]
|
||||||
|
public int PlaylistItemID { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("attempts")]
|
||||||
|
public int Attempts { get; set; }
|
||||||
|
}
|
||||||
|
}
|
16
osu.Game/Online/Rooms/PlaylistAggregateScore.cs
Normal file
16
osu.Game/Online/Rooms/PlaylistAggregateScore.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// 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 Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace osu.Game.Online.Rooms
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents aggregated score for the local user for a playlist.
|
||||||
|
/// </summary>
|
||||||
|
public class PlaylistAggregateScore
|
||||||
|
{
|
||||||
|
[JsonProperty("playlist_item_attempts")]
|
||||||
|
public ItemAttemptsCount[] PlaylistItemAttempts { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -72,6 +72,10 @@ namespace osu.Game.Online.Rooms
|
|||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public readonly Bindable<int?> MaxParticipants = new Bindable<int?>();
|
public readonly Bindable<int?> MaxParticipants = new Bindable<int?>();
|
||||||
|
|
||||||
|
[Cached]
|
||||||
|
[JsonProperty("current_user_score")]
|
||||||
|
public readonly Bindable<PlaylistAggregateScore> UserScore = new Bindable<PlaylistAggregateScore>();
|
||||||
|
|
||||||
[Cached]
|
[Cached]
|
||||||
[JsonProperty("recent_participants")]
|
[JsonProperty("recent_participants")]
|
||||||
public readonly BindableList<User> RecentParticipants = new BindableList<User>();
|
public readonly BindableList<User> RecentParticipants = new BindableList<User>();
|
||||||
@ -144,6 +148,7 @@ namespace osu.Game.Online.Rooms
|
|||||||
MaxParticipants.Value = other.MaxParticipants.Value;
|
MaxParticipants.Value = other.MaxParticipants.Value;
|
||||||
ParticipantCount.Value = other.ParticipantCount.Value;
|
ParticipantCount.Value = other.ParticipantCount.Value;
|
||||||
EndDate.Value = other.EndDate.Value;
|
EndDate.Value = other.EndDate.Value;
|
||||||
|
UserScore.Value = other.UserScore.Value;
|
||||||
|
|
||||||
if (EndDate.Value != null && DateTimeOffset.Now >= EndDate.Value)
|
if (EndDate.Value != null && DateTimeOffset.Now >= EndDate.Value)
|
||||||
Status.Value = new RoomStatusEnded();
|
Status.Value = new RoomStatusEnded();
|
||||||
|
@ -9,7 +9,6 @@ using osuTK;
|
|||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
using osu.Game.Users.Drawables;
|
using osu.Game.Users.Drawables;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Utils;
|
|
||||||
using osu.Framework.Graphics.Cursor;
|
using osu.Framework.Graphics.Cursor;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -245,11 +244,32 @@ namespace osu.Game.Overlays.Comments
|
|||||||
|
|
||||||
if (Comment.EditedAt.HasValue)
|
if (Comment.EditedAt.HasValue)
|
||||||
{
|
{
|
||||||
info.Add(new OsuSpriteText
|
var font = OsuFont.GetFont(size: 12, weight: FontWeight.Regular);
|
||||||
|
var colour = colourProvider.Foreground1;
|
||||||
|
|
||||||
|
info.Add(new FillFlowContainer
|
||||||
{
|
{
|
||||||
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Regular),
|
AutoSizeAxes = Axes.Both,
|
||||||
Text = $@"edited {HumanizerUtils.Humanize(Comment.EditedAt.Value)} by {Comment.EditedUser.Username}",
|
Children = new Drawable[]
|
||||||
Colour = colourProvider.Foreground1
|
{
|
||||||
|
new OsuSpriteText
|
||||||
|
{
|
||||||
|
Font = font,
|
||||||
|
Text = "edited ",
|
||||||
|
Colour = colour
|
||||||
|
},
|
||||||
|
new DrawableDate(Comment.EditedAt.Value)
|
||||||
|
{
|
||||||
|
Font = font,
|
||||||
|
Colour = colour
|
||||||
|
},
|
||||||
|
new OsuSpriteText
|
||||||
|
{
|
||||||
|
Font = font,
|
||||||
|
Text = $@" by {Comment.EditedUser.Username}",
|
||||||
|
Colour = colour
|
||||||
|
},
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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 System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
@ -39,12 +40,26 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
|||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
MaxAttempts.BindValueChanged(attempts =>
|
MaxAttempts.BindValueChanged(_ => updateAttempts());
|
||||||
|
UserScore.BindValueChanged(_ => updateAttempts(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateAttempts()
|
||||||
|
{
|
||||||
|
if (MaxAttempts.Value != null)
|
||||||
{
|
{
|
||||||
attemptDisplay.Text = attempts.NewValue == null
|
attemptDisplay.Text = $"Maximum attempts: {MaxAttempts.Value:N0}";
|
||||||
? string.Empty
|
|
||||||
: $"Maximum attempts: {attempts.NewValue:N0}";
|
if (UserScore.Value != null)
|
||||||
}, true);
|
{
|
||||||
|
int remaining = MaxAttempts.Value.Value - UserScore.Value.PlaylistItemAttempts.Sum(a => a.Attempts);
|
||||||
|
attemptDisplay.Text += $" ({remaining} remaining)";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
attemptDisplay.Text = string.Empty;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ using osu.Framework.Extensions.IEnumerableExtensions;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
|
using osu.Framework.Input.Events;
|
||||||
using osu.Framework.Threading;
|
using osu.Framework.Threading;
|
||||||
using osu.Game.Extensions;
|
using osu.Game.Extensions;
|
||||||
using osu.Game.Graphics.Cursor;
|
using osu.Game.Graphics.Cursor;
|
||||||
@ -42,6 +43,9 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
|||||||
[Resolved(CanBeNull = true)]
|
[Resolved(CanBeNull = true)]
|
||||||
private LoungeSubScreen loungeSubScreen { get; set; }
|
private LoungeSubScreen loungeSubScreen { get; set; }
|
||||||
|
|
||||||
|
// handle deselection
|
||||||
|
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
|
||||||
|
|
||||||
public RoomsContainer()
|
public RoomsContainer()
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
@ -69,8 +73,16 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
|||||||
rooms.BindTo(roomManager.Rooms);
|
rooms.BindTo(roomManager.Rooms);
|
||||||
|
|
||||||
filter?.BindValueChanged(criteria => Filter(criteria.NewValue));
|
filter?.BindValueChanged(criteria => Filter(criteria.NewValue));
|
||||||
|
|
||||||
|
selectedRoom.BindValueChanged(selection =>
|
||||||
|
{
|
||||||
|
updateSelection();
|
||||||
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateSelection() =>
|
||||||
|
roomFlow.Children.ForEach(r => r.State = r.Room == selectedRoom.Value ? SelectionState.Selected : SelectionState.NotSelected);
|
||||||
|
|
||||||
public void Filter(FilterCriteria criteria)
|
public void Filter(FilterCriteria criteria)
|
||||||
{
|
{
|
||||||
roomFlow.Children.ForEach(r =>
|
roomFlow.Children.ForEach(r =>
|
||||||
@ -125,6 +137,8 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
|||||||
}
|
}
|
||||||
|
|
||||||
Filter(filter?.Value);
|
Filter(filter?.Value);
|
||||||
|
|
||||||
|
updateSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeRooms(IEnumerable<Room> rooms)
|
private void removeRooms(IEnumerable<Room> rooms)
|
||||||
@ -146,11 +160,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
|||||||
roomFlow.SetLayoutPosition(room, room.Room.Position.Value);
|
roomFlow.SetLayoutPosition(room, room.Room.Position.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void selectRoom(Room room)
|
private void selectRoom(Room room) => selectedRoom.Value = room;
|
||||||
{
|
|
||||||
roomFlow.Children.ForEach(r => r.State = r.Room == room ? SelectionState.Selected : SelectionState.NotSelected);
|
|
||||||
selectedRoom.Value = room;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void joinSelected()
|
private void joinSelected()
|
||||||
{
|
{
|
||||||
@ -159,6 +169,12 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
|||||||
JoinRequested?.Invoke(selectedRoom.Value);
|
JoinRequested?.Invoke(selectedRoom.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override bool OnClick(ClickEvent e)
|
||||||
|
{
|
||||||
|
selectRoom(null);
|
||||||
|
return base.OnClick(e);
|
||||||
|
}
|
||||||
|
|
||||||
#region Key selection logic (shared with BeatmapCarousel)
|
#region Key selection logic (shared with BeatmapCarousel)
|
||||||
|
|
||||||
public bool OnPressed(GlobalAction action)
|
public bool OnPressed(GlobalAction action)
|
||||||
|
@ -42,6 +42,9 @@ namespace osu.Game.Screens.OnlinePlay
|
|||||||
[Resolved(typeof(Room))]
|
[Resolved(typeof(Room))]
|
||||||
protected Bindable<int?> MaxAttempts { get; private set; }
|
protected Bindable<int?> MaxAttempts { get; private set; }
|
||||||
|
|
||||||
|
[Resolved(typeof(Room))]
|
||||||
|
public Bindable<PlaylistAggregateScore> UserScore { get; private set; }
|
||||||
|
|
||||||
[Resolved(typeof(Room))]
|
[Resolved(typeof(Room))]
|
||||||
protected Bindable<DateTimeOffset?> EndDate { get; private set; }
|
protected Bindable<DateTimeOffset?> EndDate { get; private set; }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user