mirror of
https://github.com/ppy/osu.git
synced 2025-02-28 23:32:59 +08:00
Merge branch 'master' into fix-overlays-drag-closing
This commit is contained in:
commit
700fe5162d
@ -18,6 +18,7 @@ using osu.Game.Rulesets.Osu.Scoring;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Screens.Play;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.UI
|
||||
{
|
||||
@ -30,6 +31,8 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
{
|
||||
}
|
||||
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true; // always show the gameplay cursor
|
||||
|
||||
public override ScoreProcessor CreateScoreProcessor() => new OsuScoreProcessor(this);
|
||||
|
||||
protected override Playfield CreatePlayfield() => new OsuPlayfield();
|
||||
|
@ -228,7 +228,7 @@ namespace osu.Game.Tournament
|
||||
if (b.BeatmapInfo == null && b.ID > 0)
|
||||
{
|
||||
var req = new GetBeatmapRequest(new BeatmapInfo { OnlineBeatmapID = b.ID });
|
||||
req.Perform(API);
|
||||
API.Perform(req);
|
||||
b.BeatmapInfo = req.Result?.ToBeatmap(RulesetStore);
|
||||
|
||||
addedInfo = true;
|
||||
|
@ -398,7 +398,7 @@ namespace osu.Game.Beatmaps
|
||||
try
|
||||
{
|
||||
// intentionally blocking to limit web request concurrency
|
||||
req.Perform(api);
|
||||
api.Perform(req);
|
||||
|
||||
var res = req.Result;
|
||||
|
||||
|
@ -99,17 +99,7 @@ namespace osu.Game.Database
|
||||
currentDownloads.Add(request);
|
||||
PostNotification?.Invoke(notification);
|
||||
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
request.Perform(api);
|
||||
}
|
||||
catch (Exception error)
|
||||
{
|
||||
triggerFailure(error);
|
||||
}
|
||||
}, TaskCreationOptions.LongRunning);
|
||||
api.PerformAsync(request);
|
||||
|
||||
DownloadBegan?.Invoke(request);
|
||||
return true;
|
||||
|
@ -7,6 +7,7 @@ using System.Diagnostics;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
@ -198,6 +199,22 @@ namespace osu.Game.Online.API
|
||||
}
|
||||
}
|
||||
|
||||
public void Perform(APIRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
request.Perform(this);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// todo: fix exception handling
|
||||
request.Fail(e);
|
||||
}
|
||||
}
|
||||
|
||||
public Task PerformAsync(APIRequest request) =>
|
||||
Task.Factory.StartNew(() => Perform(request), TaskCreationOptions.LongRunning);
|
||||
|
||||
public void Login(string username, string password)
|
||||
{
|
||||
Debug.Assert(State == APIState.Offline);
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Users;
|
||||
@ -56,6 +57,10 @@ namespace osu.Game.Online.API
|
||||
{
|
||||
}
|
||||
|
||||
public void Perform(APIRequest request) { }
|
||||
|
||||
public Task PerformAsync(APIRequest request) => Task.CompletedTask;
|
||||
|
||||
public void Register(IOnlineComponent component)
|
||||
{
|
||||
Scheduler.Add(delegate { components.Add(component); });
|
||||
|
@ -1,6 +1,7 @@
|
||||
// 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.Threading.Tasks;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Users;
|
||||
|
||||
@ -42,6 +43,24 @@ namespace osu.Game.Online.API
|
||||
/// <param name="request">The request to perform.</param>
|
||||
void Queue(APIRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Perform a request immediately, bypassing any API state checks.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Can be used to run requests as a guest user.
|
||||
/// </remarks>
|
||||
/// <param name="request">The request to perform.</param>
|
||||
void Perform(APIRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Perform a request immediately, bypassing any API state checks.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Can be used to run requests as a guest user.
|
||||
/// </remarks>
|
||||
/// <param name="request">The request to perform.</param>
|
||||
Task PerformAsync(APIRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Register a component to receive state changes.
|
||||
/// </summary>
|
||||
|
@ -4,7 +4,6 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
@ -43,18 +42,7 @@ namespace osu.Game.Overlays.Changelog
|
||||
};
|
||||
req.Failure += _ => complete = true;
|
||||
|
||||
// This is done on a separate thread to support cancellation below
|
||||
Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
req.Perform(api);
|
||||
}
|
||||
catch
|
||||
{
|
||||
complete = true;
|
||||
}
|
||||
});
|
||||
api.PerformAsync(req);
|
||||
|
||||
while (!complete)
|
||||
{
|
||||
|
@ -191,15 +191,7 @@ namespace osu.Game.Overlays
|
||||
tcs.SetResult(false);
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
req.Perform(API);
|
||||
}
|
||||
catch
|
||||
{
|
||||
initialFetchTask = null;
|
||||
tcs.SetResult(false);
|
||||
}
|
||||
await API.PerformAsync(req);
|
||||
|
||||
await tcs.Task;
|
||||
});
|
||||
|
@ -34,6 +34,7 @@ using osu.Game.Rulesets.Configuration;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Play;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.UI
|
||||
{
|
||||
@ -331,6 +332,9 @@ namespace osu.Game.Rulesets.UI
|
||||
|
||||
protected override bool OnHover(HoverEvent e) => true; // required for IProvideCursor
|
||||
|
||||
// only show the cursor when within the playfield, by default.
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => Playfield.ReceivePositionalInputAt(screenSpacePos);
|
||||
|
||||
CursorContainer IProvideCursor.Cursor => Playfield.Cursor;
|
||||
|
||||
public override GameplayCursorContainer Cursor => Playfield.Cursor;
|
||||
|
@ -100,10 +100,13 @@ namespace osu.Game.Rulesets.UI
|
||||
public GameplayCursorContainer Cursor { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Provide an optional cursor which is to be used for gameplay.
|
||||
/// Provide a cursor which is to be used for gameplay.
|
||||
/// </summary>
|
||||
/// <returns>The cursor, or null if a cursor is not rqeuired.</returns>
|
||||
protected virtual GameplayCursorContainer CreateCursor() => null;
|
||||
/// <remarks>
|
||||
/// The default provided cursor is invisible when inside the bounds of the <see cref="Playfield"/>.
|
||||
/// </remarks>
|
||||
/// <returns>The cursor, or null to show the menu cursor.</returns>
|
||||
protected virtual GameplayCursorContainer CreateCursor() => new InvisibleCursorContainer();
|
||||
|
||||
/// <summary>
|
||||
/// Registers a <see cref="Playfield"/> as a nested <see cref="Playfield"/>.
|
||||
@ -143,5 +146,14 @@ namespace osu.Game.Rulesets.UI
|
||||
/// Creates the container that will be used to contain the <see cref="DrawableHitObject"/>s.
|
||||
/// </summary>
|
||||
protected virtual HitObjectContainer CreateHitObjectContainer() => new HitObjectContainer();
|
||||
|
||||
public class InvisibleCursorContainer : GameplayCursorContainer
|
||||
{
|
||||
protected override Drawable CreateCursor() => new InvisibleCursor();
|
||||
|
||||
private class InvisibleCursor : Drawable
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user