From 57c423241669ff9f6c3856bc5c4c229f64949ef2 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Thu, 4 May 2017 11:58:37 +0300 Subject: [PATCH] Added testcase --- .../Tests/TestCaseIngameModsContainer.cs | 67 +++++++++++++++++++ .../osu.Desktop.VisualTests.csproj | 1 + osu.Game/Screens/Play/ModsContainer.cs | 5 ++ 3 files changed, 73 insertions(+) create mode 100644 osu.Desktop.VisualTests/Tests/TestCaseIngameModsContainer.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseIngameModsContainer.cs b/osu.Desktop.VisualTests/Tests/TestCaseIngameModsContainer.cs new file mode 100644 index 0000000000..3b2135fcbd --- /dev/null +++ b/osu.Desktop.VisualTests/Tests/TestCaseIngameModsContainer.cs @@ -0,0 +1,67 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Testing; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Colour; +using osu.Framework.Graphics.Sprites; +using osu.Game.Screens.Menu; +using OpenTK.Graphics; +using osu.Game.Screens.Play; +using osu.Framework.Allocation; +using osu.Game.Overlays.Mods; +using osu.Game.Database; +using osu.Game.Rulesets.Mods; +using OpenTK; + +namespace osu.Desktop.VisualTests.Tests +{ + internal class TestCaseIngameModsContainer : TestCase + { + public override string Description => @"Ingame mods visualization"; + + private ModSelectOverlay modSelect; + private ModsContainer modsContainer; + private RulesetDatabase rulesets; + + [BackgroundDependencyLoader] + private void load(RulesetDatabase rulesets) + { + this.rulesets = rulesets; + } + + public override void Reset() + { + base.Reset(); + + Add(modSelect = new ModSelectOverlay + { + RelativeSizeAxes = Axes.X, + Origin = Anchor.BottomCentre, + Anchor = Anchor.BottomCentre, + }); + + Add(modsContainer = new ModsContainer + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + AutoSizeAxes = Axes.Both, + Position = new Vector2(0, 25), + }); + + modSelect.SelectedMods.ValueChanged += SelectedMods_ValueChanged; + modSelect.SelectedMods.TriggerChange(); + + AddStep("ToggleModSelect", modSelect.ToggleVisibility); + foreach (var ruleset in rulesets.AllRulesets) + AddStep(ruleset.CreateInstance().Description, () => modSelect.Ruleset.Value = ruleset); + } + + private void SelectedMods_ValueChanged(System.Collections.Generic.IEnumerable newValue) + { + modsContainer.Clear(); + foreach (Mod mod in modSelect.SelectedMods.Value) + modsContainer.Add(mod); + } + } +} diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index 135e4596c7..58d8d50ed1 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -190,6 +190,7 @@ + diff --git a/osu.Game/Screens/Play/ModsContainer.cs b/osu.Game/Screens/Play/ModsContainer.cs index 204ed95873..5806a12ac9 100644 --- a/osu.Game/Screens/Play/ModsContainer.cs +++ b/osu.Game/Screens/Play/ModsContainer.cs @@ -56,5 +56,10 @@ namespace osu.Game.Screens.Play Scale = new Vector2(0.7f), }); } + + public void Clear() + { + iconsContainer.Clear(); + } } }