mirror of
https://github.com/ppy/osu.git
synced 2025-02-26 22:43:21 +08: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();
|
var controlPoint = drawableControlPoints.LastOrDefault(t => t.CanContain(drawable)) ?? drawableControlPoints.FirstOrDefault();
|
||||||
|
|
||||||
if (controlPoint == null)
|
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);
|
controlPoint.Add(drawable);
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
ControlPoint firstTimingChange = Beatmap.TimingInfo.ControlPoints.FirstOrDefault(t => t.TimingChange);
|
ControlPoint firstTimingChange = Beatmap.TimingInfo.ControlPoints.FirstOrDefault(t => t.TimingChange);
|
||||||
|
|
||||||
if (firstTimingChange == null)
|
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
|
// Generate the timing points, making non-timing changes use the previous timing change
|
||||||
var timingChanges = Beatmap.TimingInfo.ControlPoints.Select(c =>
|
var timingChanges = Beatmap.TimingInfo.ControlPoints.Select(c =>
|
||||||
|
@ -288,7 +288,7 @@ namespace osu.Game.Online.API
|
|||||||
{
|
{
|
||||||
APIRequest req;
|
APIRequest req;
|
||||||
while (oldQueue.TryDequeue(out 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
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using osu.Framework.IO.Network;
|
using osu.Framework.IO.Network;
|
||||||
using osu.Game.Online.Chat;
|
using osu.Game.Online.Chat;
|
||||||
|
|
||||||
@ -20,10 +21,7 @@ namespace osu.Game.Online.API.Requests
|
|||||||
|
|
||||||
protected override WebRequest CreateWebRequest()
|
protected override WebRequest CreateWebRequest()
|
||||||
{
|
{
|
||||||
string channelString = string.Empty;
|
string channelString = string.Join(",", channels.Select(x => x.Id));
|
||||||
foreach (Channel c in channels)
|
|
||||||
channelString += c.Id + ",";
|
|
||||||
channelString = channelString.TrimEnd(',');
|
|
||||||
|
|
||||||
var req = base.CreateWebRequest();
|
var req = base.CreateWebRequest();
|
||||||
req.AddParameter(@"channels", channelString);
|
req.AddParameter(@"channels", channelString);
|
||||||
|
@ -23,7 +23,7 @@ namespace osu.Game.Online.Chat
|
|||||||
[JsonProperty(@"channel_id")]
|
[JsonProperty(@"channel_id")]
|
||||||
public int 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;
|
//internal bool Joined;
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ using osu.Game.Users;
|
|||||||
|
|
||||||
namespace osu.Game.Online.Chat
|
namespace osu.Game.Online.Chat
|
||||||
{
|
{
|
||||||
public class Message
|
public class Message : IComparable<Message>, IEquatable<Message>
|
||||||
{
|
{
|
||||||
[JsonProperty(@"message_id")]
|
[JsonProperty(@"message_id")]
|
||||||
public readonly long Id;
|
public readonly long Id;
|
||||||
@ -42,17 +42,11 @@ namespace osu.Game.Online.Chat
|
|||||||
Id = id;
|
Id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
public int CompareTo(Message other) => Id.CompareTo(other.Id);
|
||||||
{
|
|
||||||
var objMessage = obj as Message;
|
|
||||||
|
|
||||||
return Id == objMessage?.Id;
|
public bool Equals(Message other) => Id == other?.Id;
|
||||||
}
|
|
||||||
|
|
||||||
public override int GetHashCode()
|
public override int GetHashCode() => Id.GetHashCode();
|
||||||
{
|
|
||||||
return Id.GetHashCode();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum TargetType
|
public enum TargetType
|
||||||
|
@ -13,7 +13,7 @@ namespace osu.Game.Overlays.Chat
|
|||||||
public class DrawableChannel : Container
|
public class DrawableChannel : Container
|
||||||
{
|
{
|
||||||
public readonly Channel Channel;
|
public readonly Channel Channel;
|
||||||
private readonly FillFlowContainer flow;
|
private readonly FillFlowContainer<ChatLine> flow;
|
||||||
private readonly ScrollContainer scroll;
|
private readonly ScrollContainer scroll;
|
||||||
|
|
||||||
public DrawableChannel(Channel channel)
|
public DrawableChannel(Channel channel)
|
||||||
@ -29,7 +29,7 @@ namespace osu.Game.Overlays.Chat
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
flow = new FillFlowContainer
|
flow = new FillFlowContainer<ChatLine>
|
||||||
{
|
{
|
||||||
Direction = FillDirection.Vertical,
|
Direction = FillDirection.Vertical,
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
@ -63,19 +63,18 @@ namespace osu.Game.Overlays.Chat
|
|||||||
|
|
||||||
var displayMessages = newMessages.Skip(Math.Max(0, newMessages.Count() - Channel.MAX_HISTORY));
|
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())
|
if (scroll.IsScrolledToEnd(10) || !flow.Children.Any())
|
||||||
scrollToEnd();
|
scrollToEnd();
|
||||||
|
|
||||||
//up to last Channel.MAX_HISTORY messages
|
var staleMessages = flow.Children.Where(c => c.LifetimeEnd == double.MaxValue).ToArray();
|
||||||
foreach (Message m in displayMessages)
|
int count = staleMessages.Length - Channel.MAX_HISTORY;
|
||||||
{
|
|
||||||
var d = new ChatLine(m);
|
|
||||||
flow.Add(d);
|
|
||||||
}
|
|
||||||
|
|
||||||
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))
|
if (!scroll.IsScrolledToEnd(10))
|
||||||
scroll.OffsetScrollPosition(-d.DrawHeight);
|
scroll.OffsetScrollPosition(-d.DrawHeight);
|
||||||
d.Expire();
|
d.Expire();
|
||||||
|
@ -229,6 +229,7 @@ namespace osu.Game.Overlays
|
|||||||
Scheduler.Add(delegate
|
Scheduler.Add(delegate
|
||||||
{
|
{
|
||||||
loading.FadeOut(100);
|
loading.FadeOut(100);
|
||||||
|
loading.Expire();
|
||||||
|
|
||||||
addChannel(channels.Find(c => c.Name == @"#lazer"));
|
addChannel(channels.Find(c => c.Name == @"#lazer"));
|
||||||
addChannel(channels.Find(c => c.Name == @"#osu"));
|
addChannel(channels.Find(c => c.Name == @"#osu"));
|
||||||
@ -320,11 +321,8 @@ namespace osu.Game.Overlays
|
|||||||
fetchReq = new GetMessagesRequest(careChannels, lastMessageId);
|
fetchReq = new GetMessagesRequest(careChannels, lastMessageId);
|
||||||
fetchReq.Success += delegate (List<Message> messages)
|
fetchReq.Success += delegate (List<Message> messages)
|
||||||
{
|
{
|
||||||
var ids = messages.Where(m => m.TargetType == TargetType.Channel).Select(m => m.TargetId).Distinct();
|
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());
|
||||||
//batch messages per channel.
|
|
||||||
foreach (var id in ids)
|
|
||||||
careChannels.Find(c => c.Id == id)?.AddNewMessages(messages.Where(m => m.TargetId == id).ToArray());
|
|
||||||
|
|
||||||
lastMessageId = messages.LastOrDefault()?.Id ?? lastMessageId;
|
lastMessageId = messages.LastOrDefault()?.Id ?? lastMessageId;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user