Merge branch 'master' into ruleset-keybindings

This commit is contained in:
ocboogie 2018-05-14 15:39:10 -07:00 committed by GitHub
commit 4055a6fc0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 218 additions and 80 deletions

View File

@ -14,7 +14,7 @@ using osu.Game.Tests.Beatmaps;
namespace osu.Game.Rulesets.Catch.Tests namespace osu.Game.Rulesets.Catch.Tests
{ {
public class CatchBeatmapConversionTest : BeatmapConversionTest<TestCatchRuleset, ConvertValue> internal class CatchBeatmapConversionTest : BeatmapConversionTest<TestCatchRuleset, ConvertValue>
{ {
protected override string ResourceAssembly => "osu.Game.Rulesets.Catch"; protected override string ResourceAssembly => "osu.Game.Rulesets.Catch";
@ -50,7 +50,7 @@ namespace osu.Game.Rulesets.Catch.Tests
protected override IBeatmapConverter CreateConverter(IBeatmap beatmap) => new CatchBeatmapConverter(beatmap); protected override IBeatmapConverter CreateConverter(IBeatmap beatmap) => new CatchBeatmapConverter(beatmap);
} }
public struct ConvertValue : IEquatable<ConvertValue> internal struct ConvertValue : IEquatable<ConvertValue>
{ {
/// <summary> /// <summary>
/// A sane value to account for osu!stable using ints everwhere. /// A sane value to account for osu!stable using ints everwhere.
@ -65,7 +65,7 @@ namespace osu.Game.Rulesets.Catch.Tests
&& Precision.AlmostEquals(Position, other.Position, conversion_lenience); && Precision.AlmostEquals(Position, other.Position, conversion_lenience);
} }
public class TestCatchRuleset : CatchRuleset internal class TestCatchRuleset : CatchRuleset
{ {
} }
} }

View File

@ -14,7 +14,7 @@ using osu.Game.Tests.Beatmaps;
namespace osu.Game.Rulesets.Mania.Tests namespace osu.Game.Rulesets.Mania.Tests
{ {
public class ManiaBeatmapConversionTest : BeatmapConversionTest<TestManiaRuleset, ConvertValue> internal class ManiaBeatmapConversionTest : BeatmapConversionTest<TestManiaRuleset, ConvertValue>
{ {
protected override string ResourceAssembly => "osu.Game.Rulesets.Mania"; protected override string ResourceAssembly => "osu.Game.Rulesets.Mania";
@ -38,7 +38,7 @@ namespace osu.Game.Rulesets.Mania.Tests
protected override IBeatmapConverter CreateConverter(IBeatmap beatmap) => new ManiaBeatmapConverter(beatmap); protected override IBeatmapConverter CreateConverter(IBeatmap beatmap) => new ManiaBeatmapConverter(beatmap);
} }
public struct ConvertValue : IEquatable<ConvertValue> internal struct ConvertValue : IEquatable<ConvertValue>
{ {
/// <summary> /// <summary>
/// A sane value to account for osu!stable using ints everwhere. /// A sane value to account for osu!stable using ints everwhere.
@ -55,7 +55,7 @@ namespace osu.Game.Rulesets.Mania.Tests
&& Column == other.Column; && Column == other.Column;
} }
public class TestManiaRuleset : ManiaRuleset internal class TestManiaRuleset : ManiaRuleset
{ {
} }
} }

View File

@ -15,7 +15,7 @@ using OpenTK;
namespace osu.Game.Rulesets.Osu.Tests namespace osu.Game.Rulesets.Osu.Tests
{ {
public class OsuBeatmapConversionTest : BeatmapConversionTest<TestOsuRuleset, ConvertValue> internal class OsuBeatmapConversionTest : BeatmapConversionTest<TestOsuRuleset, ConvertValue>
{ {
protected override string ResourceAssembly => "osu.Game.Rulesets.Osu"; protected override string ResourceAssembly => "osu.Game.Rulesets.Osu";
@ -45,7 +45,7 @@ namespace osu.Game.Rulesets.Osu.Tests
protected override IBeatmapConverter CreateConverter(IBeatmap beatmap) => new OsuBeatmapConverter(beatmap); protected override IBeatmapConverter CreateConverter(IBeatmap beatmap) => new OsuBeatmapConverter(beatmap);
} }
public struct ConvertValue : IEquatable<ConvertValue> internal struct ConvertValue : IEquatable<ConvertValue>
{ {
/// <summary> /// <summary>
/// A sane value to account for osu!stable using ints everwhere. /// A sane value to account for osu!stable using ints everwhere.
@ -68,7 +68,7 @@ namespace osu.Game.Rulesets.Osu.Tests
&& Precision.AlmostEquals(EndY, other.EndY, conversion_lenience); && Precision.AlmostEquals(EndY, other.EndY, conversion_lenience);
} }
public class TestOsuRuleset : OsuRuleset internal class TestOsuRuleset : OsuRuleset
{ {
} }
} }

View File

@ -14,7 +14,7 @@ using osu.Game.Tests.Beatmaps;
namespace osu.Game.Rulesets.Taiko.Tests namespace osu.Game.Rulesets.Taiko.Tests
{ {
public class TaikoBeatmapConversionTest : BeatmapConversionTest<TestTaikoRuleset, ConvertValue> internal class TaikoBeatmapConversionTest : BeatmapConversionTest<TestTaikoRuleset, ConvertValue>
{ {
protected override string ResourceAssembly => "osu.Game.Rulesets.Taiko"; protected override string ResourceAssembly => "osu.Game.Rulesets.Taiko";
@ -43,7 +43,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
protected override IBeatmapConverter CreateConverter(IBeatmap beatmap) => new TaikoBeatmapConverter(beatmap); protected override IBeatmapConverter CreateConverter(IBeatmap beatmap) => new TaikoBeatmapConverter(beatmap);
} }
public struct ConvertValue : IEquatable<ConvertValue> internal struct ConvertValue : IEquatable<ConvertValue>
{ {
/// <summary> /// <summary>
/// A sane value to account for osu!stable using ints everwhere. /// A sane value to account for osu!stable using ints everwhere.
@ -68,7 +68,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
&& IsStrong == other.IsStrong; && IsStrong == other.IsStrong;
} }
public class TestTaikoRuleset : TaikoRuleset internal class TestTaikoRuleset : TaikoRuleset
{ {
} }
} }

View File

@ -40,6 +40,8 @@ namespace osu.Game.Rulesets.Taiko.Objects
/// </summary> /// </summary>
private double tickSpacing = 100; private double tickSpacing = 100;
private float overallDifficulty = BeatmapDifficulty.DEFAULT_DIFFICULTY;
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty) protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
{ {
base.ApplyDefaultsToSelf(controlPointInfo, difficulty); base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
@ -47,9 +49,7 @@ namespace osu.Game.Rulesets.Taiko.Objects
TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime); TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime);
tickSpacing = timingPoint.BeatLength / TickRate; tickSpacing = timingPoint.BeatLength / TickRate;
overallDifficulty = difficulty.OverallDifficulty;
RequiredGoodHits = NestedHitObjects.Count * Math.Min(0.15, 0.05 + 0.10 / 6 * difficulty.OverallDifficulty);
RequiredGreatHits = NestedHitObjects.Count * Math.Min(0.30, 0.10 + 0.20 / 6 * difficulty.OverallDifficulty);
} }
protected override void CreateNestedHitObjects() protected override void CreateNestedHitObjects()
@ -57,6 +57,9 @@ namespace osu.Game.Rulesets.Taiko.Objects
base.CreateNestedHitObjects(); base.CreateNestedHitObjects();
createTicks(); createTicks();
RequiredGoodHits = NestedHitObjects.Count * Math.Min(0.15, 0.05 + 0.10 / 6 * overallDifficulty);
RequiredGreatHits = NestedHitObjects.Count * Math.Min(0.30, 0.10 + 0.20 / 6 * overallDifficulty);
} }
private void createTicks() private void createTicks()

View File

@ -0,0 +1,62 @@
// 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;
using System.Collections.Generic;
using osu.Framework.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Screens.Menu;
namespace osu.Game.Tests.Visual
{
public class TestCaseHoldToConfirmOverlay : OsuTestCase
{
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(ExitConfirmOverlay) };
public TestCaseHoldToConfirmOverlay()
{
bool fired = false;
var firedText = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Text = "Fired!",
TextSize = 50,
Alpha = 0,
};
var overlay = new TestHoldToConfirmOverlay
{
Action = () =>
{
fired = true;
firedText.FadeTo(1).Then().FadeOut(1000);
}
};
Children = new Drawable[]
{
overlay,
firedText
};
AddStep("start confirming", () => overlay.Begin());
AddStep("abort confirming", () => overlay.Abort());
AddAssert("ensure aborted", () => !fired);
AddStep("start confirming", () => overlay.Begin());
AddUntilStep(() => fired, "wait until confirmed");
}
private class TestHoldToConfirmOverlay : ExitConfirmOverlay
{
protected override bool AllowMultipleFires => true;
public void Begin() => BeginConfirm();
public void Abort() => AbortConfirm();
}
}
}

View File

@ -0,0 +1,66 @@
// 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;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using OpenTK.Graphics;
namespace osu.Game.Overlays
{
/// <summary>
/// An overlay which will display a black screen that dims over a period before confirming an exit action.
/// Action is BYO (derived class will need to call <see cref="BeginConfirm"/> and <see cref="AbortConfirm"/> from a user event).
/// </summary>
public abstract class HoldToConfirmOverlay : Container
{
public Action Action;
private Box overlay;
private const int activate_delay = 400;
private const int fadeout_delay = 200;
private bool fired;
/// <summary>
/// Whether the overlay should be allowed to return from a fired state.
/// </summary>
protected virtual bool AllowMultipleFires => false;
[BackgroundDependencyLoader]
private void load()
{
RelativeSizeAxes = Axes.Both;
AlwaysPresent = true;
Children = new Drawable[]
{
overlay = new Box
{
Alpha = 0,
Colour = Color4.Black,
RelativeSizeAxes = Axes.Both,
}
};
}
protected void BeginConfirm()
{
if (!AllowMultipleFires && fired) return;
overlay.FadeIn(activate_delay * (1 - overlay.Alpha), Easing.Out).OnComplete(_ =>
{
Action?.Invoke();
fired = true;
});
}
protected void AbortConfirm()
{
if (!AllowMultipleFires && fired) return;
overlay.FadeOut(fadeout_delay, Easing.Out);
}
}
}

View File

@ -12,6 +12,7 @@ using osu.Framework.Graphics.Shapes;
using osu.Framework.Input; using osu.Framework.Input;
using osu.Framework.Input.Bindings; using osu.Framework.Input.Bindings;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Input; using osu.Game.Input;
using OpenTK.Graphics; using OpenTK.Graphics;
@ -43,7 +44,7 @@ namespace osu.Game.Overlays.KeyBinding
} }
private OsuSpriteText text; private OsuSpriteText text;
private OsuSpriteText pressAKey; private OsuTextFlowContainer pressAKey;
private FillFlowContainer<KeyButton> buttons; private FillFlowContainer<KeyButton> buttons;
@ -95,10 +96,11 @@ namespace osu.Game.Overlays.KeyBinding
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
Origin = Anchor.TopRight Origin = Anchor.TopRight
}, },
pressAKey = new OsuSpriteText pressAKey = new OsuTextFlowContainer
{ {
Text = "Press a key to change binding, DEL to delete, ESC to cancel.", Text = "Press a key to change binding, Shift+Delete to delete, Escape to cancel.",
Y = height, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Margin = new MarginPadding(padding), Margin = new MarginPadding(padding),
Alpha = 0, Alpha = 0,
Colour = colours.YellowDark Colour = colours.YellowDark
@ -204,9 +206,16 @@ namespace osu.Game.Overlays.KeyBinding
finalise(); finalise();
return true; return true;
case Key.Delete: case Key.Delete:
bindTarget.UpdateKeyCombination(InputKey.None); {
finalise(); if (state.Keyboard.ShiftPressed)
return true; {
bindTarget.UpdateKeyCombination(InputKey.None);
finalise();
return true;
}
break;
}
} }
bindTarget.UpdateKeyCombination(KeyCombination.FromInputState(state)); bindTarget.UpdateKeyCombination(KeyCombination.FromInputState(state));
@ -261,7 +270,7 @@ namespace osu.Game.Overlays.KeyBinding
GetContainingInputManager().ChangeFocus(null); GetContainingInputManager().ChangeFocus(null);
pressAKey.FadeOut(300, Easing.OutQuint); pressAKey.FadeOut(300, Easing.OutQuint);
pressAKey.Padding = new MarginPadding { Bottom = -pressAKey.DrawHeight }; pressAKey.Padding = new MarginPadding { Top = height, Bottom = -pressAKey.DrawHeight };
} }
protected override void OnFocus(InputState state) protected override void OnFocus(InputState state)
@ -270,7 +279,7 @@ namespace osu.Game.Overlays.KeyBinding
AutoSizeEasing = Easing.OutQuint; AutoSizeEasing = Easing.OutQuint;
pressAKey.FadeIn(300, Easing.OutQuint); pressAKey.FadeIn(300, Easing.OutQuint);
pressAKey.Padding = new MarginPadding(); pressAKey.Padding = new MarginPadding { Top = height };
updateBindTarget(); updateBindTarget();
base.OnFocus(state); base.OnFocus(state);

View File

@ -112,7 +112,7 @@ namespace osu.Game.Rulesets
try try
{ {
var assembly = Assembly.LoadFrom(file); var assembly = Assembly.LoadFrom(file);
loaded_assemblies[assembly] = assembly.GetTypes().First(t => t.IsSubclassOf(typeof(Ruleset))); loaded_assemblies[assembly] = assembly.GetTypes().First(t => t.IsPublic && t.IsSubclassOf(typeof(Ruleset)));
} }
catch (Exception) catch (Exception)
{ {

View File

@ -0,0 +1,34 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Input;
using osu.Game.Overlays;
using OpenTK.Input;
namespace osu.Game.Screens.Menu
{
public class ExitConfirmOverlay : HoldToConfirmOverlay
{
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{
if (args.Key == Key.Escape && !args.Repeat)
{
BeginConfirm();
return true;
}
return base.OnKeyDown(state, args);
}
protected override bool OnKeyUp(InputState state, KeyUpEventArgs args)
{
if (args.Key == Key.Escape)
{
AbortConfirm();
return true;
}
return base.OnKeyUp(state, args);
}
}
}

View File

@ -39,6 +39,10 @@ namespace osu.Game.Screens.Menu
Children = new Drawable[] Children = new Drawable[]
{ {
new ExitConfirmOverlay
{
Action = Exit,
},
new ParallaxContainer new ParallaxContainer
{ {
ParallaxAmount = 0.01f, ParallaxAmount = 0.01f,

View File

@ -1,50 +1,19 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using System;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Bindings; using osu.Framework.Input.Bindings;
using osu.Game.Input.Bindings; using osu.Game.Input.Bindings;
using OpenTK.Graphics; using osu.Game.Overlays;
namespace osu.Game.Screens.Play namespace osu.Game.Screens.Play
{ {
public class HotkeyRetryOverlay : Container, IKeyBindingHandler<GlobalAction> public class HotkeyRetryOverlay : HoldToConfirmOverlay, IKeyBindingHandler<GlobalAction>
{ {
public Action Action;
private Box overlay;
private const int activate_delay = 400;
private const int fadeout_delay = 200;
private bool fired;
[BackgroundDependencyLoader]
private void load()
{
RelativeSizeAxes = Axes.Both;
AlwaysPresent = true;
Children = new Drawable[]
{
overlay = new Box
{
Alpha = 0,
Colour = Color4.Black,
RelativeSizeAxes = Axes.Both,
}
};
}
public bool OnPressed(GlobalAction action) public bool OnPressed(GlobalAction action)
{ {
if (action != GlobalAction.QuickRetry) return false; if (action != GlobalAction.QuickRetry) return false;
overlay.FadeIn(activate_delay, Easing.Out); BeginConfirm();
return true; return true;
} }
@ -52,18 +21,8 @@ namespace osu.Game.Screens.Play
{ {
if (action != GlobalAction.QuickRetry) return false; if (action != GlobalAction.QuickRetry) return false;
overlay.FadeOut(fadeout_delay, Easing.Out); AbortConfirm();
return true; return true;
} }
protected override void Update()
{
base.Update();
if (!fired && overlay.Alpha == 1)
{
fired = true;
Action?.Invoke();
}
}
} }
} }

View File

@ -162,7 +162,7 @@ namespace osu.Game.Screens.Play
hudOverlay.KeyCounter.IsCounting = pauseContainer.IsPaused; hudOverlay.KeyCounter.IsCounting = pauseContainer.IsPaused;
}, },
OnResume = () => hudOverlay.KeyCounter.IsCounting = true, OnResume = () => hudOverlay.KeyCounter.IsCounting = true,
Children = new Drawable[] Children = new[]
{ {
storyboardContainer = new Container storyboardContainer = new Container
{ {
@ -174,12 +174,12 @@ namespace osu.Game.Screens.Play
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Child = RulesetContainer Child = RulesetContainer
}, },
new SkipOverlay(firstObjectTime) new BreakOverlay(beatmap.BeatmapInfo.LetterboxInBreaks, scoreProcessor)
{ {
Clock = Clock, // skip button doesn't want to use the audio clock directly Anchor = Anchor.Centre,
Origin = Anchor.Centre,
ProcessCustomClock = false, ProcessCustomClock = false,
AdjustableClock = adjustableClock, Breaks = beatmap.Breaks
FramedClock = offsetClock,
}, },
hudOverlay = new HUDOverlay(scoreProcessor, RulesetContainer, working, offsetClock, adjustableClock) hudOverlay = new HUDOverlay(scoreProcessor, RulesetContainer, working, offsetClock, adjustableClock)
{ {
@ -188,13 +188,14 @@ namespace osu.Game.Screens.Play
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre Origin = Anchor.Centre
}, },
new BreakOverlay(beatmap.BeatmapInfo.LetterboxInBreaks, scoreProcessor) RulesetContainer.Cursor?.CreateProxy() ?? new Container(),
new SkipOverlay(firstObjectTime)
{ {
Anchor = Anchor.Centre, Clock = Clock, // skip button doesn't want to use the audio clock directly
Origin = Anchor.Centre,
ProcessCustomClock = false, ProcessCustomClock = false,
Breaks = beatmap.Breaks AdjustableClock = adjustableClock,
} FramedClock = offsetClock,
},
} }
}, },
failOverlay = new FailOverlay failOverlay = new FailOverlay