mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 00:23:59 +09:00
Merge pull request #21277 from peppy/beatmap-listing-texture-reduction
Reduce unnecessary texture overhead incurred by beatmap listing
This commit is contained in:
@ -41,11 +41,8 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
private IBindable<APIUser> apiUser;
|
private IBindable<APIUser> apiUser;
|
||||||
|
|
||||||
private Drawable currentContent;
|
|
||||||
private Container panelTarget;
|
private Container panelTarget;
|
||||||
private FillFlowContainer<BeatmapCard> foundContent;
|
private FillFlowContainer<BeatmapCard> foundContent;
|
||||||
private NotFoundDrawable notFoundContent;
|
|
||||||
private SupporterRequiredDrawable supporterRequiredContent;
|
|
||||||
private BeatmapListingFilterControl filterControl;
|
private BeatmapListingFilterControl filterControl;
|
||||||
|
|
||||||
public BeatmapListingOverlay()
|
public BeatmapListingOverlay()
|
||||||
@ -86,11 +83,6 @@ namespace osu.Game.Overlays
|
|||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Masking = true,
|
Masking = true,
|
||||||
Padding = new MarginPadding { Horizontal = 20 },
|
Padding = new MarginPadding { Horizontal = 20 },
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
notFoundContent = new NotFoundDrawable(),
|
|
||||||
supporterRequiredContent = new SupporterRequiredDrawable(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -107,7 +99,7 @@ namespace osu.Game.Overlays
|
|||||||
apiUser.BindValueChanged(_ => Schedule(() =>
|
apiUser.BindValueChanged(_ => Schedule(() =>
|
||||||
{
|
{
|
||||||
if (api.IsLoggedIn)
|
if (api.IsLoggedIn)
|
||||||
addContentToResultsArea(Drawable.Empty());
|
replaceResultsAreaContent(Drawable.Empty());
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,8 +147,8 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
if (searchResult.Type == BeatmapListingFilterControl.SearchResultType.SupporterOnlyFilters)
|
if (searchResult.Type == BeatmapListingFilterControl.SearchResultType.SupporterOnlyFilters)
|
||||||
{
|
{
|
||||||
supporterRequiredContent.UpdateText(searchResult.SupporterOnlyFiltersUsed);
|
var supporterOnly = new SupporterRequiredDrawable(searchResult.SupporterOnlyFiltersUsed);
|
||||||
addContentToResultsArea(supporterRequiredContent);
|
replaceResultsAreaContent(supporterOnly);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,13 +159,13 @@ namespace osu.Game.Overlays
|
|||||||
//No matches case
|
//No matches case
|
||||||
if (!newCards.Any())
|
if (!newCards.Any())
|
||||||
{
|
{
|
||||||
addContentToResultsArea(notFoundContent);
|
replaceResultsAreaContent(new NotFoundDrawable());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var content = createCardContainerFor(newCards);
|
var content = createCardContainerFor(newCards);
|
||||||
|
|
||||||
panelLoadTask = LoadComponentAsync(foundContent = content, addContentToResultsArea, (cancellationToken = new CancellationTokenSource()).Token);
|
panelLoadTask = LoadComponentAsync(foundContent = content, replaceResultsAreaContent, (cancellationToken = new CancellationTokenSource()).Token);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -221,36 +213,16 @@ namespace osu.Game.Overlays
|
|||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addContentToResultsArea(Drawable content)
|
private void replaceResultsAreaContent(Drawable content)
|
||||||
{
|
{
|
||||||
Loading.Hide();
|
Loading.Hide();
|
||||||
lastFetchDisplayedTime = Time.Current;
|
lastFetchDisplayedTime = Time.Current;
|
||||||
|
|
||||||
if (content == currentContent)
|
panelTarget.Child = content;
|
||||||
return;
|
|
||||||
|
|
||||||
var lastContent = currentContent;
|
|
||||||
|
|
||||||
if (lastContent != null)
|
|
||||||
{
|
|
||||||
lastContent.FadeOut();
|
|
||||||
if (!isPlaceholderContent(lastContent))
|
|
||||||
lastContent.Expire();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!content.IsAlive)
|
|
||||||
panelTarget.Add(content);
|
|
||||||
|
|
||||||
content.FadeInFromZero();
|
content.FadeInFromZero();
|
||||||
currentContent = content;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Whether <paramref name="drawable"/> is a static placeholder reused multiple times by this overlay.
|
|
||||||
/// </summary>
|
|
||||||
private bool isPlaceholderContent(Drawable drawable)
|
|
||||||
=> drawable == notFoundContent || drawable == supporterRequiredContent;
|
|
||||||
|
|
||||||
private void onCardSizeChanged()
|
private void onCardSizeChanged()
|
||||||
{
|
{
|
||||||
if (foundContent?.IsAlive != true || !foundContent.Any())
|
if (foundContent?.IsAlive != true || !foundContent.Any())
|
||||||
@ -287,7 +259,7 @@ namespace osu.Game.Overlays
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(TextureStore textures)
|
private void load(LargeTextureStore textures)
|
||||||
{
|
{
|
||||||
AddInternal(new FillFlowContainer
|
AddInternal(new FillFlowContainer
|
||||||
{
|
{
|
||||||
@ -324,15 +296,19 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
private LinkFlowContainer supporterRequiredText;
|
private LinkFlowContainer supporterRequiredText;
|
||||||
|
|
||||||
public SupporterRequiredDrawable()
|
private readonly List<LocalisableString> filtersUsed;
|
||||||
|
|
||||||
|
public SupporterRequiredDrawable(List<LocalisableString> filtersUsed)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
Height = 225;
|
Height = 225;
|
||||||
Alpha = 0;
|
Alpha = 0;
|
||||||
|
|
||||||
|
this.filtersUsed = filtersUsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(TextureStore textures)
|
private void load(LargeTextureStore textures)
|
||||||
{
|
{
|
||||||
AddInternal(new FillFlowContainer
|
AddInternal(new FillFlowContainer
|
||||||
{
|
{
|
||||||
@ -360,14 +336,9 @@ namespace osu.Game.Overlays
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
public void UpdateText(List<LocalisableString> filters)
|
|
||||||
{
|
|
||||||
supporterRequiredText.Clear();
|
|
||||||
|
|
||||||
supporterRequiredText.AddText(
|
supporterRequiredText.AddText(
|
||||||
BeatmapsStrings.ListingSearchSupporterFilterQuoteDefault(string.Join(" and ", filters), "").ToString(),
|
BeatmapsStrings.ListingSearchSupporterFilterQuoteDefault(string.Join(" and ", filtersUsed), "").ToString(),
|
||||||
t =>
|
t =>
|
||||||
{
|
{
|
||||||
t.Font = OsuFont.GetFont(size: 16);
|
t.Font = OsuFont.GetFont(size: 16);
|
||||||
|
Reference in New Issue
Block a user