mirror of
https://github.com/ppy/osu
synced 2025-03-30 15:17:22 +00:00
Merge pull request #7674 from LeNitrous/linkify-metadata
Linkify metadata in beatmap details and overlay
This commit is contained in:
commit
49090a0d1b
osu.Game
@ -320,6 +320,7 @@ namespace osu.Game.Online.Chat
|
|||||||
JoinMultiplayerMatch,
|
JoinMultiplayerMatch,
|
||||||
Spectate,
|
Spectate,
|
||||||
OpenUserProfile,
|
OpenUserProfile,
|
||||||
|
SearchBeatmapSet,
|
||||||
OpenWiki,
|
OpenWiki,
|
||||||
Custom,
|
Custom,
|
||||||
}
|
}
|
||||||
|
@ -305,6 +305,10 @@ namespace osu.Game
|
|||||||
ShowChannel(link.Argument);
|
ShowChannel(link.Argument);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case LinkAction.SearchBeatmapSet:
|
||||||
|
SearchBeatmapSet(link.Argument);
|
||||||
|
break;
|
||||||
|
|
||||||
case LinkAction.OpenEditorTimestamp:
|
case LinkAction.OpenEditorTimestamp:
|
||||||
case LinkAction.JoinMultiplayerMatch:
|
case LinkAction.JoinMultiplayerMatch:
|
||||||
case LinkAction.Spectate:
|
case LinkAction.Spectate:
|
||||||
@ -375,6 +379,12 @@ namespace osu.Game
|
|||||||
/// <param name="beatmapId">The beatmap to show.</param>
|
/// <param name="beatmapId">The beatmap to show.</param>
|
||||||
public void ShowBeatmap(int beatmapId) => waitForReady(() => beatmapSetOverlay, _ => beatmapSetOverlay.FetchAndShowBeatmap(beatmapId));
|
public void ShowBeatmap(int beatmapId) => waitForReady(() => beatmapSetOverlay, _ => beatmapSetOverlay.FetchAndShowBeatmap(beatmapId));
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Shows the beatmap listing overlay, with the given <paramref name="query"/> in the search box.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="query">The query to search for.</param>
|
||||||
|
public void SearchBeatmapSet(string query) => waitForReady(() => beatmapListing, _ => beatmapListing.ShowWithSearch(query));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Show a wiki's page as an overlay
|
/// Show a wiki's page as an overlay
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -122,6 +122,9 @@ namespace osu.Game.Overlays.BeatmapListing
|
|||||||
sortControlBackground.Colour = colourProvider.Background5;
|
sortControlBackground.Colour = colourProvider.Background5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Search(string query)
|
||||||
|
=> searchControl.Query.Value = query;
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
@ -89,6 +89,12 @@ namespace osu.Game.Overlays
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ShowWithSearch(string query)
|
||||||
|
{
|
||||||
|
filterControl.Search(query);
|
||||||
|
Show();
|
||||||
|
}
|
||||||
|
|
||||||
protected override BeatmapListingHeader CreateHeader() => new BeatmapListingHeader();
|
protected override BeatmapListingHeader CreateHeader() => new BeatmapListingHeader();
|
||||||
|
|
||||||
protected override Color4 BackgroundColour => ColourProvider.Background6;
|
protected override Color4 BackgroundColour => ColourProvider.Background6;
|
||||||
|
@ -8,15 +8,12 @@ using osu.Framework.Graphics.Containers;
|
|||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Containers;
|
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osuTK;
|
|
||||||
|
|
||||||
namespace osu.Game.Overlays.BeatmapSet
|
namespace osu.Game.Overlays.BeatmapSet
|
||||||
{
|
{
|
||||||
public class Info : Container
|
public class Info : Container
|
||||||
{
|
{
|
||||||
private const float transition_duration = 250;
|
|
||||||
private const float metadata_width = 175;
|
private const float metadata_width = 175;
|
||||||
private const float spacing = 20;
|
private const float spacing = 20;
|
||||||
private const float base_height = 220;
|
private const float base_height = 220;
|
||||||
@ -60,7 +57,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
Child = new Container
|
Child = new Container
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Child = new MetadataSection("Description"),
|
Child = new MetadataSection(MetadataType.Description),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
new Container
|
new Container
|
||||||
@ -78,10 +75,10 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
Direction = FillDirection.Full,
|
Direction = FillDirection.Full,
|
||||||
Children = new[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
source = new MetadataSection("Source"),
|
source = new MetadataSection(MetadataType.Source),
|
||||||
genre = new MetadataSection("Genre") { Width = 0.5f },
|
genre = new MetadataSection(MetadataType.Genre) { Width = 0.5f },
|
||||||
language = new MetadataSection("Language") { Width = 0.5f },
|
language = new MetadataSection(MetadataType.Language) { Width = 0.5f },
|
||||||
tags = new MetadataSection("Tags"),
|
tags = new MetadataSection(MetadataType.Tags),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -135,48 +132,5 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
successRateBackground.Colour = colourProvider.Background4;
|
successRateBackground.Colour = colourProvider.Background4;
|
||||||
background.Colour = colourProvider.Background5;
|
background.Colour = colourProvider.Background5;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class MetadataSection : FillFlowContainer
|
|
||||||
{
|
|
||||||
private readonly TextFlowContainer textFlow;
|
|
||||||
|
|
||||||
public string Text
|
|
||||||
{
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(value))
|
|
||||||
{
|
|
||||||
Hide();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.FadeIn(transition_duration);
|
|
||||||
textFlow.Clear();
|
|
||||||
textFlow.AddText(value, s => s.Font = s.Font.With(size: 12));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public MetadataSection(string title)
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X;
|
|
||||||
AutoSizeAxes = Axes.Y;
|
|
||||||
Spacing = new Vector2(5f);
|
|
||||||
|
|
||||||
InternalChildren = new Drawable[]
|
|
||||||
{
|
|
||||||
new OsuSpriteText
|
|
||||||
{
|
|
||||||
Text = title,
|
|
||||||
Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold),
|
|
||||||
Margin = new MarginPadding { Top = 15 },
|
|
||||||
},
|
|
||||||
textFlow = new OsuTextFlowContainer
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
AutoSizeAxes = Axes.Y,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
115
osu.Game/Overlays/BeatmapSet/MetadataSection.cs
Normal file
115
osu.Game/Overlays/BeatmapSet/MetadataSection.cs
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Online.Chat;
|
||||||
|
using osuTK;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.BeatmapSet
|
||||||
|
{
|
||||||
|
public class MetadataSection : Container
|
||||||
|
{
|
||||||
|
private readonly FillFlowContainer textContainer;
|
||||||
|
private readonly MetadataType type;
|
||||||
|
private TextFlowContainer textFlow;
|
||||||
|
|
||||||
|
private const float transition_duration = 250;
|
||||||
|
|
||||||
|
public MetadataSection(MetadataType type)
|
||||||
|
{
|
||||||
|
this.type = type;
|
||||||
|
|
||||||
|
Alpha = 0;
|
||||||
|
|
||||||
|
RelativeSizeAxes = Axes.X;
|
||||||
|
AutoSizeAxes = Axes.Y;
|
||||||
|
|
||||||
|
InternalChild = textContainer = new FillFlowContainer
|
||||||
|
{
|
||||||
|
Alpha = 0,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
|
||||||
|
Margin = new MarginPadding { Top = 15 },
|
||||||
|
Spacing = new Vector2(5),
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Child = new OsuSpriteText
|
||||||
|
{
|
||||||
|
Text = this.type.ToString(),
|
||||||
|
Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 14),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Text
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(value))
|
||||||
|
{
|
||||||
|
this.FadeOut(transition_duration);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.FadeIn(transition_duration);
|
||||||
|
|
||||||
|
setTextAsync(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setTextAsync(string text)
|
||||||
|
{
|
||||||
|
LoadComponentAsync(new LinkFlowContainer(s => s.Font = s.Font.With(size: 14))
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Colour = Color4.White.Opacity(0.75f),
|
||||||
|
}, loaded =>
|
||||||
|
{
|
||||||
|
textFlow?.Expire();
|
||||||
|
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case MetadataType.Tags:
|
||||||
|
string[] tags = text.Split(" ");
|
||||||
|
|
||||||
|
for (int i = 0; i <= tags.Length - 1; i++)
|
||||||
|
{
|
||||||
|
loaded.AddLink(tags[i], LinkAction.SearchBeatmapSet, tags[i]);
|
||||||
|
|
||||||
|
if (i != tags.Length - 1)
|
||||||
|
loaded.AddText(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MetadataType.Source:
|
||||||
|
loaded.AddLink(text, LinkAction.SearchBeatmapSet, text);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
loaded.AddText(text);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
textContainer.Add(textFlow = loaded);
|
||||||
|
|
||||||
|
// fade in if we haven't yet.
|
||||||
|
textContainer.FadeIn(transition_duration);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
14
osu.Game/Overlays/BeatmapSet/MetadataType.cs
Normal file
14
osu.Game/Overlays/BeatmapSet/MetadataType.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.BeatmapSet
|
||||||
|
{
|
||||||
|
public enum MetadataType
|
||||||
|
{
|
||||||
|
Tags,
|
||||||
|
Source,
|
||||||
|
Description,
|
||||||
|
Genre,
|
||||||
|
Language
|
||||||
|
}
|
||||||
|
}
|
@ -1,24 +1,25 @@
|
|||||||
// 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 osuTK;
|
using System.Linq;
|
||||||
using osuTK.Graphics;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Game.Graphics.Sprites;
|
|
||||||
using System.Linq;
|
|
||||||
using osu.Game.Online.API;
|
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
|
||||||
using osu.Game.Screens.Select.Details;
|
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Online.API.Requests;
|
|
||||||
using osu.Game.Rulesets;
|
|
||||||
using osu.Game.Online;
|
using osu.Game.Online;
|
||||||
|
using osu.Game.Online.API;
|
||||||
|
using osu.Game.Online.API.Requests;
|
||||||
|
using osu.Game.Overlays.BeatmapSet;
|
||||||
|
using osu.Game.Rulesets;
|
||||||
|
using osu.Game.Screens.Select.Details;
|
||||||
|
using osuTK;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Select
|
namespace osu.Game.Screens.Select
|
||||||
{
|
{
|
||||||
@ -128,13 +129,11 @@ namespace osu.Game.Screens.Select
|
|||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
LayoutDuration = transition_duration,
|
LayoutDuration = transition_duration,
|
||||||
LayoutEasing = Easing.OutQuad,
|
LayoutEasing = Easing.OutQuad,
|
||||||
Spacing = new Vector2(spacing * 2),
|
|
||||||
Margin = new MarginPadding { Top = spacing * 2 },
|
|
||||||
Children = new[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
description = new MetadataSection("Description"),
|
description = new MetadataSection(MetadataType.Description),
|
||||||
source = new MetadataSection("Source"),
|
source = new MetadataSection(MetadataType.Source),
|
||||||
tags = new MetadataSection("Tags"),
|
tags = new MetadataSection(MetadataType.Tags),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -290,73 +289,5 @@ namespace osu.Game.Screens.Select
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class MetadataSection : Container
|
|
||||||
{
|
|
||||||
private readonly FillFlowContainer textContainer;
|
|
||||||
private TextFlowContainer textFlow;
|
|
||||||
|
|
||||||
public MetadataSection(string title)
|
|
||||||
{
|
|
||||||
Alpha = 0;
|
|
||||||
RelativeSizeAxes = Axes.X;
|
|
||||||
AutoSizeAxes = Axes.Y;
|
|
||||||
|
|
||||||
InternalChild = textContainer = new FillFlowContainer
|
|
||||||
{
|
|
||||||
Alpha = 0,
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
AutoSizeAxes = Axes.Y,
|
|
||||||
Spacing = new Vector2(spacing / 2),
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new Container
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
AutoSizeAxes = Axes.Y,
|
|
||||||
Child = new OsuSpriteText
|
|
||||||
{
|
|
||||||
Text = title,
|
|
||||||
Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 14),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Text
|
|
||||||
{
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(value))
|
|
||||||
{
|
|
||||||
this.FadeOut(transition_duration);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.FadeIn(transition_duration);
|
|
||||||
|
|
||||||
setTextAsync(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setTextAsync(string text)
|
|
||||||
{
|
|
||||||
LoadComponentAsync(new OsuTextFlowContainer(s => s.Font = s.Font.With(size: 14))
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
AutoSizeAxes = Axes.Y,
|
|
||||||
Colour = Color4.White.Opacity(0.75f),
|
|
||||||
Text = text
|
|
||||||
}, loaded =>
|
|
||||||
{
|
|
||||||
textFlow?.Expire();
|
|
||||||
textContainer.Add(textFlow = loaded);
|
|
||||||
|
|
||||||
// fade in if we haven't yet.
|
|
||||||
textContainer.FadeIn(transition_duration);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user