mirror of
https://github.com/ppy/osu.git
synced 2025-02-05 05:52:56 +08:00
Merge branch 'master' into legacy-skin-default-fallback
This commit is contained in:
commit
cd139660ab
@ -51,7 +51,7 @@
|
|||||||
<Reference Include="Java.Interop" />
|
<Reference Include="Java.Interop" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.422.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.525.0" />
|
||||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2021.528.0" />
|
<PackageReference Include="ppy.osu.Framework.Android" Version="2021.528.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -24,10 +24,10 @@ namespace osu.Game.Tests.Chat
|
|||||||
[TestCase(LinkAction.OpenBeatmap, "456", "https://dev.ppy.sh/beatmapsets/123#osu/456")]
|
[TestCase(LinkAction.OpenBeatmap, "456", "https://dev.ppy.sh/beatmapsets/123#osu/456")]
|
||||||
[TestCase(LinkAction.OpenBeatmap, "456", "https://dev.ppy.sh/beatmapsets/123#osu/456?whatever")]
|
[TestCase(LinkAction.OpenBeatmap, "456", "https://dev.ppy.sh/beatmapsets/123#osu/456?whatever")]
|
||||||
[TestCase(LinkAction.OpenBeatmap, "456", "https://dev.ppy.sh/beatmapsets/123/456")]
|
[TestCase(LinkAction.OpenBeatmap, "456", "https://dev.ppy.sh/beatmapsets/123/456")]
|
||||||
[TestCase(LinkAction.External, null, "https://dev.ppy.sh/beatmapsets/abc/def")]
|
[TestCase(LinkAction.External, "https://dev.ppy.sh/beatmapsets/abc/def", "https://dev.ppy.sh/beatmapsets/abc/def")]
|
||||||
[TestCase(LinkAction.OpenBeatmapSet, "123", "https://dev.ppy.sh/beatmapsets/123")]
|
[TestCase(LinkAction.OpenBeatmapSet, "123", "https://dev.ppy.sh/beatmapsets/123")]
|
||||||
[TestCase(LinkAction.OpenBeatmapSet, "123", "https://dev.ppy.sh/beatmapsets/123/whatever")]
|
[TestCase(LinkAction.OpenBeatmapSet, "123", "https://dev.ppy.sh/beatmapsets/123/whatever")]
|
||||||
[TestCase(LinkAction.External, null, "https://dev.ppy.sh/beatmapsets/abc")]
|
[TestCase(LinkAction.External, "https://dev.ppy.sh/beatmapsets/abc", "https://dev.ppy.sh/beatmapsets/abc")]
|
||||||
public void TestBeatmapLinks(LinkAction expectedAction, string expectedArg, string link)
|
public void TestBeatmapLinks(LinkAction expectedAction, string expectedArg, string link)
|
||||||
{
|
{
|
||||||
MessageFormatter.WebsiteRootUrl = "dev.ppy.sh";
|
MessageFormatter.WebsiteRootUrl = "dev.ppy.sh";
|
||||||
|
@ -141,14 +141,21 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
|
|
||||||
private Room createRoom(Action<Room> initFunc = null)
|
private Room createRoom(Action<Room> initFunc = null)
|
||||||
{
|
{
|
||||||
var room = new Room();
|
var room = new Room
|
||||||
|
{
|
||||||
room.Name.Value = "test room";
|
Name =
|
||||||
room.Playlist.Add(new PlaylistItem
|
{
|
||||||
|
Value = "test room"
|
||||||
|
},
|
||||||
|
Playlist =
|
||||||
|
{
|
||||||
|
new PlaylistItem
|
||||||
{
|
{
|
||||||
Beatmap = { Value = new TestBeatmap(Ruleset.Value).BeatmapInfo },
|
Beatmap = { Value = new TestBeatmap(Ruleset.Value).BeatmapInfo },
|
||||||
Ruleset = { Value = Ruleset.Value }
|
Ruleset = { Value = Ruleset.Value }
|
||||||
});
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
initFunc?.Invoke(room);
|
initFunc?.Invoke(room);
|
||||||
return room;
|
return room;
|
||||||
|
102
osu.Game.Tests/Visual/Online/TestSceneWikiHeader.cs
Normal file
102
osu.Game.Tests/Visual/Online/TestSceneWikiHeader.cs
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
// 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.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
|
using osu.Game.Overlays;
|
||||||
|
using osu.Game.Overlays.Wiki;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.Online
|
||||||
|
{
|
||||||
|
public class TestSceneWikiHeader : OsuTestScene
|
||||||
|
{
|
||||||
|
[Cached]
|
||||||
|
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Orange);
|
||||||
|
|
||||||
|
[Cached]
|
||||||
|
private readonly Bindable<APIWikiPage> wikiPageData = new Bindable<APIWikiPage>(new APIWikiPage
|
||||||
|
{
|
||||||
|
Title = "Main Page",
|
||||||
|
Path = "Main_Page",
|
||||||
|
});
|
||||||
|
|
||||||
|
private TestHeader header;
|
||||||
|
|
||||||
|
[SetUp]
|
||||||
|
public void SetUp() => Schedule(() =>
|
||||||
|
{
|
||||||
|
Child = header = new TestHeader
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
ShowIndexPage = dummyShowIndexPage,
|
||||||
|
ShowParentPage = dummyShowParentPage,
|
||||||
|
};
|
||||||
|
wikiPageData.BindTo(header.WikiPageData);
|
||||||
|
});
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestWikiHeader()
|
||||||
|
{
|
||||||
|
AddAssert("Current is index", () => checkCurrent("index"));
|
||||||
|
|
||||||
|
AddStep("Change wiki page data", () => wikiPageData.Value = new APIWikiPage
|
||||||
|
{
|
||||||
|
Title = "Welcome",
|
||||||
|
Path = "Welcome"
|
||||||
|
});
|
||||||
|
AddAssert("Current is welcome", () => checkCurrent("Welcome"));
|
||||||
|
AddAssert("Check breadcrumb", checkBreadcrumb);
|
||||||
|
|
||||||
|
AddStep("Change current to index", () => header.Current.Value = "index");
|
||||||
|
AddAssert("Current is index", () => checkCurrent("index"));
|
||||||
|
|
||||||
|
AddStep("Change wiki page data", () => wikiPageData.Value = new APIWikiPage
|
||||||
|
{
|
||||||
|
Title = "Developers",
|
||||||
|
Path = "People/The_Team/Developers",
|
||||||
|
Subtitle = "The Team",
|
||||||
|
});
|
||||||
|
AddAssert("Current is 'Developers'", () => checkCurrent("Developers"));
|
||||||
|
AddAssert("Check breadcrumb", checkBreadcrumb);
|
||||||
|
|
||||||
|
AddStep("Change current to 'The Team'", () => header.Current.Value = "The Team");
|
||||||
|
AddAssert("Current is 'The Team'", () => checkCurrent("The Team"));
|
||||||
|
AddAssert("Check breadcrumb", checkBreadcrumb);
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool checkCurrent(string expectedCurrent) => header.Current.Value == expectedCurrent;
|
||||||
|
|
||||||
|
private bool checkBreadcrumb()
|
||||||
|
{
|
||||||
|
var result = header.TabControlItems.Contains(wikiPageData.Value.Title);
|
||||||
|
|
||||||
|
if (wikiPageData.Value.Subtitle != null)
|
||||||
|
result = header.TabControlItems.Contains(wikiPageData.Value.Subtitle) && result;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void dummyShowIndexPage() => wikiPageData.SetDefault();
|
||||||
|
|
||||||
|
private void dummyShowParentPage()
|
||||||
|
{
|
||||||
|
wikiPageData.Value = new APIWikiPage
|
||||||
|
{
|
||||||
|
Path = "People/The_Team",
|
||||||
|
Title = "The Team",
|
||||||
|
Subtitle = "People"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TestHeader : WikiHeader
|
||||||
|
{
|
||||||
|
public IReadOnlyList<string> TabControlItems => TabControl.Items;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -48,7 +48,7 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestLink()
|
public void TestLink()
|
||||||
{
|
{
|
||||||
AddStep("set current path", () => markdownContainer.CurrentPath = "Article_styling_criteria/");
|
AddStep("set current path", () => markdownContainer.CurrentPath = $"{API.WebsiteRootUrl}/wiki/Article_styling_criteria/");
|
||||||
|
|
||||||
AddStep("set '/wiki/Main_Page''", () => markdownContainer.Text = "[wiki main page](/wiki/Main_Page)");
|
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");
|
||||||
@ -113,7 +113,7 @@ needs_cleanup: true
|
|||||||
AddStep("Add relative image", () =>
|
AddStep("Add relative image", () =>
|
||||||
{
|
{
|
||||||
markdownContainer.DocumentUrl = "https://dev.ppy.sh";
|
markdownContainer.DocumentUrl = "https://dev.ppy.sh";
|
||||||
markdownContainer.CurrentPath = "Interface/";
|
markdownContainer.CurrentPath = $"{API.WebsiteRootUrl}/wiki/Interface/";
|
||||||
markdownContainer.Text = "![intro](img/intro-screen.jpg)";
|
markdownContainer.Text = "![intro](img/intro-screen.jpg)";
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -124,7 +124,7 @@ needs_cleanup: true
|
|||||||
AddStep("Add paragraph with block image", () =>
|
AddStep("Add paragraph with block image", () =>
|
||||||
{
|
{
|
||||||
markdownContainer.DocumentUrl = "https://dev.ppy.sh";
|
markdownContainer.DocumentUrl = "https://dev.ppy.sh";
|
||||||
markdownContainer.CurrentPath = "Interface/";
|
markdownContainer.CurrentPath = $"{API.WebsiteRootUrl}/wiki/Interface/";
|
||||||
markdownContainer.Text = @"Line before image
|
markdownContainer.Text = @"Line before image
|
||||||
|
|
||||||
![play menu](img/play-menu.jpg ""Main Menu in osu!"")
|
![play menu](img/play-menu.jpg ""Main Menu in osu!"")
|
||||||
|
72
osu.Game.Tests/Visual/Online/TestSceneWikiOverlay.cs
Normal file
72
osu.Game.Tests/Visual/Online/TestSceneWikiOverlay.cs
Normal file
File diff suppressed because one or more lines are too long
@ -17,11 +17,12 @@ namespace osu.Game.Tournament.Tests.Screens
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
var match = new TournamentMatch();
|
ladder.CurrentMatch.Value = new TournamentMatch
|
||||||
match.Team1.Value = Ladder.Teams.FirstOrDefault(t => t.Acronym.Value == "USA");
|
{
|
||||||
match.Team2.Value = Ladder.Teams.FirstOrDefault(t => t.Acronym.Value == "JPN");
|
Team1 = { Value = Ladder.Teams.FirstOrDefault(t => t.Acronym.Value == "USA") },
|
||||||
match.Round.Value = Ladder.Rounds.FirstOrDefault(g => g.Name.Value == "Finals");
|
Team2 = { Value = Ladder.Teams.FirstOrDefault(t => t.Acronym.Value == "JPN") },
|
||||||
ladder.CurrentMatch.Value = match;
|
Round = { Value = Ladder.Rounds.FirstOrDefault(g => g.Name.Value == "Finals") }
|
||||||
|
};
|
||||||
|
|
||||||
Add(new TeamIntroScreen
|
Add(new TeamIntroScreen
|
||||||
{
|
{
|
||||||
|
@ -6,13 +6,11 @@ using Markdig.Extensions.AutoIdentifiers;
|
|||||||
using Markdig.Extensions.Tables;
|
using Markdig.Extensions.Tables;
|
||||||
using Markdig.Extensions.Yaml;
|
using Markdig.Extensions.Yaml;
|
||||||
using Markdig.Syntax;
|
using Markdig.Syntax;
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Containers.Markdown;
|
using osu.Framework.Graphics.Containers.Markdown;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Online.API;
|
|
||||||
|
|
||||||
namespace osu.Game.Graphics.Containers.Markdown
|
namespace osu.Game.Graphics.Containers.Markdown
|
||||||
{
|
{
|
||||||
@ -23,16 +21,6 @@ namespace osu.Game.Graphics.Containers.Markdown
|
|||||||
LineSpacing = 21;
|
LineSpacing = 21;
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
protected override void AddMarkdownComponent(IMarkdownObject markdownObject, FillFlowContainer container, int level)
|
||||||
{
|
{
|
||||||
switch (markdownObject)
|
switch (markdownObject)
|
||||||
|
21
osu.Game/Online/API/Requests/GetWikiRequest.cs
Normal file
21
osu.Game/Online/API/Requests/GetWikiRequest.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
// 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.Game.Online.API.Requests.Responses;
|
||||||
|
|
||||||
|
namespace osu.Game.Online.API.Requests
|
||||||
|
{
|
||||||
|
public class GetWikiRequest : APIRequest<APIWikiPage>
|
||||||
|
{
|
||||||
|
private readonly string path;
|
||||||
|
private readonly string locale;
|
||||||
|
|
||||||
|
public GetWikiRequest(string path, string locale = "en")
|
||||||
|
{
|
||||||
|
this.path = path;
|
||||||
|
this.locale = locale;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override string Target => $"wiki/{locale}/{path}";
|
||||||
|
}
|
||||||
|
}
|
32
osu.Game/Online/API/Requests/Responses/APIWikiPage.cs
Normal file
32
osu.Game/Online/API/Requests/Responses/APIWikiPage.cs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// 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.Collections.Generic;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace osu.Game.Online.API.Requests.Responses
|
||||||
|
{
|
||||||
|
public class APIWikiPage
|
||||||
|
{
|
||||||
|
[JsonProperty("layout")]
|
||||||
|
public string Layout { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("locale")]
|
||||||
|
public string Locale { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("markdown")]
|
||||||
|
public string Markdown { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("path")]
|
||||||
|
public string Path { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("subtitle")]
|
||||||
|
public string Subtitle { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("tags")]
|
||||||
|
public List<string> Tags { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("title")]
|
||||||
|
public string Title { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -167,10 +167,13 @@ namespace osu.Game.Online.Chat
|
|||||||
case "u":
|
case "u":
|
||||||
case "users":
|
case "users":
|
||||||
return new LinkDetails(LinkAction.OpenUserProfile, mainArg);
|
return new LinkDetails(LinkAction.OpenUserProfile, mainArg);
|
||||||
|
|
||||||
|
case "wiki":
|
||||||
|
return new LinkDetails(LinkAction.OpenWiki, string.Join('/', args.Skip(3)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new LinkDetails(LinkAction.External, null);
|
return new LinkDetails(LinkAction.External, url);
|
||||||
|
|
||||||
case "osu":
|
case "osu":
|
||||||
// every internal link also needs some kind of argument
|
// every internal link also needs some kind of argument
|
||||||
@ -311,7 +314,8 @@ namespace osu.Game.Online.Chat
|
|||||||
JoinMultiplayerMatch,
|
JoinMultiplayerMatch,
|
||||||
Spectate,
|
Spectate,
|
||||||
OpenUserProfile,
|
OpenUserProfile,
|
||||||
Custom
|
OpenWiki,
|
||||||
|
Custom,
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Link : IComparable<Link>
|
public class Link : IComparable<Link>
|
||||||
|
@ -81,6 +81,8 @@ namespace osu.Game
|
|||||||
|
|
||||||
private BeatmapSetOverlay beatmapSetOverlay;
|
private BeatmapSetOverlay beatmapSetOverlay;
|
||||||
|
|
||||||
|
private WikiOverlay wikiOverlay;
|
||||||
|
|
||||||
private SkinEditorOverlay skinEditor;
|
private SkinEditorOverlay skinEditor;
|
||||||
|
|
||||||
private Container overlayContent;
|
private Container overlayContent;
|
||||||
@ -307,6 +309,10 @@ namespace osu.Game
|
|||||||
ShowUser(userId);
|
ShowUser(userId);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case LinkAction.OpenWiki:
|
||||||
|
ShowWiki(link.Argument);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new NotImplementedException($"This {nameof(LinkAction)} ({link.Action.ToString()}) is missing an associated action.");
|
throw new NotImplementedException($"This {nameof(LinkAction)} ({link.Action.ToString()}) is missing an associated action.");
|
||||||
}
|
}
|
||||||
@ -354,6 +360,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>
|
||||||
|
/// Show a wiki's page as an overlay
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">The wiki page to show</param>
|
||||||
|
public void ShowWiki(string path) => waitForReady(() => wikiOverlay, _ => wikiOverlay.ShowPage(path));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Present a beatmap at song select immediately.
|
/// Present a beatmap at song select immediately.
|
||||||
/// The user should have already requested this interactively.
|
/// The user should have already requested this interactively.
|
||||||
@ -719,6 +731,7 @@ namespace osu.Game
|
|||||||
var changelogOverlay = loadComponentSingleFile(new ChangelogOverlay(), overlayContent.Add, true);
|
var changelogOverlay = loadComponentSingleFile(new ChangelogOverlay(), overlayContent.Add, true);
|
||||||
loadComponentSingleFile(userProfile = new UserProfileOverlay(), overlayContent.Add, true);
|
loadComponentSingleFile(userProfile = new UserProfileOverlay(), overlayContent.Add, true);
|
||||||
loadComponentSingleFile(beatmapSetOverlay = new BeatmapSetOverlay(), overlayContent.Add, true);
|
loadComponentSingleFile(beatmapSetOverlay = new BeatmapSetOverlay(), overlayContent.Add, true);
|
||||||
|
loadComponentSingleFile(wikiOverlay = new WikiOverlay(), overlayContent.Add, true);
|
||||||
loadComponentSingleFile(skinEditor = new SkinEditorOverlay(screenContainer), overlayContent.Add);
|
loadComponentSingleFile(skinEditor = new SkinEditorOverlay(screenContainer), overlayContent.Add);
|
||||||
|
|
||||||
loadComponentSingleFile(new LoginOverlay
|
loadComponentSingleFile(new LoginOverlay
|
||||||
@ -769,7 +782,7 @@ namespace osu.Game
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ensure only one of these overlays are open at once.
|
// ensure only one of these overlays are open at once.
|
||||||
var singleDisplayOverlays = new OverlayContainer[] { chatOverlay, news, dashboard, beatmapListing, changelogOverlay, rankingsOverlay };
|
var singleDisplayOverlays = new OverlayContainer[] { chatOverlay, news, dashboard, beatmapListing, changelogOverlay, rankingsOverlay, wikiOverlay };
|
||||||
|
|
||||||
foreach (var overlay in singleDisplayOverlays)
|
foreach (var overlay in singleDisplayOverlays)
|
||||||
{
|
{
|
||||||
|
@ -92,6 +92,7 @@ namespace osu.Game.Overlays.Toolbar
|
|||||||
new ToolbarBeatmapListingButton(),
|
new ToolbarBeatmapListingButton(),
|
||||||
new ToolbarChatButton(),
|
new ToolbarChatButton(),
|
||||||
new ToolbarSocialButton(),
|
new ToolbarSocialButton(),
|
||||||
|
new ToolbarWikiButton(),
|
||||||
new ToolbarMusicButton(),
|
new ToolbarMusicButton(),
|
||||||
//new ToolbarButton
|
//new ToolbarButton
|
||||||
//{
|
//{
|
||||||
|
19
osu.Game/Overlays/Toolbar/ToolbarWikiButton.cs
Normal file
19
osu.Game/Overlays/Toolbar/ToolbarWikiButton.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// 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.Allocation;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.Toolbar
|
||||||
|
{
|
||||||
|
public class ToolbarWikiButton : ToolbarOverlayToggleButton
|
||||||
|
{
|
||||||
|
protected override Anchor TooltipAnchor => Anchor.TopRight;
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader(true)]
|
||||||
|
private void load(WikiOverlay wiki)
|
||||||
|
{
|
||||||
|
StateContainer = wiki;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -5,17 +5,22 @@ using System.Linq;
|
|||||||
using Markdig.Extensions.Yaml;
|
using Markdig.Extensions.Yaml;
|
||||||
using Markdig.Syntax;
|
using Markdig.Syntax;
|
||||||
using Markdig.Syntax.Inlines;
|
using Markdig.Syntax.Inlines;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Containers.Markdown;
|
using osu.Framework.Graphics.Containers.Markdown;
|
||||||
using osu.Game.Graphics.Containers.Markdown;
|
using osu.Game.Graphics.Containers.Markdown;
|
||||||
|
using osu.Game.Online.API;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Wiki.Markdown
|
namespace osu.Game.Overlays.Wiki.Markdown
|
||||||
{
|
{
|
||||||
public class WikiMarkdownContainer : OsuMarkdownContainer
|
public class WikiMarkdownContainer : OsuMarkdownContainer
|
||||||
{
|
{
|
||||||
|
[Resolved]
|
||||||
|
private IAPIProvider api { get; set; }
|
||||||
|
|
||||||
public string CurrentPath
|
public string CurrentPath
|
||||||
{
|
{
|
||||||
set => DocumentUrl = $"{DocumentUrl}wiki/{value}";
|
set => DocumentUrl = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void AddMarkdownComponent(IMarkdownObject markdownObject, FillFlowContainer container, int level)
|
protected override void AddMarkdownComponent(IMarkdownObject markdownObject, FillFlowContainer container, int level)
|
||||||
|
82
osu.Game/Overlays/Wiki/WikiHeader.cs
Normal file
82
osu.Game/Overlays/Wiki/WikiHeader.cs
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
// 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;
|
||||||
|
using System.Linq;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.Wiki
|
||||||
|
{
|
||||||
|
public class WikiHeader : BreadcrumbControlOverlayHeader
|
||||||
|
{
|
||||||
|
private const string index_page_string = "index";
|
||||||
|
private const string index_path = "Main_Page";
|
||||||
|
|
||||||
|
public readonly Bindable<APIWikiPage> WikiPageData = new Bindable<APIWikiPage>();
|
||||||
|
|
||||||
|
public Action ShowIndexPage;
|
||||||
|
public Action ShowParentPage;
|
||||||
|
|
||||||
|
public WikiHeader()
|
||||||
|
{
|
||||||
|
TabControl.AddItem(index_page_string);
|
||||||
|
Current.Value = index_page_string;
|
||||||
|
|
||||||
|
WikiPageData.BindValueChanged(onWikiPageChange);
|
||||||
|
Current.BindValueChanged(onCurrentChange);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onWikiPageChange(ValueChangedEvent<APIWikiPage> e)
|
||||||
|
{
|
||||||
|
if (e.NewValue == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
TabControl.Clear();
|
||||||
|
Current.Value = null;
|
||||||
|
|
||||||
|
TabControl.AddItem(index_page_string);
|
||||||
|
|
||||||
|
if (e.NewValue.Path == index_path)
|
||||||
|
{
|
||||||
|
Current.Value = index_page_string;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.NewValue.Subtitle != null)
|
||||||
|
TabControl.AddItem(e.NewValue.Subtitle);
|
||||||
|
|
||||||
|
TabControl.AddItem(e.NewValue.Title);
|
||||||
|
Current.Value = e.NewValue.Title;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onCurrentChange(ValueChangedEvent<string> e)
|
||||||
|
{
|
||||||
|
if (e.NewValue == TabControl.Items.LastOrDefault())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (e.NewValue == index_page_string)
|
||||||
|
{
|
||||||
|
ShowIndexPage?.Invoke();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ShowParentPage?.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override Drawable CreateBackground() => new OverlayHeaderBackground(@"Headers/wiki");
|
||||||
|
|
||||||
|
protected override OverlayTitle CreateTitle() => new WikiHeaderTitle();
|
||||||
|
|
||||||
|
private class WikiHeaderTitle : OverlayTitle
|
||||||
|
{
|
||||||
|
public WikiHeaderTitle()
|
||||||
|
{
|
||||||
|
Title = "wiki";
|
||||||
|
Description = "knowledge base";
|
||||||
|
IconTexture = "Icons/Hexacons/wiki";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -13,6 +13,7 @@ using osu.Framework.Graphics.Shapes;
|
|||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Containers.Markdown;
|
using osu.Game.Graphics.Containers.Markdown;
|
||||||
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Overlays.Wiki.Markdown;
|
using osu.Game.Overlays.Wiki.Markdown;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
@ -37,7 +38,7 @@ namespace osu.Game.Overlays.Wiki
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OverlayColourProvider colourProvider)
|
private void load(OverlayColourProvider colourProvider, IAPIProvider api)
|
||||||
{
|
{
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
@ -61,6 +62,7 @@ namespace osu.Game.Overlays.Wiki
|
|||||||
},
|
},
|
||||||
panelContainer = new WikiPanelMarkdownContainer(isFullWidth)
|
panelContainer = new WikiPanelMarkdownContainer(isFullWidth)
|
||||||
{
|
{
|
||||||
|
CurrentPath = $@"{api.WebsiteRootUrl}/wiki/",
|
||||||
Text = text,
|
Text = text,
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
|
148
osu.Game/Overlays/WikiOverlay.cs
Normal file
148
osu.Game/Overlays/WikiOverlay.cs
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
// 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 System.Threading;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Online.API;
|
||||||
|
using osu.Game.Online.API.Requests;
|
||||||
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
|
using osu.Game.Overlays.Wiki;
|
||||||
|
using osu.Game.Overlays.Wiki.Markdown;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays
|
||||||
|
{
|
||||||
|
public class WikiOverlay : OnlineOverlay<WikiHeader>
|
||||||
|
{
|
||||||
|
private const string index_path = @"main_page";
|
||||||
|
|
||||||
|
private readonly Bindable<string> path = new Bindable<string>(index_path);
|
||||||
|
|
||||||
|
private readonly Bindable<APIWikiPage> wikiData = new Bindable<APIWikiPage>();
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private IAPIProvider api { get; set; }
|
||||||
|
|
||||||
|
private GetWikiRequest request;
|
||||||
|
|
||||||
|
private CancellationTokenSource cancellationToken;
|
||||||
|
|
||||||
|
private bool displayUpdateRequired = true;
|
||||||
|
|
||||||
|
public WikiOverlay()
|
||||||
|
: base(OverlayColourScheme.Orange, false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ShowPage(string pagePath = index_path)
|
||||||
|
{
|
||||||
|
path.Value = pagePath.Trim('/');
|
||||||
|
Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override WikiHeader CreateHeader() => new WikiHeader
|
||||||
|
{
|
||||||
|
ShowIndexPage = () => ShowPage(),
|
||||||
|
ShowParentPage = showParentPage,
|
||||||
|
};
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
path.BindValueChanged(onPathChanged);
|
||||||
|
wikiData.BindTo(Header.WikiPageData);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void PopIn()
|
||||||
|
{
|
||||||
|
base.PopIn();
|
||||||
|
|
||||||
|
if (displayUpdateRequired)
|
||||||
|
{
|
||||||
|
path.TriggerChange();
|
||||||
|
displayUpdateRequired = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void PopOutComplete()
|
||||||
|
{
|
||||||
|
base.PopOutComplete();
|
||||||
|
displayUpdateRequired = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void LoadDisplay(Drawable display)
|
||||||
|
{
|
||||||
|
ScrollFlow.ScrollToStart();
|
||||||
|
LoadComponentAsync(display, loaded =>
|
||||||
|
{
|
||||||
|
Child = loaded;
|
||||||
|
Loading.Hide();
|
||||||
|
}, (cancellationToken = new CancellationTokenSource()).Token);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onPathChanged(ValueChangedEvent<string> e)
|
||||||
|
{
|
||||||
|
cancellationToken?.Cancel();
|
||||||
|
request?.Cancel();
|
||||||
|
|
||||||
|
request = new GetWikiRequest(e.NewValue);
|
||||||
|
|
||||||
|
Loading.Show();
|
||||||
|
|
||||||
|
request.Success += response => Schedule(() => onSuccess(response));
|
||||||
|
request.Failure += _ => Schedule(() => LoadDisplay(Empty()));
|
||||||
|
|
||||||
|
api.PerformAsync(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onSuccess(APIWikiPage response)
|
||||||
|
{
|
||||||
|
wikiData.Value = response;
|
||||||
|
|
||||||
|
if (response.Layout == index_path)
|
||||||
|
{
|
||||||
|
LoadDisplay(new WikiMainPage
|
||||||
|
{
|
||||||
|
Markdown = response.Markdown,
|
||||||
|
Padding = new MarginPadding
|
||||||
|
{
|
||||||
|
Vertical = 20,
|
||||||
|
Horizontal = 50,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LoadDisplay(new WikiMarkdownContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
CurrentPath = $@"{api.WebsiteRootUrl}/wiki/{path.Value}/",
|
||||||
|
Text = response.Markdown,
|
||||||
|
DocumentMargin = new MarginPadding(0),
|
||||||
|
DocumentPadding = new MarginPadding
|
||||||
|
{
|
||||||
|
Vertical = 20,
|
||||||
|
Left = 30,
|
||||||
|
Right = 50,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showParentPage()
|
||||||
|
{
|
||||||
|
var parentPath = string.Join("/", path.Value.Split('/').SkipLast(1));
|
||||||
|
ShowPage(parentPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Dispose(bool isDisposing)
|
||||||
|
{
|
||||||
|
cancellationToken?.Cancel();
|
||||||
|
request?.Cancel();
|
||||||
|
base.Dispose(isDisposing);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,31 +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 osu.Framework.Bindables;
|
|
||||||
using osu.Framework.Graphics;
|
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Objects.Drawables
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// An interface that exposes properties required for scrolling hit objects to be properly displayed.
|
|
||||||
/// </summary>
|
|
||||||
internal interface IScrollingHitObject : IDrawable
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Time offset before the hit object start time at which this <see cref="IScrollingHitObject"/> becomes visible and the time offset
|
|
||||||
/// after the hit object's end time after which it expires.
|
|
||||||
///
|
|
||||||
/// <para>
|
|
||||||
/// This provides only a default life time range, however classes inheriting from <see cref="IScrollingHitObject"/> should override
|
|
||||||
/// their life times if more tight control is desired.
|
|
||||||
/// </para>
|
|
||||||
/// </summary>
|
|
||||||
BindableDouble LifetimeOffset { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Axes which this <see cref="IScrollingHitObject"/> will scroll through.
|
|
||||||
/// This is set by the container which this scrolls through.
|
|
||||||
/// </summary>
|
|
||||||
Axes ScrollingAxes { set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -122,39 +122,42 @@ namespace osu.Game.Rulesets.UI
|
|||||||
var entry = (HitObjectLifetimeEntry)lifetimeEntry;
|
var entry = (HitObjectLifetimeEntry)lifetimeEntry;
|
||||||
Debug.Assert(!aliveDrawableMap.ContainsKey(entry));
|
Debug.Assert(!aliveDrawableMap.ContainsKey(entry));
|
||||||
|
|
||||||
bool isNonPooled = nonPooledDrawableMap.TryGetValue(entry, out var drawable);
|
bool isPooled = !nonPooledDrawableMap.TryGetValue(entry, out var drawable);
|
||||||
drawable ??= pooledObjectProvider?.GetPooledDrawableRepresentation(entry.HitObject, null);
|
drawable ??= pooledObjectProvider?.GetPooledDrawableRepresentation(entry.HitObject, null);
|
||||||
if (drawable == null)
|
if (drawable == null)
|
||||||
throw new InvalidOperationException($"A drawable representation could not be retrieved for hitobject type: {entry.HitObject.GetType().ReadableName()}.");
|
throw new InvalidOperationException($"A drawable representation could not be retrieved for hitobject type: {entry.HitObject.GetType().ReadableName()}.");
|
||||||
|
|
||||||
aliveDrawableMap[entry] = drawable;
|
aliveDrawableMap[entry] = drawable;
|
||||||
OnAdd(drawable);
|
|
||||||
|
|
||||||
if (isNonPooled) return;
|
|
||||||
|
|
||||||
|
if (isPooled)
|
||||||
|
{
|
||||||
addDrawable(drawable);
|
addDrawable(drawable);
|
||||||
HitObjectUsageBegan?.Invoke(entry.HitObject);
|
HitObjectUsageBegan?.Invoke(entry.HitObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OnAdd(drawable);
|
||||||
|
}
|
||||||
|
|
||||||
private void entryBecameDead(LifetimeEntry lifetimeEntry)
|
private void entryBecameDead(LifetimeEntry lifetimeEntry)
|
||||||
{
|
{
|
||||||
var entry = (HitObjectLifetimeEntry)lifetimeEntry;
|
var entry = (HitObjectLifetimeEntry)lifetimeEntry;
|
||||||
Debug.Assert(aliveDrawableMap.ContainsKey(entry));
|
Debug.Assert(aliveDrawableMap.ContainsKey(entry));
|
||||||
|
|
||||||
var drawable = aliveDrawableMap[entry];
|
var drawable = aliveDrawableMap[entry];
|
||||||
bool isNonPooled = nonPooledDrawableMap.ContainsKey(entry);
|
bool isPooled = !nonPooledDrawableMap.ContainsKey(entry);
|
||||||
|
|
||||||
drawable.OnKilled();
|
drawable.OnKilled();
|
||||||
aliveDrawableMap.Remove(entry);
|
aliveDrawableMap.Remove(entry);
|
||||||
OnRemove(drawable);
|
|
||||||
|
|
||||||
if (isNonPooled) return;
|
|
||||||
|
|
||||||
|
if (isPooled)
|
||||||
|
{
|
||||||
removeDrawable(drawable);
|
removeDrawable(drawable);
|
||||||
// The hit object is not freed when the DHO was not pooled.
|
|
||||||
HitObjectUsageFinished?.Invoke(entry.HitObject);
|
HitObjectUsageFinished?.Invoke(entry.HitObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OnRemove(drawable);
|
||||||
|
}
|
||||||
|
|
||||||
private void addDrawable(DrawableHitObject drawable)
|
private void addDrawable(DrawableHitObject drawable)
|
||||||
{
|
{
|
||||||
drawable.OnNewResult += onNewResult;
|
drawable.OnNewResult += onNewResult;
|
||||||
@ -211,21 +214,16 @@ namespace osu.Game.Rulesets.UI
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Invoked when a <see cref="DrawableHitObject"/> is added to this container.
|
/// Invoked after a <see cref="DrawableHitObject"/> is added to this container.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
|
||||||
/// This method is not invoked for nested <see cref="DrawableHitObject"/>s.
|
|
||||||
/// </remarks>
|
|
||||||
protected virtual void OnAdd(DrawableHitObject drawableHitObject)
|
protected virtual void OnAdd(DrawableHitObject drawableHitObject)
|
||||||
{
|
{
|
||||||
|
Debug.Assert(drawableHitObject.LoadState >= LoadState.Ready);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Invoked when a <see cref="DrawableHitObject"/> is removed from this container.
|
/// Invoked after a <see cref="DrawableHitObject"/> is removed from this container.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
|
||||||
/// This method is not invoked for nested <see cref="DrawableHitObject"/>s.
|
|
||||||
/// </remarks>
|
|
||||||
protected virtual void OnRemove(DrawableHitObject drawableHitObject)
|
protected virtual void OnRemove(DrawableHitObject drawableHitObject)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -18,12 +18,7 @@ namespace osu.Game.Rulesets.UI.Scrolling
|
|||||||
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
|
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Hit objects which require lifetime computation in the next update call.
|
/// A set of top-level <see cref="DrawableHitObject"/>s which have an up-to-date layout.
|
||||||
/// </summary>
|
|
||||||
private readonly HashSet<DrawableHitObject> toComputeLifetime = new HashSet<DrawableHitObject>();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// A set containing all <see cref="HitObjectContainer.AliveObjects"/> which have an up-to-date layout.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly HashSet<DrawableHitObject> layoutComputed = new HashSet<DrawableHitObject>();
|
private readonly HashSet<DrawableHitObject> layoutComputed = new HashSet<DrawableHitObject>();
|
||||||
|
|
||||||
@ -54,7 +49,6 @@ namespace osu.Game.Rulesets.UI.Scrolling
|
|||||||
{
|
{
|
||||||
base.Clear();
|
base.Clear();
|
||||||
|
|
||||||
toComputeLifetime.Clear();
|
|
||||||
layoutComputed.Clear();
|
layoutComputed.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +77,7 @@ namespace osu.Game.Rulesets.UI.Scrolling
|
|||||||
|
|
||||||
flipPositionIfRequired(ref position);
|
flipPositionIfRequired(ref position);
|
||||||
|
|
||||||
return scrollingInfo.Algorithm.TimeAt(position, Time.Current, scrollingInfo.TimeRange.Value, getLength());
|
return scrollingInfo.Algorithm.TimeAt(position, Time.Current, scrollingInfo.TimeRange.Value, scrollLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -91,7 +85,7 @@ namespace osu.Game.Rulesets.UI.Scrolling
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public Vector2 ScreenSpacePositionAtTime(double time)
|
public Vector2 ScreenSpacePositionAtTime(double time)
|
||||||
{
|
{
|
||||||
var pos = scrollingInfo.Algorithm.PositionAt(time, Time.Current, scrollingInfo.TimeRange.Value, getLength());
|
var pos = scrollingInfo.Algorithm.PositionAt(time, Time.Current, scrollingInfo.TimeRange.Value, scrollLength);
|
||||||
|
|
||||||
flipPositionIfRequired(ref pos);
|
flipPositionIfRequired(ref pos);
|
||||||
|
|
||||||
@ -106,7 +100,9 @@ namespace osu.Game.Rulesets.UI.Scrolling
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private float getLength()
|
private float scrollLength
|
||||||
|
{
|
||||||
|
get
|
||||||
{
|
{
|
||||||
switch (scrollingInfo.Direction.Value)
|
switch (scrollingInfo.Direction.Value)
|
||||||
{
|
{
|
||||||
@ -118,6 +114,7 @@ namespace osu.Game.Rulesets.UI.Scrolling
|
|||||||
return DrawHeight;
|
return DrawHeight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private float getBreadth()
|
private float getBreadth()
|
||||||
{
|
{
|
||||||
@ -150,83 +147,42 @@ namespace osu.Game.Rulesets.UI.Scrolling
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnAdd(DrawableHitObject drawableHitObject) => onAddRecursive(drawableHitObject);
|
protected override void OnAdd(DrawableHitObject drawableHitObject)
|
||||||
|
|
||||||
protected override void OnRemove(DrawableHitObject drawableHitObject) => onRemoveRecursive(drawableHitObject);
|
|
||||||
|
|
||||||
private void onAddRecursive(DrawableHitObject hitObject)
|
|
||||||
{
|
{
|
||||||
invalidateHitObject(hitObject);
|
invalidateHitObject(drawableHitObject);
|
||||||
|
drawableHitObject.DefaultsApplied += invalidateHitObject;
|
||||||
hitObject.DefaultsApplied += invalidateHitObject;
|
|
||||||
|
|
||||||
foreach (var nested in hitObject.NestedHitObjects)
|
|
||||||
onAddRecursive(nested);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onRemoveRecursive(DrawableHitObject hitObject)
|
protected override void OnRemove(DrawableHitObject drawableHitObject)
|
||||||
{
|
{
|
||||||
toComputeLifetime.Remove(hitObject);
|
layoutComputed.Remove(drawableHitObject);
|
||||||
layoutComputed.Remove(hitObject);
|
|
||||||
|
|
||||||
hitObject.DefaultsApplied -= invalidateHitObject;
|
drawableHitObject.DefaultsApplied -= invalidateHitObject;
|
||||||
|
|
||||||
foreach (var nested in hitObject.NestedHitObjects)
|
|
||||||
onRemoveRecursive(nested);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Make this <see cref="DrawableHitObject"/> lifetime and layout computed in next update.
|
|
||||||
/// </summary>
|
|
||||||
private void invalidateHitObject(DrawableHitObject hitObject)
|
private void invalidateHitObject(DrawableHitObject hitObject)
|
||||||
{
|
{
|
||||||
// Lifetime computation is delayed until next update because
|
hitObject.LifetimeStart = computeOriginAdjustedLifetimeStart(hitObject);
|
||||||
// when the hit object is not pooled this container is not loaded here and `scrollLength` cannot be computed.
|
|
||||||
toComputeLifetime.Add(hitObject);
|
|
||||||
layoutComputed.Remove(hitObject);
|
layoutComputed.Remove(hitObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
private float scrollLength;
|
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
if (!layoutCache.IsValid)
|
if (layoutCache.IsValid) return;
|
||||||
{
|
|
||||||
toComputeLifetime.Clear();
|
|
||||||
|
|
||||||
foreach (var hitObject in Objects)
|
foreach (var hitObject in Objects)
|
||||||
{
|
{
|
||||||
if (hitObject.HitObject != null)
|
if (hitObject.HitObject != null)
|
||||||
toComputeLifetime.Add(hitObject);
|
invalidateHitObject(hitObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
layoutComputed.Clear();
|
|
||||||
|
|
||||||
scrollingInfo.Algorithm.Reset();
|
scrollingInfo.Algorithm.Reset();
|
||||||
|
|
||||||
switch (direction.Value)
|
|
||||||
{
|
|
||||||
case ScrollingDirection.Up:
|
|
||||||
case ScrollingDirection.Down:
|
|
||||||
scrollLength = DrawSize.Y;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
scrollLength = DrawSize.X;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
layoutCache.Validate();
|
layoutCache.Validate();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var hitObject in toComputeLifetime)
|
|
||||||
hitObject.LifetimeStart = computeOriginAdjustedLifetimeStart(hitObject);
|
|
||||||
|
|
||||||
toComputeLifetime.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void UpdateAfterChildrenLife()
|
protected override void UpdateAfterChildrenLife()
|
||||||
{
|
{
|
||||||
base.UpdateAfterChildrenLife();
|
base.UpdateAfterChildrenLife();
|
||||||
|
@ -39,7 +39,6 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
|||||||
public event Action<SelectionState> StateChanged;
|
public event Action<SelectionState> StateChanged;
|
||||||
|
|
||||||
private readonly Box selectionBox;
|
private readonly Box selectionBox;
|
||||||
private CachedModelDependencyContainer<Room> dependencies;
|
|
||||||
|
|
||||||
[Resolved(canBeNull: true)]
|
[Resolved(canBeNull: true)]
|
||||||
private OnlinePlayScreen parentScreen { get; set; }
|
private OnlinePlayScreen parentScreen { get; set; }
|
||||||
@ -209,9 +208,10 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
|||||||
|
|
||||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||||
{
|
{
|
||||||
dependencies = new CachedModelDependencyContainer<Room>(base.CreateChildDependencies(parent));
|
return new CachedModelDependencyContainer<Room>(base.CreateChildDependencies(parent))
|
||||||
dependencies.Model.Value = Room;
|
{
|
||||||
return dependencies;
|
Model = { Value = Room }
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
|
@ -54,12 +54,12 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
Logger.Log($"Polling adjusted (listing: {multiplayerRoomManager.TimeBetweenListingPolls.Value}, selection: {multiplayerRoomManager.TimeBetweenSelectionPolls.Value})");
|
Logger.Log($"Polling adjusted (listing: {multiplayerRoomManager.TimeBetweenListingPolls.Value}, selection: {multiplayerRoomManager.TimeBetweenSelectionPolls.Value})");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Room CreateNewRoom()
|
protected override Room CreateNewRoom() =>
|
||||||
|
new Room
|
||||||
{
|
{
|
||||||
var room = new Room { Name = { Value = $"{API.LocalUser}'s awesome room" } };
|
Name = { Value = $"{API.LocalUser}'s awesome room" },
|
||||||
room.Category.Value = RoomCategory.Realtime;
|
Category = { Value = RoomCategory.Realtime }
|
||||||
return room;
|
};
|
||||||
}
|
|
||||||
|
|
||||||
protected override string ScreenTitle => "Multiplayer";
|
protected override string ScreenTitle => "Multiplayer";
|
||||||
|
|
||||||
|
@ -96,15 +96,19 @@ namespace osu.Game.Screens.OnlinePlay
|
|||||||
{
|
{
|
||||||
itemSelected = true;
|
itemSelected = true;
|
||||||
|
|
||||||
var item = new PlaylistItem();
|
var item = new PlaylistItem
|
||||||
|
{
|
||||||
|
Beatmap =
|
||||||
|
{
|
||||||
|
Value = Beatmap.Value.BeatmapInfo
|
||||||
|
},
|
||||||
|
Ruleset =
|
||||||
|
{
|
||||||
|
Value = Ruleset.Value
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
item.Beatmap.Value = Beatmap.Value.BeatmapInfo;
|
|
||||||
item.Ruleset.Value = Ruleset.Value;
|
|
||||||
|
|
||||||
item.RequiredMods.Clear();
|
|
||||||
item.RequiredMods.AddRange(Mods.Value.Select(m => m.CreateCopy()));
|
item.RequiredMods.AddRange(Mods.Value.Select(m => m.CreateCopy()));
|
||||||
|
|
||||||
item.AllowedMods.Clear();
|
|
||||||
item.AllowedMods.AddRange(FreeMods.Value.Select(m => m.CreateCopy()));
|
item.AllowedMods.AddRange(FreeMods.Value.Select(m => m.CreateCopy()));
|
||||||
|
|
||||||
SelectItem(item);
|
SelectItem(item);
|
||||||
|
@ -31,12 +31,16 @@ namespace osu.Game.Tests.Beatmaps
|
|||||||
using (var stream = new LineBufferedReader(resStream))
|
using (var stream = new LineBufferedReader(resStream))
|
||||||
{
|
{
|
||||||
var decoder = Decoder.GetDecoder<Beatmap>(stream);
|
var decoder = Decoder.GetDecoder<Beatmap>(stream);
|
||||||
|
|
||||||
((LegacyBeatmapDecoder)decoder).ApplyOffsets = false;
|
((LegacyBeatmapDecoder)decoder).ApplyOffsets = false;
|
||||||
|
|
||||||
var working = new TestWorkingBeatmap(decoder.Decode(stream));
|
return new TestWorkingBeatmap(decoder.Decode(stream))
|
||||||
working.BeatmapInfo.Ruleset = CreateRuleset().RulesetInfo;
|
{
|
||||||
|
BeatmapInfo =
|
||||||
return working;
|
{
|
||||||
|
Ruleset = CreateRuleset().RulesetInfo
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="ppy.osu.Framework" Version="2021.528.0" />
|
<PackageReference Include="ppy.osu.Framework" Version="2021.528.0" />
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.422.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.525.0" />
|
||||||
<PackageReference Include="Sentry" Version="3.3.4" />
|
<PackageReference Include="Sentry" Version="3.3.4" />
|
||||||
<PackageReference Include="SharpCompress" Version="0.28.2" />
|
<PackageReference Include="SharpCompress" Version="0.28.2" />
|
||||||
<PackageReference Include="NUnit" Version="3.13.2" />
|
<PackageReference Include="NUnit" Version="3.13.2" />
|
||||||
|
@ -71,7 +71,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup Label="Package References">
|
<ItemGroup Label="Package References">
|
||||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2021.528.0" />
|
<PackageReference Include="ppy.osu.Framework.iOS" Version="2021.528.0" />
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.422.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.525.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net5.0 / net6.0) -->
|
<!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net5.0 / net6.0) -->
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
Loading…
Reference in New Issue
Block a user