mirror of https://github.com/ppy/osu
Clean up syntax for readability
This commit is contained in:
parent
0c177aa7de
commit
f3873b73e3
|
@ -81,9 +81,6 @@ public void TestAddJudgementsToCounters()
|
||||||
AddRepeatStep("Add judgement", () => applyOneJudgement(HitResult.Great), 2);
|
AddRepeatStep("Add judgement", () => applyOneJudgement(HitResult.Great), 2);
|
||||||
AddRepeatStep("Add judgement", () => applyOneJudgement(HitResult.Miss), 2);
|
AddRepeatStep("Add judgement", () => applyOneJudgement(HitResult.Miss), 2);
|
||||||
AddRepeatStep("Add judgement", () => applyOneJudgement(HitResult.Meh), 2);
|
AddRepeatStep("Add judgement", () => applyOneJudgement(HitResult.Meh), 2);
|
||||||
AddRepeatStep("Add judgement", () => applyOneJudgement(HitResult.LargeTickHit), 2);
|
|
||||||
AddStep("Show all judgements", () => counterDisplay.Mode.Value = JudgementCounterDisplay.DisplayMode.All);
|
|
||||||
AddAssert("Check value added whilst hidden", () => hiddenCount() == 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -105,8 +102,10 @@ public void TestChangeFlowDirection()
|
||||||
public void TestToggleJudgementNames()
|
public void TestToggleJudgementNames()
|
||||||
{
|
{
|
||||||
AddStep("Hide judgement names", () => counterDisplay.ShowName.Value = false);
|
AddStep("Hide judgement names", () => counterDisplay.ShowName.Value = false);
|
||||||
|
AddWaitStep("wait some", 2);
|
||||||
AddAssert("Assert hidden", () => counterDisplay.JudgementContainer.Children.OfType<JudgementCounter>().First().ResultName.Alpha == 0);
|
AddAssert("Assert hidden", () => counterDisplay.JudgementContainer.Children.OfType<JudgementCounter>().First().ResultName.Alpha == 0);
|
||||||
AddStep("Hide judgement names", () => counterDisplay.ShowName.Value = true);
|
AddStep("Hide judgement names", () => counterDisplay.ShowName.Value = true);
|
||||||
|
AddWaitStep("wait some", 2);
|
||||||
AddAssert("Assert shown", () => counterDisplay.JudgementContainer.Children.OfType<JudgementCounter>().First().ResultName.Alpha == 1);
|
AddAssert("Assert shown", () => counterDisplay.JudgementContainer.Children.OfType<JudgementCounter>().First().ResultName.Alpha == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,10 +20,7 @@ public partial class JudgementCounter : OverlayContainer
|
||||||
|
|
||||||
public readonly JudgementCounterInfo Result;
|
public readonly JudgementCounterInfo Result;
|
||||||
|
|
||||||
public JudgementCounter(JudgementCounterInfo result)
|
public JudgementCounter(JudgementCounterInfo result) => Result = result;
|
||||||
{
|
|
||||||
Result = result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OsuSpriteText ResultName = null!;
|
public OsuSpriteText ResultName = null!;
|
||||||
private FillFlowContainer flowContainer = null!;
|
private FillFlowContainer flowContainer = null!;
|
||||||
|
@ -52,45 +49,18 @@ private void load(OsuColour colours, IBindable<RulesetInfo> ruleset)
|
||||||
|
|
||||||
var result = Result.Type;
|
var result = Result.Type;
|
||||||
|
|
||||||
if (result.IsBasic())
|
Colour = result.IsBasic() ? colours.ForHitResult(Result.Type) : !result.IsBonus() ? colours.PurpleLight : colours.PurpleLighter;
|
||||||
{
|
|
||||||
Colour = colours.ForHitResult(Result.Type);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!result.IsBonus())
|
|
||||||
{
|
|
||||||
Colour = colours.PurpleLight;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Colour = colours.PurpleLighter;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
ShowName.BindValueChanged(value =>
|
ShowName.BindValueChanged(value =>
|
||||||
{
|
ResultName.FadeTo(value.NewValue ? 1 : 0, JudgementCounterDisplay.TRANSFORM_DURATION, Easing.OutQuint), true);
|
||||||
if (value.NewValue)
|
|
||||||
{
|
|
||||||
ResultName.Show();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ResultName.Hide();
|
|
||||||
}, true);
|
|
||||||
|
|
||||||
Direction.BindValueChanged(direction =>
|
Direction.BindValueChanged(direction =>
|
||||||
{
|
{
|
||||||
flowContainer.Direction = direction.NewValue;
|
flowContainer.Direction = direction.NewValue;
|
||||||
|
changeAnchor(direction.NewValue == FillDirection.Vertical ? Anchor.TopLeft : Anchor.BottomLeft);
|
||||||
if (direction.NewValue == FillDirection.Vertical)
|
|
||||||
{
|
|
||||||
changeAnchor(Anchor.TopLeft);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
changeAnchor(Anchor.BottomLeft);
|
|
||||||
|
|
||||||
void changeAnchor(Anchor anchor) => counter.Anchor = ResultName.Anchor = counter.Origin = ResultName.Origin = anchor;
|
void changeAnchor(Anchor anchor) => counter.Anchor = ResultName.Anchor = counter.Origin = ResultName.Origin = anchor;
|
||||||
}, true);
|
}, true);
|
||||||
|
@ -98,15 +68,8 @@ protected override void LoadComplete()
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void PopIn()
|
protected override void PopIn() => this.FadeIn(JudgementCounterDisplay.TRANSFORM_DURATION, Easing.OutQuint);
|
||||||
{
|
protected override void PopOut() => this.FadeOut(100);
|
||||||
this.FadeIn(500, Easing.OutQuint);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void PopOut()
|
|
||||||
{
|
|
||||||
this.FadeOut(100);
|
|
||||||
}
|
|
||||||
|
|
||||||
private sealed partial class JudgementRollingCounter : RollingCounter<int>
|
private sealed partial class JudgementRollingCounter : RollingCounter<int>
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,6 +16,7 @@ namespace osu.Game.Screens.Play.HUD.JudgementCounter
|
||||||
{
|
{
|
||||||
public partial class JudgementCounterDisplay : CompositeDrawable, ISkinnableDrawable
|
public partial class JudgementCounterDisplay : CompositeDrawable, ISkinnableDrawable
|
||||||
{
|
{
|
||||||
|
public const int TRANSFORM_DURATION = 500;
|
||||||
public bool UsesFixedAnchor { get; set; }
|
public bool UsesFixedAnchor { get; set; }
|
||||||
|
|
||||||
[SettingSource("Display mode")]
|
[SettingSource("Display mode")]
|
||||||
|
@ -47,9 +48,7 @@ private void load()
|
||||||
};
|
};
|
||||||
|
|
||||||
foreach (var result in tally.Results)
|
foreach (var result in tally.Results)
|
||||||
{
|
|
||||||
JudgementContainer.Add(createCounter(result));
|
JudgementContainer.Add(createCounter(result));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
|
@ -62,22 +61,13 @@ protected override void LoadComplete()
|
||||||
|
|
||||||
//Can't pass directly due to Enum conversion
|
//Can't pass directly due to Enum conversion
|
||||||
foreach (var counter in JudgementContainer.Children.OfType<JudgementCounter>())
|
foreach (var counter in JudgementContainer.Children.OfType<JudgementCounter>())
|
||||||
{
|
|
||||||
counter.Direction.Value = getFlow(direction.NewValue);
|
counter.Direction.Value = getFlow(direction.NewValue);
|
||||||
}
|
|
||||||
}, true);
|
}, true);
|
||||||
Mode.BindValueChanged(_ => updateMode(), true);
|
Mode.BindValueChanged(_ => updateMode(), true);
|
||||||
ShowMax.BindValueChanged(value =>
|
ShowMax.BindValueChanged(value =>
|
||||||
{
|
{
|
||||||
var firstChild = JudgementContainer.Children.FirstOrDefault();
|
var firstChild = JudgementContainer.Children.FirstOrDefault();
|
||||||
|
firstChild.FadeTo(value.NewValue ? 1 : 0, TRANSFORM_DURATION, Easing.OutQuint);
|
||||||
if (value.NewValue)
|
|
||||||
{
|
|
||||||
firstChild?.Show();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
firstChild?.Hide();
|
|
||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,22 +79,14 @@ private void updateMode()
|
||||||
{
|
{
|
||||||
case DisplayMode.Simple:
|
case DisplayMode.Simple:
|
||||||
counter.Hide();
|
counter.Hide();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DisplayMode.Normal:
|
case DisplayMode.Normal:
|
||||||
if (counter.Result.Type.IsBonus())
|
counter.FadeTo(counter.Result.Type.IsBonus() ? 0 : 1);
|
||||||
{
|
|
||||||
counter.Hide();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
counter.Show();
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DisplayMode.All:
|
case DisplayMode.All:
|
||||||
counter.Show();
|
counter.Show();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
|
using osu.Game.Rulesets.Judgements;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Play.HUD.JudgementCounter
|
namespace osu.Game.Screens.Play.HUD.JudgementCounter
|
||||||
|
@ -35,17 +36,14 @@ protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
scoreProcessor.NewJudgement += judgement =>
|
scoreProcessor.NewJudgement += judgement => updateCount(judgement, false);
|
||||||
{
|
scoreProcessor.JudgementReverted += judgement => updateCount(judgement, true);
|
||||||
foreach (JudgementCounterInfo result in Results.Where(result => result.Type == judgement.Type))
|
}
|
||||||
result.ResultCount.Value++;
|
|
||||||
};
|
|
||||||
|
|
||||||
scoreProcessor.JudgementReverted += judgement =>
|
private void updateCount(JudgementResult judgement, bool revert)
|
||||||
{
|
{
|
||||||
foreach (JudgementCounterInfo result in Results.Where(result => result.Type == judgement.Type))
|
foreach (JudgementCounterInfo result in Results.Where(result => result.Type == judgement.Type))
|
||||||
result.ResultCount.Value--;
|
result.ResultCount.Value = revert ? result.ResultCount.Value - 1 : result.ResultCount.Value + 1;
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue