mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 14:42:56 +08:00
Merge branch 'master' into main-page-wiki
This commit is contained in:
commit
649163e13b
@ -10,7 +10,6 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Containers.Markdown;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics.Containers.Markdown;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Wiki.Markdown;
|
||||
|
||||
@ -23,9 +22,6 @@ namespace osu.Game.Tests.Visual.Online
|
||||
[Cached]
|
||||
private readonly OverlayColourProvider overlayColour = new OverlayColourProvider(OverlayColourScheme.Orange);
|
||||
|
||||
[Cached]
|
||||
private readonly IAPIProvider api = new DummyAPIAccess();
|
||||
|
||||
[SetUp]
|
||||
public void Setup() => Schedule(() =>
|
||||
{
|
||||
@ -55,16 +51,16 @@ namespace osu.Game.Tests.Visual.Online
|
||||
AddStep("set current path", () => markdownContainer.CurrentPath = "Article_styling_criteria/");
|
||||
|
||||
AddStep("set '/wiki/Main_Page''", () => markdownContainer.Text = "[wiki main page](/wiki/Main_Page)");
|
||||
AddAssert("check url", () => markdownContainer.Link.Url == $"{api.WebsiteRootUrl}/wiki/Main_Page");
|
||||
AddAssert("check url", () => markdownContainer.Link.Url == $"{API.WebsiteRootUrl}/wiki/Main_Page");
|
||||
|
||||
AddStep("set '../FAQ''", () => markdownContainer.Text = "[FAQ](../FAQ)");
|
||||
AddAssert("check url", () => markdownContainer.Link.Url == $"{api.WebsiteRootUrl}/wiki/FAQ");
|
||||
AddAssert("check url", () => markdownContainer.Link.Url == $"{API.WebsiteRootUrl}/wiki/FAQ");
|
||||
|
||||
AddStep("set './Writing''", () => markdownContainer.Text = "[wiki writing guidline](./Writing)");
|
||||
AddAssert("check url", () => markdownContainer.Link.Url == $"{api.WebsiteRootUrl}/wiki/Article_styling_criteria/Writing");
|
||||
AddAssert("check url", () => markdownContainer.Link.Url == $"{API.WebsiteRootUrl}/wiki/Article_styling_criteria/Writing");
|
||||
|
||||
AddStep("set 'Formatting''", () => markdownContainer.Text = "[wiki formatting guidline](Formatting)");
|
||||
AddAssert("check url", () => markdownContainer.Link.Url == $"{api.WebsiteRootUrl}/wiki/Article_styling_criteria/Formatting");
|
||||
AddAssert("check url", () => markdownContainer.Link.Url == $"{API.WebsiteRootUrl}/wiki/Article_styling_criteria/Formatting");
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -106,6 +102,7 @@ needs_cleanup: true
|
||||
{
|
||||
AddStep("Add absolute image", () =>
|
||||
{
|
||||
markdownContainer.DocumentUrl = "https://dev.ppy.sh";
|
||||
markdownContainer.Text = "![intro](/wiki/Interface/img/intro-screen.jpg)";
|
||||
});
|
||||
}
|
||||
@ -115,6 +112,7 @@ needs_cleanup: true
|
||||
{
|
||||
AddStep("Add relative image", () =>
|
||||
{
|
||||
markdownContainer.DocumentUrl = "https://dev.ppy.sh";
|
||||
markdownContainer.CurrentPath = "Interface/";
|
||||
markdownContainer.Text = "![intro](img/intro-screen.jpg)";
|
||||
});
|
||||
@ -125,6 +123,7 @@ needs_cleanup: true
|
||||
{
|
||||
AddStep("Add paragraph with block image", () =>
|
||||
{
|
||||
markdownContainer.DocumentUrl = "https://dev.ppy.sh";
|
||||
markdownContainer.CurrentPath = "Interface/";
|
||||
markdownContainer.Text = @"Line before image
|
||||
|
||||
@ -139,6 +138,7 @@ Line after image";
|
||||
{
|
||||
AddStep("Add inline image", () =>
|
||||
{
|
||||
markdownContainer.DocumentUrl = "https://dev.ppy.sh";
|
||||
markdownContainer.Text = "![osu! mode icon](/wiki/shared/mode/osu.png) osu!";
|
||||
});
|
||||
}
|
||||
@ -147,6 +147,11 @@ Line after image";
|
||||
{
|
||||
public LinkInline Link;
|
||||
|
||||
public new string DocumentUrl
|
||||
{
|
||||
set => base.DocumentUrl = value;
|
||||
}
|
||||
|
||||
public override MarkdownTextFlowContainer CreateTextFlow() => new TestMarkdownTextFlowContainer
|
||||
{
|
||||
UrlAdded = link => Link = link,
|
||||
@ -162,6 +167,8 @@ Line after image";
|
||||
|
||||
UrlAdded?.Invoke(linkInline);
|
||||
}
|
||||
|
||||
protected override void AddImage(LinkInline linkInline) => AddDrawable(new WikiMarkdownImage(linkInline));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,10 +23,14 @@ namespace osu.Game.Graphics.Containers.Markdown
|
||||
LineSpacing = 21;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(IAPIProvider api)
|
||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||
{
|
||||
var api = parent.Get<IAPIProvider>();
|
||||
|
||||
// needs to be set before the base BDL call executes to avoid invalidating any already populated markdown content.
|
||||
DocumentUrl = api.WebsiteRootUrl;
|
||||
|
||||
return base.CreateChildDependencies(parent);
|
||||
}
|
||||
|
||||
protected override void AddMarkdownComponent(IMarkdownObject markdownObject, FillFlowContainer container, int level)
|
||||
|
@ -16,28 +16,29 @@ namespace osu.Game.Graphics.Containers.Markdown
|
||||
[Resolved(canBeNull: true)]
|
||||
private OsuGame game { get; set; }
|
||||
|
||||
protected string Text;
|
||||
protected string Title;
|
||||
private readonly string text;
|
||||
private readonly string title;
|
||||
|
||||
public OsuMarkdownLinkText(string text, LinkInline linkInline)
|
||||
: base(text, linkInline)
|
||||
{
|
||||
Text = text;
|
||||
Title = linkInline.Title;
|
||||
this.text = text;
|
||||
title = linkInline.Title;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OverlayColourProvider colourProvider)
|
||||
private void load()
|
||||
{
|
||||
var text = CreateSpriteText().With(t => t.Text = Text);
|
||||
var textDrawable = CreateSpriteText().With(t => t.Text = text);
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
text,
|
||||
new OsuMarkdownLinkCompiler(new[] { text })
|
||||
textDrawable,
|
||||
new OsuMarkdownLinkCompiler(new[] { textDrawable })
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Action = OnLinkPressed,
|
||||
TooltipText = Title ?? Url,
|
||||
TooltipText = title ?? Url,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -2,14 +2,13 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osuTK;
|
||||
|
||||
@ -20,26 +19,16 @@ namespace osu.Game.Overlays.News.Displays
|
||||
/// </summary>
|
||||
public class ArticleListing : CompositeDrawable
|
||||
{
|
||||
public Action<APINewsSidebar> SidebarMetadataUpdated;
|
||||
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; }
|
||||
private readonly Action fetchMorePosts;
|
||||
|
||||
private FillFlowContainer content;
|
||||
private ShowMoreButton showMore;
|
||||
|
||||
private GetNewsRequest request;
|
||||
private Cursor lastCursor;
|
||||
private CancellationTokenSource cancellationToken;
|
||||
|
||||
private readonly int? year;
|
||||
|
||||
/// <summary>
|
||||
/// Instantiate a listing for the specified year.
|
||||
/// </summary>
|
||||
/// <param name="year">The year to load articles from. If null, will show the most recent articles.</param>
|
||||
public ArticleListing(int? year = null)
|
||||
public ArticleListing(Action fetchMorePosts)
|
||||
{
|
||||
this.year = year;
|
||||
this.fetchMorePosts = fetchMorePosts;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -47,6 +36,7 @@ namespace osu.Game.Overlays.News.Displays
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
|
||||
Padding = new MarginPadding
|
||||
{
|
||||
Vertical = 20,
|
||||
@ -75,53 +65,25 @@ namespace osu.Game.Overlays.News.Displays
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Margin = new MarginPadding
|
||||
{
|
||||
Top = 15
|
||||
},
|
||||
Action = performFetch,
|
||||
Margin = new MarginPadding { Top = 15 },
|
||||
Action = fetchMorePosts,
|
||||
Alpha = 0
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
performFetch();
|
||||
}
|
||||
|
||||
private void performFetch()
|
||||
{
|
||||
request?.Cancel();
|
||||
|
||||
request = new GetNewsRequest(year, lastCursor);
|
||||
request.Success += response => Schedule(() => onSuccess(response));
|
||||
api.PerformAsync(request);
|
||||
}
|
||||
|
||||
private CancellationTokenSource cancellationToken;
|
||||
|
||||
private void onSuccess(GetNewsResponse response)
|
||||
{
|
||||
cancellationToken?.Cancel();
|
||||
|
||||
// only needs to be updated on the initial load, as the content won't change during pagination.
|
||||
if (lastCursor == null)
|
||||
SidebarMetadataUpdated?.Invoke(response.SidebarMetadata);
|
||||
|
||||
// store cursor for next pagination request.
|
||||
lastCursor = response.Cursor;
|
||||
|
||||
LoadComponentsAsync(response.NewsPosts.Select(p => new NewsCard(p)).ToList(), loaded =>
|
||||
public void AddPosts(IEnumerable<APINewsPost> posts, bool morePostsAvailable) => Schedule(() =>
|
||||
LoadComponentsAsync(posts.Select(p => new NewsCard(p)).ToList(), loaded =>
|
||||
{
|
||||
content.AddRange(loaded);
|
||||
|
||||
showMore.IsLoading = false;
|
||||
showMore.Alpha = response.Cursor != null ? 1 : 0;
|
||||
}, (cancellationToken = new CancellationTokenSource()).Token);
|
||||
}
|
||||
showMore.Alpha = morePostsAvailable ? 1 : 0;
|
||||
}, (cancellationToken = new CancellationTokenSource()).Token)
|
||||
);
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
request?.Cancel();
|
||||
cancellationToken?.Cancel();
|
||||
base.Dispose(isDisposing);
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ using System.Threading;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Overlays.News;
|
||||
using osu.Game.Overlays.News.Displays;
|
||||
using osu.Game.Overlays.News.Sidebar;
|
||||
@ -14,13 +15,21 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
public class NewsOverlay : OnlineOverlay<NewsHeader>
|
||||
{
|
||||
private readonly Bindable<string> article = new Bindable<string>(null);
|
||||
private readonly Bindable<string> article = new Bindable<string>();
|
||||
|
||||
private readonly Container sidebarContainer;
|
||||
private readonly NewsSidebar sidebar;
|
||||
|
||||
private readonly Container content;
|
||||
|
||||
private GetNewsRequest request;
|
||||
|
||||
private Cursor lastCursor;
|
||||
|
||||
/// <summary>
|
||||
/// The year currently being displayed. If null, the main listing is being displayed.
|
||||
/// </summary>
|
||||
private int? displayedYear;
|
||||
|
||||
private CancellationTokenSource cancellationToken;
|
||||
|
||||
private bool displayUpdateRequired = true;
|
||||
@ -65,7 +74,13 @@ namespace osu.Game.Overlays
|
||||
base.LoadComplete();
|
||||
|
||||
// should not be run until first pop-in to avoid requesting data before user views.
|
||||
article.BindValueChanged(onArticleChanged);
|
||||
article.BindValueChanged(a =>
|
||||
{
|
||||
if (a.NewValue == null)
|
||||
loadListing();
|
||||
else
|
||||
loadArticle(a.NewValue);
|
||||
});
|
||||
}
|
||||
|
||||
protected override NewsHeader CreateHeader() => new NewsHeader { ShowFrontPage = ShowFrontPage };
|
||||
@ -95,7 +110,7 @@ namespace osu.Game.Overlays
|
||||
|
||||
public void ShowYear(int year)
|
||||
{
|
||||
loadFrontPage(year);
|
||||
loadListing(year);
|
||||
Show();
|
||||
}
|
||||
|
||||
@ -108,7 +123,11 @@ namespace osu.Game.Overlays
|
||||
protected void LoadDisplay(Drawable display)
|
||||
{
|
||||
ScrollFlow.ScrollToStart();
|
||||
LoadComponentAsync(display, loaded => content.Child = loaded, (cancellationToken = new CancellationTokenSource()).Token);
|
||||
LoadComponentAsync(display, loaded =>
|
||||
{
|
||||
content.Child = loaded;
|
||||
Loading.Hide();
|
||||
}, (cancellationToken = new CancellationTokenSource()).Token);
|
||||
}
|
||||
|
||||
protected override void UpdateAfterChildren()
|
||||
@ -118,48 +137,65 @@ namespace osu.Game.Overlays
|
||||
sidebarContainer.Y = Math.Clamp(ScrollFlow.Current - Header.DrawHeight, 0, Math.Max(ScrollFlow.ScrollContent.DrawHeight - DrawHeight - Header.DrawHeight, 0));
|
||||
}
|
||||
|
||||
private void onArticleChanged(ValueChangedEvent<string> article)
|
||||
private void loadListing(int? year = null)
|
||||
{
|
||||
if (article.NewValue == null)
|
||||
loadFrontPage();
|
||||
else
|
||||
loadArticle(article.NewValue);
|
||||
}
|
||||
|
||||
private void loadFrontPage(int? year = null)
|
||||
{
|
||||
beginLoading();
|
||||
|
||||
Header.SetFrontPage();
|
||||
|
||||
var page = new ArticleListing(year);
|
||||
page.SidebarMetadataUpdated += metadata => Schedule(() =>
|
||||
displayedYear = year;
|
||||
lastCursor = null;
|
||||
|
||||
beginLoading(true);
|
||||
|
||||
request = new GetNewsRequest(displayedYear);
|
||||
request.Success += response => Schedule(() =>
|
||||
{
|
||||
sidebar.Metadata.Value = metadata;
|
||||
Loading.Hide();
|
||||
lastCursor = response.Cursor;
|
||||
sidebar.Metadata.Value = response.SidebarMetadata;
|
||||
|
||||
var listing = new ArticleListing(getMorePosts);
|
||||
listing.AddPosts(response.NewsPosts, response.Cursor != null);
|
||||
LoadDisplay(listing);
|
||||
});
|
||||
LoadDisplay(page);
|
||||
|
||||
API.PerformAsync(request);
|
||||
}
|
||||
|
||||
private void getMorePosts()
|
||||
{
|
||||
beginLoading(false);
|
||||
|
||||
request = new GetNewsRequest(displayedYear, lastCursor);
|
||||
request.Success += response => Schedule(() =>
|
||||
{
|
||||
lastCursor = response.Cursor;
|
||||
if (content.Child is ArticleListing listing)
|
||||
listing.AddPosts(response.NewsPosts, response.Cursor != null);
|
||||
});
|
||||
|
||||
API.PerformAsync(request);
|
||||
}
|
||||
|
||||
private void loadArticle(string article)
|
||||
{
|
||||
beginLoading();
|
||||
// This is not yet implemented nor called from anywhere.
|
||||
beginLoading(true);
|
||||
|
||||
Header.SetArticle(article);
|
||||
|
||||
// Temporary, should be handled by ArticleDisplay later
|
||||
LoadDisplay(Empty());
|
||||
Loading.Hide();
|
||||
}
|
||||
|
||||
private void beginLoading()
|
||||
private void beginLoading(bool showLoadingOverlay)
|
||||
{
|
||||
request?.Cancel();
|
||||
cancellationToken?.Cancel();
|
||||
Loading.Show();
|
||||
|
||||
if (showLoadingOverlay)
|
||||
Loading.Show();
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
request?.Cancel();
|
||||
cancellationToken?.Cancel();
|
||||
base.Dispose(isDisposing);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
// 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 System.Linq;
|
||||
using Markdig.Extensions.Yaml;
|
||||
using Markdig.Syntax;
|
||||
using Markdig.Syntax.Inlines;
|
||||
@ -14,7 +15,7 @@ namespace osu.Game.Overlays.Wiki.Markdown
|
||||
{
|
||||
public string CurrentPath
|
||||
{
|
||||
set => Schedule(() => DocumentUrl += $"wiki/{value}");
|
||||
set => DocumentUrl = $"{DocumentUrl}wiki/{value}";
|
||||
}
|
||||
|
||||
protected override void AddMarkdownComponent(IMarkdownObject markdownObject, FillFlowContainer container, int level)
|
||||
@ -22,21 +23,25 @@ namespace osu.Game.Overlays.Wiki.Markdown
|
||||
switch (markdownObject)
|
||||
{
|
||||
case YamlFrontMatterBlock yamlFrontMatterBlock:
|
||||
container.Add(CreateNotice(yamlFrontMatterBlock));
|
||||
container.Add(new WikiNoticeContainer(yamlFrontMatterBlock));
|
||||
break;
|
||||
|
||||
default:
|
||||
base.AddMarkdownComponent(markdownObject, container, level);
|
||||
case ParagraphBlock paragraphBlock:
|
||||
// Check if paragraph only contains an image
|
||||
if (paragraphBlock.Inline.Count() == 1 && paragraphBlock.Inline.FirstChild is LinkInline { IsImage: true } linkInline)
|
||||
{
|
||||
container.Add(new WikiMarkdownImageBlock(linkInline));
|
||||
return;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
base.AddMarkdownComponent(markdownObject, container, level);
|
||||
}
|
||||
|
||||
public override MarkdownTextFlowContainer CreateTextFlow() => new WikiMarkdownTextFlowContainer();
|
||||
|
||||
protected override MarkdownParagraph CreateParagraph(ParagraphBlock paragraphBlock, int level) => new WikiMarkdownParagraph(paragraphBlock);
|
||||
|
||||
protected virtual FillFlowContainer CreateNotice(YamlFrontMatterBlock yamlFrontMatterBlock) => new WikiNoticeContainer(yamlFrontMatterBlock);
|
||||
|
||||
private class WikiMarkdownTextFlowContainer : OsuMarkdownTextFlowContainer
|
||||
{
|
||||
protected override void AddImage(LinkInline linkInline) => AddDrawable(new WikiMarkdownImage(linkInline));
|
||||
|
@ -2,37 +2,28 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using Markdig.Syntax.Inlines;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Containers.Markdown;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Game.Online.API;
|
||||
|
||||
namespace osu.Game.Overlays.Wiki.Markdown
|
||||
{
|
||||
public class WikiMarkdownImage : MarkdownImage, IHasTooltip
|
||||
{
|
||||
private readonly string url;
|
||||
|
||||
public string TooltipText { get; }
|
||||
|
||||
public WikiMarkdownImage(LinkInline linkInline)
|
||||
: base(linkInline.Url)
|
||||
{
|
||||
url = linkInline.Url;
|
||||
TooltipText = linkInline.Title;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(IAPIProvider api)
|
||||
protected override ImageContainer CreateImageContainer(string url)
|
||||
{
|
||||
// The idea is replace "{api.WebsiteRootUrl}/wiki/{path-to-image}" to "{api.WebsiteRootUrl}/wiki/images/{path-to-image}"
|
||||
// The idea is replace "https://website.url/wiki/{path-to-image}" to "https://website.url/wiki/images/{path-to-image}"
|
||||
// "/wiki/images/*" is route to fetch wiki image from osu!web server (see: https://github.com/ppy/osu-web/blob/4205eb66a4da86bdee7835045e4bf28c35456e04/routes/web.php#L289)
|
||||
// Currently all image in dev server (https://dev.ppy.sh/wiki/image/*) is 404
|
||||
// So for now just replace "{api.WebsiteRootUrl}/wiki/*" to "https://osu.ppy.sh/wiki/images/*" for simplicity
|
||||
var imageUrl = url.Replace($"{api.WebsiteRootUrl}/wiki", "https://osu.ppy.sh/wiki/images");
|
||||
url = url.Replace("/wiki/", "/wiki/images/");
|
||||
|
||||
InternalChild = new DelayedLoadWrapper(CreateImageContainer(imageUrl));
|
||||
return base.CreateImageContainer(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
49
osu.Game/Overlays/Wiki/Markdown/WikiMarkdownImageBlock.cs
Normal file
49
osu.Game/Overlays/Wiki/Markdown/WikiMarkdownImageBlock.cs
Normal file
@ -0,0 +1,49 @@
|
||||
// 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 Markdig.Syntax.Inlines;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Containers.Markdown;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Overlays.Wiki.Markdown
|
||||
{
|
||||
public class WikiMarkdownImageBlock : FillFlowContainer
|
||||
{
|
||||
[Resolved]
|
||||
private IMarkdownTextComponent parentTextComponent { get; set; }
|
||||
|
||||
private readonly LinkInline linkInline;
|
||||
|
||||
public WikiMarkdownImageBlock(LinkInline linkInline)
|
||||
{
|
||||
this.linkInline = linkInline;
|
||||
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
Direction = FillDirection.Vertical;
|
||||
Spacing = new Vector2(0, 3);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new WikiMarkdownImage(linkInline)
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
},
|
||||
parentTextComponent.CreateSpriteText().With(t =>
|
||||
{
|
||||
t.Text = linkInline.Title;
|
||||
t.Anchor = Anchor.TopCentre;
|
||||
t.Origin = Anchor.TopCentre;
|
||||
}),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
// 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 System.Linq;
|
||||
using Markdig.Syntax;
|
||||
using Markdig.Syntax.Inlines;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers.Markdown;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Overlays.Wiki.Markdown
|
||||
{
|
||||
public class WikiMarkdownParagraph : MarkdownParagraph
|
||||
{
|
||||
private readonly ParagraphBlock paragraphBlock;
|
||||
|
||||
public WikiMarkdownParagraph(ParagraphBlock paragraphBlock)
|
||||
: base(paragraphBlock)
|
||||
{
|
||||
this.paragraphBlock = paragraphBlock;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
MarkdownTextFlowContainer textFlow;
|
||||
InternalChild = textFlow = CreateTextFlow();
|
||||
textFlow.AddInlineText(paragraphBlock.Inline);
|
||||
|
||||
// Check if paragraph only contains an image.
|
||||
if (paragraphBlock.Inline.Count() == 1 && paragraphBlock.Inline.FirstChild is LinkInline { IsImage: true } linkInline)
|
||||
{
|
||||
textFlow.TextAnchor = Anchor.TopCentre;
|
||||
textFlow.Spacing = new Vector2(0, 5);
|
||||
textFlow.AddText($"\n{linkInline.Title}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -59,6 +59,10 @@ namespace osu.Game.Skinning.Editor
|
||||
// the selection quad is always upright, so use an AABB rect to make mutating the values easier.
|
||||
var selectionRect = getSelectionQuad().AABBFloat;
|
||||
|
||||
// If the selection has no area we cannot scale it
|
||||
if (selectionRect.Area == 0)
|
||||
return false;
|
||||
|
||||
// copy to mutate, as we will need to compare to the original later on.
|
||||
var adjustedRect = selectionRect;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user