mirror of
https://github.com/ppy/osu
synced 2024-12-15 11:25:29 +00:00
Added all files to the .csproj and also introduced basic action filtering when you set the URL on an OsuLinkSpriteText object
This commit is contained in:
parent
0aced85908
commit
6d9dcc6691
@ -7,6 +7,7 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Overlays;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
@ -20,6 +21,8 @@ namespace osu.Game.Graphics.Sprites
|
||||
{
|
||||
private readonly OsuHoverContainer content;
|
||||
|
||||
private BeatmapSetOverlay beatmapSetOverlay;
|
||||
|
||||
public override bool HandleInput => content.Action != null;
|
||||
|
||||
protected override Container<Drawable> Content => content ?? (Container<Drawable>)this;
|
||||
@ -39,7 +42,7 @@ namespace osu.Game.Graphics.Sprites
|
||||
if (value != null)
|
||||
{
|
||||
url = value;
|
||||
content.Action = () => Process.Start(value);
|
||||
loadAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -51,5 +54,45 @@ namespace osu.Game.Graphics.Sprites
|
||||
AutoSizeAxes = Axes.Both,
|
||||
});
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(BeatmapSetOverlay beatmapSetOverlay)
|
||||
{
|
||||
this.beatmapSetOverlay = beatmapSetOverlay;
|
||||
}
|
||||
|
||||
private void loadAction()
|
||||
{
|
||||
if (Url == null || String.IsNullOrEmpty(Url))
|
||||
return;
|
||||
|
||||
var url = Url;
|
||||
|
||||
if (url.StartsWith("https://")) url = url.Substring(8);
|
||||
else if (url.StartsWith("http://")) url = url.Substring(7);
|
||||
else content.Action = () => Process.Start(Url);
|
||||
|
||||
if (url.StartsWith("osu.ppy.sh/"))
|
||||
{
|
||||
url = url.Substring(11);
|
||||
if (url.StartsWith("s") || url.StartsWith("beatmapsets"))
|
||||
content.Action = () => beatmapSetOverlay.ShowBeatmapSet(getIdFromUrl(url));
|
||||
else if (url.StartsWith("b") || url.StartsWith("beatmaps"))
|
||||
content.Action = () => beatmapSetOverlay.ShowBeatmap(getIdFromUrl(url));
|
||||
// else if (url.StartsWith("d")) Maybe later
|
||||
}
|
||||
}
|
||||
|
||||
private int getIdFromUrl(string url)
|
||||
{
|
||||
var lastSlashIndex = url.LastIndexOf('/');
|
||||
if (lastSlashIndex == url.Length)
|
||||
{
|
||||
url = url.Substring(url.Length - 1);
|
||||
lastSlashIndex = url.LastIndexOf('/');
|
||||
}
|
||||
|
||||
return int.Parse(url.Substring(lastSlashIndex + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -286,6 +286,7 @@
|
||||
<DependentUpon>20171119065731_AddBeatmapOnlineIDUniqueConstraint.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Migrations\OsuDbContextModelSnapshot.cs" />
|
||||
<Compile Include="Online\API\Requests\GetBeatmapRequest.cs" />
|
||||
<Compile Include="Online\API\Requests\GetBeatmapSetRequest.cs" />
|
||||
<Compile Include="Online\API\Requests\GetBeatmapSetsResponse.cs" />
|
||||
<Compile Include="Online\Chat\ChatLinkSpriteText.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user