1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 15:47:26 +08:00

Merge branch 'master' into timeline-maybe

This commit is contained in:
Dean Herbert 2020-01-24 13:39:51 +09:00
commit ea2271c905
13 changed files with 264 additions and 62 deletions

View File

@ -19,18 +19,22 @@ using osu.Game.Screens.Play.HUD.HitErrorMeters;
namespace osu.Game.Tests.Visual.Gameplay
{
public class TestSceneBarHitErrorMeter : OsuTestScene
public class TestSceneHitErrorMeter : OsuTestScene
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(HitErrorMeter),
typeof(BarHitErrorMeter),
typeof(ColourHitErrorMeter)
};
private HitErrorMeter meter;
private HitErrorMeter meter2;
private BarHitErrorMeter barMeter;
private BarHitErrorMeter barMeter2;
private ColourHitErrorMeter colourMeter;
private ColourHitErrorMeter colourMeter2;
private HitWindows hitWindows;
public TestSceneBarHitErrorMeter()
public TestSceneHitErrorMeter()
{
recreateDisplay(new OsuHitWindows(), 5);
@ -91,17 +95,31 @@ namespace osu.Game.Tests.Visual.Gameplay
}
});
Add(meter = new BarHitErrorMeter(hitWindows, true)
Add(barMeter = new BarHitErrorMeter(hitWindows, true)
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
});
Add(meter2 = new BarHitErrorMeter(hitWindows, false)
Add(barMeter2 = new BarHitErrorMeter(hitWindows, false)
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
});
Add(colourMeter = new ColourHitErrorMeter(hitWindows)
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Margin = new MarginPadding { Right = 50 }
});
Add(colourMeter2 = new ColourHitErrorMeter(hitWindows)
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Margin = new MarginPadding { Left = 50 }
});
}
private void newJudgement(double offset = 0)
@ -112,8 +130,10 @@ namespace osu.Game.Tests.Visual.Gameplay
Type = HitResult.Perfect,
};
meter.OnNewJudgement(judgement);
meter2.OnNewJudgement(judgement);
barMeter.OnNewJudgement(judgement);
barMeter2.OnNewJudgement(judgement);
colourMeter.OnNewJudgement(judgement);
colourMeter2.OnNewJudgement(judgement);
}
}
}

View File

@ -30,29 +30,23 @@ namespace osu.Game.Tests.Visual.Online
public TestSceneCommentsContainer()
{
BasicScrollContainer scrollFlow;
BasicScrollContainer scroll;
CommentsContainer comments;
Add(scrollFlow = new BasicScrollContainer
Add(scroll = new BasicScrollContainer
{
RelativeSizeAxes = Axes.Both,
Child = comments = new CommentsContainer()
});
AddStep("Big Black comments", () =>
AddStep("Big Black comments", () => comments.ShowComments(CommentableType.Beatmapset, 41823));
AddStep("Airman comments", () => comments.ShowComments(CommentableType.Beatmapset, 24313));
AddStep("Lazer build comments", () => comments.ShowComments(CommentableType.Build, 4772));
AddStep("News comments", () => comments.ShowComments(CommentableType.NewsPost, 715));
AddStep("Idle state", () =>
{
scrollFlow.Clear();
scrollFlow.Add(new CommentsContainer(CommentableType.Beatmapset, 41823));
});
AddStep("Airman comments", () =>
{
scrollFlow.Clear();
scrollFlow.Add(new CommentsContainer(CommentableType.Beatmapset, 24313));
});
AddStep("lazer build comments", () =>
{
scrollFlow.Clear();
scrollFlow.Add(new CommentsContainer(CommentableType.Build, 4772));
scroll.Clear();
scroll.Add(comments = new CommentsContainer());
});
}
}

View File

@ -25,6 +25,8 @@ namespace osu.Game.Tests.Visual.UserInterface
private readonly Mod testCustomisableMod = new TestModCustomisable1();
private readonly Mod testCustomisableAutoOpenMod = new TestModCustomisable2();
[Test]
public void TestButtonShowsOnCustomisableMod()
{
@ -53,6 +55,17 @@ namespace osu.Game.Tests.Visual.UserInterface
AddAssert("button enabled", () => modSelect.CustomiseButton.Enabled.Value);
}
[Test]
public void TestCustomisationOpensOnModSelect()
{
createModSelect();
AddStep("open", () => modSelect.Show());
AddAssert("Customisation closed", () => modSelect.ModSettingsContainer.Alpha == 0);
AddStep("select mod", () => modSelect.SelectMod(testCustomisableAutoOpenMod));
AddAssert("Customisation opened", () => modSelect.ModSettingsContainer.Alpha == 1);
}
private void createModSelect()
{
AddStep("create mod select", () =>
@ -128,6 +141,8 @@ namespace osu.Game.Tests.Visual.UserInterface
public override string Name => "Customisable Mod 2";
public override string Acronym => "CM2";
public override bool RequiresConfiguration => true;
}
private abstract class TestModCustomisable : Mod, IApplicableMod

View File

@ -541,7 +541,7 @@
},
{
"FlagName": "MK",
"FullName": "Macedonia",
"FullName": "North Macedonia",
"Acronym": "MKD"
},
{
@ -811,7 +811,7 @@
},
{
"FlagName": "CV",
"FullName": "Cape Verde",
"FullName": "Cabo Verde",
"Acronym": "CPV"
},
{
@ -821,7 +821,7 @@
},
{
"FlagName": "SZ",
"FullName": "Swaziland",
"FullName": "Eswatini",
"Acronym": "SWZ"
},
{

View File

@ -18,5 +18,14 @@ namespace osu.Game.Configuration
[Description("Hit Error (both)")]
HitErrorBoth,
[Description("Colour (left)")]
ColourLeft,
[Description("Colour (right)")]
ColourRight,
[Description("Colour (both)")]
ColourBoth,
}
}

View File

@ -18,8 +18,8 @@ namespace osu.Game.Overlays.Comments
{
public class CommentsContainer : CompositeDrawable
{
private readonly CommentableType type;
private readonly long id;
private CommentableType type;
private long? id;
public readonly Bindable<CommentsSortCriteria> Sort = new Bindable<CommentsSortCriteria>();
public readonly BindableBool ShowDeleted = new BindableBool();
@ -38,12 +38,10 @@ namespace osu.Game.Overlays.Comments
private readonly FillFlowContainer content;
private readonly DeletedChildrenPlaceholder deletedChildrenPlaceholder;
private readonly CommentsShowMoreButton moreButton;
private readonly TotalCommentsCounter commentCounter;
public CommentsContainer(CommentableType type, long id)
public CommentsContainer()
{
this.type = type;
this.id = id;
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
AddRangeInternal(new Drawable[]
@ -59,6 +57,7 @@ namespace osu.Game.Overlays.Comments
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
commentCounter = new TotalCommentsCounter(),
new CommentsHeader
{
Sort = { BindTarget = Sort },
@ -101,7 +100,8 @@ namespace osu.Game.Overlays.Comments
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Margin = new MarginPadding(5),
Action = getComments
Action = getComments,
IsLoading = true,
}
}
}
@ -121,11 +121,27 @@ namespace osu.Game.Overlays.Comments
protected override void LoadComplete()
{
Sort.BindValueChanged(onSortChanged, true);
Sort.BindValueChanged(_ => refetchComments(), true);
base.LoadComplete();
}
private void onSortChanged(ValueChangedEvent<CommentsSortCriteria> sort)
/// <param name="type">The type of resource to get comments for.</param>
/// <param name="id">The id of the resource to get comments for.</param>
public void ShowComments(CommentableType type, long id)
{
this.type = type;
this.id = id;
if (!IsLoaded)
return;
// only reset when changing ID/type. other refetch ops are generally just changing sort order.
commentCounter.Current.Value = 0;
refetchComments();
}
private void refetchComments()
{
clearComments();
getComments();
@ -133,9 +149,12 @@ namespace osu.Game.Overlays.Comments
private void getComments()
{
if (!id.HasValue)
return;
request?.Cancel();
loadCancellation?.Cancel();
request = new GetCommentsRequest(type, id, Sort.Value, currentPage++);
request = new GetCommentsRequest(type, id.Value, Sort.Value, currentPage++);
request.Success += onSuccess;
api.Queue(request);
}
@ -152,7 +171,7 @@ namespace osu.Game.Overlays.Comments
{
loadCancellation = new CancellationTokenSource();
FillFlowContainer page = new FillFlowContainer
var page = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
@ -185,6 +204,8 @@ namespace osu.Game.Overlays.Comments
moreButton.IsLoading = false;
}
commentCounter.Current.Value = response.Total;
moreButton.FadeTo(response.HasMore ? 1 : 0);
}, loadCancellation.Token);
}

View File

@ -473,7 +473,10 @@ namespace osu.Game.Overlays.Mods
if (selectedMod != null)
{
if (State.Value == Visibility.Visible) sampleOn?.Play();
DeselectTypes(selectedMod.IncompatibleMods, true);
if (selectedMod.RequiresConfiguration) ModSettingsContainer.Alpha = 1;
}
else
{

View File

@ -60,6 +60,12 @@ namespace osu.Game.Rulesets.Mods
[JsonIgnore]
public virtual bool Ranked => false;
/// <summary>
/// Whether this mod requires configuration to apply changes to the game.
/// </summary>
[JsonIgnore]
public virtual bool RequiresConfiguration => false;
/// <summary>
/// The mods this mod cannot be enabled with.
/// </summary>

View File

@ -24,6 +24,8 @@ namespace osu.Game.Rulesets.Mods
public override double ScoreMultiplier => 1.0;
public override bool RequiresConfiguration => true;
public override Type[] IncompatibleMods => new[] { typeof(ModEasy), typeof(ModHardRock) };
[SettingSource("Drain Rate", "Override a beatmap's set HP.")]

View File

@ -77,6 +77,19 @@ namespace osu.Game.Screens.Play.HUD
case ScoreMeterType.HitErrorRight:
createBar(true);
break;
case ScoreMeterType.ColourBoth:
createColour(false);
createColour(true);
break;
case ScoreMeterType.ColourLeft:
createColour(false);
break;
case ScoreMeterType.ColourRight:
createColour(true);
break;
}
}
@ -90,6 +103,24 @@ namespace osu.Game.Screens.Play.HUD
Alpha = 0,
};
completeDisplayLoading(display);
}
private void createColour(bool rightAligned)
{
var display = new ColourHitErrorMeter(hitWindows)
{
Margin = new MarginPadding(margin),
Anchor = rightAligned ? Anchor.CentreRight : Anchor.CentreLeft,
Origin = rightAligned ? Anchor.CentreRight : Anchor.CentreLeft,
Alpha = 0,
};
completeDisplayLoading(display);
}
private void completeDisplayLoading(HitErrorMeter display)
{
Add(display);
display.FadeInFromZero(fade_duration, Easing.OutQuint);
}

View File

@ -163,30 +163,9 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
centre.Width = 2.5f;
colourBars.Add(centre);
Color4 getColour(HitResult result)
{
switch (result)
{
case HitResult.Meh:
return colours.Yellow;
case HitResult.Ok:
return colours.Green;
case HitResult.Good:
return colours.GreenLight;
case HitResult.Great:
return colours.Blue;
default:
return colours.BlueLight;
}
}
Drawable createColourBar(HitResult result, float height, bool first = false)
{
var colour = getColour(result);
var colour = GetColourForHitResult(result);
if (first)
{
@ -201,7 +180,7 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = getColour(result),
Colour = colour,
Height = height * gradient_start
},
new Box

View File

@ -0,0 +1,92 @@
// 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.Collections.Generic;
using System.Linq;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Scoring;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Screens.Play.HUD.HitErrorMeters
{
public class ColourHitErrorMeter : HitErrorMeter
{
private const int animation_duration = 200;
private readonly JudgementFlow judgementsFlow;
public ColourHitErrorMeter(HitWindows hitWindows)
: base(hitWindows)
{
AutoSizeAxes = Axes.Both;
InternalChild = judgementsFlow = new JudgementFlow();
}
public override void OnNewJudgement(JudgementResult judgement) => judgementsFlow.Push(GetColourForHitResult(HitWindows.ResultFor(judgement.TimeOffset)));
private class JudgementFlow : FillFlowContainer<HitErrorCircle>
{
private const int max_available_judgements = 20;
private const int drawable_judgement_size = 8;
private const int spacing = 2;
public override IEnumerable<Drawable> FlowingChildren => base.FlowingChildren.Reverse();
public JudgementFlow()
{
AutoSizeAxes = Axes.X;
Height = max_available_judgements * (drawable_judgement_size + spacing) - spacing;
Spacing = new Vector2(0, spacing);
Direction = FillDirection.Vertical;
LayoutDuration = animation_duration;
LayoutEasing = Easing.OutQuint;
}
public void Push(Color4 colour)
{
Add(new HitErrorCircle(colour, drawable_judgement_size));
if (Children.Count > max_available_judgements)
Children.FirstOrDefault(c => !c.IsRemoved)?.Remove();
}
}
private class HitErrorCircle : Container
{
public bool IsRemoved { get; private set; }
private readonly Circle circle;
public HitErrorCircle(Color4 colour, int size)
{
Size = new Vector2(size);
Child = circle = new Circle
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
Colour = colour
};
}
protected override void LoadComplete()
{
base.LoadComplete();
circle.FadeInFromZero(animation_duration, Easing.OutQuint);
circle.MoveToY(-DrawSize.Y);
circle.MoveToY(0, animation_duration, Easing.OutQuint);
}
public void Remove()
{
IsRemoved = true;
this.FadeOut(animation_duration, Easing.OutQuint).Expire();
}
}
}
}

View File

@ -1,9 +1,12 @@
// 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.Containers;
using osu.Game.Graphics;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Scoring;
using osuTK.Graphics;
namespace osu.Game.Screens.Play.HUD.HitErrorMeters
{
@ -11,11 +14,38 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
{
protected readonly HitWindows HitWindows;
[Resolved]
private OsuColour colours { get; set; }
protected HitErrorMeter(HitWindows hitWindows)
{
HitWindows = hitWindows;
}
public abstract void OnNewJudgement(JudgementResult judgement);
protected Color4 GetColourForHitResult(HitResult result)
{
switch (result)
{
case HitResult.Miss:
return colours.Red;
case HitResult.Meh:
return colours.Yellow;
case HitResult.Ok:
return colours.Green;
case HitResult.Good:
return colours.GreenLight;
case HitResult.Great:
return colours.Blue;
default:
return colours.BlueLight;
}
}
}
}