Merge branch 'master' into fix-dummmy-api-request-firing-2

This commit is contained in:
Dean Herbert 2022-05-31 12:23:26 +09:00
commit c892aed797
7 changed files with 134 additions and 19 deletions

View File

@ -52,7 +52,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.527.0" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2022.527.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2022.529.0" /> <PackageReference Include="ppy.osu.Framework.Android" Version="2022.530.0" />
</ItemGroup> </ItemGroup>
<ItemGroup Label="Transitive Dependencies"> <ItemGroup Label="Transitive Dependencies">
<!-- Realm needs to be directly referenced in all Xamarin projects, as it will not pull in its transitive dependencies otherwise. --> <!-- Realm needs to be directly referenced in all Xamarin projects, as it will not pull in its transitive dependencies otherwise. -->

View File

@ -11,6 +11,7 @@ using osu.Framework.Testing;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Spectator; using osu.Game.Online.Spectator;
using osu.Game.Overlays;
using osu.Game.Overlays.Dashboard; using osu.Game.Overlays.Dashboard;
using osu.Game.Tests.Visual.Spectator; using osu.Game.Tests.Visual.Spectator;
using osu.Game.Users; using osu.Game.Users;
@ -42,7 +43,8 @@ namespace osu.Game.Tests.Visual.Online
CachedDependencies = new (Type, object)[] CachedDependencies = new (Type, object)[]
{ {
(typeof(SpectatorClient), spectatorClient), (typeof(SpectatorClient), spectatorClient),
(typeof(UserLookupCache), lookupCache) (typeof(UserLookupCache), lookupCache),
(typeof(OverlayColourProvider), new OverlayColourProvider(OverlayColourScheme.Purple)),
}, },
Child = currentlyPlaying = new CurrentlyPlayingDisplay Child = currentlyPlaying = new CurrentlyPlayingDisplay
{ {

View File

@ -1,11 +1,15 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System.Buffers;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using Microsoft.Toolkit.HighPerformance;
using osu.Framework.Extensions;
using osu.Framework.IO.Stores; using osu.Framework.IO.Stores;
using SharpCompress.Archives.Zip; using SharpCompress.Archives.Zip;
using SixLabors.ImageSharp.Memory;
namespace osu.Game.IO.Archives namespace osu.Game.IO.Archives
{ {
@ -27,15 +31,12 @@ namespace osu.Game.IO.Archives
if (entry == null) if (entry == null)
throw new FileNotFoundException(); throw new FileNotFoundException();
// allow seeking var owner = MemoryAllocator.Default.Allocate<byte>((int)entry.Size);
MemoryStream copy = new MemoryStream();
using (Stream s = entry.OpenEntryStream()) using (Stream s = entry.OpenEntryStream())
s.CopyTo(copy); s.ReadToFill(owner.Memory.Span);
copy.Position = 0; return new MemoryOwnerMemoryStream(owner);
return copy;
} }
public override void Dispose() public override void Dispose()
@ -45,5 +46,48 @@ namespace osu.Game.IO.Archives
} }
public override IEnumerable<string> Filenames => archive.Entries.Select(e => e.Key).ExcludeSystemFileNames(); public override IEnumerable<string> Filenames => archive.Entries.Select(e => e.Key).ExcludeSystemFileNames();
private class MemoryOwnerMemoryStream : Stream
{
private readonly IMemoryOwner<byte> owner;
private readonly Stream stream;
public MemoryOwnerMemoryStream(IMemoryOwner<byte> owner)
{
this.owner = owner;
stream = owner.Memory.AsStream();
}
protected override void Dispose(bool disposing)
{
owner?.Dispose();
base.Dispose(disposing);
}
public override void Flush() => stream.Flush();
public override int Read(byte[] buffer, int offset, int count) => stream.Read(buffer, offset, count);
public override long Seek(long offset, SeekOrigin origin) => stream.Seek(offset, origin);
public override void SetLength(long value) => stream.SetLength(value);
public override void Write(byte[] buffer, int offset, int count) => stream.Write(buffer, offset, count);
public override bool CanRead => stream.CanRead;
public override bool CanSeek => stream.CanSeek;
public override bool CanWrite => stream.CanWrite;
public override long Length => stream.Length;
public override long Position
{
get => stream.Position;
set => stream.Position = value;
}
}
} }
} }

View File

@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
@ -9,11 +10,16 @@ using osu.Framework.Bindables;
using osu.Framework.Extensions; using osu.Framework.Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
using osu.Framework.Localisation;
using osu.Framework.Screens; using osu.Framework.Screens;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API; using osu.Game.Online.API;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Spectator; using osu.Game.Online.Spectator;
using osu.Game.Resources.Localisation.Web;
using osu.Game.Screens; using osu.Game.Screens;
using osu.Game.Screens.OnlinePlay.Match.Components; using osu.Game.Screens.OnlinePlay.Match.Components;
using osu.Game.Screens.Play; using osu.Game.Screens.Play;
@ -24,26 +30,62 @@ namespace osu.Game.Overlays.Dashboard
{ {
internal class CurrentlyPlayingDisplay : CompositeDrawable internal class CurrentlyPlayingDisplay : CompositeDrawable
{ {
private const float search_textbox_height = 40;
private const float padding = 10;
private readonly IBindableList<int> playingUsers = new BindableList<int>(); private readonly IBindableList<int> playingUsers = new BindableList<int>();
private FillFlowContainer<PlayingUserPanel> userFlow; private SearchContainer<PlayingUserPanel> userFlow;
private BasicSearchTextBox searchTextBox;
[Resolved] [Resolved]
private SpectatorClient spectatorClient { get; set; } private SpectatorClient spectatorClient { get; set; }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load(OverlayColourProvider colourProvider)
{ {
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y; AutoSizeAxes = Axes.Y;
InternalChild = userFlow = new FillFlowContainer<PlayingUserPanel> InternalChildren = new Drawable[]
{ {
RelativeSizeAxes = Axes.X, new Box
AutoSizeAxes = Axes.Y, {
Padding = new MarginPadding(10), RelativeSizeAxes = Axes.X,
Spacing = new Vector2(10), Height = padding * 2 + search_textbox_height,
Colour = colourProvider.Background4,
},
new Container<BasicSearchTextBox>
{
RelativeSizeAxes = Axes.X,
Padding = new MarginPadding(padding),
Child = searchTextBox = new BasicSearchTextBox
{
RelativeSizeAxes = Axes.X,
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Height = search_textbox_height,
ReleaseFocusOnCommit = false,
HoldFocus = true,
PlaceholderText = HomeStrings.SearchPlaceholder,
},
},
userFlow = new SearchContainer<PlayingUserPanel>
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Spacing = new Vector2(10),
Padding = new MarginPadding
{
Top = padding * 3 + search_textbox_height,
Bottom = padding,
Right = padding,
Left = padding,
},
},
}; };
searchTextBox.Current.ValueChanged += text => userFlow.SearchTerm = text.NewValue;
} }
[Resolved] [Resolved]
@ -57,6 +99,13 @@ namespace osu.Game.Overlays.Dashboard
playingUsers.BindCollectionChanged(onPlayingUsersChanged, true); playingUsers.BindCollectionChanged(onPlayingUsersChanged, true);
} }
protected override void OnFocus(FocusEvent e)
{
base.OnFocus(e);
searchTextBox.TakeFocus();
}
private void onPlayingUsersChanged(object sender, NotifyCollectionChangedEventArgs e) => Schedule(() => private void onPlayingUsersChanged(object sender, NotifyCollectionChangedEventArgs e) => Schedule(() =>
{ {
switch (e.Action) switch (e.Action)
@ -102,17 +151,34 @@ namespace osu.Game.Overlays.Dashboard
panel.Origin = Anchor.TopCentre; panel.Origin = Anchor.TopCentre;
}); });
private class PlayingUserPanel : CompositeDrawable public class PlayingUserPanel : CompositeDrawable, IFilterable
{ {
public readonly APIUser User; public readonly APIUser User;
public IEnumerable<LocalisableString> FilterTerms { get; }
[Resolved(canBeNull: true)] [Resolved(canBeNull: true)]
private IPerformFromScreenRunner performer { get; set; } private IPerformFromScreenRunner performer { get; set; }
public bool FilteringActive { set; get; }
public bool MatchingFilter
{
set
{
if (value)
Show();
else
Hide();
}
}
public PlayingUserPanel(APIUser user) public PlayingUserPanel(APIUser user)
{ {
User = user; User = user;
FilterTerms = new LocalisableString[] { User.Username };
AutoSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both;
} }

View File

@ -16,6 +16,8 @@ namespace osu.Game.Overlays
protected override DashboardOverlayHeader CreateHeader() => new DashboardOverlayHeader(); protected override DashboardOverlayHeader CreateHeader() => new DashboardOverlayHeader();
public override bool AcceptsFocus => false;
protected override void CreateDisplayToLoad(DashboardOverlayTabs tab) protected override void CreateDisplayToLoad(DashboardOverlayTabs tab)
{ {
switch (tab) switch (tab)

View File

@ -29,13 +29,14 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.14" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.14" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="5.0.14" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="5.0.14" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Toolkit.HighPerformance" Version="7.1.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="ppy.LocalisationAnalyser" Version="2022.417.0"> <PackageReference Include="ppy.LocalisationAnalyser" Version="2022.417.0">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Realm" Version="10.11.2" /> <PackageReference Include="Realm" Version="10.11.2" />
<PackageReference Include="ppy.osu.Framework" Version="2022.529.0" /> <PackageReference Include="ppy.osu.Framework" Version="2022.530.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.527.0" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2022.527.0" />
<PackageReference Include="Sentry" Version="3.17.1" /> <PackageReference Include="Sentry" Version="3.17.1" />
<PackageReference Include="SharpCompress" Version="0.31.0" /> <PackageReference Include="SharpCompress" Version="0.31.0" />

View File

@ -61,7 +61,7 @@
<Reference Include="System.Net.Http" /> <Reference Include="System.Net.Http" />
</ItemGroup> </ItemGroup>
<ItemGroup Label="Package References"> <ItemGroup Label="Package References">
<PackageReference Include="ppy.osu.Framework.iOS" Version="2022.529.0" /> <PackageReference Include="ppy.osu.Framework.iOS" Version="2022.530.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.527.0" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2022.527.0" />
</ItemGroup> </ItemGroup>
<!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net6.0) --> <!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net6.0) -->
@ -84,7 +84,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.14" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.14" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="5.0.14" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="5.0.14" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="ppy.osu.Framework" Version="2022.529.0" /> <PackageReference Include="ppy.osu.Framework" Version="2022.530.0" />
<PackageReference Include="SharpCompress" Version="0.31.0" /> <PackageReference Include="SharpCompress" Version="0.31.0" />
<PackageReference Include="NUnit" Version="3.13.3" /> <PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" /> <PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />