2019-01-24 16:43:03 +08:00
|
|
|
|
// 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.
|
2018-10-24 04:03:00 +08:00
|
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
2019-02-21 18:04:31 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
2018-10-24 04:03:00 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Platform;
|
|
|
|
|
using osu.Game.Configuration;
|
|
|
|
|
using osu.Game.Overlays;
|
|
|
|
|
using osu.Game.Overlays.Chat;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Online.Chat
|
|
|
|
|
{
|
|
|
|
|
public class ExternalLinkOpener : Component
|
|
|
|
|
{
|
|
|
|
|
private GameHost host;
|
|
|
|
|
private DialogOverlay dialogOverlay;
|
2018-11-02 04:52:07 +08:00
|
|
|
|
private Bindable<bool> externalLinkWarning;
|
2018-10-24 04:03:00 +08:00
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader(true)]
|
|
|
|
|
private void load(GameHost host, DialogOverlay dialogOverlay, OsuConfigManager config)
|
|
|
|
|
{
|
|
|
|
|
this.host = host;
|
|
|
|
|
this.dialogOverlay = dialogOverlay;
|
2018-11-02 04:52:07 +08:00
|
|
|
|
externalLinkWarning = config.GetBindable<bool>(OsuSetting.ExternalLinkWarning);
|
2018-10-24 04:03:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OpenUrlExternally(string url)
|
|
|
|
|
{
|
2019-02-21 17:56:34 +08:00
|
|
|
|
if (externalLinkWarning.Value)
|
2018-11-02 04:52:07 +08:00
|
|
|
|
dialogOverlay.Push(new ExternalLinkDialog(url, () => host.OpenUrlExternally(url)));
|
2018-10-24 04:03:00 +08:00
|
|
|
|
else
|
2018-11-02 04:52:07 +08:00
|
|
|
|
host.OpenUrlExternally(url);
|
2018-10-24 04:03:00 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|