From ccef189b81569aa25b0d2ce26c03039be9a7aeea Mon Sep 17 00:00:00 2001 From: Alden Wu Date: Mon, 3 Oct 2022 18:19:05 -0700 Subject: [PATCH] Add barebones test for smoke --- .../metrics-skin/cursor-smoke@2x.png | Bin 0 -> 251 bytes .../Resources/old-skin/cursor-smoke.png | Bin 0 -> 2249 bytes osu.Game.Rulesets.Osu.Tests/TestSceneSmoke.cs | 97 ++++++++++++++++++ osu.Game.Rulesets.Osu/UI/SmokeContainer.cs | 4 +- 4 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 osu.Game.Rulesets.Osu.Tests/Resources/metrics-skin/cursor-smoke@2x.png create mode 100644 osu.Game.Rulesets.Osu.Tests/Resources/old-skin/cursor-smoke.png create mode 100644 osu.Game.Rulesets.Osu.Tests/TestSceneSmoke.cs diff --git a/osu.Game.Rulesets.Osu.Tests/Resources/metrics-skin/cursor-smoke@2x.png b/osu.Game.Rulesets.Osu.Tests/Resources/metrics-skin/cursor-smoke@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..b1380a47a47f4e1b293237f24f54606600a72964 GIT binary patch literal 251 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85p>QL70(Y)*K0--~>+>$B>G+x3d-b7z}wDZvFm0znsl}FGJhS zNhUL2p0i9pQWN3LxM3Pof-dWUsCWMx?mqphHvMN5)mND^EPTSXYMH5sl2F_0v2 ik^M!U07BoXGyGz#Jf&%6Kd%7Y#^CAd=d#Wzp$PzN-cP*% literal 0 HcmV?d00001 diff --git a/osu.Game.Rulesets.Osu.Tests/Resources/old-skin/cursor-smoke.png b/osu.Game.Rulesets.Osu.Tests/Resources/old-skin/cursor-smoke.png new file mode 100644 index 0000000000000000000000000000000000000000..5f7beae4e9dddd9493c3353ae209ea8c5679ca9c GIT binary patch literal 2249 zcmaJ@dstFw8b=WE5?-g&a_UIUrk21_P#{rJyk$6wkeA0z2~L6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pSw<*ErWSHM;J=*r;iMo!{W-ZK*Uy&UOU1RlL6Xu&)dy~;VhfZ>RU-}As z(>BB|69p~uAhtB`EBAPzts@3n_m>2ECE||hQ#W(F8BbaL>q-umKZx#@)W)NQHl68a zxy`}7aX(J4((BE(1=$A9Ta2&3s=@4>i$VTs%+s+hdTNK^C#%QHZkCoZU7y*o?>lPi zA5PWP=NJp-wc~5iiwJ9|p5%$9q91BTT>3hriu=npiH+f^t`5IpsAfC%lf?w;xd4yM9-hOI$o_@jD9zP8yOxP78RZ8ykxTuA6Z`3 zpZKu=fQZDnb|)82D`BnS&*RSfDf(5YomKO0Fs%G00r|oqOZGIUsPl&I%F-1Nddy|9 zna9WSfp7Z5iumR4H~y*Bny=y=ACC#ylAnJU_ZN(zYw+vii;Ny6!C&9nqYu>;>{;+S zKe~(>J^U|@PF8KPNa5vmK!-1Q66<6iL_3gqlc3$^o$oB7Q_Z5BoxuMy2~ zJTJ;Jz8^)oPHd@NtEFky8}B4b>K3O@Sd`-3i+=*qk>i7kb=Ihsz0*@?-6IF4&}`m? z50l-&o)!5_=`^p<59f;AM&q7L%^u5c!L^NTBzY%+kAB{o9QT%5|FJvxoZ4T$W~2wx ze1EwPf3xz5@sO|5E4gCR%Y|ci%f`7y@eQnh3|Bey9@Aa3?snU=TSKiw(QigL^bADr zqh|zXbCb32x%+A9epyueL{wzw4>e`=yMmhCup`U&jwTGfKJmsGvuA#KUz%M@!prGX zr58_m#tu~PxaYiCgGps`OV{qtFJS&{JH{*>#`YZ!Jf)%9YjUj29{|g{XbHV@s literal 0 HcmV?d00001 diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneSmoke.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneSmoke.cs new file mode 100644 index 0000000000..ce1cab3b9b --- /dev/null +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneSmoke.cs @@ -0,0 +1,97 @@ +// Copyright (c) ppy Pty Ltd . 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.Input.Events; +using osu.Framework.Input.States; +using osu.Framework.Testing.Input; +using osu.Game.Rulesets.Osu.UI; +using osuTK; + +namespace osu.Game.Rulesets.Osu.Tests +{ + public class TestSceneSmoke : OsuSkinnableTestScene + { + [Test] + public void TestSmoking() + { + AddStep("Create smoke", () => + { + SetContents(_ => + { + return new SmokingInputManager + { + RelativeSizeAxes = Axes.Both, + Size = new Vector2(0.95f), + Child = new TestSmokeContainer { RelativeSizeAxes = Axes.Both }, + }; + }); + }); + } + + private const double spin_duration = 5_000; + private const float spin_angle = 4 * MathF.PI; + + private class SmokingInputManager : ManualInputManager + { + private double? startTime; + + public SmokingInputManager() + { + UseParentInput = false; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + MoveMouseTo(ToScreenSpace(DrawSize / 2)); + } + + protected override void Update() + { + base.Update(); + + startTime ??= Time.Current; + + float fraction = (float)((Time.Current - startTime) / spin_duration); + + float angle = fraction * spin_angle; + float radius = fraction * Math.Min(DrawSize.X, DrawSize.Y) / 2; + + Vector2 pos = radius * new Vector2(MathF.Cos(angle), MathF.Sin(angle)) + DrawSize / 2; + MoveMouseTo(ToScreenSpace(pos)); + } + } + + private class TestSmokeContainer : SmokeContainer + { + private double? startTime; + private bool isPressing; + private bool isFinished; + + protected override void Update() + { + base.Update(); + + startTime ??= Time.Current; + + if (!isPressing && !isFinished && Time.Current > startTime + 0.1) + { + OnPressed(new KeyBindingPressEvent(new InputState(), OsuAction.Smoke)); + isPressing = true; + isFinished = false; + } + + if (isPressing && Time.Current > startTime + spin_duration) + { + OnReleased(new KeyBindingReleaseEvent(new InputState(), OsuAction.Smoke)); + isPressing = false; + isFinished = true; + } + } + } + } +} diff --git a/osu.Game.Rulesets.Osu/UI/SmokeContainer.cs b/osu.Game.Rulesets.Osu/UI/SmokeContainer.cs index f8551e46e9..449dd920d6 100644 --- a/osu.Game.Rulesets.Osu/UI/SmokeContainer.cs +++ b/osu.Game.Rulesets.Osu/UI/SmokeContainer.cs @@ -7,7 +7,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Input; using osu.Framework.Input.Bindings; using osu.Framework.Input.Events; -using osu.Game.Rulesets.Osu.Skinning; +using osu.Framework.Logging; using osu.Game.Rulesets.Osu.Skinning.Default; using osu.Game.Skinning; using osuTK; @@ -30,6 +30,8 @@ namespace osu.Game.Rulesets.Osu.UI { if (e.Action == OsuAction.Smoke) { + Logger.Log("holy moly"); + isSmoking = true; AddInternal(new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.Smoke), _ => new DefaultSmoke()));