diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index 9ac2cabe9f..8d451a92e4 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -42,6 +42,8 @@ protected override void InitialiseDefaults() if (!val) Set(OsuSetting.SavePassword, false); }; + Set(OsuSetting.WarnAboutOpeningExternalLink, true); + // Audio Set(OsuSetting.VolumeInactive, 0.25, 0, 1, 0.01); @@ -148,6 +150,7 @@ public enum OsuSetting BeatmapSkins, BeatmapHitsounds, IncreaseFirstObjectVisibility, - ScoreDisplayMode + ScoreDisplayMode, + WarnAboutOpeningExternalLink } } diff --git a/osu.Game/Graphics/Containers/LinkFlowContainer.cs b/osu.Game/Graphics/Containers/LinkFlowContainer.cs index 11dd1925be..fd1aeae80a 100644 --- a/osu.Game/Graphics/Containers/LinkFlowContainer.cs +++ b/osu.Game/Graphics/Containers/LinkFlowContainer.cs @@ -7,7 +7,9 @@ using osu.Framework.Allocation; using osu.Framework.Graphics.Sprites; using System.Collections.Generic; +using osu.Framework.Configuration; using osu.Framework.Platform; +using osu.Game.Configuration; using osu.Game.Overlays; using osu.Game.Overlays.Chat; using osu.Game.Overlays.Notifications; @@ -25,16 +27,20 @@ public LinkFlowContainer(Action defaultCreationParameters = null) private Action showNotImplementedError; private GameHost host; + private DialogOverlay dialogOverlay; + private Bindable warnAboutOpeningExternal; [BackgroundDependencyLoader(true)] - private void load(OsuGame game, NotificationOverlay notifications, GameHost host, DialogOverlay dialogOverlay) + private void load(OsuGame game, NotificationOverlay notifications, GameHost host, DialogOverlay dialogOverlay, OsuConfigManager config) { // will be null in tests this.game = game; this.host = host; this.dialogOverlay = dialogOverlay; + warnAboutOpeningExternal = config.GetBindable(OsuSetting.WarnAboutOpeningExternalLink); + showNotImplementedError = () => notifications?.Post(new SimpleNotification { Text = @"This link type is not yet supported!", @@ -91,7 +97,11 @@ public void AddLink(string text, string url, LinkAction linkType = LinkAction.Ex showNotImplementedError?.Invoke(); break; case LinkAction.External: - dialogOverlay.Push(new ExternalLinkDialog(url, () => host.OpenUrlExternally(url))); + void externalAction() => host.OpenUrlExternally(url); + if (warnAboutOpeningExternal) + dialogOverlay.Push(new ExternalLinkDialog(url, externalAction)); + else + externalAction(); break; case LinkAction.OpenUserProfile: if (long.TryParse(linkArgument, out long userId)) diff --git a/osu.Game/Overlays/Settings/Sections/Online/WebSettings.cs b/osu.Game/Overlays/Settings/Sections/Online/WebSettings.cs new file mode 100644 index 0000000000..e2a7aef2d7 --- /dev/null +++ b/osu.Game/Overlays/Settings/Sections/Online/WebSettings.cs @@ -0,0 +1,27 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Game.Configuration; + +namespace osu.Game.Overlays.Settings.Sections.Online +{ + public class WebSettings : SettingsSubsection + { + protected override string Header => "Web"; + + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) + { + Children = new Drawable[] + { + new SettingsCheckbox + { + LabelText = "Warn about opening external links", + Bindable = config.GetBindable(OsuSetting.WarnAboutOpeningExternalLink) + }, + }; + } + } +} diff --git a/osu.Game/Overlays/Settings/Sections/OnlineSection.cs b/osu.Game/Overlays/Settings/Sections/OnlineSection.cs index 28cb503288..3a2e52d2eb 100644 --- a/osu.Game/Overlays/Settings/Sections/OnlineSection.cs +++ b/osu.Game/Overlays/Settings/Sections/OnlineSection.cs @@ -3,6 +3,7 @@ using osu.Framework.Graphics; using osu.Game.Graphics; +using osu.Game.Overlays.Settings.Sections.Online; namespace osu.Game.Overlays.Settings.Sections { @@ -15,6 +16,7 @@ public OnlineSection() { Children = new Drawable[] { + new WebSettings() }; } }