1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 09:23:06 +08:00

External link warning code cleanup

This commit is contained in:
Roman Kapustin 2018-11-01 23:52:07 +03:00
parent 7401fabb5d
commit b4809f4417
5 changed files with 12 additions and 14 deletions

View File

@ -42,7 +42,7 @@ namespace osu.Game.Configuration
if (!val) Set(OsuSetting.SavePassword, false);
};
Set(OsuSetting.WarnAboutOpeningExternalLink, true);
Set(OsuSetting.ExternalLinkWarning, true);
// Audio
Set(OsuSetting.VolumeInactive, 0.25, 0, 1, 0.01);
@ -151,6 +151,6 @@ namespace osu.Game.Configuration
BeatmapHitsounds,
IncreaseFirstObjectVisibility,
ScoreDisplayMode,
WarnAboutOpeningExternalLink
ExternalLinkWarning
}
}

View File

@ -15,24 +15,22 @@ namespace osu.Game.Online.Chat
{
private GameHost host;
private DialogOverlay dialogOverlay;
private Bindable<bool> warnAboutOpeningExternal;
private Bindable<bool> externalLinkWarning;
[BackgroundDependencyLoader(true)]
private void load(GameHost host, DialogOverlay dialogOverlay, OsuConfigManager config)
{
this.host = host;
this.dialogOverlay = dialogOverlay;
warnAboutOpeningExternal = config.GetBindable<bool>(OsuSetting.WarnAboutOpeningExternalLink);
externalLinkWarning = config.GetBindable<bool>(OsuSetting.ExternalLinkWarning);
}
public void OpenUrlExternally(string url)
{
void externalAction() => host.OpenUrlExternally(url);
if (warnAboutOpeningExternal)
dialogOverlay.Push(new ExternalLinkDialog(url, externalAction));
if (externalLinkWarning)
dialogOverlay.Push(new ExternalLinkDialog(url, () => host.OpenUrlExternally(url)));
else
externalAction();
host.OpenUrlExternally(url);
}
}
}

View File

@ -104,9 +104,6 @@ namespace osu.Game
private readonly List<OverlayContainer> overlays = new List<OverlayContainer>();
private ExternalLinkOpener externalLinkOpener;
public void OpenUrlExternally(string url) => externalLinkOpener.OpenUrlExternally(url);
// todo: move this to SongSelect once Screen has the ability to unsuspend.
[Cached]
[Cached(Type = typeof(IBindable<IEnumerable<Mod>>))]
@ -182,6 +179,9 @@ namespace osu.Game
LocalConfig.BindWith(OsuSetting.VolumeInactive, inactiveVolumeAdjust);
}
private ExternalLinkOpener externalLinkOpener;
public void OpenUrlExternally(string url) => externalLinkOpener.OpenUrlExternally(url);
private ScheduledDelegate scoreLoad;
/// <summary>

View File

@ -14,7 +14,7 @@ namespace osu.Game.Overlays.Chat
BodyText = url;
Icon = FontAwesome.fa_warning;
HeaderText = "Confirm opening external link";
HeaderText = "Are you sure you want to open the following?";
Buttons = new PopupDialogButton[]
{
new PopupDialogOkButton

View File

@ -19,7 +19,7 @@ namespace osu.Game.Overlays.Settings.Sections.Online
new SettingsCheckbox
{
LabelText = "Warn about opening external links",
Bindable = config.GetBindable<bool>(OsuSetting.WarnAboutOpeningExternalLink)
Bindable = config.GetBindable<bool>(OsuSetting.ExternalLinkWarning)
},
};
}