1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-30 08:33:20 +08:00
osu-lazer/osu.Game/Online/Chat/ExternalLinkOpener.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

41 lines
1.2 KiB
C#
Raw Normal View History

// 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.
2022-06-17 15:37:17 +08:00
#nullable disable
using osu.Framework.Allocation;
2019-02-21 18:04:31 +08:00
using osu.Framework.Bindables;
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 23:02:10 +08:00
[Resolved]
2020-02-14 21:14:00 +08:00
private GameHost host { get; set; }
2020-02-14 21:59:51 +08:00
[Resolved(CanBeNull = true)]
private IDialogOverlay dialogOverlay { get; set; }
2020-02-14 21:14:00 +08:00
2018-11-02 04:52:07 +08:00
private Bindable<bool> externalLinkWarning;
[BackgroundDependencyLoader(true)]
2020-02-14 21:14:00 +08:00
private void load(OsuConfigManager config)
{
2018-11-02 04:52:07 +08:00
externalLinkWarning = config.GetBindable<bool>(OsuSetting.ExternalLinkWarning);
}
public void OpenUrlExternally(string url, bool bypassWarning = false)
{
if (!bypassWarning && externalLinkWarning.Value)
2018-11-02 04:52:07 +08:00
dialogOverlay.Push(new ExternalLinkDialog(url, () => host.OpenUrlExternally(url)));
else
2018-11-02 04:52:07 +08:00
host.OpenUrlExternally(url);
}
}
}