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

Merge branch 'master' into online-overlay-login-placeholder

This commit is contained in:
Dan Balasescu 2021-02-19 10:06:25 +09:00 committed by GitHub
commit 28550f19e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 96 additions and 51 deletions

View File

@ -139,35 +139,43 @@ namespace osu.Game.Collections
PostNotification?.Invoke(notification);
var collection = readCollections(stream, notification);
bool importCompleted = false;
Schedule(() =>
{
importCollections(collection);
importCompleted = true;
});
while (!IsDisposed && !importCompleted)
await Task.Delay(10);
await importCollections(collection);
notification.CompletionText = $"Imported {collection.Count} collections";
notification.State = ProgressNotificationState.Completed;
}
private void importCollections(List<BeatmapCollection> newCollections)
private Task importCollections(List<BeatmapCollection> newCollections)
{
foreach (var newCol in newCollections)
{
var existing = Collections.FirstOrDefault(c => c.Name == newCol.Name);
if (existing == null)
Collections.Add(existing = new BeatmapCollection { Name = { Value = newCol.Name.Value } });
var tcs = new TaskCompletionSource<bool>();
foreach (var newBeatmap in newCol.Beatmaps)
Schedule(() =>
{
try
{
if (!existing.Beatmaps.Contains(newBeatmap))
existing.Beatmaps.Add(newBeatmap);
foreach (var newCol in newCollections)
{
var existing = Collections.FirstOrDefault(c => c.Name == newCol.Name);
if (existing == null)
Collections.Add(existing = new BeatmapCollection { Name = { Value = newCol.Name.Value } });
foreach (var newBeatmap in newCol.Beatmaps)
{
if (!existing.Beatmaps.Contains(newBeatmap))
existing.Beatmaps.Add(newBeatmap);
}
}
tcs.SetResult(true);
}
}
catch (Exception e)
{
Logger.Error(e, "Failed to import collection.");
tcs.SetException(e);
}
});
return tcs.Task;
}
private List<BeatmapCollection> readCollections(Stream stream, ProgressNotification notification = null)

View File

@ -24,6 +24,7 @@ using osu.Game.Overlays.Chat.Tabs;
using osuTK.Input;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Game.Online;
namespace osu.Game.Overlays
{
@ -118,40 +119,47 @@ namespace osu.Game.Overlays
{
RelativeSizeAxes = Axes.Both,
},
currentChannelContainer = new Container<DrawableChannel>
new OnlineViewContainer("Sign in to chat")
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding
{
Bottom = textbox_height
},
},
new Container
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
RelativeSizeAxes = Axes.X,
Height = textbox_height,
Padding = new MarginPadding
{
Top = padding * 2,
Bottom = padding * 2,
Left = ChatLine.LEFT_PADDING + padding * 2,
Right = padding * 2,
},
Children = new Drawable[]
{
textbox = new FocusedTextBox
currentChannelContainer = new Container<DrawableChannel>
{
RelativeSizeAxes = Axes.Both,
Height = 1,
PlaceholderText = "type your message",
ReleaseFocusOnCommit = false,
HoldFocus = true,
}
}
},
loading = new LoadingSpinner(),
Padding = new MarginPadding
{
Bottom = textbox_height
},
},
new Container
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
RelativeSizeAxes = Axes.X,
Height = textbox_height,
Padding = new MarginPadding
{
Top = padding * 2,
Bottom = padding * 2,
Left = ChatLine.LEFT_PADDING + padding * 2,
Right = padding * 2,
},
Children = new Drawable[]
{
textbox = new FocusedTextBox
{
RelativeSizeAxes = Axes.Both,
Height = 1,
PlaceholderText = "type your message",
ReleaseFocusOnCommit = false,
HoldFocus = true,
}
}
},
loading = new LoadingSpinner(),
},
}
}
},
tabsArea = new TabsArea

View File

@ -25,8 +25,13 @@ namespace osu.Game.Screens.Select.Carousel
public readonly Bindable<CarouselItemState> State = new Bindable<CarouselItemState>(CarouselItemState.NotSelected);
private readonly HoverLayer hoverLayer;
protected override Container<Drawable> Content { get; } = new Container { RelativeSizeAxes = Axes.Both };
private const float corner_radius = 10;
private const float border_thickness = 2.5f;
public CarouselHeader()
{
RelativeSizeAxes = Axes.X;
@ -36,12 +41,12 @@ namespace osu.Game.Screens.Select.Carousel
{
RelativeSizeAxes = Axes.Both,
Masking = true,
CornerRadius = 10,
CornerRadius = corner_radius,
BorderColour = new Color4(221, 255, 255, 255),
Children = new Drawable[]
{
Content,
new HoverLayer()
hoverLayer = new HoverLayer()
}
};
}
@ -59,6 +64,8 @@ namespace osu.Game.Screens.Select.Carousel
{
case CarouselItemState.Collapsed:
case CarouselItemState.NotSelected:
hoverLayer.InsetForBorder = false;
BorderContainer.BorderThickness = 0;
BorderContainer.EdgeEffect = new EdgeEffectParameters
{
@ -70,7 +77,9 @@ namespace osu.Game.Screens.Select.Carousel
break;
case CarouselItemState.Selected:
BorderContainer.BorderThickness = 2.5f;
hoverLayer.InsetForBorder = true;
BorderContainer.BorderThickness = border_thickness;
BorderContainer.EdgeEffect = new EdgeEffectParameters
{
Type = EdgeEffectType.Glow,
@ -107,6 +116,26 @@ namespace osu.Game.Screens.Select.Carousel
sampleHover = audio.Samples.Get("SongSelect/song-ping");
}
public bool InsetForBorder
{
set
{
if (value)
{
// apply same border as above to avoid applying additive overlay to it (and blowing out the colour).
Masking = true;
CornerRadius = corner_radius;
BorderThickness = border_thickness;
}
else
{
BorderThickness = 0;
CornerRadius = 0;
Masking = false;
}
}
}
protected override bool OnHover(HoverEvent e)
{
box.FadeIn(100, Easing.OutQuint);