1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-01 13:33:09 +08:00

Merge branch 'master' into general-fixes

This commit is contained in:
Dan Balasescu 2017-05-16 16:16:43 +09:00 committed by GitHub
commit fe3d035474
8 changed files with 137 additions and 42 deletions

@ -1 +1 @@
Subproject commit b90c4ed490f76f2995662b3a8af3a32b8756a012 Subproject commit ffccbeb98dc9e8f0965520270b5885e63f244c83

View File

@ -38,9 +38,9 @@ namespace osu.Game.Online.Chat
public event Action<IEnumerable<Message>> NewMessagesArrived; public event Action<IEnumerable<Message>> NewMessagesArrived;
public void AddNewMessages(IEnumerable<Message> messages) public void AddNewMessages(params Message[] messages)
{ {
messages = messages.Except(Messages).ToList(); messages = messages.Except(Messages).ToArray();
Messages.AddRange(messages); Messages.AddRange(messages);

View File

@ -0,0 +1,25 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Game.Users;
namespace osu.Game.Online.Chat
{
public class ErrorMessage : Message
{
private static int errorId = -1;
public ErrorMessage(string message) : base(errorId--)
{
Timestamp = DateTime.Now;
Content = message;
Sender = new User
{
Username = @"system",
Colour = @"ff0000",
};
}
}
}

View File

@ -37,6 +37,11 @@ namespace osu.Game.Online.Chat
{ {
} }
public Message(long id)
{
Id = id;
}
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
var objMessage = obj as Message; var objMessage = obj as Message;

View File

@ -245,7 +245,7 @@ namespace osu.Game.Overlays
addChannel(channels.Find(c => c.Name == @"#lobby")); addChannel(channels.Find(c => c.Name == @"#lobby"));
}); });
messageRequest = Scheduler.AddDelayed(() => fetchNewMessages(), 1000, true); messageRequest = Scheduler.AddDelayed(fetchNewMessages, 1000, true);
}; };
api.Queue(req); api.Queue(req);
@ -289,24 +289,41 @@ namespace osu.Game.Overlays
channelTabs.AddItem(channel); channelTabs.AddItem(channel);
// we need to get a good number of messages initially for each channel we care about. // we need to get a good number of messages initially for each channel we care about.
fetchNewMessages(channel); fetchInitialMessages(channel);
if (CurrentChannel == null) if (CurrentChannel == null)
CurrentChannel = channel; CurrentChannel = channel;
} }
private void fetchNewMessages(Channel specificChannel = null) private void fetchInitialMessages(Channel channel)
{
var req = new GetMessagesRequest(new List<Channel> { channel }, null);
req.Success += delegate (List<Message> messages)
{
channel.AddNewMessages(messages.ToArray());
Debug.Write("success!");
};
req.Failure += delegate
{
Debug.Write("failure!");
};
api.Queue(req);
}
private void fetchNewMessages()
{ {
if (fetchReq != null) return; if (fetchReq != null) return;
fetchReq = new GetMessagesRequest(specificChannel != null ? new List<Channel> { specificChannel } : 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(); var ids = messages.Where(m => m.TargetType == TargetType.Channel).Select(m => m.TargetId).Distinct();
//batch messages per channel. //batch messages per channel.
foreach (var id in ids) foreach (var id in ids)
careChannels.Find(c => c.Id == id)?.AddNewMessages(messages.Where(m => m.TargetId == id)); careChannels.Find(c => c.Id == id)?.AddNewMessages(messages.Where(m => m.TargetId == id).ToArray());
lastMessageId = messages.LastOrDefault()?.Id ?? lastMessageId; lastMessageId = messages.LastOrDefault()?.Id ?? lastMessageId;
@ -326,38 +343,45 @@ namespace osu.Game.Overlays
{ {
var postText = textbox.Text; var postText = textbox.Text;
if (!string.IsNullOrEmpty(postText) && api.LocalUser.Value != null) if (string.IsNullOrEmpty(postText) || api.LocalUser.Value == null) return;
if (currentChannel == null) return;
if (postText[0] == '/')
{ {
if (currentChannel == null) return; // TODO: handle commands
currentChannel.AddNewMessages(new ErrorMessage("Chat commands are not supported yet!"));
var message = new Message textbox.Text = string.Empty;
{ return;
Sender = api.LocalUser.Value,
Timestamp = DateTimeOffset.Now,
TargetType = TargetType.Channel, //TODO: read this from currentChannel
TargetId = currentChannel.Id,
Content = postText
};
textbox.ReadOnly = true;
var req = new PostMessageRequest(message);
req.Failure += e =>
{
textbox.FlashColour(Color4.Red, 1000);
textbox.ReadOnly = false;
};
req.Success += m =>
{
currentChannel.AddNewMessages(new[] { m });
textbox.ReadOnly = false;
textbox.Text = string.Empty;
};
api.Queue(req);
} }
var message = new Message
{
Sender = api.LocalUser.Value,
Timestamp = DateTimeOffset.Now,
TargetType = TargetType.Channel, //TODO: read this from currentChannel
TargetId = currentChannel.Id,
Content = postText
};
textbox.ReadOnly = true;
var req = new PostMessageRequest(message);
req.Failure += e =>
{
textbox.FlashColour(Color4.Red, 1000);
textbox.ReadOnly = false;
};
req.Success += m =>
{
currentChannel.AddNewMessages(m);
textbox.ReadOnly = false;
textbox.Text = string.Empty;
};
api.Queue(req);
} }
} }
} }

View File

@ -245,8 +245,14 @@ namespace osu.Game.Screens.Menu
buttonArea.FadeIn(300); buttonArea.FadeIn(300);
if (lastState == MenuState.Initial) if (lastState == MenuState.Initial)
{
buttonArea.Delay(150, true); buttonArea.Delay(150, true);
if (osuLogo.Scale.X > 0.5f)
using (osuLogo.BeginDelayedSequence(200, true))
osuLogo.Impact();
}
Scheduler.AddDelayed(() => toolbar?.Show(), 150); Scheduler.AddDelayed(() => toolbar?.Show(), 150);
foreach (Button b in buttonsTopLevel) foreach (Button b in buttonsTopLevel)

View File

@ -35,7 +35,7 @@ namespace osu.Game.Screens.Menu
public Action Action; public Action Action;
public float SizeForFlow => logo == null ? 0 : logo.DrawSize.X * logo.Scale.X * logoBounceContainer.Scale.X * logoHoverContainer.Scale.X * 0.78f; public float SizeForFlow => logo == null ? 0 : logo.DrawSize.X * logo.Scale.X * logoBounceContainer.Scale.X * logoHoverContainer.Scale.X * 0.74f;
private readonly Sprite ripple; private readonly Sprite ripple;
@ -63,8 +63,14 @@ namespace osu.Game.Screens.Menu
public bool Interactive = true; public bool Interactive = true;
private readonly Box flashLayer; private readonly Box flashLayer;
private readonly Container impactContainer;
private const float default_size = 480;
public OsuLogo() public OsuLogo()
{ {
Size = new Vector2(default_size);
Anchor = Anchor.Centre; Anchor = Anchor.Centre;
Origin = Anchor.Centre; Origin = Anchor.Centre;
@ -92,7 +98,7 @@ namespace osu.Game.Screens.Menu
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Scale = new Vector2(0.8f), Scale = new Vector2(0.88f),
Masking = true, Masking = true,
Children = new Drawable[] Children = new Drawable[]
{ {
@ -137,6 +143,7 @@ namespace osu.Game.Screens.Menu
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Children = new Drawable[] Children = new Drawable[]
{ {
ripple = new Sprite ripple = new Sprite
@ -148,11 +155,30 @@ namespace osu.Game.Screens.Menu
} }
} }
}, },
impactContainer = new CircularContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Alpha = 0,
BorderColour = Color4.White,
RelativeSizeAxes = Axes.Both,
BorderThickness = 10,
Masking = true,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
AlwaysPresent = true,
Alpha = 0,
}
}
},
new MenuVisualisation new MenuVisualisation
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Size = logo.Size, RelativeSizeAxes = Axes.Both,
BlendingMode = BlendingMode.Additive, BlendingMode = BlendingMode.Additive,
Alpha = 0.2f, Alpha = 0.2f,
} }
@ -211,7 +237,8 @@ namespace osu.Game.Screens.Menu
protected override bool OnHover(InputState state) protected override bool OnHover(InputState state)
{ {
if (!Interactive) return false; if (!Interactive) return false;
logoHoverContainer.ScaleTo(1.2f, 500, EasingTypes.OutElastic);
logoHoverContainer.ScaleTo(1.1f, 500, EasingTypes.OutElastic);
return true; return true;
} }
@ -219,5 +246,12 @@ namespace osu.Game.Screens.Menu
{ {
logoHoverContainer.ScaleTo(1, 500, EasingTypes.OutElastic); logoHoverContainer.ScaleTo(1, 500, EasingTypes.OutElastic);
} }
public void Impact()
{
impactContainer.FadeOutFromOne(250, EasingTypes.In);
impactContainer.ScaleTo(0.96f);
impactContainer.ScaleTo(1.12f, 250);
}
} }
} }

View File

@ -75,6 +75,7 @@
<Compile Include="Beatmaps\Drawables\BeatmapBackgroundSprite.cs" /> <Compile Include="Beatmaps\Drawables\BeatmapBackgroundSprite.cs" />
<Compile Include="Beatmaps\DifficultyCalculator.cs" /> <Compile Include="Beatmaps\DifficultyCalculator.cs" />
<Compile Include="Online\API\Requests\PostMessageRequest.cs" /> <Compile Include="Online\API\Requests\PostMessageRequest.cs" />
<Compile Include="Online\Chat\ErrorMessage.cs" />
<Compile Include="Overlays\Chat\ChatTabControl.cs" /> <Compile Include="Overlays\Chat\ChatTabControl.cs" />
<Compile Include="Overlays\Music\FilterControl.cs" /> <Compile Include="Overlays\Music\FilterControl.cs" />
<Compile Include="Overlays\Music\PlaylistItem.cs" /> <Compile Include="Overlays\Music\PlaylistItem.cs" />