mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 06:36:31 +09:00
Merge pull request #15052 from gagahpangeran/handle-changelog-link
Handle changelog link to open changelog overlay
This commit is contained in:
@ -509,5 +509,17 @@ namespace osu.Game.Tests.Chat
|
||||
Assert.AreEqual(LinkAction.External, result.Action);
|
||||
Assert.AreEqual("/relative", result.Argument);
|
||||
}
|
||||
|
||||
[TestCase("https://dev.ppy.sh/home/changelog", "")]
|
||||
[TestCase("https://dev.ppy.sh/home/changelog/lazer/2021.1012", "lazer/2021.1012")]
|
||||
public void TestChangelogLinks(string link, string expectedArg)
|
||||
{
|
||||
MessageFormatter.WebsiteRootUrl = "dev.ppy.sh";
|
||||
|
||||
LinkDetails result = MessageFormatter.GetLinkDetails(link);
|
||||
|
||||
Assert.AreEqual(LinkAction.OpenChangelog, result.Action);
|
||||
Assert.AreEqual(expectedArg, result.Argument);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -177,6 +177,24 @@ namespace osu.Game.Online.Chat
|
||||
|
||||
case "wiki":
|
||||
return new LinkDetails(LinkAction.OpenWiki, string.Join('/', args.Skip(3)));
|
||||
|
||||
case "home":
|
||||
if (mainArg != "changelog")
|
||||
// handle link other than changelog as external for now
|
||||
return new LinkDetails(LinkAction.External, url);
|
||||
|
||||
switch (args.Length)
|
||||
{
|
||||
case 4:
|
||||
// https://osu.ppy.sh/home/changelog
|
||||
return new LinkDetails(LinkAction.OpenChangelog, string.Empty);
|
||||
|
||||
case 6:
|
||||
// https://osu.ppy.sh/home/changelog/lazer/2021.1006
|
||||
return new LinkDetails(LinkAction.OpenChangelog, $"{args[4]}/{args[5]}");
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -324,6 +342,7 @@ namespace osu.Game.Online.Chat
|
||||
SearchBeatmapSet,
|
||||
OpenWiki,
|
||||
Custom,
|
||||
OpenChangelog,
|
||||
}
|
||||
|
||||
public class Link : IComparable<Link>
|
||||
|
@ -90,6 +90,8 @@ namespace osu.Game
|
||||
|
||||
private WikiOverlay wikiOverlay;
|
||||
|
||||
private ChangelogOverlay changelogOverlay;
|
||||
|
||||
private SkinEditorOverlay skinEditor;
|
||||
|
||||
private Container overlayContent;
|
||||
@ -336,6 +338,17 @@ namespace osu.Game
|
||||
ShowWiki(link.Argument);
|
||||
break;
|
||||
|
||||
case LinkAction.OpenChangelog:
|
||||
if (string.IsNullOrEmpty(link.Argument))
|
||||
ShowChangelogListing();
|
||||
else
|
||||
{
|
||||
var changelogArgs = link.Argument.Split("/");
|
||||
ShowChangelogBuild(changelogArgs[0], changelogArgs[1]);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new NotImplementedException($"This {nameof(LinkAction)} ({link.Action.ToString()}) is missing an associated action.");
|
||||
}
|
||||
@ -401,6 +414,18 @@ namespace osu.Game
|
||||
/// <param name="path">The wiki page to show</param>
|
||||
public void ShowWiki(string path) => waitForReady(() => wikiOverlay, _ => wikiOverlay.ShowPage(path));
|
||||
|
||||
/// <summary>
|
||||
/// Show changelog listing overlay
|
||||
/// </summary>
|
||||
public void ShowChangelogListing() => waitForReady(() => changelogOverlay, _ => changelogOverlay.ShowListing());
|
||||
|
||||
/// <summary>
|
||||
/// Show changelog's build as an overlay
|
||||
/// </summary>
|
||||
/// <param name="updateStream">The update stream name</param>
|
||||
/// <param name="version">The build version of the update stream</param>
|
||||
public void ShowChangelogBuild(string updateStream, string version) => waitForReady(() => changelogOverlay, _ => changelogOverlay.ShowBuild(updateStream, version));
|
||||
|
||||
/// <summary>
|
||||
/// Present a beatmap at song select immediately.
|
||||
/// The user should have already requested this interactively.
|
||||
@ -769,7 +794,7 @@ namespace osu.Game
|
||||
loadComponentSingleFile(chatOverlay = new ChatOverlay(), overlayContent.Add, true);
|
||||
loadComponentSingleFile(new MessageNotifier(), AddInternal, true);
|
||||
loadComponentSingleFile(Settings = new SettingsOverlay(), leftFloatingOverlayContent.Add, true);
|
||||
var changelogOverlay = loadComponentSingleFile(new ChangelogOverlay(), overlayContent.Add, true);
|
||||
loadComponentSingleFile(changelogOverlay = new ChangelogOverlay(), overlayContent.Add, true);
|
||||
loadComponentSingleFile(userProfile = new UserProfileOverlay(), overlayContent.Add, true);
|
||||
loadComponentSingleFile(beatmapSetOverlay = new BeatmapSetOverlay(), overlayContent.Add, true);
|
||||
loadComponentSingleFile(wikiOverlay = new WikiOverlay(), overlayContent.Add, true);
|
||||
|
Reference in New Issue
Block a user