2019-01-24 08:43:03 +00: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-23 20:03:00 +00:00
|
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
2019-02-21 10:04:31 +00:00
|
|
|
|
using osu.Framework.Bindables;
|
2018-10-23 20:03:00 +00: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
|
|
|
|
|
{
|
2020-02-14 15:02:10 +00:00
|
|
|
|
[Resolved]
|
2020-02-14 13:14:00 +00:00
|
|
|
|
private GameHost host { get; set; }
|
|
|
|
|
|
2020-02-14 13:59:51 +00:00
|
|
|
|
[Resolved(CanBeNull = true)]
|
2020-02-14 13:14:00 +00:00
|
|
|
|
private DialogOverlay dialogOverlay { get; set; }
|
|
|
|
|
|
2018-11-01 20:52:07 +00:00
|
|
|
|
private Bindable<bool> externalLinkWarning;
|
2018-10-23 20:03:00 +00:00
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader(true)]
|
2020-02-14 13:14:00 +00:00
|
|
|
|
private void load(OsuConfigManager config)
|
2018-10-23 20:03:00 +00:00
|
|
|
|
{
|
2018-11-01 20:52:07 +00:00
|
|
|
|
externalLinkWarning = config.GetBindable<bool>(OsuSetting.ExternalLinkWarning);
|
2018-10-23 20:03:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OpenUrlExternally(string url)
|
|
|
|
|
{
|
2019-02-21 09:56:34 +00:00
|
|
|
|
if (externalLinkWarning.Value)
|
2018-11-01 20:52:07 +00:00
|
|
|
|
dialogOverlay.Push(new ExternalLinkDialog(url, () => host.OpenUrlExternally(url)));
|
2018-10-23 20:03:00 +00:00
|
|
|
|
else
|
2018-11-01 20:52:07 +00:00
|
|
|
|
host.OpenUrlExternally(url);
|
2018-10-23 20:03:00 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|