mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 16:19:35 +08:00
Merge branch 'master' into fix-beatmap-links
This commit is contained in:
commit
ce219cda53
@ -12,6 +12,7 @@ using osu.Framework.Platform;
|
|||||||
using osu.Game;
|
using osu.Game;
|
||||||
using OpenTK.Input;
|
using OpenTK.Input;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
|
using osu.Desktop.Updater;
|
||||||
using osu.Framework.Platform.Windows;
|
using osu.Framework.Platform.Windows;
|
||||||
|
|
||||||
namespace osu.Desktop
|
namespace osu.Desktop
|
||||||
@ -38,6 +39,52 @@ namespace osu.Desktop
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
if (!noVersionOverlay)
|
||||||
|
{
|
||||||
|
LoadComponentAsync(new VersionManager { Depth = int.MinValue }, v =>
|
||||||
|
{
|
||||||
|
Add(v);
|
||||||
|
v.State = Visibility.Visible;
|
||||||
|
});
|
||||||
|
|
||||||
|
#if NET_FRAMEWORK
|
||||||
|
Add(new SquirrelUpdateManager());
|
||||||
|
#else
|
||||||
|
Add(new SimpleUpdateManager());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void SetHost(GameHost host)
|
||||||
|
{
|
||||||
|
base.SetHost(host);
|
||||||
|
var desktopWindow = host.Window as DesktopGameWindow;
|
||||||
|
if (desktopWindow != null)
|
||||||
|
{
|
||||||
|
desktopWindow.CursorState |= CursorState.Hidden;
|
||||||
|
|
||||||
|
desktopWindow.SetIconFromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream(GetType(), "lazer.ico"));
|
||||||
|
desktopWindow.Title = Name;
|
||||||
|
|
||||||
|
desktopWindow.FileDrop += fileDrop;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fileDrop(object sender, FileDropEventArgs e)
|
||||||
|
{
|
||||||
|
var filePaths = new[] { e.FileName };
|
||||||
|
|
||||||
|
var firstExtension = Path.GetExtension(filePaths.First());
|
||||||
|
|
||||||
|
if (filePaths.Any(f => Path.GetExtension(f) != firstExtension)) return;
|
||||||
|
|
||||||
|
Task.Factory.StartNew(() => Import(filePaths), TaskCreationOptions.LongRunning);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A method of accessing an osu-stable install in a controlled fashion.
|
/// A method of accessing an osu-stable install in a controlled fashion.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -77,45 +124,5 @@ namespace osu.Desktop
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
|
||||||
{
|
|
||||||
base.LoadComplete();
|
|
||||||
|
|
||||||
if (!noVersionOverlay)
|
|
||||||
{
|
|
||||||
LoadComponentAsync(new VersionManager { Depth = int.MinValue }, v =>
|
|
||||||
{
|
|
||||||
Add(v);
|
|
||||||
v.State = Visibility.Visible;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void SetHost(GameHost host)
|
|
||||||
{
|
|
||||||
base.SetHost(host);
|
|
||||||
var desktopWindow = host.Window as DesktopGameWindow;
|
|
||||||
if (desktopWindow != null)
|
|
||||||
{
|
|
||||||
desktopWindow.CursorState |= CursorState.Hidden;
|
|
||||||
|
|
||||||
desktopWindow.SetIconFromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream(GetType(), "lazer.ico"));
|
|
||||||
desktopWindow.Title = Name;
|
|
||||||
|
|
||||||
desktopWindow.FileDrop += fileDrop;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void fileDrop(object sender, FileDropEventArgs e)
|
|
||||||
{
|
|
||||||
var filePaths = new[] { e.FileName };
|
|
||||||
|
|
||||||
var firstExtension = Path.GetExtension(filePaths.First());
|
|
||||||
|
|
||||||
if (filePaths.Any(f => Path.GetExtension(f) != firstExtension)) return;
|
|
||||||
|
|
||||||
Task.Factory.StartNew(() => Import(filePaths), TaskCreationOptions.LongRunning);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,10 +91,6 @@ namespace osu.Desktop.Overlays
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#if NET_FRAMEWORK
|
|
||||||
Add(new SquirrelUpdateManager());
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
|
103
osu.Desktop/Updater/SimpleUpdateManager.cs
Normal file
103
osu.Desktop/Updater/SimpleUpdateManager.cs
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using osu.Framework;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.IO.Network;
|
||||||
|
using osu.Framework.Platform;
|
||||||
|
using osu.Game;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Overlays;
|
||||||
|
using osu.Game.Overlays.Notifications;
|
||||||
|
|
||||||
|
namespace osu.Desktop.Updater
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// An update manager that shows notifications if a newer release is detected.
|
||||||
|
/// Installation is left up to the user.
|
||||||
|
/// </summary>
|
||||||
|
internal class SimpleUpdateManager : CompositeDrawable
|
||||||
|
{
|
||||||
|
private NotificationOverlay notificationOverlay;
|
||||||
|
private string version;
|
||||||
|
private GameHost host;
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(NotificationOverlay notification, OsuGameBase game, GameHost host)
|
||||||
|
{
|
||||||
|
notificationOverlay = notification;
|
||||||
|
|
||||||
|
this.host = host;
|
||||||
|
version = game.Version;
|
||||||
|
|
||||||
|
if (game.IsDeployedBuild)
|
||||||
|
Schedule(() => Task.Run(() => checkForUpdateAsync()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void checkForUpdateAsync()
|
||||||
|
{
|
||||||
|
var releases = new JsonWebRequest<GitHubRelease>("https://api.github.com/repos/ppy/osu/releases/latest");
|
||||||
|
await releases.PerformAsync();
|
||||||
|
|
||||||
|
var latest = releases.ResponseObject;
|
||||||
|
|
||||||
|
if (latest.TagName != version)
|
||||||
|
{
|
||||||
|
notificationOverlay.Post(new SimpleNotification
|
||||||
|
{
|
||||||
|
Text = $"A newer release of osu! has been found ({version} → {latest.TagName}).\n\n"
|
||||||
|
+ "Click here to download the new version, which can be installed over the top of your existing installation",
|
||||||
|
Icon = FontAwesome.fa_upload,
|
||||||
|
Activated = () =>
|
||||||
|
{
|
||||||
|
host.OpenUrlExternally(getBestUrl(latest));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string getBestUrl(GitHubRelease release)
|
||||||
|
{
|
||||||
|
GitHubAsset bestAsset = null;
|
||||||
|
|
||||||
|
switch (RuntimeInfo.OS)
|
||||||
|
{
|
||||||
|
case RuntimeInfo.Platform.Windows:
|
||||||
|
bestAsset = release.Assets?.FirstOrDefault(f => f.Name.EndsWith(".exe"));
|
||||||
|
break;
|
||||||
|
case RuntimeInfo.Platform.MacOsx:
|
||||||
|
bestAsset = release.Assets?.FirstOrDefault(f => f.Name.EndsWith(".dmg"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return bestAsset?.BrowserDownloadUrl ?? release.HtmlUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GitHubRelease
|
||||||
|
{
|
||||||
|
[JsonProperty("html_url")]
|
||||||
|
public string HtmlUrl { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("tag_name")]
|
||||||
|
public string TagName { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("assets")]
|
||||||
|
public List<GitHubAsset> Assets { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GitHubAsset
|
||||||
|
{
|
||||||
|
[JsonProperty("name")]
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("browser_download_url")]
|
||||||
|
public string BrowserDownloadUrl { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#if NET_FRAMEWORK
|
#if NET_FRAMEWORK
|
||||||
using System;
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Colour;
|
using osu.Framework.Graphics.Colour;
|
||||||
@ -16,7 +17,7 @@ using OpenTK;
|
|||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
using Squirrel;
|
using Squirrel;
|
||||||
|
|
||||||
namespace osu.Desktop.Overlays
|
namespace osu.Desktop.Updater
|
||||||
{
|
{
|
||||||
public class SquirrelUpdateManager : Component
|
public class SquirrelUpdateManager : Component
|
||||||
{
|
{
|
||||||
@ -35,7 +36,7 @@ namespace osu.Desktop.Overlays
|
|||||||
notificationOverlay = notification;
|
notificationOverlay = notification;
|
||||||
|
|
||||||
if (game.IsDeployedBuild)
|
if (game.IsDeployedBuild)
|
||||||
Schedule(() => checkForUpdateAsync());
|
Schedule(() => Task.Run(() => checkForUpdateAsync()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void checkForUpdateAsync(bool useDeltaPatching = true, UpdateProgressNotification notification = null)
|
private async void checkForUpdateAsync(bool useDeltaPatching = true, UpdateProgressNotification notification = null)
|
@ -339,6 +339,8 @@ namespace osu.Game.Beatmaps
|
|||||||
{
|
{
|
||||||
var beatmapInfos = new List<BeatmapInfo>();
|
var beatmapInfos = new List<BeatmapInfo>();
|
||||||
|
|
||||||
|
bool invalidateOnlineIDs = false;
|
||||||
|
|
||||||
foreach (var name in reader.Filenames.Where(f => f.EndsWith(".osu")))
|
foreach (var name in reader.Filenames.Where(f => f.EndsWith(".osu")))
|
||||||
{
|
{
|
||||||
using (var raw = reader.GetStream(name))
|
using (var raw = reader.GetStream(name))
|
||||||
@ -355,10 +357,19 @@ namespace osu.Game.Beatmaps
|
|||||||
beatmap.BeatmapInfo.Hash = ms.ComputeSHA2Hash();
|
beatmap.BeatmapInfo.Hash = ms.ComputeSHA2Hash();
|
||||||
beatmap.BeatmapInfo.MD5Hash = ms.ComputeMD5Hash();
|
beatmap.BeatmapInfo.MD5Hash = ms.ComputeMD5Hash();
|
||||||
|
|
||||||
// check that no existing beatmap exists that is imported with the same online beatmap ID. if so, give it precedence.
|
if (beatmap.BeatmapInfo.OnlineBeatmapID.HasValue)
|
||||||
if (beatmap.BeatmapInfo.OnlineBeatmapID.HasValue && QueryBeatmap(b => b.OnlineBeatmapID.Value == beatmap.BeatmapInfo.OnlineBeatmapID.Value) != null)
|
{
|
||||||
|
var ourId = beatmap.BeatmapInfo.OnlineBeatmapID;
|
||||||
|
|
||||||
|
// check that no existing beatmap in database exists that is imported with the same online beatmap ID. if so, give it precedence.
|
||||||
|
if (QueryBeatmap(b => b.OnlineBeatmapID.Value == ourId) != null)
|
||||||
beatmap.BeatmapInfo.OnlineBeatmapID = null;
|
beatmap.BeatmapInfo.OnlineBeatmapID = null;
|
||||||
|
|
||||||
|
// check that no other beatmap in this imported set has a conflicting online beatmap ID. If so, presume *all* are incorrect.
|
||||||
|
if (beatmapInfos.Any(b => b.OnlineBeatmapID == ourId))
|
||||||
|
invalidateOnlineIDs = true;
|
||||||
|
}
|
||||||
|
|
||||||
RulesetInfo ruleset = rulesets.GetRuleset(beatmap.BeatmapInfo.RulesetID);
|
RulesetInfo ruleset = rulesets.GetRuleset(beatmap.BeatmapInfo.RulesetID);
|
||||||
|
|
||||||
beatmap.BeatmapInfo.Ruleset = ruleset;
|
beatmap.BeatmapInfo.Ruleset = ruleset;
|
||||||
@ -375,6 +386,9 @@ namespace osu.Game.Beatmaps
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (invalidateOnlineIDs)
|
||||||
|
beatmapInfos.ForEach(b => b.OnlineBeatmapID = null);
|
||||||
|
|
||||||
return beatmapInfos;
|
return beatmapInfos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ using osu.Game.Graphics.Cursor;
|
|||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Framework.Graphics.Performance;
|
using osu.Framework.Graphics.Performance;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
|
using osu.Framework.Input;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
using osu.Game.Audio;
|
using osu.Game.Audio;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
@ -30,6 +31,7 @@ using osu.Game.IO;
|
|||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
|
using OpenTK.Input;
|
||||||
using DebugUtils = osu.Game.Utils.DebugUtils;
|
using DebugUtils = osu.Game.Utils.DebugUtils;
|
||||||
|
|
||||||
namespace osu.Game
|
namespace osu.Game
|
||||||
@ -98,6 +100,8 @@ namespace osu.Game
|
|||||||
|
|
||||||
private DatabaseContextFactory contextFactory;
|
private DatabaseContextFactory contextFactory;
|
||||||
|
|
||||||
|
protected override UserInputManager CreateUserInputManager() => new OsuUserInputManager();
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
@ -267,5 +271,31 @@ namespace osu.Game
|
|||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class OsuUserInputManager : UserInputManager
|
||||||
|
{
|
||||||
|
protected override MouseButtonEventManager CreateButtonManagerFor(MouseButton button)
|
||||||
|
{
|
||||||
|
switch (button)
|
||||||
|
{
|
||||||
|
case MouseButton.Right:
|
||||||
|
return new RightMouseManager(button);
|
||||||
|
}
|
||||||
|
|
||||||
|
return base.CreateButtonManagerFor(button);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class RightMouseManager : MouseButtonEventManager
|
||||||
|
{
|
||||||
|
public RightMouseManager(MouseButton button)
|
||||||
|
: base(button)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool EnableDrag => true; // allow right-mouse dragging for absolute scroll in scroll containers.
|
||||||
|
public override bool EnableClick => false;
|
||||||
|
public override bool ChangeFocusOnClick => false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user