2017-02-07 13:59:30 +09: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-19 18:00:35 +09:00
|
|
|
|
|
2016-10-26 17:26:26 +09:00
|
|
|
|
using System.Collections.Generic;
|
2017-03-09 15:52:40 +09:00
|
|
|
|
using System.Linq;
|
2016-11-28 11:38:32 +09:00
|
|
|
|
using osu.Framework.Allocation;
|
2017-03-28 21:03:34 +09:00
|
|
|
|
using osu.Framework.Testing;
|
2016-10-19 18:00:35 +09:00
|
|
|
|
using osu.Game.Beatmaps;
|
2016-10-26 17:26:26 +09:00
|
|
|
|
using OpenTK;
|
2016-11-17 21:29:35 +09:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2016-11-28 11:38:32 +09:00
|
|
|
|
using osu.Game.Database;
|
2017-04-18 16:05:58 +09:00
|
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
2016-11-14 17:23:33 +09:00
|
|
|
|
using osu.Game.Screens.Play;
|
2016-11-17 21:29:35 +09:00
|
|
|
|
using OpenTK.Graphics;
|
2017-03-22 05:54:07 -04:00
|
|
|
|
using osu.Desktop.VisualTests.Beatmaps;
|
2017-04-18 16:05:58 +09:00
|
|
|
|
using osu.Game.Rulesets.Osu.UI;
|
2016-10-19 18:00:35 +09:00
|
|
|
|
|
2016-10-26 17:26:26 +09:00
|
|
|
|
namespace osu.Desktop.VisualTests.Tests
|
2016-10-19 18:00:35 +09:00
|
|
|
|
{
|
2017-03-07 10:59:19 +09:00
|
|
|
|
internal class TestCasePlayer : TestCase
|
2016-10-19 18:00:35 +09:00
|
|
|
|
{
|
2017-03-02 16:08:37 +09:00
|
|
|
|
protected Player Player;
|
|
|
|
|
private BeatmapDatabase db;
|
2017-04-17 19:44:03 +09:00
|
|
|
|
private RulesetDatabase rulesets;
|
2017-03-02 16:08:37 +09:00
|
|
|
|
|
2016-10-19 18:00:35 +09:00
|
|
|
|
public override string Description => @"Showing everything to play the game.";
|
|
|
|
|
|
2016-11-28 11:38:32 +09:00
|
|
|
|
[BackgroundDependencyLoader]
|
2017-04-17 19:44:03 +09:00
|
|
|
|
private void load(BeatmapDatabase db, RulesetDatabase rulesets)
|
2016-11-28 11:38:32 +09:00
|
|
|
|
{
|
2017-04-17 19:44:03 +09:00
|
|
|
|
this.rulesets = rulesets;
|
2017-03-02 16:08:37 +09:00
|
|
|
|
this.db = db;
|
2016-11-28 11:38:32 +09:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-19 18:00:35 +09:00
|
|
|
|
public override void Reset()
|
|
|
|
|
{
|
|
|
|
|
base.Reset();
|
|
|
|
|
|
2017-03-02 16:08:37 +09:00
|
|
|
|
WorkingBeatmap beatmap = null;
|
|
|
|
|
|
2017-04-18 10:55:33 +09:00
|
|
|
|
var beatmapInfo = db.Query<BeatmapInfo>().FirstOrDefault(b => b.RulesetID == 0);
|
2017-03-02 16:08:37 +09:00
|
|
|
|
if (beatmapInfo != null)
|
|
|
|
|
beatmap = db.GetWorkingBeatmap(beatmapInfo);
|
|
|
|
|
|
2017-02-23 16:44:59 +09:00
|
|
|
|
if (beatmap?.Track == null)
|
2016-10-19 18:00:35 +09:00
|
|
|
|
{
|
2016-11-28 11:38:32 +09:00
|
|
|
|
var objects = new List<HitObject>();
|
|
|
|
|
|
|
|
|
|
int time = 1500;
|
|
|
|
|
for (int i = 0; i < 50; i++)
|
2016-10-19 18:00:35 +09:00
|
|
|
|
{
|
2017-03-07 10:59:19 +09:00
|
|
|
|
objects.Add(new HitCircle
|
2016-11-28 11:38:32 +09:00
|
|
|
|
{
|
|
|
|
|
StartTime = time,
|
2017-04-18 12:19:39 +09:00
|
|
|
|
Position = new Vector2(i % 4 == 0 || i % 4 == 2 ? 0 : OsuPlayfield.BASE_SIZE.X,
|
|
|
|
|
i % 4 < 2 ? 0 : OsuPlayfield.BASE_SIZE.Y),
|
2016-11-28 11:38:32 +09:00
|
|
|
|
NewCombo = i % 4 == 0
|
|
|
|
|
});
|
2016-10-19 18:00:35 +09:00
|
|
|
|
|
2016-11-28 11:38:32 +09:00
|
|
|
|
time += 500;
|
|
|
|
|
}
|
2016-10-19 18:00:35 +09:00
|
|
|
|
|
2016-11-28 11:38:32 +09:00
|
|
|
|
Beatmap b = new Beatmap
|
|
|
|
|
{
|
2017-02-22 23:27:29 +09:00
|
|
|
|
HitObjects = objects,
|
|
|
|
|
BeatmapInfo = new BeatmapInfo
|
|
|
|
|
{
|
2017-03-16 23:18:02 +09:00
|
|
|
|
Difficulty = new BeatmapDifficulty(),
|
2017-04-17 19:44:03 +09:00
|
|
|
|
Ruleset = rulesets.Query<RulesetInfo>().First(),
|
2017-02-22 23:27:29 +09:00
|
|
|
|
Metadata = new BeatmapMetadata
|
|
|
|
|
{
|
|
|
|
|
Artist = @"Unknown",
|
|
|
|
|
Title = @"Sample Beatmap",
|
|
|
|
|
Author = @"peppy",
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-11-28 11:38:32 +09:00
|
|
|
|
};
|
2016-11-02 18:08:08 +09:00
|
|
|
|
|
2017-02-24 13:43:21 +09:00
|
|
|
|
beatmap = new TestWorkingBeatmap(b);
|
2016-11-28 11:38:32 +09:00
|
|
|
|
}
|
2016-11-02 18:08:08 +09:00
|
|
|
|
|
2016-11-17 21:29:35 +09:00
|
|
|
|
Add(new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Framework.Graphics.Axes.Both,
|
2017-02-18 15:54:26 +09:00
|
|
|
|
Colour = Color4.Black,
|
2016-11-17 21:29:35 +09:00
|
|
|
|
});
|
|
|
|
|
|
2017-04-11 19:38:03 +09:00
|
|
|
|
Add(Player = CreatePlayer(beatmap));
|
2017-03-02 16:08:37 +09:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual Player CreatePlayer(WorkingBeatmap beatmap)
|
|
|
|
|
{
|
|
|
|
|
return new Player
|
2017-02-22 21:43:29 +09:00
|
|
|
|
{
|
|
|
|
|
Beatmap = beatmap
|
2017-03-02 16:08:37 +09:00
|
|
|
|
};
|
2016-10-19 18:00:35 +09:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|