mirror of
https://github.com/ppy/osu
synced 2025-01-18 20:10:49 +00:00
Merge branch 'master' into mania-distance-object-conversion
This commit is contained in:
commit
fe70641980
@ -1 +1 @@
|
||||
Subproject commit 60e0a343d2bf590f736782e2bb2a01c132e6cac0
|
||||
Subproject commit 42e26d49b9046fcb96c123b0dfb48e06d741e162
|
@ -51,7 +51,7 @@ namespace osu.Game.Rulesets.Mania.Timing
|
||||
var controlPoint = drawableControlPoints.LastOrDefault(t => t.CanContain(drawable)) ?? drawableControlPoints.FirstOrDefault();
|
||||
|
||||
if (controlPoint == null)
|
||||
throw new Exception("Could not find suitable timing section to add object to.");
|
||||
throw new InvalidOperationException("Could not find suitable timing section to add object to.");
|
||||
|
||||
controlPoint.Add(drawable);
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ namespace osu.Game.Rulesets.Mania.UI
|
||||
ControlPoint firstTimingChange = Beatmap.TimingInfo.ControlPoints.FirstOrDefault(t => t.TimingChange);
|
||||
|
||||
if (firstTimingChange == null)
|
||||
throw new Exception("The Beatmap contains no timing points!");
|
||||
throw new InvalidOperationException("The Beatmap contains no timing points!");
|
||||
|
||||
// Generate the timing points, making non-timing changes use the previous timing change
|
||||
var timingChanges = Beatmap.TimingInfo.ControlPoints.Select(c =>
|
||||
|
@ -288,7 +288,7 @@ namespace osu.Game.Online.API
|
||||
{
|
||||
APIRequest req;
|
||||
while (oldQueue.TryDequeue(out req))
|
||||
req.Fail(new Exception(@"Disconnected from server"));
|
||||
req.Fail(new WebException(@"Disconnected from server"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.IO.Network;
|
||||
using osu.Game.Online.Chat;
|
||||
|
||||
@ -20,10 +21,7 @@ namespace osu.Game.Online.API.Requests
|
||||
|
||||
protected override WebRequest CreateWebRequest()
|
||||
{
|
||||
string channelString = string.Empty;
|
||||
foreach (Channel c in channels)
|
||||
channelString += c.Id + ",";
|
||||
channelString = channelString.TrimEnd(',');
|
||||
string channelString = string.Join(",", channels.Select(x => x.Id));
|
||||
|
||||
var req = base.CreateWebRequest();
|
||||
req.AddParameter(@"channels", channelString);
|
||||
|
@ -23,7 +23,7 @@ namespace osu.Game.Online.Chat
|
||||
[JsonProperty(@"channel_id")]
|
||||
public int Id;
|
||||
|
||||
public readonly SortedList<Message> Messages = new SortedList<Message>((m1, m2) => m1.Id.CompareTo(m2.Id));
|
||||
public readonly SortedList<Message> Messages = new SortedList<Message>(Comparer<Message>.Default);
|
||||
|
||||
//internal bool Joined;
|
||||
|
||||
|
@ -8,7 +8,7 @@ using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Online.Chat
|
||||
{
|
||||
public class Message
|
||||
public class Message : IComparable<Message>, IEquatable<Message>
|
||||
{
|
||||
[JsonProperty(@"message_id")]
|
||||
public readonly long Id;
|
||||
@ -42,17 +42,11 @@ namespace osu.Game.Online.Chat
|
||||
Id = id;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var objMessage = obj as Message;
|
||||
public int CompareTo(Message other) => Id.CompareTo(other.Id);
|
||||
|
||||
return Id == objMessage?.Id;
|
||||
}
|
||||
public bool Equals(Message other) => Id == other?.Id;
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Id.GetHashCode();
|
||||
}
|
||||
public override int GetHashCode() => Id.GetHashCode();
|
||||
}
|
||||
|
||||
public enum TargetType
|
||||
|
@ -13,7 +13,7 @@ namespace osu.Game.Overlays.Chat
|
||||
public class DrawableChannel : Container
|
||||
{
|
||||
public readonly Channel Channel;
|
||||
private readonly FillFlowContainer flow;
|
||||
private readonly FillFlowContainer<ChatLine> flow;
|
||||
private readonly ScrollContainer scroll;
|
||||
|
||||
public DrawableChannel(Channel channel)
|
||||
@ -29,7 +29,7 @@ namespace osu.Game.Overlays.Chat
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
flow = new FillFlowContainer
|
||||
flow = new FillFlowContainer<ChatLine>
|
||||
{
|
||||
Direction = FillDirection.Vertical,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
@ -63,19 +63,18 @@ namespace osu.Game.Overlays.Chat
|
||||
|
||||
var displayMessages = newMessages.Skip(Math.Max(0, newMessages.Count() - Channel.MAX_HISTORY));
|
||||
|
||||
//up to last Channel.MAX_HISTORY messages
|
||||
flow.Add(displayMessages.Select(m => new ChatLine(m)));
|
||||
|
||||
if (scroll.IsScrolledToEnd(10) || !flow.Children.Any())
|
||||
scrollToEnd();
|
||||
|
||||
//up to last Channel.MAX_HISTORY messages
|
||||
foreach (Message m in displayMessages)
|
||||
{
|
||||
var d = new ChatLine(m);
|
||||
flow.Add(d);
|
||||
}
|
||||
var staleMessages = flow.Children.Where(c => c.LifetimeEnd == double.MaxValue).ToArray();
|
||||
int count = staleMessages.Length - Channel.MAX_HISTORY;
|
||||
|
||||
while (flow.Children.Count(c => c.LifetimeEnd == double.MaxValue) > Channel.MAX_HISTORY)
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
var d = flow.Children.First(c => c.LifetimeEnd == double.MaxValue);
|
||||
var d = staleMessages[i];
|
||||
if (!scroll.IsScrolledToEnd(10))
|
||||
scroll.OffsetScrollPosition(-d.DrawHeight);
|
||||
d.Expire();
|
||||
|
@ -229,6 +229,7 @@ namespace osu.Game.Overlays
|
||||
Scheduler.Add(delegate
|
||||
{
|
||||
loading.FadeOut(100);
|
||||
loading.Expire();
|
||||
|
||||
addChannel(channels.Find(c => c.Name == @"#lazer"));
|
||||
addChannel(channels.Find(c => c.Name == @"#osu"));
|
||||
@ -320,11 +321,8 @@ namespace osu.Game.Overlays
|
||||
fetchReq = new GetMessagesRequest(careChannels, lastMessageId);
|
||||
fetchReq.Success += delegate (List<Message> messages)
|
||||
{
|
||||
var ids = messages.Where(m => m.TargetType == TargetType.Channel).Select(m => m.TargetId).Distinct();
|
||||
|
||||
//batch messages per channel.
|
||||
foreach (var id in ids)
|
||||
careChannels.Find(c => c.Id == id)?.AddNewMessages(messages.Where(m => m.TargetId == id).ToArray());
|
||||
foreach (var group in messages.Where(m => m.TargetType == TargetType.Channel).GroupBy(m => m.TargetId))
|
||||
careChannels.Find(c => c.Id == group.Key)?.AddNewMessages(group.ToArray());
|
||||
|
||||
lastMessageId = messages.LastOrDefault()?.Id ?? lastMessageId;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user