Merge branch 'master' into editor-timing-screen

This commit is contained in:
Dan Balasescu
2019-11-06 12:02:00 +09:00
committed by GitHub
52 changed files with 1355 additions and 410 deletions

View File

@ -254,6 +254,12 @@ namespace osu.Game.Screens.Edit.Compose.Components
{
Debug.Assert(!clickSelectionBegan);
// If a select blueprint is already hovered, disallow changes in selection.
// Exception is made when holding control, as deselection should still be allowed.
if (!e.CurrentState.Keyboard.ControlPressed &&
selectionHandler.SelectedBlueprints.Any(s => s.IsHovered))
return;
foreach (SelectionBlueprint blueprint in selectionBlueprints.AliveBlueprints)
{
if (blueprint.IsHovered)

View File

@ -8,21 +8,21 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
using osu.Framework.Input;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.States;
using osu.Game.Graphics;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
using osuTK;
using osuTK.Input;
namespace osu.Game.Screens.Edit.Compose.Components
{
/// <summary>
/// A component which outlines <see cref="DrawableHitObject"/>s and handles movement of selections.
/// </summary>
public class SelectionHandler : CompositeDrawable
public class SelectionHandler : CompositeDrawable, IKeyBindingHandler<PlatformAction>
{
public const float BORDER_RADIUS = 2;
@ -72,22 +72,21 @@ namespace osu.Game.Screens.Edit.Compose.Components
{
}
protected override bool OnKeyDown(KeyDownEvent e)
public bool OnPressed(PlatformAction action)
{
if (e.Repeat)
return base.OnKeyDown(e);
switch (e.Key)
switch (action.ActionMethod)
{
case Key.Delete:
case PlatformActionMethod.Delete:
foreach (var h in selectedBlueprints.ToList())
placementHandler.Delete(h.DrawableObject.HitObject);
return true;
}
return base.OnKeyDown(e);
return false;
}
public bool OnReleased(PlatformAction action) => action.ActionMethod == PlatformActionMethod.Delete;
#endregion
#region Selection Handling

View File

@ -81,7 +81,7 @@ namespace osu.Game.Screens.Multi.Components
Text = new LocalisedString((beatmap.Metadata.TitleUnicode, beatmap.Metadata.Title)),
Font = OsuFont.GetFont(size: TextSize),
}
}, null, LinkAction.OpenBeatmap, beatmap.OnlineBeatmapID.ToString(), "Open beatmap");
}, LinkAction.OpenBeatmap, beatmap.OnlineBeatmapID.ToString(), "Open beatmap");
}
}
}

View File

@ -167,14 +167,17 @@ namespace osu.Game.Screens.Multi
public void APIStateChanged(IAPIProvider api, APIState state)
{
if (state != APIState.Online)
forcefullyExit();
Schedule(forcefullyExit);
}
private void forcefullyExit()
{
// This is temporary since we don't currently have a way to force screens to be exited
if (this.IsCurrentScreen())
this.Exit();
{
while (this.IsCurrentScreen())
this.Exit();
}
else
{
this.MakeCurrent();
@ -212,6 +215,8 @@ namespace osu.Game.Screens.Multi
public override bool OnExiting(IScreen next)
{
roomManager.PartRoom();
if (screenStack.CurrentScreen != null && !(screenStack.CurrentScreen is LoungeSubScreen))
{
screenStack.Exit();

View File

@ -87,9 +87,8 @@ namespace osu.Game.Screens.Multi
public void JoinRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = null)
{
currentJoinRoomRequest?.Cancel();
currentJoinRoomRequest = null;
currentJoinRoomRequest = new JoinRoomRequest(room, api.LocalUser.Value);
currentJoinRoomRequest.Success += () =>
{
joinedRoom = room;
@ -98,7 +97,8 @@ namespace osu.Game.Screens.Multi
currentJoinRoomRequest.Failure += exception =>
{
Logger.Log($"Failed to join room: {exception}", level: LogLevel.Important);
if (!(exception is OperationCanceledException))
Logger.Log($"Failed to join room: {exception}", level: LogLevel.Important);
onError?.Invoke(exception.ToString());
};
@ -107,6 +107,8 @@ namespace osu.Game.Screens.Multi
public void PartRoom()
{
currentJoinRoomRequest?.Cancel();
if (joinedRoom == null)
return;

View File

@ -8,6 +8,7 @@ using System.Threading.Tasks;
using osu.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Track;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -29,7 +30,7 @@ namespace osu.Game.Screens.Play
/// <summary>
/// The original source (usually a <see cref="WorkingBeatmap"/>'s track).
/// </summary>
private readonly IAdjustableClock sourceClock;
private IAdjustableClock sourceClock;
public readonly BindableBool IsPaused = new BindableBool();
@ -153,6 +154,18 @@ namespace osu.Game.Screens.Play
IsPaused.Value = true;
}
/// <summary>
/// Changes the backing clock to avoid using the originally provided beatmap's track.
/// </summary>
public void StopUsingBeatmapClock()
{
if (sourceClock != beatmap.Track)
return;
sourceClock = new TrackVirtual(beatmap.Track.Length);
adjustableClock.ChangeSource(sourceClock);
}
public void ResetLocalAdjustments()
{
// In the case of replays, we may have changed the playback rate.

View File

@ -30,6 +30,7 @@ using osu.Game.Users;
namespace osu.Game.Screens.Play
{
[Cached]
public class Player : ScreenWithBeatmapBackground
{
public override bool AllowBackButton => false; // handled by HoldForMenuButton
@ -311,14 +312,19 @@ namespace osu.Game.Screens.Play
this.Exit();
}
/// <summary>
/// Restart gameplay via a parent <see cref="PlayerLoader"/>.
/// <remarks>This can be called from a child screen in order to trigger the restart process.</remarks>
/// </summary>
public void Restart()
{
if (!this.IsCurrentScreen()) return;
sampleRestart?.Play();
RestartRequested?.Invoke();
performImmediateExit();
if (this.IsCurrentScreen())
performImmediateExit();
else
this.MakeCurrent();
}
private ScheduledDelegate completionProgressDelegate;
@ -443,7 +449,12 @@ namespace osu.Game.Screens.Play
{
if (!canPause) return;
IsResuming = false;
if (IsResuming)
{
DrawableRuleset.CancelResume();
IsResuming = false;
}
GameplayClockContainer.Stop();
PauseOverlay.Show();
lastPauseActionTime = GameplayClockContainer.GameplayClock.CurrentTime;
@ -527,6 +538,10 @@ namespace osu.Game.Screens.Play
GameplayClockContainer.ResetLocalAdjustments();
// GameplayClockContainer performs seeks / start / stop operations on the beatmap's track.
// as we are no longer the current screen, we cannot guarantee the track is still usable.
GameplayClockContainer.StopUsingBeatmapClock();
fadeOut();
return base.OnExiting(next);
}

View File

@ -4,12 +4,13 @@
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Online;
using osu.Game.Scoring;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Scoring;
using osuTK;
namespace osu.Game.Screens.Play
namespace osu.Game.Screens.Ranking.Pages
{
public class ReplayDownloadButton : DownloadTrackingComposite<ScoreInfo, ScoreManager>
{
@ -33,6 +34,7 @@ namespace osu.Game.Screens.Play
public ReplayDownloadButton(ScoreInfo score)
: base(score)
{
Size = new Vector2(50, 30);
}
[BackgroundDependencyLoader(true)]

View File

@ -0,0 +1,54 @@
// 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 osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
using osu.Game.Screens.Play;
using osuTK;
namespace osu.Game.Screens.Ranking.Pages
{
public class RetryButton : OsuAnimatedButton
{
private readonly Box background;
[Resolved(canBeNull: true)]
private Player player { get; set; }
public RetryButton()
{
Size = new Vector2(50, 30);
Children = new Drawable[]
{
background = new Box
{
RelativeSizeAxes = Axes.Both,
Depth = float.MaxValue
},
new SpriteIcon
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(13),
Icon = FontAwesome.Solid.ArrowCircleLeft,
},
};
TooltipText = "Retry";
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
background.Colour = colours.Green;
if (player != null)
Action = () => player.Restart();
}
}
}

View File

@ -169,12 +169,19 @@ namespace osu.Game.Screens.Ranking.Pages
},
},
},
new ReplayDownloadButton(score)
new FillFlowContainer
{
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
Margin = new MarginPadding { Bottom = 10 },
Size = new Vector2(50, 30),
Spacing = new Vector2(5),
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Children = new Drawable[]
{
new ReplayDownloadButton(score),
new RetryButton()
}
},
};

View File

@ -19,6 +19,7 @@ using osu.Game.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics.Sprites;
using osu.Game.Scoring;
using osu.Game.Screens.Play;
namespace osu.Game.Screens.Ranking
{
@ -34,6 +35,9 @@ namespace osu.Game.Screens.Ranking
private ResultModeTabControl modeChangeButtons;
[Resolved(canBeNull: true)]
private Player player { get; set; }
public override bool DisallowExternalBeatmapRulesetChanges => true;
protected readonly ScoreInfo Score;
@ -100,10 +104,7 @@ namespace osu.Game.Screens.Ranking
public override bool OnExiting(IScreen next)
{
allCircles.ForEach(c =>
{
c.ScaleTo(0, transition_time, Easing.OutSine);
});
allCircles.ForEach(c => c.ScaleTo(0, transition_time, Easing.OutSine));
Background.ScaleTo(1f, transition_time / 4, Easing.OutQuint);
@ -115,147 +116,157 @@ namespace osu.Game.Screens.Ranking
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
InternalChildren = new Drawable[]
InternalChild = new AspectContainer
{
new AspectContainer
RelativeSizeAxes = Axes.Y,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Height = overscan,
Children = new Drawable[]
{
RelativeSizeAxes = Axes.Y,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Height = overscan,
Children = new Drawable[]
circleOuterBackground = new CircularContainer
{
circleOuterBackground = new CircularContainer
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Masking = true,
Children = new Drawable[]
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Masking = true,
Children = new Drawable[]
new Box
{
new Box
{
Alpha = 0.2f,
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
}
Alpha = 0.2f,
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
}
},
circleOuter = new CircularContainer
}
},
circleOuter = new CircularContainer
{
Size = new Vector2(circle_outer_scale),
EdgeEffect = new EdgeEffectParameters
{
Size = new Vector2(circle_outer_scale),
EdgeEffect = new EdgeEffectParameters
Colour = Color4.Black.Opacity(0.4f),
Type = EdgeEffectType.Shadow,
Radius = 15,
},
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Masking = true,
Children = new Drawable[]
{
new Box
{
Colour = Color4.Black.Opacity(0.4f),
Type = EdgeEffectType.Shadow,
Radius = 15,
RelativeSizeAxes = Axes.Both,
Colour = Color4.White,
},
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Masking = true,
Children = new Drawable[]
backgroundParallax = new ParallaxContainer
{
new Box
RelativeSizeAxes = Axes.Both,
ParallaxAmount = 0.01f,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Children = new Drawable[]
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.White,
},
backgroundParallax = new ParallaxContainer
{
RelativeSizeAxes = Axes.Both,
ParallaxAmount = 0.01f,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Children = new Drawable[]
new Sprite
{
new Sprite
{
RelativeSizeAxes = Axes.Both,
Alpha = 0.2f,
Texture = Beatmap.Value.Background,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
FillMode = FillMode.Fill
}
RelativeSizeAxes = Axes.Both,
Alpha = 0.2f,
Texture = Beatmap.Value.Background,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
FillMode = FillMode.Fill
}
},
modeChangeButtons = new ResultModeTabControl
{
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
RelativeSizeAxes = Axes.X,
Height = 50,
Margin = new MarginPadding { Bottom = 110 },
},
new OsuSpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.BottomCentre,
Text = $"{Score.MaxCombo}x",
RelativePositionAxes = Axes.X,
Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 40),
X = 0.1f,
Colour = colours.BlueDarker,
},
new OsuSpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.TopCentre,
Text = "max combo",
Font = OsuFont.GetFont(size: 20),
RelativePositionAxes = Axes.X,
X = 0.1f,
Colour = colours.Gray6,
},
new OsuSpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.BottomCentre,
Text = $"{Score.Accuracy:P2}",
Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 40),
RelativePositionAxes = Axes.X,
X = 0.9f,
Colour = colours.BlueDarker,
},
new OsuSpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.TopCentre,
Text = "accuracy",
Font = OsuFont.GetFont(size: 20),
RelativePositionAxes = Axes.X,
X = 0.9f,
Colour = colours.Gray6,
},
}
},
circleInner = new CircularContainer
{
Size = new Vector2(0.6f),
EdgeEffect = new EdgeEffectParameters
{
Colour = Color4.Black.Opacity(0.4f),
Type = EdgeEffectType.Shadow,
Radius = 15,
}
},
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Masking = true,
Children = new Drawable[]
modeChangeButtons = new ResultModeTabControl
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.White,
},
}
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
RelativeSizeAxes = Axes.X,
Height = 50,
Margin = new MarginPadding { Bottom = 110 },
},
new OsuSpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.BottomCentre,
Text = $"{Score.MaxCombo}x",
RelativePositionAxes = Axes.X,
Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 40),
X = 0.1f,
Colour = colours.BlueDarker,
},
new OsuSpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.TopCentre,
Text = "max combo",
Font = OsuFont.GetFont(size: 20),
RelativePositionAxes = Axes.X,
X = 0.1f,
Colour = colours.Gray6,
},
new OsuSpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.BottomCentre,
Text = $"{Score.Accuracy:P2}",
Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 40),
RelativePositionAxes = Axes.X,
X = 0.9f,
Colour = colours.BlueDarker,
},
new OsuSpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.TopCentre,
Text = "accuracy",
Font = OsuFont.GetFont(size: 20),
RelativePositionAxes = Axes.X,
X = 0.9f,
Colour = colours.Gray6,
},
}
},
circleInner = new CircularContainer
{
Size = new Vector2(0.6f),
EdgeEffect = new EdgeEffectParameters
{
Colour = Color4.Black.Opacity(0.4f),
Type = EdgeEffectType.Shadow,
Radius = 15,
},
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Masking = true,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.White,
},
}
}
}
};
if (player != null)
{
AddInternal(new HotkeyRetryOverlay
{
Action = () =>
{
if (!this.IsCurrentScreen()) return;
player?.Restart();
},
});
}
var pages = CreateResultPages();
foreach (var p in pages)

View File

@ -179,7 +179,7 @@ namespace osu.Game.Screens.Select.Leaderboards
return req;
}
protected override LeaderboardScore CreateDrawableScore(ScoreInfo model, int index) => new LeaderboardScore(model, index)
protected override LeaderboardScore CreateDrawableScore(ScoreInfo model, int index) => new LeaderboardScore(model, index, IsOnlineScope)
{
Action = () => ScoreSelected?.Invoke(model)
};

View File

@ -77,7 +77,7 @@ namespace osu.Game.Screens.Select.Leaderboards
if (newScore == null)
return;
LoadComponentAsync(new LeaderboardScore(newScore.Score, newScore.Position)
LoadComponentAsync(new LeaderboardScore(newScore.Score, newScore.Position, false)
{
Action = () => ScoreSelected?.Invoke(newScore.Score)
}, drawableScore =>