mirror of
https://github.com/ppy/osu.git
synced 2024-12-05 09:42:54 +08:00
Compare commits
11 Commits
e25f7a4cb8
...
8d19337ac2
Author | SHA1 | Date | |
---|---|---|---|
|
8d19337ac2 | ||
|
f09d8f097a | ||
|
457957d3b8 | ||
|
2ceb3f6f85 | ||
|
ee369ef86d | ||
|
9a4c419c56 | ||
|
dbe2741982 | ||
|
83f8fa7472 | ||
|
9a89d402b9 | ||
|
2a7133d6d3 | ||
|
2417d4de83 |
47
osu.Game.Tests/Visual/Online/TestSceneImageProxying.cs
Normal file
47
osu.Game.Tests/Visual/Online/TestSceneImageProxying.cs
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Platform;
|
||||||
|
using osu.Game.Graphics.Containers.Markdown;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.Online
|
||||||
|
{
|
||||||
|
public partial class TestSceneImageProxying : OsuTestScene
|
||||||
|
{
|
||||||
|
[Resolved]
|
||||||
|
private GameHost host { get; set; } = null!;
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestExternalImageLink()
|
||||||
|
{
|
||||||
|
AddStep("load image", () => Child = new OsuMarkdownContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Text = "![](https://github.com/ppy/osu-wiki/blob/master/wiki/Announcement_messages/img/notification.png?raw=true)",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestLocalImageLink()
|
||||||
|
{
|
||||||
|
AddStep("load image", () => Child = new OsuMarkdownContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Text = "![](https://osu.ppy.sh/help/wiki/shared/news/banners/monthly-beatmapping-contest.png)",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestInvalidImageLink()
|
||||||
|
{
|
||||||
|
AddStep("load image", () => Child = new OsuMarkdownContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Text = "![](https://this-site-does-not-exist.com/img.png)",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -6,9 +6,10 @@ using osu.Framework.Audio;
|
|||||||
using osu.Framework.Audio.Track;
|
using osu.Framework.Audio.Track;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.IO.Stores;
|
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Online;
|
||||||
|
using osu.Game.Online.API;
|
||||||
|
|
||||||
namespace osu.Game.Audio
|
namespace osu.Game.Audio
|
||||||
{
|
{
|
||||||
@ -28,9 +29,9 @@ namespace osu.Game.Audio
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(AudioManager audioManager)
|
private void load(AudioManager audioManager, IAPIProvider api)
|
||||||
{
|
{
|
||||||
trackStore = audioManager.GetTrackStore(new OnlineStore());
|
trackStore = audioManager.GetTrackStore(new OsuOnlineStore(api.APIEndpointUrl));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -17,5 +17,8 @@ namespace osu.Game.Graphics.Containers.Markdown
|
|||||||
{
|
{
|
||||||
TooltipText = linkInline.Title;
|
TooltipText = linkInline.Title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override ImageContainer CreateImageContainer(string url)
|
||||||
|
=> base.CreateImageContainer($@"https://osu.ppy.sh/media-url?url={url}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,11 @@ namespace osu.Game.Localisation
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static LocalisableString CheckUpdate => new TranslatableString(getKey(@"check_update"), @"Check for updates");
|
public static LocalisableString CheckUpdate => new TranslatableString(getKey(@"check_update"), @"Check for updates");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// "Checking for updates"
|
||||||
|
/// </summary>
|
||||||
|
public static LocalisableString CheckingForUpdates => new TranslatableString(getKey(@"checking_for_updates"), @"Checking for updates");
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// "Open osu! folder"
|
/// "Open osu! folder"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
31
osu.Game/Online/OsuOnlineStore.cs
Normal file
31
osu.Game/Online/OsuOnlineStore.cs
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using osu.Framework.IO.Stores;
|
||||||
|
using osu.Framework.Logging;
|
||||||
|
|
||||||
|
namespace osu.Game.Online
|
||||||
|
{
|
||||||
|
public class OsuOnlineStore : OnlineStore
|
||||||
|
{
|
||||||
|
private readonly string apiEndpointUrl;
|
||||||
|
|
||||||
|
public OsuOnlineStore(string apiEndpointUrl)
|
||||||
|
{
|
||||||
|
this.apiEndpointUrl = apiEndpointUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override string GetLookupUrl(string url)
|
||||||
|
{
|
||||||
|
// add leading dot to avoid matching hosts named "<anything>ppy.sh"
|
||||||
|
if (!Uri.TryCreate(url, UriKind.Absolute, out Uri? uri) || !uri.Host.EndsWith(@".ppy.sh", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
Logger.Log($@"Blocking resource lookup from external website: {url}", LoggingTarget.Network, LogLevel.Important);
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -29,6 +29,7 @@ using osu.Framework.Input;
|
|||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Framework.Input.Handlers.Tablet;
|
using osu.Framework.Input.Handlers.Tablet;
|
||||||
|
using osu.Framework.IO.Stores;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
@ -824,6 +825,8 @@ namespace osu.Game
|
|||||||
|
|
||||||
protected override Container CreateScalingContainer() => new ScalingContainer(ScalingMode.Everything);
|
protected override Container CreateScalingContainer() => new ScalingContainer(ScalingMode.Everything);
|
||||||
|
|
||||||
|
protected override OnlineStore CreateOnlineStore() => new OsuOnlineStore(CreateEndpoints().APIEndpointUrl);
|
||||||
|
|
||||||
#region Beatmap progression
|
#region Beatmap progression
|
||||||
|
|
||||||
private void beatmapChanged(ValueChangedEvent<WorkingBeatmap> beatmap)
|
private void beatmapChanged(ValueChangedEvent<WorkingBeatmap> beatmap)
|
||||||
|
@ -277,7 +277,7 @@ namespace osu.Game
|
|||||||
dependencies.CacheAs(Storage);
|
dependencies.CacheAs(Storage);
|
||||||
|
|
||||||
var largeStore = new LargeTextureStore(Host.Renderer, Host.CreateTextureLoaderStore(new NamespacedResourceStore<byte[]>(Resources, @"Textures")));
|
var largeStore = new LargeTextureStore(Host.Renderer, Host.CreateTextureLoaderStore(new NamespacedResourceStore<byte[]>(Resources, @"Textures")));
|
||||||
largeStore.AddTextureSource(Host.CreateTextureLoaderStore(new OnlineStore()));
|
largeStore.AddTextureSource(Host.CreateTextureLoaderStore(CreateOnlineStore()));
|
||||||
dependencies.Cache(largeStore);
|
dependencies.Cache(largeStore);
|
||||||
|
|
||||||
dependencies.CacheAs(LocalConfig);
|
dependencies.CacheAs(LocalConfig);
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using osu.Framework;
|
using osu.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Extensions;
|
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
@ -13,6 +12,7 @@ using osu.Framework.Screens;
|
|||||||
using osu.Framework.Statistics;
|
using osu.Framework.Statistics;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Localisation;
|
using osu.Game.Localisation;
|
||||||
|
using osu.Game.Online.Multiplayer;
|
||||||
using osu.Game.Overlays.Notifications;
|
using osu.Game.Overlays.Notifications;
|
||||||
using osu.Game.Overlays.Settings.Sections.Maintenance;
|
using osu.Game.Overlays.Settings.Sections.Maintenance;
|
||||||
using osu.Game.Updater;
|
using osu.Game.Updater;
|
||||||
@ -36,8 +36,11 @@ namespace osu.Game.Overlays.Settings.Sections.General
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private Storage storage { get; set; } = null!;
|
private Storage storage { get; set; } = null!;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OsuGame? game { get; set; }
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuConfigManager config, OsuGame? game)
|
private void load(OsuConfigManager config)
|
||||||
{
|
{
|
||||||
Add(new SettingsEnumDropdown<ReleaseStream>
|
Add(new SettingsEnumDropdown<ReleaseStream>
|
||||||
{
|
{
|
||||||
@ -50,23 +53,7 @@ namespace osu.Game.Overlays.Settings.Sections.General
|
|||||||
Add(checkForUpdatesButton = new SettingsButton
|
Add(checkForUpdatesButton = new SettingsButton
|
||||||
{
|
{
|
||||||
Text = GeneralSettingsStrings.CheckUpdate,
|
Text = GeneralSettingsStrings.CheckUpdate,
|
||||||
Action = () =>
|
Action = () => checkForUpdates().FireAndForget()
|
||||||
{
|
|
||||||
checkForUpdatesButton.Enabled.Value = false;
|
|
||||||
Task.Run(updateManager.CheckForUpdateAsync).ContinueWith(task => Schedule(() =>
|
|
||||||
{
|
|
||||||
if (!task.GetResultSafely())
|
|
||||||
{
|
|
||||||
notifications?.Post(new SimpleNotification
|
|
||||||
{
|
|
||||||
Text = GeneralSettingsStrings.RunningLatestRelease(game!.Version),
|
|
||||||
Icon = FontAwesome.Solid.CheckCircle,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
checkForUpdatesButton.Enabled.Value = true;
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,6 +81,44 @@ namespace osu.Game.Overlays.Settings.Sections.General
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task checkForUpdates()
|
||||||
|
{
|
||||||
|
if (updateManager == null || game == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
checkForUpdatesButton.Enabled.Value = false;
|
||||||
|
|
||||||
|
var checkingNotification = new ProgressNotification
|
||||||
|
{
|
||||||
|
Text = GeneralSettingsStrings.CheckingForUpdates,
|
||||||
|
};
|
||||||
|
notifications?.Post(checkingNotification);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
bool foundUpdate = await updateManager.CheckForUpdateAsync().ConfigureAwait(true);
|
||||||
|
|
||||||
|
if (!foundUpdate)
|
||||||
|
{
|
||||||
|
notifications?.Post(new SimpleNotification
|
||||||
|
{
|
||||||
|
Text = GeneralSettingsStrings.RunningLatestRelease(game.Version),
|
||||||
|
Icon = FontAwesome.Solid.CheckCircle,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// This sequence allows the notification to be immediately dismissed.
|
||||||
|
checkingNotification.State = ProgressNotificationState.Cancelled;
|
||||||
|
checkingNotification.Close(false);
|
||||||
|
checkForUpdatesButton.Enabled.Value = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void exportLogs()
|
private void exportLogs()
|
||||||
{
|
{
|
||||||
ProgressNotification notification = new ProgressNotification
|
ProgressNotification notification = new ProgressNotification
|
||||||
|
Loading…
Reference in New Issue
Block a user