mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Implement warn about opening external links option
This commit is contained in:
@ -42,6 +42,8 @@ namespace osu.Game.Configuration
|
|||||||
if (!val) Set(OsuSetting.SavePassword, false);
|
if (!val) Set(OsuSetting.SavePassword, false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Set(OsuSetting.WarnAboutOpeningExternalLink, true);
|
||||||
|
|
||||||
// Audio
|
// Audio
|
||||||
Set(OsuSetting.VolumeInactive, 0.25, 0, 1, 0.01);
|
Set(OsuSetting.VolumeInactive, 0.25, 0, 1, 0.01);
|
||||||
|
|
||||||
@ -148,6 +150,7 @@ namespace osu.Game.Configuration
|
|||||||
BeatmapSkins,
|
BeatmapSkins,
|
||||||
BeatmapHitsounds,
|
BeatmapHitsounds,
|
||||||
IncreaseFirstObjectVisibility,
|
IncreaseFirstObjectVisibility,
|
||||||
ScoreDisplayMode
|
ScoreDisplayMode,
|
||||||
|
WarnAboutOpeningExternalLink
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,9 @@ using System.Linq;
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using osu.Framework.Configuration;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Overlays.Chat;
|
using osu.Game.Overlays.Chat;
|
||||||
using osu.Game.Overlays.Notifications;
|
using osu.Game.Overlays.Notifications;
|
||||||
@ -25,16 +27,20 @@ namespace osu.Game.Graphics.Containers
|
|||||||
|
|
||||||
private Action showNotImplementedError;
|
private Action showNotImplementedError;
|
||||||
private GameHost host;
|
private GameHost host;
|
||||||
|
|
||||||
private DialogOverlay dialogOverlay;
|
private DialogOverlay dialogOverlay;
|
||||||
|
private Bindable<bool> warnAboutOpeningExternal;
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[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
|
// will be null in tests
|
||||||
this.game = game;
|
this.game = game;
|
||||||
this.host = host;
|
this.host = host;
|
||||||
this.dialogOverlay = dialogOverlay;
|
this.dialogOverlay = dialogOverlay;
|
||||||
|
|
||||||
|
warnAboutOpeningExternal = config.GetBindable<bool>(OsuSetting.WarnAboutOpeningExternalLink);
|
||||||
|
|
||||||
showNotImplementedError = () => notifications?.Post(new SimpleNotification
|
showNotImplementedError = () => notifications?.Post(new SimpleNotification
|
||||||
{
|
{
|
||||||
Text = @"This link type is not yet supported!",
|
Text = @"This link type is not yet supported!",
|
||||||
@ -91,7 +97,11 @@ namespace osu.Game.Graphics.Containers
|
|||||||
showNotImplementedError?.Invoke();
|
showNotImplementedError?.Invoke();
|
||||||
break;
|
break;
|
||||||
case LinkAction.External:
|
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;
|
break;
|
||||||
case LinkAction.OpenUserProfile:
|
case LinkAction.OpenUserProfile:
|
||||||
if (long.TryParse(linkArgument, out long userId))
|
if (long.TryParse(linkArgument, out long userId))
|
||||||
|
27
osu.Game/Overlays/Settings/Sections/Online/WebSettings.cs
Normal file
27
osu.Game/Overlays/Settings/Sections/Online/WebSettings.cs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// 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<bool>(OsuSetting.WarnAboutOpeningExternalLink)
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Overlays.Settings.Sections.Online;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Settings.Sections
|
namespace osu.Game.Overlays.Settings.Sections
|
||||||
{
|
{
|
||||||
@ -15,6 +16,7 @@ namespace osu.Game.Overlays.Settings.Sections
|
|||||||
{
|
{
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
|
new WebSettings()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user