From 2db962dc33f26fe2a9f758b6c1e19b69021fc4e8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 28 Sep 2016 17:32:38 +0900 Subject: [PATCH] Add basic tweening mouse cursor. # Conflicts: # osu-framework --- osu-resources | 2 +- .../Graphics/Cursor/OsuCursorContainer.cs | 53 +++++++++++++++++++ osu.Game/OsuGameBase.cs | 3 +- osu.Game/osu.Game.csproj | 1 + 4 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 osu.Game/Graphics/Cursor/OsuCursorContainer.cs diff --git a/osu-resources b/osu-resources index 5cc6e0a311..fd4a3dd522 160000 --- a/osu-resources +++ b/osu-resources @@ -1 +1 @@ -Subproject commit 5cc6e0a311145a9871fb90d0d91226f3858bdce4 +Subproject commit fd4a3dd5223af6eb1c261af070b4220c9ff9ec2d diff --git a/osu.Game/Graphics/Cursor/OsuCursorContainer.cs b/osu.Game/Graphics/Cursor/OsuCursorContainer.cs new file mode 100644 index 0000000000..8f862d288a --- /dev/null +++ b/osu.Game/Graphics/Cursor/OsuCursorContainer.cs @@ -0,0 +1,53 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Cursor; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Transformations; +using osu.Framework.Input; + +namespace osu.Game.Graphics.Cursor +{ + class OsuCursorContainer : CursorContainer + { + protected override Drawable CreateCursor() => new OsuCursor(); + + protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) + { + ActiveCursor.Scale = new OpenTK.Vector2(1); + ActiveCursor.ScaleTo(1.2f, 100, EasingTypes.OutQuad); + return base.OnMouseDown(state, args); + } + + protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) + { + if (!state.Mouse.HasMainButtonPressed) + ActiveCursor.ScaleTo(1, 200, EasingTypes.OutQuad); + return base.OnMouseUp(state, args); + } + + class OsuCursor : AutoSizeContainer + { + public OsuCursor() + { + Origin = Anchor.Centre; + } + + public override void Load() + { + base.Load(); + + Children = new Drawable[] + { + new Sprite + { + Texture = Game.Textures.Get(@"Cursor/cursor") + } + }; + } + } + } + +} diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index c9398b15b7..20e7153575 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -4,6 +4,7 @@ using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Textures; using osu.Framework.IO.Stores; using osu.Game.Configuration; +using osu.Game.Graphics.Cursor; using osu.Game.Graphics.Processing; using osu.Game.Online.API; @@ -44,7 +45,7 @@ namespace osu.Game { Children = new Drawable[] { - new CursorContainer() + new OsuCursorContainer() } } }); diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 9510df2932..2b3c2fd30f 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -51,6 +51,7 @@ +