mirror of
https://github.com/osukey/osukey.git
synced 2025-08-01 21:58:46 +09:00
Merge remote-tracking branch 'upstream/master' into multi-background-stack
This commit is contained in:
@ -0,0 +1,207 @@
|
||||
// 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;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Lists;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Overlays;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestCaseBeatSyncedContainer : OsuTestCase
|
||||
{
|
||||
private readonly MusicController mc;
|
||||
|
||||
public TestCaseBeatSyncedContainer()
|
||||
{
|
||||
Clock = new FramedClock();
|
||||
Clock.ProcessFrame();
|
||||
|
||||
Add(new BeatContainer
|
||||
{
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
});
|
||||
|
||||
Add(mc = new MusicController
|
||||
{
|
||||
Origin = Anchor.TopRight,
|
||||
Anchor = Anchor.TopRight,
|
||||
});
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
mc.ToggleVisibility();
|
||||
}
|
||||
|
||||
private class BeatContainer : BeatSyncedContainer
|
||||
{
|
||||
private const int flash_layer_heigth = 150;
|
||||
|
||||
private readonly InfoString timingPointCount;
|
||||
private readonly InfoString currentTimingPoint;
|
||||
private readonly InfoString beatCount;
|
||||
private readonly InfoString currentBeat;
|
||||
private readonly InfoString beatsPerMinute;
|
||||
private readonly InfoString adjustedBeatLength;
|
||||
private readonly InfoString timeUntilNextBeat;
|
||||
private readonly InfoString timeSinceLastBeat;
|
||||
|
||||
private readonly Box flashLayer;
|
||||
|
||||
public BeatContainer()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Container
|
||||
{
|
||||
Name = @"Info Layer",
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Margin = new MarginPadding { Bottom = flash_layer_heigth },
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black.Opacity(150),
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Vertical,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
timingPointCount = new InfoString(@"Timing points amount"),
|
||||
currentTimingPoint = new InfoString(@"Current timing point"),
|
||||
beatCount = new InfoString(@"Beats amount (in the current timing point)"),
|
||||
currentBeat = new InfoString(@"Current beat"),
|
||||
beatsPerMinute = new InfoString(@"BPM"),
|
||||
adjustedBeatLength = new InfoString(@"Adjusted beat length"),
|
||||
timeUntilNextBeat = new InfoString(@"Time until next beat"),
|
||||
timeSinceLastBeat = new InfoString(@"Time since last beat"),
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
new Container
|
||||
{
|
||||
Name = @"Color indicator",
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = flash_layer_heigth,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black,
|
||||
},
|
||||
flashLayer = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.White,
|
||||
Alpha = 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Beatmap.ValueChanged += delegate
|
||||
{
|
||||
timingPointCount.Value = 0;
|
||||
currentTimingPoint.Value = 0;
|
||||
beatCount.Value = 0;
|
||||
currentBeat.Value = 0;
|
||||
beatsPerMinute.Value = 0;
|
||||
adjustedBeatLength.Value = 0;
|
||||
timeUntilNextBeat.Value = 0;
|
||||
timeSinceLastBeat.Value = 0;
|
||||
};
|
||||
}
|
||||
|
||||
private SortedList<TimingControlPoint> timingPoints => Beatmap.Value.Beatmap.ControlPointInfo.TimingPoints;
|
||||
|
||||
private TimingControlPoint getNextTimingPoint(TimingControlPoint current)
|
||||
{
|
||||
if (timingPoints[timingPoints.Count - 1] == current)
|
||||
return current;
|
||||
|
||||
return timingPoints[timingPoints.IndexOf(current) + 1];
|
||||
}
|
||||
|
||||
private int calculateBeatCount(TimingControlPoint current)
|
||||
{
|
||||
if (timingPoints.Count == 0) return 0;
|
||||
|
||||
if (timingPoints[timingPoints.Count - 1] == current)
|
||||
return (int)Math.Ceiling((Beatmap.Value.Track.Length - current.Time) / current.BeatLength);
|
||||
|
||||
return (int)Math.Ceiling((getNextTimingPoint(current).Time - current.Time) / current.BeatLength);
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
timeUntilNextBeat.Value = TimeUntilNextBeat;
|
||||
timeSinceLastBeat.Value = TimeSinceLastBeat;
|
||||
}
|
||||
|
||||
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes)
|
||||
{
|
||||
base.OnNewBeat(beatIndex, timingPoint, effectPoint, amplitudes);
|
||||
|
||||
timingPointCount.Value = timingPoints.Count;
|
||||
currentTimingPoint.Value = timingPoints.IndexOf(timingPoint);
|
||||
beatCount.Value = calculateBeatCount(timingPoint);
|
||||
currentBeat.Value = beatIndex;
|
||||
beatsPerMinute.Value = 60000 / timingPoint.BeatLength;
|
||||
adjustedBeatLength.Value = timingPoint.BeatLength;
|
||||
|
||||
flashLayer.FadeOutFromOne(timingPoint.BeatLength);
|
||||
}
|
||||
}
|
||||
|
||||
private class InfoString : FillFlowContainer
|
||||
{
|
||||
private const int text_size = 20;
|
||||
private const int margin = 7;
|
||||
|
||||
private readonly OsuSpriteText valueText;
|
||||
|
||||
public double Value
|
||||
{
|
||||
set => valueText.Text = $"{value:G}";
|
||||
}
|
||||
|
||||
public InfoString(string header)
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
Direction = FillDirection.Horizontal;
|
||||
Add(new OsuSpriteText { Text = header + @": ", Font = OsuFont.GetFont(size: text_size) });
|
||||
Add(valueText = new OsuSpriteText { Font = OsuFont.GetFont(size: text_size) });
|
||||
Margin = new MarginPadding(margin);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
45
osu.Game.Tests/Visual/UserInterface/TestCaseBreadcrumbs.cs
Normal file
45
osu.Game.Tests/Visual/UserInterface/TestCaseBreadcrumbs.cs
Normal file
@ -0,0 +1,45 @@
|
||||
// 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 NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestCaseBreadcrumbs : OsuTestCase
|
||||
{
|
||||
private readonly BreadcrumbControl<BreadcrumbTab> breadcrumbs;
|
||||
|
||||
public TestCaseBreadcrumbs()
|
||||
{
|
||||
Add(breadcrumbs = new BreadcrumbControl<BreadcrumbTab>
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Width = 0.5f,
|
||||
});
|
||||
|
||||
AddStep(@"first", () => breadcrumbs.Current.Value = BreadcrumbTab.Click);
|
||||
AddStep(@"second", () => breadcrumbs.Current.Value = BreadcrumbTab.The);
|
||||
AddStep(@"third", () => breadcrumbs.Current.Value = BreadcrumbTab.Circles);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
breadcrumbs.StripColour = colours.Blue;
|
||||
}
|
||||
|
||||
private enum BreadcrumbTab
|
||||
{
|
||||
Click,
|
||||
The,
|
||||
Circles,
|
||||
}
|
||||
}
|
||||
}
|
48
osu.Game.Tests/Visual/UserInterface/TestCaseButtonSystem.cs
Normal file
48
osu.Game.Tests/Visual/UserInterface/TestCaseButtonSystem.cs
Normal file
@ -0,0 +1,48 @@
|
||||
// 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;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Screens.Menu;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestCaseButtonSystem : OsuTestCase
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(ButtonSystem),
|
||||
typeof(ButtonArea),
|
||||
typeof(Button)
|
||||
};
|
||||
|
||||
public TestCaseButtonSystem()
|
||||
{
|
||||
OsuLogo logo;
|
||||
ButtonSystem buttons;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = ColourInfo.GradientVertical(Color4.Gray, Color4.WhiteSmoke),
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
buttons = new ButtonSystem(),
|
||||
logo = new OsuLogo()
|
||||
};
|
||||
|
||||
buttons.SetOsuLogo(logo);
|
||||
|
||||
foreach (var s in Enum.GetValues(typeof(ButtonSystemState)).OfType<ButtonSystemState>().Skip(1))
|
||||
AddStep($"State to {s}", () => buttons.State = s);
|
||||
}
|
||||
}
|
||||
}
|
98
osu.Game.Tests/Visual/UserInterface/TestCaseContextMenu.cs
Normal file
98
osu.Game.Tests/Visual/UserInterface/TestCaseContextMenu.cs
Normal file
@ -0,0 +1,98 @@
|
||||
// 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 NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Game.Graphics.Cursor;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestCaseContextMenu : OsuTestCase
|
||||
{
|
||||
private const int start_time = 0;
|
||||
private const int duration = 1000;
|
||||
|
||||
private readonly Container container;
|
||||
|
||||
public TestCaseContextMenu()
|
||||
{
|
||||
Add(new OsuContextMenuContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
container = new MyContextMenuContainer
|
||||
{
|
||||
Size = new Vector2(200),
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Child = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Green,
|
||||
}
|
||||
},
|
||||
new AnotherContextMenuContainer
|
||||
{
|
||||
Size = new Vector2(200),
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Child = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Red,
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
// Move box along a square trajectory
|
||||
container.Loop(c => c
|
||||
.MoveTo(new Vector2(0, 100), duration).Then()
|
||||
.MoveTo(new Vector2(100, 100), duration).Then()
|
||||
.MoveTo(new Vector2(100, 0), duration).Then()
|
||||
.MoveTo(Vector2.Zero, duration)
|
||||
);
|
||||
}
|
||||
|
||||
private class MyContextMenuContainer : Container, IHasContextMenu
|
||||
{
|
||||
public MenuItem[] ContextMenuItems => new MenuItem[]
|
||||
{
|
||||
new OsuMenuItem(@"Some option"),
|
||||
new OsuMenuItem(@"Highlighted option", MenuItemType.Highlighted),
|
||||
new OsuMenuItem(@"Another option"),
|
||||
new OsuMenuItem(@"Choose me please"),
|
||||
new OsuMenuItem(@"And me too"),
|
||||
new OsuMenuItem(@"Trying to fill"),
|
||||
new OsuMenuItem(@"Destructive option", MenuItemType.Destructive),
|
||||
};
|
||||
}
|
||||
|
||||
private class AnotherContextMenuContainer : Container, IHasContextMenu
|
||||
{
|
||||
public MenuItem[] ContextMenuItems => new MenuItem[]
|
||||
{
|
||||
new OsuMenuItem(@"Simple option"),
|
||||
new OsuMenuItem(@"Simple very very long option"),
|
||||
new OsuMenuItem(@"Change width", MenuItemType.Highlighted, () => this.ResizeWidthTo(Width * 2, 100, Easing.OutQuint)),
|
||||
new OsuMenuItem(@"Change height", MenuItemType.Highlighted, () => this.ResizeHeightTo(Height * 2, 100, Easing.OutQuint)),
|
||||
new OsuMenuItem(@"Change width back", MenuItemType.Destructive, () => this.ResizeWidthTo(Width / 2, 100, Easing.OutQuint)),
|
||||
new OsuMenuItem(@"Change height back", MenuItemType.Destructive, () => this.ResizeHeightTo(Height / 2, 100, Easing.OutQuint)),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
261
osu.Game.Tests/Visual/UserInterface/TestCaseCursors.cs
Normal file
261
osu.Game.Tests/Visual/UserInterface/TestCaseCursors.cs
Normal file
@ -0,0 +1,261 @@
|
||||
// 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 NUnit.Framework;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Game.Graphics.Cursor;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestCaseCursors : ManualInputManagerTestCase
|
||||
{
|
||||
private readonly MenuCursorContainer menuCursorContainer;
|
||||
private readonly CustomCursorBox[] cursorBoxes = new CustomCursorBox[6];
|
||||
|
||||
public TestCaseCursors()
|
||||
{
|
||||
Child = menuCursorContainer = new MenuCursorContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new[]
|
||||
{
|
||||
// Middle user
|
||||
cursorBoxes[0] = new CustomCursorBox(Color4.Green)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Size = new Vector2(0.5f),
|
||||
},
|
||||
// Top-left user
|
||||
cursorBoxes[1] = new CustomCursorBox(Color4.Blue)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Size = new Vector2(0.4f)
|
||||
},
|
||||
// Bottom-right user
|
||||
cursorBoxes[2] = new CustomCursorBox(Color4.Red)
|
||||
{
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.BottomRight,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Size = new Vector2(0.4f)
|
||||
},
|
||||
// Bottom-left local
|
||||
cursorBoxes[3] = new CustomCursorBox(Color4.Magenta, false)
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Size = new Vector2(0.4f)
|
||||
},
|
||||
// Top-right local
|
||||
cursorBoxes[4] = new CustomCursorBox(Color4.Cyan, false)
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Size = new Vector2(0.4f)
|
||||
},
|
||||
// Left-local
|
||||
cursorBoxes[5] = new CustomCursorBox(Color4.Yellow, false)
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Size = new Vector2(0.2f, 1),
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
AddToggleStep("Smooth transitions", b => cursorBoxes.ForEach(box => box.SmoothTransition = b));
|
||||
|
||||
testUserCursor();
|
||||
testLocalCursor();
|
||||
testUserCursorOverride();
|
||||
testMultipleLocalCursors();
|
||||
ReturnUserInput();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// -- Green Box --
|
||||
/// Tests whether hovering in and out of a drawable that provides the user cursor (green)
|
||||
/// results in the correct visibility state for that cursor.
|
||||
/// </summary>
|
||||
private void testUserCursor()
|
||||
{
|
||||
AddStep("Move to green area", () => InputManager.MoveMouseTo(cursorBoxes[0]));
|
||||
AddAssert("Check green cursor visible", () => checkVisible(cursorBoxes[0].Cursor));
|
||||
AddAssert("Check green cursor at mouse", () => checkAtMouse(cursorBoxes[0].Cursor));
|
||||
AddStep("Move out", moveOut);
|
||||
AddAssert("Check green cursor invisible", () => !checkVisible(cursorBoxes[0].Cursor));
|
||||
AddAssert("Check global cursor visible", () => checkVisible(menuCursorContainer.Cursor));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// -- Purple Box --
|
||||
/// Tests whether hovering in and out of a drawable that provides a local cursor (purple)
|
||||
/// results in the correct visibility and state for that cursor.
|
||||
/// </summary>
|
||||
private void testLocalCursor()
|
||||
{
|
||||
AddStep("Move to purple area", () => InputManager.MoveMouseTo(cursorBoxes[3]));
|
||||
AddAssert("Check purple cursor visible", () => checkVisible(cursorBoxes[3].Cursor));
|
||||
AddAssert("Check purple cursor at mouse", () => checkAtMouse(cursorBoxes[3].Cursor));
|
||||
AddAssert("Check global cursor visible", () => checkVisible(menuCursorContainer.Cursor));
|
||||
AddAssert("Check global cursor at mouse", () => checkAtMouse(menuCursorContainer.Cursor));
|
||||
AddStep("Move out", moveOut);
|
||||
AddAssert("Check purple cursor visible", () => checkVisible(cursorBoxes[3].Cursor));
|
||||
AddAssert("Check global cursor visible", () => checkVisible(menuCursorContainer.Cursor));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// -- Blue-Green Box Boundary --
|
||||
/// Tests whether overriding a user cursor (green) with another user cursor (blue)
|
||||
/// results in the correct visibility and states for the cursors.
|
||||
/// </summary>
|
||||
private void testUserCursorOverride()
|
||||
{
|
||||
AddStep("Move to blue-green boundary", () => InputManager.MoveMouseTo(cursorBoxes[1].ScreenSpaceDrawQuad.BottomRight - new Vector2(10)));
|
||||
AddAssert("Check blue cursor visible", () => checkVisible(cursorBoxes[1].Cursor));
|
||||
AddAssert("Check green cursor invisible", () => !checkVisible(cursorBoxes[0].Cursor));
|
||||
AddAssert("Check blue cursor at mouse", () => checkAtMouse(cursorBoxes[1].Cursor));
|
||||
AddStep("Move out", moveOut);
|
||||
AddAssert("Check blue cursor not visible", () => !checkVisible(cursorBoxes[1].Cursor));
|
||||
AddAssert("Check green cursor not visible", () => !checkVisible(cursorBoxes[0].Cursor));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// -- Yellow-Purple Box Boundary --
|
||||
/// Tests whether multiple local cursors (purple + yellow) may be visible and at the mouse position at the same time.
|
||||
/// </summary>
|
||||
private void testMultipleLocalCursors()
|
||||
{
|
||||
AddStep("Move to yellow-purple boundary", () => InputManager.MoveMouseTo(cursorBoxes[5].ScreenSpaceDrawQuad.BottomRight - new Vector2(10)));
|
||||
AddAssert("Check purple cursor visible", () => checkVisible(cursorBoxes[3].Cursor));
|
||||
AddAssert("Check purple cursor at mouse", () => checkAtMouse(cursorBoxes[3].Cursor));
|
||||
AddAssert("Check yellow cursor visible", () => checkVisible(cursorBoxes[5].Cursor));
|
||||
AddAssert("Check yellow cursor at mouse", () => checkAtMouse(cursorBoxes[5].Cursor));
|
||||
AddStep("Move out", moveOut);
|
||||
AddAssert("Check purple cursor visible", () => checkVisible(cursorBoxes[3].Cursor));
|
||||
AddAssert("Check yellow cursor visible", () => checkVisible(cursorBoxes[5].Cursor));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// -- Yellow-Blue Box Boundary --
|
||||
/// Tests whether a local cursor (yellow) may be displayed along with a user cursor override (blue).
|
||||
/// </summary>
|
||||
private void testUserOverrideWithLocal()
|
||||
{
|
||||
AddStep("Move to yellow-blue boundary", () => InputManager.MoveMouseTo(cursorBoxes[5].ScreenSpaceDrawQuad.TopRight - new Vector2(10)));
|
||||
AddAssert("Check blue cursor visible", () => checkVisible(cursorBoxes[1].Cursor));
|
||||
AddAssert("Check blue cursor at mouse", () => checkAtMouse(cursorBoxes[1].Cursor));
|
||||
AddAssert("Check yellow cursor visible", () => checkVisible(cursorBoxes[5].Cursor));
|
||||
AddAssert("Check yellow cursor at mouse", () => checkAtMouse(cursorBoxes[5].Cursor));
|
||||
AddStep("Move out", moveOut);
|
||||
AddAssert("Check blue cursor invisible", () => !checkVisible(cursorBoxes[1].Cursor));
|
||||
AddAssert("Check yellow cursor visible", () => checkVisible(cursorBoxes[5].Cursor));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Moves the cursor to a point not covered by any cursor containers.
|
||||
/// </summary>
|
||||
private void moveOut()
|
||||
=> InputManager.MoveMouseTo(new Vector2(InputManager.ScreenSpaceDrawQuad.Centre.X, InputManager.ScreenSpaceDrawQuad.TopLeft.Y));
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a cursor is visible.
|
||||
/// </summary>
|
||||
/// <param name="cursorContainer">The cursor to check.</param>
|
||||
private bool checkVisible(CursorContainer cursorContainer) => cursorContainer.State == Visibility.Visible;
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a cursor is at the current inputmanager screen position.
|
||||
/// </summary>
|
||||
/// <param name="cursorContainer">The cursor to check.</param>
|
||||
private bool checkAtMouse(CursorContainer cursorContainer)
|
||||
=> Precision.AlmostEquals(InputManager.CurrentState.Mouse.Position, cursorContainer.ToScreenSpace(cursorContainer.ActiveCursor.DrawPosition));
|
||||
|
||||
private class CustomCursorBox : Container, IProvideCursor
|
||||
{
|
||||
public bool SmoothTransition;
|
||||
|
||||
public CursorContainer Cursor { get; }
|
||||
public bool ProvidingUserCursor { get; }
|
||||
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => base.ReceivePositionalInputAt(screenSpacePos) || SmoothTransition && !ProvidingUserCursor;
|
||||
|
||||
private readonly Box background;
|
||||
|
||||
public CustomCursorBox(Color4 cursorColour, bool providesUserCursor = true)
|
||||
{
|
||||
ProvidingUserCursor = providesUserCursor;
|
||||
|
||||
Colour = cursorColour;
|
||||
Masking = true;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
background = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Alpha = 0.1f
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Text = providesUserCursor ? "User cursor" : "Local cursor"
|
||||
},
|
||||
Cursor = new TestCursorContainer
|
||||
{
|
||||
State = providesUserCursor ? Visibility.Hidden : Visibility.Visible,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
background.FadeTo(0.4f, 250, Easing.OutQuint);
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(HoverLostEvent e)
|
||||
{
|
||||
background.FadeTo(0.1f, 250);
|
||||
base.OnHoverLost(e);
|
||||
}
|
||||
}
|
||||
|
||||
private class TestCursorContainer : CursorContainer
|
||||
{
|
||||
protected override Drawable CreateCursor() => new TestCursor();
|
||||
|
||||
private class TestCursor : CircularContainer
|
||||
{
|
||||
public TestCursor()
|
||||
{
|
||||
Origin = Anchor.Centre;
|
||||
|
||||
Size = new Vector2(50);
|
||||
Masking = true;
|
||||
|
||||
Blending = BlendingMode.Additive;
|
||||
Alpha = 0.5f;
|
||||
|
||||
Child = new Box { RelativeSizeAxes = Axes.Both };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
75
osu.Game.Tests/Visual/UserInterface/TestCaseDialogOverlay.cs
Normal file
75
osu.Game.Tests/Visual/UserInterface/TestCaseDialogOverlay.cs
Normal file
@ -0,0 +1,75 @@
|
||||
// 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 NUnit.Framework;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Dialog;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestCaseDialogOverlay : OsuTestCase
|
||||
{
|
||||
public TestCaseDialogOverlay()
|
||||
{
|
||||
DialogOverlay overlay;
|
||||
|
||||
Add(overlay = new DialogOverlay());
|
||||
|
||||
AddStep("dialog #1", () => overlay.Push(new PopupDialog
|
||||
{
|
||||
Icon = FontAwesome.fa_trash_o,
|
||||
HeaderText = @"Confirm deletion of",
|
||||
BodyText = @"Ayase Rie - Yuima-ru*World TVver.",
|
||||
Buttons = new PopupDialogButton[]
|
||||
{
|
||||
new PopupDialogOkButton
|
||||
{
|
||||
Text = @"I never want to see this again.",
|
||||
Action = () => System.Console.WriteLine(@"OK"),
|
||||
},
|
||||
new PopupDialogCancelButton
|
||||
{
|
||||
Text = @"Firetruck, I still want quick ranks!",
|
||||
Action = () => System.Console.WriteLine(@"Cancel"),
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
||||
AddStep("dialog #2", () => overlay.Push(new PopupDialog
|
||||
{
|
||||
Icon = FontAwesome.fa_gear,
|
||||
HeaderText = @"What do you want to do with",
|
||||
BodyText = "Camellia as \"Bang Riot\" - Blastix Riotz",
|
||||
Buttons = new PopupDialogButton[]
|
||||
{
|
||||
new PopupDialogOkButton
|
||||
{
|
||||
Text = @"Manage collections",
|
||||
},
|
||||
new PopupDialogOkButton
|
||||
{
|
||||
Text = @"Delete...",
|
||||
},
|
||||
new PopupDialogOkButton
|
||||
{
|
||||
Text = @"Remove from unplayed",
|
||||
},
|
||||
new PopupDialogOkButton
|
||||
{
|
||||
Text = @"Clear local scores",
|
||||
},
|
||||
new PopupDialogOkButton
|
||||
{
|
||||
Text = @"Edit",
|
||||
},
|
||||
new PopupDialogCancelButton
|
||||
{
|
||||
Text = @"Cancel",
|
||||
},
|
||||
},
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
67
osu.Game.Tests/Visual/UserInterface/TestCaseDrawableDate.cs
Normal file
67
osu.Game.Tests/Visual/UserInterface/TestCaseDrawableDate.cs
Normal file
@ -0,0 +1,67 @@
|
||||
// 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;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
public class TestCaseDrawableDate : OsuTestCase
|
||||
{
|
||||
public TestCaseDrawableDate()
|
||||
{
|
||||
Child = new FillFlowContainer
|
||||
{
|
||||
Direction = FillDirection.Vertical,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new PokeyDrawableDate(DateTimeOffset.Now.Subtract(TimeSpan.FromSeconds(60))),
|
||||
new PokeyDrawableDate(DateTimeOffset.Now.Subtract(TimeSpan.FromSeconds(55))),
|
||||
new PokeyDrawableDate(DateTimeOffset.Now.Subtract(TimeSpan.FromSeconds(50))),
|
||||
new PokeyDrawableDate(DateTimeOffset.Now),
|
||||
new PokeyDrawableDate(DateTimeOffset.Now.Add(TimeSpan.FromSeconds(60))),
|
||||
new PokeyDrawableDate(DateTimeOffset.Now.Add(TimeSpan.FromSeconds(65))),
|
||||
new PokeyDrawableDate(DateTimeOffset.Now.Add(TimeSpan.FromSeconds(70))),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private class PokeyDrawableDate : CompositeDrawable
|
||||
{
|
||||
public PokeyDrawableDate(DateTimeOffset date)
|
||||
{
|
||||
const float box_size = 10;
|
||||
|
||||
DrawableDate drawableDate;
|
||||
Box flash;
|
||||
|
||||
AutoSizeAxes = Axes.Both;
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
flash = new Box
|
||||
{
|
||||
Colour = Color4.Yellow,
|
||||
Size = new Vector2(box_size),
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Alpha = 0
|
||||
},
|
||||
drawableDate = new DrawableDate(date)
|
||||
{
|
||||
X = box_size + 2,
|
||||
}
|
||||
};
|
||||
|
||||
drawableDate.Current.ValueChanged += _ => flash.FadeOutFromOne(500);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
// 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;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Screens.Menu;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
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!",
|
||||
Font = OsuFont.GetFont(size: 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("wait until confirmed", () => fired);
|
||||
}
|
||||
|
||||
private class TestHoldToConfirmOverlay : ExitConfirmOverlay
|
||||
{
|
||||
protected override bool AllowMultipleFires => true;
|
||||
|
||||
public void Begin() => BeginConfirm();
|
||||
public void Abort() => AbortConfirm();
|
||||
}
|
||||
}
|
||||
}
|
118
osu.Game.Tests/Visual/UserInterface/TestCaseIconButton.cs
Normal file
118
osu.Game.Tests/Visual/UserInterface/TestCaseIconButton.cs
Normal file
@ -0,0 +1,118 @@
|
||||
// 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 NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestCaseIconButton : OsuTestCase
|
||||
{
|
||||
public TestCaseIconButton()
|
||||
{
|
||||
Child = new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Spacing = new Vector2(10, 10),
|
||||
Children = new[]
|
||||
{
|
||||
new NamedIconButton("No change", new IconButton()),
|
||||
new NamedIconButton("Background colours", new ColouredIconButton()),
|
||||
new NamedIconButton("Full-width", new IconButton { ButtonSize = new Vector2(200, 30) }),
|
||||
new NamedIconButton("Unchanging size", new IconButton(), false),
|
||||
new NamedIconButton("Icon colours", new IconButton
|
||||
{
|
||||
IconColour = Color4.Green,
|
||||
IconHoverColour = Color4.Red
|
||||
})
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private class ColouredIconButton : IconButton
|
||||
{
|
||||
public ColouredIconButton()
|
||||
{
|
||||
FlashColour = Color4.DarkGreen;
|
||||
HoverColour = Color4.Green;
|
||||
}
|
||||
}
|
||||
|
||||
private class NamedIconButton : Container
|
||||
{
|
||||
public NamedIconButton(string name, IconButton button, bool allowSizeChange = true)
|
||||
{
|
||||
AutoSizeAxes = Axes.Y;
|
||||
Width = 200;
|
||||
|
||||
Container iconContainer;
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black,
|
||||
Alpha = 0.5f,
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(0, 10),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Text = name
|
||||
},
|
||||
new Container
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Alpha = 0.1f,
|
||||
},
|
||||
iconContainer = new Container
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Child = button
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (allowSizeChange)
|
||||
iconContainer.AutoSizeAxes = Axes.Both;
|
||||
else
|
||||
{
|
||||
iconContainer.RelativeSizeAxes = Axes.X;
|
||||
iconContainer.Height = 30;
|
||||
}
|
||||
|
||||
button.Anchor = Anchor.Centre;
|
||||
button.Origin = Anchor.Centre;
|
||||
button.Icon = FontAwesome.fa_osu_osu_o;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
// 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;
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Screens.Edit.Setup.Components.LabelledComponents;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestCaseLabelledTextBox : OsuTestCase
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(LabelledTextBox),
|
||||
};
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Child = new Container
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Padding = new MarginPadding { Left = 150, Right = 150 },
|
||||
Child = new LabelledTextBox
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
LabelText = "Testing text",
|
||||
PlaceholderText = "This is definitely working as intended",
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
// 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.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
public class TestCaseLoadingAnimation : GridTestCase
|
||||
{
|
||||
public TestCaseLoadingAnimation()
|
||||
: base(2, 2)
|
||||
{
|
||||
LoadingAnimation loading;
|
||||
|
||||
Cell(0).AddRange(new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = Color4.Black,
|
||||
RelativeSizeAxes = Axes.Both
|
||||
},
|
||||
loading = new LoadingAnimation()
|
||||
});
|
||||
|
||||
loading.Show();
|
||||
|
||||
Cell(1).AddRange(new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = Color4.White,
|
||||
RelativeSizeAxes = Axes.Both
|
||||
},
|
||||
loading = new LoadingAnimation()
|
||||
});
|
||||
|
||||
loading.Show();
|
||||
|
||||
Cell(2).AddRange(new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = Color4.Gray,
|
||||
RelativeSizeAxes = Axes.Both
|
||||
},
|
||||
loading = new LoadingAnimation()
|
||||
});
|
||||
|
||||
loading.Show();
|
||||
|
||||
Cell(3).AddRange(new Drawable[]
|
||||
{
|
||||
loading = new LoadingAnimation()
|
||||
});
|
||||
|
||||
Scheduler.AddDelayed(() => loading.ToggleVisibility(), 200, true);
|
||||
}
|
||||
}
|
||||
}
|
272
osu.Game.Tests/Visual/UserInterface/TestCaseMods.cs
Normal file
272
osu.Game.Tests/Visual/UserInterface/TestCaseMods.cs
Normal file
@ -0,0 +1,272 @@
|
||||
// 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;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Overlays.Mods;
|
||||
using osu.Game.Overlays.Mods.Sections;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mania.Mods;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Screens.Play.HUD;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
[Description("mod select and icon display")]
|
||||
public class TestCaseMods : OsuTestCase
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(ModSelectOverlay),
|
||||
typeof(ModDisplay),
|
||||
typeof(ModSection),
|
||||
typeof(ModIcon),
|
||||
typeof(ModButton),
|
||||
typeof(ModButtonEmpty),
|
||||
typeof(DifficultyReductionSection),
|
||||
typeof(DifficultyIncreaseSection),
|
||||
typeof(AutomationSection),
|
||||
typeof(ConversionSection),
|
||||
typeof(FunSection),
|
||||
};
|
||||
|
||||
private RulesetStore rulesets;
|
||||
private ModDisplay modDisplay;
|
||||
private TestModSelectOverlay modSelect;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(RulesetStore rulesets)
|
||||
{
|
||||
this.rulesets = rulesets;
|
||||
|
||||
Add(modSelect = new TestModSelectOverlay
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Origin = Anchor.BottomCentre,
|
||||
Anchor = Anchor.BottomCentre,
|
||||
});
|
||||
|
||||
Add(modDisplay = new ModDisplay
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Position = new Vector2(0, 25),
|
||||
});
|
||||
|
||||
modDisplay.Current.UnbindBindings();
|
||||
modDisplay.Current.BindTo(modSelect.SelectedMods);
|
||||
|
||||
AddStep("Show", modSelect.Show);
|
||||
AddStep("Toggle", modSelect.ToggleVisibility);
|
||||
AddStep("Toggle", modSelect.ToggleVisibility);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestOsuMods()
|
||||
{
|
||||
var ruleset = rulesets.AvailableRulesets.First(r => r.ID == 0);
|
||||
AddStep("change ruleset", () => { Ruleset.Value = ruleset; });
|
||||
|
||||
var instance = ruleset.CreateInstance();
|
||||
|
||||
var easierMods = instance.GetModsFor(ModType.DifficultyReduction);
|
||||
var harderMods = instance.GetModsFor(ModType.DifficultyIncrease);
|
||||
var assistMods = instance.GetModsFor(ModType.Automation);
|
||||
|
||||
var noFailMod = easierMods.FirstOrDefault(m => m is OsuModNoFail);
|
||||
var hiddenMod = harderMods.FirstOrDefault(m => m is OsuModHidden);
|
||||
|
||||
var doubleTimeMod = harderMods.OfType<MultiMod>().FirstOrDefault(m => m.Mods.Any(a => a is OsuModDoubleTime));
|
||||
|
||||
var autoPilotMod = assistMods.FirstOrDefault(m => m is OsuModAutopilot);
|
||||
|
||||
var easy = easierMods.FirstOrDefault(m => m is OsuModEasy);
|
||||
var hardRock = harderMods.FirstOrDefault(m => m is OsuModHardRock);
|
||||
|
||||
testSingleMod(noFailMod);
|
||||
testMultiMod(doubleTimeMod);
|
||||
testIncompatibleMods(easy, hardRock);
|
||||
testDeselectAll(easierMods.Where(m => !(m is MultiMod)));
|
||||
testMultiplierTextColour(noFailMod, modSelect.LowMultiplierColour);
|
||||
testMultiplierTextColour(hiddenMod, modSelect.HighMultiplierColour);
|
||||
|
||||
testUnimplementedMod(autoPilotMod);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestManiaMods()
|
||||
{
|
||||
var ruleset = rulesets.AvailableRulesets.First(r => r.ID == 3);
|
||||
AddStep("change ruleset", () => { Ruleset.Value = ruleset; });
|
||||
|
||||
testRankedText(ruleset.CreateInstance().GetModsFor(ModType.Conversion).First(m => m is ManiaModRandom));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRulesetChanges()
|
||||
{
|
||||
var rulesetOsu = rulesets.AvailableRulesets.First(r => r.ID == 0);
|
||||
var rulesetMania = rulesets.AvailableRulesets.First(r => r.ID == 3);
|
||||
|
||||
AddStep("change ruleset to null", () => { Ruleset.Value = null; });
|
||||
|
||||
var instance = rulesetOsu.CreateInstance();
|
||||
var easierMods = instance.GetModsFor(ModType.DifficultyReduction);
|
||||
var noFailMod = easierMods.FirstOrDefault(m => m is OsuModNoFail);
|
||||
|
||||
AddStep("set mods externally", () => { modDisplay.Current.Value = new[] { noFailMod }; });
|
||||
|
||||
AddStep("change ruleset to osu", () => { Ruleset.Value = rulesetOsu; });
|
||||
|
||||
AddAssert("ensure mods still selected", () => modDisplay.Current.Value.Single(m => m is OsuModNoFail) != null);
|
||||
|
||||
AddStep("change ruleset to mania", () => { Ruleset.Value = rulesetMania; });
|
||||
|
||||
AddAssert("ensure mods not selected", () => !modDisplay.Current.Value.Any(m => m is OsuModNoFail));
|
||||
|
||||
AddStep("change ruleset to osu", () => { Ruleset.Value = rulesetOsu; });
|
||||
|
||||
AddAssert("ensure mods not selected", () => !modDisplay.Current.Value.Any());
|
||||
}
|
||||
|
||||
private void testSingleMod(Mod mod)
|
||||
{
|
||||
selectNext(mod);
|
||||
checkSelected(mod);
|
||||
|
||||
selectPrevious(mod);
|
||||
checkNotSelected(mod);
|
||||
|
||||
selectNext(mod);
|
||||
selectNext(mod);
|
||||
checkNotSelected(mod);
|
||||
|
||||
selectPrevious(mod);
|
||||
selectPrevious(mod);
|
||||
checkNotSelected(mod);
|
||||
}
|
||||
|
||||
private void testMultiMod(MultiMod multiMod)
|
||||
{
|
||||
foreach (var mod in multiMod.Mods)
|
||||
{
|
||||
selectNext(mod);
|
||||
checkSelected(mod);
|
||||
}
|
||||
|
||||
for (int index = multiMod.Mods.Length - 1; index >= 0; index--)
|
||||
selectPrevious(multiMod.Mods[index]);
|
||||
|
||||
foreach (var mod in multiMod.Mods)
|
||||
checkNotSelected(mod);
|
||||
}
|
||||
|
||||
private void testUnimplementedMod(Mod mod)
|
||||
{
|
||||
selectNext(mod);
|
||||
checkNotSelected(mod);
|
||||
}
|
||||
|
||||
private void testIncompatibleMods(Mod modA, Mod modB)
|
||||
{
|
||||
selectNext(modA);
|
||||
checkSelected(modA);
|
||||
checkNotSelected(modB);
|
||||
|
||||
selectNext(modB);
|
||||
checkSelected(modB);
|
||||
checkNotSelected(modA);
|
||||
|
||||
selectPrevious(modB);
|
||||
checkNotSelected(modA);
|
||||
checkNotSelected(modB);
|
||||
}
|
||||
|
||||
private void testDeselectAll(IEnumerable<Mod> mods)
|
||||
{
|
||||
foreach (var mod in mods)
|
||||
selectNext(mod);
|
||||
|
||||
AddAssert("check for any selection", () => modSelect.SelectedMods.Value.Any());
|
||||
AddStep("deselect all", modSelect.DeselectAllButton.Action.Invoke);
|
||||
AddAssert("check for no selection", () => !modSelect.SelectedMods.Value.Any());
|
||||
}
|
||||
|
||||
private void testMultiplierTextColour(Mod mod, Color4 colour)
|
||||
{
|
||||
checkLabelColor(Color4.White);
|
||||
selectNext(mod);
|
||||
AddWaitStep("wait for changing colour", 1);
|
||||
checkLabelColor(colour);
|
||||
selectPrevious(mod);
|
||||
AddWaitStep("wait for changing colour", 1);
|
||||
checkLabelColor(Color4.White);
|
||||
}
|
||||
|
||||
private void testRankedText(Mod mod)
|
||||
{
|
||||
AddWaitStep("wait for fade", 1);
|
||||
AddAssert("check for ranked", () => modSelect.UnrankedLabel.Alpha == 0);
|
||||
selectNext(mod);
|
||||
AddWaitStep("wait for fade", 1);
|
||||
AddAssert("check for unranked", () => modSelect.UnrankedLabel.Alpha != 0);
|
||||
selectPrevious(mod);
|
||||
AddWaitStep("wait for fade", 1);
|
||||
AddAssert("check for ranked", () => modSelect.UnrankedLabel.Alpha == 0);
|
||||
}
|
||||
|
||||
private void selectNext(Mod mod) => AddStep($"left click {mod.Name}", () => modSelect.GetModButton(mod)?.SelectNext(1));
|
||||
|
||||
private void selectPrevious(Mod mod) => AddStep($"right click {mod.Name}", () => modSelect.GetModButton(mod)?.SelectNext(-1));
|
||||
|
||||
private void checkSelected(Mod mod)
|
||||
{
|
||||
AddAssert($"check {mod.Name} is selected", () =>
|
||||
{
|
||||
var button = modSelect.GetModButton(mod);
|
||||
return modSelect.SelectedMods.Value.Single(m => m.Name == mod.Name) != null && button.SelectedMod.GetType() == mod.GetType() && button.Selected;
|
||||
});
|
||||
}
|
||||
|
||||
private void checkNotSelected(Mod mod)
|
||||
{
|
||||
AddAssert($"check {mod.Name} is not selected", () =>
|
||||
{
|
||||
var button = modSelect.GetModButton(mod);
|
||||
return modSelect.SelectedMods.Value.All(m => m.GetType() != mod.GetType()) && button.SelectedMod?.GetType() != mod.GetType();
|
||||
});
|
||||
}
|
||||
|
||||
private void checkLabelColor(Color4 color) => AddAssert("check label has expected colour", () => modSelect.MultiplierLabel.Colour.AverageColour == color);
|
||||
|
||||
private class TestModSelectOverlay : ModSelectOverlay
|
||||
{
|
||||
public new Bindable<IEnumerable<Mod>> SelectedMods => base.SelectedMods;
|
||||
|
||||
public ModButton GetModButton(Mod mod)
|
||||
{
|
||||
var section = ModSectionsContainer.Children.Single(s => s.ModType == mod.Type);
|
||||
return section.ButtonsContainer.OfType<ModButton>().Single(b => b.Mods.Any(m => m.GetType() == mod.GetType()));
|
||||
}
|
||||
|
||||
public new OsuSpriteText MultiplierLabel => base.MultiplierLabel;
|
||||
public new OsuSpriteText UnrankedLabel => base.UnrankedLabel;
|
||||
public new TriangleButton DeselectAllButton => base.DeselectAllButton;
|
||||
|
||||
public new Color4 LowMultiplierColour => base.LowMultiplierColour;
|
||||
public new Color4 HighMultiplierColour => base.HighMultiplierColour;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
// 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 NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Overlays;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestCaseMusicController : OsuTestCase
|
||||
{
|
||||
public TestCaseMusicController()
|
||||
{
|
||||
Clock = new FramedClock();
|
||||
|
||||
var mc = new MusicController
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre
|
||||
};
|
||||
Add(mc);
|
||||
|
||||
AddToggleStep(@"toggle visibility", state => mc.State = state ? Visibility.Visible : Visibility.Hidden);
|
||||
AddStep(@"show", () => mc.State = Visibility.Visible);
|
||||
AddToggleStep(@"toggle beatmap lock", state => Beatmap.Disabled = state);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,164 @@
|
||||
// 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;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Notifications;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestCaseNotificationOverlay : OsuTestCase
|
||||
{
|
||||
private readonly NotificationOverlay manager;
|
||||
private readonly List<ProgressNotification> progressingNotifications = new List<ProgressNotification>();
|
||||
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(NotificationSection),
|
||||
typeof(SimpleNotification),
|
||||
typeof(ProgressNotification),
|
||||
typeof(ProgressCompletionNotification),
|
||||
typeof(IHasCompletionTarget),
|
||||
typeof(Notification)
|
||||
};
|
||||
|
||||
public TestCaseNotificationOverlay()
|
||||
{
|
||||
progressingNotifications.Clear();
|
||||
|
||||
Content.Add(manager = new NotificationOverlay
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight
|
||||
});
|
||||
|
||||
SpriteText displayedCount = new SpriteText();
|
||||
|
||||
Content.Add(displayedCount);
|
||||
|
||||
void setState(Visibility state) => AddStep(state.ToString(), () => manager.State = state);
|
||||
void checkProgressingCount(int expected) => AddAssert($"progressing count is {expected}", () => progressingNotifications.Count == expected);
|
||||
|
||||
manager.UnreadCount.ValueChanged += count => { displayedCount.Text = $"displayed count: {count.NewValue}"; };
|
||||
|
||||
setState(Visibility.Visible);
|
||||
AddStep(@"simple #1", sendHelloNotification);
|
||||
AddStep(@"simple #2", sendAmazingNotification);
|
||||
AddStep(@"progress #1", sendUploadProgress);
|
||||
AddStep(@"progress #2", sendDownloadProgress);
|
||||
|
||||
checkProgressingCount(2);
|
||||
|
||||
setState(Visibility.Hidden);
|
||||
|
||||
AddRepeatStep(@"add many simple", sendManyNotifications, 3);
|
||||
AddWaitStep("wait some", 5);
|
||||
|
||||
checkProgressingCount(0);
|
||||
|
||||
AddStep(@"progress #3", sendUploadProgress);
|
||||
|
||||
checkProgressingCount(1);
|
||||
|
||||
AddAssert("Displayed count is 33", () => manager.UnreadCount.Value == 33);
|
||||
|
||||
AddWaitStep("wait some", 10);
|
||||
|
||||
checkProgressingCount(0);
|
||||
|
||||
setState(Visibility.Visible);
|
||||
|
||||
//AddStep(@"barrage", () => sendBarrage());
|
||||
}
|
||||
|
||||
private void sendBarrage(int remaining = 10)
|
||||
{
|
||||
switch (RNG.Next(0, 4))
|
||||
{
|
||||
case 0:
|
||||
sendHelloNotification();
|
||||
break;
|
||||
case 1:
|
||||
sendAmazingNotification();
|
||||
break;
|
||||
case 2:
|
||||
sendUploadProgress();
|
||||
break;
|
||||
case 3:
|
||||
sendDownloadProgress();
|
||||
break;
|
||||
}
|
||||
|
||||
if (remaining > 0)
|
||||
Scheduler.AddDelayed(() => sendBarrage(remaining - 1), 80);
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
progressingNotifications.RemoveAll(n => n.State == ProgressNotificationState.Completed);
|
||||
|
||||
if (progressingNotifications.Count(n => n.State == ProgressNotificationState.Active) < 3)
|
||||
{
|
||||
var p = progressingNotifications.Find(n => n.State == ProgressNotificationState.Queued);
|
||||
if (p != null)
|
||||
p.State = ProgressNotificationState.Active;
|
||||
}
|
||||
|
||||
foreach (var n in progressingNotifications.FindAll(n => n.State == ProgressNotificationState.Active))
|
||||
{
|
||||
if (n.Progress < 1)
|
||||
n.Progress += (float)(Time.Elapsed / 400) * RNG.NextSingle();
|
||||
else
|
||||
n.State = ProgressNotificationState.Completed;
|
||||
}
|
||||
}
|
||||
|
||||
private void sendDownloadProgress()
|
||||
{
|
||||
var n = new ProgressNotification
|
||||
{
|
||||
Text = @"Downloading Haitai...",
|
||||
CompletionText = "Downloaded Haitai!",
|
||||
};
|
||||
manager.Post(n);
|
||||
progressingNotifications.Add(n);
|
||||
}
|
||||
|
||||
private void sendUploadProgress()
|
||||
{
|
||||
var n = new ProgressNotification
|
||||
{
|
||||
Text = @"Uploading to BSS...",
|
||||
CompletionText = "Uploaded to BSS!",
|
||||
};
|
||||
manager.Post(n);
|
||||
progressingNotifications.Add(n);
|
||||
}
|
||||
|
||||
private void sendAmazingNotification()
|
||||
{
|
||||
manager.Post(new SimpleNotification { Text = @"You are amazing" });
|
||||
}
|
||||
|
||||
private void sendHelloNotification()
|
||||
{
|
||||
manager.Post(new SimpleNotification { Text = @"Welcome to osu!. Enjoy your stay!" });
|
||||
}
|
||||
|
||||
private void sendManyNotifications()
|
||||
{
|
||||
for (int i = 0; i < 10; i++)
|
||||
manager.Post(new SimpleNotification { Text = @"Spam incoming!!" });
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
// 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 NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Configuration.Tracking;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Overlays;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestCaseOnScreenDisplay : OsuTestCase
|
||||
{
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
var config = new TestConfigManager();
|
||||
|
||||
var osd = new TestOnScreenDisplay();
|
||||
osd.BeginTracking(this, config);
|
||||
Add(osd);
|
||||
|
||||
AddRepeatStep("Change toggle (no bind)", () => config.ToggleSetting(TestConfigSetting.ToggleSettingNoKeybind), 2);
|
||||
AddRepeatStep("Change toggle (with bind)", () => config.ToggleSetting(TestConfigSetting.ToggleSettingWithKeybind), 2);
|
||||
AddRepeatStep("Change enum (no bind)", () => config.IncrementEnumSetting(TestConfigSetting.EnumSettingNoKeybind), 3);
|
||||
AddRepeatStep("Change enum (with bind)", () => config.IncrementEnumSetting(TestConfigSetting.EnumSettingWithKeybind), 3);
|
||||
}
|
||||
|
||||
private class TestConfigManager : ConfigManager<TestConfigSetting>
|
||||
{
|
||||
public TestConfigManager()
|
||||
{
|
||||
InitialiseDefaults();
|
||||
}
|
||||
|
||||
protected override void InitialiseDefaults()
|
||||
{
|
||||
Set(TestConfigSetting.ToggleSettingNoKeybind, false);
|
||||
Set(TestConfigSetting.EnumSettingNoKeybind, EnumSetting.Setting1);
|
||||
Set(TestConfigSetting.ToggleSettingWithKeybind, false);
|
||||
Set(TestConfigSetting.EnumSettingWithKeybind, EnumSetting.Setting1);
|
||||
|
||||
base.InitialiseDefaults();
|
||||
}
|
||||
|
||||
public void ToggleSetting(TestConfigSetting setting) => Set(setting, !Get<bool>(setting));
|
||||
|
||||
public void IncrementEnumSetting(TestConfigSetting setting)
|
||||
{
|
||||
var nextValue = Get<EnumSetting>(setting) + 1;
|
||||
if (nextValue > EnumSetting.Setting4)
|
||||
nextValue = EnumSetting.Setting1;
|
||||
Set(setting, nextValue);
|
||||
}
|
||||
|
||||
public override TrackedSettings CreateTrackedSettings() => new TrackedSettings
|
||||
{
|
||||
new TrackedSetting<bool>(TestConfigSetting.ToggleSettingNoKeybind, b => new SettingDescription(b, "toggle setting with no keybind", b ? "enabled" : "disabled")),
|
||||
new TrackedSetting<EnumSetting>(TestConfigSetting.EnumSettingNoKeybind, v => new SettingDescription(v, "enum setting with no keybind", v.ToString())),
|
||||
new TrackedSetting<bool>(TestConfigSetting.ToggleSettingWithKeybind, b => new SettingDescription(b, "toggle setting with keybind", b ? "enabled" : "disabled", "fake keybind")),
|
||||
new TrackedSetting<EnumSetting>(TestConfigSetting.EnumSettingWithKeybind, v => new SettingDescription(v, "enum setting with keybind", v.ToString(), "fake keybind")),
|
||||
};
|
||||
|
||||
protected override void PerformLoad()
|
||||
{
|
||||
}
|
||||
|
||||
protected override bool PerformSave() => false;
|
||||
}
|
||||
|
||||
private enum TestConfigSetting
|
||||
{
|
||||
ToggleSettingNoKeybind,
|
||||
EnumSettingNoKeybind,
|
||||
ToggleSettingWithKeybind,
|
||||
EnumSettingWithKeybind
|
||||
}
|
||||
|
||||
private enum EnumSetting
|
||||
{
|
||||
Setting1,
|
||||
Setting2,
|
||||
Setting3,
|
||||
Setting4
|
||||
}
|
||||
|
||||
private class TestOnScreenDisplay : OnScreenDisplay
|
||||
{
|
||||
protected override void DisplayTemporarily(Drawable toDisplay) => toDisplay.FadeIn().ResizeHeightTo(110);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
// 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.Graphics;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Screens.Backgrounds;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
public class TestCaseParallaxContainer : OsuTestCase
|
||||
{
|
||||
public TestCaseParallaxContainer()
|
||||
{
|
||||
ParallaxContainer parallax;
|
||||
|
||||
Add(parallax = new ParallaxContainer
|
||||
{
|
||||
Child = new ScreenStack(new BackgroundScreenDefault { Alpha = 0.8f })
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
}
|
||||
});
|
||||
|
||||
AddStep("default parallax", () => parallax.ParallaxAmount = ParallaxContainer.DEFAULT_PARALLAX_AMOUNT);
|
||||
AddStep("high parallax", () => parallax.ParallaxAmount = ParallaxContainer.DEFAULT_PARALLAX_AMOUNT * 10);
|
||||
AddStep("no parallax", () => parallax.ParallaxAmount = 0);
|
||||
AddStep("negative parallax", () => parallax.ParallaxAmount = -ParallaxContainer.DEFAULT_PARALLAX_AMOUNT);
|
||||
}
|
||||
}
|
||||
}
|
39
osu.Game.Tests/Visual/UserInterface/TestCasePopupDialog.cs
Normal file
39
osu.Game.Tests/Visual/UserInterface/TestCasePopupDialog.cs
Normal file
@ -0,0 +1,39 @@
|
||||
// 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 NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Overlays.Dialog;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestCasePopupDialog : OsuTestCase
|
||||
{
|
||||
public TestCasePopupDialog()
|
||||
{
|
||||
var popup = new PopupDialog
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
State = Framework.Graphics.Containers.Visibility.Visible,
|
||||
Icon = FontAwesome.fa_assistive_listening_systems,
|
||||
HeaderText = @"This is a test popup",
|
||||
BodyText = "I can say lots of stuff and even wrap my words!",
|
||||
Buttons = new PopupDialogButton[]
|
||||
{
|
||||
new PopupDialogCancelButton
|
||||
{
|
||||
Text = @"Yes. That you can.",
|
||||
},
|
||||
new PopupDialogOkButton
|
||||
{
|
||||
Text = @"You're a fake!",
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
Add(popup);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,136 @@
|
||||
// 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.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Screens;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestCaseScreenBreadcrumbControl : OsuTestCase
|
||||
{
|
||||
private readonly ScreenBreadcrumbControl breadcrumbs;
|
||||
private readonly OsuScreenStack screenStack;
|
||||
|
||||
public TestCaseScreenBreadcrumbControl()
|
||||
{
|
||||
OsuSpriteText titleText;
|
||||
|
||||
IScreen startScreen = new TestScreenOne();
|
||||
screenStack = new OsuScreenStack(startScreen) { RelativeSizeAxes = Axes.Both };
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
screenStack,
|
||||
new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(10),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
breadcrumbs = new ScreenBreadcrumbControl(screenStack)
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
},
|
||||
titleText = new OsuSpriteText(),
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
breadcrumbs.Current.ValueChanged += screen => titleText.Text = $"Changed to {screen.NewValue.ToString()}";
|
||||
breadcrumbs.Current.TriggerChange();
|
||||
|
||||
waitForCurrent();
|
||||
pushNext();
|
||||
waitForCurrent();
|
||||
pushNext();
|
||||
waitForCurrent();
|
||||
|
||||
AddStep(@"make start current", () => startScreen.MakeCurrent());
|
||||
|
||||
waitForCurrent();
|
||||
pushNext();
|
||||
waitForCurrent();
|
||||
AddAssert(@"only 2 items", () => breadcrumbs.Items.Count() == 2);
|
||||
AddStep(@"exit current", () => screenStack.CurrentScreen.Exit());
|
||||
AddAssert(@"current screen is first", () => startScreen == screenStack.CurrentScreen);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
breadcrumbs.StripColour = colours.Blue;
|
||||
}
|
||||
|
||||
private void pushNext() => AddStep(@"push next screen", () => ((TestScreen)screenStack.CurrentScreen).PushNext());
|
||||
private void waitForCurrent() => AddUntilStep("current screen", () => screenStack.CurrentScreen.IsCurrentScreen());
|
||||
|
||||
private abstract class TestScreen : OsuScreen
|
||||
{
|
||||
protected abstract string NextTitle { get; }
|
||||
protected abstract TestScreen CreateNextScreen();
|
||||
|
||||
public TestScreen PushNext()
|
||||
{
|
||||
TestScreen screen = CreateNextScreen();
|
||||
this.Push(screen);
|
||||
|
||||
return screen;
|
||||
}
|
||||
|
||||
protected TestScreen()
|
||||
{
|
||||
InternalChild = new FillFlowContainer
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(10),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Text = Title,
|
||||
},
|
||||
new TriangleButton
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Width = 100,
|
||||
Text = $"Push {NextTitle}",
|
||||
Action = () => PushNext(),
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private class TestScreenOne : TestScreen
|
||||
{
|
||||
public override string Title => @"Screen One";
|
||||
protected override string NextTitle => @"Two";
|
||||
protected override TestScreen CreateNextScreen() => new TestScreenTwo();
|
||||
}
|
||||
|
||||
private class TestScreenTwo : TestScreen
|
||||
{
|
||||
public override string Title => @"Screen Two";
|
||||
protected override string NextTitle => @"One";
|
||||
protected override TestScreen CreateNextScreen() => new TestScreenOne();
|
||||
}
|
||||
}
|
||||
}
|
42
osu.Game.Tests/Visual/UserInterface/TestCaseTabControl.cs
Normal file
42
osu.Game.Tests/Visual/UserInterface/TestCaseTabControl.cs
Normal file
@ -0,0 +1,42 @@
|
||||
// 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.ComponentModel;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Screens.Select.Filter;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
[Description("SongSelect filter control")]
|
||||
public class TestCaseTabControl : OsuTestCase
|
||||
{
|
||||
public TestCaseTabControl()
|
||||
{
|
||||
OsuSpriteText text;
|
||||
OsuTabControl<GroupMode> filter;
|
||||
Add(filter = new OsuTabControl<GroupMode>
|
||||
{
|
||||
Margin = new MarginPadding(4),
|
||||
Size = new Vector2(229, 24),
|
||||
AutoSort = true
|
||||
});
|
||||
Add(text = new OsuSpriteText
|
||||
{
|
||||
Text = "None",
|
||||
Margin = new MarginPadding(4),
|
||||
Position = new Vector2(275, 5)
|
||||
});
|
||||
|
||||
filter.PinItem(GroupMode.All);
|
||||
filter.PinItem(GroupMode.RecentlyPlayed);
|
||||
|
||||
filter.Current.ValueChanged += grouping =>
|
||||
{
|
||||
text.Text = "Currently Selected: " + grouping.NewValue.ToString();
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
55
osu.Game.Tests/Visual/UserInterface/TestCaseTextAwesome.cs
Normal file
55
osu.Game.Tests/Visual/UserInterface/TestCaseTextAwesome.cs
Normal file
@ -0,0 +1,55 @@
|
||||
// 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;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Game.Graphics;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestCaseTextAwesome : OsuTestCase
|
||||
{
|
||||
public TestCaseTextAwesome()
|
||||
{
|
||||
FillFlowContainer flow;
|
||||
|
||||
Add(new ScrollContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = flow = new FillFlowContainer
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Full,
|
||||
},
|
||||
});
|
||||
|
||||
foreach (FontAwesome fa in Enum.GetValues(typeof(FontAwesome)))
|
||||
flow.Add(new Icon(fa));
|
||||
}
|
||||
|
||||
private class Icon : Container, IHasTooltip
|
||||
{
|
||||
public string TooltipText { get; }
|
||||
|
||||
public Icon(FontAwesome fa)
|
||||
{
|
||||
TooltipText = fa.ToString();
|
||||
|
||||
AutoSizeAxes = Axes.Both;
|
||||
Child = new SpriteIcon
|
||||
{
|
||||
Icon = fa,
|
||||
Size = new Vector2(60),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
// 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.ComponentModel;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
[Description("mostly back button")]
|
||||
public class TestCaseTwoLayerButton : OsuTestCase
|
||||
{
|
||||
public TestCaseTwoLayerButton()
|
||||
{
|
||||
Add(new BackButton());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
// 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.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Tests.Beatmaps.IO;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
public class TestCaseUpdateableBeatmapBackgroundSprite : OsuTestCase
|
||||
{
|
||||
private TestUpdateableBeatmapBackgroundSprite backgroundSprite;
|
||||
|
||||
[Resolved]
|
||||
private BeatmapManager beatmaps { get; set; }
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuGameBase osu, IAPIProvider api, RulesetStore rulesets)
|
||||
{
|
||||
Bindable<BeatmapInfo> beatmapBindable = new Bindable<BeatmapInfo>();
|
||||
|
||||
var imported = ImportBeatmapTest.LoadOszIntoOsu(osu);
|
||||
|
||||
Child = backgroundSprite = new TestUpdateableBeatmapBackgroundSprite { RelativeSizeAxes = Axes.Both };
|
||||
|
||||
backgroundSprite.Beatmap.BindTo(beatmapBindable);
|
||||
|
||||
var req = new GetBeatmapSetRequest(1);
|
||||
api.Queue(req);
|
||||
|
||||
AddStep("load null beatmap", () => beatmapBindable.Value = null);
|
||||
AddUntilStep("wait for cleanup...", () => backgroundSprite.ChildCount == 1);
|
||||
AddStep("load imported beatmap", () => beatmapBindable.Value = imported.Beatmaps.First());
|
||||
AddUntilStep("wait for cleanup...", () => backgroundSprite.ChildCount == 1);
|
||||
|
||||
if (api.IsLoggedIn)
|
||||
{
|
||||
AddUntilStep("wait for api response", () => req.Result != null);
|
||||
AddStep("load online beatmap", () => beatmapBindable.Value = new BeatmapInfo
|
||||
{
|
||||
BeatmapSet = req.Result?.ToBeatmapSet(rulesets)
|
||||
});
|
||||
AddUntilStep("wait for cleanup...", () => backgroundSprite.ChildCount == 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddStep("online (login first)", () => { });
|
||||
}
|
||||
}
|
||||
|
||||
private class TestUpdateableBeatmapBackgroundSprite : UpdateableBeatmapBackgroundSprite
|
||||
{
|
||||
public int ChildCount => InternalChildren.Count;
|
||||
}
|
||||
}
|
||||
}
|
39
osu.Game.Tests/Visual/UserInterface/TestCaseVolumePieces.cs
Normal file
39
osu.Game.Tests/Visual/UserInterface/TestCaseVolumePieces.cs
Normal file
@ -0,0 +1,39 @@
|
||||
// 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;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Overlays.Volume;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
public class TestCaseVolumePieces : OsuTestCase
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(VolumeMeter), typeof(MuteButton) };
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
VolumeMeter meter;
|
||||
MuteButton mute;
|
||||
Add(meter = new VolumeMeter("MASTER", 125, Color4.Blue) { Position = new Vector2(10) });
|
||||
AddSliderStep("master volume", 0, 10, 0, i => meter.Bindable.Value = i * 0.1);
|
||||
|
||||
Add(new VolumeMeter("BIG", 250, Color4.Red)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Position = new Vector2(10),
|
||||
});
|
||||
|
||||
Add(mute = new MuteButton
|
||||
{
|
||||
Margin = new MarginPadding { Top = 200 }
|
||||
});
|
||||
|
||||
AddToggleStep("mute", b => mute.Current.Value = b);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user