1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 22:27:25 +08:00

Merge branch 'master' into fix-ctb-2b-diffcalc

This commit is contained in:
HoLLy 2019-05-12 22:09:55 +02:00 committed by GitHub
commit b2cdfceafb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 158 additions and 51 deletions

View File

@ -353,6 +353,8 @@ namespace osu.Game.Rulesets.Osu.Tests
{
public new ScoreProcessor ScoreProcessor => base.ScoreProcessor;
protected override bool PauseOnFocusLost => false;
public ScoreAccessibleReplayPlayer(Score score)
: base(score, false, false)
{

View File

@ -160,9 +160,10 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
{
base.SkinChanged(skin, allowFallback);
Body.AccentColour = skin.GetValue<SkinConfiguration, Color4?>(s => s.CustomColours.ContainsKey("SliderTrackOverride") ? s.CustomColours["SliderTrackOverride"] : (Color4?)null) ?? Body.AccentColour;
Body.BorderColour = skin.GetValue<SkinConfiguration, Color4?>(s => s.CustomColours.ContainsKey("SliderBorder") ? s.CustomColours["SliderBorder"] : (Color4?)null) ?? Body.BorderColour;
Ball.AccentColour = skin.GetValue<SkinConfiguration, Color4?>(s => s.CustomColours.ContainsKey("SliderBall") ? s.CustomColours["SliderBall"] : (Color4?)null) ?? Ball.AccentColour;
Body.BorderSize = skin.GetValue<SkinConfiguration, float?>(s => s.SliderBorderSize) ?? SliderBody.DEFAULT_BORDER_SIZE;
Body.AccentColour = skin.GetValue<SkinConfiguration, Color4?>(s => s.CustomColours.ContainsKey("SliderTrackOverride") ? s.CustomColours["SliderTrackOverride"] : (Color4?)null) ?? AccentColour;
Body.BorderColour = skin.GetValue<SkinConfiguration, Color4?>(s => s.CustomColours.ContainsKey("SliderBorder") ? s.CustomColours["SliderBorder"] : (Color4?)null) ?? Color4.White;
Ball.AccentColour = skin.GetValue<SkinConfiguration, Color4?>(s => s.CustomColours.ContainsKey("SliderBall") ? s.CustomColours["SliderBall"] : (Color4?)null) ?? AccentColour;
}
protected override void CheckForResult(bool userTriggered, double timeOffset)

View File

@ -14,6 +14,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
{
public abstract class SliderBody : CompositeDrawable
{
public const float DEFAULT_BORDER_SIZE = 1;
private readonly SliderPath path;
protected Path Path => path;
@ -64,6 +66,23 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
}
}
/// <summary>
/// Used to size the path border.
/// </summary>
public float BorderSize
{
get => path.BorderSize;
set
{
if (path.BorderSize == value)
return;
path.BorderSize = value;
container.ForceRedraw();
}
}
public Quad PathDrawQuad => container.ScreenSpaceDrawQuad;
protected SliderBody()
@ -92,6 +111,9 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
private class SliderPath : SmoothPath
{
private const float border_max_size = 8f;
private const float border_min_size = 0f;
private const float border_portion = 0.128f;
private const float gradient_portion = 1 - border_portion;
@ -130,12 +152,33 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
}
}
private float borderSize = DEFAULT_BORDER_SIZE;
public float BorderSize
{
get => borderSize;
set
{
if (borderSize == value)
return;
if (value < border_min_size || value > border_max_size)
return;
borderSize = value;
InvalidateTexture();
}
}
private float calculatedBorderPortion => BorderSize * border_portion;
protected override Color4 ColourAt(float position)
{
if (position <= border_portion)
if (calculatedBorderPortion != 0f && position <= calculatedBorderPortion)
return BorderColour;
position -= border_portion;
position -= calculatedBorderPortion;
return new Color4(AccentColour.R, AccentColour.G, AccentColour.B, (opacity_at_edge - (opacity_at_edge - opacity_at_centre) * position / gradient_portion) * AccentColour.A);
}
}

View File

@ -328,7 +328,7 @@ namespace osu.Game.Tests.Visual.Background
public bool IsBlurCorrect() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2(BACKGROUND_BLUR);
}
private class TestPlayer : Player
private class TestPlayer : Visual.TestPlayer
{
protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value);

View File

@ -24,7 +24,7 @@ namespace osu.Game.Tests.Visual.Gameplay
AddUntilStep("key counter counted keys", () => ((ScoreAccessiblePlayer)Player).HUDOverlay.KeyCounter.Children.Any(kc => kc.CountPresses > 0));
}
private class ScoreAccessiblePlayer : Player
private class ScoreAccessiblePlayer : TestPlayer
{
public new ScoreProcessor ScoreProcessor => base.ScoreProcessor;
public new HUDOverlay HUDOverlay => base.HUDOverlay;

View File

@ -195,7 +195,7 @@ namespace osu.Game.Tests.Visual.Gameplay
protected override Player CreatePlayer(Ruleset ruleset) => new PausePlayer();
protected class PausePlayer : Player
protected class PausePlayer : TestPlayer
{
public new GameplayClockContainer GameplayClockContainer => base.GameplayClockContainer;
@ -207,12 +207,6 @@ namespace osu.Game.Tests.Visual.Gameplay
public bool PauseOverlayVisible => PauseOverlay.State == Visibility.Visible;
protected override void LoadComplete()
{
base.LoadComplete();
HUDOverlay.HoldToQuit.PauseOnFocusLost = false;
}
public override void OnEntering(IScreen last)
{
base.OnEntering(last);

View File

@ -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;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
@ -34,20 +35,20 @@ namespace osu.Game.Tests.Visual.Gameplay
[Test]
public void TestLoadContinuation()
{
AddStep("load dummy beatmap", () => stack.Push(loader = new PlayerLoader(() => new Player(false, false))));
Player player = null;
SlowLoadPlayer slowPlayer = null;
AddStep("load dummy beatmap", () => stack.Push(loader = new PlayerLoader(() => player = new TestPlayer(false, false))));
AddUntilStep("wait for current", () => loader.IsCurrentScreen());
AddStep("mouse in centre", () => InputManager.MoveMouseTo(loader.ScreenSpaceDrawQuad.Centre));
AddUntilStep("wait for no longer current", () => !loader.IsCurrentScreen());
AddUntilStep("wait for player to be current", () => player.IsCurrentScreen());
AddStep("load slow dummy beatmap", () =>
{
SlowLoadPlayer slow = null;
stack.Push(loader = new PlayerLoader(() => slow = new SlowLoadPlayer(false, false)));
Scheduler.AddDelayed(() => slow.Ready = true, 5000);
stack.Push(loader = new PlayerLoader(() => slowPlayer = new SlowLoadPlayer(false, false)));
Scheduler.AddDelayed(() => slowPlayer.AllowLoad.Set(), 5000);
});
AddUntilStep("wait for no longer current", () => !loader.IsCurrentScreen());
AddUntilStep("wait for player to be current", () => slowPlayer.IsCurrentScreen());
}
[Test]
@ -101,19 +102,19 @@ namespace osu.Game.Tests.Visual.Gameplay
public ScoreRank AdjustRank(ScoreRank rank, double accuracy) => rank;
}
private class TestPlayer : Player
private class TestPlayer : Visual.TestPlayer
{
public new Bindable<IReadOnlyList<Mod>> Mods => base.Mods;
public TestPlayer()
: base(false, false)
public TestPlayer(bool allowPause = true, bool showResults = true)
: base(allowPause, showResults)
{
}
}
protected class SlowLoadPlayer : Player
protected class SlowLoadPlayer : Visual.TestPlayer
{
public bool Ready;
public readonly ManualResetEventSlim AllowLoad = new ManualResetEventSlim(false);
public SlowLoadPlayer(bool allowPause = true, bool showResults = true)
: base(allowPause, showResults)
@ -123,8 +124,8 @@ namespace osu.Game.Tests.Visual.Gameplay
[BackgroundDependencyLoader]
private void load()
{
while (!Ready)
Thread.Sleep(1);
if (!AllowLoad.Wait(TimeSpan.FromSeconds(10)))
throw new TimeoutException();
}
}
}

View File

@ -33,6 +33,8 @@ namespace osu.Game.Tests.Visual.Gameplay
public new ScoreProcessor ScoreProcessor => base.ScoreProcessor;
public new HUDOverlay HUDOverlay => base.HUDOverlay;
protected override bool PauseOnFocusLost => false;
public ScoreAccessibleReplayPlayer(Score score)
: base(score)
{

View File

@ -93,7 +93,7 @@ namespace osu.Game.Tests.Visual.Online
AddUntilStep("remove all channels", () =>
{
var first = channelTabControl.Items.First();
if (first.Name == "+")
if (first is ChannelSelectorTabItem.ChannelSelectorTabChannel)
return true;
channelTabControl.RemoveChannel(first);

View File

@ -29,5 +29,12 @@ namespace osu.Game.Beatmaps.Timing
/// Whether the break has any effect. Breaks that are too short are culled before they are added to the beatmap.
/// </summary>
public bool HasEffect => Duration >= MIN_BREAK_DURATION;
/// <summary>
/// Whether this break contains a specified time.
/// </summary>
/// <param name="time">The time to check in milliseconds.</param>
/// <returns>Whether the time falls within this <see cref="BreakPeriod"/>.</returns>
public bool Contains(double time) => time >= StartTime && time <= EndTime;
}
}

View File

@ -10,6 +10,7 @@ using osu.Framework.Bindables;
using osu.Framework.Logging;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Overlays.Chat.Tabs;
using osu.Game.Users;
namespace osu.Game.Online.Chat
@ -84,7 +85,11 @@ namespace osu.Game.Online.Chat
?? new Channel(user);
}
private void currentChannelChanged(ValueChangedEvent<Channel> e) => JoinChannel(e.NewValue);
private void currentChannelChanged(ValueChangedEvent<Channel> e)
{
if (!(e.NewValue is ChannelSelectorTabItem.ChannelSelectorTabChannel))
JoinChannel(e.NewValue);
}
/// <summary>
/// Ensure we run post actions in sequence, once at a time.

View File

@ -13,8 +13,8 @@ namespace osu.Game.Overlays.Chat.Tabs
public override bool IsSwitchable => false;
public ChannelSelectorTabItem(Channel value)
: base(value)
public ChannelSelectorTabItem()
: base(new ChannelSelectorTabChannel())
{
Depth = float.MaxValue;
Width = 45;
@ -31,5 +31,13 @@ namespace osu.Game.Overlays.Chat.Tabs
BackgroundInactive = colour.Gray2;
BackgroundActive = colour.Gray3;
}
public class ChannelSelectorTabChannel : Channel
{
public ChannelSelectorTabChannel()
{
Name = "+";
}
}
}
}

View File

@ -38,7 +38,7 @@ namespace osu.Game.Overlays.Chat.Tabs
Margin = new MarginPadding(10),
});
AddTabItem(selectorTab = new ChannelSelectorTabItem(new Channel { Name = "+" }));
AddTabItem(selectorTab = new ChannelSelectorTabItem());
ChannelSelectorActive.BindTo(selectorTab.Active);
}

View File

@ -199,6 +199,9 @@ namespace osu.Game.Overlays
return;
}
if (e.NewValue is ChannelSelectorTabItem.ChannelSelectorTabChannel)
return;
textbox.Current.Disabled = e.NewValue.ReadOnly;
if (channelTabControl.Current.Value != e.NewValue)
@ -268,7 +271,7 @@ namespace osu.Game.Overlays
private void selectTab(int index)
{
var channel = channelTabControl.Items.Skip(index).FirstOrDefault();
if (channel != null && channel.Name != "+")
if (channel != null && !(channel is ChannelSelectorTabItem.ChannelSelectorTabChannel))
channelTabControl.Current.Value = channel;
}

View File

@ -8,6 +8,7 @@ using System.Linq;
using osu.Framework.Bindables;
using osu.Framework.Extensions;
using osu.Framework.Extensions.TypeExtensions;
using osu.Framework.MathUtils;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Mods;
@ -99,7 +100,7 @@ namespace osu.Game.Rulesets.Scoring
/// <summary>
/// The default conditions for failing.
/// </summary>
protected virtual bool DefaultFailCondition => Health.Value == Health.MinValue;
protected virtual bool DefaultFailCondition => Precision.AlmostBigger(Health.MinValue, Health.Value);
protected ScoreProcessor()
{

View File

@ -25,6 +25,8 @@ namespace osu.Game.Screens.Play.HUD
{
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
public readonly Bindable<bool> IsPaused = new Bindable<bool>();
private readonly Button button;
public Action Action
@ -51,7 +53,8 @@ namespace osu.Game.Screens.Play.HUD
button = new Button
{
HoverGained = () => text.FadeIn(500, Easing.OutQuint),
HoverLost = () => text.FadeOut(500, Easing.OutQuint)
HoverLost = () => text.FadeOut(500, Easing.OutQuint),
IsPaused = { BindTarget = IsPaused }
}
};
AutoSizeAxes = Axes.Both;
@ -94,6 +97,8 @@ namespace osu.Game.Screens.Play.HUD
private CircularProgress circularProgress;
private Circle overlayCircle;
public readonly Bindable<bool> IsPaused = new Bindable<bool>();
protected override bool AllowMultipleFires => true;
public Action HoverGained;
@ -217,7 +222,7 @@ namespace osu.Game.Screens.Play.HUD
private void updateActive()
{
if (!pauseOnFocusLost) return;
if (!pauseOnFocusLost || IsPaused.Value) return;
if (gameActive.Value)
AbortConfirm();

View File

@ -131,14 +131,12 @@ namespace osu.Game.Screens.Play
{
base.LoadComplete();
replayLoaded.ValueChanged += replayLoadedValueChanged;
replayLoaded.TriggerChange();
replayLoaded.BindValueChanged(replayLoadedValueChanged, true);
}
private void replayLoadedValueChanged(ValueChangedEvent<bool> e)
{
PlayerSettingsOverlay.ReplayLoaded = e.NewValue;
HoldToQuit.PauseOnFocusLost = !e.NewValue;
if (e.NewValue)
{

View File

@ -40,6 +40,11 @@ namespace osu.Game.Screens.Play
public override OverlayActivation InitialOverlayActivationMode => OverlayActivation.UserTriggered;
/// <summary>
/// Whether gameplay should pause when the game window focus is lost.
/// </summary>
protected virtual bool PauseOnFocusLost => true;
public Action RestartRequested;
public bool HasFailed { get; private set; }
@ -132,7 +137,11 @@ namespace osu.Game.Screens.Play
DrawableRuleset.Cursor?.CreateProxy() ?? new Container(),
HUDOverlay = new HUDOverlay(ScoreProcessor, DrawableRuleset, Mods.Value)
{
HoldToQuit = { Action = performUserRequestedExit },
HoldToQuit =
{
Action = performUserRequestedExit,
IsPaused = { BindTarget = GameplayClockContainer.IsPaused }
},
PlayerSettingsOverlay = { PlaybackSettings = { UserPlaybackRate = { BindTarget = GameplayClockContainer.UserPlaybackRate } } },
KeyCounter = { Visible = { BindTarget = DrawableRuleset.HasReplayLoaded } },
RequestSeek = GameplayClockContainer.Seek,
@ -167,6 +176,8 @@ namespace osu.Game.Screens.Play
}
};
DrawableRuleset.HasReplayLoaded.BindValueChanged(e => HUDOverlay.HoldToQuit.PauseOnFocusLost = !e.NewValue && PauseOnFocusLost, true);
// bind clock into components that require it
DrawableRuleset.IsPaused.BindTo(GameplayClockContainer.IsPaused);
@ -403,8 +414,9 @@ namespace osu.Game.Screens.Play
IsResuming = true;
PauseOverlay.Hide();
// time-based conditions may allow instant resume.
if (GameplayClockContainer.GameplayClock.CurrentTime < Beatmap.Value.Beatmap.HitObjects.First().StartTime)
// breaks and time-based conditions may allow instant resume.
double time = GameplayClockContainer.GameplayClock.CurrentTime;
if (Beatmap.Value.Beatmap.Breaks.Any(b => b.Contains(time)) || time < Beatmap.Value.Beatmap.HitObjects.First().StartTime)
completeResume();
else
DrawableRuleset.RequestResume(completeResume);

View File

@ -39,6 +39,7 @@ namespace osu.Game.Screens.Select
public abstract class SongSelect : OsuScreen
{
private static readonly Vector2 wedged_container_size = new Vector2(0.5f, 245);
protected const float BACKGROUND_BLUR = 20;
private const float left_area_padding = 20;
@ -89,8 +90,6 @@ namespace osu.Game.Screens.Select
protected SongSelect()
{
const float carousel_width = 640;
AddRangeInternal(new Drawable[]
{
new ParallaxContainer
@ -103,7 +102,8 @@ namespace osu.Game.Screens.Select
new WedgeBackground
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Right = carousel_width * 0.76f },
Padding = new MarginPadding { Right = -150 },
Size = new Vector2(wedged_container_size.X, 1),
}
}
},
@ -144,8 +144,8 @@ namespace osu.Game.Screens.Select
Carousel = new BeatmapCarousel
{
Masking = false,
RelativeSizeAxes = Axes.Y,
Size = new Vector2(carousel_width, 1),
RelativeSizeAxes = Axes.Both,
Size = new Vector2(1 - wedged_container_size.X, 1),
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
SelectionChanged = updateSelectedBeatmap,
@ -505,6 +505,8 @@ namespace osu.Game.Screens.Select
{
ModSelect.Hide();
BeatmapOptions.Hide();
this.ScaleTo(1.1f, 250, Easing.InSine);
this.FadeOut(250);

View File

@ -34,6 +34,10 @@ namespace osu.Game.Skinning
case @"CursorExpand":
skin.CursorExpand = pair.Value != "0";
break;
case @"SliderBorderSize":
skin.SliderBorderSize = Parsing.ParseFloat(pair.Value);
break;
}
break;

View File

@ -25,6 +25,8 @@ namespace osu.Game.Skinning
public int HitCircleOverlap { get; set; }
public float? SliderBorderSize { get; set; }
public bool? CursorExpand { get; set; } = true;
}
}

View File

@ -76,6 +76,6 @@ namespace osu.Game.Tests.Visual
return Player;
}
protected virtual Player CreatePlayer(Ruleset ruleset) => new Player(false, false);
protected virtual Player CreatePlayer(Ruleset ruleset) => new TestPlayer(false, false);
}
}

View File

@ -56,6 +56,6 @@ namespace osu.Game.Tests.Visual
LoadScreen(Player);
}
protected virtual Player CreatePlayer(Ruleset ruleset) => new Player(false, false);
protected virtual Player CreatePlayer(Ruleset ruleset) => new TestPlayer(false, false);
}
}

View File

@ -0,0 +1,17 @@
// 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.Game.Screens.Play;
namespace osu.Game.Tests.Visual
{
public class TestPlayer : Player
{
protected override bool PauseOnFocusLost => false;
public TestPlayer(bool allowPause = true, bool showResults = true)
: base(allowPause, showResults)
{
}
}
}