1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-08 11:27:44 +08:00

Merge branch 'master' into fix-white-pixel

This commit is contained in:
Dan Balasescu 2019-10-30 12:35:22 +09:00 committed by GitHub
commit a03da25e05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 57 additions and 9 deletions

View File

@ -9,6 +9,7 @@ using osuTK;
using System; using System;
using System.Linq; using System.Linq;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Graphics.Containers;
using osu.Game.Overlays.Chat; using osu.Game.Overlays.Chat;
namespace osu.Game.Tests.Visual.Online namespace osu.Game.Tests.Visual.Online
@ -137,6 +138,17 @@ namespace osu.Game.Tests.Visual.Online
}); });
}, Channel.MAX_HISTORY / messages_per_call + 5); }, Channel.MAX_HISTORY / messages_per_call + 5);
AddAssert("Ensure no adjacent day separators", () =>
{
var indices = chatDisplay.FillFlow.OfType<DrawableChannel.DaySeparator>().Select(ds => chatDisplay.FillFlow.IndexOf(ds));
foreach (var i in indices)
if (i < chatDisplay.FillFlow.Count && chatDisplay.FillFlow[i + 1] is DrawableChannel.DaySeparator)
return false;
return true;
});
AddUntilStep("ensure still scrolled to bottom", () => chatDisplay.ScrolledToBottom); AddUntilStep("ensure still scrolled to bottom", () => chatDisplay.ScrolledToBottom);
} }
@ -147,7 +159,13 @@ namespace osu.Game.Tests.Visual.Online
{ {
} }
public bool ScrolledToBottom => ((ScrollContainer<Drawable>)((Container)InternalChildren.OfType<DrawableChannel>().First().Child).Child).IsScrolledToEnd(1); protected DrawableChannel DrawableChannel => InternalChildren.OfType<DrawableChannel>().First();
protected OsuScrollContainer ScrollContainer => (OsuScrollContainer)((Container)DrawableChannel.Child).Child;
public FillFlowContainer FillFlow => (FillFlowContainer)ScrollContainer.Child;
public bool ScrolledToBottom => ScrollContainer.IsScrolledToEnd(1);
} }
} }
} }

View File

@ -108,11 +108,25 @@ namespace osu.Game.Overlays.Chat
var staleMessages = chatLines.Where(c => c.LifetimeEnd == double.MaxValue).ToArray(); var staleMessages = chatLines.Where(c => c.LifetimeEnd == double.MaxValue).ToArray();
int count = staleMessages.Length - Channel.MAX_HISTORY; int count = staleMessages.Length - Channel.MAX_HISTORY;
for (int i = 0; i < count; i++) if (count > 0)
{ {
var d = staleMessages[i]; void expireAndAdjustScroll(Drawable d)
scroll.OffsetScrollPosition(-d.DrawHeight); {
d.Expire(); scroll.OffsetScrollPosition(-d.DrawHeight);
d.Expire();
}
for (int i = 0; i < count; i++)
expireAndAdjustScroll(staleMessages[i]);
// remove all adjacent day separators after stale message removal
for (int i = 0; i < ChatLineFlow.Count - 1; i++)
{
if (!(ChatLineFlow[i] is DaySeparator)) break;
if (!(ChatLineFlow[i + 1] is DaySeparator)) break;
expireAndAdjustScroll(ChatLineFlow[i]);
}
} }
if (shouldScrollToEnd) if (shouldScrollToEnd)
@ -142,7 +156,7 @@ namespace osu.Game.Overlays.Chat
private void scrollToEnd() => ScheduleAfterChildren(() => scroll.ScrollToEnd()); private void scrollToEnd() => ScheduleAfterChildren(() => scroll.ScrollToEnd());
protected class DaySeparator : Container public class DaySeparator : Container
{ {
public float TextSize public float TextSize
{ {

View File

@ -200,6 +200,7 @@ namespace osu.Game.Overlays.Settings.Sections.General
{ {
private TextBox username; private TextBox username;
private TextBox password; private TextBox password;
private ShakeContainer shakeSignIn;
private IAPIProvider api; private IAPIProvider api;
public Action RequestHide; public Action RequestHide;
@ -208,6 +209,8 @@ namespace osu.Game.Overlays.Settings.Sections.General
{ {
if (!string.IsNullOrEmpty(username.Text) && !string.IsNullOrEmpty(password.Text)) if (!string.IsNullOrEmpty(username.Text) && !string.IsNullOrEmpty(password.Text))
api.Login(username.Text, password.Text); api.Login(username.Text, password.Text);
else
shakeSignIn.Shake();
} }
[BackgroundDependencyLoader(permitNulls: true)] [BackgroundDependencyLoader(permitNulls: true)]
@ -244,10 +247,23 @@ namespace osu.Game.Overlays.Settings.Sections.General
LabelText = "Stay signed in", LabelText = "Stay signed in",
Bindable = config.GetBindable<bool>(OsuSetting.SavePassword), Bindable = config.GetBindable<bool>(OsuSetting.SavePassword),
}, },
new SettingsButton new Container
{ {
Text = "Sign in", RelativeSizeAxes = Axes.X,
Action = performLogin AutoSizeAxes = Axes.Y,
Children = new Drawable[]
{
shakeSignIn = new ShakeContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Child = new SettingsButton
{
Text = "Sign in",
Action = performLogin
},
}
}
}, },
new SettingsButton new SettingsButton
{ {