2017-02-07 12:59:30 +08:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2016-10-07 15:05:02 +08:00
|
|
|
|
|
2017-03-10 10:04:46 +08:00
|
|
|
|
using OpenTK;
|
2016-10-07 15:05:02 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2017-03-10 10:04:46 +08:00
|
|
|
|
using osu.Framework.Graphics.Primitives;
|
2016-10-10 03:02:44 +08:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2016-10-26 16:26:26 +08:00
|
|
|
|
using osu.Framework.MathUtils;
|
2017-03-10 10:04:46 +08:00
|
|
|
|
using osu.Framework.Screens.Testing;
|
2016-10-26 16:26:26 +08:00
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2016-11-14 17:54:24 +08:00
|
|
|
|
using osu.Game.Modes.UI;
|
2016-10-07 15:05:02 +08:00
|
|
|
|
|
2016-10-26 16:26:26 +08:00
|
|
|
|
namespace osu.Desktop.VisualTests.Tests
|
2016-10-07 15:05:02 +08:00
|
|
|
|
{
|
2017-03-07 09:59:19 +08:00
|
|
|
|
internal class TestCaseScoreCounter : TestCase
|
2016-10-07 15:05:02 +08:00
|
|
|
|
{
|
|
|
|
|
public override string Description => @"Tests multiple counters";
|
|
|
|
|
|
|
|
|
|
public override void Reset()
|
|
|
|
|
{
|
|
|
|
|
base.Reset();
|
|
|
|
|
|
2016-10-15 07:23:27 +08:00
|
|
|
|
int numerator = 0, denominator = 0;
|
|
|
|
|
|
2016-10-17 06:45:37 +08:00
|
|
|
|
bool maniaHold = false;
|
|
|
|
|
|
2016-10-13 09:58:43 +08:00
|
|
|
|
ScoreCounter score = new ScoreCounter(7)
|
2016-10-07 15:05:02 +08:00
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
|
TextSize = 40,
|
2016-11-15 00:22:20 +08:00
|
|
|
|
Margin = new MarginPadding(20),
|
2016-10-07 15:05:02 +08:00
|
|
|
|
};
|
2016-10-13 09:58:43 +08:00
|
|
|
|
Add(score);
|
2016-10-07 15:05:02 +08:00
|
|
|
|
|
2017-03-10 11:26:46 +08:00
|
|
|
|
ComboCounter comboCounter = new StandardComboCounter
|
2016-10-07 15:05:02 +08:00
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
2016-11-15 00:22:20 +08:00
|
|
|
|
Margin = new MarginPadding(10),
|
2016-10-07 15:05:02 +08:00
|
|
|
|
TextSize = 40,
|
|
|
|
|
};
|
2017-03-10 10:59:08 +08:00
|
|
|
|
Add(comboCounter);
|
2016-10-07 15:05:02 +08:00
|
|
|
|
|
2017-03-10 10:59:08 +08:00
|
|
|
|
PercentageCounter accuracyCounter = new PercentageCounter
|
2016-10-07 15:05:02 +08:00
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
|
Anchor = Anchor.TopRight,
|
2016-11-15 00:22:20 +08:00
|
|
|
|
Position = new Vector2(-20, 60),
|
2016-10-07 15:05:02 +08:00
|
|
|
|
};
|
2017-03-10 10:59:08 +08:00
|
|
|
|
Add(accuracyCounter);
|
2016-10-07 15:05:02 +08:00
|
|
|
|
|
2016-10-17 07:30:25 +08:00
|
|
|
|
StarCounter stars = new StarCounter
|
2016-10-10 03:02:44 +08:00
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
2016-11-15 00:22:20 +08:00
|
|
|
|
Position = new Vector2(20, -160),
|
2016-10-17 07:30:25 +08:00
|
|
|
|
Count = 5,
|
2016-10-10 03:02:44 +08:00
|
|
|
|
};
|
2016-10-17 07:30:25 +08:00
|
|
|
|
Add(stars);
|
2016-10-10 03:02:44 +08:00
|
|
|
|
|
2016-10-17 07:30:25 +08:00
|
|
|
|
SpriteText starsLabel = new SpriteText
|
2016-10-09 08:11:01 +08:00
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
2016-11-15 00:22:20 +08:00
|
|
|
|
Position = new Vector2(20, -190),
|
2016-10-17 07:30:25 +08:00
|
|
|
|
Text = stars.Count.ToString("0.00"),
|
2016-10-09 08:11:01 +08:00
|
|
|
|
};
|
2016-10-17 07:30:25 +08:00
|
|
|
|
Add(starsLabel);
|
2016-10-09 08:11:01 +08:00
|
|
|
|
|
2016-10-08 06:15:36 +08:00
|
|
|
|
AddButton(@"Reset all", delegate
|
2016-10-07 15:05:02 +08:00
|
|
|
|
{
|
2017-03-10 12:08:59 +08:00
|
|
|
|
score.Current.Value = 0;
|
2017-03-10 11:55:10 +08:00
|
|
|
|
comboCounter.Current.Value = 0;
|
2016-10-15 07:23:27 +08:00
|
|
|
|
numerator = denominator = 0;
|
2017-03-10 10:59:08 +08:00
|
|
|
|
accuracyCounter.SetFraction(0, 0);
|
2016-10-13 09:58:43 +08:00
|
|
|
|
stars.Count = 0;
|
|
|
|
|
starsLabel.Text = stars.Count.ToString("0.00");
|
2016-10-08 06:15:36 +08:00
|
|
|
|
});
|
2016-10-07 15:05:02 +08:00
|
|
|
|
|
2016-10-08 06:15:36 +08:00
|
|
|
|
AddButton(@"Hit! :D", delegate
|
2016-10-07 15:05:02 +08:00
|
|
|
|
{
|
2017-03-10 13:44:38 +08:00
|
|
|
|
score.Current.Value += 300 + (ulong)(300.0 * (comboCounter.Current > 0 ? comboCounter.Current - 1 : 0) / 25.0);
|
2017-03-10 11:55:10 +08:00
|
|
|
|
comboCounter.Increment();
|
2016-10-15 07:23:27 +08:00
|
|
|
|
numerator++; denominator++;
|
2017-03-10 10:59:08 +08:00
|
|
|
|
accuracyCounter.SetFraction(numerator, denominator);
|
2016-10-08 06:15:36 +08:00
|
|
|
|
});
|
2016-10-07 15:05:02 +08:00
|
|
|
|
|
2016-10-08 06:15:36 +08:00
|
|
|
|
AddButton(@"miss...", delegate
|
2016-10-07 15:05:02 +08:00
|
|
|
|
{
|
2017-03-10 13:34:08 +08:00
|
|
|
|
comboCounter.Current.Value = 0;
|
2016-10-15 07:23:27 +08:00
|
|
|
|
denominator++;
|
2017-03-10 10:59:08 +08:00
|
|
|
|
accuracyCounter.SetFraction(numerator, denominator);
|
2016-10-08 06:15:36 +08:00
|
|
|
|
});
|
2016-10-07 15:05:02 +08:00
|
|
|
|
|
2016-10-09 08:11:01 +08:00
|
|
|
|
AddButton(@"Alter stars", delegate
|
|
|
|
|
{
|
2017-02-24 18:30:04 +08:00
|
|
|
|
stars.Count = RNG.NextSingle() * (stars.StarCount + 1);
|
2016-10-13 09:58:43 +08:00
|
|
|
|
starsLabel.Text = stars.Count.ToString("0.00");
|
2016-10-09 08:11:01 +08:00
|
|
|
|
});
|
|
|
|
|
|
2016-10-08 06:15:36 +08:00
|
|
|
|
AddButton(@"Stop counters", delegate
|
2016-10-07 15:05:02 +08:00
|
|
|
|
{
|
2016-10-13 09:58:43 +08:00
|
|
|
|
score.StopRolling();
|
2017-03-10 10:59:08 +08:00
|
|
|
|
comboCounter.StopRolling();
|
|
|
|
|
accuracyCounter.StopRolling();
|
2016-10-14 06:13:20 +08:00
|
|
|
|
stars.StopAnimation();
|
2016-10-08 06:15:36 +08:00
|
|
|
|
});
|
2016-10-07 15:05:02 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|